parsing - An explanation of an ANTLR syntax required for JSON grammar -
at moment i'm investigating json antlr grammar antlr project wiki: http://www.antlr.org/wiki/display/antlr3/json+interpreter
string : '"' ( escapesequence | ~('\u0000'..'\u001f' | '\\' | '\"' ) )* '"' ; fragment escapesequence : '\\' (unicodeescape |'b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\') ;
what cannot why negate \\
, \"
in string
rule? matched escapesequence
anyway.
if change ~('\u0000'..'\u001f')
should mean same.
what missing?
this serves disallowing single unescaped backslashes , single unescaped double quotes. note these appear '\\'
, '\"'
, because @ least former disallowed in grammar literal well.
the escapesequence rule in contrast allows escaped backslashes , double quotes.
omitting exclusion of single unescaped double quote extend string tokenization last quote can found, should terminate @ first unescaped quote.
omitting exclusion of single unescaped backslash allow sequences beginning backslash, not supported escapesequences.
Comments
Post a Comment