Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Parser rule to allow apostrophe and quotes(generated editor marks apostrophes found in dsl as errors.)
Parser rule to allow apostrophe and quotes [message #687625] Wed, 22 June 2011 21:37 Go to next message
Chetan Kumar is currently offline Chetan KumarFriend
Messages: 44
Registered: July 2009
Member
folks,

i have a keyword in my dsl which is like so:
@description <value>
Value can be anything - one line description, multi-line description, with lot of characters used (' , " * : ^). The value is not enclosed in quotes (" | '). More importantly, value can have ' character as many number of times as possible.

I tried these set of rules:
ZDESCRIPTION : (ID(ZSYMBOL)*)+;

// allowed symbols
ZSYMBOL : ('"'|"'"|"'"|'<'|'/'|'>'|'\\'|','|'^'|'-'|'+'|'.'|':'|'*'|INT|'['|']');


while generating code i get these warnings: Decision can match input such as "'\''" using multiple alternatives: 2, 3As a result, alternative(s) 3 were disabled for that input.

I even tried "\\'" in ZSYMBOL but result is the same. Generated editor shows an error marker for something like this:
@description simple description copied from Pete's tag.
How to allow apostrophes in values ?

+ Chetan
Re: Parser rule to allow apostrophe and quotes [message #687665 is a reply to message #687625] Thu, 23 June 2011 00:15 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
You are probably using a terminal that eats the apostrophe (the String
terminal).

If your description ends with something distinct (or end of line), it is
probably ok with just a new terminal rule that eats until end of line.

The best is probably to solve this at the lexer level using an external
lexer as you need rules that allows unbalanced ' and ".

Regards
- henrik

On 6/22/11 11:37 PM, Chetan Kumar wrote:
> folks,
>
> i have a keyword in my dsl which is like so:
> @description <value>Value can be anything - one line description,
> multi-line description, with lot of characters used (' , " * : ^). The
> value is not enclosed in quotes (" | '). More importantly, value can
> have ' character as many number of times as possible.
>
> I tried these set of rules:
> ZDESCRIPTION : (ID(ZSYMBOL)*)+;
>
> // allowed symbols
> ZSYMBOL :
> ('"'|"'"|"'"|'<'|'/'|'>'|'\\'|','|'^'|'-'|'+'|'.'|':'|'*'|INT|'['|']');
>
> while generating code i get these warnings: Decision can match input
> such as "'\''" using multiple alternatives: 2, 3As a result,
> alternative(s) 3 were disabled for that input.
>
> I even tried "\\'" in ZSYMBOL but result is the same. Generated editor
> shows an error marker for something like this:
> @description simple description copied from Pete's tag. How to allow
> apostrophes in values ?
>
> + Chetan
>
Re: Parser rule to allow apostrophe and quotes [message #689345 is a reply to message #687665] Mon, 27 June 2011 13:37 Go to previous message
Chetan Kumar is currently offline Chetan KumarFriend
Messages: 44
Registered: July 2009
Member
thanks Henrik.

I think an 'until' rule will be the best fit for '@description'. However, there is no definite end for '@description' keyword. The start of the next '@<keyword>' is where '@description' ends. But if I define a terminal rule to consume everything until next '@' that will include '@' as part of '@description'.

+ Chetan
Previous Topic:[Xtext 2.0]Cross-References to work with existing EPackages
Next Topic:[xtext 2.0] importURI functionality totally messed up
Goto Forum:
  


Current Time: Fri Apr 19 09:35:13 GMT 2024

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

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

Back to the top