Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » match comma separated IDs between double quotes
match comma separated IDs between double quotes [message #909661] Fri, 07 September 2012 14:21 Go to next message
Stefano Cottafavi is currently offline Stefano CottafaviFriend
Messages: 57
Registered: July 2009
Member
Hi all,
I need to match patterns like this

List "el1,el2,el3"

Trying something like this

ListRule:
'List' '"' values+=ID (',' values+=ID)* '"'

compile just fine but nothing is matched in the actual DSL file


Does it mess with STRING terminal (which I need too)?
Any suggestion?


Thanks,
Ste
Re: match comma separated IDs between double quotes [message #909732 is a reply to message #909661] Fri, 07 September 2012 16:56 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Yes. Your String terminal will eat the entire string. You will never get
a token for double quote '"'.

A good solution depends on other constructs in your language. You can
try to do this with a data rule (and not have a STRING token), or create
an external lexer. In this lexer you need to keep track of the "previous
interesting token" and then take alternative action.

The difficulty with the datarule is how to specify a good string rule
without ending up with a very complex rule that slows down parsing and
creates a huge node tree.

I have similar things I need to handle in support for the puppet
language. You can look at my implementation at cloudsmith/geppetto @
github (lexer/PPLexer.g) in the o.cloudsmith.geppetto.pp.dsl project.

Hope this helps.

Regards
- henrik
On 2012-07-09 16:21, Stefano Cottafavi wrote:
> Hi all,
> I need to match patterns like this
>
> List "el1,el2,el3"
>
> Trying something like this
>
> ListRule:
> 'List' '"' values+=ID (',' values+=ID)* '"'
>
> compile just fine but nothing is matched in the actual DSL file
>
>
> Does it mess with STRING terminal (which I need too)?
> Any suggestion?
>
>
> Thanks,
> Ste
Previous Topic:Error dialog in editor
Next Topic:Guidance on M2M transformation
Goto Forum:
  


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

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

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

Back to the top