Skip to main content



      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 10:21 Go to next message
Eclipse UserFriend
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 12:56 Go to previous message
Eclipse UserFriend
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: Mon Jul 07 11:29:31 EDT 2025

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

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

Back to the top