From 63206b605c36140f2bd476e054b8318c8b08f472 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Wed, 26 Jun 2024 12:45:41 +0100 Subject: support multiple input filenames --- g.peg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'g.peg') diff --git a/g.peg b/g.peg index a3314f3..dccf361 100644 --- a/g.peg +++ b/g.peg @@ -10,7 +10,7 @@ static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning fprintf(stderr, "%*s%s %s @%zu [%.*s]\n", (int)((level) * 2), "", dbg_str[event], rule, pos, (int)(length), buffer) #endif - +#define PCC_GETCHAR(auxil) fgetc(auxil) } @@ -22,6 +22,7 @@ static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning } %value "AstNode" +%auxil "FILE *" expr <- l:list { $$ = l; } @@ -36,8 +37,8 @@ list <- { $$ = astnode_new_list(); } ')' _ number <- < [0-9]+ > (! ident_char) _ { $$ = astnode_new_num(atoi($1)); } -ident <- < ident_char+ > _ { $$ = astnode_new_ident(strdup($1)); } -string <- '"' < [^"]* > '"' _ { $$ = astnode_new_string(strdup($1)); } +ident <- < ident_char+ > _ { $$ = astnode_new_ident($1); } +string <- '"' < [^"]* > '"' _ { $$ = astnode_new_string($1); } ident_char <- [-_a-zA-Z'+*/\\%=0-9<>] _ <- [ \t\n]* -- cgit v1.2.3