(xtext) Grammar's problem [message #1791939] |
Sun, 08 July 2018 10:51  |
Eclipse User |
|
|
|
Hello,
I'm trying to specify a grammar to the go language, but I'm having a few problems and I don't know how to correct it or even why it is happening.
This is my grammar until now:
Model:
elements+=int_lit;
int_lit:
decimal_lit | octal_lit | hex_lit
;
decimal_lit:
DECIMAL_DIGIT (DECIMAL_DIGIT)*
;
octal_lit:
"0" OCTAL_DIGIT*
;
hex_lit:
"0" ( "x" | "X" ) HEX_DIGIT HEX_DIGIT*
;
terminal IDENTIFIER:
LETTER (LETTER | DECIMAL_DIGIT)*
;
terminal A_F:
"A" .. "F" | "a" .. "f"
;
terminal LETTER:
A_F | 'g' .. 'z' | 'G' .. 'Z' | "_"
;
terminal HEX_DIGIT:
DECIMAL_DIGIT | A_F
;
terminal OCTAL_DIGIT:
('0'..'7')
;
terminal ESCAPED_CHAR:
"\\" ( "a" | "b" | "f" | "n" | "r" | "t" | "v" | "\\" | "\'" | "\"" )
;
terminal DECIMAL_DIGIT:
OCTAL_DIGIT | '8' | '9';
terminal BINARY_OP:
"||" | "&&" | REL_OP | ADD_OP | MUL_OP
;
terminal REL_OP:
"==" | "!=" | "<" | "<=" | ">" | ">="
;
terminal ADD_OP:
"+" | "-" | "|" | "^"
;
terminal MUL_OP:
"*" | "/" | "%" | "<<" | ">>" | "&" | "&^"
;
terminal UNARY_OP:
"+" | "-" | "!" | "^" | "*" | "&" | "<-"
;
These are the errors I get after running it:
error(208): ../org.xtext.example.mydsl/src-gen/org/xtext/example/mydsl/parser/antlr/internal/InternalMyDsl.g:283:1: The following token definitions can never be matched because prior tokens match the same input: RULE_OCTAL_DIGIT,RULE_DECIMAL_DIGIT
error(208): ../org.xtext.example.mydsl.ide/src-gen/org/xtext/example/mydsl/ide/contentassist/antlr/internal/InternalMyDsl.g:468:1: The following token definitions can never be matched because prior tokens match the same input: RULE_OCTAL_DIGIT,RULE_DECIMAL_DIGIT
Can someone explain me why this is happening and how can I prevent this type of error?
P.S: Sorry for any mistakes, english is not my mother language.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03815 seconds