ANTLR exercise

From ASCEND
Revision as of 14:00, 13 May 2010 by UploadBot (talk | contribs) (Restored page from Google Cache, uploaded by John Pye)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to 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.