diff options
author | Dejan Jovanović <dejan.jovanovic@gmail.com> | 2010-02-02 19:12:09 +0000 |
---|---|---|
committer | Dejan Jovanović <dejan.jovanovic@gmail.com> | 2010-02-02 19:12:09 +0000 |
commit | a1ee56b7d09b4f6430a048c53a3b5bd0a194357f (patch) | |
tree | 010d94690407920b73998cb788c699f56aca3bd3 | |
parent | 2b02b131e49948180100c8ef86655cb204f529b1 (diff) |
Adding support for escapes in string literals (strings like "\n\t\"")
-rw-r--r-- | src/parser/smt/smt_lexer.g | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/parser/smt/smt_lexer.g b/src/parser/smt/smt_lexer.g index bc8c05fdd..0b38e1c2e 100644 --- a/src/parser/smt/smt_lexer.g +++ b/src/parser/smt/smt_lexer.g @@ -49,13 +49,14 @@ tokens { C_EXTRASORTS = ":extrasorts"; C_EXTRAFUNS = ":extrafuns"; C_EXTRAPREDS = ":extrapreds"; + C_NOTES = ":notes"; } /** * Matches any letter ('a'-'z' and 'A'-'Z'). */ protected -ALPHA options{ paraphrase = "a letter"; } +ALPHA options { paraphrase = "a letter"; } : 'a'..'z' | 'A'..'Z' ; @@ -64,7 +65,7 @@ ALPHA options{ paraphrase = "a letter"; } * Matches the digits (0-9) */ protected -DIGIT options{ paraphrase = "a digit"; } +DIGIT options { paraphrase = "a digit"; } : '0'..'9' ; @@ -142,12 +143,20 @@ NEWLINE options { paraphrase = "a newline"; } NUMERAL options { paraphrase = "a numeral"; } : (DIGIT)+ ; + +/** + * Matches an allowed escaped character. + */ +protected ESCAPE + : '\\' ('"' | '\\' | 'n' | 't' | 'r') + ; /** - * Matches a double quoted string literal. No quote-escaping is supported inside. + * Matches a double quoted string literal. Escaping is supported, and escape + * character '\' has to be escaped. */ STRING_LITERAL options { paraphrase = "a string literal"; } - : '\"' (~('\"'))* '\"' + : '"' (ESCAPE | ~('"'|'\\'))* '"' ; /** |