diff --git a/lexicalStructure.lex b/lexicalStructure.lex index d2b3bcf..f5315a1 100644 --- a/lexicalStructure.lex +++ b/lexicalStructure.lex @@ -6,8 +6,9 @@ %} DIGIT [0-9] -CHAR \\\\n|\\\\t|\\\'|[^'\\\n\t] -STRINGVAL CHAR | " " +CHAR \\n|\\t|\\'|[^'\n\t\\] +SCHAR \\n|\\t|\\\"|[^\"\n\\] + %% /* rules */ {DIGIT}+ {printf( "C_INTEGER: %s (%d)\n", yytext, atoi( yytext ) );} @@ -20,7 +21,7 @@ STRINGVAL CHAR | " " "false" {printf( "C_FALSE: %s (%d)\n", yytext, atoi( yytext ) );} -"{STRINGVAL}+" {printf( "C_STRING: %s (%d)\n", yytext, atoi( yytext ) );} +\"{SCHAR}+\" {printf( "C_STRING: %s (%d)\n", yytext, atoi( yytext ) );} .|\n diff --git a/simpleLiteralTest.a b/simpleLiteralTest.a index e74e4ee..e85644b 100644 --- a/simpleLiteralTest.a +++ b/simpleLiteralTest.a @@ -18,7 +18,22 @@ true '\'' '\t' '\\' - +'n' '\' - +'fdsf' +' +' +' ' ''' +"STRINGwithnotSPaces" +' ' +'\ ' +"J" +"" +" " +\"\" +"{SCHAR}" +"SCHAR" +"[SCHAR]" +"FINAL: I'd think this is a legal \"string\" that contains \n \t several escaped characters, isn't it?" +"I'd think this is a legal \"string\" that contains several \\n \t escaped characters, isn't it?"