ANTLR exercise

Jump to: navigation, search

ANTLR is a candidate for replacing yacc/lex as the parser in ascend. This is needed for many reasons, of which a key one is generating C-code versions of models that are thread safe so we don't have to clean up the current model interpreter. There are several other very good reasons for ANTLR:

  • We want to do source-to-source translation of ascend models to other languages that give us optimization access (GAMS, AMPL, OSxL, Matlab).
  • Similarly, we want to be able to dump a canned C or Fortran version of a model for standalone (non-ascend) use.

The exercise is to demonstrate just the parsing with antlr of the current ascend language, with particular attention to the portions of the language defined in compiler/scanner.l (the lex/flex input file).

The current parser/scanner are in compiler/ascParse.y and compiler/scanner.l.

Notable differences between ascend and other languages are the NOTES feature of ascend and the fact that comments in ascend nest, unlike C/Java.

Building ascend and installing Antlrworks is probably a good place to start.