antlr / antlr4

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files.
http://antlr.org
BSD 3-Clause "New" or "Revised" License
17.11k stars 3.28k forks source link

C++ codegen template incomplete: generation fails for $start, $stop #2207

Open azrdev opened 6 years ago

azrdev commented 6 years ago

test.g4:

grammar test;

test
    @after{ print( $stop.text); }
    :
    'foo'
    'bar'
    { print( $start.text ); }
    'baz'
    ;

What happens?

$ antlr4 -o /tmp/antlr/gen -Dlanguage=Cpp test.g4
error(33):  missing code generation template ThisRulePropertyRef_startHeader
error(33):  missing code generation template ThisRulePropertyRef_stopHeader

Versions:

$ antlr4
ANTLR Parser Generator  Version 4.7.1
[...]
$ java -version
openjdk version "1.8.0_144"
OpenJDK Runtime Environment (build 1.8.0_144-b01)
OpenJDK 64-Bit Server VM (build 25.144-b01, mixed mode)
azrdev commented 6 years ago

I get no error and the generated Parser.cpp looks fine when using instead $ctx.start.text etc.