added function to tokenize operators
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
/* Lexical Analysis with Flex (2.6.0) We used some of the code from this manual */
|
/* Lexical Analysis with Flex (1.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
|
||||||
@ -27,10 +27,25 @@
|
|||||||
"function" {printf("FUNCTION %s, Token %d\n",yytext, FUNCTION);} //{return FUNCTION}
|
"function" {printf("FUNCTION %s, Token %d\n",yytext, FUNCTION);} //{return FUNCTION}
|
||||||
"return" {printf("RETURN %s, Token %d\n",yytext, RETURN);} //{return RETURN}
|
"return" {printf("RETURN %s, Token %d\n",yytext, RETURN);} //{return RETURN}
|
||||||
"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}//%
|
||||||
|
|
||||||
|
/* OPERATORS */
|
||||||
|
|
||||||
|
\+ {printf("ADD %s, Token %d\n",yytext, ADD);} //return ADD
|
||||||
|
\- {printf("SUB_OR_NEG %s, Token %d\n",yytext, SUB_OR_NEG);} //return SUB_OR_NEG
|
||||||
|
\* {printf("MUL %s, Token %d\n",yytext, MUL);} //return MUL
|
||||||
|
\/ {printf("DIV %s, Token %d\n",yytext, DIV);} //return DIV
|
||||||
|
\% {printf("REM %s, Token %d\n",yytext, REM);} //return REM
|
||||||
|
\< {printf("LESS_THAN %s, Token %d\n",yytext, LESS_THAN);} //return LESS_THAN
|
||||||
|
= {printf("EQUAL_TO %s, Token %d\n",yytext, EQUAL_TO);} //return EQUAL_TO
|
||||||
|
:= {printf("ASSIGN %s, Token %d\n",yytext, ASSIGN);} //return ASSIGN
|
||||||
|
! {printf("NOT %s, Token %d\n",yytext, NOT);} //return NOT
|
||||||
|
& {printf("AND %s, Token %d\n",yytext, AND);} //return AND
|
||||||
|
\| {printf("OR %s, Token %d\n",yytext, OR);} //return OR
|
||||||
|
\. {printf("DOT %s, Token %d\n",yytext, DOT);} //return DOT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]){
|
||||||
argc--, argv++;
|
argc--, argv++;
|
||||||
if ( argc > 0 )
|
if ( argc > 0 )
|
||||||
|
Reference in New Issue
Block a user