Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Simple question about the lexer
Simple question about the lexer [message #1750314] Mon, 19 December 2016 20:03 Go to next message
Eric Salemi is currently offline Eric SalemiFriend
Messages: 35
Registered: September 2016
Location: Belgium
Member
The following DSL:

grammar com.septentrio.sandbox.flax.Flax with org.eclipse.xtext.common.Terminals
generate flax "http://www.septentrio.com/sandbox/flax/Flax"
Box:
    'label' name=QualifiedName
	items+=Item*;
Item:
	'item' name=ID;
QualifiedName:
	ID ('.'ID)*;


cannot parse this:

label flax.item.mybox
item Book
item MagicWand
item DiscoBall


It says "Missing RULE_ID at item".

I figured that any "keyword" cannot be used for matching the rule ID but I'm wondering why?

Also I noticed that the following piece of text seems valid:

label my     .     blue     .     box
item Book
item MagicWand
item DiscoBall


How can I disallow spaces in the QualifiedName rule?
Re: Simple question about the lexer [message #1750317 is a reply to message #1750314] Mon, 19 December 2016 20:13 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 11068
Registered: July 2009
Senior Member
you can use YourRule hidden(): ....

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Simple question about the lexer [message #1750318 is a reply to message #1750317] Mon, 19 December 2016 20:19 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 11068
Registered: July 2009
Senior Member
p.s. and you have to allow a keyword like this:

MyID: ID | 'keyword1' | ... | 'keywordn';

and then use MyID instead of ID

or you escape the keyword like

^mykeyword


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Simple question about the lexer [message #1750466 is a reply to message #1750318] Wed, 21 December 2016 10:46 Go to previous messageGo to next message
Eric Salemi is currently offline Eric SalemiFriend
Messages: 35
Registered: September 2016
Location: Belgium
Member
Hard-coding the keywords in the rule works (i.e no validation error) but IDEA still highlights it as it it were a keyword.

How can I disable this too?



Re: Simple question about the lexer [message #1750480 is a reply to message #1750466] Wed, 21 December 2016 14:20 Go to previous messageGo to next message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 11068
Registered: July 2009
Senior Member
You can't. You have to implement semantic highlighting (don't know if xtext in idea has support for that)

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Simple question about the lexer [message #1750540 is a reply to message #1750480] Thu, 22 December 2016 11:01 Go to previous messageGo to next message
Eric Salemi is currently offline Eric SalemiFriend
Messages: 35
Registered: September 2016
Location: Belgium
Member
Can I override semantic highlighting in Eclipse?
Re: Simple question about the lexer [message #1750541 is a reply to message #1750540] Thu, 22 December 2016 11:07 Go to previous message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 11068
Registered: July 2009
Senior Member
yes

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Previous Topic:mismatch between a grammar expression and its corresponding model
Next Topic:Build fails at p2.director
Goto Forum:
  


Current Time: Fri Aug 18 06:59:18 GMT 2017

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

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