diff --git a/lexicalStructure.lex b/lexicalStructure.lex index eed6e7d..411d0bd 100644 --- a/lexicalStructure.lex +++ b/lexicalStructure.lex @@ -16,7 +16,7 @@ ID [A-Za-z_][0-9A-Za-z_]* DIGIT [0-9] CHAR \\n|\\t|\\'|[^'\n\t\\] /* char can be a newline, tab, an escaped quote, or anything but a single quote, an actual line break, an actual tab, or a backslash by itself (to prevent confusion from escaped quote */ -SCHAR \\n|\\t|\\\"|[^\"\n\\] +SCHAR \\n|\\t|\\\"|[^\"\n\\] /* similar to above, a string Char (SCHAR) is the same as a CHAR except we cannot have double quotes instead of single quotes. Double quotes need to be escaped in Flex unlike single quotes based on documentation */ %% @@ -61,6 +61,16 @@ SCHAR \\n|\\t|\\\"|[^\"\n\\] '{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;}} + +"(" {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;}} + +"[" {if(DEBUG) {printf( "L_BRACKET: %s (%d)\n", yytext, L_BRACKET);} else {return L_BRACKET;}} +"]" {if(DEBUG) {printf( "R_BRACKET: %s (%d)\n", yytext, R_BRACKET);} else {return R_BRACKET;}} + +"{" {if(DEBUG) {printf( "L_BRACE: %s (%d)\n", yytext, L_BRACE);} else {return L_BRACE;}} +"}" {if(DEBUG) {printf( "R_BRACE: %s (%d)\n", yytext, R_BRACE);} else {return R_BRACE;}} + "true" {if(DEBUG) {printf( "C_TRUE: %s (%d)\n", yytext, C_TRUE);} else {return C_TRUE;}} "false" {if(DEBUG) {printf( "C_FALSE: %s (%d)\n", yytext, C_FALSE);} else {return C_FALSE;}} "null" {if(DEBUG) {printf( "C_NULL: %s (%d)\n", yytext, C_NULL);} else {return C_NULL;}} @@ -70,4 +80,4 @@ SCHAR \\n|\\t|\\\"|[^\"\n\\] \n {line_number++; column_number = 1;} . {column_number++;} -%% \ No newline at end of file +%% diff --git a/tests/test_punctuation_grouping.alpha b/tests/test_punctuation_grouping.alpha new file mode 100644 index 0000000..45dfb99 --- /dev/null +++ b/tests/test_punctuation_grouping.alpha @@ -0,0 +1,42 @@ +) +a) +)a +)* +*) + +(* jellsls + well this seems to work + + + *) + +( +a( +(a +(* +*( + + +{ +a{ +{a +{* +*{ +} +a} +}a +}* +*} + + + +[ +a[ +[a +[* +*[ +] +a] +]a +]* +*]