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
|
||||
# Creates "myprogram" from "scan.l" and "myprogram.c"
|
||||
#
|
||||
#LEX=flex
|
||||
#myprogram: scan.o myprogram.o
|
||||
#$(CC) -o $@ $(LDFLAGS) $^
|
||||
#myprogram.o: myprogram.c
|
||||
#$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $^
|
||||
#scan.o: scan.c
|
||||
#$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $^
|
||||
#scan.c: scan.l
|
||||
#$(LEX) $(LFLAGS) -o $@ $^
|
||||
#clean:
|
||||
#$(RM) *.o scan.c
|
||||
CC := gcc
|
||||
FLEX := flex
|
||||
LEX := lexicalStructure.lex
|
||||
EXE := lexicalStructure
|
||||
|
||||
lexicalStructure:
|
||||
$(FLEX) $(LEX)
|
||||
$(CC) lex.yy.c -o $(EXE)
|
||||
|
||||
test_operators:
|
||||
./$(EXE) ./tests/test_operators.alpha
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f lex.yy.c
|
||||
rm -f $(EXE)
|
||||
|
@ -30,20 +30,20 @@
|
||||
|
||||
/* 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
|
||||
"reserve" {printf("RESERVE %s, Token %d\n",yytext, RESERVE);} //return RESERVE
|
||||
"release" {printf("RELEASE %s, Token %d\n",yytext, RELEASE);} //return RELEASE
|
||||
"+" {return ADD;}
|
||||
"-" {return SUB_OR_NEG;}
|
||||
"*" {return MUL;}
|
||||
"/" {return DIV;}
|
||||
"%" {return REM;}
|
||||
"<" {return LESS_THAN;}
|
||||
"=" {return EQUAL_TO;}
|
||||
":=" {return ASSIGN;}
|
||||
"!" {return NOT;}
|
||||
"&" {return AND;}
|
||||
"|" {return OR;}
|
||||
"." {return DOT;}
|
||||
"reserve" {return RESERVE;}
|
||||
"release" {return RELEASE;}
|
||||
%%
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user