How would one allow for single and double quotes, as well as unicode characters inside of a PEG.js grammar definition? To be more specific, I'd like to be able to capture strings that can contain both single and double quotes (will most likely have to be \ escaped) and all unicode characters.
At the moment I have something like the following:
_ name:$(PROP_ASCII+) CHAR_SQ val:$(PROP_ASCII_INNER*) CHAR_SQ
which would capture something like
key'value'
PROP_ASCII* is defined as
PROP_ASCII
= [!-&(-<>-~]
PROP_ASCII_INNER
= [ -&(-~]
So this works fine and dandy if value contains standard ASCII characters and does not contain single quotes... But I'd like to support what I've described above, so something like this would become possible:
key'somé\'value\'☂'
Thoughts?
!('"' / "\\")
inside of the (Double/Single)StringCharacter definition, simply changing the unicode sequences[\x20-\x21\x23-\x5B\x5D-\uFFFF]
to.
works. This way it also ingests unique characters> \uFFFF
. – Terryl