bison-patches
[Top][All Lists]
Advanced

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

[PATCH 08/13] java: style: avoid useless initializers


From: Akim Demaille
Subject: [PATCH 08/13] java: style: avoid useless initializers
Date: Wed, 5 Feb 2020 18:05:00 +0100

Instead of

      /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
       STATE-NUM.  */
      private static final byte yypact_[] = yypact_init ();
      private static final byte[] yypact_init ()
      {
        return new byte[]
        {
          25,    -7,    -8,    37,    -8,    40,    -8,    20,    -8,    61,
          -8,    -8,     3,     9,    51,    -8,    -8,    -2,    -2,    -2,
          -2,    -2,    -2,    -8,    -8,    -8,     1,    66,    66,     3,
           3,     3
        };
      }

generate

    /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
       STATE-NUM.  */
      private static final byte[] yypact_ =
      {
          25,    -7,    -8,    37,    -8,    40,    -8,    20,    -8,    61,
          -8,    -8,     3,     9,    51,    -8,    -8,    -2,    -2,    -2,
          -2,    -2,    -2,    -8,    -8,    -8,     1,    66,    66,     3,
           3,     3
      };

I have no idea what motivated the previous approach.

* data/skeletons/java.m4 (b4_typed_parser_table_define): Here.
---
 data/skeletons/java.m4    | 8 ++------
 data/skeletons/lalr1.java | 2 +-
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/data/skeletons/java.m4 b/data/skeletons/java.m4
index bcf9a993..b36ee3d2 100644
--- a/data/skeletons/java.m4
+++ b/data/skeletons/java.m4
@@ -109,14 +109,10 @@ m4_define([b4_null], [null])
 m4_define([b4_typed_parser_table_define],
 [m4_ifval([$4], [b4_comment([$4])
   ])dnl
-[private static final ]$1[[] yy$2_ = yy$2_init ();
-  private static final ]$1[[] yy$2_init ()
+[private static final ]$1[[] yy$2_ =
   {
-    return new ]$1[[]
-    {
   ]$3[
-    };
-  }]])
+  };]])
 
 
 # b4_integral_parser_table_define(NAME, DATA, COMMENT)
diff --git a/data/skeletons/lalr1.java b/data/skeletons/lalr1.java
index 7f5e4a1a..24b50795 100644
--- a/data/skeletons/lalr1.java
+++ b/data/skeletons/lalr1.java
@@ -982,7 +982,7 @@ b4_dollar_popdef[]dnl
   private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = 
]b4_pact_ninf[;
   private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = 
]b4_table_ninf[;
 
-  ]b4_parser_tables_define[
+]b4_parser_tables_define[
 
   /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
      First, the terminals, then, starting at \a yyntokens_, nonterminals.  */
-- 
2.25.0




reply via email to

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