Hi Adela, > Le 20 sept. 2022 à 01:20, Adela Vais <[email protected]> a écrit : > > Hello Akim, > > Here are the patches for the syntax error that appeared when using `%code > lexer` (issue 84) and the toString method of SymbolKind (issue 88). > I used the latest DMD public release, 2.100.2. > > I used the proposed solutions created by ledaniel2. I'll let you handle the > author attribution for these patches.
I don't have his/her email, I would need that for THANKS. > I want to follow up with a test for the second patch, most probably next > week. I think that one possible test that could use the function can be > created through > https://github.com/adelavais/bison/blob/master/tests/regression.at#L1724 in > combination with functions from the local.at file, so I will look into this. Great. If you need guidance, let me know. Thanks for this! I have installed the following versions of your patches; I tweaked the commit messages. Cheers! commit be4528096ec05f0d58bd9ff53a293e1ec3193a85 Author: Adela Vais <[email protected]> Date: Mon Sep 19 15:12:39 2022 +0200 d: fix interface syntax error Fix syntax error regarding interface inheritance of the Lexer. It appeared when the `%code lexer` option was used. Reported by ledaniel2. <https://github.com/akimd/bison/issues/84> * data/skeletons/lalr1.d: Fix syntax. * tests/d.at: Test it. diff --git a/data/skeletons/lalr1.d b/data/skeletons/lalr1.d index 3195dbf8..01175325 100644 --- a/data/skeletons/lalr1.d +++ b/data/skeletons/lalr1.d @@ -269,9 +269,10 @@ b4_user_union_members } }]])[ -]b4_lexer_if([[ private class YYLexer implements Lexer { +]b4_lexer_if([[private class YYLexer: Lexer +{ ]b4_percent_code_get([[lexer]])[ - } +} ]])[ /** The object doing lexical analysis for us. */ private Lexer yylexer; diff --git a/tests/d.at b/tests/d.at index 6be53eef..347e868c 100644 --- a/tests/d.at +++ b/tests/d.at @@ -112,6 +112,13 @@ AT_SETUP([D parser class extends and implements]) AT_CHECK_D_MINIMAL([%define api.parser.extends {Interface}], [], [], [interface Interface {}]) AT_CHECK_D_GREP([[class YYParser : Interface]]) +AT_CHECK_D_MINIMAL([%code lexer +{ + Symbol yylex () {return Symbol();} + void yyerror (string s) {import std.stdio;writeln(s);} +}], [], [], []) +AT_CHECK_D_GREP([[private class YYLexer: Lexer]]) + AT_CHECK_D_MINIMAL( [%define api.parser.extends {BaseClass} %define api.parser.implements {Interface}], [], [], commit 0faf3719926defc459c10b0a8d04d6a29c47a53f Author: Adela Vais <[email protected]> Date: Mon Sep 19 19:09:20 2022 +0200 d: fix syntax error on SymbolKind.toString method Reported by ledaniel2. <https://github.com/akimd/bison/issues/88> * data/skeletons/d.m4: Here. diff --git a/data/skeletons/d.m4 b/data/skeletons/d.m4 index 9354b0fe..e82f87e5 100644 --- a/data/skeletons/d.m4 +++ b/data/skeletons/d.m4 @@ -284,8 +284,7 @@ m4_define([b4_declare_symbol_enum], that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. */ - final void toString(W)(W sink) const - if (isOutputRange!(W, char)) + final void toString(void delegate(const(char)[]) sink) const { immutable string[] yy_sname = @{ ]b4_symbol_names[ @@ -296,7 +295,7 @@ m4_define([b4_declare_symbol_enum], ]b4_translatable[ @};]])[ - put(sink, yy_sname[yycode_]); + sink.formattedWrite!"%s"(yy_sname[yycode_]); } } ]])
