1
我開始我的符號表,它仍然是新的,但面對antlr給出的一些錯誤引用我的init_declarator規則。任何提示請init_declarator是一個非唯一的參考Antlr?
declaration
: declaration_specifiers init_declarator_list? SEMICOLON! {currentScope.defineVariable($init_declarator_list.name,$declaration_specifier.type);}
;
declaration_specifiers returns [Symbol type]
: (type_specifier{$type = $type_specifier.type;} |type_qualifier)+
;
init_declarator_list returns [Symbol name]
: init_declarator (COMMA init_declarator)*{$name = $init_declarator.name;} -> ^(INIT_DECLARATOR_LIST init_declarator+)
;
init_declarator returns [Symbol name]
: declarator (ASSIGN^ initializer)? {$name = $declarator.name;}
;
declarator returns [Symbol name]
: pointer? direct_declarator{$name = $direct_declarator.text;}
| pointer
;
direct_declarator returns [Symbol name]
: ( IDENTIFIER| LPAREN! declarator RPAREN! )
declarator_suffix* {$name = $IDENTIFIER.text;}
;
type_specifier returns [Symbol type] : (CONST^)? (VOID{return VoidType;} | CHAR {return CharType;}| INT{return IntType;} | FLOAT{return FloatType;});
非常感謝你;解決了我的問題。 – Undisputed007 2013-05-06 00:42:58