added more grammar; added testing
This commit is contained in:
parent
8e1335eb4e
commit
3ff54b86e9
6
Makefile
6
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
|
||||
|
|
@ -118,7 +118,7 @@ yywrap()
|
|||
return(1);
|
||||
}
|
||||
|
||||
comment()
|
||||
void comment()
|
||||
{
|
||||
char c, c1;
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ loop:
|
|||
|
||||
int column = 0;
|
||||
|
||||
//p¼Æ¾¹
|
||||
//<EFBFBD>p<EFBFBD>ƾ<EFBFBD>
|
||||
void count()
|
||||
{
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
Loading…
Reference in New Issue