Hello! I’ve been poking through the compiler sourc...
# compiler
a
Hello! I’ve been poking through the compiler source code and have a couple questions. 1) It looks like you are lexing via JFlex instead of Antlr. Is this correct? Any reasons for one over the other? 2) Is the parser implemented by hand? I’ve seen some parsing examples where you can generate a simple parser from grammar rules. Did this not give you enough control?
i
The answers are boring: it does not matter. The lexer is written once and never changes. A recursive descent parser can be written at the same speed as the grammar for something like antlr. And also rarely changes, like once per couple of years.
🙏 1
a
Cool thanks!
m
Halloween's was just a couple of days ago so I feel like I can revive this old thread 👻. Isn't an argument for auto-generating the parser that it'll be always in sync with the spec?
And also that if
antlr
is considered "proven", it removes the possibilty of human mistakes?
i
That would be true, if the spec covered experimental features. It does not. But the parser does. For example: https://kotlinlang.org/spec/syntax-and-grammar.html#grammar-rule-classModifier does not have modifier
inline
, but inline classes are supported in the parser.
🙏 1
m
Devil's advocate: you could have multiple version of the spec 🙂
Not saying you should but there could be one experimental
antlr
grammar. I can see how that could slow down implementation a bit though