finished string and char updates and testing updates task 03

This commit is contained in:
Partho Bhattacharya
2025-02-10 13:12:46 -05:00
parent 6c3951b6ab
commit f4a86f0de7
2 changed files with 21 additions and 5 deletions

View File

@ -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

View File

@ -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?"