ViPER JavaCC
From ViPER Wiki
The ViPER JavaCC feature delivers a modified version of the JavaCC parser generator (version 4) together with an Eclipse JavaCC builder integration. As its implementation is based on the JavaCC project, which is provided by Sun Microsystems under Berkeley Software Distribution (BSD) license, and the Eclipse JavaCC Plug-in, which is provided under Lesser GNU Public License (LPGL), it is - unlike all of the ViPER IDE related code - also made available under terms of the Lesser GNU Public License (LPGL).
The ViPER JavaCC parser generator contains the following modifications in contrast to the default JavaCC parser generator:
- The GENERATE_OTHER_FILES option can be specified to suppress the otherwise generated ParseException, SimpleCharStream, Token and TokenMgrError classes. In context of ViPER IDE, GENERATE_OTHER_FILES should always be set to false and the respective classes provided by ViPER Core (package sc.viper.core.parser) should be imported.
- Productions do have to be grouped into enclosing PRODUCTIONS_BEGIN(<name of production group>) and PRODUCTIONS_END(<name of production group>) tags, similar to the PARSER_BEGIN(<name of parser file>) and PARSER_END(<name of parser file>) tags specified by the default JavaCC. At least one such production group has to be present in a .jj grammar file, it may be valid to have more than one (to group productions after certain aspects).
- Productions contained in other .jj grammar files may be imported into a .jj grammar file. The imports have to be inserted into the .jj grammar file after the parser (specified via PARSER_BEGIN(<name of parser file>) and respective closing tag) and before any local productions (specified via PRODUCTIONS_BEGIN(<name of production group>) and respective closing tag). The import of productions is done by specifying an IMPORT_PRODUCTIONS(<name of .jj grammar file>)(<name of production group>) statement, where the name of the grammar file is provided in form of a fully qualified class name without the .jj suffix (e.g. sc.viper.vme.ui.structure.UML2Tokens). All import statements have to be grouped together in an input block that is specified via PRODUCTIONS_IMPORT_BEGIN(<identifier>) and PRODUCTIONS_IMPORT_END(<identifier>) tags.
- As import functionality of productions allows to construct modular parsers, .jj grammar files may not contain any parser at all (no PARSER_BEGIN(<name of parser>) and respective closing tag) but only productions that are imported by other .jj grammar files.
THERE IS ONE IMPORTANT RESTRICTION TO THE INCLUDE STATEMENT: As ant is not capable of resolving the bundle references, it cannot evaluate the list of required bundles for a given plugin. Therefore, ant searches all plugins for the imported .jj file. Therefore, all grammar file names (fully qualified) have to be globally unique in order to get the headless build work correctly.
