Added other punctuation

This commit is contained in:
Scarlett
2025-02-11 15:32:31 -05:00
parent 9091b65a30
commit 9c67da0348
6 changed files with 17 additions and 27 deletions

View File

@ -19,6 +19,9 @@ test3:
test4:
./$(EXE) ./tests/test_variables.txt
test5:
./$(EXE) ./tests/test_otherpunc.txt
clean:
rm -f *.o
rm -f lex.yy.c

Binary file not shown.

View File

@ -10,8 +10,6 @@ DIGIT [0-9]
CHAR \\n|\\t|\\'|[^'\n\t\\]
SCHAR \\n|\\t|\\\"|[^\"\n\\]
COM ([^*]|\*+[^)*])*
/* INCOMPLETE */
ID [A-Za-z_][0-9A-Za-z_]*
%%
@ -34,7 +32,10 @@ ID [A-Za-z_][0-9A-Za-z_]*
"external" {printf("EXTERNAL %s, Token: %d\n", yytext, EXTERNAL);} // {return EXTERNAL}
"as" {printf("AS %s, Token: %d\n", yytext, AS);} // {return AS}
{ID} {printf("ID: %s, Token: %d\n", yytext, ID );} // INCOMPLETE
";" {printf("SEMI_COLON %s, Token: %d\n", yytext, SEMI_COLON);}
":" {printf("COLON %s, Token: %d\n", yytext, COLON);}
"," {printf("COMMA %s, Token: %d\n", yytext, COMMA);}
"->" {printf("ARROW %s, Token: %d\n", yytext, ARROW);}
{DIGIT}+ {printf("C_INTEGER: %s, Token: %d\n", yytext, atoi( yytext ) );}
"null" {printf("C_NULL: %s, Token: %d\n", yytext, atoi( yytext ) );}
@ -42,6 +43,9 @@ ID [A-Za-z_][0-9A-Za-z_]*
"true" {printf("C_TRUE: %s, Token: %d\n", yytext, atoi( yytext ) );}
"false" {printf("C_FALSE: %s, Token: %d\n", yytext, atoi( yytext ) );}
\"{SCHAR}*\" {printf("C_STRING: %s, Token: %d\n", yytext, atoi( yytext ) );}
{ID} {printf("ID: %s, Token: %d\n", yytext, ID);}
.|\n
%%

View File

@ -1,24 +0,0 @@
This is a test
9combined 7okens
12345
893247892
combined'DueToUnknownChar _validtoken __validtoken1 _valid_token2 validToken3_
true false
null while !wrong if when
else type function
return external as
string _NOte_that_was_not_reserved
([)]{}:;,->"\
+-*/%
<=
:=
"This is not a valid
String"
"This is a valid String"
!|
..
(* this is a comment *)
(*Not a comment
$^&
>

View File

@ -27,3 +27,4 @@ exteRnal
as
As
aS
functionaly

6
tests/test_otherpunc.txt Normal file
View File

@ -0,0 +1,6 @@
;
:
,
->
->>
-->