I am currently trying to write a small DSL for my masters thesis and reached a point, where I am not sure how to proceed.
I have the following rule:
value
= "true"
/ "false"
/ ["] content:([^"])* ["]
/ first:[0-9]+ last:(.[0-9]+)?
/ [/] content:([^/])* [/]
/ f:field
Now I want to allow escaped double quotes and escaped slashes as well, something like that:
value
= "true"
/ "false"
/ ["] content:([\"] / [^"])* ["]
/ first:[0-9]+ last:(.[0-9]+)?
/ [/] content:([\/] / [^/])* [/]
/ f:field
But this leads me to an error:
Expected ["] or [^"] but end of input found
I think the problem is, that [\"] already "grabs" the closing double quote of a doublequoted string.
So. How do I make this work? :D
Thanks in advance!
Chris
--
You received this message because you are subscribed to the Google Groups "PEG.js: Parser Generator for JavaScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pegjs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hey!
First of all, thank you very much for your fast reply :)
I tried your suggested solution:
value
= "true"
/ "false"
/ '"' content:('\"'? !'"' .)* '"'
But still, when i have this as input:
string == "Blabl\"abla"
It tells me "Line 9, column 2: Expected "\"" or any character but end of input found."
With line 9 being the end of my input. I think the expression consumes all characters, now.
Thanks for you help.
Chris
Chris
Hey, sure i can do this.
Grammar: http://pastebin.com/zeNkPdvE
Input: http://pastebin.com/QBcHJLF7
Thank you very much
Chris
Chris