Why implement a lexer as a 2d array and a giant switch?
I’m slowly working to finish my degree, and this semester is Compilers 101. We’re using the Dragon Book. Shortly into the course and we’re talking about lexical analysis and how it can be implemented via deterministic finite automata (hereafter, DFA). Set up your various lexer states, define transitions between them, etc.
When to use ANTLR and when to use a parsing library
I’ve always wanted to learn how to write a compiler – I’ve decided to use ANTLR, and am currently reading through the book (its very good by the way)
When to use ANTLR and when to use a parsing library
I’ve always wanted to learn how to write a compiler – I’ve decided to use ANTLR, and am currently reading through the book (its very good by the way)
When to use ANTLR and when to use a parsing library
I’ve always wanted to learn how to write a compiler – I’ve decided to use ANTLR, and am currently reading through the book (its very good by the way)
When to use ANTLR and when to use a parsing library
I’ve always wanted to learn how to write a compiler – I’ve decided to use ANTLR, and am currently reading through the book (its very good by the way)
Passing context around AST nodes
I have various objects inside my AST, such as IfBlock
, FunctionBlock
, LogicExpression
, etc. All of those objects share a context, which is basically a hashmap with some variables. It’s a very simple language, created for learning purposes. I use this hashmap to make it possible that a FunctionBlock
is able to modify a variable later used in an LogicExpression
.