Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Grmr2JavaReport

Generation of Java from Grammar file

This article describes the issues faced, while working on the generation of Java code from a grammar file using Gymnast, Emfatic and Grammar2Ecore frameworks.

Initial conditions

  • Eclipse plug-in project with a grammar file (SVG5.ast) is open as shown in Figure 1. Grammar file has a value for parserGenerator option as javacc.
  • srcGymnast (in Figure 1) is the source folder to which Gymnast runtime core plug-in is added manually. Please refer "Bugzilla entry 233805"
Grmr2JavaReport1.jpg
Figure 1 Project Explorer view
  • Dependent Plug-ins are added in the MANIFEST.MF file. Hence right clicking on the grammar file shows options like 'Generate .genmodel and Java', 'Generate .genmodel' etc. Refer Figure 2.
Grmr2JavaReport2.jpg
Figure 2 Context menu for grammar file

Issues

This section describes the issues faced and the workaround for the same.

Parser error in Gymnast generated Javacc file

After checking the well-formedness for the grammar file, click on 'Generate AST' from the context menu. Gymnast generates AST and Parser packages in the 'src' folder (refer Figure 3). Open the Gymnast generated Javacc file (in this case, file svg.jj in the parser package). The Outline view in eclipse shows parser error. This is because Gymnast additionally adds the word "public" in the generated JavaCC file. This issue has been reported in "Bugzilla entry 233803"

Grmr2JavaReport3.jpg
Figure 3 Parser error in JavaCC

Workaround for this issue is to manually remove the additional word "public" that causes the parser error in the Javacc file.

Incomplete generation of parser files

A smaller subsection

A smaller subsection

Back to the top