diff --git a/Makefile b/Makefile index 4a281e1..3a9feac 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ LEX_BIN ?= flex YACC_BIN ?= bison GRAMMARS_DIR ?= ./grammars -GRAMMAR_ID ?= quut +GRAMMAR_ID ?= lysator +SAMPLES_DIR ?= ./samples output ?= $(GRAMMAR_ID)-cocc all: $(output) @@ -19,3 +20,6 @@ $(output): lex.yy.c $(GRAMMAR_ID).tab.c $(GRAMMAR_ID).tab.h clean: rm -f lex.yy.c *.tab.c *.tab.h *-cocc + +test: $(SAMPLES_DIR) $(output) + for cfile in $(SAMPLES_DIR)/*; do printf "\n\n *** file: %s *** \n" $$cfile; ./$(output) < $$cfile; [ -eq $$? 0 ]; done \ No newline at end of file diff --git a/grammars/examp.l b/grammars/examp.l index b5315a2..99e758b 100644 --- a/grammars/examp.l +++ b/grammars/examp.l @@ -118,7 +118,7 @@ yywrap() return(1); } -comment() +void comment() { char c, c1; @@ -138,7 +138,7 @@ loop: int column = 0; -//­p¼Æ¾¹ +//�p�ƾ� void count() { int i; diff --git a/grammars/lysator.l b/grammars/lysator.l index 0cb9b8b..7abbe55 100644 --- a/grammars/lysator.l +++ b/grammars/lysator.l @@ -12,6 +12,12 @@ IS (u|U|l|L)* #include "lysator.tab.h" void count(); +void comment(); +int yywrap(); +int yylex(); +void yyerror(char*); +int check_type(); + %} %% @@ -115,13 +121,13 @@ L?\"(\\.|[^\\"])*\" { count(); return(STRING_LITERAL); } %% -yywrap() +int yywrap() { return(1); } -comment() +void comment() { char c, c1; diff --git a/grammars/lysator.y b/grammars/lysator.y index b606bc3..01d871c 100644 --- a/grammars/lysator.y +++ b/grammars/lysator.y @@ -421,15 +421,14 @@ function_definition extern char yytext[]; extern int column; +extern int yylex(); -int main() { - return yyparse(); -} - -yyerror(s) -char *s; +yyerror(char *s) { fflush(stdout); printf("\n%*s\n%*s\n", column, "^", column, s); } +int main() { + return yyparse(); +} \ No newline at end of file