Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Bug parsing Xtext file
Bug parsing Xtext file [message #989381] Wed, 05 December 2012 22:48 Go to next message
Scott Hendrickson is currently offline Scott HendricksonFriend
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 49 times)
Re: Bug parsing Xtext file [message #989575 is a reply to message #989381] Thu, 06 December 2012 19:42 Go to previous messageGo to next message
Felix Feisst is currently offline Felix FeisstFriend
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

Re: Bug parsing Xtext file [message #989611 is a reply to message #989575] Thu, 06 December 2012 22:59 Go to previous message
Scott Hendrickson is currently offline Scott HendricksonFriend
Messages: 22
Registered: December 2009
Junior Member
That did it. Thank you!
-- Scott
Previous Topic:Reusing validation in GMF editor
Next Topic:Problem while cross-referencing. Solution review
Goto Forum:
  


Current Time: Sun Nov 23 02:26:59 GMT 2014

Powered by FUDForum. Page generated in 0.02003 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software