I have downloaded ANTLR 1.3 and ANTLRWorks and can generate rules and syntax diagrams OK. When I try to generate code (e.g. by GenerateCode in ANTLRWorks or with java org.antlr.Tool Temp.g
I get
error(100): C:\temp\Temp.g 0:0: syntax error: codegen: <AST>: 0:0: unexpected end of subtree
I'm on Windows 7 beta, Java 1.6. I have not specifically set up a classpath as the distro implied ANTLRWorks worked out of the box.
EDIT This is a trivial grammar (generated by ANTLRWorks example) and yes, the file exists, with contents:
grammar Temp;
ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
开发者_运维问答 ;
I think this is because there were only lexical rules (of the type above). When I included:
prog: ID;
it worked
精彩评论