From 57d52922d2877edbbd83b697479845b3e2e105f6 Mon Sep 17 00:00:00 2001 From: Partho Bhattacharya Date: Wed, 19 Feb 2025 02:18:05 -0500 Subject: [PATCH] fixed comment issues --- lexicalStructure.lex | 5 +++-- tests/test_comment_issues.alpha | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 tests/test_comment_issues.alpha diff --git a/lexicalStructure.lex b/lexicalStructure.lex index 0763c99..7857730 100644 --- a/lexicalStructure.lex +++ b/lexicalStructure.lex @@ -13,7 +13,8 @@ #endif %} -COM ([^*]|\*+[^)*])* +STARCOM [^\*]|\*+[^\)\*]+ +PARENCOM [^\)]|[^\*\)]+\)+ ID [A-Za-z_][0-9A-Za-z_]* DIGIT [0-9] CHAR \\n|\\t|\\'|[^'\n\t\\]|\\\\ @@ -62,7 +63,7 @@ SCHAR \\n|\\t|\\\"|[^\"\n\\] {DIGIT}+ {if(DEBUG) {printf( "C_INTEGER: %s (%d)\n", yytext, C_INTEGER);} else {return C_INTEGER;}} '{CHAR}' {if(DEBUG) {printf( "C_CHARACTER: %s (%d)\n", yytext, C_CHARACTER);} else {return C_CHARACTER;}} \"{SCHAR}*\" {if(DEBUG) {printf( "C_STRING: %s (%d)\n", yytext, C_STRING);} else {return C_STRING;}} -"(*"{COM}"*)" {if(DEBUG) {printf( "COMMENT: %s (%d)\n", yytext, COMMENT);} else {return COMMENT;}} +\(\*{STARCOM}*\*\)|\(\*{PARENCOM}*\*\) {if(DEBUG) {printf( "COMMENT: %s (%d)\n", yytext, COMMENT);} else {return COMMENT;}} "(" {if(DEBUG) {printf( "L_PAREN: %s (%d)\n", yytext, L_PAREN);} else {return L_PAREN;}} ")" {if(DEBUG) {printf( "R_PAREN: %s (%d)\n", yytext, R_PAREN);} else {return R_PAREN;}} diff --git a/tests/test_comment_issues.alpha b/tests/test_comment_issues.alpha new file mode 100644 index 0000000..e968d93 --- /dev/null +++ b/tests/test_comment_issues.alpha @@ -0,0 +1,7 @@ +(*(**)*) +(***) +(******)(*\kpp*********) +((*((*)) +(***)(*) +(* *) +(***)))))))*(*))))))))*))