Created by: gwideman, Oct 3, 2012 10:34 pm
Revised by: gwideman, Oct 5, 2012 3:06 am (8 revisions)

Chapter 5 Exploring real grammars

05.1 CSV

  • Works as per book.
  • The '-ps' comment is hazardous (overwrites input file) unless user knows full syntax. Same point served using -gui option.

05.2 JSON

  • Works as per book

05.3 DOT

  • Works as per book

05.4 Cymbol

  • Works as per book
  • GUI output is slightly different -- lower right corner around and below exprList.
    • Book interprets 'fact" as an expr, sample code does not.

05.5 R

  • Works as per book

Chapter 6 Decoupling grammars

06.2 Listeners

  • Fails due to the large copyright comment at beginning of t.properties
  • After removing the comment, works as per book.

06.3 Visitors

  • Fails due to the large copyright comment at beginning of t.properties
  • After removing the comment, works as per book.

06.4 Labeling Rule Alternatives

  • No particular exercise to run

06.5a Sharing info TestLEvalVisitor

  • Works as per book

06.5b TestLEvaluator

  • Error due to no \r in rule WS in LExpr.g4
  • When fixed, works as per book.

06.5c TestLEvaluatorWithProps

  • Assuming \r fix to LExpr.g4...
  • Following parallel steps as 06.05b, works.

Chapter 7 Validating program symbol usage

07.1 CSV

  • Example prints out additional info about fields before printing the field=value info shown in the book

07.2 JSON to XML

  • Works as per book

07.3 Cymbol call graph

  • Works as per book

07.4 Cymbol symbol usage

  • Works as per book
  • This example uses a number of additional supporting files (for scope). Would benefit from having its own separate directory.

Chapter 8 Error reporting and recovery

08.1 Parade; Simple

  • javac E*.java does nothing as there are no E*.java files
  • javac *.java compiles OK
  • single token insertion error example: error message doesn't quite match book. Doesn't report that it found class T.

08.2 TestE_Dialog

08.2b TestE_Listener2

  • Fails to compile for similar reasons:
    • TestE_Listener2.java:9: error: package com.sun.istack.internal does not exist
    • import com.sun.istack.internal.Nullable;

08.3a Simple

  • gtest Simple prog -gui with input: class { int i; }
    • Error message: "line 1:6 mismatched input '(' expecting ID" differs from book. More importantly, sample code does not go on to report "var i...clas <missing ID>" as shown in the book.
  • gtest Simple prog with input: class T {{ int i; }
    • Matches book OK
  • "messed up input" example matches book OK.
  • 'stops gobbling" example matches book OK
  • Error Recovery Failsafe
    • Works per book, except missing space in: no viable alternative at input 'intint'

08.3b Vec.g4

  • Works as per book

08.3c Pred.g4

  • I didn't finish this example

08.3d Simple.g4 Error recovery failsafe

Try example input using 08.03a

08.4 Error Alternatives

  • Works as per book

08.5 Altering ANTLR's Error Handling

  • Fails to compile:
    • TestBail.java:13: error: cannot find symbol
    • public static class BailELexer extends ELexer {
    • Probably in TestBail.java, ELexer should be SimpleLexer
      • Then sample code works like in book (pages 170-171)
      • Several changes needed in the text.
        • Probably the example grammar used to be called E.g4, and that was changed to Simple.g4?
    • I didn't pursueMyErrorStrategy

Chapter 9 Attributes and Actions

09.1a Expr.g4

Building an Interactive Calculator
  • Using the antlr4 command as written (forward slash: tools/Expr.g4) generates all files into top dir not subdir
  • Using instead a backslash (tools\Expr.g4) generates the java files to subdir, but the two tokens files to top dir.
  • javac -d . tools/*.java compiles all the java files
  • java tools.Calc works as shown in book

09.2 Accessing Token and Rule Attributes

  • Works as per book

09.3 Non-fixed keywords

  • Works as per book

Chapter 10 Altering the parse with semantic predicates

10.1 Enum

  • javac Enum*.java : fails to compile TestEnum.java
  • Otherwise, works as per book

10.2 Enum2

  • javac Enum2*.java : fails to compile TestEnum2.java
  • Fewer errors reported for HOT COLD example
  • Otherwise, works as per book

10.3 Recognizing T(i) in C++ CppStat

  • Works as per book

10.3b PredCppStat

  • Works as per book