I have an AST obtained for some Lua code from my grammar file, which is currently doing parsing and lexing for me. I want to add tree-like grammar to this, but since I'm using C #, I'm not sure how to do this. What is the main process for generating tree grammar code when you already wrote the parser and lexer?
UPDATE: I have the following grammar file:
tree grammar LuaGrammar;
options {
backtrack=true;
language=CSharp2;
tokenVocab=Lua;
filter=true;
ASTLabelType=CommonTree;
}
@lexer::namespace{}
@parser::namespace{}
dummyRule
: ^('=' x=. y=.) {};
is placed in the same directory as my main grammar file, which generates a fine. However, when I try to compile this, I get the following errors:
[02:54:06] error(143): C:\Users\RCIX\Desktop\AguaLua\Project\trunk\AguaLua\AguaLua\ANTLR Data\LuaGrammar.g:12:18: unknown or invalid action scope for tree grammar: lexer
[02:54:06] error(143): C:\Users\RCIX\Desktop\AguaLua\Project\trunk\AguaLua\AguaLua\ANTLR Data\LuaGrammar.g:13:19: unknown or invalid action scope for tree grammar: parser
Am I on the right track or completely off?
source
share