Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Can't ignore WS in rule(even 'hidden()' doesn't help)
Can't ignore WS in rule [message #685107] Thu, 16 June 2011 20:39 Go to next message
Chetan Kumar is currently offline Chetan KumarFriend
Messages: 44
Registered: July 2009
Member
Hi,

I have these rules in my grammar:

Category :
    '@keyword' name=ZID
    '@keyword2' name2=ZSTRING
;

ZID: ID('-'ID)*; // i need '-'s

// stuff after '@keyword' is like a sentence with spaces, tabs, newlines.
// its not enclosed in "" or ''
ZSTRING: ID((' 'ID)|('\t'ID)|('\n'ID))*;


Now, considering these rules the following DSL text is marked with errors
@keyword my-variable

Error:
Mismatched input ' ' expecting RULE_ID


Wat' strange is: I don't get that error if I remove the ZSTRING rule and change
Category rule as:
Category :
    '@keyword' name=ZID
    '@keyword2' name2=STRING
;


Can anybody throw some light on this ? also, is there any predefined type that I can use for returing strings (not enclosed in quotes) ?

thanks,
Chetan Kumar

[Updated on: Thu, 16 June 2011 20:40]

Report message to a moderator

Re: Can't ignore WS in rule [message #685110 is a reply to message #685107] Thu, 16 June 2011 20:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
Hi,

what about (fixing hidden tokens / overwriting of the WS terminal)

ZID hidden (): ID('-'ID)*; // i need '-'s

// stuff after '@keyword' is like a sentence with spaces, tabs, newlines.
// its not enclosed in "" or ''
ZSTRING hidden (): ID (WS ID)*;


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Can't ignore WS in rule - solved [message #685118 is a reply to message #685107] Thu, 16 June 2011 21:01 Go to previous messageGo to next message
Chetan Kumar is currently offline Chetan KumarFriend
Messages: 44
Registered: July 2009
Member
I looked into this forum entry and solved my problem.
I think the problem was that one of my rules had whitespace, newline, and tab in its definition.
I changed ZSTRING rule to this:
ZSTRING: ID(ID)*;

white spaces are now ignored.

btw: is that string rule alrite ? Any better suggestions ?
Re: Can't ignore WS in rule [message #685499 is a reply to message #685110] Fri, 17 June 2011 16:30 Go to previous message
Chetan Kumar is currently offline Chetan KumarFriend
Messages: 44
Registered: July 2009
Member
Hi Christian,

Christian Dietrich wrote on Thu, 16 June 2011 16:48
Hi,

what about (fixing hidden tokens / overwriting of the WS terminal)

ZID hidden (): ID('-'ID)*; // i need '-'s

// stuff after '@keyword' is like a sentence with spaces, tabs, newlines.
// its not enclosed in "" or ''
ZSTRING hidden (): ID (WS ID)*;


~Christian

I removed whitespace from ZSTRING rule and it works. Thanks!

+ Chetan
Previous Topic:Problem with content assist and scoping
Next Topic:Running mwe2 after saving DSL
Goto Forum:
  


Current Time: Fri Apr 26 19:24:41 GMT 2024

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

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

Back to the top