match comma separated IDs between double quotes [message #909661] |
Fri, 07 September 2012 10:21  |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.07893 seconds