bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for Dlang support] tests: d: check the extends and implements


From: Adela Vais
Subject: Re: [PATCH for Dlang support] tests: d: check the extends and implements directives for the parser class
Date: Thu, 24 Sep 2020 15:47:36 +0300

Hello Akim,

În joi, 24 sept. 2020 la 09:51, Akim Demaille <akim@lrde.epita.fr> a scris:

> Hi Adela,
>
> > Le 23 sept. 2020 à 20:51, Adela Vais <adela.vais99@gmail.com> a écrit :
> >
> > The D skeleton was not properly supporting these directives.
> >
> > * data/skeletons/d.m4: Fix it.
> > * tests/d.at: (New.) Check it.
> > * tests/local.mk, tests/testsuite.at: Adjust.
>
> Thanks!  Installed as follows.  I didn't know D featured interfaces,
> that's nice.  I don't see when someone would install the parser below an
> interface though.
>

Thank you!


> Have you had a look at LAC?  That's something which would be most useful
> in the skeleton.  I have not forgotten your patch for yylex, I'll work on
> it asap.
>

I did not look at LAC yet, but I'll start working on it next.


> Cheers!
>
> commit 02b0b387ba391d3329b91b8ad305610dec30a025
> Author: Adela Vais <adela.vais99@gmail.com>
> Date:   Wed Sep 23 21:51:21 2020 +0300
>
>     d: check the extends and implements directives for the parser class
>
>     The D skeleton was not properly supporting api.parser.extends and
>     api.parser.implements.
>
>     * data/skeletons/d.m4: Fix it.
>     * tests/d.at: Check it.
>     * tests/local.mk, tests/testsuite.at: Adjust.
>
> diff --git a/data/skeletons/d.m4 b/data/skeletons/d.m4
> index abaa4c7b..9e4c4995 100644
> --- a/data/skeletons/d.m4
> +++ b/data/skeletons/d.m4
> @@ -58,6 +58,23 @@ m4_define([b4_percent_define_get3],
>            [m4_ifval(m4_quote(b4_percent_define_get([$1])),
>                  [$2[]b4_percent_define_get([$1])[]$3], [$4])])
>
> +# b4_percent_define_if_get2(ARG1, ARG2, DEF, NOT)
> +# -----------------------------------------------
> +# Expand to the value of DEF if ARG1 or ARG2 are %define'ed,
> +# otherwise NOT.
> +m4_define([b4_percent_define_if_get2],
> +          [m4_ifval(m4_quote(b4_percent_define_get([$1])),
> +                [$3], [m4_ifval(m4_quote(b4_percent_define_get([$2])),
> +                      [$3], [$4])])])
> +
> +# b4_percent_define_class_before_interface(CLASS, INTERFACE)
> +# ----------------------------------------------------------
> +# Expand to a ', ' if both a class and an interface have been %define'ed
> +m4_define([b4_percent_define_class_before_interface],
> +          [m4_ifval(m4_quote(b4_percent_define_get([$1])),
> +                [m4_ifval(m4_quote(b4_percent_define_get([$2])),
> +                      [, ])])])
> +
>
>  # b4_flag_value(BOOLEAN-FLAG)
>  # ---------------------------
> @@ -78,8 +95,10 @@ b4_percent_define_flag_if([api.parser.public],
>  [public ])dnl
>  b4_percent_define_flag_if([api.parser.abstract], [abstract ])dnl
>  b4_percent_define_flag_if([api.parser.final],    [final ])dnl
>  [class ]b4_parser_class[]dnl
> -b4_percent_define_get3([api.parser.extends], [ extends ])dnl
> -b4_percent_define_get3([api.parser.implements], [ implements ])])
> +b4_percent_define_if_get2([api.parser.extends], [api.parser.implements],
> [ : ])dnl
> +b4_percent_define_get([api.parser.extends])dnl
> +b4_percent_define_class_before_interface([api.parser.extends],
> [api.parser.implements])dnl
> +b4_percent_define_get([api.parser.implements])])
>
>
>  # b4_lexer_if(TRUE, FALSE)
> diff --git a/tests/d.at b/tests/d.at
> new file mode 100644
> index 00000000..fccdfaec
> --- /dev/null
> +++ b/tests/d.at
> @@ -0,0 +1,82 @@
> +# D features tests.                      -*- Autotest -*-
> +
> +# Copyright (C) 2020 Free Software Foundation, Inc.
> +
> +# This program is free software: you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation, either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +AT_BANNER([[D Features.]])
> +
> +# AT_CHECK_D_MINIMAL([DIRECTIVES], [PARSER_ACTION], [POSITION_CLASS],
> [EXTRA_USER_CODE])
> +# ----------------------------------------------------------------------
> +# Check that a minimal parser with DIRECTIVES compiles in D.
> +# Put the D code in YYParser.d.
> +m4_define([AT_CHECK_D_MINIMAL],
> +[
> +AT_DATA([[YYParser.y]], [
> +%language "D"
> +%token END "end"
> +[$1]
> +%%
> +start: END {$2};
> +%%
> +[$4]
> +void main() {}
> +])
> +AT_BISON_CHECK([[-Wno-deprecated YYParser.y]])
> +AT_CHECK([[grep '[mb]4_' YYParser.y]], [1], [ignore])
> +AT_COMPILE_D([[YYParser]])
> +])
> +
> +# AT_CHECK_D_GREP([LINE], [COUNT=1])
> +# -------------------------------------
> +# Check that YYParser.d contains exactly COUNT lines matching ^LINE$
> +# with grep.
> +m4_define([AT_CHECK_D_GREP],
> +[AT_CHECK([grep -c '^$1$' YYParser.d], [ignore], [m4_default([$2], [1])
> +])])
> +
> +## -------------------------------------- ##
> +## D parser class extends and implements. ##
> +## -------------------------------------- ##
> +
> +AT_SETUP([D parser class extends and implements])
> +AT_KEYWORD([d])
> +
> +AT_CHECK_D_MINIMAL([])
> +AT_CHECK_D_GREP([[class YYParser]])
> +
> +AT_CHECK_D_MINIMAL([%define api.parser.extends {BaseClass}], [], [],
> [class BaseClass {}])
> +AT_CHECK_D_GREP([[class YYParser : BaseClass]])
> +
> +AT_CHECK_D_MINIMAL([%define api.parser.extends {Interface}], [], [],
> [interface Interface {}])
> +AT_CHECK_D_GREP([[class YYParser : Interface]])
> +
> +AT_CHECK_D_MINIMAL(
> +[%define api.parser.extends {BaseClass}
> +%define api.parser.implements {Interface}], [], [],
> +[class BaseClass {}
> +interface Interface {}
> +])
> +AT_CHECK_D_GREP([[class YYParser : BaseClass, Interface]])
> +
> +AT_CHECK_D_MINIMAL(
> +[%define api.parser.extends {BaseClass}
> +%define api.parser.implements {Interface1, Interface2}], [], [],
> +[class BaseClass {}
> +interface Interface1 {}
> +interface Interface2 {}
> +])
> +AT_CHECK_D_GREP([[class YYParser : BaseClass, Interface1, Interface2]])
> +
> +AT_CLEANUP
> diff --git a/tests/local.mk b/tests/local.mk
> index 71e1f7a3..72328832 100644
> --- a/tests/local.mk
> +++ b/tests/local.mk
> @@ -57,6 +57,7 @@ TESTSUITE_AT =                                \
>    %D%/conflicts.at                            \
>    %D%/counterexample.at                       \
>    %D%/cxx-type.at                             \
> +  %D%/d.at                                    \
>    %D%/diagnostics.at                          \
>    %D%/existing.at                             \
>    %D%/glr-regression.at                       \
> diff --git a/tests/testsuite.at b/tests/testsuite.at
> index b09872dc..5741b811 100644
> --- a/tests/testsuite.at
> +++ b/tests/testsuite.at
> @@ -87,6 +87,9 @@ m4_include([c++.at])
>  m4_include([java.at])
>  m4_include([javapush.at])
>
> +# Parsers in D
> +m4_include([d.at])
> +
>  # GLR.
>  # C++ types, simplified
>  m4_include([cxx-type.at])
>
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]