5 ms·
The reason for LISP or SCHEME as the tutorial is that parsing is easy and doesn't call for Flex/Bison. There is a level of semantics also that if you don't stra
by cardiffspaceman 10y ago
The reason for LISP or SCHEME as the tutorial is that parsing is easy and doesn't call for Flex/Bison. There is a level of semantics also that if you don't strain yourself on edge cases you can do a decent interpreter or compiler pretty quickly.
Without making this post long I could "tempt" or encourage you by suggesting that if you take the outermost paren pair off an s-expression, you sortof have a language of function application:
defun fact n = if (< n 2) 1 (* n (fact (- n 1)))
I think there is an SRFI for Scheme that proposes something like that plus offside rule to get rid of parens.
You could get rid of more parens by adding operator precedence to the syntax (and that offside rule would help too), but now you're making the parsing interesting instead of making the execution interesting.
- kazinator 10y agoAnd the reason you don't want to drag in Flex and Yacc/Bison is that then the bulk of the course will revolve around the banal issues surrounding syntax, rather than semantics: high in heat, low in light. Not even the smarter side of syntax (abstract syntax), but rather character-and-token level syntactic sugaring.
- aidenn0 10y agoA recursive decent parser for a prefix language is not significantly complicated by using C style function calls.