Builds out Awesome:
class Awesome: def name: "I'm Awesome" def awesomeness: 100 awesome = Awesome.new print(awesome.name) print(awesome.awesomeness)
... a mix of Ruby and Python, as an interpreter. "A couple of rules for our language:
Book moves pretty fast; at 78 pages, with multi-page listings, it really doesn't dive too deep into details. Feels like a pretty decent starting-off point for further self-exploration.
Demonstrates the use of lex (with links to Rex and JFlex) to build out lexer. Uses rexical to actually build out the lexer. Uses Ragel to build out the scanner. "It’s described as a State Machine Compiler: lexers, like regular expressions, are state machines." Goes into building a lexer by hand (in Ruby), using regular expressions to help with the parsing. Also demonstrates how to lex/parse significant indentation, which I haven't seen before.
Discusses briefly a prototype-based runtime, with a link to this paper on the subject.
LLVM from Ruby
Bytecode, VM types, prototyping a VM in Ruby.
Homoiconicity. Self-hosting. Resources. Solutions to the self-homework posed along the way.
Last modified 16 December 2022