From cfd64648d9dd4d2b9741ed7d406fd15c82096700 Mon Sep 17 00:00:00 2001 From: Partho Bhattacharya Date: Fri, 7 Feb 2025 00:59:03 -0500 Subject: [PATCH] Added simple rules for literals based on documentation. Still have to test them and refine further --- lexicalStructure.lex | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lexicalStructure.lex b/lexicalStructure.lex index c41b8ce..706baca 100644 --- a/lexicalStructure.lex +++ b/lexicalStructure.lex @@ -7,6 +7,17 @@ %} %% -//rules +/* rules */ +[0-9]+ {printf( "C_INTEGER: %s (%d)\n", yytext, atoi( yytext ) );} + +"null" {printf( "C_NULL: %s (%d)\n", yytext, atoi( yytext ) );} + +['][.]['] | [']\\[nt'\\]['] {printf( "C_CHARACTER: %s (%d)\n", yytext, atoi( yytext ) );} /*using double \ per documentation to show escaped chars*/ + +"true" {printf( "C_TRUE: %s (%d)\n", yytext, atoi( yytext ) );} + +"false" {printf( "C_FALSE: %s (%d)\n", yytext, atoi( yytext ) );} + +["][.]+["] {printf( "C_STRING: %s (%d)\n", yytext, atoi( yytext ) );} %% -//user code +/* user code */