Allow whitespace surrounding the root tag, empty arrays and tuples, and literal backslashes in strings

master
Sven Slootweg 7 years ago
parent 23e8ae960a
commit c42d9ade39

@ -1,5 +1,8 @@
start start
= deriveTag = _ root:deriveTag _ { return root; }
_
= [ \n\r\t]*
value value
= deriveTag = deriveTag
@ -8,7 +11,7 @@ value
/ string / string
multipleItems multipleItems
= item:value subsequentItems:("," value)* { return [item].concat(subsequentItems.map(subsequentItem => subsequentItem[1])); } = item:value? subsequentItems:("," value)* { return (item != null) ? [item].concat(subsequentItems.map(subsequentItem => subsequentItem[1])) : []; }
deriveTag deriveTag
= "Derive(" items:multipleItems ")" { return {type: "deriveTag", items: items}; } = "Derive(" items:multipleItems ")" { return {type: "deriveTag", items: items}; }
@ -23,8 +26,9 @@ string
= '"' chars:stringCharacter* '"' { return chars.join(""); } = '"' chars:stringCharacter* '"' { return chars.join(""); }
stringCharacter stringCharacter
= !('"' / "\\") char:. { return char; } = !('"' / "\\") char:. { return char; } // Prefer a non-backslash character...
/ stringEscapedQuote { return '"'; } / stringEscapedQuote { return '"'; } // ... then an escaped quotation mark...
/ !('"') char:. { return char; } // ... and finally any other character that doesn't terminate the string.
stringEscapedQuote stringEscapedQuote
= '\\"' = '\\"'

Loading…
Cancel
Save