From c542db95be66e6db56dba1c54551ffca9afdf584 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 24 Nov 2009 13:36:01 -0800 Subject: Fixed broken yyerrorf. It was still taking char *, and passing that as an object to vformat, resulting in # output. --- ChangeLog | 16 ++++++++++++++ parser.h | 2 +- parser.l | 2 +- parser.y | 71 +++++++++++++++++++++++++++++++++++---------------------------- 4 files changed, 57 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index 08ca08d7..b7910fd9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2009-11-24 Kaz Kylheku + + Fixed broken yyerrorf. It was still taking char *, and passing + that as an object to vformat, resulting in # + output. + + * parser.h (yybadtoken): Declaration updated. + + * parser.l (yybadtoken): Redefined to take val argument. + The tok stays as int; this is closely coupled to yacc, + so why bother with num(). + + * parser.y (grammar): Fix occurences of yybadtoken to pass + proper literal objects using the lit macro, or nil in + the one case when there is no context. + 2009-11-24 Kaz Kylheku Renaming global variables that denote symbols, such that they diff --git a/parser.h b/parser.h index 2a19a349..3b58193b 100644 --- a/parser.h +++ b/parser.h @@ -33,4 +33,4 @@ extern val spec_file_str; int yyparse(void); val get_spec(void); void yyerrorf(val s, ...); -void yybadtoken(int tok, const char *context); +void yybadtoken(int tok, val context); diff --git a/parser.l b/parser.l index 433c0489..5a55115d 100644 --- a/parser.l +++ b/parser.l @@ -85,7 +85,7 @@ void yyerrorf(val fmt, ...) errors++; } -void yybadtoken(int tok, const char *context) +void yybadtoken(int tok, val context) { val problem = nil; diff --git a/parser.y b/parser.y index b9d64f2a..c5d5f9fd 100644 --- a/parser.y +++ b/parser.y @@ -85,7 +85,7 @@ static val parsed_spec; spec : clauses { parsed_spec = $1; } | /* empty */ { parsed_spec = nil; } | error { parsed_spec = nil; - yybadtoken(yychar, 0); } + yybadtoken(yychar, nil); } ; clauses : clause { $$ = cons($1, nil); } @@ -114,7 +114,7 @@ clause : all_clause { $$ = list(num(lineno - 1), $1, nao); } all_clause : ALL newl clause_parts { $$ = cons(all_s, $3); } | ALL newl error { $$ = nil; yybadtoken(yychar, - "all clause"); } + lit("all clause")); } | ALL newl END newl { $$ = nil; yyerror("empty all clause"); } @@ -123,7 +123,7 @@ all_clause : ALL newl clause_parts { $$ = cons(all_s, $3); } some_clause : SOME newl clause_parts { $$ = cons(some_s, $3); } | SOME newl error { $$ = nil; yybadtoken(yychar, - "some clause"); } + lit("some clause")); } | SOME newl END newl { $$ = nil; yyerror("empty some clause"); } ; @@ -131,7 +131,7 @@ some_clause : SOME newl clause_parts { $$ = cons(some_s, $3); } none_clause : NONE newl clause_parts { $$ = cons(none_s, $3); } | NONE newl error { $$ = nil; yybadtoken(yychar, - "none clause"); } + lit("none clause")); } | NONE newl END newl { $$ = nil; yyerror("empty none clause"); } ; @@ -139,7 +139,7 @@ none_clause : NONE newl clause_parts { $$ = cons(none_s, $3); } maybe_clause : MAYBE newl clause_parts { $$ = cons(maybe_s, $3); } | MAYBE newl error { $$ = nil; yybadtoken(yychar, - "maybe clause"); } + lit("maybe clause")); } | MAYBE newl END newl { $$ = nil; yyerror("empty maybe clause"); } ; @@ -147,7 +147,7 @@ maybe_clause : MAYBE newl clause_parts { $$ = cons(maybe_s, $3); } cases_clause : CASES newl clause_parts { $$ = cons(cases_s, $3); } | CASES newl error { $$ = nil; yybadtoken(yychar, - "cases clause"); } + lit("cases clause")); } | CASES newl END newl { $$ = nil; yyerror("empty cases clause"); } ; @@ -162,7 +162,7 @@ collect_clause : COLLECT newl clauses END newl { $$ = list(collect_s, yyerror("empty collect"); else yybadtoken(yychar, - "collect clause"); } + lit("collect clause")); } ; clause_parts : clauses additional_parts { $$ = cons($1, $2); } @@ -194,7 +194,7 @@ elem : TEXT { $$ = string_own($1); } | COLL elems UNTIL elems END { $$ = list(coll_s, $2, $4, nao); } | COLL error { $$ = nil; - yybadtoken(yychar, "coll clause"); } + yybadtoken(yychar, lit("coll clause")); } ; define_clause : DEFINE exprs ')' newl @@ -204,12 +204,12 @@ define_clause : DEFINE exprs ')' newl clauses_opt END newl { $$ = list(define_s, nil, $4, nao); } | DEFINE error { $$ = nil; - yybadtoken(yychar, "list expression"); } + yybadtoken(yychar, lit("list expression")); } | DEFINE exprs ')' newl - error { $$ = nil; yybadtoken(yychar, "define"); } + error { $$ = nil; yybadtoken(yychar, lit("define")); } | DEFINE ')' newl error { $$ = nil; - yybadtoken(yychar, "define"); } + yybadtoken(yychar, lit("define")); } ; try_clause : TRY newl @@ -225,11 +225,11 @@ try_clause : TRY newl yychar == FINALLY) yyerror("empty try clause"); else - yybadtoken(yychar, "try clause"); } + yybadtoken(yychar, lit("try clause")); } | TRY newl clauses error { $$ = nil; - yybadtoken(yychar, "try clause"); } + yybadtoken(yychar, lit("try clause")); } ; catch_clauses_opt : CATCH ')' newl @@ -247,13 +247,16 @@ catch_clauses_opt : CATCH ')' newl | { $$ = nil; } | CATCH ')' newl error { $$ = nil; - yybadtoken(yychar, "try clause"); } + yybadtoken(yychar, + lit("try clause")); } | CATCH exprs ')' newl error { $$ = nil; - yybadtoken(yychar, "try clause"); } + yybadtoken(yychar, + lit("try clause")); } | FINALLY newl error { $$ = nil; - yybadtoken(yychar, "try clause"); } + yybadtoken(yychar, + lit("try clause")); } ; @@ -272,19 +275,19 @@ output_clause : OUTPUT ')' o_elems '\n' yyerror("invalid combination of old and " "new syntax in output directive"); } | OUTPUT error { $$ = nil; - yybadtoken(yychar, "list expression"); } + yybadtoken(yychar, lit("list expression")); } | OUTPUT ')' o_elems '\n' error { $$ = nil; - yybadtoken(yychar, "output clause"); } + yybadtoken(yychar, lit("output clause")); } | OUTPUT ')' newl error { $$ = nil; - yybadtoken(yychar, "output clause"); } + yybadtoken(yychar, lit("output clause")); } | OUTPUT exprs ')' o_elems '\n' error { $$ = nil; - yybadtoken(yychar, "output clause"); } + yybadtoken(yychar, lit("output clause")); } | OUTPUT exprs ')' newl error { $$ = nil; - yybadtoken(yychar, "output clause"); } + yybadtoken(yychar, lit("output clause")); } ; out_clauses : out_clause { $$ = cons($1, nil); } @@ -320,7 +323,7 @@ repeat_clause : REPEAT newl END newl { $$ = repeat_rep_helper(repeat_s, $3, $4); } | REPEAT newl error { $$ = nil; - yybadtoken(yychar, "repeat clause"); } + yybadtoken(yychar, lit("repeat clause")); } ; repeat_parts_opt : SINGLE newl @@ -364,7 +367,8 @@ o_elem : TEXT { $$ = string_own($1); } rep_elem : REP o_elems rep_parts_opt END { $$ = repeat_rep_helper(rep_s, $2, $3); } - | REP error { $$ = nil; yybadtoken(yychar, "rep clause"); } + | REP error { $$ = nil; + yybadtoken(yychar, lit("rep clause")); } ; rep_parts_opt : SINGLE o_elems_opt2 @@ -411,9 +415,9 @@ var : IDENT { $$ = list(var_s, intern(string_own($1), nil), "not useable with " "fixed width match"); } | IDENT error { $$ = nil; - yybadtoken(yychar, "variable spec"); } + yybadtoken(yychar, lit("variable spec")); } | var_op error { $$ = nil; - yybadtoken(yychar, "variable spec"); } + yybadtoken(yychar, lit("variable spec")); } ; var_op : '*' { $$ = t; } @@ -422,7 +426,7 @@ var_op : '*' { $$ = t; } list : '(' exprs ')' { $$ = $2; } | '(' ')' { $$ = nil; } | '(' error { $$ = nil; - yybadtoken(yychar, "list expression"); } + yybadtoken(yychar, lit("list expression")); } ; exprs : expr { $$ = cons($1, nil); } @@ -444,7 +448,7 @@ expr : IDENT { $$ = intern(string_own($1), nil); } regex : '/' regexpr '/' { $$ = $2; } | '/' '/' { $$ = nil; } | '/' error { $$ = nil; - yybadtoken(yychar, "regex"); } + yybadtoken(yychar, lit("regex")); } ; regexpr : regbranch { $$ = $1; } @@ -468,9 +472,11 @@ regterm : '[' regclass ']' { $$ = cons(set_s, $2); } | REGCHAR { $$ = chr($1); } | '(' regexpr ')' { $$ = cons(compound_s, $2); } | '(' error { $$ = nil; - yybadtoken(yychar, "regex subexpression"); } + yybadtoken(yychar, + lit("regex subexpression")); } | '[' error { $$ = nil; - yybadtoken(yychar, "regex character class"); } + yybadtoken(yychar, + lit("regex character class")); } ; regclass : regclassterm { $$ = cons($1, nil); } @@ -502,7 +508,7 @@ newl : '\n' strlit : '"' '"' { $$ = null_string; } | '"' litchars '"' { $$ = lit_char_helper($2); } | '"' error { $$ = nil; - yybadtoken(yychar, "string literal"); } + yybadtoken(yychar, lit("string literal")); } ; chrlit : '\'' '\'' { $$ = nil; @@ -513,13 +519,14 @@ chrlit : '\'' '\'' { $$ = nil; yyerror("multiple characters in " "character literal"); } | '\'' error { $$ = nil; - yybadtoken(yychar, "character literal"); } + yybadtoken(yychar, + lit("character literal")); } ; quasilit : '`' '`' { $$ = null_string; } | '`' quasi_items '`' { $$ = cons(quasi_s, $2); } | '`' error { $$ = nil; - yybadtoken(yychar, "string literal"); } + yybadtoken(yychar, lit("string literal")); } ; quasi_items : quasi_item { $$ = cons($1, nil); } -- cgit v1.2.3