PDF

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.

Lexing

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.

Parsing

Then goes into parsing, discussing Bison/yacc, Lemon, ANTLR, and PEGs.

Runtime Model

Discusses briefly a prototype-based runtime, with a link to this paper on the subject.

Interpreter

Compilation

LLVM from Ruby

Virtual Machine

Bytecode, VM types, prototyping a VM in Ruby.

Conclusion

Homoiconicity. Self-hosting. Resources. Solutions to the self-homework posed along the way.


Tags: reading   language   antlr   ruby   python   langdev  

Last modified 16 December 2022