mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-23 19:23:02 +00:00
java/d: remove useless macros
There are many macros that are defined and used just once (b4_public_if, b4_abstract_if, etc.). That's overkill. Rather, let's define a macro to build the "public class YYParser" line. It appears that the same syntax with "extends", "abstract", etc. is implemented in the D parser, which looks very fishy... * data/skeletons/d.m4, data/skeletons/java.m4 (b4_public_if) (b4_abstract_if, b4_final_if, b4_strictfp_if): Replace with (b4_parser_class_declaration): this. * data/skeletons/lalr1.d, data/skeletons/lalr1.java: Adjust.
This commit is contained in:
@@ -46,25 +46,22 @@ m4_define([b4_percent_define_get3],
|
|||||||
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
|
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
|
||||||
|
|
||||||
|
|
||||||
# b4_public_if(TRUE, FALSE)
|
# b4_parser_class_declaration
|
||||||
# -------------------------
|
|
||||||
b4_percent_define_default([[public]], [[false]])
|
|
||||||
m4_define([b4_public_if],
|
|
||||||
[b4_percent_define_flag_if([public], [$1], [$2])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_abstract_if(TRUE, FALSE)
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
# The declaration of the parser class ("class YYParser"), with all its
|
||||||
|
# qualifiers/annotations.
|
||||||
|
b4_percent_define_default([[public]], [[false]])
|
||||||
b4_percent_define_default([[abstract]], [[false]])
|
b4_percent_define_default([[abstract]], [[false]])
|
||||||
m4_define([b4_abstract_if],
|
b4_percent_define_default([[final]], [[false]])
|
||||||
[b4_percent_define_flag_if([abstract], [$1], [$2])])
|
|
||||||
|
|
||||||
|
m4_define([b4_parser_class_declaration],
|
||||||
# b4_final_if(TRUE, FALSE)
|
[b4_percent_define_get3([annotations], [], [ ])dnl
|
||||||
# ---------------------------
|
b4_percent_define_flag_if([public], [public ])dnl
|
||||||
b4_percent_define_default([[final]], [[false]])
|
b4_percent_define_flag_if([abstract], [abstract ])dnl
|
||||||
m4_define([b4_final_if],
|
b4_percent_define_flag_if([final], [final ])dnl
|
||||||
[b4_percent_define_flag_if([final], [$1], [$2])])
|
[class ]b4_parser_class[]dnl
|
||||||
|
b4_percent_define_get3([extends], [ extends ])dnl
|
||||||
|
b4_percent_define_get3([implements], [ implements ])])
|
||||||
|
|
||||||
|
|
||||||
# b4_lexer_if(TRUE, FALSE)
|
# b4_lexer_if(TRUE, FALSE)
|
||||||
@@ -74,20 +71,22 @@ m4_define([b4_lexer_if],
|
|||||||
|
|
||||||
|
|
||||||
# b4_position_type_if(TRUE, FALSE)
|
# b4_position_type_if(TRUE, FALSE)
|
||||||
# ------------------------
|
# --------------------------------
|
||||||
m4_define([b4_position_type_if],
|
m4_define([b4_position_type_if],
|
||||||
[b4_percent_define_ifdef([[position_type]], [$1], [$2])])
|
[b4_percent_define_ifdef([[position_type]], [$1], [$2])])
|
||||||
|
|
||||||
|
|
||||||
# b4_location_type_if(TRUE, FALSE)
|
# b4_location_type_if(TRUE, FALSE)
|
||||||
# ------------------------
|
# --------------------------------
|
||||||
m4_define([b4_location_type_if],
|
m4_define([b4_location_type_if],
|
||||||
[b4_percent_define_ifdef([[location_type]], [$1], [$2])])
|
[b4_percent_define_ifdef([[location_type]], [$1], [$2])])
|
||||||
|
|
||||||
|
|
||||||
# b4_locations_if(TRUE, FALSE)
|
# b4_locations_if(TRUE, FALSE)
|
||||||
|
# ----------------------------
|
||||||
m4_define([b4_locations_if],
|
m4_define([b4_locations_if],
|
||||||
[m4_if(b4_locations_flag,1,[$1],[$2])])
|
[m4_if(b4_locations_flag, 1, [$1], [$2])])
|
||||||
|
|
||||||
|
|
||||||
# b4_identification
|
# b4_identification
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
@@ -42,32 +42,24 @@ m4_define([b4_percent_define_get3],
|
|||||||
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
|
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
|
||||||
|
|
||||||
|
|
||||||
# b4_public_if(TRUE, FALSE)
|
# b4_parser_class_declaration
|
||||||
# -------------------------
|
|
||||||
b4_percent_define_default([[public]], [[false]])
|
|
||||||
m4_define([b4_public_if],
|
|
||||||
[b4_percent_define_flag_if([public], [$1], [$2])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_abstract_if(TRUE, FALSE)
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
# The declaration of the parser class ("class YYParser"), with all its
|
||||||
|
# qualifiers/annotations.
|
||||||
|
b4_percent_define_default([[public]], [[false]])
|
||||||
b4_percent_define_default([[abstract]], [[false]])
|
b4_percent_define_default([[abstract]], [[false]])
|
||||||
m4_define([b4_abstract_if],
|
b4_percent_define_default([[final]], [[false]])
|
||||||
[b4_percent_define_flag_if([abstract], [$1], [$2])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_final_if(TRUE, FALSE)
|
|
||||||
# ---------------------------
|
|
||||||
b4_percent_define_default([[final]], [[false]])
|
|
||||||
m4_define([b4_final_if],
|
|
||||||
[b4_percent_define_flag_if([final], [$1], [$2])])
|
|
||||||
|
|
||||||
|
|
||||||
# b4_strictfp_if(TRUE, FALSE)
|
|
||||||
# ---------------------------
|
|
||||||
b4_percent_define_default([[strictfp]], [[false]])
|
b4_percent_define_default([[strictfp]], [[false]])
|
||||||
m4_define([b4_strictfp_if],
|
|
||||||
[b4_percent_define_flag_if([strictfp], [$1], [$2])])
|
m4_define([b4_parser_class_declaration],
|
||||||
|
[b4_percent_define_get3([annotations], [], [ ])dnl
|
||||||
|
b4_percent_define_flag_if([public], [public ])dnl
|
||||||
|
b4_percent_define_flag_if([abstract], [abstract ])dnl
|
||||||
|
b4_percent_define_flag_if([final], [final ])dnl
|
||||||
|
b4_percent_define_flag_if([strictfp], [strictfp ])dnl
|
||||||
|
[class ]b4_parser_class[]dnl
|
||||||
|
b4_percent_define_get3([extends], [ extends ])dnl
|
||||||
|
b4_percent_define_get3([implements], [ implements ])])
|
||||||
|
|
||||||
|
|
||||||
# b4_lexer_if(TRUE, FALSE)
|
# b4_lexer_if(TRUE, FALSE)
|
||||||
@@ -180,7 +172,7 @@ b4_percent_define_check_kind([[extends]], [code], [deprecated])
|
|||||||
b4_percent_define_check_kind([[implements]], [code], [deprecated])
|
b4_percent_define_check_kind([[implements]], [code], [deprecated])
|
||||||
b4_percent_define_check_kind([[init_throws]], [code], [deprecated])
|
b4_percent_define_check_kind([[init_throws]], [code], [deprecated])
|
||||||
b4_percent_define_check_kind([[lex_throws]], [code], [deprecated])
|
b4_percent_define_check_kind([[lex_throws]], [code], [deprecated])
|
||||||
b4_percent_define_check_kind([[api.parser.class]], [code], [deprecated])
|
b4_percent_define_check_kind([[api.parser.class]], [code], [deprecated])
|
||||||
b4_percent_define_check_kind([[throws]], [code], [deprecated])
|
b4_percent_define_check_kind([[throws]], [code], [deprecated])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -129,12 +129,8 @@ b4_locations_if([, ref ]b4_location_type[ loc])[)
|
|||||||
public final void print (File stream)
|
public final void print (File stream)
|
||||||
{
|
{
|
||||||
stream.write ("Stack now");
|
stream.write ("Stack now");
|
||||||
|
|
||||||
for (int i = 0; i < stack.length; i++)
|
for (int i = 0; i < stack.length; i++)
|
||||||
{
|
stream.write (" %d", stack[i].state);
|
||||||
stream.write (' ');
|
|
||||||
stream.write ("%d", stack[i].state);
|
|
||||||
}
|
|
||||||
stream.writeln ();
|
stream.writeln ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -230,12 +226,7 @@ b4_user_union_members
|
|||||||
[m4_if(b4_tag_seen_flag, 0,
|
[m4_if(b4_tag_seen_flag, 0,
|
||||||
[[private alias int YYSemanticType;]])])[
|
[[private alias int YYSemanticType;]])])[
|
||||||
]b4_token_enums(b4_tokens)[
|
]b4_token_enums(b4_tokens)[
|
||||||
]b4_public_if([public ])dnl
|
]b4_parser_class_declaration[
|
||||||
b4_abstract_if([abstract ])dnl
|
|
||||||
b4_final_if([final ])dnl
|
|
||||||
[class ]b4_parser_class[]dnl
|
|
||||||
b4_percent_define_get3([extends], [ extends ])dnl
|
|
||||||
b4_percent_define_get3([implements], [ implements ])[
|
|
||||||
{
|
{
|
||||||
]b4_identification[
|
]b4_identification[
|
||||||
|
|
||||||
|
|||||||
@@ -95,14 +95,7 @@ b4_output_begin([b4_parser_file_name])[
|
|||||||
*
|
*
|
||||||
* @@author LALR (1) parser skeleton written by Paolo Bonzini.
|
* @@author LALR (1) parser skeleton written by Paolo Bonzini.
|
||||||
*/
|
*/
|
||||||
]b4_percent_define_get3([annotations], [], [ ])dnl
|
]b4_parser_class_declaration[
|
||||||
b4_public_if([public ])dnl
|
|
||||||
b4_abstract_if([abstract ])dnl
|
|
||||||
b4_final_if([final ])dnl
|
|
||||||
b4_strictfp_if([strictfp ])dnl
|
|
||||||
[class ]b4_parser_class[]dnl
|
|
||||||
b4_percent_define_get3([extends], [ extends ])dnl
|
|
||||||
b4_percent_define_get3([implements], [ implements ])[
|
|
||||||
{
|
{
|
||||||
]b4_identification[
|
]b4_identification[
|
||||||
]b4_error_verbose_if([[
|
]b4_error_verbose_if([[
|
||||||
@@ -389,8 +382,7 @@ b4_lexer_if([[
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Print the state stack on the debug stream.
|
// Print the state stack on the debug stream.
|
||||||
public void print (java.io.PrintStream out)
|
public void print (java.io.PrintStream out) {
|
||||||
{
|
|
||||||
out.print ("Stack now");
|
out.print ("Stack now");
|
||||||
|
|
||||||
for (int i = 0; i <= height; i++)
|
for (int i = 0; i <= height; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user