removed print statements from .lex file and added test_operators to Makefile
This commit is contained in:
30
Makefile
30
Makefile
@ -1,14 +1,16 @@
|
|||||||
# Basic Makefile example from flex documentation -- provides explicit rules
|
CC := gcc
|
||||||
# Creates "myprogram" from "scan.l" and "myprogram.c"
|
FLEX := flex
|
||||||
#
|
LEX := lexicalStructure.lex
|
||||||
#LEX=flex
|
EXE := lexicalStructure
|
||||||
#myprogram: scan.o myprogram.o
|
|
||||||
#$(CC) -o $@ $(LDFLAGS) $^
|
lexicalStructure:
|
||||||
#myprogram.o: myprogram.c
|
$(FLEX) $(LEX)
|
||||||
#$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $^
|
$(CC) lex.yy.c -o $(EXE)
|
||||||
#scan.o: scan.c
|
|
||||||
#$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $^
|
test_operators:
|
||||||
#scan.c: scan.l
|
./$(EXE) ./tests/test_operators.alpha
|
||||||
#$(LEX) $(LFLAGS) -o $@ $^
|
|
||||||
#clean:
|
clean:
|
||||||
#$(RM) *.o scan.c
|
rm -f *.o
|
||||||
|
rm -f lex.yy.c
|
||||||
|
rm -f $(EXE)
|
||||||
|
@ -30,20 +30,20 @@
|
|||||||
|
|
||||||
/* OPERATORS */
|
/* OPERATORS */
|
||||||
|
|
||||||
"+" {printf("ADD %s, Token %d\n",yytext, ADD);} //return ADD
|
"+" {return ADD;}
|
||||||
"-" {printf("SUB_OR_NEG %s, Token %d\n",yytext, SUB_OR_NEG);} //return SUB_OR_NEG
|
"-" {return SUB_OR_NEG;}
|
||||||
"*" {printf("MUL %s, Token %d\n",yytext, MUL);} //return MUL
|
"*" {return MUL;}
|
||||||
"/" {printf("DIV %s, Token %d\n",yytext, DIV);} //return DIV
|
"/" {return DIV;}
|
||||||
"%" {printf("REM %s, Token %d\n",yytext, REM);} //return REM
|
"%" {return REM;}
|
||||||
"<" {printf("LESS_THAN %s, Token %d\n",yytext, LESS_THAN);} //return LESS_THAN
|
"<" {return LESS_THAN;}
|
||||||
"=" {printf("EQUAL_TO %s, Token %d\n",yytext, EQUAL_TO);} //return EQUAL_TO
|
"=" {return EQUAL_TO;}
|
||||||
":=" {printf("ASSIGN %s, Token %d\n",yytext, ASSIGN);} //return ASSIGN
|
":=" {return ASSIGN;}
|
||||||
"!" {printf("NOT %s, Token %d\n",yytext, NOT);} //return NOT
|
"!" {return NOT;}
|
||||||
"&" {printf("AND %s, Token %d\n",yytext, AND);} //return AND
|
"&" {return AND;}
|
||||||
"|" {printf("OR %s, Token %d\n",yytext, OR);} //return OR
|
"|" {return OR;}
|
||||||
"." {printf("DOT %s, Token %d\n",yytext, DOT);} //return DOT
|
"." {return DOT;}
|
||||||
"reserve" {printf("RESERVE %s, Token %d\n",yytext, RESERVE);} //return RESERVE
|
"reserve" {return RESERVE;}
|
||||||
"release" {printf("RELEASE %s, Token %d\n",yytext, RELEASE);} //return RELEASE
|
"release" {return RELEASE;}
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user