Skip to main content


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 offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
you can use YourRule hidden(): ....

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 offline Christian DietrichFriend
Messages: 14665
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 offline Christian DietrichFriend
Messages: 14665
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)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
yes

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:documentation on rule fragments
Next Topic:Reference to files from plugins or projects
Goto Forum:
  


Current Time: Tue Apr 23 15:55:11 GMT 2024

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

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

Back to the top