> The lexical grammars of Python and Haskell are not regular. What does that
> mean, and why aren’t they?
Regular languages can be parsed with an FSM, but Python and Haskell's grammars
more context than that to be determined.
> Aside from separating tokens—distinguishing `print foo` from
> `printfoo`—spaces aren’t used for much in most languages. However, in a
> couple of dark corners, a space does affect how code is parsed in
> CoffeeScript, Ruby, and the C preprocessor. Where and what effect does it
> have in each of those languages?
Spaces do matter for the closing of heredocs in Ruby...
> Our scanner here, like most, discards comments and whitespace since those
> aren’t needed by the parser. Why might you want to write a scanner that does
> not discard those? What would it be useful for?
Formatting or documentation generation?
FossilOrigin-Name: 5738a38b8f15d1aca61212966ff990de59a03502f183a7400bf4f2ea14ae5af6
> 2. This informal introduction leaves a lot unspecified. List several open
> questions you have about the language’s syntax and semantics. What do you
> think the answers should be?
- String escaping, Unicode?
- Interaction with the system (i.e., exit status code)?
- What are the built-in errors?
- What happens when we all a function with the wrong number of arguments? It
would be cool if it were curried...
- Multiple inheritance?
> 3. Lox is a pretty tiny language. What features do you think it is missing
> that would make it annoying to use for real programs? (Aside from the
> standard library, of course.)
No way to interact with the outside world, whether that's files, stdin, or
networking. No parallelization. Somewhat reminiscent of Lua, really.
FossilOrigin-Name: 394141a0b92ff762adcc54b53e4a04786a5374ad42fe312be5c20b6666dbb3f5
> 1. Pick an open source implementation of a language you like. Download the
> source code and poke around in it. Try to find the code that implements the
> scanner and parser. Are they handwritten, or generated using tools like Lex
> and Yacc? (.l or .y files usually imply the latter.)
Of course, I have to pick out Ruby's [parse.y][parse.y]. The file is 14k lines
long, so I have no idea where the scanner and parser are, and I think that
Bison is used for Ruby's YACC?
[parse.y]: https://github.com/ruby/ruby/blob/master/parse.y
> 2. Just-in-time compilation tends to be the fastest way to implement
> dynamically typed languages, but not all of them use it. What reasons are
> there to not JIT?
Probably simplicity first and foremost? I assume there's also at least slight
negative tradeoffs for runtime/memory as well.
> 3. Most Lisp implementations that compile to C also contain an interpreter
> that lets them execute Lisp code on the fly as well. Why?
Is this because Lisp has such a heavy REPL history/culture?
FossilOrigin-Name: 7177648dc716668fe15ac77d3f1ad1c03e5a3d7f6180415ee78de6b61fd9e0e9