Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Error "missing EOF at <token>"
Error "missing EOF at <token>" [message #1063740] Fri, 14 June 2013 01:32 Go to next message
K Kumar is currently offline K KumarFriend
Messages: 18
Registered: March 2011
Junior Member
Hi Team,

I'm trying to write xtext grammar for Salesforce SOSL language but bumping into an error. Sosl language reference is at http://www.salesforce.com/us/developer/docs/soql_sosl/

The usecase I'm trying is
find {test}

and grammar I have so far is
grammar com.salesforce.dsl.sosl.Sosl hidden(WS, ML_COMMENT, SL_COMMENT)

import "http://www.eclipse.org/emf/2002/Ecore"
generate sosl "http://www.salesforce.com/dsl/sosl/Sosl"

SoslFile:
	soslStatements+=SoslStatement*
;

SoslStatement:
	'find' ('{' searchQuery=SearchQuery '}'|'\'' searchQuery=SearchQuery '\'')
;

SearchQuery:
	terms+=SEARCH_WORD+	
;

terminal ML_COMMENT: 
	'/*' -> '*/'
;

terminal SL_COMMENT: 
	'//' !('\n'|'\r')* ('\r'? '\n')?
;

terminal WS: 
	(' '|'\t'|'\r'|'\n')+
;

terminal SEARCH_WORD:
	( '\\' SEARCH_RESERVED_CHARS | !SEARCH_RESERVED_CHARS)*
; 

terminal fragment SEARCH_RESERVED_CHARS:
	('?'|'&'|'|'|'!'|'{'|'}'|'['|']'|'('|')'|'~'|'*'|':'|'"'|'\''|'+'|'-'|'\\')
;


After compiling and running the app, I'm getting below error
missing EOF at 'find '

Some Notes:
1. I'm not using Xtext default terminals but have copied applicable ones (WS, ML and SL Comment).

2. SEARCH_RESERVED_CHARS is fragment to parse information in this page http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_sosl_find.htm

Any help is appreciated.

Thanks,
Kumar
Re: Error "missing EOF at <token>" [message #1063761 is a reply to message #1063740] Fri, 14 June 2013 06:55 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1159
Registered: July 2009
Senior Member
Hi,

generally, it is not a good idea to mess with terminal rules in the very beginning. You may think that "find" will be interpreted as a keyword, but due to your SEARCH_WORD definition it will be a SEARCH_WORD-token.

The very first step when reading a model is lexing. The document will be chopped into tokens and the lexer will make them as long as possible. "find" is a possible token (keyword) but "find " is longer and fits the SEARCH_WORD definition as that swallows up EVERYTHING that is not a special character.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Error "missing EOF at <token>" [message #1063765 is a reply to message #1063761] Fri, 14 June 2013 07:21 Go to previous message
K Kumar is currently offline K KumarFriend
Messages: 18
Registered: March 2011
Junior Member
Hi Alex,

Thank you for the reply. I understand now about the lexing and how it would consume pretty much everything till first { and treat it as SEARCH_WORD.

Can you please advise how do I go about a grammar to parse an example like below?
FIND {MyProspect AND ("John Smith" OR MyCompany)}


Thanks,
Kumar
Previous Topic:Problem while deploying xtext plugin
Next Topic:Scoping: Import EObjects from external java-written Provider
Goto Forum:
  


Current Time: Sat Nov 22 03:04:23 GMT 2014

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

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