开发者

Problem generating code with ANTLR 1.3 / ANTLRWorks

开发者 https://www.devze.com 2022-12-09 13:55 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号