Reputation: 103
How do I describe a quoted string (like in C, Java, etc) in EBNF notation?
I was thinking of this (see below), but the AnyCharacter part will also match the double quotes ("
).
QuotedString = '"' AnyCharacter* '"' ;
In other words, how do I match all characters except the double quote character ("
), but still allow escapes (/"
)?
Upvotes: 4
Views: 1284
Reputation: 15
You could do something like
string = " printable-chars | nested-quotes "
where
printable chars = letter | digit | ~ @ # % _ $ & ' - + /
where
letter = A..Z | a..z | extended ascii
and
digit = 0..9
I think you've got the general idea
Upvotes: 0