mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
* doc/gpl-3.0.texi: New file. * doc/gpl.texi: Remove. * COPYING, GNUmakefile, HACKING, Makefile.am, Makefile.cfg: * Makefile.maint, NEWS, PACKAGING, README, README-alpha: * README-hacking, TODO, bootstrap, bootstrap.conf: * configure.ac, data/Makefile.am, data/README, data/bison.m4: * data/c++-skel.m4, data/c++.m4, data/c-skel.m4, data/c.m4: * data/glr.c, data/glr.cc, data/java-skel.m4, data/java.m4: * data/lalr1.cc, data/lalr1.java, data/location.cc: * data/push.c, data/yacc.c, data/m4sugar/m4sugar.m4: * djgpp/Makefile.maint, djgpp/README.in, djgpp/config.bat: * djgpp/config.sed, djgpp/config.site, djgpp/config_h.sed: * djgpp/djunpack.bat, djgpp/subpipe.c, djgpp/subpipe.h: * djgpp/testsuite.sed, doc/Makefile.am, doc/bison.texinfo: * doc/fdl.texi, doc/refcard.tex, etc/Makefile.am, etc/README: * etc/bench.pl.in, examples/Makefile.am, examples/extexi: * examples/calc++/Makefile.am, lib/Makefile.am, lib/abitset.c: * lib/abitset.h, lib/bbitset.h, lib/bitset.c, lib/bitset.h: * lib/bitset_stats.c, lib/bitset_stats.h, lib/bitsetv-print.c: * lib/bitsetv-print.h, lib/bitsetv.c, lib/bitsetv.h: * lib/ebitset.c, lib/ebitset.h, lib/get-errno.c: * lib/get-errno.h, lib/lbitset.c, lib/lbitset.h: * lib/libiberty.h, lib/main.c, lib/subpipe.c, lib/subpipe.h: * lib/timevar.c, lib/timevar.def, lib/timevar.h: * lib/vbitset.c, lib/vbitset.h, lib/yyerror.c: * m4/c-working.m4, m4/cxx.m4, m4/m4.m4, m4/subpipe.m4: * m4/timevar.m4, src/LR0.c, src/LR0.h, src/Makefile.am: * src/assoc.c, src/assoc.h, src/closure.c, src/closure.h: * src/complain.c, src/complain.h, src/conflicts.c: * src/conflicts.h, src/derives.c, src/derives.h, src/files.c: * src/files.h, src/flex-scanner.h, src/getargs.c: * src/getargs.h, src/gram.c, src/gram.h, src/graphviz.c: * src/lalr.c, src/lalr.h, src/location.c, src/location.h: * src/main.c, src/muscle_tab.c, src/muscle_tab.h: * src/nullable.c, src/nullable.h, src/output.c, src/output.h: * src/parse-gram.c, src/parse-gram.h, src/parse-gram.y: * src/print.c, src/print.h, src/print_graph.c: * src/print_graph.h, src/reader.c, src/reader.h, src/reduce.c: * src/reduce.h, src/relation.c, src/relation.h: * src/revision.h, src/scan-code.h, src/scan-code.l: * src/scan-gram.h, src/scan-gram.l, src/scan-skel.h: * src/scan-skel.l, src/state.c, src/state.h, src/symlist.c: * src/symlist.h, src/symtab.c, src/symtab.h, src/system.h: * src/tables.c, src/tables.h, src/uniqstr.c, src/uniqstr.h: * tests/Makefile.am, tests/actions.at, tests/c++.at: * tests/calc.at, tests/conflicts.at, tests/cxx-type.at: * tests/existing.at, tests/glr-regression.at: * tests/headers.at, tests/input.at, tests/java.at: * tests/local.at, tests/output.at, tests/push.at: * tests/reduce.at, tests/regression.at, tests/sets.at: * tests/skeletons.at, tests/synclines.at, tests/testsuite.at: * tests/torture.at: Update to GPLv3.
274 lines
7.2 KiB
Plaintext
274 lines
7.2 KiB
Plaintext
-*- Autoconf -*-
|
|
|
|
# Java language support for Bison
|
|
|
|
# Copyright (C) 2007 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/>.
|
|
|
|
|
|
# b4_comment(TEXT)
|
|
# ----------------
|
|
m4_define([b4_comment], [/* m4_bpatsubst([$1], [
|
|
], [
|
|
]) */])
|
|
|
|
|
|
# b4_flag_value(BOOLEAN-FLAG)
|
|
# ---------------------------
|
|
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
|
|
|
|
|
|
# b4_public_if(TRUE, FALSE)
|
|
# -------------------------
|
|
b4_percent_define_default([[public]], [[false]])
|
|
m4_define([b4_public_if],
|
|
[b4_percent_define_flag_if([public], [$1], [$2])])
|
|
|
|
|
|
# b4_abstract_if(TRUE, FALSE)
|
|
# ---------------------------
|
|
b4_percent_define_default([[abstract]], [[false]])
|
|
m4_define([b4_abstract_if],
|
|
[b4_percent_define_flag_if([abstract], [$1], [$2])])
|
|
|
|
|
|
# b4_lexer_if(TRUE, FALSE)
|
|
# ------------------------
|
|
m4_define([b4_lexer_if],
|
|
[b4_percent_code_ifdef([[lexer]], [$1], [$2])])
|
|
|
|
|
|
# b4_identification
|
|
# -----------------
|
|
m4_define([b4_identification],
|
|
[/** Always <tt>true</tt>, identifies Bison output. */
|
|
public static final boolean bison = true;
|
|
|
|
/** Version number for the Bison executable that generated this parser. */
|
|
public static final String bisonVersion = "b4_version";
|
|
|
|
/** Name of the skeleton that generated this parser. */
|
|
public static final String bisonSkeleton = b4_skeleton;
|
|
])
|
|
|
|
|
|
## ------------ ##
|
|
## Data types. ##
|
|
## ------------ ##
|
|
|
|
# b4_int_type(MIN, MAX)
|
|
# ---------------------
|
|
# Return the smallest int type able to handle numbers ranging from
|
|
# MIN to MAX (included).
|
|
m4_define([b4_int_type],
|
|
[m4_if(b4_ints_in($@, [-128], [127]), [1], [byte],
|
|
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
|
[int])])
|
|
|
|
# b4_int_type_for(NAME)
|
|
# ---------------------
|
|
# Return the smallest int type able to handle numbers ranging from
|
|
# `NAME_min' to `NAME_max' (included).
|
|
m4_define([b4_int_type_for],
|
|
[b4_int_type($1_min, $1_max)])
|
|
|
|
# b4_null
|
|
# -------
|
|
m4_define([b4_null], [null])
|
|
|
|
|
|
## ------------------------- ##
|
|
## Assigning token numbers. ##
|
|
## ------------------------- ##
|
|
|
|
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
|
# ---------------------------------------
|
|
# Output the definition of this token as an enum.
|
|
m4_define([b4_token_enum],
|
|
[ /** Token number, to be returned by the scanner. */
|
|
public static final int $1 = $2;
|
|
])
|
|
|
|
|
|
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
|
# -----------------------------------------------------
|
|
# Output the definition of the tokens (if there are) as enums.
|
|
m4_define([b4_token_enums],
|
|
[m4_if([$@], [[]], [],
|
|
[/* Tokens. */
|
|
m4_map([b4_token_enum], [$@])])
|
|
])
|
|
|
|
# b4-case(ID, CODE)
|
|
# -----------------
|
|
# We need to fool Java's stupid unreachable code detection.
|
|
m4_define([b4_case], [ case $1:
|
|
if (yyn == $1)
|
|
$2;
|
|
break;
|
|
])
|
|
|
|
|
|
## ---------------- ##
|
|
## Default values. ##
|
|
## ---------------- ##
|
|
|
|
m4_define([b4_yystype], [b4_percent_define_get([[stype]])])
|
|
b4_percent_define_default([[stype]], [[Object]])])
|
|
|
|
m4_define_default([[b4_prefix]], [[YY]])])
|
|
b4_percent_define_default([[parser_class_name]], [b4_prefix[]Parser])])
|
|
m4_define([b4_parser_class_name], [b4_percent_define_get([[parser_class_name]])])
|
|
|
|
b4_percent_define_default([[lex_throws]], [[java.io.IOException]])])
|
|
m4_define([b4_lex_throws], [b4_percent_define_get([[lex_throws]])])
|
|
|
|
b4_percent_define_default([[throws]], [b4_lex_throws])])
|
|
m4_define([b4_throws], [b4_percent_define_get([[throws]])])
|
|
|
|
b4_percent_define_default([[location_type]], [Location])])
|
|
m4_define([b4_location_type], [b4_percent_define_get([[location_type]])])
|
|
|
|
b4_percent_define_default([[position_type]], [Position])])
|
|
m4_define([b4_position_type], [b4_percent_define_get([[position_type]])])
|
|
|
|
|
|
## ----------------- ##
|
|
## Semantic Values. ##
|
|
## ----------------- ##
|
|
|
|
|
|
# b4_lhs_value([TYPE])
|
|
# --------------------
|
|
# Expansion of $<TYPE>$.
|
|
m4_define([b4_lhs_value], [yyval])
|
|
|
|
|
|
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
|
|
# --------------------------------------
|
|
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
|
|
# symbols on RHS.
|
|
#
|
|
# In this simple implementation, %token and %type have class names
|
|
# between the angle brackets.
|
|
m4_define([b4_rhs_value],
|
|
[(m4_ifval($3, [($3)])[](yystack.valueAt ($1-($2))))])
|
|
|
|
# b4_lhs_location()
|
|
# -----------------
|
|
# Expansion of @$.
|
|
m4_define([b4_lhs_location],
|
|
[(yyloc)])
|
|
|
|
|
|
# b4_rhs_location(RULE-LENGTH, NUM)
|
|
# ---------------------------------
|
|
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
|
# on RHS.
|
|
m4_define([b4_rhs_location],
|
|
[yystack.locationAt ($1-($2))])
|
|
|
|
|
|
# b4_lex_param
|
|
# b4_parse_param
|
|
# --------------
|
|
# If defined, b4_lex_param arrives double quoted, but below we prefer
|
|
# it to be single quoted. Same for b4_parse_param.
|
|
|
|
# TODO: should be in bison.m4
|
|
m4_define_default([b4_lex_param], [[]]))
|
|
m4_define([b4_lex_param], b4_lex_param))
|
|
m4_define([b4_parse_param], b4_parse_param))
|
|
|
|
# b4_lex_param_decl
|
|
# -------------------
|
|
# Extra formal arguments of the constructor.
|
|
m4_define([b4_lex_param_decl],
|
|
[m4_ifset([b4_lex_param],
|
|
[b4_remove_comma([$1],
|
|
b4_param_decls(b4_lex_param))],
|
|
[$1])])
|
|
|
|
m4_define([b4_param_decls],
|
|
[m4_map([b4_param_decl], [$@])])
|
|
m4_define([b4_param_decl], [, $1])
|
|
|
|
m4_define([b4_remove_comma], [m4_ifval($1, [$1, ], [])m4_shiftn(2, $@)])
|
|
|
|
|
|
|
|
# b4_parse_param_decl
|
|
# -------------------
|
|
# Extra formal arguments of the constructor.
|
|
m4_define([b4_parse_param_decl],
|
|
[m4_ifset([b4_parse_param],
|
|
[b4_remove_comma([$1],
|
|
b4_param_decls(b4_parse_param))],
|
|
[$1])])
|
|
|
|
|
|
|
|
# b4_lex_param_call
|
|
# -------------------
|
|
# Delegating the lexer parameters to the lexer constructor.
|
|
m4_define([b4_lex_param_call],
|
|
[m4_ifset([b4_lex_param],
|
|
[b4_remove_comma([$1],
|
|
b4_param_calls(b4_lex_param))],
|
|
[$1])])
|
|
m4_define([b4_param_calls],
|
|
[m4_map([b4_param_call], [$@])])
|
|
m4_define([b4_param_call], [, $2])
|
|
|
|
|
|
|
|
# b4_parse_param_cons
|
|
# -------------------
|
|
# Extra initialisations of the constructor.
|
|
m4_define([b4_parse_param_cons],
|
|
[m4_ifset([b4_parse_param],
|
|
[b4_constructor_calls(b4_parse_param)])])
|
|
|
|
m4_define([b4_constructor_calls],
|
|
[m4_map([b4_constructor_call], [$@])])
|
|
m4_define([b4_constructor_call],
|
|
[this.$2 = $2;
|
|
])
|
|
|
|
|
|
|
|
# b4_parse_param_vars
|
|
# -------------------
|
|
# Extra instance variables.
|
|
m4_define([b4_parse_param_vars],
|
|
[m4_ifset([b4_parse_param],
|
|
[
|
|
/* User arguments. */
|
|
b4_var_decls(b4_parse_param)])])
|
|
|
|
m4_define([b4_var_decls],
|
|
[m4_map_sep([b4_var_decl], [
|
|
], [$@])])
|
|
m4_define([b4_var_decl],
|
|
[ protected final $1;])
|
|
|
|
|
|
|
|
# b4_maybe_throws(THROWS)
|
|
# -----------------------
|
|
# Expand to either an empty string or "throws THROWS".
|
|
m4_define([b4_maybe_throws],
|
|
[m4_ifval($1, [throws $1])])
|