Bug parsing Xtext file [message #989381] |
Wed, 05 December 2012 22:48 |
Scott Hendrickson Messages: 22 Registered: December 2009 |
Junior Member |
|
|
Here is my xtext file to parse PROLOG programs:
grammar org.archstudio.prolog.xtext.Prolog with org.eclipse.xtext.common.Terminals
generate prolog "http://www.archstudio.org/prolog/xtext/Prolog"
Program:
(clauses+=Clause)* (query=Query)?;
Clause:
(predicates+=Predicate) (':-' predicates+=Predicate (',' predicates+=Predicate)*)? '.';
Query:
'?-' predicates+=Predicate (',' predicates+=Predicate)* '.';
Predicate:
functor=Functor '(' terms+=Predicate (',' terms+=Predicate)* ')'
| terms+=Term functor=Functor terms+=Predicate;
Term:
(atom=ATOM) | (number=NUMBER) | ('\'' string=STRING '\'') | (variable=VARIABLE)
| (list?='[' (terms+=Predicate (',' terms+=Predicate)* ('|' rest=Predicate)?)? ']');
Functor:
name=(OPERATOR | ATOM);
terminal OPERATOR:
'==' | '\\=' | '.';
terminal NUMBER:
'-'? ('0'..'9')+;
terminal ATOM:
'a'..'z' ('0'..'9' | 'a'..'z' | 'A'..'Z' | '_')*;
terminal VARIABLE:
('A'..'Z' | '_') ('0'..'9' | 'a'..'z' | 'A'..'Z' | '_')*;
terminal STRING:
'a'..'z' | 'A'..'Z' |
'_' | '0'..'9' | '+' | '-' | '*' | '/' | '\\' | '^' | '~' | ':' | '.' | '?' | '@' | '#' | '$' | '&';
When I try to Generate Xtext Artifacts, it ends with an error of:
error(208): ../org.archstudio.prolog.xtext/src-gen/org/archstudio/prolog/xtext/parser/antlr/internal/InternalProlog.g:682:1: The following token definitions can never be matched because prior tokens match the same input: RULE_INT
The problem is that I'm not using the INT rule, so it shouldn't complain about it (right?).
Is this a bug, is there a workaround?
Thank you,
-- Scott
-
Attachment: Prolog.xtext
(Size: 1.08KB, Downloaded 136 times)
|
|
|
Re: Bug parsing Xtext file [message #989575 is a reply to message #989381] |
Thu, 06 December 2012 19:42 |
Felix Feisst Messages: 20 Registered: February 2012 Location: Germany |
Junior Member |
|
|
When you created your grammar, xtext imported (by default) some terminals. Your terminals do conflict with these terminals, that's why you get the error message.
The import is done by
with org.eclipse.xtext.common.Terminals
To see which terminals are defined in this grammar consult the manual or just hit F3 when your cursor is over the import.
To get rid of your error just remove the "with ...".
Note that you have to import the basic ecore types when you're no longer referencing the base grammar. This is done by:
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
Felix
[Updated on: Fri, 07 December 2012 07:23] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04166 seconds