character identifier seems to work. Still working on strings. Updated tests to include more. Task01
This commit is contained in:
@ -1,4 +1,3 @@
|
|||||||
/* Lexical Analysis with Flex (2.6.0) We used some of the code from this manual */
|
|
||||||
/* so we placed the citation here. */
|
/* so we placed the citation here. */
|
||||||
/* definitions */
|
/* definitions */
|
||||||
%option noyywrap
|
%option noyywrap
|
||||||
@ -7,19 +6,21 @@
|
|||||||
%}
|
%}
|
||||||
|
|
||||||
DIGIT [0-9]
|
DIGIT [0-9]
|
||||||
|
CHAR \\\\n|\\\\t|\\\'|[^'\\\n\t]
|
||||||
|
STRINGVAL CHAR | " "
|
||||||
%%
|
%%
|
||||||
/* rules */
|
/* rules */
|
||||||
{DIGIT}+ {printf( "C_INTEGER: %s (%d)\n", yytext, atoi( yytext ) );}
|
{DIGIT}+ {printf( "C_INTEGER: %s (%d)\n", yytext, atoi( yytext ) );}
|
||||||
|
|
||||||
"null" {printf( "C_NULL: %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*/
|
'{CHAR}' {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 ) );}
|
"true" {printf( "C_TRUE: %s (%d)\n", yytext, atoi( yytext ) );}
|
||||||
|
|
||||||
"false" {printf( "C_FALSE: %s (%d)\n", yytext, atoi( yytext ) );}
|
"false" {printf( "C_FALSE: %s (%d)\n", yytext, atoi( yytext ) );}
|
||||||
|
|
||||||
"\""[\^{}}\n]*"\"" {printf( "C_STRING: %s (%d)\n", yytext, atoi( yytext ) );}
|
"{STRINGVAL}+" {printf( "C_STRING: %s (%d)\n", yytext, atoi( yytext ) );}
|
||||||
|
|
||||||
.|\n
|
.|\n
|
||||||
|
|
||||||
|
@ -1,16 +1,24 @@
|
|||||||
"this is a string" 721398 'g' '/n'
|
"this is a string" 721398 'g' '/n'
|
||||||
12893 "this is not a string
|
12893 "this is not a string
|
||||||
"
|
"
|
||||||
|
'''
|
||||||
|
'\'
|
||||||
false
|
false
|
||||||
|
'''
|
||||||
nullfalse
|
nullfalse
|
||||||
"nulltrue
|
"nulltrue
|
||||||
null
|
null
|
||||||
'7'
|
'7'
|
||||||
true
|
true
|
||||||
'189
|
'189
|
||||||
'/n'
|
'\t'
|
||||||
'/t'
|
|
||||||
'"'
|
'"'
|
||||||
'/'
|
'/'
|
||||||
|
'\n'
|
||||||
|
'\''
|
||||||
|
'\t'
|
||||||
|
'\\'
|
||||||
|
|
||||||
|
'\'
|
||||||
|
|
||||||
|
'''
|
||||||
|
Reference in New Issue
Block a user