Added other punctuation
This commit is contained in:
3
Makefile
3
Makefile
@ -19,6 +19,9 @@ test3:
|
|||||||
test4:
|
test4:
|
||||||
./$(EXE) ./tests/test_variables.txt
|
./$(EXE) ./tests/test_variables.txt
|
||||||
|
|
||||||
|
test5:
|
||||||
|
./$(EXE) ./tests/test_otherpunc.txt
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o
|
rm -f *.o
|
||||||
rm -f lex.yy.c
|
rm -f lex.yy.c
|
||||||
|
BIN
lexicalStructure
BIN
lexicalStructure
Binary file not shown.
@ -10,8 +10,6 @@ DIGIT [0-9]
|
|||||||
CHAR \\n|\\t|\\'|[^'\n\t\\]
|
CHAR \\n|\\t|\\'|[^'\n\t\\]
|
||||||
SCHAR \\n|\\t|\\\"|[^\"\n\\]
|
SCHAR \\n|\\t|\\\"|[^\"\n\\]
|
||||||
COM ([^*]|\*+[^)*])*
|
COM ([^*]|\*+[^)*])*
|
||||||
|
|
||||||
/* INCOMPLETE */
|
|
||||||
ID [A-Za-z_][0-9A-Za-z_]*
|
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}
|
"external" {printf("EXTERNAL %s, Token: %d\n", yytext, EXTERNAL);} // {return EXTERNAL}
|
||||||
"as" {printf("AS %s, Token: %d\n", yytext, AS);} // {return AS}
|
"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 ) );}
|
{DIGIT}+ {printf("C_INTEGER: %s, Token: %d\n", yytext, atoi( yytext ) );}
|
||||||
"null" {printf("C_NULL: %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 ) );}
|
"true" {printf("C_TRUE: %s, Token: %d\n", yytext, atoi( yytext ) );}
|
||||||
"false" {printf("C_FALSE: %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 ) );}
|
\"{SCHAR}*\" {printf("C_STRING: %s, Token: %d\n", yytext, atoi( yytext ) );}
|
||||||
|
|
||||||
|
{ID} {printf("ID: %s, Token: %d\n", yytext, ID);}
|
||||||
|
|
||||||
.|\n
|
.|\n
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
24
test1.txt
24
test1.txt
@ -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
|
|
||||||
$^&
|
|
||||||
>
|
|
||||||
|
|
@ -27,3 +27,4 @@ exteRnal
|
|||||||
as
|
as
|
||||||
As
|
As
|
||||||
aS
|
aS
|
||||||
|
functionaly
|
6
tests/test_otherpunc.txt
Normal file
6
tests/test_otherpunc.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
;
|
||||||
|
:
|
||||||
|
,
|
||||||
|
->
|
||||||
|
->>
|
||||||
|
-->
|
Reference in New Issue
Block a user