Shevek (shevek) wrote,
Shevek
shevek

Having spent some time using antlr, I have come to the regrettable conclusion that whatever the task, antlr is the wrong way to address it. As is common with LL parser generators, it has no clear distinction between the syntax and the semantics of the target language; the grammar specification is overcomplex and underpowered, and involves an unholy mixture of code and data; and the API is generally a botch job which leaves one to invent a great many uninteresting wheels.

The right answer is almost always SableCC.

Protip: When using sablecc, feel free to add arbitrary semantic constructs to your AST, even if they aren't the target of any transformation the CST. You can transform to these constructs later in your semantic analyzer visitor, and it's an elegant way of generating the extra classes and visitor hooks. This trick also allows one to resolve parser ambiguities in an early-stage visitor.
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 3 comments