bison-patches
[Top][All Lists]
Advanced

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

c++: move stack<T> inside yy::parser


From: Akim Demaille
Subject: c++: move stack<T> inside yy::parser
Date: Wed, 26 Dec 2018 20:52:17 +0100

commit f44fcd30ea61c6d65cf4a0e4f5ab27ea9da97b84
Author: Akim Demaille <address@hidden>
Date:   Tue Dec 25 18:55:18 2018 +0100

    c++: move stack<T> inside yy::parser
    
    We used to define such auxiliary structures outside the class, mainly
    as a matter of style to keep the definition of yy::parser short and
    simple.  However, now there's a lot more code generated inside the
    class definition (e.g., all the token constructors), so the
    readability no longer applies.
    
    However, if we move stack (and slice) inside yy::parser, then it
    should no longer be needed to change the namespace to have multiple
    parsers: changing the class name should suffice.
    
    One common argument against inner classes is that they code bloat.  It
    hardly applies here, since typically different parsers will have
    different semantic value types, hence different actual stack types.
    
    * data/skeletons/lalr1.cc: Invoke b4_stack_define inside yy::parser.

diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index ecf55930..977b4b23 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -172,7 +172,6 @@ m4_define([b4_shared_declarations],
 
 ]b4_namespace_open[
 
-]b4_stack_define[
 ]b4_bison_locations_if([m4_ifndef([b4_location_file],
                                   [b4_location_define])])[
 
@@ -339,6 +338,8 @@ m4_define([b4_shared_declarations],
 #endif
     };
 
+]b4_stack_define[
+
     /// Stack type.
     typedef stack<stack_symbol_type> stack_type;
 




reply via email to

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