From 07fb4674904bac673ddbb5d6ce4afbe959c4dcd3 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 12 Jan 2020 18:15:27 +0100 Subject: Make the lexer and parser re-entrant --- libstorycode/storycode.y | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'libstorycode/storycode.y') diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y index f3c2653..0e00e36 100644 --- a/libstorycode/storycode.y +++ b/libstorycode/storycode.y @@ -21,8 +21,11 @@ */ %define api.token.prefix {SC_} -%define api.prefix {sc} +%define api.pure full %locations +%lex-param {yscan_t scanner} +%parse-param {Narrative *n}; +%parse-param {yyscan_t scanner}; %code requires { @@ -71,6 +74,8 @@ int max_paras; }; + typedef void *yyscan_t; + } %union { @@ -103,9 +108,8 @@ #include #include - extern int sclex(); - extern int scparse(); - void scerror(Narrative *n, const char *s); + extern int yylex(); + void yyerror(YYLTYPE *locp, Narrative *n, yyscan_t scanner, const char *s); extern int lineno; %} @@ -173,8 +177,6 @@ %type VALUE %type gradtype -%parse-param { Narrative *n }; - %{ static void merge_style(struct parse_style *combined, struct parse_style inp) @@ -620,6 +622,6 @@ styledef: %% -void scerror(Narrative *n, const char *s) { +void yyerror(YYLTYPE *locp, Narrative *n, yyscan_t scanner, const char *s) { printf("Storycode parse error at line %i\n", lineno); } -- cgit v1.2.3