Evaluating rules

In this section, you will learn how to use the interpreter to test and evaluate rules.

Note: The use of the interpreter is for fast prototyping of ANTLR grammars. The ANTLR built-in interpreter can't deal with predicates, if your grammar contains predicates (or if you see FailPredicateException when you are evaluating rules) you need to launch the grammar in Run/Debug mode.

  1. Double click in Expr.g file to open it with the ANTLR editor
  2. Select the Interpreter page
  3. Using the ANTLR Interpreter

    In the Rule Panel you'll see all the rule available for the current grammar

    In the Test Panel you'll see all test defined for each rule available in the current grammar

    In the Input Panel you'll see the input for the current test case

  4. In the input panel type: 3 + 6 and hit enter. Then click on the "Run" button
  5. Using the ANTLR Interpreter

  6. Let's take a look at the matching tree generated by the interpreter
  7. Using the ANTLR Interpreter

  8. You can select any node of the tree to see the corresponding rule or input text that match it.
SourceForge.net Logo