From a1ee56b7d09b4f6430a048c53a3b5bd0a194357f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Dejan=20Jovanovi=C4=87?= Date: Tue, 2 Feb 2010 19:12:09 +0000 Subject: [PATCH] Adding support for escapes in string literals (strings like "\n\t\"") --- src/parser/smt/smt_lexer.g | 17 +++++++++++++---- 1 file 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 | ~('"'|'\\'))* '"' ; /** -- 2.30.2