Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- platform/dbops/binaries/build/share/bison/m4sugar/foreach.m4 +362 -0
- platform/dbops/binaries/build/share/bison/m4sugar/m4sugar.m4 +0 -0
- platform/dbops/binaries/build/share/bison/skeletons/bison.m4 +1241 -0
- platform/dbops/binaries/build/share/bison/skeletons/c++-skel.m4 +27 -0
- platform/dbops/binaries/build/share/bison/skeletons/c++.m4 +778 -0
- platform/dbops/binaries/build/share/bison/skeletons/c-like.m4 +72 -0
- platform/dbops/binaries/build/share/bison/skeletons/c-skel.m4 +27 -0
- platform/dbops/binaries/build/share/bison/skeletons/c.m4 +1125 -0
- platform/dbops/binaries/build/share/bison/skeletons/d-skel.m4 +26 -0
- platform/dbops/binaries/build/share/bison/skeletons/d.m4 +628 -0
- platform/dbops/binaries/build/share/bison/skeletons/glr.c +2763 -0
- platform/dbops/binaries/build/share/bison/skeletons/glr.cc +397 -0
- platform/dbops/binaries/build/share/bison/skeletons/glr2.cc +0 -0
- platform/dbops/binaries/build/share/bison/skeletons/java-skel.m4 +27 -0
- platform/dbops/binaries/build/share/bison/skeletons/java.m4 +502 -0
- platform/dbops/binaries/build/share/bison/skeletons/lalr1.cc +1633 -0
- platform/dbops/binaries/build/share/bison/skeletons/lalr1.d +1326 -0
- platform/dbops/binaries/build/share/bison/skeletons/lalr1.java +1303 -0
- platform/dbops/binaries/build/share/bison/skeletons/location.cc +380 -0
- platform/dbops/binaries/build/share/bison/skeletons/stack.hh +157 -0
- platform/dbops/binaries/build/share/bison/skeletons/traceon.m4 +2 -0
- platform/dbops/binaries/build/share/bison/skeletons/variant.hh +525 -0
- platform/dbops/binaries/build/share/bison/skeletons/yacc.c +2209 -0
- platform/dbops/binaries/build/share/bison/xslt/bison.xsl +105 -0
- platform/dbops/binaries/build/share/bison/xslt/xml2dot.xsl +401 -0
- platform/dbops/binaries/build/share/bison/xslt/xml2text.xsl +572 -0
- platform/dbops/binaries/build/share/bison/xslt/xml2xhtml.xsl +765 -0
- platform/dbops/binaries/build/share/doc/bison/AUTHORS +42 -0
- platform/dbops/binaries/build/share/doc/bison/COPYING +674 -0
- platform/dbops/binaries/build/share/doc/bison/NEWS +0 -0
- platform/dbops/binaries/build/share/doc/bison/README +135 -0
- platform/dbops/binaries/build/share/doc/bison/THANKS +256 -0
- platform/dbops/binaries/build/share/doc/bison/TODO +723 -0
- platform/dbops/binaries/build/share/doc/bison/examples/README.md +28 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c++/Makefile +21 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c++/README.md +68 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c++/calc++/Makefile +36 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c++/calc++/README.md +49 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c++/calc++/calc++.cc +38 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c++/calc++/driver.cc +41 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c++/calc++/driver.hh +57 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c++/calc++/parser.yy +92 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c++/calc++/scanner.ll +171 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c++/simple.yy +99 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c++/variant-11.yy +154 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c++/variant.yy +154 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c/README.md +99 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c/bistromathic/Makefile +35 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c/bistromathic/README.md +49 -0
- platform/dbops/binaries/build/share/doc/bison/examples/c/bistromathic/parse.y +695 -0
platform/dbops/binaries/build/share/bison/m4sugar/foreach.m4
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- Autoconf -*-
|
| 2 |
+
# This file is part of Autoconf.
|
| 3 |
+
# foreach-based replacements for recursive functions.
|
| 4 |
+
# Speeds up GNU M4 1.4.x by avoiding quadratic $@ recursion, but penalizes
|
| 5 |
+
# GNU M4 1.6 by requiring more memory and macro expansions.
|
| 6 |
+
#
|
| 7 |
+
# Copyright (C) 2008-2017, 2020 Free Software Foundation, Inc.
|
| 8 |
+
|
| 9 |
+
# This file is part of Autoconf. This program is free
|
| 10 |
+
# software; you can redistribute it and/or modify it under the
|
| 11 |
+
# terms of the GNU General Public License as published by the
|
| 12 |
+
# Free Software Foundation, either version 3 of the License, or
|
| 13 |
+
# (at your option) any later version.
|
| 14 |
+
#
|
| 15 |
+
# This program is distributed in the hope that it will be useful,
|
| 16 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 17 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 18 |
+
# GNU General Public License for more details.
|
| 19 |
+
#
|
| 20 |
+
# Under Section 7 of GPL version 3, you are granted additional
|
| 21 |
+
# permissions described in the Autoconf Configure Script Exception,
|
| 22 |
+
# version 3.0, as published by the Free Software Foundation.
|
| 23 |
+
#
|
| 24 |
+
# You should have received a copy of the GNU General Public License
|
| 25 |
+
# and a copy of the Autoconf Configure Script Exception along with
|
| 26 |
+
# this program; see the files COPYINGv3 and COPYING.EXCEPTION
|
| 27 |
+
# respectively. If not, see <https://www.gnu.org/licenses/>.
|
| 28 |
+
|
| 29 |
+
# Written by Eric Blake.
|
| 30 |
+
|
| 31 |
+
# In M4 1.4.x, every byte of $@ is rescanned. This means that an
|
| 32 |
+
# algorithm on n arguments that recurses with one less argument each
|
| 33 |
+
# iteration will scan n * (n + 1) / 2 arguments, for O(n^2) time. In
|
| 34 |
+
# M4 1.6, this was fixed so that $@ is only scanned once, then
|
| 35 |
+
# back-references are made to information stored about the scan.
|
| 36 |
+
# Thus, n iterations need only scan n arguments, for O(n) time.
|
| 37 |
+
# Additionally, in M4 1.4.x, recursive algorithms did not clean up
|
| 38 |
+
# memory very well, requiring O(n^2) memory rather than O(n) for n
|
| 39 |
+
# iterations.
|
| 40 |
+
#
|
| 41 |
+
# This file is designed to overcome the quadratic nature of $@
|
| 42 |
+
# recursion by writing a variant of m4_foreach that uses m4_for rather
|
| 43 |
+
# than $@ recursion to operate on the list. This involves more macro
|
| 44 |
+
# expansions, but avoids the need to rescan a quadratic number of
|
| 45 |
+
# arguments, making these replacements very attractive for M4 1.4.x.
|
| 46 |
+
# On the other hand, in any version of M4, expanding additional macros
|
| 47 |
+
# costs additional time; therefore, in M4 1.6, where $@ recursion uses
|
| 48 |
+
# fewer macros, these replacements actually pessimize performance.
|
| 49 |
+
# Additionally, the use of $10 to mean the tenth argument violates
|
| 50 |
+
# POSIX; although all versions of m4 1.4.x support this meaning, a
|
| 51 |
+
# future m4 version may switch to take it as the first argument
|
| 52 |
+
# concatenated with a literal 0, so the implementations in this file
|
| 53 |
+
# are not future-proof. Thus, this file is conditionally included as
|
| 54 |
+
# part of m4_init(), only when it is detected that M4 probably has
|
| 55 |
+
# quadratic behavior (ie. it lacks the macro __m4_version__).
|
| 56 |
+
#
|
| 57 |
+
# Please keep this file in sync with m4sugar.m4.
|
| 58 |
+
|
| 59 |
+
# _m4_foreach(PRE, POST, IGNORED, ARG...)
|
| 60 |
+
# ---------------------------------------
|
| 61 |
+
# Form the common basis of the m4_foreach and m4_map macros. For each
|
| 62 |
+
# ARG, expand PRE[ARG]POST[]. The IGNORED argument makes recursion
|
| 63 |
+
# easier, and must be supplied rather than implicit.
|
| 64 |
+
#
|
| 65 |
+
# This version minimizes the number of times that $@ is evaluated by
|
| 66 |
+
# using m4_for to generate a boilerplate into _m4_f then passing $@ to
|
| 67 |
+
# that temporary macro. Thus, the recursion is done in m4_for without
|
| 68 |
+
# reparsing any user input, and is not quadratic. For an idea of how
|
| 69 |
+
# this works, note that m4_foreach(i,[1,2],[i]) calls
|
| 70 |
+
# _m4_foreach([m4_define([i],],[)i],[],[1],[2])
|
| 71 |
+
# which defines _m4_f:
|
| 72 |
+
# $1[$4]$2[]$1[$5]$2[]_m4_popdef([_m4_f])
|
| 73 |
+
# then calls _m4_f([m4_define([i],],[)i],[],[1],[2]) for a net result:
|
| 74 |
+
# m4_define([i],[1])i[]m4_define([i],[2])i[]_m4_popdef([_m4_f]).
|
| 75 |
+
m4_define([_m4_foreach],
|
| 76 |
+
[m4_if([$#], [3], [],
|
| 77 |
+
[m4_pushdef([_m4_f], _m4_for([4], [$#], [1],
|
| 78 |
+
[$0_([1], [2],], [)])[_m4_popdef([_m4_f])])_m4_f($@)])])
|
| 79 |
+
|
| 80 |
+
m4_define([_m4_foreach_],
|
| 81 |
+
[[$$1[$$3]$$2[]]])
|
| 82 |
+
|
| 83 |
+
# m4_case(SWITCH, VAL1, IF-VAL1, VAL2, IF-VAL2, ..., DEFAULT)
|
| 84 |
+
# -----------------------------------------------------------
|
| 85 |
+
# Find the first VAL that SWITCH matches, and expand the corresponding
|
| 86 |
+
# IF-VAL. If there are no matches, expand DEFAULT.
|
| 87 |
+
#
|
| 88 |
+
# Use m4_for to create a temporary macro in terms of a boilerplate
|
| 89 |
+
# m4_if with final cleanup. If $# is even, we have DEFAULT; if it is
|
| 90 |
+
# odd, then rounding the last $# up in the temporary macro is
|
| 91 |
+
# harmless. For example, both m4_case(1,2,3,4,5) and
|
| 92 |
+
# m4_case(1,2,3,4,5,6) result in the intermediate _m4_case being
|
| 93 |
+
# m4_if([$1],[$2],[$3],[$1],[$4],[$5],_m4_popdef([_m4_case])[$6])
|
| 94 |
+
m4_define([m4_case],
|
| 95 |
+
[m4_if(m4_eval([$# <= 2]), [1], [$2],
|
| 96 |
+
[m4_pushdef([_$0], [m4_if(]_m4_for([2], m4_eval([($# - 1) / 2 * 2]), [2],
|
| 97 |
+
[_$0_(], [)])[_m4_popdef(
|
| 98 |
+
[_$0])]m4_dquote($m4_eval([($# + 1) & ~1]))[)])_$0($@)])])
|
| 99 |
+
|
| 100 |
+
m4_define([_m4_case_],
|
| 101 |
+
[$0_([1], [$1], m4_incr([$1]))])
|
| 102 |
+
|
| 103 |
+
m4_define([_m4_case__],
|
| 104 |
+
[[[$$1],[$$2],[$$3],]])
|
| 105 |
+
|
| 106 |
+
# m4_bmatch(SWITCH, RE1, VAL1, RE2, VAL2, ..., DEFAULT)
|
| 107 |
+
# -----------------------------------------------------
|
| 108 |
+
# m4 equivalent of
|
| 109 |
+
#
|
| 110 |
+
# if (SWITCH =~ RE1)
|
| 111 |
+
# VAL1;
|
| 112 |
+
# elif (SWITCH =~ RE2)
|
| 113 |
+
# VAL2;
|
| 114 |
+
# elif ...
|
| 115 |
+
# ...
|
| 116 |
+
# else
|
| 117 |
+
# DEFAULT
|
| 118 |
+
#
|
| 119 |
+
# We build the temporary macro _m4_b:
|
| 120 |
+
# m4_define([_m4_b], _m4_defn([_m4_bmatch]))_m4_b([$1], [$2], [$3])...
|
| 121 |
+
# _m4_b([$1], [$m-1], [$m])_m4_b([], [], [$m+1]_m4_popdef([_m4_b]))
|
| 122 |
+
# then invoke m4_unquote(_m4_b($@)), for concatenation with later text.
|
| 123 |
+
m4_define([m4_bmatch],
|
| 124 |
+
[m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],
|
| 125 |
+
[$#], 1, [m4_fatal([$0: too few arguments: $#: $1])],
|
| 126 |
+
[$#], 2, [$2],
|
| 127 |
+
[m4_pushdef([_m4_b], [m4_define([_m4_b],
|
| 128 |
+
_m4_defn([_$0]))]_m4_for([3], m4_eval([($# + 1) / 2 * 2 - 1]),
|
| 129 |
+
[2], [_$0_(], [)])[_m4_b([], [],]m4_dquote([$]m4_eval(
|
| 130 |
+
[($# + 1) / 2 * 2]))[_m4_popdef([_m4_b]))])m4_unquote(_m4_b($@))])])
|
| 131 |
+
|
| 132 |
+
m4_define([_m4_bmatch],
|
| 133 |
+
[m4_if(m4_bregexp([$1], [$2]), [-1], [], [[$3]m4_define([$0])])])
|
| 134 |
+
|
| 135 |
+
m4_define([_m4_bmatch_],
|
| 136 |
+
[$0_([1], m4_decr([$1]), [$1])])
|
| 137 |
+
|
| 138 |
+
m4_define([_m4_bmatch__],
|
| 139 |
+
[[_m4_b([$$1], [$$2], [$$3])]])
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
# m4_cond(TEST1, VAL1, IF-VAL1, TEST2, VAL2, IF-VAL2, ..., [DEFAULT])
|
| 143 |
+
# -------------------------------------------------------------------
|
| 144 |
+
# Similar to m4_if, except that each TEST is expanded when encountered.
|
| 145 |
+
# If the expansion of TESTn matches the string VALn, the result is IF-VALn.
|
| 146 |
+
# The result is DEFAULT if no tests passed. This macro allows
|
| 147 |
+
# short-circuiting of expensive tests, where it pays to arrange quick
|
| 148 |
+
# filter tests to run first.
|
| 149 |
+
#
|
| 150 |
+
# m4_cond already guarantees either 3*n or 3*n + 1 arguments, 1 <= n.
|
| 151 |
+
# We only have to speed up _m4_cond, by building the temporary _m4_c:
|
| 152 |
+
# m4_define([_m4_c], _m4_defn([m4_unquote]))_m4_c([m4_if(($1), [($2)],
|
| 153 |
+
# [[$3]m4_define([_m4_c])])])_m4_c([m4_if(($4), [($5)],
|
| 154 |
+
# [[$6]m4_define([_m4_c])])])..._m4_c([m4_if(($m-2), [($m-1)],
|
| 155 |
+
# [[$m]m4_define([_m4_c])])])_m4_c([[$m+1]]_m4_popdef([_m4_c]))
|
| 156 |
+
# We invoke m4_unquote(_m4_c($@)), for concatenation with later text.
|
| 157 |
+
m4_define([_m4_cond],
|
| 158 |
+
[m4_pushdef([_m4_c], [m4_define([_m4_c],
|
| 159 |
+
_m4_defn([m4_unquote]))]_m4_for([2], m4_eval([$# / 3 * 3 - 1]), [3],
|
| 160 |
+
[$0_(], [)])[_m4_c(]m4_dquote(m4_dquote(
|
| 161 |
+
[$]m4_eval([$# / 3 * 3 + 1])))[_m4_popdef([_m4_c]))])m4_unquote(_m4_c($@))])
|
| 162 |
+
|
| 163 |
+
m4_define([_m4_cond_],
|
| 164 |
+
[$0_(m4_decr([$1]), [$1], m4_incr([$1]))])
|
| 165 |
+
|
| 166 |
+
m4_define([_m4_cond__],
|
| 167 |
+
[[_m4_c([m4_if(($$1), [($$2)], [[$$3]m4_define([_m4_c])])])]])
|
| 168 |
+
|
| 169 |
+
# m4_bpatsubsts(STRING, RE1, SUBST1, RE2, SUBST2, ...)
|
| 170 |
+
# ----------------------------------------------------
|
| 171 |
+
# m4 equivalent of
|
| 172 |
+
#
|
| 173 |
+
# $_ = STRING;
|
| 174 |
+
# s/RE1/SUBST1/g;
|
| 175 |
+
# s/RE2/SUBST2/g;
|
| 176 |
+
# ...
|
| 177 |
+
#
|
| 178 |
+
# m4_bpatsubsts already validated an odd number of arguments; we only
|
| 179 |
+
# need to speed up _m4_bpatsubsts. To avoid nesting, we build the
|
| 180 |
+
# temporary _m4_p:
|
| 181 |
+
# m4_define([_m4_p], [$1])m4_define([_m4_p],
|
| 182 |
+
# m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$2], [$3]))m4_define([_m4_p],
|
| 183 |
+
# m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$4], [$5]))m4_define([_m4_p],...
|
| 184 |
+
# m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$m-1], [$m]))m4_unquote(
|
| 185 |
+
# _m4_defn([_m4_p])_m4_popdef([_m4_p]))
|
| 186 |
+
m4_define([_m4_bpatsubsts],
|
| 187 |
+
[m4_pushdef([_m4_p], [m4_define([_m4_p],
|
| 188 |
+
]m4_dquote([$]1)[)]_m4_for([3], [$#], [2], [$0_(],
|
| 189 |
+
[)])[m4_unquote(_m4_defn([_m4_p])_m4_popdef([_m4_p]))])_m4_p($@)])
|
| 190 |
+
|
| 191 |
+
m4_define([_m4_bpatsubsts_],
|
| 192 |
+
[$0_(m4_decr([$1]), [$1])])
|
| 193 |
+
|
| 194 |
+
m4_define([_m4_bpatsubsts__],
|
| 195 |
+
[[m4_define([_m4_p],
|
| 196 |
+
m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$$1], [$$2]))]])
|
| 197 |
+
|
| 198 |
+
# m4_shiftn(N, ...)
|
| 199 |
+
# -----------------
|
| 200 |
+
# Returns ... shifted N times. Useful for recursive "varargs" constructs.
|
| 201 |
+
#
|
| 202 |
+
# m4_shiftn already validated arguments; we only need to speed up
|
| 203 |
+
# _m4_shiftn. If N is 3, then we build the temporary _m4_s, defined as
|
| 204 |
+
# ,[$5],[$6],...,[$m]_m4_popdef([_m4_s])
|
| 205 |
+
# before calling m4_shift(_m4_s($@)).
|
| 206 |
+
m4_define([_m4_shiftn],
|
| 207 |
+
[m4_if(m4_incr([$1]), [$#], [], [m4_pushdef([_m4_s],
|
| 208 |
+
_m4_for(m4_eval([$1 + 2]), [$#], [1],
|
| 209 |
+
[[,]m4_dquote($], [)])[_m4_popdef([_m4_s])])m4_shift(_m4_s($@))])])
|
| 210 |
+
|
| 211 |
+
# m4_do(STRING, ...)
|
| 212 |
+
# ------------------
|
| 213 |
+
# This macro invokes all its arguments (in sequence, of course). It is
|
| 214 |
+
# useful for making your macros more structured and readable by dropping
|
| 215 |
+
# unnecessary dnl's and have the macros indented properly.
|
| 216 |
+
#
|
| 217 |
+
# Here, we use the temporary macro _m4_do, defined as
|
| 218 |
+
# $1[]$2[]...[]$n[]_m4_popdef([_m4_do])
|
| 219 |
+
m4_define([m4_do],
|
| 220 |
+
[m4_if([$#], [0], [],
|
| 221 |
+
[m4_pushdef([_$0], _m4_for([1], [$#], [1],
|
| 222 |
+
[$], [[[]]])[_m4_popdef([_$0])])_$0($@)])])
|
| 223 |
+
|
| 224 |
+
# m4_dquote_elt(ARGS)
|
| 225 |
+
# -------------------
|
| 226 |
+
# Return ARGS as an unquoted list of double-quoted arguments.
|
| 227 |
+
#
|
| 228 |
+
# _m4_foreach to the rescue.
|
| 229 |
+
m4_define([m4_dquote_elt],
|
| 230 |
+
[m4_if([$#], [0], [], [[[$1]]_m4_foreach([,m4_dquote(], [)], $@)])])
|
| 231 |
+
|
| 232 |
+
# m4_reverse(ARGS)
|
| 233 |
+
# ----------------
|
| 234 |
+
# Output ARGS in reverse order.
|
| 235 |
+
#
|
| 236 |
+
# Invoke _m4_r($@) with the temporary _m4_r built as
|
| 237 |
+
# [$m], [$m-1], ..., [$2], [$1]_m4_popdef([_m4_r])
|
| 238 |
+
m4_define([m4_reverse],
|
| 239 |
+
[m4_if([$#], [0], [], [$#], [1], [[$1]],
|
| 240 |
+
[m4_pushdef([_m4_r], [[$$#]]_m4_for(m4_decr([$#]), [1], [-1],
|
| 241 |
+
[[, ]m4_dquote($], [)])[_m4_popdef([_m4_r])])_m4_r($@)])])
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
# m4_map_args_pair(EXPRESSION, [END-EXPR = EXPRESSION], ARG...)
|
| 245 |
+
# -------------------------------------------------------------
|
| 246 |
+
# Perform a pairwise grouping of consecutive ARGs, by expanding
|
| 247 |
+
# EXPRESSION([ARG1], [ARG2]). If there are an odd number of ARGs, the
|
| 248 |
+
# final argument is expanded with END-EXPR([ARGn]).
|
| 249 |
+
#
|
| 250 |
+
# Build the temporary macro _m4_map_args_pair, with the $2([$m+1])
|
| 251 |
+
# only output if $# is odd:
|
| 252 |
+
# $1([$3], [$4])[]$1([$5], [$6])[]...$1([$m-1],
|
| 253 |
+
# [$m])[]m4_default([$2], [$1])([$m+1])[]_m4_popdef([_m4_map_args_pair])
|
| 254 |
+
m4_define([m4_map_args_pair],
|
| 255 |
+
[m4_if([$#], [0], [m4_fatal([$0: too few arguments: $#])],
|
| 256 |
+
[$#], [1], [m4_fatal([$0: too few arguments: $#: $1])],
|
| 257 |
+
[$#], [2], [],
|
| 258 |
+
[$#], [3], [m4_default([$2], [$1])([$3])[]],
|
| 259 |
+
[m4_pushdef([_$0], _m4_for([3],
|
| 260 |
+
m4_eval([$# / 2 * 2 - 1]), [2], [_$0_(], [)])_$0_end(
|
| 261 |
+
[1], [2], [$#])[_m4_popdef([_$0])])_$0($@)])])
|
| 262 |
+
|
| 263 |
+
m4_define([_m4_map_args_pair_],
|
| 264 |
+
[$0_([1], [$1], m4_incr([$1]))])
|
| 265 |
+
|
| 266 |
+
m4_define([_m4_map_args_pair__],
|
| 267 |
+
[[$$1([$$2], [$$3])[]]])
|
| 268 |
+
|
| 269 |
+
m4_define([_m4_map_args_pair_end],
|
| 270 |
+
[m4_if(m4_eval([$3 & 1]), [1], [[m4_default([$$2], [$$1])([$$3])[]]])])
|
| 271 |
+
|
| 272 |
+
# m4_join(SEP, ARG1, ARG2...)
|
| 273 |
+
# ---------------------------
|
| 274 |
+
# Produce ARG1SEPARG2...SEPARGn. Avoid back-to-back SEP when a given ARG
|
| 275 |
+
# is the empty string. No expansion is performed on SEP or ARGs.
|
| 276 |
+
#
|
| 277 |
+
# Use a self-modifying separator, since we don't know how many
|
| 278 |
+
# arguments might be skipped before a separator is first printed, but
|
| 279 |
+
# be careful if the separator contains $. _m4_foreach to the rescue.
|
| 280 |
+
m4_define([m4_join],
|
| 281 |
+
[m4_pushdef([_m4_sep], [m4_define([_m4_sep], _m4_defn([m4_echo]))])]dnl
|
| 282 |
+
[_m4_foreach([_$0([$1],], [)], $@)_m4_popdef([_m4_sep])])
|
| 283 |
+
|
| 284 |
+
m4_define([_m4_join],
|
| 285 |
+
[m4_if([$2], [], [], [_m4_sep([$1])[$2]])])
|
| 286 |
+
|
| 287 |
+
# m4_joinall(SEP, ARG1, ARG2...)
|
| 288 |
+
# ------------------------------
|
| 289 |
+
# Produce ARG1SEPARG2...SEPARGn. An empty ARG results in back-to-back SEP.
|
| 290 |
+
# No expansion is performed on SEP or ARGs.
|
| 291 |
+
#
|
| 292 |
+
# A bit easier than m4_join. _m4_foreach to the rescue.
|
| 293 |
+
m4_define([m4_joinall],
|
| 294 |
+
[[$2]m4_if(m4_eval([$# <= 2]), [1], [],
|
| 295 |
+
[_m4_foreach([$1], [], m4_shift($@))])])
|
| 296 |
+
|
| 297 |
+
# m4_list_cmp(A, B)
|
| 298 |
+
# -----------------
|
| 299 |
+
# Compare the two lists of integer expressions A and B.
|
| 300 |
+
#
|
| 301 |
+
# m4_list_cmp takes care of any side effects; we only override
|
| 302 |
+
# _m4_list_cmp_raw, where we can safely expand lists multiple times.
|
| 303 |
+
# First, insert padding so that both lists are the same length; the
|
| 304 |
+
# trailing +0 is necessary to handle a missing list. Next, create a
|
| 305 |
+
# temporary macro to perform pairwise comparisons until an inequality
|
| 306 |
+
# is found. For example, m4_list_cmp([1], [1,2]) creates _m4_cmp as
|
| 307 |
+
# m4_if(m4_eval([($1) != ($3)]), [1], [m4_cmp([$1], [$3])],
|
| 308 |
+
# m4_eval([($2) != ($4)]), [1], [m4_cmp([$2], [$4])],
|
| 309 |
+
# [0]_m4_popdef([_m4_cmp]))
|
| 310 |
+
# then calls _m4_cmp([1+0], [0*2], [1], [2+0])
|
| 311 |
+
m4_define([_m4_list_cmp_raw],
|
| 312 |
+
[m4_if([$1], [$2], 0,
|
| 313 |
+
[_m4_list_cmp($1+0_m4_list_pad(m4_count($1), m4_count($2)),
|
| 314 |
+
$2+0_m4_list_pad(m4_count($2), m4_count($1)))])])
|
| 315 |
+
|
| 316 |
+
m4_define([_m4_list_pad],
|
| 317 |
+
[m4_if(m4_eval($1 < $2), [1],
|
| 318 |
+
[_m4_for(m4_incr([$1]), [$2], [1], [,0*])])])
|
| 319 |
+
|
| 320 |
+
m4_define([_m4_list_cmp],
|
| 321 |
+
[m4_pushdef([_m4_cmp], [m4_if(]_m4_for(
|
| 322 |
+
[1], m4_eval([$# >> 1]), [1], [$0_(], [,]m4_eval([$# >> 1])[)])[
|
| 323 |
+
[0]_m4_popdef([_m4_cmp]))])_m4_cmp($@)])
|
| 324 |
+
|
| 325 |
+
m4_define([_m4_list_cmp_],
|
| 326 |
+
[$0_([$1], m4_eval([$1 + $2]))])
|
| 327 |
+
|
| 328 |
+
m4_define([_m4_list_cmp__],
|
| 329 |
+
[[m4_eval([($$1) != ($$2)]), [1], [m4_cmp([$$1], [$$2])],
|
| 330 |
+
]])
|
| 331 |
+
|
| 332 |
+
# m4_max(EXPR, ...)
|
| 333 |
+
# m4_min(EXPR, ...)
|
| 334 |
+
# -----------------
|
| 335 |
+
# Return the decimal value of the maximum (or minimum) in a series of
|
| 336 |
+
# integer expressions.
|
| 337 |
+
#
|
| 338 |
+
# _m4_foreach to the rescue; we only need to replace _m4_minmax. Here,
|
| 339 |
+
# we need a temporary macro to track the best answer so far, so that
|
| 340 |
+
# the foreach expression is tractable.
|
| 341 |
+
m4_define([_m4_minmax],
|
| 342 |
+
[m4_pushdef([_m4_best], m4_eval([$2]))_m4_foreach(
|
| 343 |
+
[m4_define([_m4_best], $1(_m4_best,], [))], m4_shift($@))]dnl
|
| 344 |
+
[_m4_best[]_m4_popdef([_m4_best])])
|
| 345 |
+
|
| 346 |
+
# m4_set_add_all(SET, VALUE...)
|
| 347 |
+
# -----------------------------
|
| 348 |
+
# Add each VALUE into SET. This is O(n) in the number of VALUEs, and
|
| 349 |
+
# can be faster than calling m4_set_add for each VALUE.
|
| 350 |
+
#
|
| 351 |
+
# _m4_foreach to the rescue. If no deletions have occurred, then
|
| 352 |
+
# avoid the speed penalty of m4_set_add.
|
| 353 |
+
m4_define([m4_set_add_all],
|
| 354 |
+
[m4_if([$#], [0], [], [$#], [1], [],
|
| 355 |
+
[m4_define([_m4_set_size($1)], m4_eval(m4_set_size([$1])
|
| 356 |
+
+ m4_len(_m4_foreach(m4_ifdef([_m4_set_cleanup($1)],
|
| 357 |
+
[[m4_set_add]], [[_$0]])[([$1],], [)], $@))))])])
|
| 358 |
+
|
| 359 |
+
m4_define([_m4_set_add_all],
|
| 360 |
+
[m4_ifdef([_m4_set([$1],$2)], [],
|
| 361 |
+
[m4_define([_m4_set([$1],$2)],
|
| 362 |
+
[1])m4_pushdef([_m4_set([$1])], [$2])-])])
|
platform/dbops/binaries/build/share/bison/m4sugar/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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-*- Autoconf -*-
|
| 2 |
+
|
| 3 |
+
# Language-independent M4 Macros for Bison.
|
| 4 |
+
|
| 5 |
+
# Copyright (C) 2002, 2004-2015, 2018-2021 Free Software Foundation,
|
| 6 |
+
# Inc.
|
| 7 |
+
|
| 8 |
+
# This program is free software: you can redistribute it and/or modify
|
| 9 |
+
# it under the terms of the GNU General Public License as published by
|
| 10 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 11 |
+
# (at your option) any later version.
|
| 12 |
+
#
|
| 13 |
+
# This program is distributed in the hope that it will be useful,
|
| 14 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 16 |
+
# GNU General Public License for more details.
|
| 17 |
+
#
|
| 18 |
+
# You should have received a copy of the GNU General Public License
|
| 19 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
# m4_gsub(STRING, RE1, SUBST1, RE2, SUBST2, ...)
|
| 24 |
+
# ----------------------------------------------
|
| 25 |
+
# m4 equivalent of
|
| 26 |
+
#
|
| 27 |
+
# $_ = STRING;
|
| 28 |
+
# s/RE1/SUBST1/g;
|
| 29 |
+
# s/RE2/SUBST2/g;
|
| 30 |
+
# ...
|
| 31 |
+
#
|
| 32 |
+
# Really similar to m4_bpatsubsts, but behaves properly with quotes.
|
| 33 |
+
# See m4.at's "Generating Comments". Super inelegant, but so far, I
|
| 34 |
+
# did not find any better solution.
|
| 35 |
+
m4_define([b4_gsub],
|
| 36 |
+
[m4_bpatsubst(m4_bpatsubst(m4_bpatsubst([[[[$1]]]],
|
| 37 |
+
[$2], [$3]),
|
| 38 |
+
[$4], [$5]),
|
| 39 |
+
[$6], [$7])])
|
| 40 |
+
|
| 41 |
+
# m4_shift2 and m4_shift3 are provided by m4sugar.
|
| 42 |
+
m4_define([m4_shift4], [m4_shift(m4_shift(m4_shift(m4_shift($@))))])
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
## ---------------- ##
|
| 46 |
+
## Identification. ##
|
| 47 |
+
## ---------------- ##
|
| 48 |
+
|
| 49 |
+
# b4_generated_by
|
| 50 |
+
# ---------------
|
| 51 |
+
m4_define([b4_generated_by],
|
| 52 |
+
[b4_comment([A Bison parser, made by GNU Bison b4_version_string.])
|
| 53 |
+
])
|
| 54 |
+
|
| 55 |
+
# b4_copyright(TITLE, [YEARS])
|
| 56 |
+
# ----------------------------
|
| 57 |
+
# If YEARS are not defined, use b4_copyright_years.
|
| 58 |
+
m4_define([b4_copyright],
|
| 59 |
+
[b4_generated_by
|
| 60 |
+
b4_comment([$1
|
| 61 |
+
|
| 62 |
+
]m4_dquote(m4_text_wrap([Copyright (C)
|
| 63 |
+
]m4_ifval([$2], [[$2]], [m4_defn([b4_copyright_years])])[
|
| 64 |
+
Free Software Foundation, Inc.]))[
|
| 65 |
+
|
| 66 |
+
This program is free software: you can redistribute it and/or modify
|
| 67 |
+
it under the terms of the GNU General Public License as published by
|
| 68 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 69 |
+
(at your option) any later version.
|
| 70 |
+
|
| 71 |
+
This program is distributed in the hope that it will be useful,
|
| 72 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 73 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 74 |
+
GNU General Public License for more details.
|
| 75 |
+
|
| 76 |
+
You should have received a copy of the GNU General Public License
|
| 77 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.])
|
| 78 |
+
|
| 79 |
+
b4_comment([As a special exception, you may create a larger work that contains
|
| 80 |
+
part or all of the Bison parser skeleton and distribute that work
|
| 81 |
+
under terms of your choice, so long as that work isn't itself a
|
| 82 |
+
parser generator using the skeleton or a modified version thereof
|
| 83 |
+
as a parser skeleton. Alternatively, if you modify or redistribute
|
| 84 |
+
the parser skeleton itself, you may (at your option) remove this
|
| 85 |
+
special exception, which will cause the skeleton and the resulting
|
| 86 |
+
Bison output files to be licensed under the GNU General Public
|
| 87 |
+
License without this special exception.
|
| 88 |
+
|
| 89 |
+
This special exception was added by the Free Software Foundation in
|
| 90 |
+
version 2.2 of Bison.])
|
| 91 |
+
])
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
# b4_disclaimer
|
| 95 |
+
# -------------
|
| 96 |
+
# Issue a warning about private implementation details.
|
| 97 |
+
m4_define([b4_disclaimer],
|
| 98 |
+
[b4_comment([DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
|
| 99 |
+
especially those whose name start with YY_ or yy_. They are
|
| 100 |
+
private implementation details that can be changed or removed.])
|
| 101 |
+
])
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
# b4_required_version_if(VERSION, IF_NEWER, IF_OLDER)
|
| 106 |
+
# ---------------------------------------------------
|
| 107 |
+
# If the version %require'd by the user is VERSION (or newer) expand
|
| 108 |
+
# IF_NEWER, otherwise IF_OLDER. VERSION should be an integer, e.g.,
|
| 109 |
+
# 302 for 3.2.
|
| 110 |
+
m4_define([b4_required_version_if],
|
| 111 |
+
[m4_if(m4_eval($1 <= b4_required_version),
|
| 112 |
+
[1], [$2], [$3])])
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
## -------- ##
|
| 116 |
+
## Output. ##
|
| 117 |
+
## -------- ##
|
| 118 |
+
|
| 119 |
+
# b4_output_begin(FILE1, FILE2)
|
| 120 |
+
# -----------------------------
|
| 121 |
+
# Enable output, i.e., send to diversion 0, expand after "#", and
|
| 122 |
+
# generate the tag to output into FILE. Must be followed by EOL.
|
| 123 |
+
# FILE is FILE1 concatenated to FILE2. FILE2 can be empty, or be
|
| 124 |
+
# absolute: do the right thing.
|
| 125 |
+
m4_define([b4_output_begin],
|
| 126 |
+
[m4_changecom()
|
| 127 |
+
m4_divert_push(0)dnl
|
| 128 |
+
@output(m4_unquote([$1])@,m4_unquote([$2])@)@dnl
|
| 129 |
+
])
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
# b4_output_end
|
| 133 |
+
# -------------
|
| 134 |
+
# Output nothing, restore # as comment character (no expansions after #).
|
| 135 |
+
m4_define([b4_output_end],
|
| 136 |
+
[m4_divert_pop(0)
|
| 137 |
+
m4_changecom([#])
|
| 138 |
+
])
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
# b4_divert_kill(CODE)
|
| 142 |
+
# --------------------
|
| 143 |
+
# Expand CODE for its side effects, discard its output.
|
| 144 |
+
m4_define([b4_divert_kill],
|
| 145 |
+
[m4_divert_text([KILL], [$1])])
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
# b4_define_silent(MACRO, CODE)
|
| 149 |
+
# -----------------------------
|
| 150 |
+
# Same as m4_define, but throw away the expansion of CODE.
|
| 151 |
+
m4_define([b4_define_silent],
|
| 152 |
+
[m4_define([$1], [b4_divert_kill([$2])])])
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
## ---------------- ##
|
| 156 |
+
## Error handling. ##
|
| 157 |
+
## ---------------- ##
|
| 158 |
+
|
| 159 |
+
# The following error handling macros print error directives that should not
|
| 160 |
+
# become arguments of other macro invocations since they would likely then be
|
| 161 |
+
# mangled. Thus, they print to stdout directly.
|
| 162 |
+
|
| 163 |
+
# b4_cat(TEXT)
|
| 164 |
+
# ------------
|
| 165 |
+
# Write TEXT to stdout. Precede the final newline with an @ so that it's
|
| 166 |
+
# escaped. For example:
|
| 167 |
+
#
|
| 168 |
+
# b4_cat([[@complain(invalid input@)]])
|
| 169 |
+
m4_define([b4_cat],
|
| 170 |
+
[m4_syscmd([cat <<'_m4eof'
|
| 171 |
+
]m4_bpatsubst(m4_dquote($1), [_m4eof], [_m4@`eof])[@
|
| 172 |
+
_m4eof
|
| 173 |
+
])dnl
|
| 174 |
+
m4_if(m4_sysval, [0], [], [m4_fatal([$0: cannot write to stdout])])])
|
| 175 |
+
|
| 176 |
+
# b4_error(KIND, START, END, FORMAT, [ARG1], [ARG2], ...)
|
| 177 |
+
# -------------------------------------------------------
|
| 178 |
+
# Write @KIND(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout.
|
| 179 |
+
#
|
| 180 |
+
# For example:
|
| 181 |
+
#
|
| 182 |
+
# b4_error([[complain]], [[input.y:2.3]], [[input.y:5.4]],
|
| 183 |
+
# [[invalid %s]], [[foo]])
|
| 184 |
+
m4_define([b4_error],
|
| 185 |
+
[b4_cat([[@complain][(]$1[@,]$2[@,]$3[@,]$4[]]dnl
|
| 186 |
+
[m4_if([$#], [4], [],
|
| 187 |
+
[m4_foreach([b4_arg],
|
| 188 |
+
m4_dquote(m4_shift4($@)),
|
| 189 |
+
[[@,]b4_arg])])[@)]])])
|
| 190 |
+
|
| 191 |
+
# b4_warn(FORMAT, [ARG1], [ARG2], ...)
|
| 192 |
+
# ------------------------------------
|
| 193 |
+
# Write @warn(FORMAT@,ARG1@,ARG2@,...@) to stdout.
|
| 194 |
+
#
|
| 195 |
+
# For example:
|
| 196 |
+
#
|
| 197 |
+
# b4_warn([[invalid value for '%s': %s]], [[foo]], [[3]])
|
| 198 |
+
#
|
| 199 |
+
# As a simple test suite, this:
|
| 200 |
+
#
|
| 201 |
+
# m4_divert(-1)
|
| 202 |
+
# m4_define([asdf], [ASDF])
|
| 203 |
+
# m4_define([fsa], [FSA])
|
| 204 |
+
# m4_define([fdsa], [FDSA])
|
| 205 |
+
# b4_warn_at([[[asdf), asdf]]], [[[fsa), fsa]]], [[[fdsa), fdsa]]])
|
| 206 |
+
# b4_warn_at([[asdf), asdf]], [[fsa), fsa]], [[fdsa), fdsa]])
|
| 207 |
+
# b4_warn_at()
|
| 208 |
+
# b4_warn_at(1)
|
| 209 |
+
# b4_warn_at(1, 2)
|
| 210 |
+
#
|
| 211 |
+
# Should produce this without newlines:
|
| 212 |
+
#
|
| 213 |
+
# @warn_at([asdf), asdf]@,@,@,[fsa), fsa]@,[fdsa), fdsa]@)
|
| 214 |
+
# @warn(asdf), asdf@,@,@,fsa), fsa@,fdsa), fdsa@)
|
| 215 |
+
# @warn(@)
|
| 216 |
+
# @warn(1@)
|
| 217 |
+
# @warn(1@,2@)
|
| 218 |
+
m4_define([b4_warn],
|
| 219 |
+
[b4_warn_at([], [], $@)])
|
| 220 |
+
|
| 221 |
+
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
| 222 |
+
# ---------------------------------------------------
|
| 223 |
+
# Write @warn(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout.
|
| 224 |
+
#
|
| 225 |
+
# For example:
|
| 226 |
+
#
|
| 227 |
+
# b4_warn_at([[input.y:2.3]], [[input.y:5.4]], [[invalid %s]], [[foo]])
|
| 228 |
+
m4_define([b4_warn_at],
|
| 229 |
+
[b4_error([[warn]], $@)])
|
| 230 |
+
|
| 231 |
+
# b4_complain(FORMAT, [ARG1], [ARG2], ...)
|
| 232 |
+
# ----------------------------------------
|
| 233 |
+
# Bounce to b4_complain_at.
|
| 234 |
+
#
|
| 235 |
+
# See b4_warn example.
|
| 236 |
+
m4_define([b4_complain],
|
| 237 |
+
[b4_complain_at([], [], $@)])
|
| 238 |
+
|
| 239 |
+
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
| 240 |
+
# -------------------------------------------------------
|
| 241 |
+
# Write @complain(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout.
|
| 242 |
+
#
|
| 243 |
+
# See b4_warn_at example.
|
| 244 |
+
m4_define([b4_complain_at],
|
| 245 |
+
[b4_error([[complain]], $@)])
|
| 246 |
+
|
| 247 |
+
# b4_fatal(FORMAT, [ARG1], [ARG2], ...)
|
| 248 |
+
# -------------------------------------
|
| 249 |
+
# Bounce to b4_fatal_at.
|
| 250 |
+
#
|
| 251 |
+
# See b4_warn example.
|
| 252 |
+
m4_define([b4_fatal],
|
| 253 |
+
[b4_fatal_at([], [], $@)])
|
| 254 |
+
|
| 255 |
+
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
| 256 |
+
# ----------------------------------------------------
|
| 257 |
+
# Write @fatal(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout and exit.
|
| 258 |
+
#
|
| 259 |
+
# See b4_warn_at example.
|
| 260 |
+
m4_define([b4_fatal_at],
|
| 261 |
+
[b4_error([[fatal]], $@)dnl
|
| 262 |
+
m4_exit(1)])
|
| 263 |
+
|
| 264 |
+
# b4_canary(MSG)
|
| 265 |
+
# --------------
|
| 266 |
+
# Issue a warning on stderr and in the output. Used in the test suite
|
| 267 |
+
# to catch spurious m4 evaluations.
|
| 268 |
+
m4_define([b4_canary],
|
| 269 |
+
[m4_errprintn([dead canary: $1])DEAD CANARY($1)])
|
| 270 |
+
|
| 271 |
+
|
| 272 |
+
## ------------ ##
|
| 273 |
+
## Data Types. ##
|
| 274 |
+
## ------------ ##
|
| 275 |
+
|
| 276 |
+
# b4_ints_in(INT1, INT2, LOW, HIGH)
|
| 277 |
+
# ---------------------------------
|
| 278 |
+
# Return 1 iff both INT1 and INT2 are in [LOW, HIGH], 0 otherwise.
|
| 279 |
+
m4_define([b4_ints_in],
|
| 280 |
+
[m4_eval([$3 <= $1 && $1 <= $4 && $3 <= $2 && $2 <= $4])])
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
# b4_subtract(LHS, RHS)
|
| 284 |
+
# ---------------------
|
| 285 |
+
# Evaluate LHS - RHS if they are integer literals, otherwise expand
|
| 286 |
+
# to (LHS) - (RHS).
|
| 287 |
+
m4_define([b4_subtract],
|
| 288 |
+
[m4_bmatch([$1$2], [^[0123456789]*$],
|
| 289 |
+
[m4_eval([$1 - $2])],
|
| 290 |
+
[($1) - ($2)])])
|
| 291 |
+
|
| 292 |
+
# b4_join(ARG1, ...)
|
| 293 |
+
# _b4_join(ARG1, ...)
|
| 294 |
+
# -------------------
|
| 295 |
+
# Join with comma, skipping empty arguments.
|
| 296 |
+
# b4_join calls itself recursively until it sees the first non-empty
|
| 297 |
+
# argument, then calls _b4_join (i.e., `_$0`) which prepends each
|
| 298 |
+
# non-empty argument with a comma.
|
| 299 |
+
m4_define([b4_join],
|
| 300 |
+
[m4_if([$#$1],
|
| 301 |
+
[1], [],
|
| 302 |
+
[m4_ifval([$1],
|
| 303 |
+
[$1[]_$0(m4_shift($@))],
|
| 304 |
+
[$0(m4_shift($@))])])])
|
| 305 |
+
|
| 306 |
+
# _b4_join(ARGS1, ...)
|
| 307 |
+
# --------------------
|
| 308 |
+
m4_define([_b4_join],
|
| 309 |
+
[m4_if([$#$1],
|
| 310 |
+
[1], [],
|
| 311 |
+
[m4_ifval([$1], [, $1])[]$0(m4_shift($@))])])
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
# b4_integral_parser_tables_map(MACRO)
|
| 317 |
+
# -------------------------------------
|
| 318 |
+
# Map MACRO on all the integral tables. MACRO is expected to have
|
| 319 |
+
# the signature MACRO(TABLE-NAME, CONTENT, COMMENT).
|
| 320 |
+
m4_define([b4_integral_parser_tables_map],
|
| 321 |
+
[$1([pact], [b4_pact],
|
| 322 |
+
[[YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
| 323 |
+
STATE-NUM.]])
|
| 324 |
+
|
| 325 |
+
$1([defact], [b4_defact],
|
| 326 |
+
[[YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
|
| 327 |
+
Performed when YYTABLE does not specify something else to do. Zero
|
| 328 |
+
means the default is an error.]])
|
| 329 |
+
|
| 330 |
+
$1([pgoto], [b4_pgoto], [[YYPGOTO[NTERM-NUM].]])
|
| 331 |
+
|
| 332 |
+
$1([defgoto], [b4_defgoto], [[YYDEFGOTO[NTERM-NUM].]])
|
| 333 |
+
|
| 334 |
+
$1([table], [b4_table],
|
| 335 |
+
[[YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
|
| 336 |
+
positive, shift that token. If negative, reduce the rule whose
|
| 337 |
+
number is the opposite. If YYTABLE_NINF, syntax error.]])
|
| 338 |
+
|
| 339 |
+
$1([check], [b4_check])
|
| 340 |
+
|
| 341 |
+
$1([stos], [b4_stos],
|
| 342 |
+
[[YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
|
| 343 |
+
state STATE-NUM.]])
|
| 344 |
+
|
| 345 |
+
$1([r1], [b4_r1],
|
| 346 |
+
[[YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.]])
|
| 347 |
+
|
| 348 |
+
$1([r2], [b4_r2],
|
| 349 |
+
[[YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.]])
|
| 350 |
+
])
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
# b4_parser_tables_declare
|
| 354 |
+
# b4_parser_tables_define
|
| 355 |
+
# ------------------------
|
| 356 |
+
# Define/declare the (deterministic) parser tables.
|
| 357 |
+
m4_define([b4_parser_tables_declare],
|
| 358 |
+
[b4_integral_parser_tables_map([b4_integral_parser_table_declare])])
|
| 359 |
+
|
| 360 |
+
m4_define([b4_parser_tables_define],
|
| 361 |
+
[b4_integral_parser_tables_map([b4_integral_parser_table_define])])
|
| 362 |
+
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
## ------------------ ##
|
| 366 |
+
## Decoding options. ##
|
| 367 |
+
## ------------------ ##
|
| 368 |
+
|
| 369 |
+
# b4_flag_if(FLAG, IF-TRUE, IF-FALSE)
|
| 370 |
+
# -----------------------------------
|
| 371 |
+
# Run IF-TRUE if b4_FLAG_flag is 1, IF-FALSE if FLAG is 0, otherwise fail.
|
| 372 |
+
m4_define([b4_flag_if],
|
| 373 |
+
[m4_case(b4_$1_flag,
|
| 374 |
+
[0], [$3],
|
| 375 |
+
[1], [$2],
|
| 376 |
+
[m4_fatal([invalid $1 value: ]b4_$1_flag)])])
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
# b4_define_flag_if(FLAG)
|
| 380 |
+
# -----------------------
|
| 381 |
+
# Define "b4_FLAG_if(IF-TRUE, IF-FALSE)" that depends on the
|
| 382 |
+
# value of the Boolean FLAG.
|
| 383 |
+
m4_define([b4_define_flag_if],
|
| 384 |
+
[_b4_define_flag_if($[1], $[2], [$1])])
|
| 385 |
+
|
| 386 |
+
# _b4_define_flag_if($1, $2, FLAG)
|
| 387 |
+
# --------------------------------
|
| 388 |
+
# Work around the impossibility to define macros inside macros,
|
| 389 |
+
# because issuing '[$1]' is not possible in M4. GNU M4 should provide
|
| 390 |
+
# $$1 a la M5/TeX.
|
| 391 |
+
m4_define([_b4_define_flag_if],
|
| 392 |
+
[m4_if([$1$2], $[1]$[2], [],
|
| 393 |
+
[m4_fatal([$0: Invalid arguments: $@])])dnl
|
| 394 |
+
m4_define([b4_$3_if],
|
| 395 |
+
[b4_flag_if([$3], [$1], [$2])])])
|
| 396 |
+
|
| 397 |
+
|
| 398 |
+
# b4_FLAG_if(IF-TRUE, IF-FALSE)
|
| 399 |
+
# -----------------------------
|
| 400 |
+
# Expand IF-TRUE, if FLAG is true, IF-FALSE otherwise.
|
| 401 |
+
b4_define_flag_if([glr]) # Whether a GLR parser is requested.
|
| 402 |
+
b4_define_flag_if([has_translations]) # Whether some tokens are internationalized.
|
| 403 |
+
b4_define_flag_if([header]) # Whether a header is requested.
|
| 404 |
+
b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled.
|
| 405 |
+
b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
|
| 406 |
+
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
# b4_glr_cc_if([IF-TRUE], [IF-FALSE])
|
| 410 |
+
# -----------------------------------
|
| 411 |
+
m4_define([b4_glr_cc_if],
|
| 412 |
+
[m4_if(b4_skeleton, ["glr.cc"], $@)])
|
| 413 |
+
|
| 414 |
+
# b4_glr2_cc_if([IF-TRUE], [IF-FALSE])
|
| 415 |
+
# ------------------------------------
|
| 416 |
+
m4_define([b4_glr2_cc_if],
|
| 417 |
+
[m4_if(b4_skeleton, ["glr2.cc"], $@)])
|
| 418 |
+
|
| 419 |
+
## --------- ##
|
| 420 |
+
## Symbols. ##
|
| 421 |
+
## --------- ##
|
| 422 |
+
|
| 423 |
+
# For a description of the Symbol handling, see README.md.
|
| 424 |
+
#
|
| 425 |
+
# The following macros provide access to symbol related values.
|
| 426 |
+
|
| 427 |
+
# __b4_symbol(NUM, FIELD)
|
| 428 |
+
# -----------------------
|
| 429 |
+
# Fetch FIELD of symbol #NUM. Fail if undefined.
|
| 430 |
+
m4_define([__b4_symbol],
|
| 431 |
+
[m4_indir([b4_symbol($1, $2)])])
|
| 432 |
+
|
| 433 |
+
|
| 434 |
+
# _b4_symbol(NUM, FIELD)
|
| 435 |
+
# ----------------------
|
| 436 |
+
# Fetch FIELD of symbol #NUM (or "orig NUM", see README.md).
|
| 437 |
+
# Fail if undefined.
|
| 438 |
+
m4_define([_b4_symbol],
|
| 439 |
+
[m4_ifdef([b4_symbol($1, number)],
|
| 440 |
+
[__b4_symbol(m4_indir([b4_symbol($1, number)]), $2)],
|
| 441 |
+
[__b4_symbol([$1], [$2])])])
|
| 442 |
+
|
| 443 |
+
|
| 444 |
+
# b4_symbol_token_kind(NUM)
|
| 445 |
+
# -------------------------
|
| 446 |
+
# The token kind of this symbol.
|
| 447 |
+
m4_define([b4_symbol_token_kind],
|
| 448 |
+
[b4_percent_define_get([api.token.prefix])dnl
|
| 449 |
+
_b4_symbol([$1], [id])])
|
| 450 |
+
|
| 451 |
+
|
| 452 |
+
# b4_symbol_kind_base(NUM)
|
| 453 |
+
# ------------------------
|
| 454 |
+
# Build the name of the kind of this symbol. It must always exist,
|
| 455 |
+
# otherwise some symbols might not be represented in the enum, which
|
| 456 |
+
# might be compiled into too small a type to contain all the symbol
|
| 457 |
+
# numbers.
|
| 458 |
+
m4_define([b4_symbol_prefix], [b4_percent_define_get([api.symbol.prefix])])
|
| 459 |
+
m4_define([b4_symbol_kind_base],
|
| 460 |
+
[b4_percent_define_get([api.symbol.prefix])dnl
|
| 461 |
+
m4_case([$1],
|
| 462 |
+
[-2], [[YYEMPTY]],
|
| 463 |
+
[0], [[YYEOF]],
|
| 464 |
+
[1], [[YYerror]],
|
| 465 |
+
[2], [[YYUNDEF]],
|
| 466 |
+
[m4_case(b4_symbol([$1], [tag]),
|
| 467 |
+
[$accept], [[YYACCEPT]],
|
| 468 |
+
[b4_symbol_if([$1], [has_id], _b4_symbol([$1], [id]),
|
| 469 |
+
[m4_bpatsubst([$1-][]_b4_symbol([$1], [tag]), [[^a-zA-Z_0-9]+], [_])])])])])
|
| 470 |
+
|
| 471 |
+
|
| 472 |
+
# b4_symbol_kind(NUM)
|
| 473 |
+
# -------------------
|
| 474 |
+
# Same as b4_symbol_kind, but possibly with a prefix in some
|
| 475 |
+
# languages. E.g., EOF's kind_base and kind are YYSYMBOL_YYEOF in C,
|
| 476 |
+
# but are S_YYEMPTY and symbol_kind::S_YYEMPTY in C++.
|
| 477 |
+
m4_copy([b4_symbol_kind_base], [b4_symbol_kind])
|
| 478 |
+
|
| 479 |
+
|
| 480 |
+
# b4_symbol_slot(NUM)
|
| 481 |
+
# -------------------
|
| 482 |
+
# The name of union member that contains the value of these symbols.
|
| 483 |
+
# Currently, we are messy, this should actually be type_tag, but type_tag
|
| 484 |
+
# has several meanings.
|
| 485 |
+
m4_define([b4_symbol_slot],
|
| 486 |
+
[m4_case(b4_percent_define_get([[api.value.type]]),
|
| 487 |
+
[union], [b4_symbol([$1], [type_tag])],
|
| 488 |
+
[variant], [b4_symbol([$1], [type_tag])],
|
| 489 |
+
[b4_symbol([$1], [type])])])
|
| 490 |
+
|
| 491 |
+
|
| 492 |
+
# b4_symbol(NUM, FIELD)
|
| 493 |
+
# ---------------------
|
| 494 |
+
# Fetch FIELD of symbol #NUM (or "orig NUM", or "empty"). Fail if undefined.
|
| 495 |
+
#
|
| 496 |
+
# If FIELD = id, prepend the token prefix.
|
| 497 |
+
m4_define([b4_symbol],
|
| 498 |
+
[m4_if([$1], [empty], [b4_symbol([-2], [$2])],
|
| 499 |
+
[$1], [eof], [b4_symbol([0], [$2])],
|
| 500 |
+
[$1], [error], [b4_symbol([1], [$2])],
|
| 501 |
+
[$1], [undef], [b4_symbol([2], [$2])],
|
| 502 |
+
[m4_case([$2],
|
| 503 |
+
[id], [b4_symbol_token_kind([$1])],
|
| 504 |
+
[kind_base], [b4_symbol_kind_base([$1])],
|
| 505 |
+
[kind], [b4_symbol_kind([$1])],
|
| 506 |
+
[slot], [b4_symbol_slot([$1])],
|
| 507 |
+
[_b4_symbol($@)])])])
|
| 508 |
+
|
| 509 |
+
|
| 510 |
+
# b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE)
|
| 511 |
+
# -------------------------------------------
|
| 512 |
+
# If FIELD about symbol #NUM is 1 expand IF-TRUE, if is 0, expand IF-FALSE.
|
| 513 |
+
# Otherwise an error.
|
| 514 |
+
m4_define([b4_symbol_if],
|
| 515 |
+
[m4_case(b4_symbol([$1], [$2]),
|
| 516 |
+
[1], [$3],
|
| 517 |
+
[0], [$4],
|
| 518 |
+
[m4_fatal([$0: field $2 of $1 is not a Boolean:] b4_symbol([$1], [$2]))])])
|
| 519 |
+
|
| 520 |
+
|
| 521 |
+
# b4_symbol_tag_comment(SYMBOL-NUM)
|
| 522 |
+
# ---------------------------------
|
| 523 |
+
# Issue a comment giving the tag of symbol NUM.
|
| 524 |
+
m4_define([b4_symbol_tag_comment],
|
| 525 |
+
[b4_comment([b4_symbol([$1], [tag])])
|
| 526 |
+
])
|
| 527 |
+
|
| 528 |
+
|
| 529 |
+
# b4_symbol_action(SYMBOL-NUM, ACTION)
|
| 530 |
+
# ------------------------------------
|
| 531 |
+
# Run the action ACTION ("destructor" or "printer") for SYMBOL-NUM.
|
| 532 |
+
m4_define([b4_symbol_action],
|
| 533 |
+
[b4_symbol_if([$1], [has_$2],
|
| 534 |
+
[b4_dollar_pushdef([(*yyvaluep)],
|
| 535 |
+
[$1],
|
| 536 |
+
[],
|
| 537 |
+
[(*yylocationp)])dnl
|
| 538 |
+
_b4_symbol_case([$1])[]dnl
|
| 539 |
+
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])dnl
|
| 540 |
+
b4_symbol([$1], [$2])
|
| 541 |
+
b4_syncline([@oline@], [@ofile@])dnl
|
| 542 |
+
break;
|
| 543 |
+
|
| 544 |
+
b4_dollar_popdef[]dnl
|
| 545 |
+
])])
|
| 546 |
+
|
| 547 |
+
|
| 548 |
+
# b4_symbol_destructor(SYMBOL-NUM)
|
| 549 |
+
# b4_symbol_printer(SYMBOL-NUM)
|
| 550 |
+
# --------------------------------
|
| 551 |
+
m4_define([b4_symbol_destructor], [b4_symbol_action([$1], [destructor])])
|
| 552 |
+
m4_define([b4_symbol_printer], [b4_symbol_action([$1], [printer])])
|
| 553 |
+
|
| 554 |
+
|
| 555 |
+
# b4_symbol_actions(ACTION, [KIND = yykind])
|
| 556 |
+
# ------------------------------------------
|
| 557 |
+
# Emit the symbol actions for ACTION ("destructor" or "printer").
|
| 558 |
+
# Dispatch on KIND.
|
| 559 |
+
m4_define([b4_symbol_actions],
|
| 560 |
+
[m4_pushdef([b4_actions_], m4_expand([b4_symbol_foreach([b4_symbol_$1])]))dnl
|
| 561 |
+
m4_ifval(m4_defn([b4_actions_]),
|
| 562 |
+
[switch (m4_default([$2], [yykind]))
|
| 563 |
+
{
|
| 564 |
+
m4_defn([b4_actions_])[]dnl
|
| 565 |
+
default:
|
| 566 |
+
break;
|
| 567 |
+
}dnl
|
| 568 |
+
],
|
| 569 |
+
[b4_use(m4_default([$2], [yykind]));])dnl
|
| 570 |
+
m4_popdef([b4_actions_])dnl
|
| 571 |
+
])
|
| 572 |
+
|
| 573 |
+
# _b4_symbol_case(SYMBOL-NUM)
|
| 574 |
+
# ---------------------------
|
| 575 |
+
# Issue a "case NUM" for SYMBOL-NUM. Ends with its EOL to make it
|
| 576 |
+
# easier to use with m4_map, but then, use []dnl to suppress the last
|
| 577 |
+
# one.
|
| 578 |
+
m4_define([_b4_symbol_case],
|
| 579 |
+
[case b4_symbol([$1], [kind]): b4_symbol_tag_comment([$1])])
|
| 580 |
+
])
|
| 581 |
+
|
| 582 |
+
|
| 583 |
+
# b4_symbol_foreach(MACRO)
|
| 584 |
+
# ------------------------
|
| 585 |
+
# Invoke MACRO(SYMBOL-NUM) for each SYMBOL-NUM.
|
| 586 |
+
m4_define([b4_symbol_foreach],
|
| 587 |
+
[m4_map([$1], m4_defn([b4_symbol_numbers]))])
|
| 588 |
+
|
| 589 |
+
# b4_symbol_map(MACRO)
|
| 590 |
+
# --------------------
|
| 591 |
+
# Return a list (possibly empty elements) of MACRO invoked for each
|
| 592 |
+
# SYMBOL-NUM.
|
| 593 |
+
m4_define([b4_symbol_map],
|
| 594 |
+
[m4_map_args_sep([$1(], [)], [,], b4_symbol_numbers)])
|
| 595 |
+
|
| 596 |
+
|
| 597 |
+
# b4_token_visible_if(NUM, IF-TRUE, IF-FALSE)
|
| 598 |
+
# -------------------------------------------
|
| 599 |
+
# Whether NUM denotes a token kind that has an exported definition
|
| 600 |
+
# (i.e., shows in enum yytokentype).
|
| 601 |
+
m4_define([b4_token_visible_if],
|
| 602 |
+
[b4_symbol_if([$1], [is_token],
|
| 603 |
+
[b4_symbol_if([$1], [has_id], [$2], [$3])],
|
| 604 |
+
[$3])])
|
| 605 |
+
|
| 606 |
+
|
| 607 |
+
# b4_token_has_definition(NUM)
|
| 608 |
+
# ----------------------------
|
| 609 |
+
# 1 if NUM is visible, nothing otherwise.
|
| 610 |
+
m4_define([b4_token_has_definition],
|
| 611 |
+
[b4_token_visible_if([$1], [1])])
|
| 612 |
+
|
| 613 |
+
# b4_any_token_visible_if([IF-TRUE], [IF-FALSE])
|
| 614 |
+
# ----------------------------------------------
|
| 615 |
+
# Whether there is a token that needs to be defined.
|
| 616 |
+
m4_define([b4_any_token_visible_if],
|
| 617 |
+
[m4_ifval(b4_symbol_foreach([b4_token_has_definition]),
|
| 618 |
+
[$1], [$2])])
|
| 619 |
+
|
| 620 |
+
|
| 621 |
+
# b4_token_format(FORMAT, NUM)
|
| 622 |
+
# ----------------------------
|
| 623 |
+
# If token NUM has a visible ID, format FORMAT with ID, USER_NUMBER.
|
| 624 |
+
m4_define([b4_token_format],
|
| 625 |
+
[b4_token_visible_if([$2],
|
| 626 |
+
[m4_format([[$1]],
|
| 627 |
+
b4_symbol([$2], [id]),
|
| 628 |
+
b4_symbol([$2], b4_api_token_raw_if([[number]], [[code]])))])])
|
| 629 |
+
|
| 630 |
+
|
| 631 |
+
# b4_last_enum_token
|
| 632 |
+
# ------------------
|
| 633 |
+
# The code of the last token visible token.
|
| 634 |
+
m4_define([_b4_last_enum_token],
|
| 635 |
+
[b4_token_visible_if([$1],
|
| 636 |
+
[m4_define([b4_last_enum_token], [$1])])])
|
| 637 |
+
b4_symbol_foreach([_b4_last_enum_token])
|
| 638 |
+
|
| 639 |
+
# b4_last_symbol
|
| 640 |
+
# --------------
|
| 641 |
+
# The code of the last symbol.
|
| 642 |
+
m4_define([b4_last_symbol], m4_eval(b4_tokens_number + b4_nterms_number - 1))
|
| 643 |
+
|
| 644 |
+
## ------- ##
|
| 645 |
+
## Types. ##
|
| 646 |
+
## ------- ##
|
| 647 |
+
|
| 648 |
+
# _b4_type_action(NUMS)
|
| 649 |
+
# ---------------------
|
| 650 |
+
# Run actions for the symbol NUMS that all have the same type-name.
|
| 651 |
+
# Skip NUMS that have no type-name.
|
| 652 |
+
#
|
| 653 |
+
# To specify the action to run, define b4_dollar_dollar(SYMBOL-NUM,
|
| 654 |
+
# TAG, TYPE).
|
| 655 |
+
m4_define([_b4_type_action],
|
| 656 |
+
[b4_symbol_if([$1], [has_type],
|
| 657 |
+
[m4_map([ _b4_symbol_case], [$@])[]dnl
|
| 658 |
+
b4_dollar_dollar([b4_symbol([$1], [number])],
|
| 659 |
+
[b4_symbol([$1], [tag])],
|
| 660 |
+
[b4_symbol([$1], [type])]);
|
| 661 |
+
break;
|
| 662 |
+
|
| 663 |
+
])])
|
| 664 |
+
|
| 665 |
+
# b4_type_foreach(MACRO, [SEP])
|
| 666 |
+
# -----------------------------
|
| 667 |
+
# Invoke MACRO(SYMBOL-NUMS) for each set of SYMBOL-NUMS for each type set.
|
| 668 |
+
m4_define([b4_type_foreach],
|
| 669 |
+
[m4_map_sep([$1], [$2], m4_defn([b4_type_names]))])
|
| 670 |
+
|
| 671 |
+
|
| 672 |
+
|
| 673 |
+
## ----------- ##
|
| 674 |
+
## Synclines. ##
|
| 675 |
+
## ----------- ##
|
| 676 |
+
|
| 677 |
+
# b4_basename(NAME)
|
| 678 |
+
# -----------------
|
| 679 |
+
# Similar to POSIX basename; the differences don't matter here.
|
| 680 |
+
# Beware that NAME is not evaluated.
|
| 681 |
+
m4_define([b4_basename],
|
| 682 |
+
[m4_bpatsubst([$1], [^.*/\([^/]+\)/*$], [\1])])
|
| 683 |
+
|
| 684 |
+
|
| 685 |
+
# b4_syncline(LINE, FILE)dnl
|
| 686 |
+
# --------------------------
|
| 687 |
+
# Should always be following by a dnl.
|
| 688 |
+
#
|
| 689 |
+
# Emit "#line LINE FILE /* __LINE__ __FILE__ */".
|
| 690 |
+
m4_define([b4_syncline],
|
| 691 |
+
[b4_flag_if([synclines],
|
| 692 |
+
[b4_sync_start([$1], [$2])[]dnl
|
| 693 |
+
b4_sync_end([__line__], [b4_basename(m4_quote(__file__))])
|
| 694 |
+
])])
|
| 695 |
+
|
| 696 |
+
# b4_sync_start(LINE, FILE)
|
| 697 |
+
# -----------------------
|
| 698 |
+
# Syncline for the new place. Typically a directive for the compiler.
|
| 699 |
+
m4_define([b4_sync_start], [b4_comment([$2:$1])])
|
| 700 |
+
|
| 701 |
+
# b4_sync_end(LINE, FILE)
|
| 702 |
+
# -----------------------
|
| 703 |
+
# Syncline for the current place, which ends. Typically a comment
|
| 704 |
+
# left for the reader.
|
| 705 |
+
m4_define([b4_sync_end], [ b4_comment([$2:$1])]
|
| 706 |
+
)
|
| 707 |
+
# This generates dependencies on the Bison skeletons hence lots of
|
| 708 |
+
# useless 'git diff'. This location is useless for the regular
|
| 709 |
+
# user (who does not care about the skeletons) and is actually not
|
| 710 |
+
# useful for Bison developers too (I, Akim, never used this to locate
|
| 711 |
+
# the code in skeletons that generated output). So disable it
|
| 712 |
+
# completely. If someone thinks this was actually useful, a %define
|
| 713 |
+
# variable should be provided to control the level of verbosity of
|
| 714 |
+
# '#line', in replacement of --no-lines.
|
| 715 |
+
m4_define([b4_sync_end])
|
| 716 |
+
|
| 717 |
+
|
| 718 |
+
# b4_user_code(USER-CODE)
|
| 719 |
+
# -----------------------
|
| 720 |
+
# Emit code from the user, ending it with synclines.
|
| 721 |
+
m4_define([b4_user_code],
|
| 722 |
+
[$1
|
| 723 |
+
b4_syncline([@oline@], [@ofile@])])
|
| 724 |
+
|
| 725 |
+
|
| 726 |
+
# b4_define_user_code(MACRO, COMMENT)
|
| 727 |
+
# -----------------------------------
|
| 728 |
+
# From b4_MACRO, if defined, build b4_user_MACRO that includes the synclines.
|
| 729 |
+
m4_define([b4_define_user_code],
|
| 730 |
+
[m4_define([b4_user_$1],
|
| 731 |
+
[m4_ifdef([b4_$1],
|
| 732 |
+
[m4_ifval([$2],
|
| 733 |
+
[b4_comment([$2])
|
| 734 |
+
])b4_user_code([b4_$1])])])])
|
| 735 |
+
|
| 736 |
+
# b4_user_actions
|
| 737 |
+
# b4_user_initial_action
|
| 738 |
+
# b4_user_post_prologue
|
| 739 |
+
# b4_user_pre_prologue
|
| 740 |
+
# b4_user_union_members
|
| 741 |
+
# ----------------------
|
| 742 |
+
# Macros that issue user code, ending with synclines.
|
| 743 |
+
b4_define_user_code([actions])
|
| 744 |
+
b4_define_user_code([initial_action], [User initialization code.])
|
| 745 |
+
b4_define_user_code([post_prologue], [Second part of user prologue.])
|
| 746 |
+
b4_define_user_code([pre_prologue], [First part of user prologue.])
|
| 747 |
+
b4_define_user_code([union_members])
|
| 748 |
+
|
| 749 |
+
|
| 750 |
+
# b4_check_user_names(WHAT, USER-LIST, BISON-NAMESPACE)
|
| 751 |
+
# -----------------------------------------------------
|
| 752 |
+
# Complain if any name of type WHAT is used by the user (as recorded in
|
| 753 |
+
# USER-LIST) but is not used by Bison (as recorded by macros in the
|
| 754 |
+
# namespace BISON-NAMESPACE).
|
| 755 |
+
#
|
| 756 |
+
# USER-LIST must expand to a list specifying all user occurrences of all names
|
| 757 |
+
# of type WHAT. Each item in the list must be a triplet specifying one
|
| 758 |
+
# occurrence: name, start boundary, and end boundary. Empty string names are
|
| 759 |
+
# fine. An empty list is fine.
|
| 760 |
+
#
|
| 761 |
+
# For example, to define b4_foo_user_names to be used for USER-LIST with three
|
| 762 |
+
# name occurrences and with correct quoting:
|
| 763 |
+
#
|
| 764 |
+
# m4_define([b4_foo_user_names],
|
| 765 |
+
# [[[[[[bar]], [[parser.y:1.7]], [[parser.y:1.16]]]],
|
| 766 |
+
# [[[[bar]], [[parser.y:5.7]], [[parser.y:5.16]]]],
|
| 767 |
+
# [[[[baz]], [[parser.y:8.7]], [[parser.y:8.16]]]]]])
|
| 768 |
+
#
|
| 769 |
+
# The macro BISON-NAMESPACE(bar) must be defined iff the name bar of type WHAT
|
| 770 |
+
# is used by Bison (in the front-end or in the skeleton). Empty string names
|
| 771 |
+
# are fine, but it would be ugly for Bison to actually use one.
|
| 772 |
+
#
|
| 773 |
+
# For example, to use b4_foo_bison_names for BISON-NAMESPACE and define that
|
| 774 |
+
# the names bar and baz are used by Bison:
|
| 775 |
+
#
|
| 776 |
+
# m4_define([b4_foo_bison_names(bar)])
|
| 777 |
+
# m4_define([b4_foo_bison_names(baz)])
|
| 778 |
+
#
|
| 779 |
+
# To invoke b4_check_user_names with TYPE foo, with USER-LIST
|
| 780 |
+
# b4_foo_user_names, with BISON-NAMESPACE b4_foo_bison_names, and with correct
|
| 781 |
+
# quoting:
|
| 782 |
+
#
|
| 783 |
+
# b4_check_user_names([[foo]], [b4_foo_user_names],
|
| 784 |
+
# [[b4_foo_bison_names]])
|
| 785 |
+
m4_define([b4_check_user_names],
|
| 786 |
+
[m4_foreach([b4_occurrence], $2,
|
| 787 |
+
[m4_pushdef([b4_occurrence], b4_occurrence)dnl
|
| 788 |
+
m4_pushdef([b4_user_name], m4_car(b4_occurrence))dnl
|
| 789 |
+
m4_pushdef([b4_start], m4_car(m4_shift(b4_occurrence)))dnl
|
| 790 |
+
m4_pushdef([b4_end], m4_shift2(b4_occurrence))dnl
|
| 791 |
+
m4_ifndef($3[(]m4_quote(b4_user_name)[)],
|
| 792 |
+
[b4_complain_at([b4_start], [b4_end],
|
| 793 |
+
[[%s '%s' is not used]],
|
| 794 |
+
[$1], [b4_user_name])])[]dnl
|
| 795 |
+
m4_popdef([b4_occurrence])dnl
|
| 796 |
+
m4_popdef([b4_user_name])dnl
|
| 797 |
+
m4_popdef([b4_start])dnl
|
| 798 |
+
m4_popdef([b4_end])dnl
|
| 799 |
+
])])
|
| 800 |
+
|
| 801 |
+
|
| 802 |
+
|
| 803 |
+
## --------------------- ##
|
| 804 |
+
## b4_percent_define_*. ##
|
| 805 |
+
## --------------------- ##
|
| 806 |
+
|
| 807 |
+
|
| 808 |
+
# b4_percent_define_use(VARIABLE)
|
| 809 |
+
# -------------------------------
|
| 810 |
+
# Declare that VARIABLE was used.
|
| 811 |
+
m4_define([b4_percent_define_use],
|
| 812 |
+
[m4_define([b4_percent_define_bison_variables(]$1[)])dnl
|
| 813 |
+
])
|
| 814 |
+
|
| 815 |
+
# b4_percent_define_get(VARIABLE, [DEFAULT])
|
| 816 |
+
# ------------------------------------------
|
| 817 |
+
# Mimic muscle_percent_define_get in ../src/muscle-tab.h. That is, if
|
| 818 |
+
# the %define variable VARIABLE is defined, emit its value. Contrary
|
| 819 |
+
# to its C counterpart, return DEFAULT otherwise. Also, record
|
| 820 |
+
# Bison's usage of VARIABLE by defining
|
| 821 |
+
# b4_percent_define_bison_variables(VARIABLE).
|
| 822 |
+
#
|
| 823 |
+
# For example:
|
| 824 |
+
#
|
| 825 |
+
# b4_percent_define_get([[foo]])
|
| 826 |
+
m4_define([b4_percent_define_get],
|
| 827 |
+
[b4_percent_define_use([$1])dnl
|
| 828 |
+
_b4_percent_define_ifdef([$1],
|
| 829 |
+
[m4_indir([b4_percent_define(]$1[)])],
|
| 830 |
+
[$2])])
|
| 831 |
+
|
| 832 |
+
# b4_percent_define_get_loc(VARIABLE)
|
| 833 |
+
# -----------------------------------
|
| 834 |
+
# Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is,
|
| 835 |
+
# if the %define variable VARIABLE is undefined, complain fatally since that's
|
| 836 |
+
# a Bison or skeleton error. Otherwise, return its definition location in a
|
| 837 |
+
# form appropriate for the first two arguments of b4_warn_at, b4_complain_at, or
|
| 838 |
+
# b4_fatal_at. Don't record this as a Bison usage of VARIABLE as there's no
|
| 839 |
+
# reason to suspect that the user-supplied value has yet influenced the output.
|
| 840 |
+
#
|
| 841 |
+
# For example:
|
| 842 |
+
#
|
| 843 |
+
# b4_complain_at(b4_percent_define_get_loc([[foo]]), [[invalid foo]])
|
| 844 |
+
m4_define([b4_percent_define_get_loc],
|
| 845 |
+
[m4_ifdef([b4_percent_define_loc(]$1[)],
|
| 846 |
+
[m4_pushdef([b4_loc], m4_indir([b4_percent_define_loc(]$1[)]))dnl
|
| 847 |
+
b4_loc[]dnl
|
| 848 |
+
m4_popdef([b4_loc])],
|
| 849 |
+
[b4_fatal([[$0: undefined %%define variable '%s']], [$1])])])
|
| 850 |
+
|
| 851 |
+
# b4_percent_define_get_kind(VARIABLE)
|
| 852 |
+
# ------------------------------------
|
| 853 |
+
# Get the kind (code, keyword, string) of VARIABLE, i.e., how its
|
| 854 |
+
# value was defined (braces, not delimiters, quotes).
|
| 855 |
+
#
|
| 856 |
+
# If the %define variable VARIABLE is undefined, complain fatally
|
| 857 |
+
# since that's a Bison or skeleton error. Don't record this as a
|
| 858 |
+
# Bison usage of VARIABLE as there's no reason to suspect that the
|
| 859 |
+
# user-supplied value has yet influenced the output.
|
| 860 |
+
m4_define([b4_percent_define_get_kind],
|
| 861 |
+
[m4_ifdef([b4_percent_define_kind(]$1[)],
|
| 862 |
+
[m4_indir([b4_percent_define_kind(]$1[)])],
|
| 863 |
+
[b4_fatal([[$0: undefined %%define variable '%s']], [$1])])])
|
| 864 |
+
|
| 865 |
+
# b4_percent_define_get_syncline(VARIABLE)dnl
|
| 866 |
+
# -------------------------------------------
|
| 867 |
+
# Should always be following by a dnl.
|
| 868 |
+
#
|
| 869 |
+
# Mimic muscle_percent_define_get_syncline in ../src/muscle-tab.h exactly.
|
| 870 |
+
# That is, if the %define variable VARIABLE is undefined, complain fatally
|
| 871 |
+
# since that's a Bison or skeleton error. Otherwise, return its definition
|
| 872 |
+
# location as a b4_syncline invocation. Don't record this as a Bison usage of
|
| 873 |
+
# VARIABLE as there's no reason to suspect that the user-supplied value has yet
|
| 874 |
+
# influenced the output.
|
| 875 |
+
#
|
| 876 |
+
# For example:
|
| 877 |
+
#
|
| 878 |
+
# b4_percent_define_get_syncline([[foo]])
|
| 879 |
+
m4_define([b4_percent_define_get_syncline],
|
| 880 |
+
[m4_ifdef([b4_percent_define_syncline(]$1[)],
|
| 881 |
+
[m4_indir([b4_percent_define_syncline(]$1[)])],
|
| 882 |
+
[b4_fatal([[$0: undefined %%define variable '%s']], [$1])])])
|
| 883 |
+
|
| 884 |
+
# _b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE])
|
| 885 |
+
# ------------------------------------------------------
|
| 886 |
+
# If the %define variable VARIABLE is defined, expand IF-TRUE, else expand
|
| 887 |
+
# IF-FALSE. Don't record usage of VARIABLE.
|
| 888 |
+
#
|
| 889 |
+
# For example:
|
| 890 |
+
#
|
| 891 |
+
# _b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
|
| 892 |
+
m4_define([_b4_percent_define_ifdef],
|
| 893 |
+
[m4_ifdef([b4_percent_define(]$1[)],
|
| 894 |
+
[$2],
|
| 895 |
+
[$3])])
|
| 896 |
+
|
| 897 |
+
# b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE])
|
| 898 |
+
# ------------------------------------------------------
|
| 899 |
+
# Mimic muscle_percent_define_ifdef in ../src/muscle-tab.h exactly. That is,
|
| 900 |
+
# if the %define variable VARIABLE is defined, expand IF-TRUE, else expand
|
| 901 |
+
# IF-FALSE. Also, record Bison's usage of VARIABLE by defining
|
| 902 |
+
# b4_percent_define_bison_variables(VARIABLE).
|
| 903 |
+
#
|
| 904 |
+
# For example:
|
| 905 |
+
#
|
| 906 |
+
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
|
| 907 |
+
m4_define([b4_percent_define_ifdef],
|
| 908 |
+
[_b4_percent_define_ifdef([$1],
|
| 909 |
+
[b4_percent_define_use([$1])$2],
|
| 910 |
+
[$3])])
|
| 911 |
+
|
| 912 |
+
|
| 913 |
+
# b4_percent_define_check_file_complain(VARIABLE)
|
| 914 |
+
# -----------------------------------------------
|
| 915 |
+
# Warn about %define variable VARIABLE having an incorrect
|
| 916 |
+
# value.
|
| 917 |
+
m4_define([b4_percent_define_check_file_complain],
|
| 918 |
+
[b4_complain_at(b4_percent_define_get_loc([$1]),
|
| 919 |
+
[[%%define variable '%s' requires 'none' or '"..."' values]],
|
| 920 |
+
[$1])])
|
| 921 |
+
|
| 922 |
+
|
| 923 |
+
# b4_percent_define_check_file(MACRO, VARIABLE, DEFAULT)
|
| 924 |
+
# ------------------------------------------------------
|
| 925 |
+
# If the %define variable VARIABLE:
|
| 926 |
+
# - is undefined, then if DEFAULT is non-empty, define MACRO to DEFAULT
|
| 927 |
+
# - is a string, define MACRO to its value
|
| 928 |
+
# - is the keyword 'none', do nothing
|
| 929 |
+
# - otherwise, warn about the incorrect value.
|
| 930 |
+
m4_define([b4_percent_define_check_file],
|
| 931 |
+
[b4_percent_define_ifdef([$2],
|
| 932 |
+
[m4_case(b4_percent_define_get_kind([$2]),
|
| 933 |
+
[string],
|
| 934 |
+
[m4_define([$1], b4_percent_define_get([$2]))],
|
| 935 |
+
[keyword],
|
| 936 |
+
[m4_if(b4_percent_define_get([$2]), [none], [],
|
| 937 |
+
[b4_percent_define_check_file_complain([$2])])],
|
| 938 |
+
[b4_percent_define_check_file_complain([$2])])
|
| 939 |
+
],
|
| 940 |
+
[m4_ifval([$3],
|
| 941 |
+
[m4_define([$1], [$3])])])
|
| 942 |
+
])
|
| 943 |
+
|
| 944 |
+
|
| 945 |
+
|
| 946 |
+
## --------- ##
|
| 947 |
+
## Options. ##
|
| 948 |
+
## --------- ##
|
| 949 |
+
|
| 950 |
+
|
| 951 |
+
# b4_percent_define_flag_if(VARIABLE, IF-TRUE, [IF-FALSE])
|
| 952 |
+
# --------------------------------------------------------
|
| 953 |
+
# Mimic muscle_percent_define_flag_if in ../src/muscle-tab.h exactly. That is,
|
| 954 |
+
# if the %define variable VARIABLE is defined to "" or "true", expand IF-TRUE.
|
| 955 |
+
# If it is defined to "false", expand IF-FALSE. Complain if it is undefined
|
| 956 |
+
# (a Bison or skeleton error since the default value should have been set
|
| 957 |
+
# already) or defined to any other value (possibly a user error). Also, record
|
| 958 |
+
# Bison's usage of VARIABLE by defining
|
| 959 |
+
# b4_percent_define_bison_variables(VARIABLE).
|
| 960 |
+
#
|
| 961 |
+
# For example:
|
| 962 |
+
#
|
| 963 |
+
# b4_percent_define_flag_if([[foo]], [[it's true]], [[it's false]])
|
| 964 |
+
m4_define([b4_percent_define_flag_if],
|
| 965 |
+
[b4_percent_define_ifdef([$1],
|
| 966 |
+
[m4_case(b4_percent_define_get([$1]),
|
| 967 |
+
[], [$2], [true], [$2], [false], [$3],
|
| 968 |
+
[m4_expand_once([b4_complain_at(b4_percent_define_get_loc([$1]),
|
| 969 |
+
[[invalid value for %%define Boolean variable '%s']],
|
| 970 |
+
[$1])],
|
| 971 |
+
[[b4_percent_define_flag_if($1)]])])],
|
| 972 |
+
[b4_fatal([[$0: undefined %%define variable '%s']], [$1])])])
|
| 973 |
+
|
| 974 |
+
|
| 975 |
+
# b4_percent_define_default(VARIABLE, DEFAULT, [KIND = keyword])
|
| 976 |
+
# --------------------------------------------------------------
|
| 977 |
+
# Mimic muscle_percent_define_default in ../src/muscle-tab.h exactly. That is,
|
| 978 |
+
# if the %define variable VARIABLE is undefined, set its value to DEFAULT.
|
| 979 |
+
# Don't record this as a Bison usage of VARIABLE as there's no reason to
|
| 980 |
+
# suspect that the value has yet influenced the output.
|
| 981 |
+
#
|
| 982 |
+
# For example:
|
| 983 |
+
#
|
| 984 |
+
# b4_percent_define_default([[foo]], [[default value]])
|
| 985 |
+
m4_define([_b4_percent_define_define],
|
| 986 |
+
[m4_define([b4_percent_define(]$1[)], [$2])dnl
|
| 987 |
+
m4_define([b4_percent_define_kind(]$1[)],
|
| 988 |
+
[m4_default([$3], [keyword])])dnl
|
| 989 |
+
m4_define([b4_percent_define_loc(]$1[)],
|
| 990 |
+
[[[[<skeleton default value>:-1.-1]],
|
| 991 |
+
[[<skeleton default value>:-1.-1]]]])dnl
|
| 992 |
+
m4_define([b4_percent_define_syncline(]$1[)], [[]])])
|
| 993 |
+
|
| 994 |
+
m4_define([b4_percent_define_default],
|
| 995 |
+
[_b4_percent_define_ifdef([$1], [],
|
| 996 |
+
[_b4_percent_define_define($@)])])
|
| 997 |
+
|
| 998 |
+
|
| 999 |
+
# b4_percent_define_if_define(NAME, [VARIABLE = NAME])
|
| 1000 |
+
# ----------------------------------------------------
|
| 1001 |
+
# Define b4_NAME_if that executes its $1 or $2 depending whether
|
| 1002 |
+
# VARIABLE was %defined. The characters '.' and `-' in VARIABLE are mapped
|
| 1003 |
+
# to '_'.
|
| 1004 |
+
m4_define([_b4_percent_define_if_define],
|
| 1005 |
+
[m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]),
|
| 1006 |
+
[b4_percent_define_default([m4_default([$2], [$1])], [[false]])dnl
|
| 1007 |
+
b4_percent_define_flag_if(m4_default([$2], [$1]),
|
| 1008 |
+
[$3], [$4])])])
|
| 1009 |
+
|
| 1010 |
+
m4_define([b4_percent_define_if_define],
|
| 1011 |
+
[_b4_percent_define_if_define([$1], [$2], $[1], $[2])])
|
| 1012 |
+
|
| 1013 |
+
|
| 1014 |
+
# b4_percent_define_check_kind(VARIABLE, KIND, [DIAGNOSTIC = complain])
|
| 1015 |
+
# ---------------------------------------------------------------------
|
| 1016 |
+
m4_define([b4_percent_define_check_kind],
|
| 1017 |
+
[_b4_percent_define_ifdef([$1],
|
| 1018 |
+
[m4_if(b4_percent_define_get_kind([$1]), [$2], [],
|
| 1019 |
+
[b4_error([m4_default([$3], [complain])],
|
| 1020 |
+
b4_percent_define_get_loc([$1]),
|
| 1021 |
+
[m4_case([$2],
|
| 1022 |
+
[code], [[%%define variable '%s' requires '{...}' values]],
|
| 1023 |
+
[keyword], [[%%define variable '%s' requires keyword values]],
|
| 1024 |
+
[string], [[%%define variable '%s' requires '"..."' values]])],
|
| 1025 |
+
[$1])])])dnl
|
| 1026 |
+
])
|
| 1027 |
+
|
| 1028 |
+
|
| 1029 |
+
# b4_percent_define_check_values(VALUES)
|
| 1030 |
+
# --------------------------------------
|
| 1031 |
+
# Mimic muscle_percent_define_check_values in ../src/muscle-tab.h exactly
|
| 1032 |
+
# except that the VALUES structure is more appropriate for M4. That is, VALUES
|
| 1033 |
+
# is a list of sublists of strings. For each sublist, the first string is the
|
| 1034 |
+
# name of a %define variable, and all remaining strings in that sublist are the
|
| 1035 |
+
# valid values for that variable. Complain if such a variable is undefined (a
|
| 1036 |
+
# Bison error since the default value should have been set already) or defined
|
| 1037 |
+
# to any other value (possibly a user error). Don't record this as a Bison
|
| 1038 |
+
# usage of the variable as there's no reason to suspect that the value has yet
|
| 1039 |
+
# influenced the output.
|
| 1040 |
+
#
|
| 1041 |
+
# For example:
|
| 1042 |
+
#
|
| 1043 |
+
# b4_percent_define_check_values([[[[foo]], [[foo-value1]], [[foo-value2]]]],
|
| 1044 |
+
# [[[[bar]], [[bar-value1]]]])
|
| 1045 |
+
m4_define([b4_percent_define_check_values],
|
| 1046 |
+
[m4_foreach([b4_sublist], m4_quote($@),
|
| 1047 |
+
[_b4_percent_define_check_values(b4_sublist)])])
|
| 1048 |
+
|
| 1049 |
+
m4_define([_b4_percent_define_check_values],
|
| 1050 |
+
[_b4_percent_define_ifdef([$1],
|
| 1051 |
+
[b4_percent_define_check_kind(]$1[, [keyword], [deprecated])dnl
|
| 1052 |
+
m4_pushdef([b4_good_value], [0])dnl
|
| 1053 |
+
m4_if($#, 1, [],
|
| 1054 |
+
[m4_foreach([b4_value], m4_dquote(m4_shift($@)),
|
| 1055 |
+
[m4_if(m4_indir([b4_percent_define(]$1[)]), b4_value,
|
| 1056 |
+
[m4_define([b4_good_value], [1])])])])dnl
|
| 1057 |
+
m4_if(b4_good_value, [0],
|
| 1058 |
+
[b4_complain_at(b4_percent_define_get_loc([$1]),
|
| 1059 |
+
[[invalid value for %%define variable '%s': '%s']],
|
| 1060 |
+
[$1],
|
| 1061 |
+
m4_dquote(m4_indir([b4_percent_define(]$1[)])))
|
| 1062 |
+
m4_foreach([b4_value], m4_dquote(m4_shift($@)),
|
| 1063 |
+
[b4_error([[note]], b4_percent_define_get_loc([$1]), []
|
| 1064 |
+
[[accepted value: '%s']],
|
| 1065 |
+
m4_dquote(b4_value))])])dnl
|
| 1066 |
+
m4_popdef([b4_good_value])],
|
| 1067 |
+
[b4_fatal([[$0: undefined %%define variable '%s']], [$1])])])
|
| 1068 |
+
|
| 1069 |
+
# b4_percent_code_get([QUALIFIER])
|
| 1070 |
+
# --------------------------------
|
| 1071 |
+
# If any %code blocks for QUALIFIER are defined, emit them beginning with a
|
| 1072 |
+
# comment and ending with synclines and a newline. If QUALIFIER is not
|
| 1073 |
+
# specified or empty, do this for the unqualified %code blocks. Also, record
|
| 1074 |
+
# Bison's usage of QUALIFIER (if specified) by defining
|
| 1075 |
+
# b4_percent_code_bison_qualifiers(QUALIFIER).
|
| 1076 |
+
#
|
| 1077 |
+
# For example, to emit any unqualified %code blocks followed by any %code
|
| 1078 |
+
# blocks for the qualifier foo:
|
| 1079 |
+
#
|
| 1080 |
+
# b4_percent_code_get
|
| 1081 |
+
# b4_percent_code_get([[foo]])
|
| 1082 |
+
m4_define([b4_percent_code_get],
|
| 1083 |
+
[m4_pushdef([b4_macro_name], [[b4_percent_code(]$1[)]])dnl
|
| 1084 |
+
m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])dnl
|
| 1085 |
+
m4_ifdef(b4_macro_name,
|
| 1086 |
+
[b4_comment(m4_if([$#], [0], [[[Unqualified %code blocks.]]],
|
| 1087 |
+
[[["%code ]$1[" blocks.]]]))
|
| 1088 |
+
b4_user_code([m4_indir(b4_macro_name)])])dnl
|
| 1089 |
+
m4_popdef([b4_macro_name])])
|
| 1090 |
+
|
| 1091 |
+
# b4_percent_code_ifdef(QUALIFIER, IF-TRUE, [IF-FALSE])
|
| 1092 |
+
# -----------------------------------------------------
|
| 1093 |
+
# If any %code blocks for QUALIFIER (or unqualified %code blocks if
|
| 1094 |
+
# QUALIFIER is empty) are defined, expand IF-TRUE, else expand IF-FALSE.
|
| 1095 |
+
# Also, record Bison's usage of QUALIFIER (if specified) by defining
|
| 1096 |
+
# b4_percent_code_bison_qualifiers(QUALIFIER).
|
| 1097 |
+
m4_define([b4_percent_code_ifdef],
|
| 1098 |
+
[m4_ifdef([b4_percent_code(]$1[)],
|
| 1099 |
+
[m4_ifval([$1], [m4_define([b4_percent_code_bison_qualifiers(]$1[)])])$2],
|
| 1100 |
+
[$3])])
|
| 1101 |
+
|
| 1102 |
+
|
| 1103 |
+
## ------------------ ##
|
| 1104 |
+
## Common variables. ##
|
| 1105 |
+
## ------------------ ##
|
| 1106 |
+
|
| 1107 |
+
|
| 1108 |
+
# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
|
| 1109 |
+
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
|
| 1110 |
+
# b4_token_ctor_if([IF-YYLEX-RETURNS-A-TOKEN], [IF-NOT])
|
| 1111 |
+
# ----------------------------------------------------------
|
| 1112 |
+
b4_percent_define_if_define([api.token.raw])
|
| 1113 |
+
b4_percent_define_if_define([token_ctor], [api.token.constructor])
|
| 1114 |
+
b4_percent_define_if_define([locations]) # Whether locations are tracked.
|
| 1115 |
+
b4_percent_define_if_define([parse.assert])
|
| 1116 |
+
b4_percent_define_if_define([parse.trace])
|
| 1117 |
+
b4_percent_define_if_define([posix])
|
| 1118 |
+
|
| 1119 |
+
|
| 1120 |
+
# b4_bison_locations_if([IF-TRUE])
|
| 1121 |
+
# --------------------------------
|
| 1122 |
+
# Expand IF-TRUE if using locations, and using the default location
|
| 1123 |
+
# type.
|
| 1124 |
+
m4_define([b4_bison_locations_if],
|
| 1125 |
+
[b4_locations_if([b4_percent_define_ifdef([[api.location.type]], [], [$1])])])
|
| 1126 |
+
|
| 1127 |
+
|
| 1128 |
+
|
| 1129 |
+
# %define parse.error "(custom|detailed|simple|verbose)"
|
| 1130 |
+
# ------------------------------------------------------
|
| 1131 |
+
b4_percent_define_default([[parse.error]], [[simple]])
|
| 1132 |
+
b4_percent_define_check_values([[[[parse.error]],
|
| 1133 |
+
[[custom]], [[detailed]], [[simple]], [[verbose]]]])
|
| 1134 |
+
|
| 1135 |
+
# b4_parse_error_case(CASE1, THEN1, CASE2, THEN2, ..., ELSE)
|
| 1136 |
+
# ----------------------------------------------------------
|
| 1137 |
+
m4_define([b4_parse_error_case],
|
| 1138 |
+
[m4_case(b4_percent_define_get([[parse.error]]), $@)])
|
| 1139 |
+
|
| 1140 |
+
# b4_parse_error_bmatch(PATTERN1, THEN1, PATTERN2, THEN2, ..., ELSE)
|
| 1141 |
+
# ------------------------------------------------------------------
|
| 1142 |
+
m4_define([b4_parse_error_bmatch],
|
| 1143 |
+
[m4_bmatch(b4_percent_define_get([[parse.error]]), $@)])
|
| 1144 |
+
|
| 1145 |
+
|
| 1146 |
+
|
| 1147 |
+
# b4_union_if([IF-UNION-ARE-USED], [IF-NOT])
|
| 1148 |
+
# b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
|
| 1149 |
+
# ----------------------------------------------
|
| 1150 |
+
# Depend on whether api.value.type is union, or variant.
|
| 1151 |
+
m4_define([b4_union_flag], [[0]])
|
| 1152 |
+
m4_define([b4_variant_flag], [[0]])
|
| 1153 |
+
b4_percent_define_ifdef([[api.value.type]],
|
| 1154 |
+
[m4_case(b4_percent_define_get_kind([[api.value.type]]), [keyword],
|
| 1155 |
+
[m4_case(b4_percent_define_get([[api.value.type]]),
|
| 1156 |
+
[union], [m4_define([b4_union_flag], [[1]])],
|
| 1157 |
+
[variant], [m4_define([b4_variant_flag], [[1]])])])])
|
| 1158 |
+
b4_define_flag_if([union])
|
| 1159 |
+
b4_define_flag_if([variant])
|
| 1160 |
+
|
| 1161 |
+
|
| 1162 |
+
## ----------------------------------------------------------- ##
|
| 1163 |
+
## After processing the skeletons, check that all the user's ##
|
| 1164 |
+
## %define variables and %code qualifiers were used by Bison. ##
|
| 1165 |
+
## ----------------------------------------------------------- ##
|
| 1166 |
+
|
| 1167 |
+
m4_define([b4_check_user_names_wrap],
|
| 1168 |
+
[m4_ifdef([b4_percent_]$1[_user_]$2[s],
|
| 1169 |
+
[b4_check_user_names([[%]$1 $2],
|
| 1170 |
+
[b4_percent_]$1[_user_]$2[s],
|
| 1171 |
+
[[b4_percent_]$1[_bison_]$2[s]])])])
|
| 1172 |
+
|
| 1173 |
+
m4_wrap_lifo([
|
| 1174 |
+
b4_check_user_names_wrap([[define]], [[variable]])
|
| 1175 |
+
b4_check_user_names_wrap([[code]], [[qualifier]])
|
| 1176 |
+
])
|
| 1177 |
+
|
| 1178 |
+
|
| 1179 |
+
## ---------------- ##
|
| 1180 |
+
## Default values. ##
|
| 1181 |
+
## ---------------- ##
|
| 1182 |
+
|
| 1183 |
+
# m4_define_default([b4_lex_param], []) dnl breaks other skeletons
|
| 1184 |
+
m4_define_default([b4_epilogue], [])
|
| 1185 |
+
m4_define_default([b4_parse_param], [])
|
| 1186 |
+
|
| 1187 |
+
# The initial column and line.
|
| 1188 |
+
m4_define_default([b4_location_initial_column], [1])
|
| 1189 |
+
m4_define_default([b4_location_initial_line], [1])
|
| 1190 |
+
|
| 1191 |
+
|
| 1192 |
+
## --------------- ##
|
| 1193 |
+
## Sanity checks. ##
|
| 1194 |
+
## --------------- ##
|
| 1195 |
+
|
| 1196 |
+
# api.location.type={...} (C, C++ and Java).
|
| 1197 |
+
b4_percent_define_check_kind([api.location.type], [code], [deprecated])
|
| 1198 |
+
|
| 1199 |
+
# api.position.type={...} (Java).
|
| 1200 |
+
b4_percent_define_check_kind([api.position.type], [code], [deprecated])
|
| 1201 |
+
|
| 1202 |
+
# api.prefix >< %name-prefix.
|
| 1203 |
+
b4_percent_define_check_kind([api.prefix], [code], [deprecated])
|
| 1204 |
+
b4_percent_define_ifdef([api.prefix],
|
| 1205 |
+
[m4_ifdef([b4_prefix],
|
| 1206 |
+
[b4_complain_at(b4_percent_define_get_loc([api.prefix]),
|
| 1207 |
+
[['%s' and '%s' cannot be used together]],
|
| 1208 |
+
[%name-prefix],
|
| 1209 |
+
[%define api.prefix])])])
|
| 1210 |
+
|
| 1211 |
+
# api.token.prefix={...}
|
| 1212 |
+
# Make it a warning for those who used betas of Bison 3.0.
|
| 1213 |
+
b4_percent_define_check_kind([api.token.prefix], [code], [deprecated])
|
| 1214 |
+
|
| 1215 |
+
# api.value.type >< %union.
|
| 1216 |
+
b4_percent_define_ifdef([api.value.type],
|
| 1217 |
+
[m4_ifdef([b4_union_members],
|
| 1218 |
+
[b4_complain_at(b4_percent_define_get_loc([api.value.type]),
|
| 1219 |
+
[['%s' and '%s' cannot be used together]],
|
| 1220 |
+
[%union],
|
| 1221 |
+
[%define api.value.type])])])
|
| 1222 |
+
|
| 1223 |
+
# api.value.type=union >< %yacc.
|
| 1224 |
+
b4_percent_define_ifdef([api.value.type],
|
| 1225 |
+
[m4_if(b4_percent_define_get([api.value.type]), [union],
|
| 1226 |
+
[b4_yacc_if(dnl
|
| 1227 |
+
[b4_complain_at(b4_percent_define_get_loc([api.value.type]),
|
| 1228 |
+
[['%s' and '%s' cannot be used together]],
|
| 1229 |
+
[%yacc],
|
| 1230 |
+
[%define api.value.type "union"])])])])
|
| 1231 |
+
|
| 1232 |
+
# api.value.union.name.
|
| 1233 |
+
b4_percent_define_check_kind([api.value.union.name], [keyword])
|
| 1234 |
+
|
| 1235 |
+
# parse.error (custom|detailed) >< token-table.
|
| 1236 |
+
b4_token_table_if(
|
| 1237 |
+
[b4_parse_error_bmatch([custom\|detailed],
|
| 1238 |
+
[b4_complain_at(b4_percent_define_get_loc([parse.error]),
|
| 1239 |
+
[['%s' and '%s' cannot be used together]],
|
| 1240 |
+
[%token-table],
|
| 1241 |
+
[%define parse.error (custom|detailed)])])])
|
platform/dbops/binaries/build/share/bison/skeletons/c++-skel.m4
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-*- Autoconf -*-
|
| 2 |
+
|
| 3 |
+
# C++ skeleton dispatching for Bison.
|
| 4 |
+
|
| 5 |
+
# Copyright (C) 2006-2007, 2009-2015, 2018-2021 Free Software
|
| 6 |
+
# Foundation, Inc.
|
| 7 |
+
|
| 8 |
+
# This program is free software: you can redistribute it and/or modify
|
| 9 |
+
# it under the terms of the GNU General Public License as published by
|
| 10 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 11 |
+
# (at your option) any later version.
|
| 12 |
+
#
|
| 13 |
+
# This program is distributed in the hope that it will be useful,
|
| 14 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 16 |
+
# GNU General Public License for more details.
|
| 17 |
+
#
|
| 18 |
+
# You should have received a copy of the GNU General Public License
|
| 19 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 20 |
+
|
| 21 |
+
b4_glr_if( [m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.cc]])])
|
| 22 |
+
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.cc]])])
|
| 23 |
+
|
| 24 |
+
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[lalr1.cc]])
|
| 25 |
+
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
| 26 |
+
|
| 27 |
+
m4_include(b4_used_skeleton)
|
platform/dbops/binaries/build/share/bison/skeletons/c++.m4
ADDED
|
@@ -0,0 +1,778 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-*- Autoconf -*-
|
| 2 |
+
|
| 3 |
+
# C++ skeleton for Bison
|
| 4 |
+
|
| 5 |
+
# Copyright (C) 2002-2021 Free Software Foundation, Inc.
|
| 6 |
+
|
| 7 |
+
# This program is free software: you can redistribute it and/or modify
|
| 8 |
+
# it under the terms of the GNU General Public License as published by
|
| 9 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 10 |
+
# (at your option) any later version.
|
| 11 |
+
#
|
| 12 |
+
# This program is distributed in the hope that it will be useful,
|
| 13 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
# GNU General Public License for more details.
|
| 16 |
+
#
|
| 17 |
+
# You should have received a copy of the GNU General Public License
|
| 18 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 19 |
+
|
| 20 |
+
# Sanity checks, before defaults installed by c.m4.
|
| 21 |
+
b4_percent_define_ifdef([[api.value.union.name]],
|
| 22 |
+
[b4_complain_at(b4_percent_define_get_loc([[api.value.union.name]]),
|
| 23 |
+
[named %union is invalid in C++])])
|
| 24 |
+
|
| 25 |
+
b4_percent_define_default([[api.symbol.prefix]], [[S_]])
|
| 26 |
+
|
| 27 |
+
m4_include(b4_skeletonsdir/[c.m4])
|
| 28 |
+
|
| 29 |
+
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
|
| 30 |
+
b4_percent_define_check_kind([api.parser.class], [code], [deprecated])
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
## ----- ##
|
| 34 |
+
## C++. ##
|
| 35 |
+
## ----- ##
|
| 36 |
+
|
| 37 |
+
# b4_comment(TEXT, [PREFIX])
|
| 38 |
+
# --------------------------
|
| 39 |
+
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
| 40 |
+
m4_define([b4_comment],
|
| 41 |
+
[_b4_comment([$1], [$2// ], [$2// ])])
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
# b4_inline(hh|cc)
|
| 45 |
+
# ----------------
|
| 46 |
+
# Expand to `inline\n ` if $1 is hh.
|
| 47 |
+
m4_define([b4_inline],
|
| 48 |
+
[m4_case([$1],
|
| 49 |
+
[cc], [],
|
| 50 |
+
[hh], [[inline
|
| 51 |
+
]],
|
| 52 |
+
[m4_fatal([$0: invalid argument: $1])])])
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
# b4_cxx_portability
|
| 56 |
+
# ------------------
|
| 57 |
+
m4_define([b4_cxx_portability],
|
| 58 |
+
[#if defined __cplusplus
|
| 59 |
+
# define YY_CPLUSPLUS __cplusplus
|
| 60 |
+
#else
|
| 61 |
+
# define YY_CPLUSPLUS 199711L
|
| 62 |
+
#endif
|
| 63 |
+
|
| 64 |
+
// Support move semantics when possible.
|
| 65 |
+
#if 201103L <= YY_CPLUSPLUS
|
| 66 |
+
# define YY_MOVE std::move
|
| 67 |
+
# define YY_MOVE_OR_COPY move
|
| 68 |
+
# define YY_MOVE_REF(Type) Type&&
|
| 69 |
+
# define YY_RVREF(Type) Type&&
|
| 70 |
+
# define YY_COPY(Type) Type
|
| 71 |
+
#else
|
| 72 |
+
# define YY_MOVE
|
| 73 |
+
# define YY_MOVE_OR_COPY copy
|
| 74 |
+
# define YY_MOVE_REF(Type) Type&
|
| 75 |
+
# define YY_RVREF(Type) const Type&
|
| 76 |
+
# define YY_COPY(Type) const Type&
|
| 77 |
+
#endif
|
| 78 |
+
|
| 79 |
+
// Support noexcept when possible.
|
| 80 |
+
#if 201103L <= YY_CPLUSPLUS
|
| 81 |
+
# define YY_NOEXCEPT noexcept
|
| 82 |
+
# define YY_NOTHROW
|
| 83 |
+
#else
|
| 84 |
+
# define YY_NOEXCEPT
|
| 85 |
+
# define YY_NOTHROW throw ()
|
| 86 |
+
#endif
|
| 87 |
+
|
| 88 |
+
// Support constexpr when possible.
|
| 89 |
+
#if 201703 <= YY_CPLUSPLUS
|
| 90 |
+
# define YY_CONSTEXPR constexpr
|
| 91 |
+
#else
|
| 92 |
+
# define YY_CONSTEXPR
|
| 93 |
+
#endif[]dnl
|
| 94 |
+
])
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
## ---------------- ##
|
| 98 |
+
## Default values. ##
|
| 99 |
+
## ---------------- ##
|
| 100 |
+
|
| 101 |
+
b4_percent_define_default([[api.parser.class]], [[parser]])
|
| 102 |
+
|
| 103 |
+
# Don't do that so that we remember whether we're using a user
|
| 104 |
+
# request, or the default value.
|
| 105 |
+
#
|
| 106 |
+
# b4_percent_define_default([[api.location.type]], [[location]])
|
| 107 |
+
|
| 108 |
+
b4_percent_define_default([[api.filename.type]], [[const std::string]])
|
| 109 |
+
# Make it a warning for those who used betas of Bison 3.0.
|
| 110 |
+
b4_percent_define_default([[api.namespace]], m4_defn([b4_prefix]))
|
| 111 |
+
|
| 112 |
+
b4_percent_define_default([[define_location_comparison]],
|
| 113 |
+
[m4_if(b4_percent_define_get([[filename_type]]),
|
| 114 |
+
[std::string], [[true]], [[false]])])
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
## ----------- ##
|
| 119 |
+
## Namespace. ##
|
| 120 |
+
## ----------- ##
|
| 121 |
+
|
| 122 |
+
m4_define([b4_namespace_ref], [b4_percent_define_get([[api.namespace]])])
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
# Don't permit an empty b4_namespace_ref. Any '::parser::foo' appended to it
|
| 126 |
+
# would compile as an absolute reference with 'parser' in the global namespace.
|
| 127 |
+
# b4_namespace_open would open an anonymous namespace and thus establish
|
| 128 |
+
# internal linkage. This would compile. However, it's cryptic, and internal
|
| 129 |
+
# linkage for the parser would be specified in all translation units that
|
| 130 |
+
# include the header, which is always generated. If we ever need to permit
|
| 131 |
+
# internal linkage somehow, surely we can find a cleaner approach.
|
| 132 |
+
m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
|
| 133 |
+
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
| 134 |
+
[[namespace reference is empty]])])
|
| 135 |
+
|
| 136 |
+
# Instead of assuming the C++ compiler will do it, Bison should reject any
|
| 137 |
+
# invalid b4_namespace_ref that would be converted to a valid
|
| 138 |
+
# b4_namespace_open. The problem is that Bison doesn't always output
|
| 139 |
+
# b4_namespace_ref to uncommented code but should reserve the ability to do so
|
| 140 |
+
# in future releases without risking breaking any existing user grammars.
|
| 141 |
+
# Specifically, don't allow empty names as b4_namespace_open would just convert
|
| 142 |
+
# those into anonymous namespaces, and that might tempt some users.
|
| 143 |
+
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*::]), [-1], [],
|
| 144 |
+
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
| 145 |
+
[[namespace reference has consecutive "::"]])])
|
| 146 |
+
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [],
|
| 147 |
+
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
| 148 |
+
[[namespace reference has a trailing "::"]])])
|
| 149 |
+
|
| 150 |
+
m4_define([b4_namespace_open],
|
| 151 |
+
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])dnl
|
| 152 |
+
[namespace ]m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref),
|
| 153 |
+
[^\(.\)[ ]*::], [\1])),
|
| 154 |
+
[::], [ { namespace ])[ {]])])
|
| 155 |
+
|
| 156 |
+
m4_define([b4_namespace_close],
|
| 157 |
+
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])dnl
|
| 158 |
+
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
|
| 159 |
+
[^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],
|
| 160 |
+
[\1])),
|
| 161 |
+
[::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])])
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
## ------------- ##
|
| 165 |
+
## Token kinds. ##
|
| 166 |
+
## ------------- ##
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
# b4_token_enums
|
| 170 |
+
# --------------
|
| 171 |
+
# Output the definition of the token kinds.
|
| 172 |
+
m4_define([b4_token_enums],
|
| 173 |
+
[[enum token_kind_type
|
| 174 |
+
{
|
| 175 |
+
]b4_symbol([-2], [id])[ = -2,
|
| 176 |
+
]b4_symbol_foreach([b4_token_enum])dnl
|
| 177 |
+
[ };]dnl
|
| 178 |
+
])
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
## -------------- ##
|
| 183 |
+
## Symbol kinds. ##
|
| 184 |
+
## -------------- ##
|
| 185 |
+
|
| 186 |
+
# b4_declare_symbol_enum
|
| 187 |
+
# ----------------------
|
| 188 |
+
# The definition of the symbol internal numbers as an enum.
|
| 189 |
+
# Defining YYEMPTY here is important: it forces the compiler
|
| 190 |
+
# to use a signed type, which matters for yytoken.
|
| 191 |
+
m4_define([b4_declare_symbol_enum],
|
| 192 |
+
[[enum symbol_kind_type
|
| 193 |
+
{
|
| 194 |
+
YYNTOKENS = ]b4_tokens_number[, ///< Number of tokens.
|
| 195 |
+
]b4_symbol(empty, kind_base)[ = -2,
|
| 196 |
+
]b4_symbol_foreach([ b4_symbol_enum])dnl
|
| 197 |
+
[ };]])
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
## ----------------- ##
|
| 202 |
+
## Semantic Values. ##
|
| 203 |
+
## ----------------- ##
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
# b4_value_type_declare
|
| 208 |
+
# ---------------------
|
| 209 |
+
# Declare value_type.
|
| 210 |
+
m4_define([b4_value_type_declare],
|
| 211 |
+
[b4_value_type_setup[]dnl
|
| 212 |
+
[ /// Symbol semantic values.
|
| 213 |
+
]m4_bmatch(b4_percent_define_get_kind([[api.value.type]]),
|
| 214 |
+
[code],
|
| 215 |
+
[[ typedef ]b4_percent_define_get([[api.value.type]])[ value_type;]],
|
| 216 |
+
[m4_bmatch(b4_percent_define_get([[api.value.type]]),
|
| 217 |
+
[union\|union-directive],
|
| 218 |
+
[[ union value_type
|
| 219 |
+
{
|
| 220 |
+
]b4_user_union_members[
|
| 221 |
+
};]])])dnl
|
| 222 |
+
])
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
# b4_public_types_declare
|
| 226 |
+
# -----------------------
|
| 227 |
+
# Define the public types: token, semantic value, location, and so forth.
|
| 228 |
+
# Depending on %define token_lex, may be output in the header or source file.
|
| 229 |
+
m4_define([b4_public_types_declare],
|
| 230 |
+
[b4_glr2_cc_if(
|
| 231 |
+
[b4_value_type_declare],
|
| 232 |
+
[[#ifdef ]b4_api_PREFIX[STYPE
|
| 233 |
+
# ifdef __GNUC__
|
| 234 |
+
# pragma GCC message "bison: do not #define ]b4_api_PREFIX[STYPE in C++, use %define api.value.type"
|
| 235 |
+
# endif
|
| 236 |
+
typedef ]b4_api_PREFIX[STYPE value_type;
|
| 237 |
+
#else
|
| 238 |
+
]b4_value_type_declare[
|
| 239 |
+
#endif
|
| 240 |
+
/// Backward compatibility (Bison 3.8).
|
| 241 |
+
typedef value_type semantic_type;
|
| 242 |
+
]])[]b4_locations_if([
|
| 243 |
+
/// Symbol locations.
|
| 244 |
+
typedef b4_percent_define_get([[api.location.type]],
|
| 245 |
+
[[location]]) location_type;])[
|
| 246 |
+
|
| 247 |
+
/// Syntax errors thrown from user actions.
|
| 248 |
+
struct syntax_error : std::runtime_error
|
| 249 |
+
{
|
| 250 |
+
syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m)
|
| 251 |
+
: std::runtime_error (m)]b4_locations_if([
|
| 252 |
+
, location (l)])[
|
| 253 |
+
{}
|
| 254 |
+
|
| 255 |
+
syntax_error (const syntax_error& s)
|
| 256 |
+
: std::runtime_error (s.what ())]b4_locations_if([
|
| 257 |
+
, location (s.location)])[
|
| 258 |
+
{}
|
| 259 |
+
|
| 260 |
+
~syntax_error () YY_NOEXCEPT YY_NOTHROW;]b4_locations_if([
|
| 261 |
+
|
| 262 |
+
location_type location;])[
|
| 263 |
+
};
|
| 264 |
+
|
| 265 |
+
/// Token kinds.
|
| 266 |
+
struct token
|
| 267 |
+
{
|
| 268 |
+
]b4_token_enums[]b4_glr2_cc_if([], [[
|
| 269 |
+
/// Backward compatibility alias (Bison 3.6).
|
| 270 |
+
typedef token_kind_type yytokentype;]])[
|
| 271 |
+
};
|
| 272 |
+
|
| 273 |
+
/// Token kind, as returned by yylex.
|
| 274 |
+
typedef token::token_kind_type token_kind_type;]b4_glr2_cc_if([], [[
|
| 275 |
+
|
| 276 |
+
/// Backward compatibility alias (Bison 3.6).
|
| 277 |
+
typedef token_kind_type token_type;]])[
|
| 278 |
+
|
| 279 |
+
/// Symbol kinds.
|
| 280 |
+
struct symbol_kind
|
| 281 |
+
{
|
| 282 |
+
]b4_declare_symbol_enum[
|
| 283 |
+
};
|
| 284 |
+
|
| 285 |
+
/// (Internal) symbol kind.
|
| 286 |
+
typedef symbol_kind::symbol_kind_type symbol_kind_type;
|
| 287 |
+
|
| 288 |
+
/// The number of tokens.
|
| 289 |
+
static const symbol_kind_type YYNTOKENS = symbol_kind::YYNTOKENS;
|
| 290 |
+
]])
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
# b4_symbol_type_define
|
| 294 |
+
# ---------------------
|
| 295 |
+
# Define symbol_type, the external type for symbols used for symbol
|
| 296 |
+
# constructors.
|
| 297 |
+
m4_define([b4_symbol_type_define],
|
| 298 |
+
[[ /// A complete symbol.
|
| 299 |
+
///
|
| 300 |
+
/// Expects its Base type to provide access to the symbol kind
|
| 301 |
+
/// via kind ().
|
| 302 |
+
///
|
| 303 |
+
/// Provide access to semantic value]b4_locations_if([ and location])[.
|
| 304 |
+
template <typename Base>
|
| 305 |
+
struct basic_symbol : Base
|
| 306 |
+
{
|
| 307 |
+
/// Alias to Base.
|
| 308 |
+
typedef Base super_type;
|
| 309 |
+
|
| 310 |
+
/// Default constructor.
|
| 311 |
+
basic_symbol () YY_NOEXCEPT
|
| 312 |
+
: value ()]b4_locations_if([
|
| 313 |
+
, location ()])[
|
| 314 |
+
{}
|
| 315 |
+
|
| 316 |
+
#if 201103L <= YY_CPLUSPLUS
|
| 317 |
+
/// Move constructor.
|
| 318 |
+
basic_symbol (basic_symbol&& that)
|
| 319 |
+
: Base (std::move (that))
|
| 320 |
+
, value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([
|
| 321 |
+
, location (std::move (that.location))])[
|
| 322 |
+
{]b4_variant_if([
|
| 323 |
+
b4_symbol_variant([this->kind ()], [value], [move],
|
| 324 |
+
[std::move (that.value)])
|
| 325 |
+
])[}
|
| 326 |
+
#endif
|
| 327 |
+
|
| 328 |
+
/// Copy constructor.
|
| 329 |
+
basic_symbol (const basic_symbol& that);]b4_variant_if([[
|
| 330 |
+
|
| 331 |
+
/// Constructors for typed symbols.
|
| 332 |
+
]b4_type_foreach([b4_basic_symbol_constructor_define], [
|
| 333 |
+
])], [[
|
| 334 |
+
/// Constructor for valueless symbols.
|
| 335 |
+
basic_symbol (typename Base::kind_type t]b4_locations_if([,
|
| 336 |
+
YY_MOVE_REF (location_type) l])[);
|
| 337 |
+
|
| 338 |
+
/// Constructor for symbols with semantic value.
|
| 339 |
+
basic_symbol (typename Base::kind_type t,
|
| 340 |
+
YY_RVREF (value_type) v]b4_locations_if([,
|
| 341 |
+
YY_RVREF (location_type) l])[);
|
| 342 |
+
]])[
|
| 343 |
+
/// Destroy the symbol.
|
| 344 |
+
~basic_symbol ()
|
| 345 |
+
{
|
| 346 |
+
clear ();
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
]b4_glr2_cc_if([[
|
| 350 |
+
/// Copy assignment.
|
| 351 |
+
basic_symbol& operator= (const basic_symbol& that)
|
| 352 |
+
{
|
| 353 |
+
Base::operator= (that);]b4_variant_if([[
|
| 354 |
+
]b4_symbol_variant([this->kind ()], [value], [copy],
|
| 355 |
+
[that.value])], [[
|
| 356 |
+
value = that.value]])[;]b4_locations_if([[
|
| 357 |
+
location = that.location;]])[
|
| 358 |
+
return *this;
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
/// Move assignment.
|
| 362 |
+
basic_symbol& operator= (basic_symbol&& that)
|
| 363 |
+
{
|
| 364 |
+
Base::operator= (std::move (that));]b4_variant_if([[
|
| 365 |
+
]b4_symbol_variant([this->kind ()], [value], [move],
|
| 366 |
+
[std::move (that.value)])], [[
|
| 367 |
+
value = std::move (that.value)]])[;]b4_locations_if([[
|
| 368 |
+
location = std::move (that.location);]])[
|
| 369 |
+
return *this;
|
| 370 |
+
}
|
| 371 |
+
]])[
|
| 372 |
+
|
| 373 |
+
/// Destroy contents, and record that is empty.
|
| 374 |
+
void clear () YY_NOEXCEPT
|
| 375 |
+
{]b4_variant_if([[
|
| 376 |
+
// User destructor.
|
| 377 |
+
symbol_kind_type yykind = this->kind ();
|
| 378 |
+
basic_symbol<Base>& yysym = *this;
|
| 379 |
+
(void) yysym;
|
| 380 |
+
switch (yykind)
|
| 381 |
+
{
|
| 382 |
+
]b4_symbol_foreach([b4_symbol_destructor])dnl
|
| 383 |
+
[ default:
|
| 384 |
+
break;
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
// Value type destructor.
|
| 388 |
+
]b4_symbol_variant([[yykind]], [[value]], [[template destroy]])])[
|
| 389 |
+
Base::clear ();
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
]b4_parse_error_bmatch(
|
| 393 |
+
[custom\|detailed],
|
| 394 |
+
[[ /// The user-facing name of this symbol.
|
| 395 |
+
const char *name () const YY_NOEXCEPT
|
| 396 |
+
{
|
| 397 |
+
return ]b4_parser_class[::symbol_name (this->kind ());
|
| 398 |
+
}]],
|
| 399 |
+
[simple],
|
| 400 |
+
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
| 401 |
+
/// The user-facing name of this symbol.
|
| 402 |
+
const char *name () const YY_NOEXCEPT
|
| 403 |
+
{
|
| 404 |
+
return ]b4_parser_class[::symbol_name (this->kind ());
|
| 405 |
+
}
|
| 406 |
+
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
| 407 |
+
]],
|
| 408 |
+
[verbose],
|
| 409 |
+
[[ /// The user-facing name of this symbol.
|
| 410 |
+
std::string name () const YY_NOEXCEPT
|
| 411 |
+
{
|
| 412 |
+
return ]b4_parser_class[::symbol_name (this->kind ());
|
| 413 |
+
}]])[]b4_glr2_cc_if([], [[
|
| 414 |
+
|
| 415 |
+
/// Backward compatibility (Bison 3.6).
|
| 416 |
+
symbol_kind_type type_get () const YY_NOEXCEPT;]])[
|
| 417 |
+
|
| 418 |
+
/// Whether empty.
|
| 419 |
+
bool empty () const YY_NOEXCEPT;
|
| 420 |
+
|
| 421 |
+
/// Destructive move, \a s is emptied into this.
|
| 422 |
+
void move (basic_symbol& s);
|
| 423 |
+
|
| 424 |
+
/// The semantic value.
|
| 425 |
+
value_type value;]b4_locations_if([
|
| 426 |
+
|
| 427 |
+
/// The location.
|
| 428 |
+
location_type location;])[
|
| 429 |
+
|
| 430 |
+
private:
|
| 431 |
+
#if YY_CPLUSPLUS < 201103L
|
| 432 |
+
/// Assignment operator.
|
| 433 |
+
basic_symbol& operator= (const basic_symbol& that);
|
| 434 |
+
#endif
|
| 435 |
+
};
|
| 436 |
+
|
| 437 |
+
/// Type access provider for token (enum) based symbols.
|
| 438 |
+
struct by_kind
|
| 439 |
+
{
|
| 440 |
+
/// The symbol kind as needed by the constructor.
|
| 441 |
+
typedef token_kind_type kind_type;
|
| 442 |
+
|
| 443 |
+
/// Default constructor.
|
| 444 |
+
by_kind () YY_NOEXCEPT;
|
| 445 |
+
|
| 446 |
+
#if 201103L <= YY_CPLUSPLUS
|
| 447 |
+
/// Move constructor.
|
| 448 |
+
by_kind (by_kind&& that) YY_NOEXCEPT;
|
| 449 |
+
#endif
|
| 450 |
+
|
| 451 |
+
/// Copy constructor.
|
| 452 |
+
by_kind (const by_kind& that) YY_NOEXCEPT;
|
| 453 |
+
|
| 454 |
+
/// Constructor from (external) token numbers.
|
| 455 |
+
by_kind (kind_type t) YY_NOEXCEPT;
|
| 456 |
+
|
| 457 |
+
]b4_glr2_cc_if([[
|
| 458 |
+
/// Copy assignment.
|
| 459 |
+
by_kind& operator= (const by_kind& that);
|
| 460 |
+
|
| 461 |
+
/// Move assignment.
|
| 462 |
+
by_kind& operator= (by_kind&& that);
|
| 463 |
+
]])[
|
| 464 |
+
|
| 465 |
+
/// Record that this symbol is empty.
|
| 466 |
+
void clear () YY_NOEXCEPT;
|
| 467 |
+
|
| 468 |
+
/// Steal the symbol kind from \a that.
|
| 469 |
+
void move (by_kind& that);
|
| 470 |
+
|
| 471 |
+
/// The (internal) type number (corresponding to \a type).
|
| 472 |
+
/// \a empty when empty.
|
| 473 |
+
symbol_kind_type kind () const YY_NOEXCEPT;]b4_glr2_cc_if([], [[
|
| 474 |
+
|
| 475 |
+
/// Backward compatibility (Bison 3.6).
|
| 476 |
+
symbol_kind_type type_get () const YY_NOEXCEPT;]])[
|
| 477 |
+
|
| 478 |
+
/// The symbol kind.
|
| 479 |
+
/// \a ]b4_symbol_prefix[YYEMPTY when empty.
|
| 480 |
+
symbol_kind_type kind_;
|
| 481 |
+
};]b4_glr2_cc_if([], [[
|
| 482 |
+
|
| 483 |
+
/// Backward compatibility for a private implementation detail (Bison 3.6).
|
| 484 |
+
typedef by_kind by_type;]])[
|
| 485 |
+
|
| 486 |
+
/// "External" symbols: returned by the scanner.
|
| 487 |
+
struct symbol_type : basic_symbol<by_kind>
|
| 488 |
+
{]b4_variant_if([[
|
| 489 |
+
/// Superclass.
|
| 490 |
+
typedef basic_symbol<by_kind> super_type;
|
| 491 |
+
|
| 492 |
+
/// Empty symbol.
|
| 493 |
+
symbol_type () YY_NOEXCEPT {}
|
| 494 |
+
|
| 495 |
+
/// Constructor for valueless symbols, and symbols from each type.
|
| 496 |
+
]b4_type_foreach([_b4_symbol_constructor_define])dnl
|
| 497 |
+
])[};
|
| 498 |
+
]])
|
| 499 |
+
|
| 500 |
+
|
| 501 |
+
# b4_public_types_define(hh|cc)
|
| 502 |
+
# -----------------------------
|
| 503 |
+
# Provide the implementation needed by the public types.
|
| 504 |
+
m4_define([b4_public_types_define],
|
| 505 |
+
[[ // basic_symbol.
|
| 506 |
+
template <typename Base>
|
| 507 |
+
]b4_parser_class[::basic_symbol<Base>::basic_symbol (const basic_symbol& that)
|
| 508 |
+
: Base (that)
|
| 509 |
+
, value (]b4_variant_if([], [that.value]))b4_locations_if([
|
| 510 |
+
, location (that.location)])[
|
| 511 |
+
{]b4_variant_if([
|
| 512 |
+
b4_symbol_variant([this->kind ()], [value], [copy],
|
| 513 |
+
[YY_MOVE (that.value)])
|
| 514 |
+
])[}
|
| 515 |
+
|
| 516 |
+
]b4_variant_if([], [[
|
| 517 |
+
/// Constructor for valueless symbols.
|
| 518 |
+
template <typename Base>
|
| 519 |
+
]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join(
|
| 520 |
+
[typename Base::kind_type t],
|
| 521 |
+
b4_locations_if([YY_MOVE_REF (location_type) l]))[)
|
| 522 |
+
: Base (t)
|
| 523 |
+
, value ()]b4_locations_if([
|
| 524 |
+
, location (l)])[
|
| 525 |
+
{}
|
| 526 |
+
|
| 527 |
+
template <typename Base>
|
| 528 |
+
]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join(
|
| 529 |
+
[typename Base::kind_type t],
|
| 530 |
+
[YY_RVREF (value_type) v],
|
| 531 |
+
b4_locations_if([YY_RVREF (location_type) l]))[)
|
| 532 |
+
: Base (t)
|
| 533 |
+
, value (]b4_variant_if([], [YY_MOVE (v)])[)]b4_locations_if([
|
| 534 |
+
, location (YY_MOVE (l))])[
|
| 535 |
+
{]b4_variant_if([[
|
| 536 |
+
(void) v;
|
| 537 |
+
]b4_symbol_variant([this->kind ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
| 538 |
+
|
| 539 |
+
]b4_glr2_cc_if([], [[
|
| 540 |
+
template <typename Base>
|
| 541 |
+
]b4_parser_class[::symbol_kind_type
|
| 542 |
+
]b4_parser_class[::basic_symbol<Base>::type_get () const YY_NOEXCEPT
|
| 543 |
+
{
|
| 544 |
+
return this->kind ();
|
| 545 |
+
}
|
| 546 |
+
]])[
|
| 547 |
+
|
| 548 |
+
template <typename Base>
|
| 549 |
+
bool
|
| 550 |
+
]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT
|
| 551 |
+
{
|
| 552 |
+
return this->kind () == ]b4_symbol(empty, kind)[;
|
| 553 |
+
}
|
| 554 |
+
|
| 555 |
+
template <typename Base>
|
| 556 |
+
void
|
| 557 |
+
]b4_parser_class[::basic_symbol<Base>::move (basic_symbol& s)
|
| 558 |
+
{
|
| 559 |
+
super_type::move (s);
|
| 560 |
+
]b4_variant_if([b4_symbol_variant([this->kind ()], [value], [move],
|
| 561 |
+
[YY_MOVE (s.value)])],
|
| 562 |
+
[value = YY_MOVE (s.value);])[]b4_locations_if([
|
| 563 |
+
location = YY_MOVE (s.location);])[
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
// by_kind.
|
| 567 |
+
]b4_inline([$1])b4_parser_class[::by_kind::by_kind () YY_NOEXCEPT
|
| 568 |
+
: kind_ (]b4_symbol(empty, kind)[)
|
| 569 |
+
{}
|
| 570 |
+
|
| 571 |
+
#if 201103L <= YY_CPLUSPLUS
|
| 572 |
+
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT
|
| 573 |
+
: kind_ (that.kind_)
|
| 574 |
+
{
|
| 575 |
+
that.clear ();
|
| 576 |
+
}
|
| 577 |
+
#endif
|
| 578 |
+
|
| 579 |
+
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT
|
| 580 |
+
: kind_ (that.kind_)
|
| 581 |
+
{}
|
| 582 |
+
|
| 583 |
+
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT
|
| 584 |
+
: kind_ (yytranslate_ (t))
|
| 585 |
+
{}
|
| 586 |
+
|
| 587 |
+
]b4_glr2_cc_if([[
|
| 588 |
+
]b4_inline([$1])]b4_parser_class[::by_kind&
|
| 589 |
+
b4_parser_class[::by_kind::by_kind::operator= (const by_kind& that)
|
| 590 |
+
{
|
| 591 |
+
kind_ = that.kind_;
|
| 592 |
+
return *this;
|
| 593 |
+
}
|
| 594 |
+
|
| 595 |
+
]b4_inline([$1])]b4_parser_class[::by_kind&
|
| 596 |
+
b4_parser_class[::by_kind::by_kind::operator= (by_kind&& that)
|
| 597 |
+
{
|
| 598 |
+
kind_ = that.kind_;
|
| 599 |
+
that.clear ();
|
| 600 |
+
return *this;
|
| 601 |
+
}
|
| 602 |
+
]])[
|
| 603 |
+
|
| 604 |
+
]b4_inline([$1])[void
|
| 605 |
+
]b4_parser_class[::by_kind::clear () YY_NOEXCEPT
|
| 606 |
+
{
|
| 607 |
+
kind_ = ]b4_symbol(empty, kind)[;
|
| 608 |
+
}
|
| 609 |
+
|
| 610 |
+
]b4_inline([$1])[void
|
| 611 |
+
]b4_parser_class[::by_kind::move (by_kind& that)
|
| 612 |
+
{
|
| 613 |
+
kind_ = that.kind_;
|
| 614 |
+
that.clear ();
|
| 615 |
+
}
|
| 616 |
+
|
| 617 |
+
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
| 618 |
+
]b4_parser_class[::by_kind::kind () const YY_NOEXCEPT
|
| 619 |
+
{
|
| 620 |
+
return kind_;
|
| 621 |
+
}
|
| 622 |
+
|
| 623 |
+
]b4_glr2_cc_if([], [[
|
| 624 |
+
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
| 625 |
+
]b4_parser_class[::by_kind::type_get () const YY_NOEXCEPT
|
| 626 |
+
{
|
| 627 |
+
return this->kind ();
|
| 628 |
+
}
|
| 629 |
+
]])[
|
| 630 |
+
]])
|
| 631 |
+
|
| 632 |
+
|
| 633 |
+
# b4_token_constructor_define
|
| 634 |
+
# ----------------------------
|
| 635 |
+
# Define make_FOO for all the token kinds.
|
| 636 |
+
# Use at class-level. Redefined in variant.hh.
|
| 637 |
+
m4_define([b4_token_constructor_define], [])
|
| 638 |
+
|
| 639 |
+
|
| 640 |
+
# b4_yytranslate_define(cc|hh)
|
| 641 |
+
# ----------------------------
|
| 642 |
+
# Define yytranslate_. Sometimes used in the header file ($1=hh),
|
| 643 |
+
# sometimes in the cc file.
|
| 644 |
+
m4_define([b4_yytranslate_define],
|
| 645 |
+
[ b4_inline([$1])b4_parser_class[::symbol_kind_type
|
| 646 |
+
]b4_parser_class[::yytranslate_ (int t) YY_NOEXCEPT
|
| 647 |
+
{
|
| 648 |
+
]b4_api_token_raw_if(
|
| 649 |
+
[[ return static_cast<symbol_kind_type> (t);]],
|
| 650 |
+
[[ // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to
|
| 651 |
+
// TOKEN-NUM as returned by yylex.
|
| 652 |
+
static
|
| 653 |
+
const ]b4_int_type_for([b4_translate])[
|
| 654 |
+
translate_table[] =
|
| 655 |
+
{
|
| 656 |
+
]b4_translate[
|
| 657 |
+
};
|
| 658 |
+
// Last valid token kind.
|
| 659 |
+
const int code_max = ]b4_code_max[;
|
| 660 |
+
|
| 661 |
+
if (t <= 0)
|
| 662 |
+
return symbol_kind::]b4_symbol_prefix[YYEOF;
|
| 663 |
+
else if (t <= code_max)
|
| 664 |
+
return static_cast <symbol_kind_type> (translate_table[t]);
|
| 665 |
+
else
|
| 666 |
+
return symbol_kind::]b4_symbol_prefix[YYUNDEF;]])[
|
| 667 |
+
}
|
| 668 |
+
]])
|
| 669 |
+
|
| 670 |
+
|
| 671 |
+
# b4_lhs_value([TYPE])
|
| 672 |
+
# --------------------
|
| 673 |
+
m4_define([b4_lhs_value],
|
| 674 |
+
[b4_symbol_value([yyval], [$1])])
|
| 675 |
+
|
| 676 |
+
|
| 677 |
+
# b4_rhs_value(RULE-LENGTH, POS, [TYPE])
|
| 678 |
+
# --------------------------------------
|
| 679 |
+
# FIXME: Dead code.
|
| 680 |
+
m4_define([b4_rhs_value],
|
| 681 |
+
[b4_symbol_value([yysemantic_stack_@{($1) - ($2)@}], [$3])])
|
| 682 |
+
|
| 683 |
+
|
| 684 |
+
# b4_lhs_location()
|
| 685 |
+
# -----------------
|
| 686 |
+
# Expansion of @$.
|
| 687 |
+
m4_define([b4_lhs_location],
|
| 688 |
+
[(yyloc)])
|
| 689 |
+
|
| 690 |
+
|
| 691 |
+
# b4_rhs_location(RULE-LENGTH, POS)
|
| 692 |
+
# ---------------------------------
|
| 693 |
+
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
| 694 |
+
# on RHS.
|
| 695 |
+
m4_define([b4_rhs_location],
|
| 696 |
+
[(yylocation_stack_@{($1) - ($2)@})])
|
| 697 |
+
|
| 698 |
+
|
| 699 |
+
# b4_parse_param_decl
|
| 700 |
+
# -------------------
|
| 701 |
+
# Extra formal arguments of the constructor.
|
| 702 |
+
# Change the parameter names from "foo" into "foo_yyarg", so that
|
| 703 |
+
# there is no collision bw the user chosen attribute name, and the
|
| 704 |
+
# argument name in the constructor.
|
| 705 |
+
m4_define([b4_parse_param_decl],
|
| 706 |
+
[m4_ifset([b4_parse_param],
|
| 707 |
+
[m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
|
| 708 |
+
|
| 709 |
+
m4_define([b4_parse_param_decl_1],
|
| 710 |
+
[$1_yyarg])
|
| 711 |
+
|
| 712 |
+
|
| 713 |
+
|
| 714 |
+
# b4_parse_param_cons
|
| 715 |
+
# -------------------
|
| 716 |
+
# Extra initialisations of the constructor.
|
| 717 |
+
m4_define([b4_parse_param_cons],
|
| 718 |
+
[m4_ifset([b4_parse_param],
|
| 719 |
+
[
|
| 720 |
+
b4_cc_constructor_calls(b4_parse_param)])])
|
| 721 |
+
m4_define([b4_cc_constructor_calls],
|
| 722 |
+
[m4_map_sep([b4_cc_constructor_call], [,
|
| 723 |
+
], [$@])])
|
| 724 |
+
m4_define([b4_cc_constructor_call],
|
| 725 |
+
[$2 ($2_yyarg)])
|
| 726 |
+
|
| 727 |
+
# b4_parse_param_vars
|
| 728 |
+
# -------------------
|
| 729 |
+
# Extra instance variables.
|
| 730 |
+
m4_define([b4_parse_param_vars],
|
| 731 |
+
[m4_ifset([b4_parse_param],
|
| 732 |
+
[
|
| 733 |
+
// User arguments.
|
| 734 |
+
b4_cc_var_decls(b4_parse_param)])])
|
| 735 |
+
m4_define([b4_cc_var_decls],
|
| 736 |
+
[m4_map_sep([b4_cc_var_decl], [
|
| 737 |
+
], [$@])])
|
| 738 |
+
m4_define([b4_cc_var_decl],
|
| 739 |
+
[ $1;])
|
| 740 |
+
|
| 741 |
+
|
| 742 |
+
## ---------##
|
| 743 |
+
## Values. ##
|
| 744 |
+
## ---------##
|
| 745 |
+
|
| 746 |
+
# b4_yylloc_default_define
|
| 747 |
+
# ------------------------
|
| 748 |
+
# Define YYLLOC_DEFAULT.
|
| 749 |
+
m4_define([b4_yylloc_default_define],
|
| 750 |
+
[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
| 751 |
+
If N is 0, then set CURRENT to the empty location which ends
|
| 752 |
+
the previous symbol: RHS[0] (always defined). */
|
| 753 |
+
|
| 754 |
+
# ifndef YYLLOC_DEFAULT
|
| 755 |
+
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
| 756 |
+
do \
|
| 757 |
+
if (N) \
|
| 758 |
+
{ \
|
| 759 |
+
(Current).begin = YYRHSLOC (Rhs, 1).begin; \
|
| 760 |
+
(Current).end = YYRHSLOC (Rhs, N).end; \
|
| 761 |
+
} \
|
| 762 |
+
else \
|
| 763 |
+
{ \
|
| 764 |
+
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
| 765 |
+
} \
|
| 766 |
+
while (false)
|
| 767 |
+
# endif
|
| 768 |
+
]])
|
| 769 |
+
|
| 770 |
+
## -------- ##
|
| 771 |
+
## Checks. ##
|
| 772 |
+
## -------- ##
|
| 773 |
+
|
| 774 |
+
b4_token_ctor_if([b4_variant_if([],
|
| 775 |
+
[b4_fatal_at(b4_percent_define_get_loc(api.token.constructor),
|
| 776 |
+
[cannot use '%s' without '%s'],
|
| 777 |
+
[%define api.token.constructor],
|
| 778 |
+
[%define api.value.type variant]))])])
|
platform/dbops/binaries/build/share/bison/skeletons/c-like.m4
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-*- Autoconf -*-
|
| 2 |
+
|
| 3 |
+
# Common code for C-like languages (C, C++, Java, etc.)
|
| 4 |
+
|
| 5 |
+
# Copyright (C) 2012-2015, 2018-2021 Free Software Foundation, Inc.
|
| 6 |
+
|
| 7 |
+
# This program is free software: you can redistribute it and/or modify
|
| 8 |
+
# it under the terms of the GNU General Public License as published by
|
| 9 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 10 |
+
# (at your option) any later version.
|
| 11 |
+
#
|
| 12 |
+
# This program is distributed in the hope that it will be useful,
|
| 13 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
# GNU General Public License for more details.
|
| 16 |
+
#
|
| 17 |
+
# You should have received a copy of the GNU General Public License
|
| 18 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# _b4_comment(TEXT, OPEN, CONTINUE, END)
|
| 22 |
+
# --------------------------------------
|
| 23 |
+
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
|
| 24 |
+
# Avoid adding indentation to the first line, as the indentation comes
|
| 25 |
+
# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
|
| 26 |
+
# Turn "*/" in TEXT into "* /" so that we don't unexpectedly close
|
| 27 |
+
# the comments before its end.
|
| 28 |
+
#
|
| 29 |
+
# Prefix all the output lines with PREFIX.
|
| 30 |
+
m4_define([_b4_comment],
|
| 31 |
+
[$2[]b4_gsub(m4_expand([$1]),
|
| 32 |
+
[[*]/], [*\\/],
|
| 33 |
+
[/[*]], [/\\*],
|
| 34 |
+
[
|
| 35 |
+
\(.\)], [
|
| 36 |
+
$3\1])$4])
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
# b4_comment(TEXT, [PREFIX])
|
| 40 |
+
# --------------------------
|
| 41 |
+
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
| 42 |
+
m4_define([b4_comment],
|
| 43 |
+
[_b4_comment([$1], [$2/* ], [$2 ], [ */])])
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
# _b4_dollar_dollar(VALUE, SYMBOL-NUM, FIELD, DEFAULT-FIELD)
|
| 49 |
+
# ----------------------------------------------------------
|
| 50 |
+
# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
|
| 51 |
+
# otherwise just VALUE. Be sure to pass "(VALUE)" if VALUE is a
|
| 52 |
+
# pointer.
|
| 53 |
+
m4_define([_b4_dollar_dollar],
|
| 54 |
+
[b4_symbol_value([$1],
|
| 55 |
+
[$2],
|
| 56 |
+
m4_if([$3], [[]],
|
| 57 |
+
[[$4]], [[$3]]))])
|
| 58 |
+
|
| 59 |
+
# b4_dollar_pushdef(VALUE-POINTER, SYMBOL-NUM, [TYPE_TAG], LOCATION)
|
| 60 |
+
# b4_dollar_popdef
|
| 61 |
+
# ------------------------------------------------------------------
|
| 62 |
+
# Define b4_dollar_dollar for VALUE-POINTER and DEFAULT-FIELD,
|
| 63 |
+
# and b4_at_dollar for LOCATION.
|
| 64 |
+
m4_define([b4_dollar_pushdef],
|
| 65 |
+
[m4_pushdef([b4_dollar_dollar],
|
| 66 |
+
[_b4_dollar_dollar([$1], [$2], m4_dquote($][1), [$3])])dnl
|
| 67 |
+
m4_pushdef([b4_at_dollar], [$4])dnl
|
| 68 |
+
])
|
| 69 |
+
m4_define([b4_dollar_popdef],
|
| 70 |
+
[m4_popdef([b4_at_dollar])dnl
|
| 71 |
+
m4_popdef([b4_dollar_dollar])dnl
|
| 72 |
+
])
|
platform/dbops/binaries/build/share/bison/skeletons/c-skel.m4
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-*- Autoconf -*-
|
| 2 |
+
|
| 3 |
+
# C skeleton dispatching for Bison.
|
| 4 |
+
|
| 5 |
+
# Copyright (C) 2006-2007, 2009-2015, 2018-2021 Free Software
|
| 6 |
+
# Foundation, Inc.
|
| 7 |
+
|
| 8 |
+
# This program is free software: you can redistribute it and/or modify
|
| 9 |
+
# it under the terms of the GNU General Public License as published by
|
| 10 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 11 |
+
# (at your option) any later version.
|
| 12 |
+
#
|
| 13 |
+
# This program is distributed in the hope that it will be useful,
|
| 14 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 16 |
+
# GNU General Public License for more details.
|
| 17 |
+
#
|
| 18 |
+
# You should have received a copy of the GNU General Public License
|
| 19 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 20 |
+
|
| 21 |
+
b4_glr_if( [m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.c]])])
|
| 22 |
+
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.c]])])
|
| 23 |
+
|
| 24 |
+
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[yacc.c]])
|
| 25 |
+
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
| 26 |
+
|
| 27 |
+
m4_include(b4_used_skeleton)
|
platform/dbops/binaries/build/share/bison/skeletons/c.m4
ADDED
|
@@ -0,0 +1,1125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-*- Autoconf -*-
|
| 2 |
+
|
| 3 |
+
# C M4 Macros for Bison.
|
| 4 |
+
|
| 5 |
+
# Copyright (C) 2002, 2004-2015, 2018-2021 Free Software Foundation,
|
| 6 |
+
# Inc.
|
| 7 |
+
|
| 8 |
+
# This program is free software: you can redistribute it and/or modify
|
| 9 |
+
# it under the terms of the GNU General Public License as published by
|
| 10 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 11 |
+
# (at your option) any later version.
|
| 12 |
+
#
|
| 13 |
+
# This program is distributed in the hope that it will be useful,
|
| 14 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 16 |
+
# GNU General Public License for more details.
|
| 17 |
+
#
|
| 18 |
+
# You should have received a copy of the GNU General Public License
|
| 19 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 20 |
+
|
| 21 |
+
m4_include(b4_skeletonsdir/[c-like.m4])
|
| 22 |
+
|
| 23 |
+
# b4_tocpp(STRING)
|
| 24 |
+
# ----------------
|
| 25 |
+
# Convert STRING into a valid C macro name.
|
| 26 |
+
m4_define([b4_tocpp],
|
| 27 |
+
[m4_toupper(m4_bpatsubst(m4_quote($1), [[^a-zA-Z0-9]+], [_]))])
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
# b4_cpp_guard(FILE)
|
| 31 |
+
# ------------------
|
| 32 |
+
# A valid C macro name to use as a CPP header guard for FILE.
|
| 33 |
+
m4_define([b4_cpp_guard],
|
| 34 |
+
[[YY_]b4_tocpp(m4_defn([b4_prefix])/[$1])[_INCLUDED]])
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
# b4_cpp_guard_open(FILE)
|
| 38 |
+
# b4_cpp_guard_close(FILE)
|
| 39 |
+
# ------------------------
|
| 40 |
+
# If FILE does not expand to nothing, open/close CPP inclusion guards for FILE.
|
| 41 |
+
m4_define([b4_cpp_guard_open],
|
| 42 |
+
[m4_ifval(m4_quote($1),
|
| 43 |
+
[#ifndef b4_cpp_guard([$1])
|
| 44 |
+
# define b4_cpp_guard([$1])])])
|
| 45 |
+
|
| 46 |
+
m4_define([b4_cpp_guard_close],
|
| 47 |
+
[m4_ifval(m4_quote($1),
|
| 48 |
+
[#endif b4_comment([!b4_cpp_guard([$1])])])])
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
## ---------------- ##
|
| 52 |
+
## Identification. ##
|
| 53 |
+
## ---------------- ##
|
| 54 |
+
|
| 55 |
+
# b4_identification
|
| 56 |
+
# -----------------
|
| 57 |
+
# Depends on individual skeletons to define b4_pure_flag, b4_push_flag, or
|
| 58 |
+
# b4_pull_flag if they use the values of the %define variables api.pure or
|
| 59 |
+
# api.push-pull.
|
| 60 |
+
m4_define([b4_identification],
|
| 61 |
+
[[/* Identify Bison output, and Bison version. */
|
| 62 |
+
#define YYBISON ]b4_version[
|
| 63 |
+
|
| 64 |
+
/* Bison version string. */
|
| 65 |
+
#define YYBISON_VERSION "]b4_version_string["
|
| 66 |
+
|
| 67 |
+
/* Skeleton name. */
|
| 68 |
+
#define YYSKELETON_NAME ]b4_skeleton[]m4_ifdef([b4_pure_flag], [[
|
| 69 |
+
|
| 70 |
+
/* Pure parsers. */
|
| 71 |
+
#define YYPURE ]b4_pure_flag])[]m4_ifdef([b4_push_flag], [[
|
| 72 |
+
|
| 73 |
+
/* Push parsers. */
|
| 74 |
+
#define YYPUSH ]b4_push_flag])[]m4_ifdef([b4_pull_flag], [[
|
| 75 |
+
|
| 76 |
+
/* Pull parsers. */
|
| 77 |
+
#define YYPULL ]b4_pull_flag])[
|
| 78 |
+
]])
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
## ---------------- ##
|
| 82 |
+
## Default values. ##
|
| 83 |
+
## ---------------- ##
|
| 84 |
+
|
| 85 |
+
# b4_api_prefix, b4_api_PREFIX
|
| 86 |
+
# ----------------------------
|
| 87 |
+
# Corresponds to %define api.prefix
|
| 88 |
+
b4_percent_define_default([[api.prefix]], [[yy]])
|
| 89 |
+
m4_define([b4_api_prefix],
|
| 90 |
+
[b4_percent_define_get([[api.prefix]])])
|
| 91 |
+
m4_define([b4_api_PREFIX],
|
| 92 |
+
[m4_toupper(b4_api_prefix)])
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
# b4_prefix
|
| 96 |
+
# ---------
|
| 97 |
+
# If the %name-prefix is not given, it is api.prefix.
|
| 98 |
+
m4_define_default([b4_prefix], [b4_api_prefix])
|
| 99 |
+
|
| 100 |
+
# If the %union is not named, its name is YYSTYPE.
|
| 101 |
+
b4_percent_define_default([[api.value.union.name]],
|
| 102 |
+
[b4_api_PREFIX[][STYPE]])
|
| 103 |
+
|
| 104 |
+
b4_percent_define_default([[api.symbol.prefix]], [[YYSYMBOL_]])
|
| 105 |
+
|
| 106 |
+
## ------------------------ ##
|
| 107 |
+
## Pure/impure interfaces. ##
|
| 108 |
+
## ------------------------ ##
|
| 109 |
+
|
| 110 |
+
# b4_yylex_formals
|
| 111 |
+
# ----------------
|
| 112 |
+
# All the yylex formal arguments.
|
| 113 |
+
# b4_lex_param arrives quoted twice, but we want to keep only one level.
|
| 114 |
+
m4_define([b4_yylex_formals],
|
| 115 |
+
[b4_pure_if([[[b4_api_PREFIX[STYPE *yylvalp]], [[&yylval]]][]dnl
|
| 116 |
+
b4_locations_if([, [b4_api_PREFIX[LTYPE *yyllocp], [&yylloc]]])])dnl
|
| 117 |
+
m4_ifdef([b4_lex_param], [, ]b4_lex_param)])
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
# b4_yylex
|
| 121 |
+
# --------
|
| 122 |
+
# Call yylex.
|
| 123 |
+
m4_define([b4_yylex],
|
| 124 |
+
[b4_function_call([yylex], [int], b4_yylex_formals)])
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
# b4_user_args
|
| 128 |
+
# ------------
|
| 129 |
+
m4_define([b4_user_args],
|
| 130 |
+
[m4_ifset([b4_parse_param], [, b4_user_args_no_comma])])
|
| 131 |
+
|
| 132 |
+
# b4_user_args_no_comma
|
| 133 |
+
# ---------------------
|
| 134 |
+
m4_define([b4_user_args_no_comma],
|
| 135 |
+
[m4_ifset([b4_parse_param], [b4_args(b4_parse_param)])])
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
# b4_user_formals
|
| 139 |
+
# ---------------
|
| 140 |
+
# The possible parse-params formal arguments preceded by a comma.
|
| 141 |
+
m4_define([b4_user_formals],
|
| 142 |
+
[m4_ifset([b4_parse_param], [, b4_formals(b4_parse_param)])])
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
# b4_parse_param
|
| 146 |
+
# --------------
|
| 147 |
+
# If defined, b4_parse_param arrives double quoted, but below we prefer
|
| 148 |
+
# it to be single quoted.
|
| 149 |
+
m4_define([b4_parse_param],
|
| 150 |
+
b4_parse_param)
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
# b4_parse_param_for(DECL, FORMAL, BODY)
|
| 154 |
+
# ---------------------------------------
|
| 155 |
+
# Iterate over the user parameters, binding the declaration to DECL,
|
| 156 |
+
# the formal name to FORMAL, and evaluating the BODY.
|
| 157 |
+
m4_define([b4_parse_param_for],
|
| 158 |
+
[m4_foreach([$1_$2], m4_defn([b4_parse_param]),
|
| 159 |
+
[m4_pushdef([$1], m4_unquote(m4_car($1_$2)))dnl
|
| 160 |
+
m4_pushdef([$2], m4_shift($1_$2))dnl
|
| 161 |
+
$3[]dnl
|
| 162 |
+
m4_popdef([$2])dnl
|
| 163 |
+
m4_popdef([$1])dnl
|
| 164 |
+
])])
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
# b4_use(EXPR)
|
| 168 |
+
# ------------
|
| 169 |
+
# Pacify the compiler about some maybe unused value.
|
| 170 |
+
m4_define([b4_use],
|
| 171 |
+
[YY_USE ($1)])
|
| 172 |
+
|
| 173 |
+
# b4_parse_param_use([VAL], [LOC])
|
| 174 |
+
# --------------------------------
|
| 175 |
+
# 'YY_USE' VAL, LOC if locations are enabled, and all the parse-params.
|
| 176 |
+
m4_define([b4_parse_param_use],
|
| 177 |
+
[m4_ifvaln([$1], [ b4_use([$1]);])dnl
|
| 178 |
+
b4_locations_if([m4_ifvaln([$2], [ b4_use([$2]);])])dnl
|
| 179 |
+
b4_parse_param_for([Decl], [Formal], [ b4_use(Formal);
|
| 180 |
+
])dnl
|
| 181 |
+
])
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
## ------------ ##
|
| 185 |
+
## Data Types. ##
|
| 186 |
+
## ------------ ##
|
| 187 |
+
|
| 188 |
+
# b4_int_type(MIN, MAX)
|
| 189 |
+
# ---------------------
|
| 190 |
+
# Return a narrow int type able to handle integers ranging from MIN
|
| 191 |
+
# to MAX (included) in portable C code. Assume MIN and MAX fall in
|
| 192 |
+
# 'int' range.
|
| 193 |
+
m4_define([b4_int_type],
|
| 194 |
+
[m4_if(b4_ints_in($@, [-127], [127]), [1], [signed char],
|
| 195 |
+
b4_ints_in($@, [0], [255]), [1], [unsigned char],
|
| 196 |
+
|
| 197 |
+
b4_ints_in($@, [-32767], [32767]), [1], [short],
|
| 198 |
+
b4_ints_in($@, [0], [65535]), [1], [unsigned short],
|
| 199 |
+
|
| 200 |
+
[int])])
|
| 201 |
+
|
| 202 |
+
# b4_c99_int_type(MIN, MAX)
|
| 203 |
+
# -------------------------
|
| 204 |
+
# Like b4_int_type, but for C99.
|
| 205 |
+
# b4_c99_int_type_define replaces b4_int_type with this.
|
| 206 |
+
m4_define([b4_c99_int_type],
|
| 207 |
+
[m4_if(b4_ints_in($@, [-127], [127]), [1], [yytype_int8],
|
| 208 |
+
b4_ints_in($@, [0], [255]), [1], [yytype_uint8],
|
| 209 |
+
|
| 210 |
+
b4_ints_in($@, [-32767], [32767]), [1], [yytype_int16],
|
| 211 |
+
b4_ints_in($@, [0], [65535]), [1], [yytype_uint16],
|
| 212 |
+
|
| 213 |
+
[int])])
|
| 214 |
+
|
| 215 |
+
# b4_c99_int_type_define
|
| 216 |
+
# ----------------------
|
| 217 |
+
# Define private types suitable for holding small integers in C99 or later.
|
| 218 |
+
m4_define([b4_c99_int_type_define],
|
| 219 |
+
[m4_copy_force([b4_c99_int_type], [b4_int_type])dnl
|
| 220 |
+
[#ifdef short
|
| 221 |
+
# undef short
|
| 222 |
+
#endif
|
| 223 |
+
|
| 224 |
+
/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
|
| 225 |
+
<limits.h> and (if available) <stdint.h> are included
|
| 226 |
+
so that the code can choose integer types of a good width. */
|
| 227 |
+
|
| 228 |
+
#ifndef __PTRDIFF_MAX__
|
| 229 |
+
# include <limits.h> /* INFRINGES ON USER NAME SPACE */
|
| 230 |
+
# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
|
| 231 |
+
# include <stdint.h> /* INFRINGES ON USER NAME SPACE */
|
| 232 |
+
# define YY_STDINT_H
|
| 233 |
+
# endif
|
| 234 |
+
#endif
|
| 235 |
+
|
| 236 |
+
/* Narrow types that promote to a signed type and that can represent a
|
| 237 |
+
signed or unsigned integer of at least N bits. In tables they can
|
| 238 |
+
save space and decrease cache pressure. Promoting to a signed type
|
| 239 |
+
helps avoid bugs in integer arithmetic. */
|
| 240 |
+
|
| 241 |
+
#ifdef __INT_LEAST8_MAX__
|
| 242 |
+
typedef __INT_LEAST8_TYPE__ yytype_int8;
|
| 243 |
+
#elif defined YY_STDINT_H
|
| 244 |
+
typedef int_least8_t yytype_int8;
|
| 245 |
+
#else
|
| 246 |
+
typedef signed char yytype_int8;
|
| 247 |
+
#endif
|
| 248 |
+
|
| 249 |
+
#ifdef __INT_LEAST16_MAX__
|
| 250 |
+
typedef __INT_LEAST16_TYPE__ yytype_int16;
|
| 251 |
+
#elif defined YY_STDINT_H
|
| 252 |
+
typedef int_least16_t yytype_int16;
|
| 253 |
+
#else
|
| 254 |
+
typedef short yytype_int16;
|
| 255 |
+
#endif
|
| 256 |
+
|
| 257 |
+
/* Work around bug in HP-UX 11.23, which defines these macros
|
| 258 |
+
incorrectly for preprocessor constants. This workaround can likely
|
| 259 |
+
be removed in 2023, as HPE has promised support for HP-UX 11.23
|
| 260 |
+
(aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
|
| 261 |
+
<https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
|
| 262 |
+
#ifdef __hpux
|
| 263 |
+
# undef UINT_LEAST8_MAX
|
| 264 |
+
# undef UINT_LEAST16_MAX
|
| 265 |
+
# define UINT_LEAST8_MAX 255
|
| 266 |
+
# define UINT_LEAST16_MAX 65535
|
| 267 |
+
#endif
|
| 268 |
+
|
| 269 |
+
#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
|
| 270 |
+
typedef __UINT_LEAST8_TYPE__ yytype_uint8;
|
| 271 |
+
#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
|
| 272 |
+
&& UINT_LEAST8_MAX <= INT_MAX)
|
| 273 |
+
typedef uint_least8_t yytype_uint8;
|
| 274 |
+
#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
|
| 275 |
+
typedef unsigned char yytype_uint8;
|
| 276 |
+
#else
|
| 277 |
+
typedef short yytype_uint8;
|
| 278 |
+
#endif
|
| 279 |
+
|
| 280 |
+
#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
|
| 281 |
+
typedef __UINT_LEAST16_TYPE__ yytype_uint16;
|
| 282 |
+
#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
|
| 283 |
+
&& UINT_LEAST16_MAX <= INT_MAX)
|
| 284 |
+
typedef uint_least16_t yytype_uint16;
|
| 285 |
+
#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
|
| 286 |
+
typedef unsigned short yytype_uint16;
|
| 287 |
+
#else
|
| 288 |
+
typedef int yytype_uint16;
|
| 289 |
+
#endif]])
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
# b4_sizes_types_define
|
| 293 |
+
# ---------------------
|
| 294 |
+
# Define YYPTRDIFF_T/YYPTRDIFF_MAXIMUM, YYSIZE_T/YYSIZE_MAXIMUM,
|
| 295 |
+
# and YYSIZEOF.
|
| 296 |
+
m4_define([b4_sizes_types_define],
|
| 297 |
+
[[#ifndef YYPTRDIFF_T
|
| 298 |
+
# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
|
| 299 |
+
# define YYPTRDIFF_T __PTRDIFF_TYPE__
|
| 300 |
+
# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
|
| 301 |
+
# elif defined PTRDIFF_MAX
|
| 302 |
+
# ifndef ptrdiff_t
|
| 303 |
+
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
| 304 |
+
# endif
|
| 305 |
+
# define YYPTRDIFF_T ptrdiff_t
|
| 306 |
+
# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
|
| 307 |
+
# else
|
| 308 |
+
# define YYPTRDIFF_T long
|
| 309 |
+
# define YYPTRDIFF_MAXIMUM LONG_MAX
|
| 310 |
+
# endif
|
| 311 |
+
#endif
|
| 312 |
+
|
| 313 |
+
#ifndef YYSIZE_T
|
| 314 |
+
# ifdef __SIZE_TYPE__
|
| 315 |
+
# define YYSIZE_T __SIZE_TYPE__
|
| 316 |
+
# elif defined size_t
|
| 317 |
+
# define YYSIZE_T size_t
|
| 318 |
+
# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
|
| 319 |
+
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
| 320 |
+
# define YYSIZE_T size_t
|
| 321 |
+
# else
|
| 322 |
+
# define YYSIZE_T unsigned
|
| 323 |
+
# endif
|
| 324 |
+
#endif
|
| 325 |
+
|
| 326 |
+
#define YYSIZE_MAXIMUM \
|
| 327 |
+
YY_CAST (YYPTRDIFF_T, \
|
| 328 |
+
(YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
|
| 329 |
+
? YYPTRDIFF_MAXIMUM \
|
| 330 |
+
: YY_CAST (YYSIZE_T, -1)))
|
| 331 |
+
|
| 332 |
+
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
|
| 333 |
+
]])
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
# b4_int_type_for(NAME)
|
| 337 |
+
# ---------------------
|
| 338 |
+
# Return a narrow int type able to handle numbers ranging from
|
| 339 |
+
# 'NAME_min' to 'NAME_max' (included).
|
| 340 |
+
m4_define([b4_int_type_for],
|
| 341 |
+
[b4_int_type($1_min, $1_max)])
|
| 342 |
+
|
| 343 |
+
|
| 344 |
+
# b4_table_value_equals(TABLE, VALUE, LITERAL, SYMBOL)
|
| 345 |
+
# ----------------------------------------------------
|
| 346 |
+
# Without inducing a comparison warning from the compiler, check if the
|
| 347 |
+
# literal value LITERAL equals VALUE from table TABLE, which must have
|
| 348 |
+
# TABLE_min and TABLE_max defined. SYMBOL denotes
|
| 349 |
+
m4_define([b4_table_value_equals],
|
| 350 |
+
[m4_if(m4_eval($3 < m4_indir([b4_]$1[_min])
|
| 351 |
+
|| m4_indir([b4_]$1[_max]) < $3), [1],
|
| 352 |
+
[[0]],
|
| 353 |
+
[(($2) == $4)])])
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
## ----------------- ##
|
| 357 |
+
## Compiler issues. ##
|
| 358 |
+
## ----------------- ##
|
| 359 |
+
|
| 360 |
+
# b4_attribute_define([noreturn])
|
| 361 |
+
# -------------------------------
|
| 362 |
+
# Provide portable compiler "attributes". If "noreturn" is passed, define
|
| 363 |
+
# _Noreturn.
|
| 364 |
+
m4_define([b4_attribute_define],
|
| 365 |
+
[[#ifndef YY_ATTRIBUTE_PURE
|
| 366 |
+
# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
|
| 367 |
+
# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
|
| 368 |
+
# else
|
| 369 |
+
# define YY_ATTRIBUTE_PURE
|
| 370 |
+
# endif
|
| 371 |
+
#endif
|
| 372 |
+
|
| 373 |
+
#ifndef YY_ATTRIBUTE_UNUSED
|
| 374 |
+
# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
|
| 375 |
+
# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
| 376 |
+
# else
|
| 377 |
+
# define YY_ATTRIBUTE_UNUSED
|
| 378 |
+
# endif
|
| 379 |
+
#endif
|
| 380 |
+
|
| 381 |
+
]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */
|
| 382 |
+
]dnl This is close to lib/_Noreturn.h, except that we do enable
|
| 383 |
+
dnl the use of [[noreturn]], because _Noreturn is used in places
|
| 384 |
+
dnl where [[noreturn]] works in C++. We need this in particular
|
| 385 |
+
dnl because of glr.cc which compiles code from glr.c in C++.
|
| 386 |
+
dnl And the C++ compiler chokes on _Noreturn. Also, we do not
|
| 387 |
+
dnl use C' _Noreturn in C++, to avoid -Wc11-extensions warnings.
|
| 388 |
+
[#ifndef _Noreturn
|
| 389 |
+
# if (defined __cplusplus \
|
| 390 |
+
&& ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
|
| 391 |
+
|| (defined _MSC_VER && 1900 <= _MSC_VER)))
|
| 392 |
+
# define _Noreturn [[noreturn]]
|
| 393 |
+
# elif ((!defined __cplusplus || defined __clang__) \
|
| 394 |
+
&& (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
|
| 395 |
+
|| (!defined __STRICT_ANSI__ \
|
| 396 |
+
&& (4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
|
| 397 |
+
|| (defined __apple_build_version__ \
|
| 398 |
+
? 6000000 <= __apple_build_version__ \
|
| 399 |
+
: 3 < __clang_major__ + (5 <= __clang_minor__))))))
|
| 400 |
+
/* _Noreturn works as-is. */
|
| 401 |
+
# elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \
|
| 402 |
+
|| 0x5110 <= __SUNPRO_C)
|
| 403 |
+
# define _Noreturn __attribute__ ((__noreturn__))
|
| 404 |
+
# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
|
| 405 |
+
# define _Noreturn __declspec (noreturn)
|
| 406 |
+
# else
|
| 407 |
+
# define _Noreturn
|
| 408 |
+
# endif
|
| 409 |
+
#endif
|
| 410 |
+
|
| 411 |
+
]])[/* Suppress unused-variable warnings by "using" E. */
|
| 412 |
+
#if ! defined lint || defined __GNUC__
|
| 413 |
+
# define YY_USE(E) ((void) (E))
|
| 414 |
+
#else
|
| 415 |
+
# define YY_USE(E) /* empty */
|
| 416 |
+
#endif
|
| 417 |
+
|
| 418 |
+
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
|
| 419 |
+
#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
|
| 420 |
+
# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
|
| 421 |
+
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
| 422 |
+
_Pragma ("GCC diagnostic push") \
|
| 423 |
+
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
|
| 424 |
+
# else
|
| 425 |
+
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
| 426 |
+
_Pragma ("GCC diagnostic push") \
|
| 427 |
+
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
|
| 428 |
+
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
|
| 429 |
+
# endif
|
| 430 |
+
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
|
| 431 |
+
_Pragma ("GCC diagnostic pop")
|
| 432 |
+
#else
|
| 433 |
+
# define YY_INITIAL_VALUE(Value) Value
|
| 434 |
+
#endif
|
| 435 |
+
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
| 436 |
+
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
| 437 |
+
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
|
| 438 |
+
#endif
|
| 439 |
+
#ifndef YY_INITIAL_VALUE
|
| 440 |
+
# define YY_INITIAL_VALUE(Value) /* Nothing. */
|
| 441 |
+
#endif
|
| 442 |
+
|
| 443 |
+
#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
|
| 444 |
+
# define YY_IGNORE_USELESS_CAST_BEGIN \
|
| 445 |
+
_Pragma ("GCC diagnostic push") \
|
| 446 |
+
_Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
|
| 447 |
+
# define YY_IGNORE_USELESS_CAST_END \
|
| 448 |
+
_Pragma ("GCC diagnostic pop")
|
| 449 |
+
#endif
|
| 450 |
+
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
|
| 451 |
+
# define YY_IGNORE_USELESS_CAST_BEGIN
|
| 452 |
+
# define YY_IGNORE_USELESS_CAST_END
|
| 453 |
+
#endif
|
| 454 |
+
]])
|
| 455 |
+
|
| 456 |
+
|
| 457 |
+
# b4_cast_define
|
| 458 |
+
# --------------
|
| 459 |
+
m4_define([b4_cast_define],
|
| 460 |
+
[# ifndef YY_CAST
|
| 461 |
+
# ifdef __cplusplus
|
| 462 |
+
# define YY_CAST(Type, Val) static_cast<Type> (Val)
|
| 463 |
+
# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
|
| 464 |
+
# else
|
| 465 |
+
# define YY_CAST(Type, Val) ((Type) (Val))
|
| 466 |
+
# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
|
| 467 |
+
# endif
|
| 468 |
+
# endif[]dnl
|
| 469 |
+
])
|
| 470 |
+
|
| 471 |
+
|
| 472 |
+
# b4_null_define
|
| 473 |
+
# --------------
|
| 474 |
+
# Portability issues: define a YY_NULLPTR appropriate for the current
|
| 475 |
+
# language (C, C++98, or C++11).
|
| 476 |
+
#
|
| 477 |
+
# In C++ pre C++11 it is standard practice to use 0 (not NULL) for the
|
| 478 |
+
# null pointer. In C, prefer ((void*)0) to avoid having to include stdlib.h.
|
| 479 |
+
m4_define([b4_null_define],
|
| 480 |
+
[# ifndef YY_NULLPTR
|
| 481 |
+
# if defined __cplusplus
|
| 482 |
+
# if 201103L <= __cplusplus
|
| 483 |
+
# define YY_NULLPTR nullptr
|
| 484 |
+
# else
|
| 485 |
+
# define YY_NULLPTR 0
|
| 486 |
+
# endif
|
| 487 |
+
# else
|
| 488 |
+
# define YY_NULLPTR ((void*)0)
|
| 489 |
+
# endif
|
| 490 |
+
# endif[]dnl
|
| 491 |
+
])
|
| 492 |
+
|
| 493 |
+
|
| 494 |
+
# b4_null
|
| 495 |
+
# -------
|
| 496 |
+
# Return a null pointer constant.
|
| 497 |
+
m4_define([b4_null], [YY_NULLPTR])
|
| 498 |
+
|
| 499 |
+
|
| 500 |
+
|
| 501 |
+
## ---------##
|
| 502 |
+
## Values. ##
|
| 503 |
+
## ---------##
|
| 504 |
+
|
| 505 |
+
# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
|
| 506 |
+
# -------------------------------------------------------------
|
| 507 |
+
# Define "yy<TABLE-NAME>" whose contents is CONTENT.
|
| 508 |
+
m4_define([b4_integral_parser_table_define],
|
| 509 |
+
[m4_ifvaln([$3], [b4_comment([$3])])dnl
|
| 510 |
+
static const b4_int_type_for([$2]) yy$1[[]] =
|
| 511 |
+
{
|
| 512 |
+
$2
|
| 513 |
+
};dnl
|
| 514 |
+
])
|
| 515 |
+
|
| 516 |
+
|
| 517 |
+
## ------------- ##
|
| 518 |
+
## Token kinds. ##
|
| 519 |
+
## ------------- ##
|
| 520 |
+
|
| 521 |
+
# Because C enums are not scoped, because tokens are exposed in the
|
| 522 |
+
# header, and because these tokens are common to all the parsers, we
|
| 523 |
+
# need to make sure their names don't collide: use the api.prefix.
|
| 524 |
+
# YYEOF is special, since the user may give it a different name.
|
| 525 |
+
m4_define([b4_symbol(-2, id)], [b4_api_PREFIX[][EMPTY]])
|
| 526 |
+
m4_define([b4_symbol(-2, tag)], [[No symbol.]])
|
| 527 |
+
|
| 528 |
+
m4_if(b4_symbol(eof, id), [YYEOF],
|
| 529 |
+
[m4_define([b4_symbol(0, id)], [b4_api_PREFIX[][EOF]])])
|
| 530 |
+
m4_define([b4_symbol(1, id)], [b4_api_PREFIX[][error]])
|
| 531 |
+
m4_define([b4_symbol(2, id)], [b4_api_PREFIX[][UNDEF]])
|
| 532 |
+
|
| 533 |
+
|
| 534 |
+
# b4_token_define(TOKEN-NUM)
|
| 535 |
+
# --------------------------
|
| 536 |
+
# Output the definition of this token as #define.
|
| 537 |
+
m4_define([b4_token_define],
|
| 538 |
+
[b4_token_format([#define %s %s], [$1])])
|
| 539 |
+
|
| 540 |
+
# b4_token_defines
|
| 541 |
+
# ----------------
|
| 542 |
+
# Output the definition of the tokens.
|
| 543 |
+
m4_define([b4_token_defines],
|
| 544 |
+
[[/* Token kinds. */
|
| 545 |
+
#define ]b4_symbol(empty, [id])[ -2
|
| 546 |
+
]m4_join([
|
| 547 |
+
], b4_symbol_map([b4_token_define]))
|
| 548 |
+
])
|
| 549 |
+
|
| 550 |
+
|
| 551 |
+
# b4_token_enum(TOKEN-NUM)
|
| 552 |
+
# ------------------------
|
| 553 |
+
# Output the definition of this token as an enum.
|
| 554 |
+
m4_define([b4_token_enum],
|
| 555 |
+
[b4_token_visible_if([$1],
|
| 556 |
+
[m4_format([ %-30s %s],
|
| 557 |
+
m4_format([[%s = %s%s%s]],
|
| 558 |
+
b4_symbol([$1], [id]),
|
| 559 |
+
b4_symbol([$1], b4_api_token_raw_if([[number]], [[code]])),
|
| 560 |
+
m4_if([$1], b4_last_enum_token, [], [[,]])),
|
| 561 |
+
[b4_symbol_tag_comment([$1])])])])
|
| 562 |
+
|
| 563 |
+
|
| 564 |
+
# b4_token_enums
|
| 565 |
+
# --------------
|
| 566 |
+
# The definition of the token kinds.
|
| 567 |
+
m4_define([b4_token_enums],
|
| 568 |
+
[b4_any_token_visible_if([[/* Token kinds. */
|
| 569 |
+
#ifndef ]b4_api_PREFIX[TOKENTYPE
|
| 570 |
+
# define ]b4_api_PREFIX[TOKENTYPE
|
| 571 |
+
enum ]b4_api_prefix[tokentype
|
| 572 |
+
{
|
| 573 |
+
]b4_symbol(empty, [id])[ = -2,
|
| 574 |
+
]b4_symbol_foreach([b4_token_enum])dnl
|
| 575 |
+
[ };
|
| 576 |
+
typedef enum ]b4_api_prefix[tokentype ]b4_api_prefix[token_kind_t;
|
| 577 |
+
#endif
|
| 578 |
+
]])])
|
| 579 |
+
|
| 580 |
+
|
| 581 |
+
# b4_token_enums_defines
|
| 582 |
+
# ----------------------
|
| 583 |
+
# The definition of the tokens (if there are any) as enums and,
|
| 584 |
+
# if POSIX Yacc is enabled, as #defines.
|
| 585 |
+
m4_define([b4_token_enums_defines],
|
| 586 |
+
[b4_token_enums[]b4_yacc_if([b4_token_defines])])
|
| 587 |
+
|
| 588 |
+
|
| 589 |
+
# b4_symbol_translate(STRING)
|
| 590 |
+
# ---------------------------
|
| 591 |
+
# Used by "bison" in the array of symbol names to mark those that
|
| 592 |
+
# require translation.
|
| 593 |
+
m4_define([b4_symbol_translate],
|
| 594 |
+
[[N_($1)]])
|
| 595 |
+
|
| 596 |
+
|
| 597 |
+
|
| 598 |
+
## -------------- ##
|
| 599 |
+
## Symbol kinds. ##
|
| 600 |
+
## -------------- ##
|
| 601 |
+
|
| 602 |
+
# b4_symbol_enum(SYMBOL-NUM)
|
| 603 |
+
# --------------------------
|
| 604 |
+
# Output the definition of this symbol as an enum.
|
| 605 |
+
m4_define([b4_symbol_enum],
|
| 606 |
+
[m4_format([ %-40s %s],
|
| 607 |
+
m4_format([[%s = %s%s%s]],
|
| 608 |
+
b4_symbol([$1], [kind_base]),
|
| 609 |
+
[$1],
|
| 610 |
+
m4_if([$1], b4_last_symbol, [], [[,]])),
|
| 611 |
+
[b4_symbol_tag_comment([$1])])])
|
| 612 |
+
|
| 613 |
+
|
| 614 |
+
# b4_declare_symbol_enum
|
| 615 |
+
# ----------------------
|
| 616 |
+
# The definition of the symbol internal numbers as an enum.
|
| 617 |
+
# Defining YYEMPTY here is important: it forces the compiler
|
| 618 |
+
# to use a signed type, which matters for yytoken.
|
| 619 |
+
m4_define([b4_declare_symbol_enum],
|
| 620 |
+
[[/* Symbol kind. */
|
| 621 |
+
enum yysymbol_kind_t
|
| 622 |
+
{
|
| 623 |
+
]b4_symbol(empty, [kind_base])[ = -2,
|
| 624 |
+
]b4_symbol_foreach([b4_symbol_enum])dnl
|
| 625 |
+
[};
|
| 626 |
+
typedef enum yysymbol_kind_t yysymbol_kind_t;
|
| 627 |
+
]])])
|
| 628 |
+
|
| 629 |
+
|
| 630 |
+
## ----------------- ##
|
| 631 |
+
## Semantic Values. ##
|
| 632 |
+
## ----------------- ##
|
| 633 |
+
|
| 634 |
+
|
| 635 |
+
# b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
|
| 636 |
+
# ----------------------------------------------
|
| 637 |
+
# See README.
|
| 638 |
+
m4_define([b4_symbol_value],
|
| 639 |
+
[m4_ifval([$3],
|
| 640 |
+
[($1.$3)],
|
| 641 |
+
[m4_ifval([$2],
|
| 642 |
+
[b4_symbol_if([$2], [has_type],
|
| 643 |
+
[($1.b4_symbol([$2], [type]))],
|
| 644 |
+
[$1])],
|
| 645 |
+
[$1])])])
|
| 646 |
+
|
| 647 |
+
|
| 648 |
+
## ---------------------- ##
|
| 649 |
+
## Defining C functions. ##
|
| 650 |
+
## ---------------------- ##
|
| 651 |
+
|
| 652 |
+
|
| 653 |
+
# b4_formals([DECL1, NAME1], ...)
|
| 654 |
+
# -------------------------------
|
| 655 |
+
# The formal arguments of a C function definition.
|
| 656 |
+
m4_define([b4_formals],
|
| 657 |
+
[m4_if([$#], [0], [void],
|
| 658 |
+
[$#$1], [1], [void],
|
| 659 |
+
[m4_map_sep([b4_formal], [, ], [$@])])])
|
| 660 |
+
|
| 661 |
+
m4_define([b4_formal],
|
| 662 |
+
[$1])
|
| 663 |
+
|
| 664 |
+
|
| 665 |
+
# b4_function_declare(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
| 666 |
+
# ------------------------------------------------------------
|
| 667 |
+
# Declare the function NAME.
|
| 668 |
+
m4_define([b4_function_declare],
|
| 669 |
+
[$2 $1 (b4_formals(m4_shift2($@)));[]dnl
|
| 670 |
+
])
|
| 671 |
+
|
| 672 |
+
|
| 673 |
+
|
| 674 |
+
## --------------------- ##
|
| 675 |
+
## Calling C functions. ##
|
| 676 |
+
## --------------------- ##
|
| 677 |
+
|
| 678 |
+
|
| 679 |
+
# b4_function_call(NAME, RETURN-VALUE, [DECL1, NAME1], ...)
|
| 680 |
+
# -----------------------------------------------------------
|
| 681 |
+
# Call the function NAME with arguments NAME1, NAME2 etc.
|
| 682 |
+
m4_define([b4_function_call],
|
| 683 |
+
[$1 (b4_args(m4_shift2($@)))[]dnl
|
| 684 |
+
])
|
| 685 |
+
|
| 686 |
+
|
| 687 |
+
# b4_args([DECL1, NAME1], ...)
|
| 688 |
+
# ----------------------------
|
| 689 |
+
# Output the arguments NAME1, NAME2...
|
| 690 |
+
m4_define([b4_args],
|
| 691 |
+
[m4_map_sep([b4_arg], [, ], [$@])])
|
| 692 |
+
|
| 693 |
+
m4_define([b4_arg],
|
| 694 |
+
[$2])
|
| 695 |
+
|
| 696 |
+
|
| 697 |
+
## ----------- ##
|
| 698 |
+
## Synclines. ##
|
| 699 |
+
## ----------- ##
|
| 700 |
+
|
| 701 |
+
# b4_sync_start(LINE, FILE)
|
| 702 |
+
# -------------------------
|
| 703 |
+
m4_define([b4_sync_start], [[#]line $1 $2])
|
| 704 |
+
|
| 705 |
+
|
| 706 |
+
## -------------- ##
|
| 707 |
+
## User actions. ##
|
| 708 |
+
## -------------- ##
|
| 709 |
+
|
| 710 |
+
# b4_case(LABEL, STATEMENTS, [COMMENTS])
|
| 711 |
+
# --------------------------------------
|
| 712 |
+
m4_define([b4_case],
|
| 713 |
+
[ case $1:m4_ifval([$3], [ b4_comment([$3])])
|
| 714 |
+
$2
|
| 715 |
+
b4_syncline([@oline@], [@ofile@])dnl
|
| 716 |
+
break;])
|
| 717 |
+
|
| 718 |
+
|
| 719 |
+
# b4_predicate_case(LABEL, CONDITIONS)
|
| 720 |
+
# ------------------------------------
|
| 721 |
+
m4_define([b4_predicate_case],
|
| 722 |
+
[ case $1:
|
| 723 |
+
if (! (
|
| 724 |
+
$2)) YYERROR;
|
| 725 |
+
b4_syncline([@oline@], [@ofile@])dnl
|
| 726 |
+
break;])
|
| 727 |
+
|
| 728 |
+
|
| 729 |
+
# b4_yydestruct_define
|
| 730 |
+
# --------------------
|
| 731 |
+
# Define the "yydestruct" function.
|
| 732 |
+
m4_define_default([b4_yydestruct_define],
|
| 733 |
+
[[/*-----------------------------------------------.
|
| 734 |
+
| Release the memory associated to this symbol. |
|
| 735 |
+
`-----------------------------------------------*/
|
| 736 |
+
|
| 737 |
+
static void
|
| 738 |
+
yydestruct (const char *yymsg,
|
| 739 |
+
yysymbol_kind_t yykind, YYSTYPE *yyvaluep]b4_locations_if(dnl
|
| 740 |
+
[[, YYLTYPE *yylocationp]])[]b4_user_formals[)
|
| 741 |
+
{
|
| 742 |
+
]b4_parse_param_use([yyvaluep], [yylocationp])dnl
|
| 743 |
+
[ if (!yymsg)
|
| 744 |
+
yymsg = "Deleting";
|
| 745 |
+
YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
|
| 746 |
+
|
| 747 |
+
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
| 748 |
+
]b4_symbol_actions([destructor])[
|
| 749 |
+
YY_IGNORE_MAYBE_UNINITIALIZED_END
|
| 750 |
+
}]dnl
|
| 751 |
+
])
|
| 752 |
+
|
| 753 |
+
|
| 754 |
+
# b4_yy_symbol_print_define
|
| 755 |
+
# -------------------------
|
| 756 |
+
# Define the "yy_symbol_print" function.
|
| 757 |
+
m4_define_default([b4_yy_symbol_print_define],
|
| 758 |
+
[[
|
| 759 |
+
/*-----------------------------------.
|
| 760 |
+
| Print this symbol's value on YYO. |
|
| 761 |
+
`-----------------------------------*/
|
| 762 |
+
|
| 763 |
+
static void
|
| 764 |
+
yy_symbol_value_print (FILE *yyo,
|
| 765 |
+
yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep]b4_locations_if(dnl
|
| 766 |
+
[[, YYLTYPE const * const yylocationp]])[]b4_user_formals[)
|
| 767 |
+
{
|
| 768 |
+
FILE *yyoutput = yyo;
|
| 769 |
+
]b4_parse_param_use([yyoutput], [yylocationp])dnl
|
| 770 |
+
[ if (!yyvaluep)
|
| 771 |
+
return;]
|
| 772 |
+
b4_percent_code_get([[pre-printer]])dnl
|
| 773 |
+
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
| 774 |
+
b4_symbol_actions([printer])
|
| 775 |
+
YY_IGNORE_MAYBE_UNINITIALIZED_END
|
| 776 |
+
b4_percent_code_get([[post-printer]])dnl
|
| 777 |
+
[}
|
| 778 |
+
|
| 779 |
+
|
| 780 |
+
/*---------------------------.
|
| 781 |
+
| Print this symbol on YYO. |
|
| 782 |
+
`---------------------------*/
|
| 783 |
+
|
| 784 |
+
static void
|
| 785 |
+
yy_symbol_print (FILE *yyo,
|
| 786 |
+
yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep]b4_locations_if(dnl
|
| 787 |
+
[[, YYLTYPE const * const yylocationp]])[]b4_user_formals[)
|
| 788 |
+
{
|
| 789 |
+
YYFPRINTF (yyo, "%s %s (",
|
| 790 |
+
yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
|
| 791 |
+
|
| 792 |
+
]b4_locations_if([ YYLOCATION_PRINT (yyo, yylocationp);
|
| 793 |
+
YYFPRINTF (yyo, ": ");
|
| 794 |
+
])dnl
|
| 795 |
+
[ yy_symbol_value_print (yyo, yykind, yyvaluep]dnl
|
| 796 |
+
b4_locations_if([, yylocationp])[]b4_user_args[);
|
| 797 |
+
YYFPRINTF (yyo, ")");
|
| 798 |
+
}]dnl
|
| 799 |
+
])
|
| 800 |
+
|
| 801 |
+
|
| 802 |
+
## ---------------- ##
|
| 803 |
+
## api.value.type. ##
|
| 804 |
+
## ---------------- ##
|
| 805 |
+
|
| 806 |
+
|
| 807 |
+
# ---------------------- #
|
| 808 |
+
# api.value.type=union. #
|
| 809 |
+
# ---------------------- #
|
| 810 |
+
|
| 811 |
+
# b4_symbol_type_register(SYMBOL-NUM)
|
| 812 |
+
# -----------------------------------
|
| 813 |
+
# Symbol SYMBOL-NUM has a type (for variant) instead of a type-tag.
|
| 814 |
+
# Extend the definition of %union's body (b4_union_members) with a
|
| 815 |
+
# field of that type, and extend the symbol's "type" field to point to
|
| 816 |
+
# the field name, instead of the type name.
|
| 817 |
+
m4_define([b4_symbol_type_register],
|
| 818 |
+
[m4_define([b4_symbol($1, type_tag)],
|
| 819 |
+
[b4_symbol_if([$1], [has_id],
|
| 820 |
+
[b4_symbol([$1], [id])],
|
| 821 |
+
[yykind_[]b4_symbol([$1], [number])])])dnl
|
| 822 |
+
m4_append([b4_union_members],
|
| 823 |
+
m4_expand([m4_format([ %-40s %s],
|
| 824 |
+
m4_expand([b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);]),
|
| 825 |
+
[b4_symbol_tag_comment([$1])])]))
|
| 826 |
+
])
|
| 827 |
+
|
| 828 |
+
|
| 829 |
+
# b4_type_define_tag(SYMBOL1-NUM, ...)
|
| 830 |
+
# ------------------------------------
|
| 831 |
+
# For the batch of symbols SYMBOL1-NUM... (which all have the same
|
| 832 |
+
# type), enhance the %union definition for each of them, and set
|
| 833 |
+
# there "type" field to the field tag name, instead of the type name.
|
| 834 |
+
m4_define([b4_type_define_tag],
|
| 835 |
+
[b4_symbol_if([$1], [has_type],
|
| 836 |
+
[m4_map([b4_symbol_type_register], [$@])])
|
| 837 |
+
])
|
| 838 |
+
|
| 839 |
+
|
| 840 |
+
# b4_symbol_value_union(VAL, SYMBOL-NUM, [TYPE])
|
| 841 |
+
# ----------------------------------------------
|
| 842 |
+
# Same of b4_symbol_value, but when api.value.type=union.
|
| 843 |
+
m4_define([b4_symbol_value_union],
|
| 844 |
+
[m4_ifval([$3],
|
| 845 |
+
[(*($3*)(&$1))],
|
| 846 |
+
[m4_ifval([$2],
|
| 847 |
+
[b4_symbol_if([$2], [has_type],
|
| 848 |
+
[($1.b4_symbol([$2], [type_tag]))],
|
| 849 |
+
[$1])],
|
| 850 |
+
[$1])])])
|
| 851 |
+
|
| 852 |
+
|
| 853 |
+
# b4_value_type_setup_union
|
| 854 |
+
# -------------------------
|
| 855 |
+
# Setup support for api.value.type=union. Symbols are defined with a
|
| 856 |
+
# type instead of a union member name: build the corresponding union,
|
| 857 |
+
# and give the symbols their tag.
|
| 858 |
+
m4_define([b4_value_type_setup_union],
|
| 859 |
+
[m4_define([b4_union_members])
|
| 860 |
+
b4_type_foreach([b4_type_define_tag])
|
| 861 |
+
m4_copy_force([b4_symbol_value_union], [b4_symbol_value])
|
| 862 |
+
])
|
| 863 |
+
|
| 864 |
+
|
| 865 |
+
# -------------------------- #
|
| 866 |
+
# api.value.type = variant. #
|
| 867 |
+
# -------------------------- #
|
| 868 |
+
|
| 869 |
+
# b4_value_type_setup_variant
|
| 870 |
+
# ---------------------------
|
| 871 |
+
# Setup support for api.value.type=variant. By default, fail, specialized
|
| 872 |
+
# by other skeletons.
|
| 873 |
+
m4_define([b4_value_type_setup_variant],
|
| 874 |
+
[b4_complain_at(b4_percent_define_get_loc([[api.value.type]]),
|
| 875 |
+
[['%s' does not support '%s']],
|
| 876 |
+
[b4_skeleton],
|
| 877 |
+
[%define api.value.type variant])])
|
| 878 |
+
|
| 879 |
+
|
| 880 |
+
# _b4_value_type_setup_keyword
|
| 881 |
+
# ----------------------------
|
| 882 |
+
# api.value.type is defined with a keyword/string syntax. Check if
|
| 883 |
+
# that is properly defined, and prepare its use.
|
| 884 |
+
m4_define([_b4_value_type_setup_keyword],
|
| 885 |
+
[b4_percent_define_check_values([[[[api.value.type]],
|
| 886 |
+
[[none]],
|
| 887 |
+
[[union]],
|
| 888 |
+
[[union-directive]],
|
| 889 |
+
[[variant]],
|
| 890 |
+
[[yystype]]]])dnl
|
| 891 |
+
m4_case(b4_percent_define_get([[api.value.type]]),
|
| 892 |
+
[union], [b4_value_type_setup_union],
|
| 893 |
+
[variant], [b4_value_type_setup_variant])])
|
| 894 |
+
|
| 895 |
+
|
| 896 |
+
# b4_value_type_setup
|
| 897 |
+
# -------------------
|
| 898 |
+
# Check if api.value.type is properly defined, and possibly prepare
|
| 899 |
+
# its use.
|
| 900 |
+
b4_define_silent([b4_value_type_setup],
|
| 901 |
+
[# Define default value.
|
| 902 |
+
b4_percent_define_ifdef([[api.value.type]], [],
|
| 903 |
+
[# %union => api.value.type=union-directive
|
| 904 |
+
m4_ifdef([b4_union_members],
|
| 905 |
+
[m4_define([b4_percent_define_kind(api.value.type)], [keyword])
|
| 906 |
+
m4_define([b4_percent_define(api.value.type)], [union-directive])],
|
| 907 |
+
[# no tag seen => api.value.type={int}
|
| 908 |
+
m4_if(b4_tag_seen_flag, 0,
|
| 909 |
+
[m4_define([b4_percent_define_kind(api.value.type)], [code])
|
| 910 |
+
m4_define([b4_percent_define(api.value.type)], [int])],
|
| 911 |
+
[# otherwise api.value.type=yystype
|
| 912 |
+
m4_define([b4_percent_define_kind(api.value.type)], [keyword])
|
| 913 |
+
m4_define([b4_percent_define(api.value.type)], [yystype])])])])
|
| 914 |
+
|
| 915 |
+
# Set up.
|
| 916 |
+
m4_bmatch(b4_percent_define_get_kind([[api.value.type]]),
|
| 917 |
+
[keyword\|string], [_b4_value_type_setup_keyword])
|
| 918 |
+
])
|
| 919 |
+
|
| 920 |
+
|
| 921 |
+
## -------------- ##
|
| 922 |
+
## Declarations. ##
|
| 923 |
+
## -------------- ##
|
| 924 |
+
|
| 925 |
+
|
| 926 |
+
# b4_value_type_define
|
| 927 |
+
# --------------------
|
| 928 |
+
m4_define([b4_value_type_define],
|
| 929 |
+
[b4_value_type_setup[]dnl
|
| 930 |
+
/* Value type. */
|
| 931 |
+
m4_bmatch(b4_percent_define_get_kind([[api.value.type]]),
|
| 932 |
+
[code],
|
| 933 |
+
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
|
| 934 |
+
typedef ]b4_percent_define_get([[api.value.type]])[ ]b4_api_PREFIX[STYPE;
|
| 935 |
+
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1
|
| 936 |
+
# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1
|
| 937 |
+
#endif
|
| 938 |
+
]],
|
| 939 |
+
[m4_bmatch(b4_percent_define_get([[api.value.type]]),
|
| 940 |
+
[union\|union-directive],
|
| 941 |
+
[[#if ! defined ]b4_api_PREFIX[STYPE && ! defined ]b4_api_PREFIX[STYPE_IS_DECLARED
|
| 942 |
+
]b4_percent_define_get_syncline([[api.value.union.name]])dnl
|
| 943 |
+
[union ]b4_percent_define_get([[api.value.union.name]])[
|
| 944 |
+
{
|
| 945 |
+
]b4_user_union_members[
|
| 946 |
+
};
|
| 947 |
+
]b4_percent_define_get_syncline([[api.value.union.name]])dnl
|
| 948 |
+
[typedef union ]b4_percent_define_get([[api.value.union.name]])[ ]b4_api_PREFIX[STYPE;
|
| 949 |
+
# define ]b4_api_PREFIX[STYPE_IS_TRIVIAL 1
|
| 950 |
+
# define ]b4_api_PREFIX[STYPE_IS_DECLARED 1
|
| 951 |
+
#endif
|
| 952 |
+
]])])])
|
| 953 |
+
|
| 954 |
+
|
| 955 |
+
# b4_location_type_define
|
| 956 |
+
# -----------------------
|
| 957 |
+
m4_define([b4_location_type_define],
|
| 958 |
+
[[/* Location type. */
|
| 959 |
+
]b4_percent_define_ifdef([[api.location.type]],
|
| 960 |
+
[[typedef ]b4_percent_define_get([[api.location.type]])[ ]b4_api_PREFIX[LTYPE;
|
| 961 |
+
]],
|
| 962 |
+
[[#if ! defined ]b4_api_PREFIX[LTYPE && ! defined ]b4_api_PREFIX[LTYPE_IS_DECLARED
|
| 963 |
+
typedef struct ]b4_api_PREFIX[LTYPE ]b4_api_PREFIX[LTYPE;
|
| 964 |
+
struct ]b4_api_PREFIX[LTYPE
|
| 965 |
+
{
|
| 966 |
+
int first_line;
|
| 967 |
+
int first_column;
|
| 968 |
+
int last_line;
|
| 969 |
+
int last_column;
|
| 970 |
+
};
|
| 971 |
+
# define ]b4_api_PREFIX[LTYPE_IS_DECLARED 1
|
| 972 |
+
# define ]b4_api_PREFIX[LTYPE_IS_TRIVIAL 1
|
| 973 |
+
#endif
|
| 974 |
+
]])])
|
| 975 |
+
|
| 976 |
+
|
| 977 |
+
# b4_declare_yylstype
|
| 978 |
+
# -------------------
|
| 979 |
+
# Declarations that might either go into the header (if --header) or
|
| 980 |
+
# in the parser body. Declare YYSTYPE/YYLTYPE, and yylval/yylloc.
|
| 981 |
+
m4_define([b4_declare_yylstype],
|
| 982 |
+
[b4_value_type_define[]b4_locations_if([
|
| 983 |
+
b4_location_type_define])
|
| 984 |
+
|
| 985 |
+
b4_pure_if([], [[extern ]b4_api_PREFIX[STYPE ]b4_prefix[lval;
|
| 986 |
+
]b4_locations_if([[extern ]b4_api_PREFIX[LTYPE ]b4_prefix[lloc;]])])[]dnl
|
| 987 |
+
])
|
| 988 |
+
|
| 989 |
+
|
| 990 |
+
# b4_YYDEBUG_define
|
| 991 |
+
# -----------------
|
| 992 |
+
m4_define([b4_YYDEBUG_define],
|
| 993 |
+
[[/* Debug traces. */
|
| 994 |
+
]m4_if(b4_api_prefix, [yy],
|
| 995 |
+
[[#ifndef YYDEBUG
|
| 996 |
+
# define YYDEBUG ]b4_parse_trace_if([1], [0])[
|
| 997 |
+
#endif]],
|
| 998 |
+
[[#ifndef ]b4_api_PREFIX[DEBUG
|
| 999 |
+
# if defined YYDEBUG
|
| 1000 |
+
#if YYDEBUG
|
| 1001 |
+
# define ]b4_api_PREFIX[DEBUG 1
|
| 1002 |
+
# else
|
| 1003 |
+
# define ]b4_api_PREFIX[DEBUG 0
|
| 1004 |
+
# endif
|
| 1005 |
+
# else /* ! defined YYDEBUG */
|
| 1006 |
+
# define ]b4_api_PREFIX[DEBUG ]b4_parse_trace_if([1], [0])[
|
| 1007 |
+
# endif /* ! defined YYDEBUG */
|
| 1008 |
+
#endif /* ! defined ]b4_api_PREFIX[DEBUG */]])[]dnl
|
| 1009 |
+
])
|
| 1010 |
+
|
| 1011 |
+
# b4_declare_yydebug
|
| 1012 |
+
# ------------------
|
| 1013 |
+
m4_define([b4_declare_yydebug],
|
| 1014 |
+
[b4_YYDEBUG_define[
|
| 1015 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 1016 |
+
extern int ]b4_prefix[debug;
|
| 1017 |
+
#endif][]dnl
|
| 1018 |
+
])
|
| 1019 |
+
|
| 1020 |
+
# b4_yylloc_default_define
|
| 1021 |
+
# ------------------------
|
| 1022 |
+
# Define YYLLOC_DEFAULT.
|
| 1023 |
+
m4_define([b4_yylloc_default_define],
|
| 1024 |
+
[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
| 1025 |
+
If N is 0, then set CURRENT to the empty location which ends
|
| 1026 |
+
the previous symbol: RHS[0] (always defined). */
|
| 1027 |
+
|
| 1028 |
+
#ifndef YYLLOC_DEFAULT
|
| 1029 |
+
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
| 1030 |
+
do \
|
| 1031 |
+
if (N) \
|
| 1032 |
+
{ \
|
| 1033 |
+
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
| 1034 |
+
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
| 1035 |
+
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
| 1036 |
+
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
| 1037 |
+
} \
|
| 1038 |
+
else \
|
| 1039 |
+
{ \
|
| 1040 |
+
(Current).first_line = (Current).last_line = \
|
| 1041 |
+
YYRHSLOC (Rhs, 0).last_line; \
|
| 1042 |
+
(Current).first_column = (Current).last_column = \
|
| 1043 |
+
YYRHSLOC (Rhs, 0).last_column; \
|
| 1044 |
+
} \
|
| 1045 |
+
while (0)
|
| 1046 |
+
#endif
|
| 1047 |
+
]])
|
| 1048 |
+
|
| 1049 |
+
# b4_yylocation_print_define
|
| 1050 |
+
# --------------------------
|
| 1051 |
+
# Define YYLOCATION_PRINT.
|
| 1052 |
+
m4_define([b4_yylocation_print_define],
|
| 1053 |
+
[b4_locations_if([[
|
| 1054 |
+
/* YYLOCATION_PRINT -- Print the location on the stream.
|
| 1055 |
+
This macro was not mandated originally: define only if we know
|
| 1056 |
+
we won't break user code: when these are the locations we know. */
|
| 1057 |
+
|
| 1058 |
+
# ifndef YYLOCATION_PRINT
|
| 1059 |
+
|
| 1060 |
+
# if defined YY_LOCATION_PRINT
|
| 1061 |
+
|
| 1062 |
+
/* Temporary convenience wrapper in case some people defined the
|
| 1063 |
+
undocumented and private YY_LOCATION_PRINT macros. */
|
| 1064 |
+
# define YYLOCATION_PRINT(File, Loc) YY_LOCATION_PRINT(File, *(Loc))
|
| 1065 |
+
|
| 1066 |
+
# elif defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
| 1067 |
+
|
| 1068 |
+
/* Print *YYLOCP on YYO. Private, do not rely on its existence. */
|
| 1069 |
+
|
| 1070 |
+
YY_ATTRIBUTE_UNUSED
|
| 1071 |
+
static int
|
| 1072 |
+
yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
|
| 1073 |
+
{
|
| 1074 |
+
int res = 0;
|
| 1075 |
+
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
|
| 1076 |
+
if (0 <= yylocp->first_line)
|
| 1077 |
+
{
|
| 1078 |
+
res += YYFPRINTF (yyo, "%d", yylocp->first_line);
|
| 1079 |
+
if (0 <= yylocp->first_column)
|
| 1080 |
+
res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
|
| 1081 |
+
}
|
| 1082 |
+
if (0 <= yylocp->last_line)
|
| 1083 |
+
{
|
| 1084 |
+
if (yylocp->first_line < yylocp->last_line)
|
| 1085 |
+
{
|
| 1086 |
+
res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
|
| 1087 |
+
if (0 <= end_col)
|
| 1088 |
+
res += YYFPRINTF (yyo, ".%d", end_col);
|
| 1089 |
+
}
|
| 1090 |
+
else if (0 <= end_col && yylocp->first_column < end_col)
|
| 1091 |
+
res += YYFPRINTF (yyo, "-%d", end_col);
|
| 1092 |
+
}
|
| 1093 |
+
return res;
|
| 1094 |
+
}
|
| 1095 |
+
|
| 1096 |
+
# define YYLOCATION_PRINT yy_location_print_
|
| 1097 |
+
|
| 1098 |
+
/* Temporary convenience wrapper in case some people defined the
|
| 1099 |
+
undocumented and private YY_LOCATION_PRINT macros. */
|
| 1100 |
+
# define YY_LOCATION_PRINT(File, Loc) YYLOCATION_PRINT(File, &(Loc))
|
| 1101 |
+
|
| 1102 |
+
# else
|
| 1103 |
+
|
| 1104 |
+
# define YYLOCATION_PRINT(File, Loc) ((void) 0)
|
| 1105 |
+
/* Temporary convenience wrapper in case some people defined the
|
| 1106 |
+
undocumented and private YY_LOCATION_PRINT macros. */
|
| 1107 |
+
# define YY_LOCATION_PRINT YYLOCATION_PRINT
|
| 1108 |
+
|
| 1109 |
+
# endif
|
| 1110 |
+
# endif /* !defined YYLOCATION_PRINT */]])
|
| 1111 |
+
])
|
| 1112 |
+
|
| 1113 |
+
# b4_yyloc_default
|
| 1114 |
+
# ----------------
|
| 1115 |
+
# Expand to a possible default value for yylloc.
|
| 1116 |
+
m4_define([b4_yyloc_default],
|
| 1117 |
+
[[
|
| 1118 |
+
# if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
|
| 1119 |
+
= { ]m4_join([, ],
|
| 1120 |
+
m4_defn([b4_location_initial_line]),
|
| 1121 |
+
m4_defn([b4_location_initial_column]),
|
| 1122 |
+
m4_defn([b4_location_initial_line]),
|
| 1123 |
+
m4_defn([b4_location_initial_column]))[ }
|
| 1124 |
+
# endif
|
| 1125 |
+
]])
|
platform/dbops/binaries/build/share/bison/skeletons/d-skel.m4
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-*- Autoconf -*-
|
| 2 |
+
|
| 3 |
+
# D skeleton dispatching for Bison.
|
| 4 |
+
|
| 5 |
+
# Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
| 6 |
+
|
| 7 |
+
# This program is free software: you can redistribute it and/or modify
|
| 8 |
+
# it under the terms of the GNU General Public License as published by
|
| 9 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 10 |
+
# (at your option) any later version.
|
| 11 |
+
#
|
| 12 |
+
# This program is distributed in the hope that it will be useful,
|
| 13 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
# GNU General Public License for more details.
|
| 16 |
+
#
|
| 17 |
+
# You should have received a copy of the GNU General Public License
|
| 18 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 19 |
+
|
| 20 |
+
b4_glr_if( [b4_complain([%%glr-parser not supported for D])])
|
| 21 |
+
b4_nondeterministic_if([b4_complain([%%nondeterministic-parser not supported for D])])
|
| 22 |
+
|
| 23 |
+
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[lalr1.d]])
|
| 24 |
+
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
| 25 |
+
|
| 26 |
+
m4_include(b4_used_skeleton)
|
platform/dbops/binaries/build/share/bison/skeletons/d.m4
ADDED
|
@@ -0,0 +1,628 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-*- Autoconf -*-
|
| 2 |
+
|
| 3 |
+
# D language support for Bison
|
| 4 |
+
|
| 5 |
+
# Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
| 6 |
+
|
| 7 |
+
# This program is free software: you can redistribute it and/or modify
|
| 8 |
+
# it under the terms of the GNU General Public License as published by
|
| 9 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 10 |
+
# (at your option) any later version.
|
| 11 |
+
#
|
| 12 |
+
# This program is distributed in the hope that it will be useful,
|
| 13 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
# GNU General Public License for more details.
|
| 16 |
+
#
|
| 17 |
+
# You should have received a copy of the GNU General Public License
|
| 18 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
m4_include(b4_skeletonsdir/[c-like.m4])
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
# b4_symbol_action(SYMBOL-NUM, ACTION)
|
| 25 |
+
# ------------------------------------
|
| 26 |
+
# Run the action ACTION ("destructor" or "printer") for SYMBOL-NUM.
|
| 27 |
+
m4_define([b4_symbol_action],
|
| 28 |
+
[b4_symbol_if([$1], [has_$2],
|
| 29 |
+
[b4_dollar_pushdef([yyval],
|
| 30 |
+
[$1],
|
| 31 |
+
[],
|
| 32 |
+
[yyloc])dnl
|
| 33 |
+
_b4_symbol_case([$1])[]dnl
|
| 34 |
+
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])dnl
|
| 35 |
+
b4_symbol([$1], [$2])
|
| 36 |
+
b4_syncline([@oline@], [@ofile@])dnl
|
| 37 |
+
break;
|
| 38 |
+
|
| 39 |
+
b4_dollar_popdef[]dnl
|
| 40 |
+
])])
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
# b4_use(EXPR)
|
| 44 |
+
# ------------
|
| 45 |
+
# Pacify the compiler about some maybe unused value.
|
| 46 |
+
m4_define([b4_use],
|
| 47 |
+
[])
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
# b4_sync_start(LINE, FILE)
|
| 51 |
+
# -------------------------
|
| 52 |
+
m4_define([b4_sync_start], [[#]line $1 $2])
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
# b4_list2(LIST1, LIST2)
|
| 56 |
+
# ----------------------
|
| 57 |
+
# Join two lists with a comma if necessary.
|
| 58 |
+
m4_define([b4_list2],
|
| 59 |
+
[$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2])
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
# b4_percent_define_get3(DEF, PRE, POST, NOT)
|
| 63 |
+
# -------------------------------------------
|
| 64 |
+
# Expand to the value of DEF surrounded by PRE and POST if it's %define'ed,
|
| 65 |
+
# otherwise NOT.
|
| 66 |
+
m4_define([b4_percent_define_get3],
|
| 67 |
+
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
| 68 |
+
[$2[]b4_percent_define_get([$1])[]$3], [$4])])
|
| 69 |
+
|
| 70 |
+
# b4_percent_define_if_get2(ARG1, ARG2, DEF, NOT)
|
| 71 |
+
# -----------------------------------------------
|
| 72 |
+
# Expand to the value of DEF if ARG1 or ARG2 are %define'ed,
|
| 73 |
+
# otherwise NOT.
|
| 74 |
+
m4_define([b4_percent_define_if_get2],
|
| 75 |
+
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
| 76 |
+
[$3], [m4_ifval(m4_quote(b4_percent_define_get([$2])),
|
| 77 |
+
[$3], [$4])])])
|
| 78 |
+
|
| 79 |
+
# b4_percent_define_class_before_interface(CLASS, INTERFACE)
|
| 80 |
+
# ----------------------------------------------------------
|
| 81 |
+
# Expand to a ', ' if both a class and an interface have been %define'ed
|
| 82 |
+
m4_define([b4_percent_define_class_before_interface],
|
| 83 |
+
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
| 84 |
+
[m4_ifval(m4_quote(b4_percent_define_get([$2])),
|
| 85 |
+
[, ])])])
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
# b4_flag_value(BOOLEAN-FLAG)
|
| 89 |
+
# ---------------------------
|
| 90 |
+
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
# b4_parser_class_declaration
|
| 94 |
+
# ---------------------------
|
| 95 |
+
# The declaration of the parser class ("class YYParser"), with all its
|
| 96 |
+
# qualifiers/annotations.
|
| 97 |
+
b4_percent_define_default([[api.parser.abstract]], [[false]])
|
| 98 |
+
b4_percent_define_default([[api.parser.final]], [[false]])
|
| 99 |
+
b4_percent_define_default([[api.parser.public]], [[false]])
|
| 100 |
+
|
| 101 |
+
m4_define([b4_parser_class_declaration],
|
| 102 |
+
[b4_percent_define_get3([api.parser.annotations], [], [ ])dnl
|
| 103 |
+
b4_percent_define_flag_if([api.parser.public], [public ])dnl
|
| 104 |
+
b4_percent_define_flag_if([api.parser.abstract], [abstract ])dnl
|
| 105 |
+
b4_percent_define_flag_if([api.parser.final], [final ])dnl
|
| 106 |
+
[class ]b4_parser_class[]dnl
|
| 107 |
+
b4_percent_define_if_get2([api.parser.extends], [api.parser.implements], [ : ])dnl
|
| 108 |
+
b4_percent_define_get([api.parser.extends])dnl
|
| 109 |
+
b4_percent_define_class_before_interface([api.parser.extends], [api.parser.implements])dnl
|
| 110 |
+
b4_percent_define_get([api.parser.implements])])
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
# b4_lexer_if(TRUE, FALSE)
|
| 114 |
+
# ------------------------
|
| 115 |
+
m4_define([b4_lexer_if],
|
| 116 |
+
[b4_percent_code_ifdef([[lexer]], [$1], [$2])])
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
# b4_position_type_if(TRUE, FALSE)
|
| 120 |
+
# --------------------------------
|
| 121 |
+
m4_define([b4_position_type_if],
|
| 122 |
+
[b4_percent_define_ifdef([[position_type]], [$1], [$2])])
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
# b4_location_type_if(TRUE, FALSE)
|
| 126 |
+
# --------------------------------
|
| 127 |
+
m4_define([b4_location_type_if],
|
| 128 |
+
[b4_percent_define_ifdef([[location_type]], [$1], [$2])])
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
# b4_identification
|
| 132 |
+
# -----------------
|
| 133 |
+
m4_define([b4_identification],
|
| 134 |
+
[[/** Version number for the Bison executable that generated this parser. */
|
| 135 |
+
public static immutable string yy_bison_version = "]b4_version_string[";
|
| 136 |
+
|
| 137 |
+
/** Name of the skeleton that generated this parser. */
|
| 138 |
+
public static immutable string yy_bison_skeleton = ]b4_skeleton[;
|
| 139 |
+
]])
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
## ------------ ##
|
| 143 |
+
## Data types. ##
|
| 144 |
+
## ------------ ##
|
| 145 |
+
|
| 146 |
+
# b4_int_type(MIN, MAX)
|
| 147 |
+
# ---------------------
|
| 148 |
+
# Return the smallest int type able to handle numbers ranging from
|
| 149 |
+
# MIN to MAX (included).
|
| 150 |
+
m4_define([b4_int_type],
|
| 151 |
+
[m4_if(b4_ints_in($@, [-128], [127]), [1], [byte],
|
| 152 |
+
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
| 153 |
+
[int])])
|
| 154 |
+
|
| 155 |
+
# b4_int_type_for(NAME)
|
| 156 |
+
# ---------------------
|
| 157 |
+
# Return the smallest int type able to handle numbers ranging from
|
| 158 |
+
# `NAME_min' to `NAME_max' (included).
|
| 159 |
+
m4_define([b4_int_type_for],
|
| 160 |
+
[b4_int_type($1_min, $1_max)])
|
| 161 |
+
|
| 162 |
+
# b4_null
|
| 163 |
+
# -------
|
| 164 |
+
m4_define([b4_null], [null])
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
# b4_integral_parser_table_define(NAME, DATA, COMMENT)
|
| 168 |
+
#-----------------------------------------------------
|
| 169 |
+
# Define "yy<TABLE-NAME>" whose contents is CONTENT.
|
| 170 |
+
m4_define([b4_integral_parser_table_define],
|
| 171 |
+
[m4_ifvaln([$3], [b4_comment([$3], [ ])])dnl
|
| 172 |
+
private static immutable b4_int_type_for([$2])[[]] yy$1_ =
|
| 173 |
+
@{
|
| 174 |
+
$2
|
| 175 |
+
@};dnl
|
| 176 |
+
])
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
## ------------- ##
|
| 180 |
+
## Token kinds. ##
|
| 181 |
+
## ------------- ##
|
| 182 |
+
|
| 183 |
+
m4_define([b4_symbol(-2, id)], [[YYEMPTY]])
|
| 184 |
+
b4_percent_define_default([[api.token.raw]], [[true]])
|
| 185 |
+
|
| 186 |
+
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
| 187 |
+
# ---------------------------------------
|
| 188 |
+
# Output the definition of this token as an enum.
|
| 189 |
+
m4_define([b4_token_enum],
|
| 190 |
+
[b4_token_format([ %s = %s,
|
| 191 |
+
], [$1])])
|
| 192 |
+
|
| 193 |
+
# b4_token_enums
|
| 194 |
+
# --------------
|
| 195 |
+
# Output the definition of the tokens as enums.
|
| 196 |
+
m4_define([b4_token_enums],
|
| 197 |
+
[/* Token kinds. */
|
| 198 |
+
public enum TokenKind {
|
| 199 |
+
]b4_symbol(empty, id)[ = -2,
|
| 200 |
+
b4_symbol_foreach([b4_token_enum])dnl
|
| 201 |
+
}
|
| 202 |
+
])
|
| 203 |
+
|
| 204 |
+
# b4_symbol_translate(STRING)
|
| 205 |
+
# ---------------------------
|
| 206 |
+
# Used by "bison" in the array of symbol names to mark those that
|
| 207 |
+
# require translation.
|
| 208 |
+
m4_define([b4_symbol_translate],
|
| 209 |
+
[[_($1)]])
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
# _b4_token_constructor_define(SYMBOL-NUM)
|
| 213 |
+
# ----------------------------------------
|
| 214 |
+
# Define Symbol.FOO for SYMBOL-NUM.
|
| 215 |
+
m4_define([_b4_token_constructor_define],
|
| 216 |
+
[b4_token_visible_if([$1],
|
| 217 |
+
[[
|
| 218 |
+
static auto ]b4_symbol([$1], [id])[(]b4_symbol_if([$1], [has_type],
|
| 219 |
+
[b4_union_if([b4_symbol([$1], [type]],
|
| 220 |
+
[[typeof(YYSemanticType.]b4_symbol([$1], [type])[]])) [val]])dnl
|
| 221 |
+
[]b4_locations_if([b4_symbol_if([$1], [has_type], [[, ]])[Location l]])[)
|
| 222 |
+
{
|
| 223 |
+
return Symbol(TokenKind.]b4_symbol([$1], [id])[]b4_symbol_if([$1], [has_type],
|
| 224 |
+
[[, val]])[]b4_locations_if([[, l]])[);
|
| 225 |
+
}]])])
|
| 226 |
+
|
| 227 |
+
# b4_token_constructor_define
|
| 228 |
+
# ---------------------------
|
| 229 |
+
# Define Symbol.FOO for each token kind FOO.
|
| 230 |
+
m4_define([b4_token_constructor_define],
|
| 231 |
+
[[
|
| 232 |
+
/* Implementation of token constructors for each symbol type visible to
|
| 233 |
+
* the user. The code generates static methods that have the same names
|
| 234 |
+
* as the TokenKinds.
|
| 235 |
+
*/]b4_symbol_foreach([_b4_token_constructor_define])dnl
|
| 236 |
+
])
|
| 237 |
+
|
| 238 |
+
## -------------- ##
|
| 239 |
+
## Symbol kinds. ##
|
| 240 |
+
## -------------- ##
|
| 241 |
+
|
| 242 |
+
# b4_symbol_kind(NUM)
|
| 243 |
+
# -------------------
|
| 244 |
+
m4_define([b4_symbol_kind],
|
| 245 |
+
[SymbolKind.b4_symbol_kind_base($@)])
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
# b4_symbol_enum(SYMBOL-NUM)
|
| 249 |
+
# --------------------------
|
| 250 |
+
# Output the definition of this symbol as an enum.
|
| 251 |
+
m4_define([b4_symbol_enum],
|
| 252 |
+
[m4_format([ %-30s %s],
|
| 253 |
+
m4_format([[%s = %s,]],
|
| 254 |
+
b4_symbol([$1], [kind_base]),
|
| 255 |
+
[$1]),
|
| 256 |
+
[b4_symbol_tag_comment([$1])])])
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
# b4_declare_symbol_enum
|
| 260 |
+
# ----------------------
|
| 261 |
+
# The definition of the symbol internal numbers as an enum.
|
| 262 |
+
# Defining YYEMPTY here is important: it forces the compiler
|
| 263 |
+
# to use a signed type, which matters for yytoken.
|
| 264 |
+
m4_define([b4_declare_symbol_enum],
|
| 265 |
+
[[ /* Symbol kinds. */
|
| 266 |
+
struct SymbolKind
|
| 267 |
+
{
|
| 268 |
+
enum
|
| 269 |
+
{
|
| 270 |
+
]b4_symbol(empty, kind_base)[ = -2, /* No symbol. */
|
| 271 |
+
]b4_symbol_foreach([b4_symbol_enum])dnl
|
| 272 |
+
[ }
|
| 273 |
+
|
| 274 |
+
private int yycode_;
|
| 275 |
+
alias yycode_ this;
|
| 276 |
+
|
| 277 |
+
this(int code)
|
| 278 |
+
{
|
| 279 |
+
yycode_ = code;
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
/* Return YYSTR after stripping away unnecessary quotes and
|
| 283 |
+
backslashes, so that it's suitable for yyerror. The heuristic is
|
| 284 |
+
that double-quoting is unnecessary unless the string contains an
|
| 285 |
+
apostrophe, a comma, or backslash (other than backslash-backslash).
|
| 286 |
+
YYSTR is taken from yytname. */
|
| 287 |
+
final void toString(W)(W sink) const
|
| 288 |
+
if (isOutputRange!(W, char))
|
| 289 |
+
{
|
| 290 |
+
immutable string[] yy_sname = @{
|
| 291 |
+
]b4_symbol_names[
|
| 292 |
+
@};]b4_has_translations_if([[
|
| 293 |
+
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
|
| 294 |
+
internationalizable. */
|
| 295 |
+
immutable ]b4_int_type_for([b4_translatable])[[] yytranslatable = @{
|
| 296 |
+
]b4_translatable[
|
| 297 |
+
@};]])[
|
| 298 |
+
|
| 299 |
+
put(sink, yy_sname[yycode_]);
|
| 300 |
+
}
|
| 301 |
+
}
|
| 302 |
+
]])
|
| 303 |
+
|
| 304 |
+
|
| 305 |
+
# b4_case(ID, CODE, [COMMENTS])
|
| 306 |
+
# -----------------------------
|
| 307 |
+
m4_define([b4_case], [ case $1:m4_ifval([$3], [ b4_comment([$3])])
|
| 308 |
+
$2
|
| 309 |
+
break;])
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
## ---------------- ##
|
| 313 |
+
## Default values. ##
|
| 314 |
+
## ---------------- ##
|
| 315 |
+
|
| 316 |
+
m4_define([b4_yystype], [b4_percent_define_get([[stype]])])
|
| 317 |
+
b4_percent_define_default([[stype]], [[YYSemanticType]])])
|
| 318 |
+
|
| 319 |
+
# %name-prefix
|
| 320 |
+
m4_define_default([b4_prefix], [[YY]])
|
| 321 |
+
|
| 322 |
+
b4_percent_define_default([[api.parser.class]], [b4_prefix[]Parser])])
|
| 323 |
+
m4_define([b4_parser_class], [b4_percent_define_get([[api.parser.class]])])
|
| 324 |
+
|
| 325 |
+
#b4_percent_define_default([[location_type]], [Location])])
|
| 326 |
+
m4_define([b4_location_type], b4_percent_define_ifdef([[location_type]],[b4_percent_define_get([[location_type]])],[YYLocation]))
|
| 327 |
+
|
| 328 |
+
#b4_percent_define_default([[position_type]], [Position])])
|
| 329 |
+
m4_define([b4_position_type], b4_percent_define_ifdef([[position_type]],[b4_percent_define_get([[position_type]])],[YYPosition]))
|
| 330 |
+
|
| 331 |
+
|
| 332 |
+
## ---------------- ##
|
| 333 |
+
## api.value.type. ##
|
| 334 |
+
## ---------------- ##
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
# ---------------------- #
|
| 338 |
+
# api.value.type=union. #
|
| 339 |
+
# ---------------------- #
|
| 340 |
+
|
| 341 |
+
# b4_symbol_type_register(SYMBOL-NUM)
|
| 342 |
+
# -----------------------------------
|
| 343 |
+
# Symbol SYMBOL-NUM has a type (for union) instead of a type-tag.
|
| 344 |
+
# Extend the definition of %union's body (b4_union_members) with a
|
| 345 |
+
# field of that type, and extend the symbol's "type" field to point to
|
| 346 |
+
# the field name, instead of the type name.
|
| 347 |
+
m4_define([b4_symbol_type_register],
|
| 348 |
+
[m4_define([b4_symbol($1, type_tag)],
|
| 349 |
+
[b4_symbol_if([$1], [has_id],
|
| 350 |
+
[b4_symbol([$1], [id])],
|
| 351 |
+
[yykind_[]b4_symbol([$1], [number])])])dnl
|
| 352 |
+
m4_append([b4_union_members],
|
| 353 |
+
m4_expand([m4_format([ %-40s %s],
|
| 354 |
+
m4_expand([b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);]),
|
| 355 |
+
[b4_symbol_tag_comment([$1])])]))
|
| 356 |
+
])
|
| 357 |
+
|
| 358 |
+
|
| 359 |
+
# b4_type_define_tag(SYMBOL1-NUM, ...)
|
| 360 |
+
# ------------------------------------
|
| 361 |
+
# For the batch of symbols SYMBOL1-NUM... (which all have the same
|
| 362 |
+
# type), enhance the %union definition for each of them, and set
|
| 363 |
+
# there "type" field to the field tag name, instead of the type name.
|
| 364 |
+
m4_define([b4_type_define_tag],
|
| 365 |
+
[b4_symbol_if([$1], [has_type],
|
| 366 |
+
[m4_map([b4_symbol_type_register], [$@])])
|
| 367 |
+
])
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
# b4_symbol_value_union(VAL, SYMBOL-NUM, [TYPE])
|
| 371 |
+
# ----------------------------------------------
|
| 372 |
+
# Same of b4_symbol_value, but when api.value.type=union.
|
| 373 |
+
m4_define([b4_symbol_value_union],
|
| 374 |
+
[m4_ifval([$3],
|
| 375 |
+
[(*($3*)(&$1))],
|
| 376 |
+
[m4_ifval([$2],
|
| 377 |
+
[b4_symbol_if([$2], [has_type],
|
| 378 |
+
[($1.b4_symbol([$2], [type_tag]))],
|
| 379 |
+
[$1])],
|
| 380 |
+
[$1])])])
|
| 381 |
+
|
| 382 |
+
|
| 383 |
+
# b4_value_type_setup_union
|
| 384 |
+
# -------------------------
|
| 385 |
+
# Setup support for api.value.type=union. Symbols are defined with a
|
| 386 |
+
# type instead of a union member name: build the corresponding union,
|
| 387 |
+
# and give the symbols their tag.
|
| 388 |
+
m4_define([b4_value_type_setup_union],
|
| 389 |
+
[m4_define([b4_union_members])
|
| 390 |
+
b4_type_foreach([b4_type_define_tag])
|
| 391 |
+
m4_copy_force([b4_symbol_value_union], [b4_symbol_value])
|
| 392 |
+
])
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
# _b4_value_type_setup_keyword
|
| 396 |
+
# ----------------------------
|
| 397 |
+
# api.value.type is defined with a keyword/string syntax. Check if
|
| 398 |
+
# that is properly defined, and prepare its use.
|
| 399 |
+
m4_define([_b4_value_type_setup_keyword],
|
| 400 |
+
[b4_percent_define_check_values([[[[api.value.type]],
|
| 401 |
+
[[none]],
|
| 402 |
+
[[union]],
|
| 403 |
+
[[union-directive]],
|
| 404 |
+
[[yystype]]]])dnl
|
| 405 |
+
m4_case(b4_percent_define_get([[api.value.type]]),
|
| 406 |
+
[union], [b4_value_type_setup_union])])
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
# b4_value_type_setup
|
| 410 |
+
# -------------------
|
| 411 |
+
# Check if api.value.type is properly defined, and possibly prepare
|
| 412 |
+
# its use.
|
| 413 |
+
b4_define_silent([b4_value_type_setup],
|
| 414 |
+
[
|
| 415 |
+
# Define default value.
|
| 416 |
+
b4_percent_define_ifdef([[api.value.type]], [],
|
| 417 |
+
[# %union => api.value.type=union-directive
|
| 418 |
+
m4_ifdef([b4_union_members],
|
| 419 |
+
[m4_define([b4_percent_define_kind(api.value.type)], [keyword])
|
| 420 |
+
m4_define([b4_percent_define(api.value.type)], [union-directive])],
|
| 421 |
+
[# no tag seen => api.value.type={int}
|
| 422 |
+
m4_if(b4_tag_seen_flag, 0,
|
| 423 |
+
[m4_define([b4_percent_define_kind(api.value.type)], [code])
|
| 424 |
+
m4_define([b4_percent_define(api.value.type)], [int])],
|
| 425 |
+
[# otherwise api.value.type=yystype
|
| 426 |
+
m4_define([b4_percent_define_kind(api.value.type)], [keyword])
|
| 427 |
+
m4_define([b4_percent_define(api.value.type)], [yystype])])])])
|
| 428 |
+
|
| 429 |
+
# Set up.
|
| 430 |
+
m4_bmatch(b4_percent_define_get_kind([[api.value.type]]),
|
| 431 |
+
[keyword], [_b4_value_type_setup_keyword])
|
| 432 |
+
])
|
| 433 |
+
|
| 434 |
+
|
| 435 |
+
## ----------------- ##
|
| 436 |
+
## Semantic Values. ##
|
| 437 |
+
## ----------------- ##
|
| 438 |
+
|
| 439 |
+
|
| 440 |
+
# b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
|
| 441 |
+
# ----------------------------------------------
|
| 442 |
+
# See README. FIXME: factor in c-like?
|
| 443 |
+
m4_define([b4_symbol_value],
|
| 444 |
+
[m4_ifval([$3],
|
| 445 |
+
[($1.$3)],
|
| 446 |
+
[m4_ifval([$2],
|
| 447 |
+
[b4_symbol_if([$2], [has_type],
|
| 448 |
+
[($1.b4_symbol([$2], [type]))],
|
| 449 |
+
[$1])],
|
| 450 |
+
[$1])])])
|
| 451 |
+
|
| 452 |
+
# b4_lhs_value(SYMBOL-NUM, [TYPE])
|
| 453 |
+
# --------------------------------
|
| 454 |
+
# See README.
|
| 455 |
+
m4_define([b4_lhs_value],
|
| 456 |
+
[b4_symbol_value([yyval], [$1], [$2])])
|
| 457 |
+
|
| 458 |
+
|
| 459 |
+
# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
|
| 460 |
+
# --------------------------------------------------
|
| 461 |
+
# See README.
|
| 462 |
+
#
|
| 463 |
+
# In this simple implementation, %token and %type have class names
|
| 464 |
+
# between the angle brackets.
|
| 465 |
+
m4_define([b4_rhs_value],
|
| 466 |
+
[b4_symbol_value([(yystack.valueAt (b4_subtract([$1], [$2])))], [$3], [$4])])
|
| 467 |
+
|
| 468 |
+
|
| 469 |
+
# b4_lhs_location()
|
| 470 |
+
# -----------------
|
| 471 |
+
# Expansion of @$.
|
| 472 |
+
m4_define([b4_lhs_location],
|
| 473 |
+
[(yyloc)])
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
# b4_rhs_location(RULE-LENGTH, POS)
|
| 477 |
+
# ---------------------------------
|
| 478 |
+
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
| 479 |
+
# on RHS.
|
| 480 |
+
m4_define([b4_rhs_location],
|
| 481 |
+
[yystack.locationAt (b4_subtract($@))])
|
| 482 |
+
|
| 483 |
+
|
| 484 |
+
# b4_lex_param
|
| 485 |
+
# b4_parse_param
|
| 486 |
+
# --------------
|
| 487 |
+
# If defined, b4_lex_param arrives double quoted, but below we prefer
|
| 488 |
+
# it to be single quoted. Same for b4_parse_param.
|
| 489 |
+
|
| 490 |
+
# TODO: should be in bison.m4
|
| 491 |
+
m4_define_default([b4_lex_param], [[]]))
|
| 492 |
+
m4_define([b4_lex_param], b4_lex_param))
|
| 493 |
+
m4_define([b4_parse_param], b4_parse_param))
|
| 494 |
+
|
| 495 |
+
# b4_lex_param_decl
|
| 496 |
+
# -------------------
|
| 497 |
+
# Extra formal arguments of the constructor.
|
| 498 |
+
m4_define([b4_lex_param_decl],
|
| 499 |
+
[m4_ifset([b4_lex_param],
|
| 500 |
+
[b4_remove_comma([$1],
|
| 501 |
+
b4_param_decls(b4_lex_param))],
|
| 502 |
+
[$1])])
|
| 503 |
+
|
| 504 |
+
m4_define([b4_param_decls],
|
| 505 |
+
[m4_map([b4_param_decl], [$@])])
|
| 506 |
+
m4_define([b4_param_decl], [, $1])
|
| 507 |
+
|
| 508 |
+
m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])
|
| 509 |
+
|
| 510 |
+
|
| 511 |
+
|
| 512 |
+
# b4_parse_param_decl
|
| 513 |
+
# -------------------
|
| 514 |
+
# Extra formal arguments of the constructor.
|
| 515 |
+
m4_define([b4_parse_param_decl],
|
| 516 |
+
[m4_ifset([b4_parse_param],
|
| 517 |
+
[b4_remove_comma([$1],
|
| 518 |
+
b4_param_decls(b4_parse_param))],
|
| 519 |
+
[$1])])
|
| 520 |
+
|
| 521 |
+
|
| 522 |
+
|
| 523 |
+
# b4_lex_param_call
|
| 524 |
+
# -------------------
|
| 525 |
+
# Delegating the lexer parameters to the lexer constructor.
|
| 526 |
+
m4_define([b4_lex_param_call],
|
| 527 |
+
[m4_ifset([b4_lex_param],
|
| 528 |
+
[b4_remove_comma([$1],
|
| 529 |
+
b4_param_calls(b4_lex_param))],
|
| 530 |
+
[$1])])
|
| 531 |
+
m4_define([b4_param_calls],
|
| 532 |
+
[m4_map([b4_param_call], [$@])])
|
| 533 |
+
m4_define([b4_param_call], [, $2])
|
| 534 |
+
|
| 535 |
+
|
| 536 |
+
|
| 537 |
+
# b4_parse_param_cons
|
| 538 |
+
# -------------------
|
| 539 |
+
# Extra initialisations of the constructor.
|
| 540 |
+
m4_define([b4_parse_param_cons],
|
| 541 |
+
[m4_ifset([b4_parse_param],
|
| 542 |
+
[b4_constructor_calls(b4_parse_param)])])
|
| 543 |
+
|
| 544 |
+
m4_define([b4_constructor_calls],
|
| 545 |
+
[m4_map([b4_constructor_call], [$@])])
|
| 546 |
+
m4_define([b4_constructor_call],
|
| 547 |
+
[this.$2 = $2;
|
| 548 |
+
])
|
| 549 |
+
|
| 550 |
+
|
| 551 |
+
|
| 552 |
+
# b4_parse_param_vars
|
| 553 |
+
# -------------------
|
| 554 |
+
# Extra instance variables.
|
| 555 |
+
m4_define([b4_parse_param_vars],
|
| 556 |
+
[m4_ifset([b4_parse_param],
|
| 557 |
+
[
|
| 558 |
+
/* User arguments. */
|
| 559 |
+
b4_var_decls(b4_parse_param)])])
|
| 560 |
+
|
| 561 |
+
m4_define([b4_var_decls],
|
| 562 |
+
[m4_map_sep([b4_var_decl], [
|
| 563 |
+
], [$@])])
|
| 564 |
+
m4_define([b4_var_decl],
|
| 565 |
+
[ protected $1;])
|
| 566 |
+
|
| 567 |
+
|
| 568 |
+
# b4_public_types_declare
|
| 569 |
+
# -----------------------
|
| 570 |
+
# Define the public types: token, semantic value, location, and so forth.
|
| 571 |
+
# Depending on %define token_lex, may be output in the header or source file.
|
| 572 |
+
m4_define([b4_public_types_declare],
|
| 573 |
+
[[
|
| 574 |
+
alias Symbol = ]b4_parser_class[.Symbol;
|
| 575 |
+
alias Value = ]b4_yystype[;]b4_locations_if([[
|
| 576 |
+
alias Location = ]b4_location_type[;
|
| 577 |
+
alias Position = ]b4_position_type[;]b4_push_if([[
|
| 578 |
+
alias PUSH_MORE = ]b4_parser_class[.YYPUSH_MORE;
|
| 579 |
+
alias ABORT = ]b4_parser_class[.YYABORT;
|
| 580 |
+
alias ACCEPT = ]b4_parser_class[.YYACCEPT;]])[]])[
|
| 581 |
+
]])
|
| 582 |
+
|
| 583 |
+
|
| 584 |
+
# b4_basic_symbol_constructor_define
|
| 585 |
+
# ----------------------------------
|
| 586 |
+
# Create Symbol struct constructors for all the visible types.
|
| 587 |
+
m4_define([b4_basic_symbol_constructor_define],
|
| 588 |
+
[b4_token_visible_if([$1],
|
| 589 |
+
[[ this(TokenKind token]b4_symbol_if([$1], [has_type],
|
| 590 |
+
[[, ]b4_union_if([], [[typeof(YYSemanticType.]])b4_symbol([$1], [type])dnl
|
| 591 |
+
[]b4_union_if([], [[) ]])[ val]])[]b4_locations_if([[, Location loc]])[)
|
| 592 |
+
{
|
| 593 |
+
kind = yytranslate_(token);]b4_union_if([b4_symbol_if([$1], [has_type], [[
|
| 594 |
+
static foreach (member; __traits(allMembers, YYSemanticType))
|
| 595 |
+
{
|
| 596 |
+
static if (is(typeof(mixin("value_." ~ member)) == ]b4_symbol([$1], [type])[))
|
| 597 |
+
{
|
| 598 |
+
mixin("value_." ~ member ~ " = val;");
|
| 599 |
+
}
|
| 600 |
+
}]])], [b4_symbol_if([$1], [has_type], [[
|
| 601 |
+
value_.]b4_symbol([$1], [type])[ = val;]])])[]b4_locations_if([
|
| 602 |
+
location_ = loc;])[
|
| 603 |
+
}
|
| 604 |
+
]])])
|
| 605 |
+
|
| 606 |
+
|
| 607 |
+
# b4_symbol_type_define
|
| 608 |
+
# ---------------------
|
| 609 |
+
# Define symbol_type, the external type for symbols used for symbol
|
| 610 |
+
# constructors.
|
| 611 |
+
m4_define([b4_symbol_type_define],
|
| 612 |
+
[[
|
| 613 |
+
/**
|
| 614 |
+
* A complete symbol
|
| 615 |
+
*/
|
| 616 |
+
struct Symbol
|
| 617 |
+
{
|
| 618 |
+
private SymbolKind kind;
|
| 619 |
+
private Value value_;]b4_locations_if([[
|
| 620 |
+
private Location location_;]])[
|
| 621 |
+
|
| 622 |
+
]b4_type_foreach([b4_basic_symbol_constructor_define])[
|
| 623 |
+
SymbolKind token() { return kind; }
|
| 624 |
+
Value value() { return value_; }]b4_locations_if([[
|
| 625 |
+
Location location() { return location_; }]])[
|
| 626 |
+
]b4_token_ctor_if([b4_token_constructor_define])[
|
| 627 |
+
}
|
| 628 |
+
]])
|
platform/dbops/binaries/build/share/bison/skeletons/glr.c
ADDED
|
@@ -0,0 +1,2763 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- C -*-
|
| 2 |
+
|
| 3 |
+
# GLR skeleton for Bison
|
| 4 |
+
|
| 5 |
+
# Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc.
|
| 6 |
+
|
| 7 |
+
# This program is free software: you can redistribute it and/or modify
|
| 8 |
+
# it under the terms of the GNU General Public License as published by
|
| 9 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 10 |
+
# (at your option) any later version.
|
| 11 |
+
#
|
| 12 |
+
# This program is distributed in the hope that it will be useful,
|
| 13 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
# GNU General Public License for more details.
|
| 16 |
+
#
|
| 17 |
+
# You should have received a copy of the GNU General Public License
|
| 18 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# If we are loaded by glr.cc, do not override c++.m4 definitions by
|
| 22 |
+
# those of c.m4.
|
| 23 |
+
m4_if(b4_skeleton, ["glr.c"],
|
| 24 |
+
[m4_include(b4_skeletonsdir/[c.m4])])
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
## ---------------- ##
|
| 28 |
+
## Default values. ##
|
| 29 |
+
## ---------------- ##
|
| 30 |
+
|
| 31 |
+
# Stack parameters.
|
| 32 |
+
m4_define_default([b4_stack_depth_max], [10000])
|
| 33 |
+
m4_define_default([b4_stack_depth_init], [200])
|
| 34 |
+
|
| 35 |
+
# Included header.
|
| 36 |
+
b4_percent_define_default([[api.header.include]],
|
| 37 |
+
[["@basename(]b4_spec_header_file[@)"]])
|
| 38 |
+
|
| 39 |
+
## ------------------------ ##
|
| 40 |
+
## Pure/impure interfaces. ##
|
| 41 |
+
## ------------------------ ##
|
| 42 |
+
|
| 43 |
+
b4_define_flag_if([pure])
|
| 44 |
+
# If glr.cc is including this file and thus has already set b4_pure_flag,
|
| 45 |
+
# do not change the value of b4_pure_flag, and do not record a use of api.pure.
|
| 46 |
+
m4_ifndef([b4_pure_flag],
|
| 47 |
+
[b4_percent_define_default([[api.pure]], [[false]])
|
| 48 |
+
m4_define([b4_pure_flag],
|
| 49 |
+
[b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])])])
|
| 50 |
+
|
| 51 |
+
# b4_yyerror_args
|
| 52 |
+
# ---------------
|
| 53 |
+
# Optional effective arguments passed to yyerror: user args plus yylloc, and
|
| 54 |
+
# a trailing comma.
|
| 55 |
+
m4_define([b4_yyerror_args],
|
| 56 |
+
[b4_pure_if([b4_locations_if([yylocp, ])])dnl
|
| 57 |
+
m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])])
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
# b4_lyyerror_args
|
| 61 |
+
# ----------------
|
| 62 |
+
# Same as above, but on the lookahead, hence &yylloc instead of yylocp.
|
| 63 |
+
m4_define([b4_lyyerror_args],
|
| 64 |
+
[b4_pure_if([b4_locations_if([&yylloc, ])])dnl
|
| 65 |
+
m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])])
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
# b4_pure_args
|
| 69 |
+
# ------------
|
| 70 |
+
# Same as b4_yyerror_args, but with a leading comma.
|
| 71 |
+
m4_define([b4_pure_args],
|
| 72 |
+
[b4_pure_if([b4_locations_if([, yylocp])])[]b4_user_args])
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
# b4_lpure_args
|
| 76 |
+
# -------------
|
| 77 |
+
# Same as above, but on the lookahead, hence &yylloc instead of yylocp.
|
| 78 |
+
m4_define([b4_lpure_args],
|
| 79 |
+
[b4_pure_if([b4_locations_if([, &yylloc])])[]b4_user_args])
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
# b4_pure_formals
|
| 84 |
+
# ---------------
|
| 85 |
+
# Arguments passed to yyerror: user formals plus yylocp with leading comma.
|
| 86 |
+
m4_define([b4_pure_formals],
|
| 87 |
+
[b4_pure_if([b4_locations_if([, YYLTYPE *yylocp])])[]b4_user_formals])
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
# b4_locuser_formals(LOC = yylocp)
|
| 91 |
+
# --------------------------------
|
| 92 |
+
# User formal arguments, possibly preceded by location argument.
|
| 93 |
+
m4_define([b4_locuser_formals],
|
| 94 |
+
[b4_locations_if([, YYLTYPE *m4_default([$1], [yylocp])])[]b4_user_formals])
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
# b4_locuser_args(LOC = yylocp)
|
| 98 |
+
# -----------------------------
|
| 99 |
+
m4_define([b4_locuser_args],
|
| 100 |
+
[b4_locations_if([, m4_default([$1], [yylocp])])[]b4_user_args])
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
## ----------------- ##
|
| 105 |
+
## Semantic Values. ##
|
| 106 |
+
## ----------------- ##
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
# b4_lhs_value(SYMBOL-NUM, [TYPE])
|
| 110 |
+
# --------------------------------
|
| 111 |
+
# See README.
|
| 112 |
+
m4_define([b4_lhs_value],
|
| 113 |
+
[b4_symbol_value([(*yyvalp)], [$1], [$2])])
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
# b4_rhs_data(RULE-LENGTH, POS)
|
| 117 |
+
# -----------------------------
|
| 118 |
+
# See README.
|
| 119 |
+
m4_define([b4_rhs_data],
|
| 120 |
+
[YY_CAST (yyGLRStackItem const *, yyvsp)@{YYFILL (b4_subtract([$2], [$1]))@}.yystate])
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
|
| 124 |
+
# --------------------------------------------------
|
| 125 |
+
# Expansion of $$ or $<TYPE>$, for symbol SYMBOL-NUM.
|
| 126 |
+
m4_define([b4_rhs_value],
|
| 127 |
+
[b4_symbol_value([b4_rhs_data([$1], [$2]).yysemantics.yyval], [$3], [$4])])
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
## ----------- ##
|
| 132 |
+
## Locations. ##
|
| 133 |
+
## ----------- ##
|
| 134 |
+
|
| 135 |
+
# b4_lhs_location()
|
| 136 |
+
# -----------------
|
| 137 |
+
# Expansion of @$.
|
| 138 |
+
m4_define([b4_lhs_location],
|
| 139 |
+
[(*yylocp)])
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
# b4_rhs_location(RULE-LENGTH, NUM)
|
| 143 |
+
# ---------------------------------
|
| 144 |
+
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
|
| 145 |
+
# on RHS.
|
| 146 |
+
m4_define([b4_rhs_location],
|
| 147 |
+
[(b4_rhs_data([$1], [$2]).yyloc)])
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
# b4_call_merger(MERGER-NUM, MERGER-NAME, SYMBOL-SUM)
|
| 151 |
+
# ---------------------------------------------------
|
| 152 |
+
m4_define([b4_call_merger],
|
| 153 |
+
[b4_case([$1],
|
| 154 |
+
[ b4_symbol_if([$3], [has_type],
|
| 155 |
+
[yy0->b4_symbol($3, slot) = $2 (*yy0, *yy1);],
|
| 156 |
+
[*yy0 = $2 (*yy0, *yy1);])])])
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
## -------------- ##
|
| 160 |
+
## Declarations. ##
|
| 161 |
+
## -------------- ##
|
| 162 |
+
|
| 163 |
+
# b4_shared_declarations
|
| 164 |
+
# ----------------------
|
| 165 |
+
# Declaration that might either go into the header (if --header)
|
| 166 |
+
# or open coded in the parser body. glr.cc has its own definition.
|
| 167 |
+
m4_if(b4_skeleton, ["glr.c"],
|
| 168 |
+
[m4_define([b4_shared_declarations],
|
| 169 |
+
[b4_declare_yydebug[
|
| 170 |
+
]b4_percent_code_get([[requires]])[
|
| 171 |
+
]b4_token_enums[
|
| 172 |
+
]b4_declare_yylstype[
|
| 173 |
+
int ]b4_prefix[parse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[);
|
| 174 |
+
]b4_percent_code_get([[provides]])[]dnl
|
| 175 |
+
])
|
| 176 |
+
])
|
| 177 |
+
|
| 178 |
+
## -------------- ##
|
| 179 |
+
## Output files. ##
|
| 180 |
+
## -------------- ##
|
| 181 |
+
|
| 182 |
+
# Unfortunately the order of generation between the header and the
|
| 183 |
+
# implementation file matters (for glr.c) because of the current
|
| 184 |
+
# implementation of api.value.type=union. In that case we still use a
|
| 185 |
+
# union for YYSTYPE, but we generate the contents of this union when
|
| 186 |
+
# setting up YYSTYPE. This is needed for other aspects, such as
|
| 187 |
+
# defining yy_symbol_value_print, since we need to now the name of the
|
| 188 |
+
# members of this union.
|
| 189 |
+
#
|
| 190 |
+
# To avoid this issue, just generate the header before the
|
| 191 |
+
# implementation file. But we should also make them more independent.
|
| 192 |
+
|
| 193 |
+
# ----------------- #
|
| 194 |
+
# The header file. #
|
| 195 |
+
# ----------------- #
|
| 196 |
+
|
| 197 |
+
# glr.cc produces its own header.
|
| 198 |
+
b4_glr_cc_if([],
|
| 199 |
+
[b4_header_if(
|
| 200 |
+
[b4_output_begin([b4_spec_header_file])
|
| 201 |
+
b4_copyright([Skeleton interface for Bison GLR parsers in C],
|
| 202 |
+
[2002-2015, 2018-2021])[
|
| 203 |
+
]b4_cpp_guard_open([b4_spec_mapped_header_file])[
|
| 204 |
+
]b4_shared_declarations[
|
| 205 |
+
]b4_cpp_guard_close([b4_spec_mapped_header_file])[
|
| 206 |
+
]b4_output_end[
|
| 207 |
+
]])])
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
# ------------------------- #
|
| 211 |
+
# The implementation file. #
|
| 212 |
+
# ------------------------- #
|
| 213 |
+
|
| 214 |
+
b4_output_begin([b4_parser_file_name])
|
| 215 |
+
b4_copyright([Skeleton implementation for Bison GLR parsers in C],
|
| 216 |
+
[2002-2015, 2018-2021])[
|
| 217 |
+
/* C GLR parser skeleton written by Paul Hilfinger. */
|
| 218 |
+
|
| 219 |
+
]b4_disclaimer[
|
| 220 |
+
]b4_identification[
|
| 221 |
+
|
| 222 |
+
]b4_percent_code_get([[top]])[
|
| 223 |
+
]m4_if(b4_api_prefix, [yy], [],
|
| 224 |
+
[[/* Substitute the type names. */
|
| 225 |
+
#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
|
| 226 |
+
#define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
|
| 227 |
+
]m4_if(b4_prefix, [yy], [],
|
| 228 |
+
[[/* Substitute the variable and function names. */
|
| 229 |
+
#define ]b4_glr_cc_if([yy_parse_impl], [yyparse])[ ]b4_prefix[]b4_glr_cc_if([_parse_impl], [parse])[
|
| 230 |
+
#define yylex ]b4_prefix[lex
|
| 231 |
+
#define yyerror ]b4_prefix[error
|
| 232 |
+
#define yydebug ]b4_prefix[debug]]b4_pure_if([], [[
|
| 233 |
+
#define yylval ]b4_prefix[lval
|
| 234 |
+
#define yychar ]b4_prefix[char
|
| 235 |
+
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
|
| 236 |
+
#define yylloc ]b4_prefix[lloc]])]))[
|
| 237 |
+
|
| 238 |
+
]b4_user_pre_prologue[
|
| 239 |
+
]b4_cast_define[
|
| 240 |
+
]b4_null_define[
|
| 241 |
+
|
| 242 |
+
]b4_header_if([[#include ]b4_percent_define_get([[api.header.include]])],
|
| 243 |
+
[b4_shared_declarations])[
|
| 244 |
+
|
| 245 |
+
]b4_glr_cc_if([b4_glr_cc_setup],
|
| 246 |
+
[b4_declare_symbol_enum])[
|
| 247 |
+
|
| 248 |
+
/* Default (constant) value used for initialization for null
|
| 249 |
+
right-hand sides. Unlike the standard yacc.c template, here we set
|
| 250 |
+
the default value of $$ to a zeroed-out value. Since the default
|
| 251 |
+
value is undefined, this behavior is technically correct. */
|
| 252 |
+
static YYSTYPE yyval_default;]b4_locations_if([[
|
| 253 |
+
static YYLTYPE yyloc_default][]b4_yyloc_default;])[
|
| 254 |
+
|
| 255 |
+
]b4_user_post_prologue[
|
| 256 |
+
]b4_percent_code_get[]dnl
|
| 257 |
+
|
| 258 |
+
[#include <stddef.h>
|
| 259 |
+
#include <stdint.h>
|
| 260 |
+
#include <stdio.h>
|
| 261 |
+
#include <stdlib.h>
|
| 262 |
+
#include <string.h>
|
| 263 |
+
|
| 264 |
+
]b4_c99_int_type_define[
|
| 265 |
+
]b4_sizes_types_define[
|
| 266 |
+
|
| 267 |
+
#ifndef YY_
|
| 268 |
+
# if defined YYENABLE_NLS && YYENABLE_NLS
|
| 269 |
+
# if ENABLE_NLS
|
| 270 |
+
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
|
| 271 |
+
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
|
| 272 |
+
# endif
|
| 273 |
+
# endif
|
| 274 |
+
# ifndef YY_
|
| 275 |
+
# define YY_(Msgid) Msgid
|
| 276 |
+
# endif
|
| 277 |
+
#endif
|
| 278 |
+
]b4_has_translations_if([
|
| 279 |
+
#ifndef N_
|
| 280 |
+
# define N_(Msgid) Msgid
|
| 281 |
+
#endif
|
| 282 |
+
])[
|
| 283 |
+
|
| 284 |
+
#ifndef YYFREE
|
| 285 |
+
# define YYFREE free
|
| 286 |
+
#endif
|
| 287 |
+
#ifndef YYMALLOC
|
| 288 |
+
# define YYMALLOC malloc
|
| 289 |
+
#endif
|
| 290 |
+
#ifndef YYREALLOC
|
| 291 |
+
# define YYREALLOC realloc
|
| 292 |
+
#endif
|
| 293 |
+
|
| 294 |
+
#ifdef __cplusplus
|
| 295 |
+
typedef bool yybool;
|
| 296 |
+
# define yytrue true
|
| 297 |
+
# define yyfalse false
|
| 298 |
+
#else
|
| 299 |
+
/* When we move to stdbool, get rid of the various casts to yybool. */
|
| 300 |
+
typedef signed char yybool;
|
| 301 |
+
# define yytrue 1
|
| 302 |
+
# define yyfalse 0
|
| 303 |
+
#endif
|
| 304 |
+
|
| 305 |
+
#ifndef YYSETJMP
|
| 306 |
+
# include <setjmp.h>
|
| 307 |
+
# define YYJMP_BUF jmp_buf
|
| 308 |
+
# define YYSETJMP(Env) setjmp (Env)
|
| 309 |
+
/* Pacify Clang and ICC. */
|
| 310 |
+
# define YYLONGJMP(Env, Val) \
|
| 311 |
+
do { \
|
| 312 |
+
longjmp (Env, Val); \
|
| 313 |
+
YY_ASSERT (0); \
|
| 314 |
+
} while (yyfalse)
|
| 315 |
+
#endif
|
| 316 |
+
|
| 317 |
+
]b4_attribute_define([noreturn])[
|
| 318 |
+
|
| 319 |
+
]b4_parse_assert_if([[#ifdef NDEBUG
|
| 320 |
+
# define YY_ASSERT(E) ((void) (0 && (E)))
|
| 321 |
+
#else
|
| 322 |
+
# include <assert.h> /* INFRINGES ON USER NAME SPACE */
|
| 323 |
+
# define YY_ASSERT(E) assert (E)
|
| 324 |
+
#endif
|
| 325 |
+
]],
|
| 326 |
+
[[#define YY_ASSERT(E) ((void) (0 && (E)))]])[
|
| 327 |
+
|
| 328 |
+
/* YYFINAL -- State number of the termination state. */
|
| 329 |
+
#define YYFINAL ]b4_final_state_number[
|
| 330 |
+
/* YYLAST -- Last index in YYTABLE. */
|
| 331 |
+
#define YYLAST ]b4_last[
|
| 332 |
+
|
| 333 |
+
/* YYNTOKENS -- Number of terminals. */
|
| 334 |
+
#define YYNTOKENS ]b4_tokens_number[
|
| 335 |
+
/* YYNNTS -- Number of nonterminals. */
|
| 336 |
+
#define YYNNTS ]b4_nterms_number[
|
| 337 |
+
/* YYNRULES -- Number of rules. */
|
| 338 |
+
#define YYNRULES ]b4_rules_number[
|
| 339 |
+
/* YYNSTATES -- Number of states. */
|
| 340 |
+
#define YYNSTATES ]b4_states_number[
|
| 341 |
+
/* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
|
| 342 |
+
#define YYMAXRHS ]b4_r2_max[
|
| 343 |
+
/* YYMAXLEFT -- Maximum number of symbols to the left of a handle
|
| 344 |
+
accessed by $0, $-1, etc., in any rule. */
|
| 345 |
+
#define YYMAXLEFT ]b4_max_left_semantic_context[
|
| 346 |
+
|
| 347 |
+
/* YYMAXUTOK -- Last valid token kind. */
|
| 348 |
+
#define YYMAXUTOK ]b4_code_max[
|
| 349 |
+
|
| 350 |
+
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
|
| 351 |
+
as returned by yylex, with out-of-bounds checking. */
|
| 352 |
+
]b4_api_token_raw_if(dnl
|
| 353 |
+
[[#define YYTRANSLATE(YYX) YY_CAST (yysymbol_kind_t, YYX)]],
|
| 354 |
+
[[#define YYTRANSLATE(YYX) \
|
| 355 |
+
(0 <= (YYX) && (YYX) <= YYMAXUTOK \
|
| 356 |
+
? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
|
| 357 |
+
: ]b4_symbol_prefix[YYUNDEF)
|
| 358 |
+
|
| 359 |
+
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
| 360 |
+
as returned by yylex. */
|
| 361 |
+
static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
|
| 362 |
+
{
|
| 363 |
+
]b4_translate[
|
| 364 |
+
};]])[
|
| 365 |
+
|
| 366 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 367 |
+
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
| 368 |
+
static const ]b4_int_type_for([b4_rline])[ yyrline[] =
|
| 369 |
+
{
|
| 370 |
+
]b4_rline[
|
| 371 |
+
};
|
| 372 |
+
#endif
|
| 373 |
+
|
| 374 |
+
#define YYPACT_NINF (]b4_pact_ninf[)
|
| 375 |
+
#define YYTABLE_NINF (]b4_table_ninf[)
|
| 376 |
+
|
| 377 |
+
]b4_parser_tables_define[
|
| 378 |
+
|
| 379 |
+
/* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
|
| 380 |
+
static const ]b4_int_type_for([b4_dprec])[ yydprec[] =
|
| 381 |
+
{
|
| 382 |
+
]b4_dprec[
|
| 383 |
+
};
|
| 384 |
+
|
| 385 |
+
/* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
|
| 386 |
+
static const ]b4_int_type_for([b4_merger])[ yymerger[] =
|
| 387 |
+
{
|
| 388 |
+
]b4_merger[
|
| 389 |
+
};
|
| 390 |
+
|
| 391 |
+
/* YYIMMEDIATE[RULE-NUM] -- True iff rule #RULE-NUM is not to be deferred, as
|
| 392 |
+
in the case of predicates. */
|
| 393 |
+
static const yybool yyimmediate[] =
|
| 394 |
+
{
|
| 395 |
+
]b4_immediate[
|
| 396 |
+
};
|
| 397 |
+
|
| 398 |
+
/* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
|
| 399 |
+
list of conflicting reductions corresponding to action entry for
|
| 400 |
+
state STATE-NUM in yytable. 0 means no conflicts. The list in
|
| 401 |
+
yyconfl is terminated by a rule number of 0. */
|
| 402 |
+
static const ]b4_int_type_for([b4_conflict_list_heads])[ yyconflp[] =
|
| 403 |
+
{
|
| 404 |
+
]b4_conflict_list_heads[
|
| 405 |
+
};
|
| 406 |
+
|
| 407 |
+
/* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
|
| 408 |
+
0, pointed into by YYCONFLP. */
|
| 409 |
+
]dnl Do not use b4_int_type_for here, since there are places where
|
| 410 |
+
dnl pointers onto yyconfl are taken, whose type is "short*".
|
| 411 |
+
dnl We probably ought to introduce a type for confl.
|
| 412 |
+
[static const short yyconfl[] =
|
| 413 |
+
{
|
| 414 |
+
]b4_conflicting_rules[
|
| 415 |
+
};
|
| 416 |
+
|
| 417 |
+
]b4_locations_if([[
|
| 418 |
+
]b4_yylloc_default_define[
|
| 419 |
+
# define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
|
| 420 |
+
]])[
|
| 421 |
+
|
| 422 |
+
]b4_pure_if(
|
| 423 |
+
[
|
| 424 |
+
#undef yynerrs
|
| 425 |
+
#define yynerrs (yystackp->yyerrcnt)
|
| 426 |
+
#undef yychar
|
| 427 |
+
#define yychar (yystackp->yyrawchar)
|
| 428 |
+
#undef yylval
|
| 429 |
+
#define yylval (yystackp->yyval)
|
| 430 |
+
#undef yylloc
|
| 431 |
+
#define yylloc (yystackp->yyloc)
|
| 432 |
+
m4_if(b4_prefix[], [yy], [],
|
| 433 |
+
[#define b4_prefix[]nerrs yynerrs
|
| 434 |
+
#define b4_prefix[]char yychar
|
| 435 |
+
#define b4_prefix[]lval yylval
|
| 436 |
+
#define b4_prefix[]lloc yylloc])],
|
| 437 |
+
[YYSTYPE yylval;]b4_locations_if([[
|
| 438 |
+
YYLTYPE yylloc;]])[
|
| 439 |
+
|
| 440 |
+
int yynerrs;
|
| 441 |
+
int yychar;])[
|
| 442 |
+
|
| 443 |
+
enum { YYENOMEM = -2 };
|
| 444 |
+
|
| 445 |
+
typedef enum { yyok, yyaccept, yyabort, yyerr, yynomem } YYRESULTTAG;
|
| 446 |
+
|
| 447 |
+
#define YYCHK(YYE) \
|
| 448 |
+
do { \
|
| 449 |
+
YYRESULTTAG yychk_flag = YYE; \
|
| 450 |
+
if (yychk_flag != yyok) \
|
| 451 |
+
return yychk_flag; \
|
| 452 |
+
} while (0)
|
| 453 |
+
|
| 454 |
+
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
| 455 |
+
#ifndef YYINITDEPTH
|
| 456 |
+
# define YYINITDEPTH ]b4_stack_depth_init[
|
| 457 |
+
#endif
|
| 458 |
+
|
| 459 |
+
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
|
| 460 |
+
if the built-in stack extension method is used).
|
| 461 |
+
|
| 462 |
+
Do not make this value too large; the results are undefined if
|
| 463 |
+
SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)
|
| 464 |
+
evaluated with infinite-precision integer arithmetic. */
|
| 465 |
+
|
| 466 |
+
#ifndef YYMAXDEPTH
|
| 467 |
+
# define YYMAXDEPTH ]b4_stack_depth_max[
|
| 468 |
+
#endif
|
| 469 |
+
|
| 470 |
+
/* Minimum number of free items on the stack allowed after an
|
| 471 |
+
allocation. This is to allow allocation and initialization
|
| 472 |
+
to be completed by functions that call yyexpandGLRStack before the
|
| 473 |
+
stack is expanded, thus insuring that all necessary pointers get
|
| 474 |
+
properly redirected to new data. */
|
| 475 |
+
#define YYHEADROOM 2
|
| 476 |
+
|
| 477 |
+
#ifndef YYSTACKEXPANDABLE
|
| 478 |
+
# define YYSTACKEXPANDABLE 1
|
| 479 |
+
#endif
|
| 480 |
+
|
| 481 |
+
#if YYSTACKEXPANDABLE
|
| 482 |
+
# define YY_RESERVE_GLRSTACK(Yystack) \
|
| 483 |
+
do { \
|
| 484 |
+
if (Yystack->yyspaceLeft < YYHEADROOM) \
|
| 485 |
+
yyexpandGLRStack (Yystack); \
|
| 486 |
+
} while (0)
|
| 487 |
+
#else
|
| 488 |
+
# define YY_RESERVE_GLRSTACK(Yystack) \
|
| 489 |
+
do { \
|
| 490 |
+
if (Yystack->yyspaceLeft < YYHEADROOM) \
|
| 491 |
+
yyMemoryExhausted (Yystack); \
|
| 492 |
+
} while (0)
|
| 493 |
+
#endif
|
| 494 |
+
|
| 495 |
+
/** State numbers. */
|
| 496 |
+
typedef int yy_state_t;
|
| 497 |
+
|
| 498 |
+
/** Rule numbers. */
|
| 499 |
+
typedef int yyRuleNum;
|
| 500 |
+
|
| 501 |
+
/** Item references. */
|
| 502 |
+
typedef short yyItemNum;
|
| 503 |
+
|
| 504 |
+
typedef struct yyGLRState yyGLRState;
|
| 505 |
+
typedef struct yyGLRStateSet yyGLRStateSet;
|
| 506 |
+
typedef struct yySemanticOption yySemanticOption;
|
| 507 |
+
typedef union yyGLRStackItem yyGLRStackItem;
|
| 508 |
+
typedef struct yyGLRStack yyGLRStack;
|
| 509 |
+
|
| 510 |
+
struct yyGLRState
|
| 511 |
+
{
|
| 512 |
+
/** Type tag: always true. */
|
| 513 |
+
yybool yyisState;
|
| 514 |
+
/** Type tag for yysemantics. If true, yyval applies, otherwise
|
| 515 |
+
* yyfirstVal applies. */
|
| 516 |
+
yybool yyresolved;
|
| 517 |
+
/** Number of corresponding LALR(1) machine state. */
|
| 518 |
+
yy_state_t yylrState;
|
| 519 |
+
/** Preceding state in this stack */
|
| 520 |
+
yyGLRState* yypred;
|
| 521 |
+
/** Source position of the last token produced by my symbol */
|
| 522 |
+
YYPTRDIFF_T yyposn;
|
| 523 |
+
union {
|
| 524 |
+
/** First in a chain of alternative reductions producing the
|
| 525 |
+
* nonterminal corresponding to this state, threaded through
|
| 526 |
+
* yynext. */
|
| 527 |
+
yySemanticOption* yyfirstVal;
|
| 528 |
+
/** Semantic value for this state. */
|
| 529 |
+
YYSTYPE yyval;
|
| 530 |
+
} yysemantics;]b4_locations_if([[
|
| 531 |
+
/** Source location for this state. */
|
| 532 |
+
YYLTYPE yyloc;]])[
|
| 533 |
+
};
|
| 534 |
+
|
| 535 |
+
struct yyGLRStateSet
|
| 536 |
+
{
|
| 537 |
+
yyGLRState** yystates;
|
| 538 |
+
/** During nondeterministic operation, yylookaheadNeeds tracks which
|
| 539 |
+
* stacks have actually needed the current lookahead. During deterministic
|
| 540 |
+
* operation, yylookaheadNeeds[0] is not maintained since it would merely
|
| 541 |
+
* duplicate yychar != ]b4_symbol(empty, id)[. */
|
| 542 |
+
yybool* yylookaheadNeeds;
|
| 543 |
+
YYPTRDIFF_T yysize;
|
| 544 |
+
YYPTRDIFF_T yycapacity;
|
| 545 |
+
};
|
| 546 |
+
|
| 547 |
+
struct yySemanticOption
|
| 548 |
+
{
|
| 549 |
+
/** Type tag: always false. */
|
| 550 |
+
yybool yyisState;
|
| 551 |
+
/** Rule number for this reduction */
|
| 552 |
+
yyRuleNum yyrule;
|
| 553 |
+
/** The last RHS state in the list of states to be reduced. */
|
| 554 |
+
yyGLRState* yystate;
|
| 555 |
+
/** The lookahead for this reduction. */
|
| 556 |
+
int yyrawchar;
|
| 557 |
+
YYSTYPE yyval;]b4_locations_if([[
|
| 558 |
+
YYLTYPE yyloc;]])[
|
| 559 |
+
/** Next sibling in chain of options. To facilitate merging,
|
| 560 |
+
* options are chained in decreasing order by address. */
|
| 561 |
+
yySemanticOption* yynext;
|
| 562 |
+
};
|
| 563 |
+
|
| 564 |
+
/** Type of the items in the GLR stack. The yyisState field
|
| 565 |
+
* indicates which item of the union is valid. */
|
| 566 |
+
union yyGLRStackItem {
|
| 567 |
+
yyGLRState yystate;
|
| 568 |
+
yySemanticOption yyoption;
|
| 569 |
+
};
|
| 570 |
+
|
| 571 |
+
struct yyGLRStack {
|
| 572 |
+
int yyerrState;
|
| 573 |
+
]b4_locations_if([[ /* To compute the location of the error token. */
|
| 574 |
+
yyGLRStackItem yyerror_range[3];]])[
|
| 575 |
+
]b4_pure_if(
|
| 576 |
+
[
|
| 577 |
+
int yyerrcnt;
|
| 578 |
+
int yyrawchar;
|
| 579 |
+
YYSTYPE yyval;]b4_locations_if([[
|
| 580 |
+
YYLTYPE yyloc;]])[
|
| 581 |
+
])[
|
| 582 |
+
YYJMP_BUF yyexception_buffer;
|
| 583 |
+
yyGLRStackItem* yyitems;
|
| 584 |
+
yyGLRStackItem* yynextFree;
|
| 585 |
+
YYPTRDIFF_T yyspaceLeft;
|
| 586 |
+
yyGLRState* yysplitPoint;
|
| 587 |
+
yyGLRState* yylastDeleted;
|
| 588 |
+
yyGLRStateSet yytops;
|
| 589 |
+
};
|
| 590 |
+
|
| 591 |
+
#if YYSTACKEXPANDABLE
|
| 592 |
+
static void yyexpandGLRStack (yyGLRStack* yystackp);
|
| 593 |
+
#endif
|
| 594 |
+
|
| 595 |
+
_Noreturn static void
|
| 596 |
+
yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
|
| 597 |
+
{
|
| 598 |
+
if (yymsg != YY_NULLPTR)
|
| 599 |
+
yyerror (]b4_yyerror_args[yymsg);
|
| 600 |
+
YYLONGJMP (yystackp->yyexception_buffer, 1);
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
_Noreturn static void
|
| 604 |
+
yyMemoryExhausted (yyGLRStack* yystackp)
|
| 605 |
+
{
|
| 606 |
+
YYLONGJMP (yystackp->yyexception_buffer, 2);
|
| 607 |
+
}
|
| 608 |
+
|
| 609 |
+
/** Accessing symbol of state YYSTATE. */
|
| 610 |
+
static inline yysymbol_kind_t
|
| 611 |
+
yy_accessing_symbol (yy_state_t yystate)
|
| 612 |
+
{
|
| 613 |
+
return YY_CAST (yysymbol_kind_t, yystos[yystate]);
|
| 614 |
+
}
|
| 615 |
+
|
| 616 |
+
#if ]b4_parse_error_case([simple], [b4_api_PREFIX[DEBUG || ]b4_token_table_flag], [[1]])[
|
| 617 |
+
/* The user-facing name of the symbol whose (internal) number is
|
| 618 |
+
YYSYMBOL. No bounds checking. */
|
| 619 |
+
static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
|
| 620 |
+
|
| 621 |
+
]b4_parse_error_bmatch([simple\|verbose],
|
| 622 |
+
[[/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
| 623 |
+
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
| 624 |
+
static const char *const yytname[] =
|
| 625 |
+
{
|
| 626 |
+
]b4_tname[
|
| 627 |
+
};
|
| 628 |
+
|
| 629 |
+
static const char *
|
| 630 |
+
yysymbol_name (yysymbol_kind_t yysymbol)
|
| 631 |
+
{
|
| 632 |
+
return yytname[yysymbol];
|
| 633 |
+
}]],
|
| 634 |
+
[[static const char *
|
| 635 |
+
yysymbol_name (yysymbol_kind_t yysymbol)
|
| 636 |
+
{
|
| 637 |
+
static const char *const yy_sname[] =
|
| 638 |
+
{
|
| 639 |
+
]b4_symbol_names[
|
| 640 |
+
};]b4_has_translations_if([[
|
| 641 |
+
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
|
| 642 |
+
internationalizable. */
|
| 643 |
+
static ]b4_int_type_for([b4_translatable])[ yytranslatable[] =
|
| 644 |
+
{
|
| 645 |
+
]b4_translatable[
|
| 646 |
+
};
|
| 647 |
+
return (yysymbol < YYNTOKENS && yytranslatable[yysymbol]
|
| 648 |
+
? _(yy_sname[yysymbol])
|
| 649 |
+
: yy_sname[yysymbol]);]], [[
|
| 650 |
+
return yy_sname[yysymbol];]])[
|
| 651 |
+
}]])[
|
| 652 |
+
#endif
|
| 653 |
+
|
| 654 |
+
/** Left-hand-side symbol for rule #YYRULE. */
|
| 655 |
+
static inline yysymbol_kind_t
|
| 656 |
+
yylhsNonterm (yyRuleNum yyrule)
|
| 657 |
+
{
|
| 658 |
+
return YY_CAST (yysymbol_kind_t, yyr1[yyrule]);
|
| 659 |
+
}
|
| 660 |
+
|
| 661 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 662 |
+
|
| 663 |
+
# ifndef YYFPRINTF
|
| 664 |
+
# define YYFPRINTF fprintf
|
| 665 |
+
# endif
|
| 666 |
+
|
| 667 |
+
# define YY_FPRINTF \
|
| 668 |
+
YY_IGNORE_USELESS_CAST_BEGIN YY_FPRINTF_
|
| 669 |
+
|
| 670 |
+
# define YY_FPRINTF_(Args) \
|
| 671 |
+
do { \
|
| 672 |
+
YYFPRINTF Args; \
|
| 673 |
+
YY_IGNORE_USELESS_CAST_END \
|
| 674 |
+
} while (0)
|
| 675 |
+
|
| 676 |
+
# define YY_DPRINTF \
|
| 677 |
+
YY_IGNORE_USELESS_CAST_BEGIN YY_DPRINTF_
|
| 678 |
+
|
| 679 |
+
# define YY_DPRINTF_(Args) \
|
| 680 |
+
do { \
|
| 681 |
+
if (yydebug) \
|
| 682 |
+
YYFPRINTF Args; \
|
| 683 |
+
YY_IGNORE_USELESS_CAST_END \
|
| 684 |
+
} while (0)
|
| 685 |
+
|
| 686 |
+
]b4_yylocation_print_define[
|
| 687 |
+
|
| 688 |
+
]b4_yy_symbol_print_define[
|
| 689 |
+
|
| 690 |
+
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
|
| 691 |
+
do { \
|
| 692 |
+
if (yydebug) \
|
| 693 |
+
{ \
|
| 694 |
+
YY_FPRINTF ((stderr, "%s ", Title)); \
|
| 695 |
+
yy_symbol_print (stderr, Kind, Value]b4_locuser_args([Location])[); \
|
| 696 |
+
YY_FPRINTF ((stderr, "\n")); \
|
| 697 |
+
} \
|
| 698 |
+
} while (0)
|
| 699 |
+
|
| 700 |
+
static inline void
|
| 701 |
+
yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, YYPTRDIFF_T yyk,
|
| 702 |
+
yyRuleNum yyrule]b4_user_formals[);
|
| 703 |
+
|
| 704 |
+
# define YY_REDUCE_PRINT(Args) \
|
| 705 |
+
do { \
|
| 706 |
+
if (yydebug) \
|
| 707 |
+
yy_reduce_print Args; \
|
| 708 |
+
} while (0)
|
| 709 |
+
|
| 710 |
+
/* Nonzero means print parse trace. It is left uninitialized so that
|
| 711 |
+
multiple parsers can coexist. */
|
| 712 |
+
int yydebug;
|
| 713 |
+
|
| 714 |
+
static void yypstack (yyGLRStack* yystackp, YYPTRDIFF_T yyk)
|
| 715 |
+
YY_ATTRIBUTE_UNUSED;
|
| 716 |
+
static void yypdumpstack (yyGLRStack* yystackp)
|
| 717 |
+
YY_ATTRIBUTE_UNUSED;
|
| 718 |
+
|
| 719 |
+
#else /* !]b4_api_PREFIX[DEBUG */
|
| 720 |
+
|
| 721 |
+
# define YY_DPRINTF(Args) do {} while (yyfalse)
|
| 722 |
+
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
|
| 723 |
+
# define YY_REDUCE_PRINT(Args)
|
| 724 |
+
|
| 725 |
+
#endif /* !]b4_api_PREFIX[DEBUG */
|
| 726 |
+
|
| 727 |
+
]b4_parse_error_case(
|
| 728 |
+
[simple],
|
| 729 |
+
[[]],
|
| 730 |
+
[[#ifndef yystrlen
|
| 731 |
+
# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
|
| 732 |
+
#endif
|
| 733 |
+
|
| 734 |
+
]b4_parse_error_bmatch(
|
| 735 |
+
[detailed\|verbose],
|
| 736 |
+
[[#ifndef yystpcpy
|
| 737 |
+
# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
|
| 738 |
+
# define yystpcpy stpcpy
|
| 739 |
+
# else
|
| 740 |
+
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
|
| 741 |
+
YYDEST. */
|
| 742 |
+
static char *
|
| 743 |
+
yystpcpy (char *yydest, const char *yysrc)
|
| 744 |
+
{
|
| 745 |
+
char *yyd = yydest;
|
| 746 |
+
const char *yys = yysrc;
|
| 747 |
+
|
| 748 |
+
while ((*yyd++ = *yys++) != '\0')
|
| 749 |
+
continue;
|
| 750 |
+
|
| 751 |
+
return yyd - 1;
|
| 752 |
+
}
|
| 753 |
+
# endif
|
| 754 |
+
#endif]])[
|
| 755 |
+
|
| 756 |
+
]b4_parse_error_case(
|
| 757 |
+
[verbose],
|
| 758 |
+
[[#ifndef yytnamerr
|
| 759 |
+
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
|
| 760 |
+
quotes and backslashes, so that it's suitable for yyerror. The
|
| 761 |
+
heuristic is that double-quoting is unnecessary unless the string
|
| 762 |
+
contains an apostrophe, a comma, or backslash (other than
|
| 763 |
+
backslash-backslash). YYSTR is taken from yytname. If YYRES is
|
| 764 |
+
null, do not copy; instead, return the length of what the result
|
| 765 |
+
would have been. */
|
| 766 |
+
static YYPTRDIFF_T
|
| 767 |
+
yytnamerr (char *yyres, const char *yystr)
|
| 768 |
+
{
|
| 769 |
+
if (*yystr == '"')
|
| 770 |
+
{
|
| 771 |
+
YYPTRDIFF_T yyn = 0;
|
| 772 |
+
char const *yyp = yystr;
|
| 773 |
+
|
| 774 |
+
for (;;)
|
| 775 |
+
switch (*++yyp)
|
| 776 |
+
{
|
| 777 |
+
case '\'':
|
| 778 |
+
case ',':
|
| 779 |
+
goto do_not_strip_quotes;
|
| 780 |
+
|
| 781 |
+
case '\\':
|
| 782 |
+
if (*++yyp != '\\')
|
| 783 |
+
goto do_not_strip_quotes;
|
| 784 |
+
else
|
| 785 |
+
goto append;
|
| 786 |
+
|
| 787 |
+
append:
|
| 788 |
+
default:
|
| 789 |
+
if (yyres)
|
| 790 |
+
yyres[yyn] = *yyp;
|
| 791 |
+
yyn++;
|
| 792 |
+
break;
|
| 793 |
+
|
| 794 |
+
case '"':
|
| 795 |
+
if (yyres)
|
| 796 |
+
yyres[yyn] = '\0';
|
| 797 |
+
return yyn;
|
| 798 |
+
}
|
| 799 |
+
do_not_strip_quotes: ;
|
| 800 |
+
}
|
| 801 |
+
|
| 802 |
+
if (yyres)
|
| 803 |
+
return yystpcpy (yyres, yystr) - yyres;
|
| 804 |
+
else
|
| 805 |
+
return yystrlen (yystr);
|
| 806 |
+
}
|
| 807 |
+
#endif
|
| 808 |
+
]])])[
|
| 809 |
+
|
| 810 |
+
/** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
|
| 811 |
+
* at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
|
| 812 |
+
* containing the pointer to the next state in the chain. */
|
| 813 |
+
static void yyfillin (yyGLRStackItem *, int, int) YY_ATTRIBUTE_UNUSED;
|
| 814 |
+
static void
|
| 815 |
+
yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
|
| 816 |
+
{
|
| 817 |
+
int i;
|
| 818 |
+
yyGLRState *s = yyvsp[yylow0].yystate.yypred;
|
| 819 |
+
for (i = yylow0-1; i >= yylow1; i -= 1)
|
| 820 |
+
{
|
| 821 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 822 |
+
yyvsp[i].yystate.yylrState = s->yylrState;
|
| 823 |
+
#endif
|
| 824 |
+
yyvsp[i].yystate.yyresolved = s->yyresolved;
|
| 825 |
+
if (s->yyresolved)
|
| 826 |
+
yyvsp[i].yystate.yysemantics.yyval = s->yysemantics.yyval;
|
| 827 |
+
else
|
| 828 |
+
/* The effect of using yyval or yyloc (in an immediate rule) is
|
| 829 |
+
* undefined. */
|
| 830 |
+
yyvsp[i].yystate.yysemantics.yyfirstVal = YY_NULLPTR;]b4_locations_if([[
|
| 831 |
+
yyvsp[i].yystate.yyloc = s->yyloc;]])[
|
| 832 |
+
s = yyvsp[i].yystate.yypred = s->yypred;
|
| 833 |
+
}
|
| 834 |
+
}
|
| 835 |
+
|
| 836 |
+
]m4_define([b4_yygetToken_call],
|
| 837 |
+
[[yygetToken (&yychar][]b4_pure_if([, yystackp])[]b4_user_args[)]])[
|
| 838 |
+
/** If yychar is empty, fetch the next token. */
|
| 839 |
+
static inline yysymbol_kind_t
|
| 840 |
+
yygetToken (int *yycharp][]b4_pure_if([, yyGLRStack* yystackp])[]b4_user_formals[)
|
| 841 |
+
{
|
| 842 |
+
yysymbol_kind_t yytoken;
|
| 843 |
+
]b4_parse_param_use()dnl
|
| 844 |
+
[ if (*yycharp == ]b4_symbol(empty, id)[)
|
| 845 |
+
{
|
| 846 |
+
YY_DPRINTF ((stderr, "Reading a token\n"));]b4_glr_cc_if([[
|
| 847 |
+
#if YY_EXCEPTIONS
|
| 848 |
+
try
|
| 849 |
+
{
|
| 850 |
+
#endif // YY_EXCEPTIONS
|
| 851 |
+
*yycharp = ]b4_yylex[;
|
| 852 |
+
#if YY_EXCEPTIONS
|
| 853 |
+
}
|
| 854 |
+
catch (const ]b4_namespace_ref[::]b4_parser_class[::syntax_error& yyexc)
|
| 855 |
+
{
|
| 856 |
+
YY_DPRINTF ((stderr, "Caught exception: %s\n", yyexc.what()));]b4_locations_if([
|
| 857 |
+
yylloc = yyexc.location;])[
|
| 858 |
+
yyerror (]b4_lyyerror_args[yyexc.what ());
|
| 859 |
+
// Map errors caught in the scanner to the undefined token,
|
| 860 |
+
// so that error handling is started. However, record this
|
| 861 |
+
// with this special value of yychar.
|
| 862 |
+
*yycharp = ]b4_symbol(error, id)[;
|
| 863 |
+
}
|
| 864 |
+
#endif // YY_EXCEPTIONS]], [[
|
| 865 |
+
*yycharp = ]b4_yylex[;]])[
|
| 866 |
+
}
|
| 867 |
+
if (*yycharp <= ]b4_symbol(eof, [id])[)
|
| 868 |
+
{
|
| 869 |
+
*yycharp = ]b4_symbol(eof, [id])[;
|
| 870 |
+
yytoken = ]b4_symbol_prefix[YYEOF;
|
| 871 |
+
YY_DPRINTF ((stderr, "Now at end of input.\n"));
|
| 872 |
+
}
|
| 873 |
+
else
|
| 874 |
+
{
|
| 875 |
+
yytoken = YYTRANSLATE (*yycharp);
|
| 876 |
+
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
|
| 877 |
+
}
|
| 878 |
+
return yytoken;
|
| 879 |
+
}
|
| 880 |
+
|
| 881 |
+
/* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in
|
| 882 |
+
* YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
|
| 883 |
+
* For convenience, always return YYLOW1. */
|
| 884 |
+
static inline int yyfill (yyGLRStackItem *, int *, int, yybool)
|
| 885 |
+
YY_ATTRIBUTE_UNUSED;
|
| 886 |
+
static inline int
|
| 887 |
+
yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
|
| 888 |
+
{
|
| 889 |
+
if (!yynormal && yylow1 < *yylow)
|
| 890 |
+
{
|
| 891 |
+
yyfillin (yyvsp, *yylow, yylow1);
|
| 892 |
+
*yylow = yylow1;
|
| 893 |
+
}
|
| 894 |
+
return yylow1;
|
| 895 |
+
}
|
| 896 |
+
|
| 897 |
+
/** Perform user action for rule number YYN, with RHS length YYRHSLEN,
|
| 898 |
+
* and top stack item YYVSP. YYLVALP points to place to put semantic
|
| 899 |
+
* value ($$), and yylocp points to place for location information
|
| 900 |
+
* (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
|
| 901 |
+
* yyerr for YYERROR, yyabort for YYABORT, yynomem for YYNOMEM. */
|
| 902 |
+
static YYRESULTTAG
|
| 903 |
+
yyuserAction (yyRuleNum yyrule, int yyrhslen, yyGLRStackItem* yyvsp,
|
| 904 |
+
yyGLRStack* yystackp, YYPTRDIFF_T yyk,
|
| 905 |
+
YYSTYPE* yyvalp]b4_locuser_formals[)
|
| 906 |
+
{
|
| 907 |
+
const yybool yynormal YY_ATTRIBUTE_UNUSED = yystackp->yysplitPoint == YY_NULLPTR;
|
| 908 |
+
int yylow = 1;
|
| 909 |
+
]b4_parse_param_use([yyvalp], [yylocp])dnl
|
| 910 |
+
[ YY_USE (yyk);
|
| 911 |
+
YY_USE (yyrhslen);
|
| 912 |
+
# undef yyerrok
|
| 913 |
+
# define yyerrok (yystackp->yyerrState = 0)
|
| 914 |
+
# undef YYACCEPT
|
| 915 |
+
# define YYACCEPT return yyaccept
|
| 916 |
+
# undef YYABORT
|
| 917 |
+
# define YYABORT return yyabort
|
| 918 |
+
# undef YYNOMEM
|
| 919 |
+
# define YYNOMEM return yynomem
|
| 920 |
+
# undef YYERROR
|
| 921 |
+
# define YYERROR return yyerrok, yyerr
|
| 922 |
+
# undef YYRECOVERING
|
| 923 |
+
# define YYRECOVERING() (yystackp->yyerrState != 0)
|
| 924 |
+
# undef yyclearin
|
| 925 |
+
# define yyclearin (yychar = ]b4_symbol(empty, id)[)
|
| 926 |
+
# undef YYFILL
|
| 927 |
+
# define YYFILL(N) yyfill (yyvsp, &yylow, (N), yynormal)
|
| 928 |
+
# undef YYBACKUP
|
| 929 |
+
# define YYBACKUP(Token, Value) \
|
| 930 |
+
return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")), \
|
| 931 |
+
yyerrok, yyerr
|
| 932 |
+
|
| 933 |
+
if (yyrhslen == 0)
|
| 934 |
+
*yyvalp = yyval_default;
|
| 935 |
+
else
|
| 936 |
+
*yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yyval;]b4_locations_if([[
|
| 937 |
+
/* Default location. */
|
| 938 |
+
YYLLOC_DEFAULT ((*yylocp), (yyvsp - yyrhslen), yyrhslen);
|
| 939 |
+
yystackp->yyerror_range[1].yystate.yyloc = *yylocp;]])[
|
| 940 |
+
/* If yyk == -1, we are running a deferred action on a temporary
|
| 941 |
+
stack. In that case, YY_REDUCE_PRINT must not play with YYFILL,
|
| 942 |
+
so pretend the stack is "normal". */
|
| 943 |
+
YY_REDUCE_PRINT ((yynormal || yyk == -1, yyvsp, yyk, yyrule]b4_user_args[));]b4_glr_cc_if([[
|
| 944 |
+
#if YY_EXCEPTIONS
|
| 945 |
+
typedef ]b4_namespace_ref[::]b4_parser_class[::syntax_error syntax_error;
|
| 946 |
+
try
|
| 947 |
+
{
|
| 948 |
+
#endif // YY_EXCEPTIONS]])[
|
| 949 |
+
switch (yyrule)
|
| 950 |
+
{
|
| 951 |
+
]b4_user_actions[
|
| 952 |
+
default: break;
|
| 953 |
+
}]b4_glr_cc_if([[
|
| 954 |
+
#if YY_EXCEPTIONS
|
| 955 |
+
}
|
| 956 |
+
catch (const syntax_error& yyexc)
|
| 957 |
+
{
|
| 958 |
+
YY_DPRINTF ((stderr, "Caught exception: %s\n", yyexc.what()));]b4_locations_if([
|
| 959 |
+
*yylocp = yyexc.location;])[
|
| 960 |
+
yyerror (]b4_yyerror_args[yyexc.what ());
|
| 961 |
+
YYERROR;
|
| 962 |
+
}
|
| 963 |
+
#endif // YY_EXCEPTIONS]])[
|
| 964 |
+
YY_SYMBOL_PRINT ("-> $$ =", yylhsNonterm (yyrule), yyvalp, yylocp);
|
| 965 |
+
|
| 966 |
+
return yyok;
|
| 967 |
+
# undef yyerrok
|
| 968 |
+
# undef YYABORT
|
| 969 |
+
# undef YYACCEPT
|
| 970 |
+
# undef YYNOMEM
|
| 971 |
+
# undef YYERROR
|
| 972 |
+
# undef YYBACKUP
|
| 973 |
+
# undef yyclearin
|
| 974 |
+
# undef YYRECOVERING
|
| 975 |
+
}
|
| 976 |
+
|
| 977 |
+
|
| 978 |
+
static void
|
| 979 |
+
yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
|
| 980 |
+
{
|
| 981 |
+
YY_USE (yy0);
|
| 982 |
+
YY_USE (yy1);
|
| 983 |
+
|
| 984 |
+
switch (yyn)
|
| 985 |
+
{
|
| 986 |
+
]b4_mergers[
|
| 987 |
+
default: break;
|
| 988 |
+
}
|
| 989 |
+
}
|
| 990 |
+
|
| 991 |
+
/* Bison grammar-table manipulation. */
|
| 992 |
+
|
| 993 |
+
]b4_yydestruct_define[
|
| 994 |
+
|
| 995 |
+
/** Number of symbols composing the right hand side of rule #RULE. */
|
| 996 |
+
static inline int
|
| 997 |
+
yyrhsLength (yyRuleNum yyrule)
|
| 998 |
+
{
|
| 999 |
+
return yyr2[yyrule];
|
| 1000 |
+
}
|
| 1001 |
+
|
| 1002 |
+
static void
|
| 1003 |
+
yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
|
| 1004 |
+
{
|
| 1005 |
+
if (yys->yyresolved)
|
| 1006 |
+
yydestruct (yymsg, yy_accessing_symbol (yys->yylrState),
|
| 1007 |
+
&yys->yysemantics.yyval]b4_locuser_args([&yys->yyloc])[);
|
| 1008 |
+
else
|
| 1009 |
+
{
|
| 1010 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 1011 |
+
if (yydebug)
|
| 1012 |
+
{
|
| 1013 |
+
if (yys->yysemantics.yyfirstVal)
|
| 1014 |
+
YY_FPRINTF ((stderr, "%s unresolved", yymsg));
|
| 1015 |
+
else
|
| 1016 |
+
YY_FPRINTF ((stderr, "%s incomplete", yymsg));
|
| 1017 |
+
YY_SYMBOL_PRINT ("", yy_accessing_symbol (yys->yylrState), YY_NULLPTR, &yys->yyloc);
|
| 1018 |
+
}
|
| 1019 |
+
#endif
|
| 1020 |
+
|
| 1021 |
+
if (yys->yysemantics.yyfirstVal)
|
| 1022 |
+
{
|
| 1023 |
+
yySemanticOption *yyoption = yys->yysemantics.yyfirstVal;
|
| 1024 |
+
yyGLRState *yyrh;
|
| 1025 |
+
int yyn;
|
| 1026 |
+
for (yyrh = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule);
|
| 1027 |
+
yyn > 0;
|
| 1028 |
+
yyrh = yyrh->yypred, yyn -= 1)
|
| 1029 |
+
yydestroyGLRState (yymsg, yyrh]b4_user_args[);
|
| 1030 |
+
}
|
| 1031 |
+
}
|
| 1032 |
+
}
|
| 1033 |
+
|
| 1034 |
+
#define yypact_value_is_default(Yyn) \
|
| 1035 |
+
]b4_table_value_equals([[pact]], [[Yyn]], [b4_pact_ninf], [YYPACT_NINF])[
|
| 1036 |
+
|
| 1037 |
+
/** True iff LR state YYSTATE has only a default reduction (regardless
|
| 1038 |
+
* of token). */
|
| 1039 |
+
static inline yybool
|
| 1040 |
+
yyisDefaultedState (yy_state_t yystate)
|
| 1041 |
+
{
|
| 1042 |
+
return yypact_value_is_default (yypact[yystate]);
|
| 1043 |
+
}
|
| 1044 |
+
|
| 1045 |
+
/** The default reduction for YYSTATE, assuming it has one. */
|
| 1046 |
+
static inline yyRuleNum
|
| 1047 |
+
yydefaultAction (yy_state_t yystate)
|
| 1048 |
+
{
|
| 1049 |
+
return yydefact[yystate];
|
| 1050 |
+
}
|
| 1051 |
+
|
| 1052 |
+
#define yytable_value_is_error(Yyn) \
|
| 1053 |
+
]b4_table_value_equals([[table]], [[Yyn]], [b4_table_ninf], [YYTABLE_NINF])[
|
| 1054 |
+
|
| 1055 |
+
/** The action to take in YYSTATE on seeing YYTOKEN.
|
| 1056 |
+
* Result R means
|
| 1057 |
+
* R < 0: Reduce on rule -R.
|
| 1058 |
+
* R = 0: Error.
|
| 1059 |
+
* R > 0: Shift to state R.
|
| 1060 |
+
* Set *YYCONFLICTS to a pointer into yyconfl to a 0-terminated list
|
| 1061 |
+
* of conflicting reductions.
|
| 1062 |
+
*/
|
| 1063 |
+
static inline int
|
| 1064 |
+
yygetLRActions (yy_state_t yystate, yysymbol_kind_t yytoken, const short** yyconflicts)
|
| 1065 |
+
{
|
| 1066 |
+
int yyindex = yypact[yystate] + yytoken;
|
| 1067 |
+
if (yytoken == ]b4_symbol(error, kind)[)
|
| 1068 |
+
{
|
| 1069 |
+
// This is the error token.
|
| 1070 |
+
*yyconflicts = yyconfl;
|
| 1071 |
+
return 0;
|
| 1072 |
+
}
|
| 1073 |
+
else if (yyisDefaultedState (yystate)
|
| 1074 |
+
|| yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
|
| 1075 |
+
{
|
| 1076 |
+
*yyconflicts = yyconfl;
|
| 1077 |
+
return -yydefact[yystate];
|
| 1078 |
+
}
|
| 1079 |
+
else if (! yytable_value_is_error (yytable[yyindex]))
|
| 1080 |
+
{
|
| 1081 |
+
*yyconflicts = yyconfl + yyconflp[yyindex];
|
| 1082 |
+
return yytable[yyindex];
|
| 1083 |
+
}
|
| 1084 |
+
else
|
| 1085 |
+
{
|
| 1086 |
+
*yyconflicts = yyconfl + yyconflp[yyindex];
|
| 1087 |
+
return 0;
|
| 1088 |
+
}
|
| 1089 |
+
}
|
| 1090 |
+
|
| 1091 |
+
/** Compute post-reduction state.
|
| 1092 |
+
* \param yystate the current state
|
| 1093 |
+
* \param yysym the nonterminal to push on the stack
|
| 1094 |
+
*/
|
| 1095 |
+
static inline yy_state_t
|
| 1096 |
+
yyLRgotoState (yy_state_t yystate, yysymbol_kind_t yysym)
|
| 1097 |
+
{
|
| 1098 |
+
int yyr = yypgoto[yysym - YYNTOKENS] + yystate;
|
| 1099 |
+
if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
|
| 1100 |
+
return yytable[yyr];
|
| 1101 |
+
else
|
| 1102 |
+
return yydefgoto[yysym - YYNTOKENS];
|
| 1103 |
+
}
|
| 1104 |
+
|
| 1105 |
+
static inline yybool
|
| 1106 |
+
yyisShiftAction (int yyaction)
|
| 1107 |
+
{
|
| 1108 |
+
return 0 < yyaction;
|
| 1109 |
+
}
|
| 1110 |
+
|
| 1111 |
+
static inline yybool
|
| 1112 |
+
yyisErrorAction (int yyaction)
|
| 1113 |
+
{
|
| 1114 |
+
return yyaction == 0;
|
| 1115 |
+
}
|
| 1116 |
+
|
| 1117 |
+
/* GLRStates */
|
| 1118 |
+
|
| 1119 |
+
/** Return a fresh GLRStackItem in YYSTACKP. The item is an LR state
|
| 1120 |
+
* if YYISSTATE, and otherwise a semantic option. Callers should call
|
| 1121 |
+
* YY_RESERVE_GLRSTACK afterwards to make sure there is sufficient
|
| 1122 |
+
* headroom. */
|
| 1123 |
+
|
| 1124 |
+
static inline yyGLRStackItem*
|
| 1125 |
+
yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState)
|
| 1126 |
+
{
|
| 1127 |
+
yyGLRStackItem* yynewItem = yystackp->yynextFree;
|
| 1128 |
+
yystackp->yyspaceLeft -= 1;
|
| 1129 |
+
yystackp->yynextFree += 1;
|
| 1130 |
+
yynewItem->yystate.yyisState = yyisState;
|
| 1131 |
+
return yynewItem;
|
| 1132 |
+
}
|
| 1133 |
+
|
| 1134 |
+
/** Add a new semantic action that will execute the action for rule
|
| 1135 |
+
* YYRULE on the semantic values in YYRHS to the list of
|
| 1136 |
+
* alternative actions for YYSTATE. Assumes that YYRHS comes from
|
| 1137 |
+
* stack #YYK of *YYSTACKP. */
|
| 1138 |
+
static void
|
| 1139 |
+
yyaddDeferredAction (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yyGLRState* yystate,
|
| 1140 |
+
yyGLRState* yyrhs, yyRuleNum yyrule)
|
| 1141 |
+
{
|
| 1142 |
+
yySemanticOption* yynewOption =
|
| 1143 |
+
&yynewGLRStackItem (yystackp, yyfalse)->yyoption;
|
| 1144 |
+
YY_ASSERT (!yynewOption->yyisState);
|
| 1145 |
+
yynewOption->yystate = yyrhs;
|
| 1146 |
+
yynewOption->yyrule = yyrule;
|
| 1147 |
+
if (yystackp->yytops.yylookaheadNeeds[yyk])
|
| 1148 |
+
{
|
| 1149 |
+
yynewOption->yyrawchar = yychar;
|
| 1150 |
+
yynewOption->yyval = yylval;]b4_locations_if([
|
| 1151 |
+
yynewOption->yyloc = yylloc;])[
|
| 1152 |
+
}
|
| 1153 |
+
else
|
| 1154 |
+
yynewOption->yyrawchar = ]b4_symbol(empty, id)[;
|
| 1155 |
+
yynewOption->yynext = yystate->yysemantics.yyfirstVal;
|
| 1156 |
+
yystate->yysemantics.yyfirstVal = yynewOption;
|
| 1157 |
+
|
| 1158 |
+
YY_RESERVE_GLRSTACK (yystackp);
|
| 1159 |
+
}
|
| 1160 |
+
|
| 1161 |
+
/* GLRStacks */
|
| 1162 |
+
|
| 1163 |
+
/** Initialize YYSET to a singleton set containing an empty stack. */
|
| 1164 |
+
static yybool
|
| 1165 |
+
yyinitStateSet (yyGLRStateSet* yyset)
|
| 1166 |
+
{
|
| 1167 |
+
yyset->yysize = 1;
|
| 1168 |
+
yyset->yycapacity = 16;
|
| 1169 |
+
yyset->yystates
|
| 1170 |
+
= YY_CAST (yyGLRState**,
|
| 1171 |
+
YYMALLOC (YY_CAST (YYSIZE_T, yyset->yycapacity)
|
| 1172 |
+
* sizeof yyset->yystates[0]));
|
| 1173 |
+
if (! yyset->yystates)
|
| 1174 |
+
return yyfalse;
|
| 1175 |
+
yyset->yystates[0] = YY_NULLPTR;
|
| 1176 |
+
yyset->yylookaheadNeeds
|
| 1177 |
+
= YY_CAST (yybool*,
|
| 1178 |
+
YYMALLOC (YY_CAST (YYSIZE_T, yyset->yycapacity)
|
| 1179 |
+
* sizeof yyset->yylookaheadNeeds[0]));
|
| 1180 |
+
if (! yyset->yylookaheadNeeds)
|
| 1181 |
+
{
|
| 1182 |
+
YYFREE (yyset->yystates);
|
| 1183 |
+
return yyfalse;
|
| 1184 |
+
}
|
| 1185 |
+
memset (yyset->yylookaheadNeeds,
|
| 1186 |
+
0,
|
| 1187 |
+
YY_CAST (YYSIZE_T, yyset->yycapacity) * sizeof yyset->yylookaheadNeeds[0]);
|
| 1188 |
+
return yytrue;
|
| 1189 |
+
}
|
| 1190 |
+
|
| 1191 |
+
static void yyfreeStateSet (yyGLRStateSet* yyset)
|
| 1192 |
+
{
|
| 1193 |
+
YYFREE (yyset->yystates);
|
| 1194 |
+
YYFREE (yyset->yylookaheadNeeds);
|
| 1195 |
+
}
|
| 1196 |
+
|
| 1197 |
+
/** Initialize *YYSTACKP to a single empty stack, with total maximum
|
| 1198 |
+
* capacity for all stacks of YYSIZE. */
|
| 1199 |
+
static yybool
|
| 1200 |
+
yyinitGLRStack (yyGLRStack* yystackp, YYPTRDIFF_T yysize)
|
| 1201 |
+
{
|
| 1202 |
+
yystackp->yyerrState = 0;
|
| 1203 |
+
yynerrs = 0;
|
| 1204 |
+
yystackp->yyspaceLeft = yysize;
|
| 1205 |
+
yystackp->yyitems
|
| 1206 |
+
= YY_CAST (yyGLRStackItem*,
|
| 1207 |
+
YYMALLOC (YY_CAST (YYSIZE_T, yysize)
|
| 1208 |
+
* sizeof yystackp->yynextFree[0]));
|
| 1209 |
+
if (!yystackp->yyitems)
|
| 1210 |
+
return yyfalse;
|
| 1211 |
+
yystackp->yynextFree = yystackp->yyitems;
|
| 1212 |
+
yystackp->yysplitPoint = YY_NULLPTR;
|
| 1213 |
+
yystackp->yylastDeleted = YY_NULLPTR;
|
| 1214 |
+
return yyinitStateSet (&yystackp->yytops);
|
| 1215 |
+
}
|
| 1216 |
+
|
| 1217 |
+
|
| 1218 |
+
#if YYSTACKEXPANDABLE
|
| 1219 |
+
# define YYRELOC(YYFROMITEMS, YYTOITEMS, YYX, YYTYPE) \
|
| 1220 |
+
&((YYTOITEMS) \
|
| 1221 |
+
- ((YYFROMITEMS) - YY_REINTERPRET_CAST (yyGLRStackItem*, (YYX))))->YYTYPE
|
| 1222 |
+
|
| 1223 |
+
/** If *YYSTACKP is expandable, extend it. WARNING: Pointers into the
|
| 1224 |
+
stack from outside should be considered invalid after this call.
|
| 1225 |
+
We always expand when there are 1 or fewer items left AFTER an
|
| 1226 |
+
allocation, so that we can avoid having external pointers exist
|
| 1227 |
+
across an allocation. */
|
| 1228 |
+
static void
|
| 1229 |
+
yyexpandGLRStack (yyGLRStack* yystackp)
|
| 1230 |
+
{
|
| 1231 |
+
yyGLRStackItem* yynewItems;
|
| 1232 |
+
yyGLRStackItem* yyp0, *yyp1;
|
| 1233 |
+
YYPTRDIFF_T yynewSize;
|
| 1234 |
+
YYPTRDIFF_T yyn;
|
| 1235 |
+
YYPTRDIFF_T yysize = yystackp->yynextFree - yystackp->yyitems;
|
| 1236 |
+
if (YYMAXDEPTH - YYHEADROOM < yysize)
|
| 1237 |
+
yyMemoryExhausted (yystackp);
|
| 1238 |
+
yynewSize = 2*yysize;
|
| 1239 |
+
if (YYMAXDEPTH < yynewSize)
|
| 1240 |
+
yynewSize = YYMAXDEPTH;
|
| 1241 |
+
yynewItems
|
| 1242 |
+
= YY_CAST (yyGLRStackItem*,
|
| 1243 |
+
YYMALLOC (YY_CAST (YYSIZE_T, yynewSize)
|
| 1244 |
+
* sizeof yynewItems[0]));
|
| 1245 |
+
if (! yynewItems)
|
| 1246 |
+
yyMemoryExhausted (yystackp);
|
| 1247 |
+
for (yyp0 = yystackp->yyitems, yyp1 = yynewItems, yyn = yysize;
|
| 1248 |
+
0 < yyn;
|
| 1249 |
+
yyn -= 1, yyp0 += 1, yyp1 += 1)
|
| 1250 |
+
{
|
| 1251 |
+
*yyp1 = *yyp0;
|
| 1252 |
+
if (*YY_REINTERPRET_CAST (yybool *, yyp0))
|
| 1253 |
+
{
|
| 1254 |
+
yyGLRState* yys0 = &yyp0->yystate;
|
| 1255 |
+
yyGLRState* yys1 = &yyp1->yystate;
|
| 1256 |
+
if (yys0->yypred != YY_NULLPTR)
|
| 1257 |
+
yys1->yypred =
|
| 1258 |
+
YYRELOC (yyp0, yyp1, yys0->yypred, yystate);
|
| 1259 |
+
if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != YY_NULLPTR)
|
| 1260 |
+
yys1->yysemantics.yyfirstVal =
|
| 1261 |
+
YYRELOC (yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption);
|
| 1262 |
+
}
|
| 1263 |
+
else
|
| 1264 |
+
{
|
| 1265 |
+
yySemanticOption* yyv0 = &yyp0->yyoption;
|
| 1266 |
+
yySemanticOption* yyv1 = &yyp1->yyoption;
|
| 1267 |
+
if (yyv0->yystate != YY_NULLPTR)
|
| 1268 |
+
yyv1->yystate = YYRELOC (yyp0, yyp1, yyv0->yystate, yystate);
|
| 1269 |
+
if (yyv0->yynext != YY_NULLPTR)
|
| 1270 |
+
yyv1->yynext = YYRELOC (yyp0, yyp1, yyv0->yynext, yyoption);
|
| 1271 |
+
}
|
| 1272 |
+
}
|
| 1273 |
+
if (yystackp->yysplitPoint != YY_NULLPTR)
|
| 1274 |
+
yystackp->yysplitPoint = YYRELOC (yystackp->yyitems, yynewItems,
|
| 1275 |
+
yystackp->yysplitPoint, yystate);
|
| 1276 |
+
|
| 1277 |
+
for (yyn = 0; yyn < yystackp->yytops.yysize; yyn += 1)
|
| 1278 |
+
if (yystackp->yytops.yystates[yyn] != YY_NULLPTR)
|
| 1279 |
+
yystackp->yytops.yystates[yyn] =
|
| 1280 |
+
YYRELOC (yystackp->yyitems, yynewItems,
|
| 1281 |
+
yystackp->yytops.yystates[yyn], yystate);
|
| 1282 |
+
YYFREE (yystackp->yyitems);
|
| 1283 |
+
yystackp->yyitems = yynewItems;
|
| 1284 |
+
yystackp->yynextFree = yynewItems + yysize;
|
| 1285 |
+
yystackp->yyspaceLeft = yynewSize - yysize;
|
| 1286 |
+
}
|
| 1287 |
+
#endif
|
| 1288 |
+
|
| 1289 |
+
static void
|
| 1290 |
+
yyfreeGLRStack (yyGLRStack* yystackp)
|
| 1291 |
+
{
|
| 1292 |
+
YYFREE (yystackp->yyitems);
|
| 1293 |
+
yyfreeStateSet (&yystackp->yytops);
|
| 1294 |
+
}
|
| 1295 |
+
|
| 1296 |
+
/** Assuming that YYS is a GLRState somewhere on *YYSTACKP, update the
|
| 1297 |
+
* splitpoint of *YYSTACKP, if needed, so that it is at least as deep as
|
| 1298 |
+
* YYS. */
|
| 1299 |
+
static inline void
|
| 1300 |
+
yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
|
| 1301 |
+
{
|
| 1302 |
+
if (yystackp->yysplitPoint != YY_NULLPTR && yystackp->yysplitPoint > yys)
|
| 1303 |
+
yystackp->yysplitPoint = yys;
|
| 1304 |
+
}
|
| 1305 |
+
|
| 1306 |
+
/** Invalidate stack #YYK in *YYSTACKP. */
|
| 1307 |
+
static inline void
|
| 1308 |
+
yymarkStackDeleted (yyGLRStack* yystackp, YYPTRDIFF_T yyk)
|
| 1309 |
+
{
|
| 1310 |
+
if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
|
| 1311 |
+
yystackp->yylastDeleted = yystackp->yytops.yystates[yyk];
|
| 1312 |
+
yystackp->yytops.yystates[yyk] = YY_NULLPTR;
|
| 1313 |
+
}
|
| 1314 |
+
|
| 1315 |
+
/** Undelete the last stack in *YYSTACKP that was marked as deleted. Can
|
| 1316 |
+
only be done once after a deletion, and only when all other stacks have
|
| 1317 |
+
been deleted. */
|
| 1318 |
+
static void
|
| 1319 |
+
yyundeleteLastStack (yyGLRStack* yystackp)
|
| 1320 |
+
{
|
| 1321 |
+
if (yystackp->yylastDeleted == YY_NULLPTR || yystackp->yytops.yysize != 0)
|
| 1322 |
+
return;
|
| 1323 |
+
yystackp->yytops.yystates[0] = yystackp->yylastDeleted;
|
| 1324 |
+
yystackp->yytops.yysize = 1;
|
| 1325 |
+
YY_DPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
|
| 1326 |
+
yystackp->yylastDeleted = YY_NULLPTR;
|
| 1327 |
+
}
|
| 1328 |
+
|
| 1329 |
+
static inline void
|
| 1330 |
+
yyremoveDeletes (yyGLRStack* yystackp)
|
| 1331 |
+
{
|
| 1332 |
+
YYPTRDIFF_T yyi, yyj;
|
| 1333 |
+
yyi = yyj = 0;
|
| 1334 |
+
while (yyj < yystackp->yytops.yysize)
|
| 1335 |
+
{
|
| 1336 |
+
if (yystackp->yytops.yystates[yyi] == YY_NULLPTR)
|
| 1337 |
+
{
|
| 1338 |
+
if (yyi == yyj)
|
| 1339 |
+
YY_DPRINTF ((stderr, "Removing dead stacks.\n"));
|
| 1340 |
+
yystackp->yytops.yysize -= 1;
|
| 1341 |
+
}
|
| 1342 |
+
else
|
| 1343 |
+
{
|
| 1344 |
+
yystackp->yytops.yystates[yyj] = yystackp->yytops.yystates[yyi];
|
| 1345 |
+
/* In the current implementation, it's unnecessary to copy
|
| 1346 |
+
yystackp->yytops.yylookaheadNeeds[yyi] since, after
|
| 1347 |
+
yyremoveDeletes returns, the parser immediately either enters
|
| 1348 |
+
deterministic operation or shifts a token. However, it doesn't
|
| 1349 |
+
hurt, and the code might evolve to need it. */
|
| 1350 |
+
yystackp->yytops.yylookaheadNeeds[yyj] =
|
| 1351 |
+
yystackp->yytops.yylookaheadNeeds[yyi];
|
| 1352 |
+
if (yyj != yyi)
|
| 1353 |
+
YY_DPRINTF ((stderr, "Rename stack %ld -> %ld.\n",
|
| 1354 |
+
YY_CAST (long, yyi), YY_CAST (long, yyj)));
|
| 1355 |
+
yyj += 1;
|
| 1356 |
+
}
|
| 1357 |
+
yyi += 1;
|
| 1358 |
+
}
|
| 1359 |
+
}
|
| 1360 |
+
|
| 1361 |
+
/** Shift to a new state on stack #YYK of *YYSTACKP, corresponding to LR
|
| 1362 |
+
* state YYLRSTATE, at input position YYPOSN, with (resolved) semantic
|
| 1363 |
+
* value *YYVALP and source location *YYLOCP. */
|
| 1364 |
+
static inline void
|
| 1365 |
+
yyglrShift (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yy_state_t yylrState,
|
| 1366 |
+
YYPTRDIFF_T yyposn,
|
| 1367 |
+
YYSTYPE* yyvalp]b4_locations_if([, YYLTYPE* yylocp])[)
|
| 1368 |
+
{
|
| 1369 |
+
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
|
| 1370 |
+
|
| 1371 |
+
yynewState->yylrState = yylrState;
|
| 1372 |
+
yynewState->yyposn = yyposn;
|
| 1373 |
+
yynewState->yyresolved = yytrue;
|
| 1374 |
+
yynewState->yypred = yystackp->yytops.yystates[yyk];
|
| 1375 |
+
yynewState->yysemantics.yyval = *yyvalp;]b4_locations_if([
|
| 1376 |
+
yynewState->yyloc = *yylocp;])[
|
| 1377 |
+
yystackp->yytops.yystates[yyk] = yynewState;
|
| 1378 |
+
|
| 1379 |
+
YY_RESERVE_GLRSTACK (yystackp);
|
| 1380 |
+
}
|
| 1381 |
+
|
| 1382 |
+
/** Shift stack #YYK of *YYSTACKP, to a new state corresponding to LR
|
| 1383 |
+
* state YYLRSTATE, at input position YYPOSN, with the (unresolved)
|
| 1384 |
+
* semantic value of YYRHS under the action for YYRULE. */
|
| 1385 |
+
static inline void
|
| 1386 |
+
yyglrShiftDefer (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yy_state_t yylrState,
|
| 1387 |
+
YYPTRDIFF_T yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
|
| 1388 |
+
{
|
| 1389 |
+
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
|
| 1390 |
+
YY_ASSERT (yynewState->yyisState);
|
| 1391 |
+
|
| 1392 |
+
yynewState->yylrState = yylrState;
|
| 1393 |
+
yynewState->yyposn = yyposn;
|
| 1394 |
+
yynewState->yyresolved = yyfalse;
|
| 1395 |
+
yynewState->yypred = yystackp->yytops.yystates[yyk];
|
| 1396 |
+
yynewState->yysemantics.yyfirstVal = YY_NULLPTR;
|
| 1397 |
+
yystackp->yytops.yystates[yyk] = yynewState;
|
| 1398 |
+
|
| 1399 |
+
/* Invokes YY_RESERVE_GLRSTACK. */
|
| 1400 |
+
yyaddDeferredAction (yystackp, yyk, yynewState, yyrhs, yyrule);
|
| 1401 |
+
}
|
| 1402 |
+
|
| 1403 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 1404 |
+
|
| 1405 |
+
/*----------------------------------------------------------------------.
|
| 1406 |
+
| Report that stack #YYK of *YYSTACKP is going to be reduced by YYRULE. |
|
| 1407 |
+
`----------------------------------------------------------------------*/
|
| 1408 |
+
|
| 1409 |
+
static inline void
|
| 1410 |
+
yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, YYPTRDIFF_T yyk,
|
| 1411 |
+
yyRuleNum yyrule]b4_user_formals[)
|
| 1412 |
+
{
|
| 1413 |
+
int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
|
| 1414 |
+
int yylow = 1;])[
|
| 1415 |
+
int yyi;
|
| 1416 |
+
YY_FPRINTF ((stderr, "Reducing stack %ld by rule %d (line %d):\n",
|
| 1417 |
+
YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule]));
|
| 1418 |
+
if (! yynormal)
|
| 1419 |
+
yyfillin (yyvsp, 1, -yynrhs);
|
| 1420 |
+
/* The symbols being reduced. */
|
| 1421 |
+
for (yyi = 0; yyi < yynrhs; yyi++)
|
| 1422 |
+
{
|
| 1423 |
+
YY_FPRINTF ((stderr, " $%d = ", yyi + 1));
|
| 1424 |
+
yy_symbol_print (stderr,
|
| 1425 |
+
yy_accessing_symbol (yyvsp[yyi - yynrhs + 1].yystate.yylrState),
|
| 1426 |
+
&yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yyval]b4_locations_if([,
|
| 1427 |
+
&]b4_rhs_location(yynrhs, yyi + 1))[]dnl
|
| 1428 |
+
b4_user_args[);
|
| 1429 |
+
if (!yyvsp[yyi - yynrhs + 1].yystate.yyresolved)
|
| 1430 |
+
YY_FPRINTF ((stderr, " (unresolved)"));
|
| 1431 |
+
YY_FPRINTF ((stderr, "\n"));
|
| 1432 |
+
}
|
| 1433 |
+
}
|
| 1434 |
+
#endif
|
| 1435 |
+
|
| 1436 |
+
/** Pop the symbols consumed by reduction #YYRULE from the top of stack
|
| 1437 |
+
* #YYK of *YYSTACKP, and perform the appropriate semantic action on their
|
| 1438 |
+
* semantic values. Assumes that all ambiguities in semantic values
|
| 1439 |
+
* have been previously resolved. Set *YYVALP to the resulting value,
|
| 1440 |
+
* and *YYLOCP to the computed location (if any). Return value is as
|
| 1441 |
+
* for userAction. */
|
| 1442 |
+
static inline YYRESULTTAG
|
| 1443 |
+
yydoAction (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yyRuleNum yyrule,
|
| 1444 |
+
YYSTYPE* yyvalp]b4_locuser_formals[)
|
| 1445 |
+
{
|
| 1446 |
+
int yynrhs = yyrhsLength (yyrule);
|
| 1447 |
+
|
| 1448 |
+
if (yystackp->yysplitPoint == YY_NULLPTR)
|
| 1449 |
+
{
|
| 1450 |
+
/* Standard special case: single stack. */
|
| 1451 |
+
yyGLRStackItem* yyrhs
|
| 1452 |
+
= YY_REINTERPRET_CAST (yyGLRStackItem*, yystackp->yytops.yystates[yyk]);
|
| 1453 |
+
YY_ASSERT (yyk == 0);
|
| 1454 |
+
yystackp->yynextFree -= yynrhs;
|
| 1455 |
+
yystackp->yyspaceLeft += yynrhs;
|
| 1456 |
+
yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
|
| 1457 |
+
return yyuserAction (yyrule, yynrhs, yyrhs, yystackp, yyk,
|
| 1458 |
+
yyvalp]b4_locuser_args[);
|
| 1459 |
+
}
|
| 1460 |
+
else
|
| 1461 |
+
{
|
| 1462 |
+
yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
|
| 1463 |
+
yyGLRState* yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred
|
| 1464 |
+
= yystackp->yytops.yystates[yyk];
|
| 1465 |
+
int yyi;]b4_locations_if([[
|
| 1466 |
+
if (yynrhs == 0)
|
| 1467 |
+
/* Set default location. */
|
| 1468 |
+
yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yys->yyloc;]])[
|
| 1469 |
+
for (yyi = 0; yyi < yynrhs; yyi += 1)
|
| 1470 |
+
{
|
| 1471 |
+
yys = yys->yypred;
|
| 1472 |
+
YY_ASSERT (yys);
|
| 1473 |
+
}
|
| 1474 |
+
yyupdateSplit (yystackp, yys);
|
| 1475 |
+
yystackp->yytops.yystates[yyk] = yys;
|
| 1476 |
+
return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
|
| 1477 |
+
yystackp, yyk, yyvalp]b4_locuser_args[);
|
| 1478 |
+
}
|
| 1479 |
+
}
|
| 1480 |
+
|
| 1481 |
+
/** Pop items off stack #YYK of *YYSTACKP according to grammar rule YYRULE,
|
| 1482 |
+
* and push back on the resulting nonterminal symbol. Perform the
|
| 1483 |
+
* semantic action associated with YYRULE and store its value with the
|
| 1484 |
+
* newly pushed state, if YYFORCEEVAL or if *YYSTACKP is currently
|
| 1485 |
+
* unambiguous. Otherwise, store the deferred semantic action with
|
| 1486 |
+
* the new state. If the new state would have an identical input
|
| 1487 |
+
* position, LR state, and predecessor to an existing state on the stack,
|
| 1488 |
+
* it is identified with that existing state, eliminating stack #YYK from
|
| 1489 |
+
* *YYSTACKP. In this case, the semantic value is
|
| 1490 |
+
* added to the options for the existing state's semantic value.
|
| 1491 |
+
*/
|
| 1492 |
+
static inline YYRESULTTAG
|
| 1493 |
+
yyglrReduce (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yyRuleNum yyrule,
|
| 1494 |
+
yybool yyforceEval]b4_user_formals[)
|
| 1495 |
+
{
|
| 1496 |
+
YYPTRDIFF_T yyposn = yystackp->yytops.yystates[yyk]->yyposn;
|
| 1497 |
+
|
| 1498 |
+
if (yyforceEval || yystackp->yysplitPoint == YY_NULLPTR)
|
| 1499 |
+
{
|
| 1500 |
+
YYSTYPE yyval;]b4_locations_if([[
|
| 1501 |
+
YYLTYPE yyloc;]])[
|
| 1502 |
+
|
| 1503 |
+
YYRESULTTAG yyflag = yydoAction (yystackp, yyk, yyrule, &yyval]b4_locuser_args([&yyloc])[);
|
| 1504 |
+
if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULLPTR)
|
| 1505 |
+
YY_DPRINTF ((stderr,
|
| 1506 |
+
"Parse on stack %ld rejected by rule %d (line %d).\n",
|
| 1507 |
+
YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule]));
|
| 1508 |
+
if (yyflag != yyok)
|
| 1509 |
+
return yyflag;
|
| 1510 |
+
yyglrShift (yystackp, yyk,
|
| 1511 |
+
yyLRgotoState (yystackp->yytops.yystates[yyk]->yylrState,
|
| 1512 |
+
yylhsNonterm (yyrule)),
|
| 1513 |
+
yyposn, &yyval]b4_locations_if([, &yyloc])[);
|
| 1514 |
+
}
|
| 1515 |
+
else
|
| 1516 |
+
{
|
| 1517 |
+
YYPTRDIFF_T yyi;
|
| 1518 |
+
int yyn;
|
| 1519 |
+
yyGLRState* yys, *yys0 = yystackp->yytops.yystates[yyk];
|
| 1520 |
+
yy_state_t yynewLRState;
|
| 1521 |
+
|
| 1522 |
+
for (yys = yystackp->yytops.yystates[yyk], yyn = yyrhsLength (yyrule);
|
| 1523 |
+
0 < yyn; yyn -= 1)
|
| 1524 |
+
{
|
| 1525 |
+
yys = yys->yypred;
|
| 1526 |
+
YY_ASSERT (yys);
|
| 1527 |
+
}
|
| 1528 |
+
yyupdateSplit (yystackp, yys);
|
| 1529 |
+
yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
|
| 1530 |
+
YY_DPRINTF ((stderr,
|
| 1531 |
+
"Reduced stack %ld by rule %d (line %d); action deferred. "
|
| 1532 |
+
"Now in state %d.\n",
|
| 1533 |
+
YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule],
|
| 1534 |
+
yynewLRState));
|
| 1535 |
+
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
|
| 1536 |
+
if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULLPTR)
|
| 1537 |
+
{
|
| 1538 |
+
yyGLRState *yysplit = yystackp->yysplitPoint;
|
| 1539 |
+
yyGLRState *yyp = yystackp->yytops.yystates[yyi];
|
| 1540 |
+
while (yyp != yys && yyp != yysplit && yyp->yyposn >= yyposn)
|
| 1541 |
+
{
|
| 1542 |
+
if (yyp->yylrState == yynewLRState && yyp->yypred == yys)
|
| 1543 |
+
{
|
| 1544 |
+
yyaddDeferredAction (yystackp, yyk, yyp, yys0, yyrule);
|
| 1545 |
+
yymarkStackDeleted (yystackp, yyk);
|
| 1546 |
+
YY_DPRINTF ((stderr, "Merging stack %ld into stack %ld.\n",
|
| 1547 |
+
YY_CAST (long, yyk), YY_CAST (long, yyi)));
|
| 1548 |
+
return yyok;
|
| 1549 |
+
}
|
| 1550 |
+
yyp = yyp->yypred;
|
| 1551 |
+
}
|
| 1552 |
+
}
|
| 1553 |
+
yystackp->yytops.yystates[yyk] = yys;
|
| 1554 |
+
yyglrShiftDefer (yystackp, yyk, yynewLRState, yyposn, yys0, yyrule);
|
| 1555 |
+
}
|
| 1556 |
+
return yyok;
|
| 1557 |
+
}
|
| 1558 |
+
|
| 1559 |
+
static YYPTRDIFF_T
|
| 1560 |
+
yysplitStack (yyGLRStack* yystackp, YYPTRDIFF_T yyk)
|
| 1561 |
+
{
|
| 1562 |
+
if (yystackp->yysplitPoint == YY_NULLPTR)
|
| 1563 |
+
{
|
| 1564 |
+
YY_ASSERT (yyk == 0);
|
| 1565 |
+
yystackp->yysplitPoint = yystackp->yytops.yystates[yyk];
|
| 1566 |
+
}
|
| 1567 |
+
if (yystackp->yytops.yycapacity <= yystackp->yytops.yysize)
|
| 1568 |
+
{
|
| 1569 |
+
YYPTRDIFF_T state_size = YYSIZEOF (yystackp->yytops.yystates[0]);
|
| 1570 |
+
YYPTRDIFF_T half_max_capacity = YYSIZE_MAXIMUM / 2 / state_size;
|
| 1571 |
+
if (half_max_capacity < yystackp->yytops.yycapacity)
|
| 1572 |
+
yyMemoryExhausted (yystackp);
|
| 1573 |
+
yystackp->yytops.yycapacity *= 2;
|
| 1574 |
+
|
| 1575 |
+
{
|
| 1576 |
+
yyGLRState** yynewStates
|
| 1577 |
+
= YY_CAST (yyGLRState**,
|
| 1578 |
+
YYREALLOC (yystackp->yytops.yystates,
|
| 1579 |
+
(YY_CAST (YYSIZE_T, yystackp->yytops.yycapacity)
|
| 1580 |
+
* sizeof yynewStates[0])));
|
| 1581 |
+
if (yynewStates == YY_NULLPTR)
|
| 1582 |
+
yyMemoryExhausted (yystackp);
|
| 1583 |
+
yystackp->yytops.yystates = yynewStates;
|
| 1584 |
+
}
|
| 1585 |
+
|
| 1586 |
+
{
|
| 1587 |
+
yybool* yynewLookaheadNeeds
|
| 1588 |
+
= YY_CAST (yybool*,
|
| 1589 |
+
YYREALLOC (yystackp->yytops.yylookaheadNeeds,
|
| 1590 |
+
(YY_CAST (YYSIZE_T, yystackp->yytops.yycapacity)
|
| 1591 |
+
* sizeof yynewLookaheadNeeds[0])));
|
| 1592 |
+
if (yynewLookaheadNeeds == YY_NULLPTR)
|
| 1593 |
+
yyMemoryExhausted (yystackp);
|
| 1594 |
+
yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds;
|
| 1595 |
+
}
|
| 1596 |
+
}
|
| 1597 |
+
yystackp->yytops.yystates[yystackp->yytops.yysize]
|
| 1598 |
+
= yystackp->yytops.yystates[yyk];
|
| 1599 |
+
yystackp->yytops.yylookaheadNeeds[yystackp->yytops.yysize]
|
| 1600 |
+
= yystackp->yytops.yylookaheadNeeds[yyk];
|
| 1601 |
+
yystackp->yytops.yysize += 1;
|
| 1602 |
+
return yystackp->yytops.yysize - 1;
|
| 1603 |
+
}
|
| 1604 |
+
|
| 1605 |
+
/** True iff YYY0 and YYY1 represent identical options at the top level.
|
| 1606 |
+
* That is, they represent the same rule applied to RHS symbols
|
| 1607 |
+
* that produce the same terminal symbols. */
|
| 1608 |
+
static yybool
|
| 1609 |
+
yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1)
|
| 1610 |
+
{
|
| 1611 |
+
if (yyy0->yyrule == yyy1->yyrule)
|
| 1612 |
+
{
|
| 1613 |
+
yyGLRState *yys0, *yys1;
|
| 1614 |
+
int yyn;
|
| 1615 |
+
for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
|
| 1616 |
+
yyn = yyrhsLength (yyy0->yyrule);
|
| 1617 |
+
yyn > 0;
|
| 1618 |
+
yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
|
| 1619 |
+
if (yys0->yyposn != yys1->yyposn)
|
| 1620 |
+
return yyfalse;
|
| 1621 |
+
return yytrue;
|
| 1622 |
+
}
|
| 1623 |
+
else
|
| 1624 |
+
return yyfalse;
|
| 1625 |
+
}
|
| 1626 |
+
|
| 1627 |
+
/** Assuming identicalOptions (YYY0,YYY1), destructively merge the
|
| 1628 |
+
* alternative semantic values for the RHS-symbols of YYY1 and YYY0. */
|
| 1629 |
+
static void
|
| 1630 |
+
yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
|
| 1631 |
+
{
|
| 1632 |
+
yyGLRState *yys0, *yys1;
|
| 1633 |
+
int yyn;
|
| 1634 |
+
for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
|
| 1635 |
+
yyn = yyrhsLength (yyy0->yyrule);
|
| 1636 |
+
0 < yyn;
|
| 1637 |
+
yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
|
| 1638 |
+
{
|
| 1639 |
+
if (yys0 == yys1)
|
| 1640 |
+
break;
|
| 1641 |
+
else if (yys0->yyresolved)
|
| 1642 |
+
{
|
| 1643 |
+
yys1->yyresolved = yytrue;
|
| 1644 |
+
yys1->yysemantics.yyval = yys0->yysemantics.yyval;
|
| 1645 |
+
}
|
| 1646 |
+
else if (yys1->yyresolved)
|
| 1647 |
+
{
|
| 1648 |
+
yys0->yyresolved = yytrue;
|
| 1649 |
+
yys0->yysemantics.yyval = yys1->yysemantics.yyval;
|
| 1650 |
+
}
|
| 1651 |
+
else
|
| 1652 |
+
{
|
| 1653 |
+
yySemanticOption** yyz0p = &yys0->yysemantics.yyfirstVal;
|
| 1654 |
+
yySemanticOption* yyz1 = yys1->yysemantics.yyfirstVal;
|
| 1655 |
+
while (yytrue)
|
| 1656 |
+
{
|
| 1657 |
+
if (yyz1 == *yyz0p || yyz1 == YY_NULLPTR)
|
| 1658 |
+
break;
|
| 1659 |
+
else if (*yyz0p == YY_NULLPTR)
|
| 1660 |
+
{
|
| 1661 |
+
*yyz0p = yyz1;
|
| 1662 |
+
break;
|
| 1663 |
+
}
|
| 1664 |
+
else if (*yyz0p < yyz1)
|
| 1665 |
+
{
|
| 1666 |
+
yySemanticOption* yyz = *yyz0p;
|
| 1667 |
+
*yyz0p = yyz1;
|
| 1668 |
+
yyz1 = yyz1->yynext;
|
| 1669 |
+
(*yyz0p)->yynext = yyz;
|
| 1670 |
+
}
|
| 1671 |
+
yyz0p = &(*yyz0p)->yynext;
|
| 1672 |
+
}
|
| 1673 |
+
yys1->yysemantics.yyfirstVal = yys0->yysemantics.yyfirstVal;
|
| 1674 |
+
}
|
| 1675 |
+
}
|
| 1676 |
+
}
|
| 1677 |
+
|
| 1678 |
+
/** Y0 and Y1 represent two possible actions to take in a given
|
| 1679 |
+
* parsing state; return 0 if no combination is possible,
|
| 1680 |
+
* 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
|
| 1681 |
+
static int
|
| 1682 |
+
yypreference (yySemanticOption* y0, yySemanticOption* y1)
|
| 1683 |
+
{
|
| 1684 |
+
yyRuleNum r0 = y0->yyrule, r1 = y1->yyrule;
|
| 1685 |
+
int p0 = yydprec[r0], p1 = yydprec[r1];
|
| 1686 |
+
|
| 1687 |
+
if (p0 == p1)
|
| 1688 |
+
{
|
| 1689 |
+
if (yymerger[r0] == 0 || yymerger[r0] != yymerger[r1])
|
| 1690 |
+
return 0;
|
| 1691 |
+
else
|
| 1692 |
+
return 1;
|
| 1693 |
+
}
|
| 1694 |
+
if (p0 == 0 || p1 == 0)
|
| 1695 |
+
return 0;
|
| 1696 |
+
if (p0 < p1)
|
| 1697 |
+
return 3;
|
| 1698 |
+
if (p1 < p0)
|
| 1699 |
+
return 2;
|
| 1700 |
+
return 0;
|
| 1701 |
+
}
|
| 1702 |
+
|
| 1703 |
+
static YYRESULTTAG
|
| 1704 |
+
yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[);
|
| 1705 |
+
|
| 1706 |
+
|
| 1707 |
+
/** Resolve the previous YYN states starting at and including state YYS
|
| 1708 |
+
* on *YYSTACKP. If result != yyok, some states may have been left
|
| 1709 |
+
* unresolved possibly with empty semantic option chains. Regardless
|
| 1710 |
+
* of whether result = yyok, each state has been left with consistent
|
| 1711 |
+
* data so that yydestroyGLRState can be invoked if necessary. */
|
| 1712 |
+
static YYRESULTTAG
|
| 1713 |
+
yyresolveStates (yyGLRState* yys, int yyn,
|
| 1714 |
+
yyGLRStack* yystackp]b4_user_formals[)
|
| 1715 |
+
{
|
| 1716 |
+
if (0 < yyn)
|
| 1717 |
+
{
|
| 1718 |
+
YY_ASSERT (yys->yypred);
|
| 1719 |
+
YYCHK (yyresolveStates (yys->yypred, yyn-1, yystackp]b4_user_args[));
|
| 1720 |
+
if (! yys->yyresolved)
|
| 1721 |
+
YYCHK (yyresolveValue (yys, yystackp]b4_user_args[));
|
| 1722 |
+
}
|
| 1723 |
+
return yyok;
|
| 1724 |
+
}
|
| 1725 |
+
|
| 1726 |
+
/** Resolve the states for the RHS of YYOPT on *YYSTACKP, perform its
|
| 1727 |
+
* user action, and return the semantic value and location in *YYVALP
|
| 1728 |
+
* and *YYLOCP. Regardless of whether result = yyok, all RHS states
|
| 1729 |
+
* have been destroyed (assuming the user action destroys all RHS
|
| 1730 |
+
* semantic values if invoked). */
|
| 1731 |
+
static YYRESULTTAG
|
| 1732 |
+
yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystackp,
|
| 1733 |
+
YYSTYPE* yyvalp]b4_locuser_formals[)
|
| 1734 |
+
{
|
| 1735 |
+
yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
|
| 1736 |
+
int yynrhs = yyrhsLength (yyopt->yyrule);
|
| 1737 |
+
YYRESULTTAG yyflag =
|
| 1738 |
+
yyresolveStates (yyopt->yystate, yynrhs, yystackp]b4_user_args[);
|
| 1739 |
+
if (yyflag != yyok)
|
| 1740 |
+
{
|
| 1741 |
+
yyGLRState *yys;
|
| 1742 |
+
for (yys = yyopt->yystate; yynrhs > 0; yys = yys->yypred, yynrhs -= 1)
|
| 1743 |
+
yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[);
|
| 1744 |
+
return yyflag;
|
| 1745 |
+
}
|
| 1746 |
+
|
| 1747 |
+
yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;]b4_locations_if([[
|
| 1748 |
+
if (yynrhs == 0)
|
| 1749 |
+
/* Set default location. */
|
| 1750 |
+
yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].yystate.yyloc = yyopt->yystate->yyloc;]])[
|
| 1751 |
+
{
|
| 1752 |
+
int yychar_current = yychar;
|
| 1753 |
+
YYSTYPE yylval_current = yylval;]b4_locations_if([
|
| 1754 |
+
YYLTYPE yylloc_current = yylloc;])[
|
| 1755 |
+
yychar = yyopt->yyrawchar;
|
| 1756 |
+
yylval = yyopt->yyval;]b4_locations_if([
|
| 1757 |
+
yylloc = yyopt->yyloc;])[
|
| 1758 |
+
yyflag = yyuserAction (yyopt->yyrule, yynrhs,
|
| 1759 |
+
yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
|
| 1760 |
+
yystackp, -1, yyvalp]b4_locuser_args[);
|
| 1761 |
+
yychar = yychar_current;
|
| 1762 |
+
yylval = yylval_current;]b4_locations_if([
|
| 1763 |
+
yylloc = yylloc_current;])[
|
| 1764 |
+
}
|
| 1765 |
+
return yyflag;
|
| 1766 |
+
}
|
| 1767 |
+
|
| 1768 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 1769 |
+
static void
|
| 1770 |
+
yyreportTree (yySemanticOption* yyx, int yyindent)
|
| 1771 |
+
{
|
| 1772 |
+
int yynrhs = yyrhsLength (yyx->yyrule);
|
| 1773 |
+
int yyi;
|
| 1774 |
+
yyGLRState* yys;
|
| 1775 |
+
yyGLRState* yystates[1 + YYMAXRHS];
|
| 1776 |
+
yyGLRState yyleftmost_state;
|
| 1777 |
+
|
| 1778 |
+
for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred)
|
| 1779 |
+
yystates[yyi] = yys;
|
| 1780 |
+
if (yys == YY_NULLPTR)
|
| 1781 |
+
{
|
| 1782 |
+
yyleftmost_state.yyposn = 0;
|
| 1783 |
+
yystates[0] = &yyleftmost_state;
|
| 1784 |
+
}
|
| 1785 |
+
else
|
| 1786 |
+
yystates[0] = yys;
|
| 1787 |
+
|
| 1788 |
+
if (yyx->yystate->yyposn < yys->yyposn + 1)
|
| 1789 |
+
YY_FPRINTF ((stderr, "%*s%s -> <Rule %d, empty>\n",
|
| 1790 |
+
yyindent, "", yysymbol_name (yylhsNonterm (yyx->yyrule)),
|
| 1791 |
+
yyx->yyrule - 1));
|
| 1792 |
+
else
|
| 1793 |
+
YY_FPRINTF ((stderr, "%*s%s -> <Rule %d, tokens %ld .. %ld>\n",
|
| 1794 |
+
yyindent, "", yysymbol_name (yylhsNonterm (yyx->yyrule)),
|
| 1795 |
+
yyx->yyrule - 1, YY_CAST (long, yys->yyposn + 1),
|
| 1796 |
+
YY_CAST (long, yyx->yystate->yyposn)));
|
| 1797 |
+
for (yyi = 1; yyi <= yynrhs; yyi += 1)
|
| 1798 |
+
{
|
| 1799 |
+
if (yystates[yyi]->yyresolved)
|
| 1800 |
+
{
|
| 1801 |
+
if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
|
| 1802 |
+
YY_FPRINTF ((stderr, "%*s%s <empty>\n", yyindent+2, "",
|
| 1803 |
+
yysymbol_name (yy_accessing_symbol (yystates[yyi]->yylrState))));
|
| 1804 |
+
else
|
| 1805 |
+
YY_FPRINTF ((stderr, "%*s%s <tokens %ld .. %ld>\n", yyindent+2, "",
|
| 1806 |
+
yysymbol_name (yy_accessing_symbol (yystates[yyi]->yylrState)),
|
| 1807 |
+
YY_CAST (long, yystates[yyi-1]->yyposn + 1),
|
| 1808 |
+
YY_CAST (long, yystates[yyi]->yyposn)));
|
| 1809 |
+
}
|
| 1810 |
+
else
|
| 1811 |
+
yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);
|
| 1812 |
+
}
|
| 1813 |
+
}
|
| 1814 |
+
#endif
|
| 1815 |
+
|
| 1816 |
+
static YYRESULTTAG
|
| 1817 |
+
yyreportAmbiguity (yySemanticOption* yyx0,
|
| 1818 |
+
yySemanticOption* yyx1]b4_pure_formals[)
|
| 1819 |
+
{
|
| 1820 |
+
YY_USE (yyx0);
|
| 1821 |
+
YY_USE (yyx1);
|
| 1822 |
+
|
| 1823 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 1824 |
+
YY_FPRINTF ((stderr, "Ambiguity detected.\n"));
|
| 1825 |
+
YY_FPRINTF ((stderr, "Option 1,\n"));
|
| 1826 |
+
yyreportTree (yyx0, 2);
|
| 1827 |
+
YY_FPRINTF ((stderr, "\nOption 2,\n"));
|
| 1828 |
+
yyreportTree (yyx1, 2);
|
| 1829 |
+
YY_FPRINTF ((stderr, "\n"));
|
| 1830 |
+
#endif
|
| 1831 |
+
|
| 1832 |
+
yyerror (]b4_yyerror_args[YY_("syntax is ambiguous"));
|
| 1833 |
+
return yyabort;
|
| 1834 |
+
}]b4_locations_if([[
|
| 1835 |
+
|
| 1836 |
+
/** Resolve the locations for each of the YYN1 states in *YYSTACKP,
|
| 1837 |
+
* ending at YYS1. Has no effect on previously resolved states.
|
| 1838 |
+
* The first semantic option of a state is always chosen. */
|
| 1839 |
+
static void
|
| 1840 |
+
yyresolveLocations (yyGLRState *yys1, int yyn1,
|
| 1841 |
+
yyGLRStack *yystackp]b4_user_formals[)
|
| 1842 |
+
{
|
| 1843 |
+
if (0 < yyn1)
|
| 1844 |
+
{
|
| 1845 |
+
yyresolveLocations (yys1->yypred, yyn1 - 1, yystackp]b4_user_args[);
|
| 1846 |
+
if (!yys1->yyresolved)
|
| 1847 |
+
{
|
| 1848 |
+
yyGLRStackItem yyrhsloc[1 + YYMAXRHS];
|
| 1849 |
+
int yynrhs;
|
| 1850 |
+
yySemanticOption *yyoption = yys1->yysemantics.yyfirstVal;
|
| 1851 |
+
YY_ASSERT (yyoption);
|
| 1852 |
+
yynrhs = yyrhsLength (yyoption->yyrule);
|
| 1853 |
+
if (0 < yynrhs)
|
| 1854 |
+
{
|
| 1855 |
+
yyGLRState *yys;
|
| 1856 |
+
int yyn;
|
| 1857 |
+
yyresolveLocations (yyoption->yystate, yynrhs,
|
| 1858 |
+
yystackp]b4_user_args[);
|
| 1859 |
+
for (yys = yyoption->yystate, yyn = yynrhs;
|
| 1860 |
+
yyn > 0;
|
| 1861 |
+
yys = yys->yypred, yyn -= 1)
|
| 1862 |
+
yyrhsloc[yyn].yystate.yyloc = yys->yyloc;
|
| 1863 |
+
}
|
| 1864 |
+
else
|
| 1865 |
+
{
|
| 1866 |
+
/* Both yyresolveAction and yyresolveLocations traverse the GSS
|
| 1867 |
+
in reverse rightmost order. It is only necessary to invoke
|
| 1868 |
+
yyresolveLocations on a subforest for which yyresolveAction
|
| 1869 |
+
would have been invoked next had an ambiguity not been
|
| 1870 |
+
detected. Thus the location of the previous state (but not
|
| 1871 |
+
necessarily the previous state itself) is guaranteed to be
|
| 1872 |
+
resolved already. */
|
| 1873 |
+
yyGLRState *yyprevious = yyoption->yystate;
|
| 1874 |
+
yyrhsloc[0].yystate.yyloc = yyprevious->yyloc;
|
| 1875 |
+
}
|
| 1876 |
+
YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs);
|
| 1877 |
+
}
|
| 1878 |
+
}
|
| 1879 |
+
}]])[
|
| 1880 |
+
|
| 1881 |
+
/** Resolve the ambiguity represented in state YYS in *YYSTACKP,
|
| 1882 |
+
* perform the indicated actions, and set the semantic value of YYS.
|
| 1883 |
+
* If result != yyok, the chain of semantic options in YYS has been
|
| 1884 |
+
* cleared instead or it has been left unmodified except that
|
| 1885 |
+
* redundant options may have been removed. Regardless of whether
|
| 1886 |
+
* result = yyok, YYS has been left with consistent data so that
|
| 1887 |
+
* yydestroyGLRState can be invoked if necessary. */
|
| 1888 |
+
static YYRESULTTAG
|
| 1889 |
+
yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
|
| 1890 |
+
{
|
| 1891 |
+
yySemanticOption* yyoptionList = yys->yysemantics.yyfirstVal;
|
| 1892 |
+
yySemanticOption* yybest = yyoptionList;
|
| 1893 |
+
yySemanticOption** yypp;
|
| 1894 |
+
yybool yymerge = yyfalse;
|
| 1895 |
+
YYSTYPE yyval;
|
| 1896 |
+
YYRESULTTAG yyflag;]b4_locations_if([
|
| 1897 |
+
YYLTYPE *yylocp = &yys->yyloc;])[
|
| 1898 |
+
|
| 1899 |
+
for (yypp = &yyoptionList->yynext; *yypp != YY_NULLPTR; )
|
| 1900 |
+
{
|
| 1901 |
+
yySemanticOption* yyp = *yypp;
|
| 1902 |
+
|
| 1903 |
+
if (yyidenticalOptions (yybest, yyp))
|
| 1904 |
+
{
|
| 1905 |
+
yymergeOptionSets (yybest, yyp);
|
| 1906 |
+
*yypp = yyp->yynext;
|
| 1907 |
+
}
|
| 1908 |
+
else
|
| 1909 |
+
{
|
| 1910 |
+
switch (yypreference (yybest, yyp))
|
| 1911 |
+
{
|
| 1912 |
+
case 0:]b4_locations_if([[
|
| 1913 |
+
yyresolveLocations (yys, 1, yystackp]b4_user_args[);]])[
|
| 1914 |
+
return yyreportAmbiguity (yybest, yyp]b4_pure_args[);
|
| 1915 |
+
break;
|
| 1916 |
+
case 1:
|
| 1917 |
+
yymerge = yytrue;
|
| 1918 |
+
break;
|
| 1919 |
+
case 2:
|
| 1920 |
+
break;
|
| 1921 |
+
case 3:
|
| 1922 |
+
yybest = yyp;
|
| 1923 |
+
yymerge = yyfalse;
|
| 1924 |
+
break;
|
| 1925 |
+
default:
|
| 1926 |
+
/* This cannot happen so it is not worth a YY_ASSERT (yyfalse),
|
| 1927 |
+
but some compilers complain if the default case is
|
| 1928 |
+
omitted. */
|
| 1929 |
+
break;
|
| 1930 |
+
}
|
| 1931 |
+
yypp = &yyp->yynext;
|
| 1932 |
+
}
|
| 1933 |
+
}
|
| 1934 |
+
|
| 1935 |
+
if (yymerge)
|
| 1936 |
+
{
|
| 1937 |
+
yySemanticOption* yyp;
|
| 1938 |
+
int yyprec = yydprec[yybest->yyrule];
|
| 1939 |
+
yyflag = yyresolveAction (yybest, yystackp, &yyval]b4_locuser_args[);
|
| 1940 |
+
if (yyflag == yyok)
|
| 1941 |
+
for (yyp = yybest->yynext; yyp != YY_NULLPTR; yyp = yyp->yynext)
|
| 1942 |
+
{
|
| 1943 |
+
if (yyprec == yydprec[yyp->yyrule])
|
| 1944 |
+
{
|
| 1945 |
+
YYSTYPE yyval_other;]b4_locations_if([
|
| 1946 |
+
YYLTYPE yydummy;])[
|
| 1947 |
+
yyflag = yyresolveAction (yyp, yystackp, &yyval_other]b4_locuser_args([&yydummy])[);
|
| 1948 |
+
if (yyflag != yyok)
|
| 1949 |
+
{
|
| 1950 |
+
yydestruct ("Cleanup: discarding incompletely merged value for",
|
| 1951 |
+
yy_accessing_symbol (yys->yylrState),
|
| 1952 |
+
&yyval]b4_locuser_args[);
|
| 1953 |
+
break;
|
| 1954 |
+
}
|
| 1955 |
+
yyuserMerge (yymerger[yyp->yyrule], &yyval, &yyval_other);
|
| 1956 |
+
}
|
| 1957 |
+
}
|
| 1958 |
+
}
|
| 1959 |
+
else
|
| 1960 |
+
yyflag = yyresolveAction (yybest, yystackp, &yyval]b4_locuser_args([yylocp])[);
|
| 1961 |
+
|
| 1962 |
+
if (yyflag == yyok)
|
| 1963 |
+
{
|
| 1964 |
+
yys->yyresolved = yytrue;
|
| 1965 |
+
yys->yysemantics.yyval = yyval;
|
| 1966 |
+
}
|
| 1967 |
+
else
|
| 1968 |
+
yys->yysemantics.yyfirstVal = YY_NULLPTR;
|
| 1969 |
+
return yyflag;
|
| 1970 |
+
}
|
| 1971 |
+
|
| 1972 |
+
static YYRESULTTAG
|
| 1973 |
+
yyresolveStack (yyGLRStack* yystackp]b4_user_formals[)
|
| 1974 |
+
{
|
| 1975 |
+
if (yystackp->yysplitPoint != YY_NULLPTR)
|
| 1976 |
+
{
|
| 1977 |
+
yyGLRState* yys;
|
| 1978 |
+
int yyn;
|
| 1979 |
+
|
| 1980 |
+
for (yyn = 0, yys = yystackp->yytops.yystates[0];
|
| 1981 |
+
yys != yystackp->yysplitPoint;
|
| 1982 |
+
yys = yys->yypred, yyn += 1)
|
| 1983 |
+
continue;
|
| 1984 |
+
YYCHK (yyresolveStates (yystackp->yytops.yystates[0], yyn, yystackp
|
| 1985 |
+
]b4_user_args[));
|
| 1986 |
+
}
|
| 1987 |
+
return yyok;
|
| 1988 |
+
}
|
| 1989 |
+
|
| 1990 |
+
/** Called when returning to deterministic operation to clean up the extra
|
| 1991 |
+
* stacks. */
|
| 1992 |
+
static void
|
| 1993 |
+
yycompressStack (yyGLRStack* yystackp)
|
| 1994 |
+
{
|
| 1995 |
+
/* yyr is the state after the split point. */
|
| 1996 |
+
yyGLRState *yyr;
|
| 1997 |
+
|
| 1998 |
+
if (yystackp->yytops.yysize != 1 || yystackp->yysplitPoint == YY_NULLPTR)
|
| 1999 |
+
return;
|
| 2000 |
+
|
| 2001 |
+
{
|
| 2002 |
+
yyGLRState *yyp, *yyq;
|
| 2003 |
+
for (yyp = yystackp->yytops.yystates[0], yyq = yyp->yypred, yyr = YY_NULLPTR;
|
| 2004 |
+
yyp != yystackp->yysplitPoint;
|
| 2005 |
+
yyr = yyp, yyp = yyq, yyq = yyp->yypred)
|
| 2006 |
+
yyp->yypred = yyr;
|
| 2007 |
+
}
|
| 2008 |
+
|
| 2009 |
+
yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems;
|
| 2010 |
+
yystackp->yynextFree = YY_REINTERPRET_CAST (yyGLRStackItem*, yystackp->yysplitPoint) + 1;
|
| 2011 |
+
yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems;
|
| 2012 |
+
yystackp->yysplitPoint = YY_NULLPTR;
|
| 2013 |
+
yystackp->yylastDeleted = YY_NULLPTR;
|
| 2014 |
+
|
| 2015 |
+
while (yyr != YY_NULLPTR)
|
| 2016 |
+
{
|
| 2017 |
+
yystackp->yynextFree->yystate = *yyr;
|
| 2018 |
+
yyr = yyr->yypred;
|
| 2019 |
+
yystackp->yynextFree->yystate.yypred = &yystackp->yynextFree[-1].yystate;
|
| 2020 |
+
yystackp->yytops.yystates[0] = &yystackp->yynextFree->yystate;
|
| 2021 |
+
yystackp->yynextFree += 1;
|
| 2022 |
+
yystackp->yyspaceLeft -= 1;
|
| 2023 |
+
}
|
| 2024 |
+
}
|
| 2025 |
+
|
| 2026 |
+
static YYRESULTTAG
|
| 2027 |
+
yyprocessOneStack (yyGLRStack* yystackp, YYPTRDIFF_T yyk,
|
| 2028 |
+
YYPTRDIFF_T yyposn]b4_pure_formals[)
|
| 2029 |
+
{
|
| 2030 |
+
while (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
|
| 2031 |
+
{
|
| 2032 |
+
yy_state_t yystate = yystackp->yytops.yystates[yyk]->yylrState;
|
| 2033 |
+
YY_DPRINTF ((stderr, "Stack %ld Entering state %d\n",
|
| 2034 |
+
YY_CAST (long, yyk), yystate));
|
| 2035 |
+
|
| 2036 |
+
YY_ASSERT (yystate != YYFINAL);
|
| 2037 |
+
|
| 2038 |
+
if (yyisDefaultedState (yystate))
|
| 2039 |
+
{
|
| 2040 |
+
YYRESULTTAG yyflag;
|
| 2041 |
+
yyRuleNum yyrule = yydefaultAction (yystate);
|
| 2042 |
+
if (yyrule == 0)
|
| 2043 |
+
{
|
| 2044 |
+
YY_DPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yyk)));
|
| 2045 |
+
yymarkStackDeleted (yystackp, yyk);
|
| 2046 |
+
return yyok;
|
| 2047 |
+
}
|
| 2048 |
+
yyflag = yyglrReduce (yystackp, yyk, yyrule, yyimmediate[yyrule]]b4_user_args[);
|
| 2049 |
+
if (yyflag == yyerr)
|
| 2050 |
+
{
|
| 2051 |
+
YY_DPRINTF ((stderr,
|
| 2052 |
+
"Stack %ld dies "
|
| 2053 |
+
"(predicate failure or explicit user error).\n",
|
| 2054 |
+
YY_CAST (long, yyk)));
|
| 2055 |
+
yymarkStackDeleted (yystackp, yyk);
|
| 2056 |
+
return yyok;
|
| 2057 |
+
}
|
| 2058 |
+
if (yyflag != yyok)
|
| 2059 |
+
return yyflag;
|
| 2060 |
+
}
|
| 2061 |
+
else
|
| 2062 |
+
{
|
| 2063 |
+
yysymbol_kind_t yytoken = ]b4_yygetToken_call[;
|
| 2064 |
+
const short* yyconflicts;
|
| 2065 |
+
const int yyaction = yygetLRActions (yystate, yytoken, &yyconflicts);
|
| 2066 |
+
yystackp->yytops.yylookaheadNeeds[yyk] = yytrue;
|
| 2067 |
+
|
| 2068 |
+
for (/* nothing */; *yyconflicts; yyconflicts += 1)
|
| 2069 |
+
{
|
| 2070 |
+
YYRESULTTAG yyflag;
|
| 2071 |
+
YYPTRDIFF_T yynewStack = yysplitStack (yystackp, yyk);
|
| 2072 |
+
YY_DPRINTF ((stderr, "Splitting off stack %ld from %ld.\n",
|
| 2073 |
+
YY_CAST (long, yynewStack), YY_CAST (long, yyk)));
|
| 2074 |
+
yyflag = yyglrReduce (yystackp, yynewStack,
|
| 2075 |
+
*yyconflicts,
|
| 2076 |
+
yyimmediate[*yyconflicts]]b4_user_args[);
|
| 2077 |
+
if (yyflag == yyok)
|
| 2078 |
+
YYCHK (yyprocessOneStack (yystackp, yynewStack,
|
| 2079 |
+
yyposn]b4_pure_args[));
|
| 2080 |
+
else if (yyflag == yyerr)
|
| 2081 |
+
{
|
| 2082 |
+
YY_DPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yynewStack)));
|
| 2083 |
+
yymarkStackDeleted (yystackp, yynewStack);
|
| 2084 |
+
}
|
| 2085 |
+
else
|
| 2086 |
+
return yyflag;
|
| 2087 |
+
}
|
| 2088 |
+
|
| 2089 |
+
if (yyisShiftAction (yyaction))
|
| 2090 |
+
break;
|
| 2091 |
+
else if (yyisErrorAction (yyaction))
|
| 2092 |
+
{
|
| 2093 |
+
YY_DPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yyk)));
|
| 2094 |
+
yymarkStackDeleted (yystackp, yyk);
|
| 2095 |
+
break;
|
| 2096 |
+
}
|
| 2097 |
+
else
|
| 2098 |
+
{
|
| 2099 |
+
YYRESULTTAG yyflag = yyglrReduce (yystackp, yyk, -yyaction,
|
| 2100 |
+
yyimmediate[-yyaction]]b4_user_args[);
|
| 2101 |
+
if (yyflag == yyerr)
|
| 2102 |
+
{
|
| 2103 |
+
YY_DPRINTF ((stderr,
|
| 2104 |
+
"Stack %ld dies "
|
| 2105 |
+
"(predicate failure or explicit user error).\n",
|
| 2106 |
+
YY_CAST (long, yyk)));
|
| 2107 |
+
yymarkStackDeleted (yystackp, yyk);
|
| 2108 |
+
break;
|
| 2109 |
+
}
|
| 2110 |
+
else if (yyflag != yyok)
|
| 2111 |
+
return yyflag;
|
| 2112 |
+
}
|
| 2113 |
+
}
|
| 2114 |
+
}
|
| 2115 |
+
return yyok;
|
| 2116 |
+
}
|
| 2117 |
+
|
| 2118 |
+
]b4_parse_error_case([simple], [],
|
| 2119 |
+
[[/* Put in YYARG at most YYARGN of the expected tokens given the
|
| 2120 |
+
current YYSTACKP, and return the number of tokens stored in YYARG. If
|
| 2121 |
+
YYARG is null, return the number of expected tokens (guaranteed to
|
| 2122 |
+
be less than YYNTOKENS). */
|
| 2123 |
+
static int
|
| 2124 |
+
yypcontext_expected_tokens (const yyGLRStack* yystackp,
|
| 2125 |
+
yysymbol_kind_t yyarg[], int yyargn)
|
| 2126 |
+
{
|
| 2127 |
+
/* Actual size of YYARG. */
|
| 2128 |
+
int yycount = 0;
|
| 2129 |
+
int yyn = yypact[yystackp->yytops.yystates[0]->yylrState];
|
| 2130 |
+
if (!yypact_value_is_default (yyn))
|
| 2131 |
+
{
|
| 2132 |
+
/* Start YYX at -YYN if negative to avoid negative indexes in
|
| 2133 |
+
YYCHECK. In other words, skip the first -YYN actions for
|
| 2134 |
+
this state because they are default actions. */
|
| 2135 |
+
int yyxbegin = yyn < 0 ? -yyn : 0;
|
| 2136 |
+
/* Stay within bounds of both yycheck and yytname. */
|
| 2137 |
+
int yychecklim = YYLAST - yyn + 1;
|
| 2138 |
+
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
| 2139 |
+
int yyx;
|
| 2140 |
+
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
|
| 2141 |
+
if (yycheck[yyx + yyn] == yyx && yyx != ]b4_symbol(error, kind)[
|
| 2142 |
+
&& !yytable_value_is_error (yytable[yyx + yyn]))
|
| 2143 |
+
{
|
| 2144 |
+
if (!yyarg)
|
| 2145 |
+
++yycount;
|
| 2146 |
+
else if (yycount == yyargn)
|
| 2147 |
+
return 0;
|
| 2148 |
+
else
|
| 2149 |
+
yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx);
|
| 2150 |
+
}
|
| 2151 |
+
}
|
| 2152 |
+
if (yyarg && yycount == 0 && 0 < yyargn)
|
| 2153 |
+
yyarg[0] = ]b4_symbol(empty, kind)[;
|
| 2154 |
+
return yycount;
|
| 2155 |
+
}]])[
|
| 2156 |
+
|
| 2157 |
+
]b4_parse_error_bmatch(
|
| 2158 |
+
[custom],
|
| 2159 |
+
[[/* User defined function to report a syntax error. */
|
| 2160 |
+
typedef yyGLRStack yypcontext_t;
|
| 2161 |
+
static int
|
| 2162 |
+
yyreport_syntax_error (const yyGLRStack* yystackp]b4_user_formals[);
|
| 2163 |
+
|
| 2164 |
+
/* The kind of the lookahead of this context. */
|
| 2165 |
+
static yysymbol_kind_t
|
| 2166 |
+
yypcontext_token (const yyGLRStack *yystackp) YY_ATTRIBUTE_UNUSED;
|
| 2167 |
+
|
| 2168 |
+
static yysymbol_kind_t
|
| 2169 |
+
yypcontext_token (const yyGLRStack *yystackp)
|
| 2170 |
+
{
|
| 2171 |
+
YY_USE (yystackp);
|
| 2172 |
+
yysymbol_kind_t yytoken = yychar == ]b4_symbol(empty, id)[ ? ]b4_symbol(empty, kind)[ : YYTRANSLATE (yychar);
|
| 2173 |
+
return yytoken;
|
| 2174 |
+
}
|
| 2175 |
+
|
| 2176 |
+
]b4_locations_if([[/* The location of the lookahead of this context. */
|
| 2177 |
+
static const YYLTYPE *
|
| 2178 |
+
yypcontext_location (const yyGLRStack *yystackp) YY_ATTRIBUTE_UNUSED;
|
| 2179 |
+
|
| 2180 |
+
static const YYLTYPE *
|
| 2181 |
+
yypcontext_location (const yyGLRStack *yystackp)
|
| 2182 |
+
{
|
| 2183 |
+
YY_USE (yystackp);
|
| 2184 |
+
return &yylloc;
|
| 2185 |
+
}]])],
|
| 2186 |
+
[detailed\|verbose],
|
| 2187 |
+
[[static int
|
| 2188 |
+
yy_syntax_error_arguments (const yyGLRStack* yystackp,
|
| 2189 |
+
yysymbol_kind_t yyarg[], int yyargn)
|
| 2190 |
+
{
|
| 2191 |
+
yysymbol_kind_t yytoken = yychar == ]b4_symbol(empty, id)[ ? ]b4_symbol(empty, kind)[ : YYTRANSLATE (yychar);
|
| 2192 |
+
/* Actual size of YYARG. */
|
| 2193 |
+
int yycount = 0;
|
| 2194 |
+
/* There are many possibilities here to consider:
|
| 2195 |
+
- If this state is a consistent state with a default action, then
|
| 2196 |
+
the only way this function was invoked is if the default action
|
| 2197 |
+
is an error action. In that case, don't check for expected
|
| 2198 |
+
tokens because there are none.
|
| 2199 |
+
- The only way there can be no lookahead present (in yychar) is if
|
| 2200 |
+
this state is a consistent state with a default action. Thus,
|
| 2201 |
+
detecting the absence of a lookahead is sufficient to determine
|
| 2202 |
+
that there is no unexpected or expected token to report. In that
|
| 2203 |
+
case, just report a simple "syntax error".
|
| 2204 |
+
- Don't assume there isn't a lookahead just because this state is a
|
| 2205 |
+
consistent state with a default action. There might have been a
|
| 2206 |
+
previous inconsistent state, consistent state with a non-default
|
| 2207 |
+
action, or user semantic action that manipulated yychar.
|
| 2208 |
+
- Of course, the expected token list depends on states to have
|
| 2209 |
+
correct lookahead information, and it depends on the parser not
|
| 2210 |
+
to perform extra reductions after fetching a lookahead from the
|
| 2211 |
+
scanner and before detecting a syntax error. Thus, state merging
|
| 2212 |
+
(from LALR or IELR) and default reductions corrupt the expected
|
| 2213 |
+
token list. However, the list is correct for canonical LR with
|
| 2214 |
+
one exception: it will still contain any token that will not be
|
| 2215 |
+
accepted due to an error action in a later state.
|
| 2216 |
+
*/
|
| 2217 |
+
if (yytoken != ]b4_symbol(empty, kind)[)
|
| 2218 |
+
{
|
| 2219 |
+
int yyn;
|
| 2220 |
+
if (yyarg)
|
| 2221 |
+
yyarg[yycount] = yytoken;
|
| 2222 |
+
++yycount;
|
| 2223 |
+
yyn = yypcontext_expected_tokens (yystackp,
|
| 2224 |
+
yyarg ? yyarg + 1 : yyarg, yyargn - 1);
|
| 2225 |
+
if (yyn == YYENOMEM)
|
| 2226 |
+
return YYENOMEM;
|
| 2227 |
+
else
|
| 2228 |
+
yycount += yyn;
|
| 2229 |
+
}
|
| 2230 |
+
return yycount;
|
| 2231 |
+
}
|
| 2232 |
+
]])[
|
| 2233 |
+
|
| 2234 |
+
|
| 2235 |
+
static void
|
| 2236 |
+
yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
| 2237 |
+
{
|
| 2238 |
+
if (yystackp->yyerrState != 0)
|
| 2239 |
+
return;
|
| 2240 |
+
]b4_parse_error_case(
|
| 2241 |
+
[custom],
|
| 2242 |
+
[[ if (yyreport_syntax_error (yystackp]b4_user_args[))
|
| 2243 |
+
yyMemoryExhausted (yystackp);]],
|
| 2244 |
+
[simple],
|
| 2245 |
+
[[ yyerror (]b4_lyyerror_args[YY_("syntax error"));]],
|
| 2246 |
+
[[ {
|
| 2247 |
+
yybool yysize_overflow = yyfalse;
|
| 2248 |
+
char* yymsg = YY_NULLPTR;
|
| 2249 |
+
enum { YYARGS_MAX = 5 };
|
| 2250 |
+
/* Internationalized format string. */
|
| 2251 |
+
const char *yyformat = YY_NULLPTR;
|
| 2252 |
+
/* Arguments of yyformat: reported tokens (one for the "unexpected",
|
| 2253 |
+
one per "expected"). */
|
| 2254 |
+
yysymbol_kind_t yyarg[YYARGS_MAX];
|
| 2255 |
+
/* Cumulated lengths of YYARG. */
|
| 2256 |
+
YYPTRDIFF_T yysize = 0;
|
| 2257 |
+
|
| 2258 |
+
/* Actual size of YYARG. */
|
| 2259 |
+
int yycount
|
| 2260 |
+
= yy_syntax_error_arguments (yystackp, yyarg, YYARGS_MAX);
|
| 2261 |
+
if (yycount == YYENOMEM)
|
| 2262 |
+
yyMemoryExhausted (yystackp);
|
| 2263 |
+
|
| 2264 |
+
switch (yycount)
|
| 2265 |
+
{
|
| 2266 |
+
#define YYCASE_(N, S) \
|
| 2267 |
+
case N: \
|
| 2268 |
+
yyformat = S; \
|
| 2269 |
+
break
|
| 2270 |
+
default: /* Avoid compiler warnings. */
|
| 2271 |
+
YYCASE_(0, YY_("syntax error"));
|
| 2272 |
+
YYCASE_(1, YY_("syntax error, unexpected %s"));
|
| 2273 |
+
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
|
| 2274 |
+
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
|
| 2275 |
+
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
|
| 2276 |
+
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
|
| 2277 |
+
#undef YYCASE_
|
| 2278 |
+
}
|
| 2279 |
+
|
| 2280 |
+
/* Compute error message size. Don't count the "%s"s, but reserve
|
| 2281 |
+
room for the terminator. */
|
| 2282 |
+
yysize = yystrlen (yyformat) - 2 * yycount + 1;
|
| 2283 |
+
{
|
| 2284 |
+
int yyi;
|
| 2285 |
+
for (yyi = 0; yyi < yycount; ++yyi)
|
| 2286 |
+
{
|
| 2287 |
+
YYPTRDIFF_T yysz
|
| 2288 |
+
= ]b4_parse_error_case(
|
| 2289 |
+
[verbose], [[yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]])]],
|
| 2290 |
+
[[yystrlen (yysymbol_name (yyarg[yyi]))]]);[
|
| 2291 |
+
if (YYSIZE_MAXIMUM - yysize < yysz)
|
| 2292 |
+
yysize_overflow = yytrue;
|
| 2293 |
+
else
|
| 2294 |
+
yysize += yysz;
|
| 2295 |
+
}
|
| 2296 |
+
}
|
| 2297 |
+
|
| 2298 |
+
if (!yysize_overflow)
|
| 2299 |
+
yymsg = YY_CAST (char *, YYMALLOC (YY_CAST (YYSIZE_T, yysize)));
|
| 2300 |
+
|
| 2301 |
+
if (yymsg)
|
| 2302 |
+
{
|
| 2303 |
+
char *yyp = yymsg;
|
| 2304 |
+
int yyi = 0;
|
| 2305 |
+
while ((*yyp = *yyformat))
|
| 2306 |
+
{
|
| 2307 |
+
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
|
| 2308 |
+
{]b4_parse_error_case([verbose], [[
|
| 2309 |
+
yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);]], [[
|
| 2310 |
+
yyp = yystpcpy (yyp, yysymbol_name (yyarg[yyi++]));]])[
|
| 2311 |
+
yyformat += 2;
|
| 2312 |
+
}
|
| 2313 |
+
else
|
| 2314 |
+
{
|
| 2315 |
+
++yyp;
|
| 2316 |
+
++yyformat;
|
| 2317 |
+
}
|
| 2318 |
+
}
|
| 2319 |
+
yyerror (]b4_lyyerror_args[yymsg);
|
| 2320 |
+
YYFREE (yymsg);
|
| 2321 |
+
}
|
| 2322 |
+
else
|
| 2323 |
+
{
|
| 2324 |
+
yyerror (]b4_lyyerror_args[YY_("syntax error"));
|
| 2325 |
+
yyMemoryExhausted (yystackp);
|
| 2326 |
+
}
|
| 2327 |
+
}]])[
|
| 2328 |
+
yynerrs += 1;
|
| 2329 |
+
}
|
| 2330 |
+
|
| 2331 |
+
/* Recover from a syntax error on *YYSTACKP, assuming that *YYSTACKP->YYTOKENP,
|
| 2332 |
+
yylval, and yylloc are the syntactic category, semantic value, and location
|
| 2333 |
+
of the lookahead. */
|
| 2334 |
+
static void
|
| 2335 |
+
yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
| 2336 |
+
{
|
| 2337 |
+
if (yystackp->yyerrState == 3)
|
| 2338 |
+
/* We just shifted the error token and (perhaps) took some
|
| 2339 |
+
reductions. Skip tokens until we can proceed. */
|
| 2340 |
+
while (yytrue)
|
| 2341 |
+
{
|
| 2342 |
+
yysymbol_kind_t yytoken;
|
| 2343 |
+
int yyj;
|
| 2344 |
+
if (yychar == ]b4_symbol(eof, [id])[)
|
| 2345 |
+
yyFail (yystackp][]b4_lpure_args[, YY_NULLPTR);
|
| 2346 |
+
if (yychar != ]b4_symbol(empty, id)[)
|
| 2347 |
+
{]b4_locations_if([[
|
| 2348 |
+
/* We throw away the lookahead, but the error range
|
| 2349 |
+
of the shifted error token must take it into account. */
|
| 2350 |
+
yyGLRState *yys = yystackp->yytops.yystates[0];
|
| 2351 |
+
yyGLRStackItem yyerror_range[3];
|
| 2352 |
+
yyerror_range[1].yystate.yyloc = yys->yyloc;
|
| 2353 |
+
yyerror_range[2].yystate.yyloc = yylloc;
|
| 2354 |
+
YYLLOC_DEFAULT ((yys->yyloc), yyerror_range, 2);]])[
|
| 2355 |
+
yytoken = YYTRANSLATE (yychar);
|
| 2356 |
+
yydestruct ("Error: discarding",
|
| 2357 |
+
yytoken, &yylval]b4_locuser_args([&yylloc])[);
|
| 2358 |
+
yychar = ]b4_symbol(empty, id)[;
|
| 2359 |
+
}
|
| 2360 |
+
yytoken = ]b4_yygetToken_call[;
|
| 2361 |
+
yyj = yypact[yystackp->yytops.yystates[0]->yylrState];
|
| 2362 |
+
if (yypact_value_is_default (yyj))
|
| 2363 |
+
return;
|
| 2364 |
+
yyj += yytoken;
|
| 2365 |
+
if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != yytoken)
|
| 2366 |
+
{
|
| 2367 |
+
if (yydefact[yystackp->yytops.yystates[0]->yylrState] != 0)
|
| 2368 |
+
return;
|
| 2369 |
+
}
|
| 2370 |
+
else if (! yytable_value_is_error (yytable[yyj]))
|
| 2371 |
+
return;
|
| 2372 |
+
}
|
| 2373 |
+
|
| 2374 |
+
/* Reduce to one stack. */
|
| 2375 |
+
{
|
| 2376 |
+
YYPTRDIFF_T yyk;
|
| 2377 |
+
for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1)
|
| 2378 |
+
if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
|
| 2379 |
+
break;
|
| 2380 |
+
if (yyk >= yystackp->yytops.yysize)
|
| 2381 |
+
yyFail (yystackp][]b4_lpure_args[, YY_NULLPTR);
|
| 2382 |
+
for (yyk += 1; yyk < yystackp->yytops.yysize; yyk += 1)
|
| 2383 |
+
yymarkStackDeleted (yystackp, yyk);
|
| 2384 |
+
yyremoveDeletes (yystackp);
|
| 2385 |
+
yycompressStack (yystackp);
|
| 2386 |
+
}
|
| 2387 |
+
|
| 2388 |
+
/* Pop stack until we find a state that shifts the error token. */
|
| 2389 |
+
yystackp->yyerrState = 3;
|
| 2390 |
+
while (yystackp->yytops.yystates[0] != YY_NULLPTR)
|
| 2391 |
+
{
|
| 2392 |
+
yyGLRState *yys = yystackp->yytops.yystates[0];
|
| 2393 |
+
int yyj = yypact[yys->yylrState];
|
| 2394 |
+
if (! yypact_value_is_default (yyj))
|
| 2395 |
+
{
|
| 2396 |
+
yyj += ]b4_symbol(error, kind)[;
|
| 2397 |
+
if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == ]b4_symbol(error, kind)[
|
| 2398 |
+
&& yyisShiftAction (yytable[yyj]))
|
| 2399 |
+
{
|
| 2400 |
+
/* Shift the error token. */
|
| 2401 |
+
int yyaction = yytable[yyj];]b4_locations_if([[
|
| 2402 |
+
/* First adjust its location.*/
|
| 2403 |
+
YYLTYPE yyerrloc;
|
| 2404 |
+
yystackp->yyerror_range[2].yystate.yyloc = yylloc;
|
| 2405 |
+
YYLLOC_DEFAULT (yyerrloc, (yystackp->yyerror_range), 2);]])[
|
| 2406 |
+
YY_SYMBOL_PRINT ("Shifting", yy_accessing_symbol (yyaction),
|
| 2407 |
+
&yylval, &yyerrloc);
|
| 2408 |
+
yyglrShift (yystackp, 0, yyaction,
|
| 2409 |
+
yys->yyposn, &yylval]b4_locations_if([, &yyerrloc])[);
|
| 2410 |
+
yys = yystackp->yytops.yystates[0];
|
| 2411 |
+
break;
|
| 2412 |
+
}
|
| 2413 |
+
}]b4_locations_if([[
|
| 2414 |
+
yystackp->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
|
| 2415 |
+
if (yys->yypred != YY_NULLPTR)
|
| 2416 |
+
yydestroyGLRState ("Error: popping", yys]b4_user_args[);
|
| 2417 |
+
yystackp->yytops.yystates[0] = yys->yypred;
|
| 2418 |
+
yystackp->yynextFree -= 1;
|
| 2419 |
+
yystackp->yyspaceLeft += 1;
|
| 2420 |
+
}
|
| 2421 |
+
if (yystackp->yytops.yystates[0] == YY_NULLPTR)
|
| 2422 |
+
yyFail (yystackp][]b4_lpure_args[, YY_NULLPTR);
|
| 2423 |
+
}
|
| 2424 |
+
|
| 2425 |
+
#define YYCHK1(YYE) \
|
| 2426 |
+
do { \
|
| 2427 |
+
switch (YYE) { \
|
| 2428 |
+
case yyok: break; \
|
| 2429 |
+
case yyabort: goto yyabortlab; \
|
| 2430 |
+
case yyaccept: goto yyacceptlab; \
|
| 2431 |
+
case yyerr: goto yyuser_error; \
|
| 2432 |
+
case yynomem: goto yyexhaustedlab; \
|
| 2433 |
+
default: goto yybuglab; \
|
| 2434 |
+
} \
|
| 2435 |
+
} while (0)
|
| 2436 |
+
|
| 2437 |
+
/*----------.
|
| 2438 |
+
| yyparse. |
|
| 2439 |
+
`----------*/
|
| 2440 |
+
|
| 2441 |
+
int
|
| 2442 |
+
]b4_glr_cc_if([yy_parse_impl], [yyparse])[ (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)
|
| 2443 |
+
{
|
| 2444 |
+
int yyresult;
|
| 2445 |
+
yyGLRStack yystack;
|
| 2446 |
+
yyGLRStack* const yystackp = &yystack;
|
| 2447 |
+
YYPTRDIFF_T yyposn;
|
| 2448 |
+
|
| 2449 |
+
YY_DPRINTF ((stderr, "Starting parse\n"));
|
| 2450 |
+
|
| 2451 |
+
yychar = ]b4_symbol(empty, id)[;
|
| 2452 |
+
yylval = yyval_default;]b4_locations_if([
|
| 2453 |
+
yylloc = yyloc_default;])[
|
| 2454 |
+
]m4_ifdef([b4_initial_action], [
|
| 2455 |
+
b4_dollar_pushdef([yylval], [], [], [yylloc])dnl
|
| 2456 |
+
b4_user_initial_action
|
| 2457 |
+
b4_dollar_popdef])[]dnl
|
| 2458 |
+
[
|
| 2459 |
+
if (! yyinitGLRStack (yystackp, YYINITDEPTH))
|
| 2460 |
+
goto yyexhaustedlab;
|
| 2461 |
+
switch (YYSETJMP (yystack.yyexception_buffer))
|
| 2462 |
+
{
|
| 2463 |
+
case 0: break;
|
| 2464 |
+
case 1: goto yyabortlab;
|
| 2465 |
+
case 2: goto yyexhaustedlab;
|
| 2466 |
+
default: goto yybuglab;
|
| 2467 |
+
}
|
| 2468 |
+
yyglrShift (&yystack, 0, 0, 0, &yylval]b4_locations_if([, &yylloc])[);
|
| 2469 |
+
yyposn = 0;
|
| 2470 |
+
|
| 2471 |
+
while (yytrue)
|
| 2472 |
+
{
|
| 2473 |
+
/* For efficiency, we have two loops, the first of which is
|
| 2474 |
+
specialized to deterministic operation (single stack, no
|
| 2475 |
+
potential ambiguity). */
|
| 2476 |
+
/* Standard mode. */
|
| 2477 |
+
while (yytrue)
|
| 2478 |
+
{
|
| 2479 |
+
yy_state_t yystate = yystack.yytops.yystates[0]->yylrState;
|
| 2480 |
+
YY_DPRINTF ((stderr, "Entering state %d\n", yystate));
|
| 2481 |
+
if (yystate == YYFINAL)
|
| 2482 |
+
goto yyacceptlab;
|
| 2483 |
+
if (yyisDefaultedState (yystate))
|
| 2484 |
+
{
|
| 2485 |
+
yyRuleNum yyrule = yydefaultAction (yystate);
|
| 2486 |
+
if (yyrule == 0)
|
| 2487 |
+
{]b4_locations_if([[
|
| 2488 |
+
yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
|
| 2489 |
+
yyreportSyntaxError (&yystack]b4_user_args[);
|
| 2490 |
+
goto yyuser_error;
|
| 2491 |
+
}
|
| 2492 |
+
YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue]b4_user_args[));
|
| 2493 |
+
}
|
| 2494 |
+
else
|
| 2495 |
+
{
|
| 2496 |
+
yysymbol_kind_t yytoken = ]b4_yygetToken_call;[
|
| 2497 |
+
const short* yyconflicts;
|
| 2498 |
+
int yyaction = yygetLRActions (yystate, yytoken, &yyconflicts);
|
| 2499 |
+
if (*yyconflicts)
|
| 2500 |
+
/* Enter nondeterministic mode. */
|
| 2501 |
+
break;
|
| 2502 |
+
if (yyisShiftAction (yyaction))
|
| 2503 |
+
{
|
| 2504 |
+
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
|
| 2505 |
+
yychar = ]b4_symbol(empty, id)[;
|
| 2506 |
+
yyposn += 1;
|
| 2507 |
+
yyglrShift (&yystack, 0, yyaction, yyposn, &yylval]b4_locations_if([, &yylloc])[);
|
| 2508 |
+
if (0 < yystack.yyerrState)
|
| 2509 |
+
yystack.yyerrState -= 1;
|
| 2510 |
+
}
|
| 2511 |
+
else if (yyisErrorAction (yyaction))
|
| 2512 |
+
{]b4_locations_if([[
|
| 2513 |
+
yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
|
| 2514 |
+
/* Issue an error message unless the scanner already
|
| 2515 |
+
did. */
|
| 2516 |
+
if (yychar != ]b4_symbol(error, id)[)
|
| 2517 |
+
yyreportSyntaxError (&yystack]b4_user_args[);
|
| 2518 |
+
goto yyuser_error;
|
| 2519 |
+
}
|
| 2520 |
+
else
|
| 2521 |
+
YYCHK1 (yyglrReduce (&yystack, 0, -yyaction, yytrue]b4_user_args[));
|
| 2522 |
+
}
|
| 2523 |
+
}
|
| 2524 |
+
|
| 2525 |
+
/* Nondeterministic mode. */
|
| 2526 |
+
while (yytrue)
|
| 2527 |
+
{
|
| 2528 |
+
yysymbol_kind_t yytoken_to_shift;
|
| 2529 |
+
YYPTRDIFF_T yys;
|
| 2530 |
+
|
| 2531 |
+
for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
|
| 2532 |
+
yystackp->yytops.yylookaheadNeeds[yys] = yychar != ]b4_symbol(empty, id)[;
|
| 2533 |
+
|
| 2534 |
+
/* yyprocessOneStack returns one of three things:
|
| 2535 |
+
|
| 2536 |
+
- An error flag. If the caller is yyprocessOneStack, it
|
| 2537 |
+
immediately returns as well. When the caller is finally
|
| 2538 |
+
yyparse, it jumps to an error label via YYCHK1.
|
| 2539 |
+
|
| 2540 |
+
- yyok, but yyprocessOneStack has invoked yymarkStackDeleted
|
| 2541 |
+
(&yystack, yys), which sets the top state of yys to NULL. Thus,
|
| 2542 |
+
yyparse's following invocation of yyremoveDeletes will remove
|
| 2543 |
+
the stack.
|
| 2544 |
+
|
| 2545 |
+
- yyok, when ready to shift a token.
|
| 2546 |
+
|
| 2547 |
+
Except in the first case, yyparse will invoke yyremoveDeletes and
|
| 2548 |
+
then shift the next token onto all remaining stacks. This
|
| 2549 |
+
synchronization of the shift (that is, after all preceding
|
| 2550 |
+
reductions on all stacks) helps prevent double destructor calls
|
| 2551 |
+
on yylval in the event of memory exhaustion. */
|
| 2552 |
+
|
| 2553 |
+
for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
|
| 2554 |
+
YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn]b4_lpure_args[));
|
| 2555 |
+
yyremoveDeletes (&yystack);
|
| 2556 |
+
if (yystack.yytops.yysize == 0)
|
| 2557 |
+
{
|
| 2558 |
+
yyundeleteLastStack (&yystack);
|
| 2559 |
+
if (yystack.yytops.yysize == 0)
|
| 2560 |
+
yyFail (&yystack][]b4_lpure_args[, YY_("syntax error"));
|
| 2561 |
+
YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
|
| 2562 |
+
YY_DPRINTF ((stderr, "Returning to deterministic operation.\n"));]b4_locations_if([[
|
| 2563 |
+
yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
|
| 2564 |
+
yyreportSyntaxError (&yystack]b4_user_args[);
|
| 2565 |
+
goto yyuser_error;
|
| 2566 |
+
}
|
| 2567 |
+
|
| 2568 |
+
/* If any yyglrShift call fails, it will fail after shifting. Thus,
|
| 2569 |
+
a copy of yylval will already be on stack 0 in the event of a
|
| 2570 |
+
failure in the following loop. Thus, yychar is set to ]b4_symbol(empty, id)[
|
| 2571 |
+
before the loop to make sure the user destructor for yylval isn't
|
| 2572 |
+
called twice. */
|
| 2573 |
+
yytoken_to_shift = YYTRANSLATE (yychar);
|
| 2574 |
+
yychar = ]b4_symbol(empty, id)[;
|
| 2575 |
+
yyposn += 1;
|
| 2576 |
+
for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
|
| 2577 |
+
{
|
| 2578 |
+
yy_state_t yystate = yystack.yytops.yystates[yys]->yylrState;
|
| 2579 |
+
const short* yyconflicts;
|
| 2580 |
+
int yyaction = yygetLRActions (yystate, yytoken_to_shift,
|
| 2581 |
+
&yyconflicts);
|
| 2582 |
+
/* Note that yyconflicts were handled by yyprocessOneStack. */
|
| 2583 |
+
YY_DPRINTF ((stderr, "On stack %ld, ", YY_CAST (long, yys)));
|
| 2584 |
+
YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, &yylval, &yylloc);
|
| 2585 |
+
yyglrShift (&yystack, yys, yyaction, yyposn,
|
| 2586 |
+
&yylval]b4_locations_if([, &yylloc])[);
|
| 2587 |
+
YY_DPRINTF ((stderr, "Stack %ld now in state %d\n",
|
| 2588 |
+
YY_CAST (long, yys),
|
| 2589 |
+
yystack.yytops.yystates[yys]->yylrState));
|
| 2590 |
+
}
|
| 2591 |
+
|
| 2592 |
+
if (yystack.yytops.yysize == 1)
|
| 2593 |
+
{
|
| 2594 |
+
YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
|
| 2595 |
+
YY_DPRINTF ((stderr, "Returning to deterministic operation.\n"));
|
| 2596 |
+
yycompressStack (&yystack);
|
| 2597 |
+
break;
|
| 2598 |
+
}
|
| 2599 |
+
}
|
| 2600 |
+
continue;
|
| 2601 |
+
yyuser_error:
|
| 2602 |
+
yyrecoverSyntaxError (&yystack]b4_user_args[);
|
| 2603 |
+
yyposn = yystack.yytops.yystates[0]->yyposn;
|
| 2604 |
+
}
|
| 2605 |
+
|
| 2606 |
+
yyacceptlab:
|
| 2607 |
+
yyresult = 0;
|
| 2608 |
+
goto yyreturnlab;
|
| 2609 |
+
|
| 2610 |
+
yybuglab:
|
| 2611 |
+
YY_ASSERT (yyfalse);
|
| 2612 |
+
goto yyabortlab;
|
| 2613 |
+
|
| 2614 |
+
yyabortlab:
|
| 2615 |
+
yyresult = 1;
|
| 2616 |
+
goto yyreturnlab;
|
| 2617 |
+
|
| 2618 |
+
yyexhaustedlab:
|
| 2619 |
+
yyerror (]b4_lyyerror_args[YY_("memory exhausted"));
|
| 2620 |
+
yyresult = 2;
|
| 2621 |
+
goto yyreturnlab;
|
| 2622 |
+
|
| 2623 |
+
yyreturnlab:
|
| 2624 |
+
if (yychar != ]b4_symbol(empty, id)[)
|
| 2625 |
+
yydestruct ("Cleanup: discarding lookahead",
|
| 2626 |
+
YYTRANSLATE (yychar), &yylval]b4_locuser_args([&yylloc])[);
|
| 2627 |
+
|
| 2628 |
+
/* If the stack is well-formed, pop the stack until it is empty,
|
| 2629 |
+
destroying its entries as we go. But free the stack regardless
|
| 2630 |
+
of whether it is well-formed. */
|
| 2631 |
+
if (yystack.yyitems)
|
| 2632 |
+
{
|
| 2633 |
+
yyGLRState** yystates = yystack.yytops.yystates;
|
| 2634 |
+
if (yystates)
|
| 2635 |
+
{
|
| 2636 |
+
YYPTRDIFF_T yysize = yystack.yytops.yysize;
|
| 2637 |
+
YYPTRDIFF_T yyk;
|
| 2638 |
+
for (yyk = 0; yyk < yysize; yyk += 1)
|
| 2639 |
+
if (yystates[yyk])
|
| 2640 |
+
{
|
| 2641 |
+
while (yystates[yyk])
|
| 2642 |
+
{
|
| 2643 |
+
yyGLRState *yys = yystates[yyk];]b4_locations_if([[
|
| 2644 |
+
yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
|
| 2645 |
+
if (yys->yypred != YY_NULLPTR)
|
| 2646 |
+
yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[);
|
| 2647 |
+
yystates[yyk] = yys->yypred;
|
| 2648 |
+
yystack.yynextFree -= 1;
|
| 2649 |
+
yystack.yyspaceLeft += 1;
|
| 2650 |
+
}
|
| 2651 |
+
break;
|
| 2652 |
+
}
|
| 2653 |
+
}
|
| 2654 |
+
yyfreeGLRStack (&yystack);
|
| 2655 |
+
}
|
| 2656 |
+
|
| 2657 |
+
return yyresult;
|
| 2658 |
+
}
|
| 2659 |
+
|
| 2660 |
+
/* DEBUGGING ONLY */
|
| 2661 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 2662 |
+
/* Print *YYS and its predecessors. */
|
| 2663 |
+
static void
|
| 2664 |
+
yy_yypstack (yyGLRState* yys)
|
| 2665 |
+
{
|
| 2666 |
+
if (yys->yypred)
|
| 2667 |
+
{
|
| 2668 |
+
yy_yypstack (yys->yypred);
|
| 2669 |
+
YY_FPRINTF ((stderr, " -> "));
|
| 2670 |
+
}
|
| 2671 |
+
YY_FPRINTF ((stderr, "%d@@%ld", yys->yylrState, YY_CAST (long, yys->yyposn)));
|
| 2672 |
+
}
|
| 2673 |
+
|
| 2674 |
+
/* Print YYS (possibly NULL) and its predecessors. */
|
| 2675 |
+
static void
|
| 2676 |
+
yypstates (yyGLRState* yys)
|
| 2677 |
+
{
|
| 2678 |
+
if (yys == YY_NULLPTR)
|
| 2679 |
+
YY_FPRINTF ((stderr, "<null>"));
|
| 2680 |
+
else
|
| 2681 |
+
yy_yypstack (yys);
|
| 2682 |
+
YY_FPRINTF ((stderr, "\n"));
|
| 2683 |
+
}
|
| 2684 |
+
|
| 2685 |
+
/* Print the stack #YYK. */
|
| 2686 |
+
static void
|
| 2687 |
+
yypstack (yyGLRStack* yystackp, YYPTRDIFF_T yyk)
|
| 2688 |
+
{
|
| 2689 |
+
yypstates (yystackp->yytops.yystates[yyk]);
|
| 2690 |
+
}
|
| 2691 |
+
|
| 2692 |
+
/* Print all the stacks. */
|
| 2693 |
+
static void
|
| 2694 |
+
yypdumpstack (yyGLRStack* yystackp)
|
| 2695 |
+
{
|
| 2696 |
+
#define YYINDEX(YYX) \
|
| 2697 |
+
YY_CAST (long, \
|
| 2698 |
+
((YYX) \
|
| 2699 |
+
? YY_REINTERPRET_CAST (yyGLRStackItem*, (YYX)) - yystackp->yyitems \
|
| 2700 |
+
: -1))
|
| 2701 |
+
|
| 2702 |
+
yyGLRStackItem* yyp;
|
| 2703 |
+
for (yyp = yystackp->yyitems; yyp < yystackp->yynextFree; yyp += 1)
|
| 2704 |
+
{
|
| 2705 |
+
YY_FPRINTF ((stderr, "%3ld. ",
|
| 2706 |
+
YY_CAST (long, yyp - yystackp->yyitems)));
|
| 2707 |
+
if (*YY_REINTERPRET_CAST (yybool *, yyp))
|
| 2708 |
+
{
|
| 2709 |
+
YY_ASSERT (yyp->yystate.yyisState);
|
| 2710 |
+
YY_ASSERT (yyp->yyoption.yyisState);
|
| 2711 |
+
YY_FPRINTF ((stderr, "Res: %d, LR State: %d, posn: %ld, pred: %ld",
|
| 2712 |
+
yyp->yystate.yyresolved, yyp->yystate.yylrState,
|
| 2713 |
+
YY_CAST (long, yyp->yystate.yyposn),
|
| 2714 |
+
YYINDEX (yyp->yystate.yypred)));
|
| 2715 |
+
if (! yyp->yystate.yyresolved)
|
| 2716 |
+
YY_FPRINTF ((stderr, ", firstVal: %ld",
|
| 2717 |
+
YYINDEX (yyp->yystate.yysemantics.yyfirstVal)));
|
| 2718 |
+
}
|
| 2719 |
+
else
|
| 2720 |
+
{
|
| 2721 |
+
YY_ASSERT (!yyp->yystate.yyisState);
|
| 2722 |
+
YY_ASSERT (!yyp->yyoption.yyisState);
|
| 2723 |
+
YY_FPRINTF ((stderr, "Option. rule: %d, state: %ld, next: %ld",
|
| 2724 |
+
yyp->yyoption.yyrule - 1,
|
| 2725 |
+
YYINDEX (yyp->yyoption.yystate),
|
| 2726 |
+
YYINDEX (yyp->yyoption.yynext)));
|
| 2727 |
+
}
|
| 2728 |
+
YY_FPRINTF ((stderr, "\n"));
|
| 2729 |
+
}
|
| 2730 |
+
|
| 2731 |
+
YY_FPRINTF ((stderr, "Tops:"));
|
| 2732 |
+
{
|
| 2733 |
+
YYPTRDIFF_T yyi;
|
| 2734 |
+
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
|
| 2735 |
+
YY_FPRINTF ((stderr, "%ld: %ld; ", YY_CAST (long, yyi),
|
| 2736 |
+
YYINDEX (yystackp->yytops.yystates[yyi])));
|
| 2737 |
+
YY_FPRINTF ((stderr, "\n"));
|
| 2738 |
+
}
|
| 2739 |
+
#undef YYINDEX
|
| 2740 |
+
}
|
| 2741 |
+
#endif
|
| 2742 |
+
|
| 2743 |
+
#undef yylval
|
| 2744 |
+
#undef yychar
|
| 2745 |
+
#undef yynerrs]b4_locations_if([
|
| 2746 |
+
#undef yylloc])
|
| 2747 |
+
|
| 2748 |
+
m4_if(b4_prefix, [yy], [],
|
| 2749 |
+
[[/* Substitute the variable and function names. */
|
| 2750 |
+
#define yyparse ]b4_prefix[parse
|
| 2751 |
+
#define yylex ]b4_prefix[lex
|
| 2752 |
+
#define yyerror ]b4_prefix[error
|
| 2753 |
+
#define yylval ]b4_prefix[lval
|
| 2754 |
+
#define yychar ]b4_prefix[char
|
| 2755 |
+
#define yydebug ]b4_prefix[debug
|
| 2756 |
+
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
|
| 2757 |
+
#define yylloc ]b4_prefix[lloc]])])[
|
| 2758 |
+
|
| 2759 |
+
]b4_glr_cc_if([b4_glr_cc_pre_epilogue
|
| 2760 |
+
b4_glr_cc_cleanup])[
|
| 2761 |
+
]b4_percent_code_get([[epilogue]])[]dnl
|
| 2762 |
+
b4_epilogue[]dnl
|
| 2763 |
+
b4_output_end
|
platform/dbops/binaries/build/share/bison/skeletons/glr.cc
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# C++ GLR skeleton for Bison
|
| 2 |
+
|
| 3 |
+
# Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc.
|
| 4 |
+
|
| 5 |
+
# This program is free software: you can redistribute it and/or modify
|
| 6 |
+
# it under the terms of the GNU General Public License as published by
|
| 7 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 8 |
+
# (at your option) any later version.
|
| 9 |
+
#
|
| 10 |
+
# This program is distributed in the hope that it will be useful,
|
| 11 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 13 |
+
# GNU General Public License for more details.
|
| 14 |
+
#
|
| 15 |
+
# You should have received a copy of the GNU General Public License
|
| 16 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# This skeleton produces a C++ class that encapsulates a C glr parser.
|
| 20 |
+
# This is in order to reduce the maintenance burden. The glr.c
|
| 21 |
+
# skeleton is clean and pure enough so that there are no real
|
| 22 |
+
# problems. The C++ interface is the same as that of lalr1.cc. In
|
| 23 |
+
# fact, glr.c can replace yacc.c without the user noticing any
|
| 24 |
+
# difference, and similarly for glr.cc replacing lalr1.cc.
|
| 25 |
+
#
|
| 26 |
+
# The passing of parse-params
|
| 27 |
+
#
|
| 28 |
+
# The additional arguments are stored as members of the parser
|
| 29 |
+
# object, yyparser. The C routines need to carry yyparser
|
| 30 |
+
# throughout the C parser; that's easy: make yyparser an
|
| 31 |
+
# additional parse-param. But because the C++ skeleton needs to
|
| 32 |
+
# know the "real" original parse-param, we save them
|
| 33 |
+
# (b4_parse_param_orig). Note that b4_parse_param is overquoted
|
| 34 |
+
# (and c.m4 strips one level of quotes). This is a PITA, and
|
| 35 |
+
# explains why there are so many levels of quotes.
|
| 36 |
+
#
|
| 37 |
+
# The locations
|
| 38 |
+
#
|
| 39 |
+
# We use location.cc just like lalr1.cc, but because glr.c stores
|
| 40 |
+
# the locations in a union, the position and location classes
|
| 41 |
+
# must not have a constructor. Therefore, contrary to lalr1.cc, we
|
| 42 |
+
# must not define "b4_location_constructors". As a consequence the
|
| 43 |
+
# user must initialize the first positions (in particular the
|
| 44 |
+
# filename member).
|
| 45 |
+
|
| 46 |
+
# We require a pure interface.
|
| 47 |
+
m4_define([b4_pure_flag], [1])
|
| 48 |
+
|
| 49 |
+
m4_include(b4_skeletonsdir/[c++.m4])
|
| 50 |
+
b4_bison_locations_if([m4_include(b4_skeletonsdir/[location.cc])])
|
| 51 |
+
|
| 52 |
+
m4_define([b4_parser_class],
|
| 53 |
+
[b4_percent_define_get([[api.parser.class]])])
|
| 54 |
+
|
| 55 |
+
# Save the parse parameters.
|
| 56 |
+
m4_define([b4_parse_param_orig], m4_defn([b4_parse_param]))
|
| 57 |
+
|
| 58 |
+
# b4_parse_param_wrap
|
| 59 |
+
# -------------------
|
| 60 |
+
# New ones.
|
| 61 |
+
m4_ifset([b4_parse_param],
|
| 62 |
+
[m4_define([b4_parse_param_wrap],
|
| 63 |
+
[[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]],]
|
| 64 |
+
m4_defn([b4_parse_param]))],
|
| 65 |
+
[m4_define([b4_parse_param_wrap],
|
| 66 |
+
[[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]]])
|
| 67 |
+
])
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
# b4_yy_symbol_print_define
|
| 71 |
+
# -------------------------
|
| 72 |
+
# Bypass the default implementation to generate the "yy_symbol_print"
|
| 73 |
+
# and "yy_symbol_value_print" functions.
|
| 74 |
+
m4_define([b4_yy_symbol_print_define],
|
| 75 |
+
[[/*--------------------.
|
| 76 |
+
| Print this symbol. |
|
| 77 |
+
`--------------------*/
|
| 78 |
+
|
| 79 |
+
static void
|
| 80 |
+
yy_symbol_print (FILE *, ]b4_namespace_ref::b4_parser_class[::symbol_kind_type yytoken,
|
| 81 |
+
const ]b4_namespace_ref::b4_parser_class[::value_type *yyvaluep]b4_locations_if([[,
|
| 82 |
+
const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp]])[]b4_user_formals[)
|
| 83 |
+
{
|
| 84 |
+
]b4_parse_param_use[]dnl
|
| 85 |
+
[ yyparser.yy_symbol_print_ (yytoken, yyvaluep]b4_locations_if([, yylocationp])[);
|
| 86 |
+
}
|
| 87 |
+
]])[
|
| 88 |
+
|
| 89 |
+
# Hijack the initial action to initialize the locations.
|
| 90 |
+
]b4_bison_locations_if([m4_define([b4_initial_action],
|
| 91 |
+
[yylloc.initialize ();]m4_ifdef([b4_initial_action], [
|
| 92 |
+
m4_defn([b4_initial_action])]))])[
|
| 93 |
+
|
| 94 |
+
# Hijack the post prologue to declare yyerror.
|
| 95 |
+
]m4_append([b4_post_prologue],
|
| 96 |
+
[b4_syncline([@oline@], [@ofile@])dnl
|
| 97 |
+
[static void
|
| 98 |
+
yyerror (]b4_locations_if([[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp,
|
| 99 |
+
]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param),
|
| 100 |
+
])[const char* msg);]])[
|
| 101 |
+
|
| 102 |
+
# Inserted before the epilogue to define implementations (yyerror, parser member
|
| 103 |
+
# functions etc.).
|
| 104 |
+
]m4_define([b4_glr_cc_pre_epilogue],
|
| 105 |
+
[b4_syncline([@oline@], [@ofile@])dnl
|
| 106 |
+
[
|
| 107 |
+
/*------------------.
|
| 108 |
+
| Report an error. |
|
| 109 |
+
`------------------*/
|
| 110 |
+
|
| 111 |
+
static void
|
| 112 |
+
yyerror (]b4_locations_if([[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp,
|
| 113 |
+
]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param),
|
| 114 |
+
])[const char* msg)
|
| 115 |
+
{
|
| 116 |
+
]b4_parse_param_use[]dnl
|
| 117 |
+
[ yyparser.error (]b4_locations_if([[*yylocationp, ]])[msg);
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
]b4_namespace_open[
|
| 122 |
+
]dnl In this section, the parse params are the original parse_params.
|
| 123 |
+
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
| 124 |
+
[ /// Build a parser object.
|
| 125 |
+
]b4_parser_class::b4_parser_class[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
| 126 |
+
:])[
|
| 127 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 128 |
+
]m4_ifset([b4_parse_param], [ ], [ :])[yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
| 129 |
+
#endif]b4_parse_param_cons[
|
| 130 |
+
{}
|
| 131 |
+
|
| 132 |
+
]b4_parser_class::~b4_parser_class[ ()
|
| 133 |
+
{}
|
| 134 |
+
|
| 135 |
+
]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
|
| 136 |
+
{}
|
| 137 |
+
|
| 138 |
+
int
|
| 139 |
+
]b4_parser_class[::operator() ()
|
| 140 |
+
{
|
| 141 |
+
return parse ();
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
int
|
| 145 |
+
]b4_parser_class[::parse ()
|
| 146 |
+
{
|
| 147 |
+
return ::yy_parse_impl (*this]b4_user_args[);
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 151 |
+
/*--------------------.
|
| 152 |
+
| Print this symbol. |
|
| 153 |
+
`--------------------*/
|
| 154 |
+
|
| 155 |
+
void
|
| 156 |
+
]b4_parser_class[::yy_symbol_value_print_ (symbol_kind_type yykind,
|
| 157 |
+
const value_type* yyvaluep]b4_locations_if([[,
|
| 158 |
+
const location_type* yylocationp]])[) const
|
| 159 |
+
{]b4_locations_if([[
|
| 160 |
+
YY_USE (yylocationp);]])[
|
| 161 |
+
YY_USE (yyvaluep);
|
| 162 |
+
std::ostream& yyo = debug_stream ();
|
| 163 |
+
std::ostream& yyoutput = yyo;
|
| 164 |
+
YY_USE (yyoutput);
|
| 165 |
+
]b4_symbol_actions([printer])[
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
void
|
| 170 |
+
]b4_parser_class[::yy_symbol_print_ (symbol_kind_type yykind,
|
| 171 |
+
const value_type* yyvaluep]b4_locations_if([[,
|
| 172 |
+
const location_type* yylocationp]])[) const
|
| 173 |
+
{
|
| 174 |
+
*yycdebug_ << (yykind < YYNTOKENS ? "token" : "nterm")
|
| 175 |
+
<< ' ' << yysymbol_name (yykind) << " ("]b4_locations_if([[
|
| 176 |
+
<< *yylocationp << ": "]])[;
|
| 177 |
+
yy_symbol_value_print_ (yykind, yyvaluep]b4_locations_if([[, yylocationp]])[);
|
| 178 |
+
*yycdebug_ << ')';
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
std::ostream&
|
| 182 |
+
]b4_parser_class[::debug_stream () const
|
| 183 |
+
{
|
| 184 |
+
return *yycdebug_;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
void
|
| 188 |
+
]b4_parser_class[::set_debug_stream (std::ostream& o)
|
| 189 |
+
{
|
| 190 |
+
yycdebug_ = &o;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
]b4_parser_class[::debug_level_type
|
| 195 |
+
]b4_parser_class[::debug_level () const
|
| 196 |
+
{
|
| 197 |
+
return yydebug;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
void
|
| 201 |
+
]b4_parser_class[::set_debug_level (debug_level_type l)
|
| 202 |
+
{
|
| 203 |
+
// Actually, it is yydebug which is really used.
|
| 204 |
+
yydebug = l;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
#endif
|
| 208 |
+
]m4_popdef([b4_parse_param])dnl
|
| 209 |
+
b4_namespace_close[]dnl
|
| 210 |
+
])
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
m4_define([b4_define_symbol_kind],
|
| 214 |
+
[m4_format([#define %-15s %s],
|
| 215 |
+
b4_symbol($][1, kind_base),
|
| 216 |
+
b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol($1, kind_base))
|
| 217 |
+
])
|
| 218 |
+
|
| 219 |
+
# b4_glr_cc_setup
|
| 220 |
+
# ---------------
|
| 221 |
+
# Setup redirections for glr.c: Map the names used in c.m4 to the ones used
|
| 222 |
+
# in c++.m4.
|
| 223 |
+
m4_define([b4_glr_cc_setup],
|
| 224 |
+
[[]b4_attribute_define[
|
| 225 |
+
]b4_null_define[
|
| 226 |
+
|
| 227 |
+
// This skeleton is based on C, yet compiles it as C++.
|
| 228 |
+
// So expect warnings about C style casts.
|
| 229 |
+
#if defined __clang__ && 306 <= __clang_major__ * 100 + __clang_minor__
|
| 230 |
+
# pragma clang diagnostic ignored "-Wold-style-cast"
|
| 231 |
+
#elif defined __GNUC__ && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
|
| 232 |
+
# pragma GCC diagnostic ignored "-Wold-style-cast"
|
| 233 |
+
#endif
|
| 234 |
+
|
| 235 |
+
// On MacOS, PTRDIFF_MAX is defined as long long, which Clang's
|
| 236 |
+
// -pedantic reports as being a C++11 extension.
|
| 237 |
+
#if defined __APPLE__ && YY_CPLUSPLUS < 201103L \
|
| 238 |
+
&& defined __clang__ && 4 <= __clang_major__
|
| 239 |
+
# pragma clang diagnostic ignored "-Wc++11-long-long"
|
| 240 |
+
#endif
|
| 241 |
+
|
| 242 |
+
#undef ]b4_symbol(empty, [id])[
|
| 243 |
+
#define ]b4_symbol(empty, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(empty, [id])[
|
| 244 |
+
#undef ]b4_symbol(eof, [id])[
|
| 245 |
+
#define ]b4_symbol(eof, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(eof, [id])[
|
| 246 |
+
#undef ]b4_symbol(error, [id])[
|
| 247 |
+
#define ]b4_symbol(error, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(error, [id])[
|
| 248 |
+
|
| 249 |
+
#ifndef ]b4_api_PREFIX[STYPE
|
| 250 |
+
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class[::value_type
|
| 251 |
+
#endif
|
| 252 |
+
#ifndef ]b4_api_PREFIX[LTYPE
|
| 253 |
+
# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class[::location_type
|
| 254 |
+
#endif
|
| 255 |
+
|
| 256 |
+
typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type yysymbol_kind_t;
|
| 257 |
+
|
| 258 |
+
// Expose C++ symbol kinds to C.
|
| 259 |
+
]b4_define_symbol_kind(-2)dnl
|
| 260 |
+
b4_symbol_foreach([b4_define_symbol_kind])])[
|
| 261 |
+
]])
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
m4_define([b4_undef_symbol_kind],
|
| 265 |
+
[[#undef ]b4_symbol($1, kind_base)[
|
| 266 |
+
]])
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
# b4_glr_cc_cleanup
|
| 270 |
+
# -----------------
|
| 271 |
+
# Remove redirections for glr.c.
|
| 272 |
+
m4_define([b4_glr_cc_cleanup],
|
| 273 |
+
[[#undef ]b4_symbol(empty, [id])[
|
| 274 |
+
#undef ]b4_symbol(eof, [id])[
|
| 275 |
+
#undef ]b4_symbol(error, [id])[
|
| 276 |
+
|
| 277 |
+
]b4_undef_symbol_kind(-2)dnl
|
| 278 |
+
b4_symbol_foreach([b4_undef_symbol_kind])dnl
|
| 279 |
+
])
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
# b4_shared_declarations(hh|cc)
|
| 283 |
+
# -----------------------------
|
| 284 |
+
# Declaration that might either go into the header (if --header, $1 = hh)
|
| 285 |
+
# or in the implementation file.
|
| 286 |
+
m4_define([b4_shared_declarations],
|
| 287 |
+
[m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
| 288 |
+
b4_percent_code_get([[requires]])[
|
| 289 |
+
#include <iostream>
|
| 290 |
+
#include <stdexcept>
|
| 291 |
+
#include <string>
|
| 292 |
+
|
| 293 |
+
]b4_cxx_portability[
|
| 294 |
+
]m4_ifdef([b4_location_include],
|
| 295 |
+
[[# include ]b4_location_include])[
|
| 296 |
+
]b4_variant_if([b4_variant_includes])[
|
| 297 |
+
|
| 298 |
+
// Whether we are compiled with exception support.
|
| 299 |
+
#ifndef YY_EXCEPTIONS
|
| 300 |
+
# if defined __GNUC__ && !defined __EXCEPTIONS
|
| 301 |
+
# define YY_EXCEPTIONS 0
|
| 302 |
+
# else
|
| 303 |
+
# define YY_EXCEPTIONS 1
|
| 304 |
+
# endif
|
| 305 |
+
#endif
|
| 306 |
+
|
| 307 |
+
]b4_YYDEBUG_define[
|
| 308 |
+
|
| 309 |
+
]b4_namespace_open[
|
| 310 |
+
|
| 311 |
+
]b4_bison_locations_if([m4_ifndef([b4_location_file],
|
| 312 |
+
[b4_location_define])])[
|
| 313 |
+
|
| 314 |
+
/// A Bison parser.
|
| 315 |
+
class ]b4_parser_class[
|
| 316 |
+
{
|
| 317 |
+
public:
|
| 318 |
+
]b4_public_types_declare[
|
| 319 |
+
|
| 320 |
+
/// Build a parser object.
|
| 321 |
+
]b4_parser_class[ (]b4_parse_param_decl[);
|
| 322 |
+
virtual ~]b4_parser_class[ ();
|
| 323 |
+
|
| 324 |
+
/// Parse. An alias for parse ().
|
| 325 |
+
/// \returns 0 iff parsing succeeded.
|
| 326 |
+
int operator() ();
|
| 327 |
+
|
| 328 |
+
/// Parse.
|
| 329 |
+
/// \returns 0 iff parsing succeeded.
|
| 330 |
+
virtual int parse ();
|
| 331 |
+
|
| 332 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 333 |
+
/// The current debugging stream.
|
| 334 |
+
std::ostream& debug_stream () const;
|
| 335 |
+
/// Set the current debugging stream.
|
| 336 |
+
void set_debug_stream (std::ostream &);
|
| 337 |
+
|
| 338 |
+
/// Type for debugging levels.
|
| 339 |
+
typedef int debug_level_type;
|
| 340 |
+
/// The current debugging level.
|
| 341 |
+
debug_level_type debug_level () const;
|
| 342 |
+
/// Set the current debugging level.
|
| 343 |
+
void set_debug_level (debug_level_type l);
|
| 344 |
+
#endif
|
| 345 |
+
|
| 346 |
+
/// Report a syntax error.]b4_locations_if([[
|
| 347 |
+
/// \param loc where the syntax error is found.]])[
|
| 348 |
+
/// \param msg a description of the syntax error.
|
| 349 |
+
virtual void error (]b4_locations_if([[const location_type& loc, ]])[const std::string& msg);
|
| 350 |
+
|
| 351 |
+
# if ]b4_api_PREFIX[DEBUG
|
| 352 |
+
public:
|
| 353 |
+
/// \brief Report a symbol value on the debug stream.
|
| 354 |
+
/// \param yykind The symbol kind.
|
| 355 |
+
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
| 356 |
+
/// \param yylocationp Its location.]])[
|
| 357 |
+
virtual void yy_symbol_value_print_ (symbol_kind_type yykind,
|
| 358 |
+
const value_type* yyvaluep]b4_locations_if([[,
|
| 359 |
+
const location_type* yylocationp]])[) const;
|
| 360 |
+
/// \brief Report a symbol on the debug stream.
|
| 361 |
+
/// \param yykind The symbol kind.
|
| 362 |
+
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
| 363 |
+
/// \param yylocationp Its location.]])[
|
| 364 |
+
virtual void yy_symbol_print_ (symbol_kind_type yykind,
|
| 365 |
+
const value_type* yyvaluep]b4_locations_if([[,
|
| 366 |
+
const location_type* yylocationp]])[) const;
|
| 367 |
+
private:
|
| 368 |
+
/// Debug stream.
|
| 369 |
+
std::ostream* yycdebug_;
|
| 370 |
+
#endif
|
| 371 |
+
|
| 372 |
+
]b4_parse_param_vars[
|
| 373 |
+
};
|
| 374 |
+
|
| 375 |
+
]b4_namespace_close[
|
| 376 |
+
|
| 377 |
+
]b4_percent_code_get([[provides]])[
|
| 378 |
+
]m4_popdef([b4_parse_param])dnl
|
| 379 |
+
])[
|
| 380 |
+
|
| 381 |
+
]b4_header_if(
|
| 382 |
+
[b4_output_begin([b4_spec_header_file])
|
| 383 |
+
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
| 384 |
+
[2002-2015, 2018-2021])[
|
| 385 |
+
// C++ GLR parser skeleton written by Akim Demaille.
|
| 386 |
+
|
| 387 |
+
]b4_disclaimer[
|
| 388 |
+
]b4_cpp_guard_open([b4_spec_mapped_header_file])[
|
| 389 |
+
]b4_shared_declarations[
|
| 390 |
+
]b4_cpp_guard_close([b4_spec_mapped_header_file])[
|
| 391 |
+
]b4_output_end])
|
| 392 |
+
|
| 393 |
+
# Let glr.c (and b4_shared_declarations) believe that the user
|
| 394 |
+
# arguments include the parser itself.
|
| 395 |
+
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_wrap]))
|
| 396 |
+
m4_include(b4_skeletonsdir/[glr.c])
|
| 397 |
+
m4_popdef([b4_parse_param])
|
platform/dbops/binaries/build/share/bison/skeletons/glr2.cc
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
platform/dbops/binaries/build/share/bison/skeletons/java-skel.m4
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-*- Autoconf -*-
|
| 2 |
+
|
| 3 |
+
# Java skeleton dispatching for Bison.
|
| 4 |
+
|
| 5 |
+
# Copyright (C) 2007, 2009-2015, 2018-2021 Free Software Foundation,
|
| 6 |
+
# Inc.
|
| 7 |
+
|
| 8 |
+
# This program is free software: you can redistribute it and/or modify
|
| 9 |
+
# it under the terms of the GNU General Public License as published by
|
| 10 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 11 |
+
# (at your option) any later version.
|
| 12 |
+
#
|
| 13 |
+
# This program is distributed in the hope that it will be useful,
|
| 14 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 15 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 16 |
+
# GNU General Public License for more details.
|
| 17 |
+
#
|
| 18 |
+
# You should have received a copy of the GNU General Public License
|
| 19 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 20 |
+
|
| 21 |
+
b4_glr_if( [b4_complain([%%glr-parser not supported for Java])])
|
| 22 |
+
b4_nondeterministic_if([b4_complain([%%nondeterministic-parser not supported for Java])])
|
| 23 |
+
|
| 24 |
+
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[lalr1.java]])
|
| 25 |
+
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
| 26 |
+
|
| 27 |
+
m4_include(b4_used_skeleton)
|
platform/dbops/binaries/build/share/bison/skeletons/java.m4
ADDED
|
@@ -0,0 +1,502 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-*- Autoconf -*-
|
| 2 |
+
|
| 3 |
+
# Java language support for Bison
|
| 4 |
+
|
| 5 |
+
# Copyright (C) 2007-2015, 2018-2021 Free Software Foundation, Inc.
|
| 6 |
+
|
| 7 |
+
# This program is free software: you can redistribute it and/or modify
|
| 8 |
+
# it under the terms of the GNU General Public License as published by
|
| 9 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 10 |
+
# (at your option) any later version.
|
| 11 |
+
#
|
| 12 |
+
# This program is distributed in the hope that it will be useful,
|
| 13 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
# GNU General Public License for more details.
|
| 16 |
+
#
|
| 17 |
+
# You should have received a copy of the GNU General Public License
|
| 18 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 19 |
+
|
| 20 |
+
m4_include(b4_skeletonsdir/[c-like.m4])
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
# b4_list2(LIST1, LIST2)
|
| 24 |
+
# ----------------------
|
| 25 |
+
# Join two lists with a comma if necessary.
|
| 26 |
+
m4_define([b4_list2],
|
| 27 |
+
[$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2])
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
# b4_percent_define_get3(DEF, PRE, POST, NOT)
|
| 31 |
+
# -------------------------------------------
|
| 32 |
+
# Expand to the value of DEF surrounded by PRE and POST if it's %define'ed,
|
| 33 |
+
# otherwise NOT.
|
| 34 |
+
m4_define([b4_percent_define_get3],
|
| 35 |
+
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
| 36 |
+
[$2[]b4_percent_define_get([$1])[]$3], [$4])])
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
# b4_flag_value(BOOLEAN-FLAG)
|
| 41 |
+
# ---------------------------
|
| 42 |
+
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
# b4_parser_class_declaration
|
| 46 |
+
# ---------------------------
|
| 47 |
+
# The declaration of the parser class ("class YYParser"), with all its
|
| 48 |
+
# qualifiers/annotations.
|
| 49 |
+
b4_percent_define_default([[api.parser.abstract]], [[false]])
|
| 50 |
+
b4_percent_define_default([[api.parser.final]], [[false]])
|
| 51 |
+
b4_percent_define_default([[api.parser.public]], [[false]])
|
| 52 |
+
b4_percent_define_default([[api.parser.strictfp]], [[false]])
|
| 53 |
+
|
| 54 |
+
m4_define([b4_parser_class_declaration],
|
| 55 |
+
[b4_percent_define_get3([api.parser.annotations], [], [ ])dnl
|
| 56 |
+
b4_percent_define_flag_if([api.parser.public], [public ])dnl
|
| 57 |
+
b4_percent_define_flag_if([api.parser.abstract], [abstract ])dnl
|
| 58 |
+
b4_percent_define_flag_if([api.parser.final], [final ])dnl
|
| 59 |
+
b4_percent_define_flag_if([api.parser.strictfp], [strictfp ])dnl
|
| 60 |
+
[class ]b4_parser_class[]dnl
|
| 61 |
+
b4_percent_define_get3([api.parser.extends], [ extends ])dnl
|
| 62 |
+
b4_percent_define_get3([api.parser.implements], [ implements ])])
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
# b4_lexer_if(TRUE, FALSE)
|
| 66 |
+
# ------------------------
|
| 67 |
+
m4_define([b4_lexer_if],
|
| 68 |
+
[b4_percent_code_ifdef([[lexer]], [$1], [$2])])
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
# b4_identification
|
| 72 |
+
# -----------------
|
| 73 |
+
m4_define([b4_identification],
|
| 74 |
+
[[ /** Version number for the Bison executable that generated this parser. */
|
| 75 |
+
public static final String bisonVersion = "]b4_version_string[";
|
| 76 |
+
|
| 77 |
+
/** Name of the skeleton that generated this parser. */
|
| 78 |
+
public static final String bisonSkeleton = ]b4_skeleton[;
|
| 79 |
+
]])
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
## ------------ ##
|
| 83 |
+
## Data types. ##
|
| 84 |
+
## ------------ ##
|
| 85 |
+
|
| 86 |
+
# b4_int_type(MIN, MAX)
|
| 87 |
+
# ---------------------
|
| 88 |
+
# Return the smallest int type able to handle numbers ranging from
|
| 89 |
+
# MIN to MAX (included).
|
| 90 |
+
m4_define([b4_int_type],
|
| 91 |
+
[m4_if(b4_ints_in($@, [-128], [127]), [1], [byte],
|
| 92 |
+
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
| 93 |
+
[int])])
|
| 94 |
+
|
| 95 |
+
# b4_int_type_for(NAME)
|
| 96 |
+
# ---------------------
|
| 97 |
+
# Return the smallest int type able to handle numbers ranging from
|
| 98 |
+
# 'NAME_min' to 'NAME_max' (included).
|
| 99 |
+
m4_define([b4_int_type_for],
|
| 100 |
+
[b4_int_type($1_min, $1_max)])
|
| 101 |
+
|
| 102 |
+
# b4_null
|
| 103 |
+
# -------
|
| 104 |
+
m4_define([b4_null], [null])
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
# b4_typed_parser_table_define(TYPE, NAME, DATA, COMMENT)
|
| 108 |
+
# -------------------------------------------------------
|
| 109 |
+
# We use intermediate functions (e.g., yypact_init) to work around the
|
| 110 |
+
# 64KB limit for JVM methods. See
|
| 111 |
+
# https://lists.gnu.org/r/help-bison/2008-11/msg00004.html.
|
| 112 |
+
m4_define([b4_typed_parser_table_define],
|
| 113 |
+
[m4_ifval([$4], [b4_comment([$4])
|
| 114 |
+
])dnl
|
| 115 |
+
[private static final ]$1[[] yy$2_ = yy$2_init();
|
| 116 |
+
private static final ]$1[[] yy$2_init()
|
| 117 |
+
{
|
| 118 |
+
return new ]$1[[]
|
| 119 |
+
{
|
| 120 |
+
]$3[
|
| 121 |
+
};
|
| 122 |
+
}]])
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
# b4_integral_parser_table_define(NAME, DATA, COMMENT)
|
| 126 |
+
#-----------------------------------------------------
|
| 127 |
+
m4_define([b4_integral_parser_table_define],
|
| 128 |
+
[b4_typed_parser_table_define([b4_int_type_for([$2])], [$1], [$2], [$3])])
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
## ------------- ##
|
| 132 |
+
## Token kinds. ##
|
| 133 |
+
## ------------- ##
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
# b4_token_enum(TOKEN-NUM)
|
| 137 |
+
# ------------------------
|
| 138 |
+
# Output the definition of this token as an enum.
|
| 139 |
+
m4_define([b4_token_enum],
|
| 140 |
+
[b4_token_visible_if([$1],
|
| 141 |
+
[m4_format([[ /** Token %s, to be returned by the scanner. */
|
| 142 |
+
static final int %s = %s%s;
|
| 143 |
+
]],
|
| 144 |
+
b4_symbol([$1], [tag]),
|
| 145 |
+
b4_symbol([$1], [id]),
|
| 146 |
+
b4_symbol([$1], b4_api_token_raw_if([[number]], [[code]])))])])
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
# b4_token_enums
|
| 150 |
+
# --------------
|
| 151 |
+
# Output the definition of the tokens (if there are) as enums.
|
| 152 |
+
m4_define([b4_token_enums],
|
| 153 |
+
[b4_any_token_visible_if([ /* Token kinds. */
|
| 154 |
+
b4_symbol_foreach([b4_token_enum])])])
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
## -------------- ##
|
| 159 |
+
## Symbol kinds. ##
|
| 160 |
+
## -------------- ##
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
# b4_symbol_kind(NUM)
|
| 164 |
+
# -------------------
|
| 165 |
+
m4_define([b4_symbol_kind],
|
| 166 |
+
[SymbolKind.b4_symbol_kind_base($@)])
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
# b4_symbol_enum(SYMBOL-NUM)
|
| 170 |
+
# --------------------------
|
| 171 |
+
# Output the definition of this symbol as an enum.
|
| 172 |
+
m4_define([b4_symbol_enum],
|
| 173 |
+
[m4_format([ %-30s %s],
|
| 174 |
+
m4_format([[%s(%s)%s]],
|
| 175 |
+
b4_symbol([$1], [kind_base]),
|
| 176 |
+
[$1],
|
| 177 |
+
m4_if([$1], b4_last_symbol, [[;]], [[,]])),
|
| 178 |
+
[b4_symbol_tag_comment([$1])])])
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
# b4_declare_symbol_enum
|
| 182 |
+
# ----------------------
|
| 183 |
+
# The definition of the symbol internal numbers as an enum.
|
| 184 |
+
m4_define([b4_declare_symbol_enum],
|
| 185 |
+
[[ public enum SymbolKind
|
| 186 |
+
{
|
| 187 |
+
]b4_symbol_foreach([b4_symbol_enum])[
|
| 188 |
+
|
| 189 |
+
private final int yycode_;
|
| 190 |
+
|
| 191 |
+
SymbolKind (int n) {
|
| 192 |
+
this.yycode_ = n;
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
private static final SymbolKind[] values_ = {
|
| 196 |
+
]m4_map_args_sep([b4_symbol_kind(], [)], [,
|
| 197 |
+
], b4_symbol_numbers)[
|
| 198 |
+
};
|
| 199 |
+
|
| 200 |
+
static final SymbolKind get(int code) {
|
| 201 |
+
return values_[code];
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
public final int getCode() {
|
| 205 |
+
return this.yycode_;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
]b4_parse_error_bmatch(
|
| 209 |
+
[simple\|verbose],
|
| 210 |
+
[[ /* Return YYSTR after stripping away unnecessary quotes and
|
| 211 |
+
backslashes, so that it's suitable for yyerror. The heuristic is
|
| 212 |
+
that double-quoting is unnecessary unless the string contains an
|
| 213 |
+
apostrophe, a comma, or backslash (other than backslash-backslash).
|
| 214 |
+
YYSTR is taken from yytname. */
|
| 215 |
+
private static String yytnamerr_(String yystr)
|
| 216 |
+
{
|
| 217 |
+
if (yystr.charAt (0) == '"')
|
| 218 |
+
{
|
| 219 |
+
StringBuffer yyr = new StringBuffer();
|
| 220 |
+
strip_quotes: for (int i = 1; i < yystr.length(); i++)
|
| 221 |
+
switch (yystr.charAt(i))
|
| 222 |
+
{
|
| 223 |
+
case '\'':
|
| 224 |
+
case ',':
|
| 225 |
+
break strip_quotes;
|
| 226 |
+
|
| 227 |
+
case '\\':
|
| 228 |
+
if (yystr.charAt(++i) != '\\')
|
| 229 |
+
break strip_quotes;
|
| 230 |
+
/* Fall through. */
|
| 231 |
+
default:
|
| 232 |
+
yyr.append(yystr.charAt(i));
|
| 233 |
+
break;
|
| 234 |
+
|
| 235 |
+
case '"':
|
| 236 |
+
return yyr.toString();
|
| 237 |
+
}
|
| 238 |
+
}
|
| 239 |
+
return yystr;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
| 243 |
+
First, the terminals, then, starting at \a YYNTOKENS_, nonterminals. */
|
| 244 |
+
]b4_typed_parser_table_define([String], [tname], [b4_tname])[
|
| 245 |
+
|
| 246 |
+
/* The user-facing name of this symbol. */
|
| 247 |
+
public final String getName() {
|
| 248 |
+
return yytnamerr_(yytname_[yycode_]);
|
| 249 |
+
}
|
| 250 |
+
]],
|
| 251 |
+
[custom\|detailed],
|
| 252 |
+
[[ /* YYNAMES_[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
| 253 |
+
First, the terminals, then, starting at \a YYNTOKENS_, nonterminals. */
|
| 254 |
+
]b4_typed_parser_table_define([String], [names], [b4_symbol_names])[
|
| 255 |
+
|
| 256 |
+
/* The user-facing name of this symbol. */
|
| 257 |
+
public final String getName() {
|
| 258 |
+
return yynames_[yycode_];
|
| 259 |
+
}]])[
|
| 260 |
+
};
|
| 261 |
+
]])])
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
# b4_case(ID, CODE, [COMMENTS])
|
| 266 |
+
# -----------------------------
|
| 267 |
+
# We need to fool Java's stupid unreachable code detection.
|
| 268 |
+
m4_define([b4_case],
|
| 269 |
+
[ case $1:m4_ifval([$3], [ b4_comment([$3])])
|
| 270 |
+
if (yyn == $1)
|
| 271 |
+
$2;
|
| 272 |
+
break;
|
| 273 |
+
])
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
# b4_predicate_case(LABEL, CONDITIONS)
|
| 277 |
+
# ------------------------------------
|
| 278 |
+
m4_define([b4_predicate_case],
|
| 279 |
+
[ case $1:
|
| 280 |
+
if (! ($2)) YYERROR;
|
| 281 |
+
break;
|
| 282 |
+
])
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
## -------- ##
|
| 286 |
+
## Checks. ##
|
| 287 |
+
## -------- ##
|
| 288 |
+
|
| 289 |
+
b4_percent_define_check_kind([[api.value.type]], [code], [deprecated])
|
| 290 |
+
|
| 291 |
+
b4_percent_define_check_kind([[annotations]], [code], [deprecated])
|
| 292 |
+
b4_percent_define_check_kind([[extends]], [code], [deprecated])
|
| 293 |
+
b4_percent_define_check_kind([[implements]], [code], [deprecated])
|
| 294 |
+
b4_percent_define_check_kind([[init_throws]], [code], [deprecated])
|
| 295 |
+
b4_percent_define_check_kind([[lex_throws]], [code], [deprecated])
|
| 296 |
+
b4_percent_define_check_kind([[api.parser.class]], [code], [deprecated])
|
| 297 |
+
b4_percent_define_check_kind([[throws]], [code], [deprecated])
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
## ---------------- ##
|
| 302 |
+
## Default values. ##
|
| 303 |
+
## ---------------- ##
|
| 304 |
+
|
| 305 |
+
m4_define([b4_yystype], [b4_percent_define_get([[api.value.type]])])
|
| 306 |
+
b4_percent_define_default([[api.value.type]], [[Object]])
|
| 307 |
+
b4_percent_define_default([[api.symbol.prefix]], [[S_]])
|
| 308 |
+
|
| 309 |
+
# b4_api_prefix, b4_api_PREFIX
|
| 310 |
+
# ----------------------------
|
| 311 |
+
# Corresponds to %define api.prefix
|
| 312 |
+
b4_percent_define_default([[api.prefix]], [[YY]])
|
| 313 |
+
m4_define([b4_api_prefix],
|
| 314 |
+
[b4_percent_define_get([[api.prefix]])])
|
| 315 |
+
m4_define([b4_api_PREFIX],
|
| 316 |
+
[m4_toupper(b4_api_prefix)])
|
| 317 |
+
|
| 318 |
+
# b4_prefix
|
| 319 |
+
# ---------
|
| 320 |
+
# If the %name-prefix is not given, it is api.prefix.
|
| 321 |
+
m4_define_default([b4_prefix], [b4_api_prefix])
|
| 322 |
+
|
| 323 |
+
b4_percent_define_default([[api.parser.class]], [b4_prefix[]Parser])
|
| 324 |
+
m4_define([b4_parser_class], [b4_percent_define_get([[api.parser.class]])])
|
| 325 |
+
|
| 326 |
+
b4_percent_define_default([[lex_throws]], [[java.io.IOException]])
|
| 327 |
+
m4_define([b4_lex_throws], [b4_percent_define_get([[lex_throws]])])
|
| 328 |
+
|
| 329 |
+
b4_percent_define_default([[throws]], [])
|
| 330 |
+
m4_define([b4_throws], [b4_percent_define_get([[throws]])])
|
| 331 |
+
|
| 332 |
+
b4_percent_define_default([[init_throws]], [])
|
| 333 |
+
m4_define([b4_init_throws], [b4_percent_define_get([[init_throws]])])
|
| 334 |
+
|
| 335 |
+
b4_percent_define_default([[api.location.type]], [Location])
|
| 336 |
+
m4_define([b4_location_type], [b4_percent_define_get([[api.location.type]])])
|
| 337 |
+
|
| 338 |
+
b4_percent_define_default([[api.position.type]], [Position])
|
| 339 |
+
m4_define([b4_position_type], [b4_percent_define_get([[api.position.type]])])
|
| 340 |
+
|
| 341 |
+
|
| 342 |
+
## ----------------- ##
|
| 343 |
+
## Semantic Values. ##
|
| 344 |
+
## ----------------- ##
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
# b4_symbol_translate(STRING)
|
| 348 |
+
# ---------------------------
|
| 349 |
+
# Used by "bison" in the array of symbol names to mark those that
|
| 350 |
+
# require translation.
|
| 351 |
+
m4_define([b4_symbol_translate],
|
| 352 |
+
[[i18n($1)]])
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
# b4_trans(STRING)
|
| 356 |
+
# ----------------
|
| 357 |
+
# Translate a string if i18n is enabled. Avoid collision with b4_translate.
|
| 358 |
+
m4_define([b4_trans],
|
| 359 |
+
[b4_has_translations_if([i18n($1)], [$1])])
|
| 360 |
+
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
# b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
|
| 364 |
+
# ----------------------------------------------
|
| 365 |
+
# See README.
|
| 366 |
+
m4_define([b4_symbol_value],
|
| 367 |
+
[m4_ifval([$3],
|
| 368 |
+
[(($3)($1))],
|
| 369 |
+
[m4_ifval([$2],
|
| 370 |
+
[b4_symbol_if([$2], [has_type],
|
| 371 |
+
[((b4_symbol([$2], [type]))($1))],
|
| 372 |
+
[$1])],
|
| 373 |
+
[$1])])])
|
| 374 |
+
|
| 375 |
+
|
| 376 |
+
# b4_lhs_value([SYMBOL-NUM], [TYPE])
|
| 377 |
+
# ----------------------------------
|
| 378 |
+
# See README.
|
| 379 |
+
m4_define([b4_lhs_value], [yyval])
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
# b4_rhs_data(RULE-LENGTH, POS)
|
| 383 |
+
# -----------------------------
|
| 384 |
+
# See README.
|
| 385 |
+
m4_define([b4_rhs_data],
|
| 386 |
+
[yystack.valueAt (b4_subtract($@))])
|
| 387 |
+
|
| 388 |
+
# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
|
| 389 |
+
# --------------------------------------------------
|
| 390 |
+
# See README.
|
| 391 |
+
#
|
| 392 |
+
# In this simple implementation, %token and %type have class names
|
| 393 |
+
# between the angle brackets.
|
| 394 |
+
m4_define([b4_rhs_value],
|
| 395 |
+
[b4_symbol_value([b4_rhs_data([$1], [$2])], [$3], [$4])])
|
| 396 |
+
|
| 397 |
+
|
| 398 |
+
# b4_lhs_location()
|
| 399 |
+
# -----------------
|
| 400 |
+
# Expansion of @$.
|
| 401 |
+
m4_define([b4_lhs_location],
|
| 402 |
+
[(yyloc)])
|
| 403 |
+
|
| 404 |
+
|
| 405 |
+
# b4_rhs_location(RULE-LENGTH, POS)
|
| 406 |
+
# ---------------------------------
|
| 407 |
+
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
| 408 |
+
# on RHS.
|
| 409 |
+
m4_define([b4_rhs_location],
|
| 410 |
+
[yystack.locationAt (b4_subtract($@))])
|
| 411 |
+
|
| 412 |
+
|
| 413 |
+
# b4_lex_param
|
| 414 |
+
# b4_parse_param
|
| 415 |
+
# --------------
|
| 416 |
+
# If defined, b4_lex_param arrives double quoted, but below we prefer
|
| 417 |
+
# it to be single quoted. Same for b4_parse_param.
|
| 418 |
+
|
| 419 |
+
# TODO: should be in bison.m4
|
| 420 |
+
m4_define_default([b4_lex_param], [[]])
|
| 421 |
+
m4_define([b4_lex_param], b4_lex_param)
|
| 422 |
+
m4_define([b4_parse_param], b4_parse_param)
|
| 423 |
+
|
| 424 |
+
# b4_lex_param_decl
|
| 425 |
+
# -----------------
|
| 426 |
+
# Extra formal arguments of the constructor.
|
| 427 |
+
m4_define([b4_lex_param_decl],
|
| 428 |
+
[m4_ifset([b4_lex_param],
|
| 429 |
+
[b4_remove_comma([$1],
|
| 430 |
+
b4_param_decls(b4_lex_param))],
|
| 431 |
+
[$1])])
|
| 432 |
+
|
| 433 |
+
m4_define([b4_param_decls],
|
| 434 |
+
[m4_map([b4_param_decl], [$@])])
|
| 435 |
+
m4_define([b4_param_decl], [, $1])
|
| 436 |
+
|
| 437 |
+
m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])
|
| 438 |
+
|
| 439 |
+
|
| 440 |
+
|
| 441 |
+
# b4_parse_param_decl
|
| 442 |
+
# -------------------
|
| 443 |
+
# Extra formal arguments of the constructor.
|
| 444 |
+
m4_define([b4_parse_param_decl],
|
| 445 |
+
[m4_ifset([b4_parse_param],
|
| 446 |
+
[b4_remove_comma([$1],
|
| 447 |
+
b4_param_decls(b4_parse_param))],
|
| 448 |
+
[$1])])
|
| 449 |
+
|
| 450 |
+
|
| 451 |
+
|
| 452 |
+
# b4_lex_param_call
|
| 453 |
+
# -----------------
|
| 454 |
+
# Delegating the lexer parameters to the lexer constructor.
|
| 455 |
+
m4_define([b4_lex_param_call],
|
| 456 |
+
[m4_ifset([b4_lex_param],
|
| 457 |
+
[b4_remove_comma([$1],
|
| 458 |
+
b4_param_calls(b4_lex_param))],
|
| 459 |
+
[$1])])
|
| 460 |
+
m4_define([b4_param_calls],
|
| 461 |
+
[m4_map([b4_param_call], [$@])])
|
| 462 |
+
m4_define([b4_param_call], [, $2])
|
| 463 |
+
|
| 464 |
+
|
| 465 |
+
|
| 466 |
+
# b4_parse_param_cons
|
| 467 |
+
# -------------------
|
| 468 |
+
# Extra initialisations of the constructor.
|
| 469 |
+
m4_define([b4_parse_param_cons],
|
| 470 |
+
[m4_ifset([b4_parse_param],
|
| 471 |
+
[b4_constructor_calls(b4_parse_param)])])
|
| 472 |
+
|
| 473 |
+
m4_define([b4_constructor_calls],
|
| 474 |
+
[m4_map([b4_constructor_call], [$@])])
|
| 475 |
+
m4_define([b4_constructor_call],
|
| 476 |
+
[this.$2 = $2;
|
| 477 |
+
])
|
| 478 |
+
|
| 479 |
+
|
| 480 |
+
|
| 481 |
+
# b4_parse_param_vars
|
| 482 |
+
# -------------------
|
| 483 |
+
# Extra instance variables.
|
| 484 |
+
m4_define([b4_parse_param_vars],
|
| 485 |
+
[m4_ifset([b4_parse_param],
|
| 486 |
+
[
|
| 487 |
+
/* User arguments. */
|
| 488 |
+
b4_var_decls(b4_parse_param)])])
|
| 489 |
+
|
| 490 |
+
m4_define([b4_var_decls],
|
| 491 |
+
[m4_map_sep([b4_var_decl], [
|
| 492 |
+
], [$@])])
|
| 493 |
+
m4_define([b4_var_decl],
|
| 494 |
+
[ protected final $1;])
|
| 495 |
+
|
| 496 |
+
|
| 497 |
+
|
| 498 |
+
# b4_maybe_throws(THROWS)
|
| 499 |
+
# -----------------------
|
| 500 |
+
# Expand to either an empty string or "throws THROWS".
|
| 501 |
+
m4_define([b4_maybe_throws],
|
| 502 |
+
[m4_ifval($1, [ throws $1])])
|
platform/dbops/binaries/build/share/bison/skeletons/lalr1.cc
ADDED
|
@@ -0,0 +1,1633 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# C++ skeleton for Bison
|
| 2 |
+
|
| 3 |
+
# Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc.
|
| 4 |
+
|
| 5 |
+
# This program is free software: you can redistribute it and/or modify
|
| 6 |
+
# it under the terms of the GNU General Public License as published by
|
| 7 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 8 |
+
# (at your option) any later version.
|
| 9 |
+
#
|
| 10 |
+
# This program is distributed in the hope that it will be useful,
|
| 11 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 13 |
+
# GNU General Public License for more details.
|
| 14 |
+
#
|
| 15 |
+
# You should have received a copy of the GNU General Public License
|
| 16 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 17 |
+
|
| 18 |
+
m4_include(b4_skeletonsdir/[c++.m4])
|
| 19 |
+
|
| 20 |
+
# api.value.type=variant is valid.
|
| 21 |
+
m4_define([b4_value_type_setup_variant])
|
| 22 |
+
|
| 23 |
+
# parse.lac
|
| 24 |
+
b4_percent_define_default([[parse.lac]], [[none]])
|
| 25 |
+
b4_percent_define_check_values([[[[parse.lac]], [[full]], [[none]]]])
|
| 26 |
+
b4_define_flag_if([lac])
|
| 27 |
+
m4_define([b4_lac_flag],
|
| 28 |
+
[m4_if(b4_percent_define_get([[parse.lac]]),
|
| 29 |
+
[none], [[0]], [[1]])])
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
# b4_tname_if(TNAME-NEEDED, TNAME-NOT-NEEDED)
|
| 33 |
+
# -------------------------------------------
|
| 34 |
+
m4_define([b4_tname_if],
|
| 35 |
+
[m4_case(b4_percent_define_get([[parse.error]]),
|
| 36 |
+
[verbose], [$1],
|
| 37 |
+
[b4_token_table_if([$1],
|
| 38 |
+
[$2])])])
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
# b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
|
| 42 |
+
# --------------------------------------------------------------
|
| 43 |
+
# Declare "parser::yy<TABLE-NAME>_" whose contents is CONTENT.
|
| 44 |
+
m4_define([b4_integral_parser_table_declare],
|
| 45 |
+
[m4_ifval([$3], [b4_comment([$3], [ ])
|
| 46 |
+
])dnl
|
| 47 |
+
static const b4_int_type_for([$2]) yy$1_[[]];dnl
|
| 48 |
+
])
|
| 49 |
+
|
| 50 |
+
# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
|
| 51 |
+
# -------------------------------------------------------------
|
| 52 |
+
# Define "parser::yy<TABLE-NAME>_" whose contents is CONTENT.
|
| 53 |
+
m4_define([b4_integral_parser_table_define],
|
| 54 |
+
[ const b4_int_type_for([$2])
|
| 55 |
+
b4_parser_class::yy$1_[[]] =
|
| 56 |
+
{
|
| 57 |
+
$2
|
| 58 |
+
};dnl
|
| 59 |
+
])
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
# b4_symbol_kind(NUM)
|
| 63 |
+
# -------------------
|
| 64 |
+
m4_define([b4_symbol_kind],
|
| 65 |
+
[symbol_kind::b4_symbol_kind_base($@)])
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
# b4_symbol_value_template(VAL, SYMBOL-NUM, [TYPE])
|
| 69 |
+
# -------------------------------------------------
|
| 70 |
+
# Same as b4_symbol_value, but used in a template method. It makes
|
| 71 |
+
# a difference when using variants. Note that b4_value_type_setup_union
|
| 72 |
+
# overrides b4_symbol_value, so we must override it again.
|
| 73 |
+
m4_copy([b4_symbol_value], [b4_symbol_value_template])
|
| 74 |
+
m4_append([b4_value_type_setup_union],
|
| 75 |
+
[m4_copy_force([b4_symbol_value_union], [b4_symbol_value_template])])
|
| 76 |
+
|
| 77 |
+
# b4_lhs_value(SYMBOL-NUM, [TYPE])
|
| 78 |
+
# --------------------------------
|
| 79 |
+
# See README.
|
| 80 |
+
m4_define([b4_lhs_value],
|
| 81 |
+
[b4_symbol_value([yylhs.value], [$1], [$2])])
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
# b4_lhs_location()
|
| 85 |
+
# -----------------
|
| 86 |
+
# Expansion of @$.
|
| 87 |
+
m4_define([b4_lhs_location],
|
| 88 |
+
[yylhs.location])
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
# b4_rhs_data(RULE-LENGTH, POS)
|
| 92 |
+
# -----------------------------
|
| 93 |
+
# See README.
|
| 94 |
+
m4_define([b4_rhs_data],
|
| 95 |
+
[yystack_@{b4_subtract($@)@}])
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
# b4_rhs_state(RULE-LENGTH, POS)
|
| 99 |
+
# ------------------------------
|
| 100 |
+
# The state corresponding to the symbol #POS, where the current
|
| 101 |
+
# rule has RULE-LENGTH symbols on RHS.
|
| 102 |
+
m4_define([b4_rhs_state],
|
| 103 |
+
[b4_rhs_data([$1], [$2]).state])
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
|
| 107 |
+
# --------------------------------------------------
|
| 108 |
+
# See README.
|
| 109 |
+
m4_define([_b4_rhs_value],
|
| 110 |
+
[b4_symbol_value([b4_rhs_data([$1], [$2]).value], [$3], [$4])])
|
| 111 |
+
|
| 112 |
+
m4_define([b4_rhs_value],
|
| 113 |
+
[b4_percent_define_ifdef([api.value.automove],
|
| 114 |
+
[YY_MOVE (_b4_rhs_value($@))],
|
| 115 |
+
[_b4_rhs_value($@)])])
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
# b4_rhs_location(RULE-LENGTH, POS)
|
| 119 |
+
# ---------------------------------
|
| 120 |
+
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
| 121 |
+
# on RHS.
|
| 122 |
+
m4_define([b4_rhs_location],
|
| 123 |
+
[b4_rhs_data([$1], [$2]).location])
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
# b4_symbol_action(SYMBOL-NUM, KIND)
|
| 127 |
+
# ----------------------------------
|
| 128 |
+
# Run the action KIND (destructor or printer) for SYMBOL-NUM.
|
| 129 |
+
# Same as in C, but using references instead of pointers.
|
| 130 |
+
m4_define([b4_symbol_action],
|
| 131 |
+
[b4_symbol_if([$1], [has_$2],
|
| 132 |
+
[m4_pushdef([b4_symbol_value], m4_defn([b4_symbol_value_template]))[]dnl
|
| 133 |
+
b4_dollar_pushdef([yysym.value],
|
| 134 |
+
[$1],
|
| 135 |
+
[],
|
| 136 |
+
[yysym.location])dnl
|
| 137 |
+
_b4_symbol_case([$1])[]dnl
|
| 138 |
+
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])dnl
|
| 139 |
+
b4_symbol([$1], [$2])
|
| 140 |
+
b4_syncline([@oline@], [@ofile@])dnl
|
| 141 |
+
break;
|
| 142 |
+
|
| 143 |
+
m4_popdef([b4_symbol_value])[]dnl
|
| 144 |
+
b4_dollar_popdef[]dnl
|
| 145 |
+
])])
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
# b4_yylex
|
| 149 |
+
# --------
|
| 150 |
+
# Call yylex.
|
| 151 |
+
m4_define([b4_yylex],
|
| 152 |
+
[b4_token_ctor_if(
|
| 153 |
+
[b4_function_call([yylex],
|
| 154 |
+
[symbol_type], m4_ifdef([b4_lex_param], b4_lex_param))],
|
| 155 |
+
[b4_function_call([yylex], [int],
|
| 156 |
+
[[value_type *], [&yyla.value]][]dnl
|
| 157 |
+
b4_locations_if([, [[location_type *], [&yyla.location]]])dnl
|
| 158 |
+
m4_ifdef([b4_lex_param], [, ]b4_lex_param))])])
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
m4_pushdef([b4_copyright_years],
|
| 162 |
+
[2002-2015, 2018-2021])
|
| 163 |
+
|
| 164 |
+
m4_define([b4_parser_class],
|
| 165 |
+
[b4_percent_define_get([[api.parser.class]])])
|
| 166 |
+
|
| 167 |
+
b4_bison_locations_if([# Backward compatibility.
|
| 168 |
+
m4_define([b4_location_constructors])
|
| 169 |
+
m4_include(b4_skeletonsdir/[location.cc])])
|
| 170 |
+
m4_include(b4_skeletonsdir/[stack.hh])
|
| 171 |
+
b4_variant_if([m4_include(b4_skeletonsdir/[variant.hh])])
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
# b4_shared_declarations(hh|cc)
|
| 175 |
+
# -----------------------------
|
| 176 |
+
# Declaration that might either go into the header (if --header, $1 = hh)
|
| 177 |
+
# or in the implementation file.
|
| 178 |
+
m4_define([b4_shared_declarations],
|
| 179 |
+
[b4_percent_code_get([[requires]])[
|
| 180 |
+
]b4_parse_assert_if([# include <cassert>])[
|
| 181 |
+
# include <cstdlib> // std::abort
|
| 182 |
+
# include <iostream>
|
| 183 |
+
# include <stdexcept>
|
| 184 |
+
# include <string>
|
| 185 |
+
# include <vector>
|
| 186 |
+
|
| 187 |
+
]b4_cxx_portability[
|
| 188 |
+
]m4_ifdef([b4_location_include],
|
| 189 |
+
[[# include ]b4_location_include])[
|
| 190 |
+
]b4_variant_if([b4_variant_includes])[
|
| 191 |
+
|
| 192 |
+
]b4_attribute_define[
|
| 193 |
+
]b4_cast_define[
|
| 194 |
+
]b4_null_define[
|
| 195 |
+
|
| 196 |
+
]b4_YYDEBUG_define[
|
| 197 |
+
|
| 198 |
+
]b4_namespace_open[
|
| 199 |
+
|
| 200 |
+
]b4_bison_locations_if([m4_ifndef([b4_location_file],
|
| 201 |
+
[b4_location_define])])[
|
| 202 |
+
|
| 203 |
+
/// A Bison parser.
|
| 204 |
+
class ]b4_parser_class[
|
| 205 |
+
{
|
| 206 |
+
public:
|
| 207 |
+
]b4_public_types_declare[
|
| 208 |
+
]b4_symbol_type_define[
|
| 209 |
+
/// Build a parser object.
|
| 210 |
+
]b4_parser_class[ (]b4_parse_param_decl[);
|
| 211 |
+
virtual ~]b4_parser_class[ ();
|
| 212 |
+
|
| 213 |
+
#if 201103L <= YY_CPLUSPLUS
|
| 214 |
+
/// Non copyable.
|
| 215 |
+
]b4_parser_class[ (const ]b4_parser_class[&) = delete;
|
| 216 |
+
/// Non copyable.
|
| 217 |
+
]b4_parser_class[& operator= (const ]b4_parser_class[&) = delete;
|
| 218 |
+
#endif
|
| 219 |
+
|
| 220 |
+
/// Parse. An alias for parse ().
|
| 221 |
+
/// \returns 0 iff parsing succeeded.
|
| 222 |
+
int operator() ();
|
| 223 |
+
|
| 224 |
+
/// Parse.
|
| 225 |
+
/// \returns 0 iff parsing succeeded.
|
| 226 |
+
virtual int parse ();
|
| 227 |
+
|
| 228 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 229 |
+
/// The current debugging stream.
|
| 230 |
+
std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
|
| 231 |
+
/// Set the current debugging stream.
|
| 232 |
+
void set_debug_stream (std::ostream &);
|
| 233 |
+
|
| 234 |
+
/// Type for debugging levels.
|
| 235 |
+
typedef int debug_level_type;
|
| 236 |
+
/// The current debugging level.
|
| 237 |
+
debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
|
| 238 |
+
/// Set the current debugging level.
|
| 239 |
+
void set_debug_level (debug_level_type l);
|
| 240 |
+
#endif
|
| 241 |
+
|
| 242 |
+
/// Report a syntax error.]b4_locations_if([[
|
| 243 |
+
/// \param loc where the syntax error is found.]])[
|
| 244 |
+
/// \param msg a description of the syntax error.
|
| 245 |
+
virtual void error (]b4_locations_if([[const location_type& loc, ]])[const std::string& msg);
|
| 246 |
+
|
| 247 |
+
/// Report a syntax error.
|
| 248 |
+
void error (const syntax_error& err);
|
| 249 |
+
|
| 250 |
+
]b4_parse_error_bmatch(
|
| 251 |
+
[custom\|detailed],
|
| 252 |
+
[[ /// The user-facing name of the symbol whose (internal) number is
|
| 253 |
+
/// YYSYMBOL. No bounds checking.
|
| 254 |
+
static const char *symbol_name (symbol_kind_type yysymbol);]],
|
| 255 |
+
[simple],
|
| 256 |
+
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
| 257 |
+
/// The user-facing name of the symbol whose (internal) number is
|
| 258 |
+
/// YYSYMBOL. No bounds checking.
|
| 259 |
+
static const char *symbol_name (symbol_kind_type yysymbol);
|
| 260 |
+
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
| 261 |
+
]],
|
| 262 |
+
[verbose],
|
| 263 |
+
[[ /// The user-facing name of the symbol whose (internal) number is
|
| 264 |
+
/// YYSYMBOL. No bounds checking.
|
| 265 |
+
static std::string symbol_name (symbol_kind_type yysymbol);]])[
|
| 266 |
+
|
| 267 |
+
]b4_token_constructor_define[
|
| 268 |
+
]b4_parse_error_bmatch([custom\|detailed\|verbose], [[
|
| 269 |
+
class context
|
| 270 |
+
{
|
| 271 |
+
public:
|
| 272 |
+
context (const ]b4_parser_class[& yyparser, const symbol_type& yyla);
|
| 273 |
+
const symbol_type& lookahead () const YY_NOEXCEPT { return yyla_; }
|
| 274 |
+
symbol_kind_type token () const YY_NOEXCEPT { return yyla_.kind (); }]b4_locations_if([[
|
| 275 |
+
const location_type& location () const YY_NOEXCEPT { return yyla_.location; }
|
| 276 |
+
]])[
|
| 277 |
+
/// Put in YYARG at most YYARGN of the expected tokens, and return the
|
| 278 |
+
/// number of tokens stored in YYARG. If YYARG is null, return the
|
| 279 |
+
/// number of expected tokens (guaranteed to be less than YYNTOKENS).
|
| 280 |
+
int expected_tokens (symbol_kind_type yyarg[], int yyargn) const;
|
| 281 |
+
|
| 282 |
+
private:
|
| 283 |
+
const ]b4_parser_class[& yyparser_;
|
| 284 |
+
const symbol_type& yyla_;
|
| 285 |
+
};
|
| 286 |
+
]])[
|
| 287 |
+
private:
|
| 288 |
+
#if YY_CPLUSPLUS < 201103L
|
| 289 |
+
/// Non copyable.
|
| 290 |
+
]b4_parser_class[ (const ]b4_parser_class[&);
|
| 291 |
+
/// Non copyable.
|
| 292 |
+
]b4_parser_class[& operator= (const ]b4_parser_class[&);
|
| 293 |
+
#endif
|
| 294 |
+
]b4_lac_if([[
|
| 295 |
+
/// Check the lookahead yytoken.
|
| 296 |
+
/// \returns true iff the token will be eventually shifted.
|
| 297 |
+
bool yy_lac_check_ (symbol_kind_type yytoken) const;
|
| 298 |
+
/// Establish the initial context if no initial context currently exists.
|
| 299 |
+
/// \returns true iff the token will be eventually shifted.
|
| 300 |
+
bool yy_lac_establish_ (symbol_kind_type yytoken);
|
| 301 |
+
/// Discard any previous initial lookahead context because of event.
|
| 302 |
+
/// \param event the event which caused the lookahead to be discarded.
|
| 303 |
+
/// Only used for debbuging output.
|
| 304 |
+
void yy_lac_discard_ (const char* event);]])[
|
| 305 |
+
|
| 306 |
+
/// Stored state numbers (used for stacks).
|
| 307 |
+
typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ state_type;
|
| 308 |
+
]b4_parse_error_bmatch(
|
| 309 |
+
[custom], [[
|
| 310 |
+
/// Report a syntax error
|
| 311 |
+
/// \param yyctx the context in which the error occurred.
|
| 312 |
+
void report_syntax_error (const context& yyctx) const;]],
|
| 313 |
+
[detailed\|verbose], [[
|
| 314 |
+
/// The arguments of the error message.
|
| 315 |
+
int yy_syntax_error_arguments_ (const context& yyctx,
|
| 316 |
+
symbol_kind_type yyarg[], int yyargn) const;
|
| 317 |
+
|
| 318 |
+
/// Generate an error message.
|
| 319 |
+
/// \param yyctx the context in which the error occurred.
|
| 320 |
+
virtual std::string yysyntax_error_ (const context& yyctx) const;]])[
|
| 321 |
+
/// Compute post-reduction state.
|
| 322 |
+
/// \param yystate the current state
|
| 323 |
+
/// \param yysym the nonterminal to push on the stack
|
| 324 |
+
static state_type yy_lr_goto_state_ (state_type yystate, int yysym);
|
| 325 |
+
|
| 326 |
+
/// Whether the given \c yypact_ value indicates a defaulted state.
|
| 327 |
+
/// \param yyvalue the value to check
|
| 328 |
+
static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT;
|
| 329 |
+
|
| 330 |
+
/// Whether the given \c yytable_ value indicates a syntax error.
|
| 331 |
+
/// \param yyvalue the value to check
|
| 332 |
+
static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT;
|
| 333 |
+
|
| 334 |
+
static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
|
| 335 |
+
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
|
| 336 |
+
|
| 337 |
+
/// Convert a scanner token kind \a t to a symbol kind.
|
| 338 |
+
/// In theory \a t should be a token_kind_type, but character literals
|
| 339 |
+
/// are valid, yet not members of the token_kind_type enum.
|
| 340 |
+
static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
|
| 341 |
+
|
| 342 |
+
]b4_parse_error_bmatch(
|
| 343 |
+
[simple],
|
| 344 |
+
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
| 345 |
+
/// For a symbol, its name in clear.
|
| 346 |
+
static const char* const yytname_[];
|
| 347 |
+
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
| 348 |
+
]],
|
| 349 |
+
[verbose],
|
| 350 |
+
[[ /// Convert the symbol name \a n to a form suitable for a diagnostic.
|
| 351 |
+
static std::string yytnamerr_ (const char *yystr);
|
| 352 |
+
|
| 353 |
+
/// For a symbol, its name in clear.
|
| 354 |
+
static const char* const yytname_[];
|
| 355 |
+
]])[
|
| 356 |
+
|
| 357 |
+
// Tables.
|
| 358 |
+
]b4_parser_tables_declare[
|
| 359 |
+
|
| 360 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 361 |
+
]b4_integral_parser_table_declare([rline], [b4_rline],
|
| 362 |
+
[[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
|
| 363 |
+
/// Report on the debug stream that the rule \a r is going to be reduced.
|
| 364 |
+
virtual void yy_reduce_print_ (int r) const;
|
| 365 |
+
/// Print the state stack on the debug stream.
|
| 366 |
+
virtual void yy_stack_print_ () const;
|
| 367 |
+
|
| 368 |
+
/// Debugging level.
|
| 369 |
+
int yydebug_;
|
| 370 |
+
/// Debug stream.
|
| 371 |
+
std::ostream* yycdebug_;
|
| 372 |
+
|
| 373 |
+
/// \brief Display a symbol kind, value and location.
|
| 374 |
+
/// \param yyo The output stream.
|
| 375 |
+
/// \param yysym The symbol.
|
| 376 |
+
template <typename Base>
|
| 377 |
+
void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
|
| 378 |
+
#endif
|
| 379 |
+
|
| 380 |
+
/// \brief Reclaim the memory associated to a symbol.
|
| 381 |
+
/// \param yymsg Why this token is reclaimed.
|
| 382 |
+
/// If null, print nothing.
|
| 383 |
+
/// \param yysym The symbol.
|
| 384 |
+
template <typename Base>
|
| 385 |
+
void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
|
| 386 |
+
|
| 387 |
+
private:
|
| 388 |
+
/// Type access provider for state based symbols.
|
| 389 |
+
struct by_state
|
| 390 |
+
{
|
| 391 |
+
/// Default constructor.
|
| 392 |
+
by_state () YY_NOEXCEPT;
|
| 393 |
+
|
| 394 |
+
/// The symbol kind as needed by the constructor.
|
| 395 |
+
typedef state_type kind_type;
|
| 396 |
+
|
| 397 |
+
/// Constructor.
|
| 398 |
+
by_state (kind_type s) YY_NOEXCEPT;
|
| 399 |
+
|
| 400 |
+
/// Copy constructor.
|
| 401 |
+
by_state (const by_state& that) YY_NOEXCEPT;
|
| 402 |
+
|
| 403 |
+
/// Record that this symbol is empty.
|
| 404 |
+
void clear () YY_NOEXCEPT;
|
| 405 |
+
|
| 406 |
+
/// Steal the symbol kind from \a that.
|
| 407 |
+
void move (by_state& that);
|
| 408 |
+
|
| 409 |
+
/// The symbol kind (corresponding to \a state).
|
| 410 |
+
/// \a ]b4_symbol(empty, kind)[ when empty.
|
| 411 |
+
symbol_kind_type kind () const YY_NOEXCEPT;
|
| 412 |
+
|
| 413 |
+
/// The state number used to denote an empty symbol.
|
| 414 |
+
/// We use the initial state, as it does not have a value.
|
| 415 |
+
enum { empty_state = 0 };
|
| 416 |
+
|
| 417 |
+
/// The state.
|
| 418 |
+
/// \a empty when empty.
|
| 419 |
+
state_type state;
|
| 420 |
+
};
|
| 421 |
+
|
| 422 |
+
/// "Internal" symbol: element of the stack.
|
| 423 |
+
struct stack_symbol_type : basic_symbol<by_state>
|
| 424 |
+
{
|
| 425 |
+
/// Superclass.
|
| 426 |
+
typedef basic_symbol<by_state> super_type;
|
| 427 |
+
/// Construct an empty symbol.
|
| 428 |
+
stack_symbol_type ();
|
| 429 |
+
/// Move or copy construction.
|
| 430 |
+
stack_symbol_type (YY_RVREF (stack_symbol_type) that);
|
| 431 |
+
/// Steal the contents from \a sym to build this.
|
| 432 |
+
stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym);
|
| 433 |
+
#if YY_CPLUSPLUS < 201103L
|
| 434 |
+
/// Assignment, needed by push_back by some old implementations.
|
| 435 |
+
/// Moves the contents of that.
|
| 436 |
+
stack_symbol_type& operator= (stack_symbol_type& that);
|
| 437 |
+
|
| 438 |
+
/// Assignment, needed by push_back by other implementations.
|
| 439 |
+
/// Needed by some other old implementations.
|
| 440 |
+
stack_symbol_type& operator= (const stack_symbol_type& that);
|
| 441 |
+
#endif
|
| 442 |
+
};
|
| 443 |
+
|
| 444 |
+
]b4_stack_define[
|
| 445 |
+
|
| 446 |
+
/// Stack type.
|
| 447 |
+
typedef stack<stack_symbol_type> stack_type;
|
| 448 |
+
|
| 449 |
+
/// The stack.
|
| 450 |
+
stack_type yystack_;]b4_lac_if([[
|
| 451 |
+
/// The stack for LAC.
|
| 452 |
+
/// Logically, the yy_lac_stack's lifetime is confined to the function
|
| 453 |
+
/// yy_lac_check_. We just store it as a member of this class to hold
|
| 454 |
+
/// on to the memory and to avoid frequent reallocations.
|
| 455 |
+
/// Since yy_lac_check_ is const, this member must be mutable.
|
| 456 |
+
mutable std::vector<state_type> yylac_stack_;
|
| 457 |
+
/// Whether an initial LAC context was established.
|
| 458 |
+
bool yy_lac_established_;
|
| 459 |
+
]])[
|
| 460 |
+
|
| 461 |
+
/// Push a new state on the stack.
|
| 462 |
+
/// \param m a debug message to display
|
| 463 |
+
/// if null, no trace is output.
|
| 464 |
+
/// \param sym the symbol
|
| 465 |
+
/// \warning the contents of \a s.value is stolen.
|
| 466 |
+
void yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym);
|
| 467 |
+
|
| 468 |
+
/// Push a new look ahead token on the state on the stack.
|
| 469 |
+
/// \param m a debug message to display
|
| 470 |
+
/// if null, no trace is output.
|
| 471 |
+
/// \param s the state
|
| 472 |
+
/// \param sym the symbol (for its value and location).
|
| 473 |
+
/// \warning the contents of \a sym.value is stolen.
|
| 474 |
+
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
|
| 475 |
+
|
| 476 |
+
/// Pop \a n symbols from the stack.
|
| 477 |
+
void yypop_ (int n = 1) YY_NOEXCEPT;
|
| 478 |
+
|
| 479 |
+
/// Constants.
|
| 480 |
+
enum
|
| 481 |
+
{
|
| 482 |
+
yylast_ = ]b4_last[, ///< Last index in yytable_.
|
| 483 |
+
yynnts_ = ]b4_nterms_number[, ///< Number of nonterminal symbols.
|
| 484 |
+
yyfinal_ = ]b4_final_state_number[ ///< Termination state number.
|
| 485 |
+
};
|
| 486 |
+
|
| 487 |
+
]b4_parse_param_vars[
|
| 488 |
+
]b4_percent_code_get([[yy_bison_internal_hook]])[
|
| 489 |
+
};
|
| 490 |
+
|
| 491 |
+
]b4_token_ctor_if([b4_yytranslate_define([$1])[
|
| 492 |
+
]b4_public_types_define([$1])])[
|
| 493 |
+
]b4_namespace_close[
|
| 494 |
+
|
| 495 |
+
]b4_percent_code_get([[provides]])[
|
| 496 |
+
]])[
|
| 497 |
+
|
| 498 |
+
|
| 499 |
+
## -------------- ##
|
| 500 |
+
## Output files. ##
|
| 501 |
+
## -------------- ##
|
| 502 |
+
|
| 503 |
+
# ------------- #
|
| 504 |
+
# Header file. #
|
| 505 |
+
# ------------- #
|
| 506 |
+
|
| 507 |
+
]b4_header_if([[
|
| 508 |
+
]b4_output_begin([b4_spec_header_file])[
|
| 509 |
+
]b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])[
|
| 510 |
+
|
| 511 |
+
/**
|
| 512 |
+
** \file ]b4_spec_mapped_header_file[
|
| 513 |
+
** Define the ]b4_namespace_ref[::parser class.
|
| 514 |
+
*/
|
| 515 |
+
|
| 516 |
+
// C++ LALR(1) parser skeleton written by Akim Demaille.
|
| 517 |
+
|
| 518 |
+
]b4_disclaimer[
|
| 519 |
+
]b4_cpp_guard_open([b4_spec_mapped_header_file])[
|
| 520 |
+
]b4_shared_declarations(hh)[
|
| 521 |
+
]b4_cpp_guard_close([b4_spec_mapped_header_file])[
|
| 522 |
+
]b4_output_end[
|
| 523 |
+
]])[
|
| 524 |
+
|
| 525 |
+
|
| 526 |
+
# --------------------- #
|
| 527 |
+
# Implementation file. #
|
| 528 |
+
# --------------------- #
|
| 529 |
+
|
| 530 |
+
]b4_output_begin([b4_parser_file_name])[
|
| 531 |
+
]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])[
|
| 532 |
+
]b4_disclaimer[
|
| 533 |
+
]b4_percent_code_get([[top]])[]dnl
|
| 534 |
+
m4_if(b4_prefix, [yy], [],
|
| 535 |
+
[
|
| 536 |
+
// Take the name prefix into account.
|
| 537 |
+
[#]define yylex b4_prefix[]lex])[
|
| 538 |
+
|
| 539 |
+
]b4_user_pre_prologue[
|
| 540 |
+
|
| 541 |
+
]b4_header_if([[#include "@basename(]b4_spec_header_file[@)"]],
|
| 542 |
+
[b4_shared_declarations([cc])])[
|
| 543 |
+
|
| 544 |
+
]b4_user_post_prologue[
|
| 545 |
+
]b4_percent_code_get[
|
| 546 |
+
|
| 547 |
+
#ifndef YY_
|
| 548 |
+
# if defined YYENABLE_NLS && YYENABLE_NLS
|
| 549 |
+
# if ENABLE_NLS
|
| 550 |
+
# include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE.
|
| 551 |
+
# define YY_(msgid) dgettext ("bison-runtime", msgid)
|
| 552 |
+
# endif
|
| 553 |
+
# endif
|
| 554 |
+
# ifndef YY_
|
| 555 |
+
# define YY_(msgid) msgid
|
| 556 |
+
# endif
|
| 557 |
+
#endif
|
| 558 |
+
]b4_has_translations_if([
|
| 559 |
+
#ifndef N_
|
| 560 |
+
# define N_(Msgid) Msgid
|
| 561 |
+
#endif
|
| 562 |
+
])[
|
| 563 |
+
|
| 564 |
+
// Whether we are compiled with exception support.
|
| 565 |
+
#ifndef YY_EXCEPTIONS
|
| 566 |
+
# if defined __GNUC__ && !defined __EXCEPTIONS
|
| 567 |
+
# define YY_EXCEPTIONS 0
|
| 568 |
+
# else
|
| 569 |
+
# define YY_EXCEPTIONS 1
|
| 570 |
+
# endif
|
| 571 |
+
#endif
|
| 572 |
+
|
| 573 |
+
]b4_locations_if([dnl
|
| 574 |
+
[#define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
|
| 575 |
+
]b4_yylloc_default_define])[
|
| 576 |
+
|
| 577 |
+
// Enable debugging if requested.
|
| 578 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 579 |
+
|
| 580 |
+
// A pseudo ostream that takes yydebug_ into account.
|
| 581 |
+
# define YYCDEBUG if (yydebug_) (*yycdebug_)
|
| 582 |
+
|
| 583 |
+
# define YY_SYMBOL_PRINT(Title, Symbol) \
|
| 584 |
+
do { \
|
| 585 |
+
if (yydebug_) \
|
| 586 |
+
{ \
|
| 587 |
+
*yycdebug_ << Title << ' '; \
|
| 588 |
+
yy_print_ (*yycdebug_, Symbol); \
|
| 589 |
+
*yycdebug_ << '\n'; \
|
| 590 |
+
} \
|
| 591 |
+
} while (false)
|
| 592 |
+
|
| 593 |
+
# define YY_REDUCE_PRINT(Rule) \
|
| 594 |
+
do { \
|
| 595 |
+
if (yydebug_) \
|
| 596 |
+
yy_reduce_print_ (Rule); \
|
| 597 |
+
} while (false)
|
| 598 |
+
|
| 599 |
+
# define YY_STACK_PRINT() \
|
| 600 |
+
do { \
|
| 601 |
+
if (yydebug_) \
|
| 602 |
+
yy_stack_print_ (); \
|
| 603 |
+
} while (false)
|
| 604 |
+
|
| 605 |
+
#else // !]b4_api_PREFIX[DEBUG
|
| 606 |
+
|
| 607 |
+
# define YYCDEBUG if (false) std::cerr
|
| 608 |
+
# define YY_SYMBOL_PRINT(Title, Symbol) YY_USE (Symbol)
|
| 609 |
+
# define YY_REDUCE_PRINT(Rule) static_cast<void> (0)
|
| 610 |
+
# define YY_STACK_PRINT() static_cast<void> (0)
|
| 611 |
+
|
| 612 |
+
#endif // !]b4_api_PREFIX[DEBUG
|
| 613 |
+
|
| 614 |
+
#define yyerrok (yyerrstatus_ = 0)
|
| 615 |
+
#define yyclearin (yyla.clear ())
|
| 616 |
+
|
| 617 |
+
#define YYACCEPT goto yyacceptlab
|
| 618 |
+
#define YYABORT goto yyabortlab
|
| 619 |
+
#define YYERROR goto yyerrorlab
|
| 620 |
+
#define YYRECOVERING() (!!yyerrstatus_)
|
| 621 |
+
|
| 622 |
+
]b4_namespace_open[
|
| 623 |
+
/// Build a parser object.
|
| 624 |
+
]b4_parser_class::b4_parser_class[ (]b4_parse_param_decl[)
|
| 625 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 626 |
+
: yydebug_ (false),
|
| 627 |
+
yycdebug_ (&std::cerr)]b4_lac_if([,], [m4_ifset([b4_parse_param], [,])])[
|
| 628 |
+
#else
|
| 629 |
+
]b4_lac_if([ :], [m4_ifset([b4_parse_param], [ :])])[
|
| 630 |
+
#endif]b4_lac_if([[
|
| 631 |
+
yy_lac_established_ (false)]m4_ifset([b4_parse_param], [,])])[]b4_parse_param_cons[
|
| 632 |
+
{}
|
| 633 |
+
|
| 634 |
+
]b4_parser_class::~b4_parser_class[ ()
|
| 635 |
+
{}
|
| 636 |
+
|
| 637 |
+
]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
|
| 638 |
+
{}
|
| 639 |
+
|
| 640 |
+
/*---------.
|
| 641 |
+
| symbol. |
|
| 642 |
+
`---------*/
|
| 643 |
+
|
| 644 |
+
]b4_token_ctor_if([], [b4_public_types_define([cc])])[
|
| 645 |
+
|
| 646 |
+
// by_state.
|
| 647 |
+
]b4_parser_class[::by_state::by_state () YY_NOEXCEPT
|
| 648 |
+
: state (empty_state)
|
| 649 |
+
{}
|
| 650 |
+
|
| 651 |
+
]b4_parser_class[::by_state::by_state (const by_state& that) YY_NOEXCEPT
|
| 652 |
+
: state (that.state)
|
| 653 |
+
{}
|
| 654 |
+
|
| 655 |
+
void
|
| 656 |
+
]b4_parser_class[::by_state::clear () YY_NOEXCEPT
|
| 657 |
+
{
|
| 658 |
+
state = empty_state;
|
| 659 |
+
}
|
| 660 |
+
|
| 661 |
+
void
|
| 662 |
+
]b4_parser_class[::by_state::move (by_state& that)
|
| 663 |
+
{
|
| 664 |
+
state = that.state;
|
| 665 |
+
that.clear ();
|
| 666 |
+
}
|
| 667 |
+
|
| 668 |
+
]b4_parser_class[::by_state::by_state (state_type s) YY_NOEXCEPT
|
| 669 |
+
: state (s)
|
| 670 |
+
{}
|
| 671 |
+
|
| 672 |
+
]b4_parser_class[::symbol_kind_type
|
| 673 |
+
]b4_parser_class[::by_state::kind () const YY_NOEXCEPT
|
| 674 |
+
{
|
| 675 |
+
if (state == empty_state)
|
| 676 |
+
return ]b4_symbol(empty, kind)[;
|
| 677 |
+
else
|
| 678 |
+
return YY_CAST (symbol_kind_type, yystos_[+state]);
|
| 679 |
+
}
|
| 680 |
+
|
| 681 |
+
]b4_parser_class[::stack_symbol_type::stack_symbol_type ()
|
| 682 |
+
{}
|
| 683 |
+
|
| 684 |
+
]b4_parser_class[::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that)
|
| 685 |
+
: super_type (YY_MOVE (that.state)]b4_variant_if([], [, YY_MOVE (that.value)])b4_locations_if([, YY_MOVE (that.location)])[)
|
| 686 |
+
{]b4_variant_if([
|
| 687 |
+
b4_symbol_variant([that.kind ()],
|
| 688 |
+
[value], [YY_MOVE_OR_COPY], [YY_MOVE (that.value)])])[
|
| 689 |
+
#if 201103L <= YY_CPLUSPLUS
|
| 690 |
+
// that is emptied.
|
| 691 |
+
that.state = empty_state;
|
| 692 |
+
#endif
|
| 693 |
+
}
|
| 694 |
+
|
| 695 |
+
]b4_parser_class[::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that)
|
| 696 |
+
: super_type (s]b4_variant_if([], [, YY_MOVE (that.value)])[]b4_locations_if([, YY_MOVE (that.location)])[)
|
| 697 |
+
{]b4_variant_if([
|
| 698 |
+
b4_symbol_variant([that.kind ()],
|
| 699 |
+
[value], [move], [YY_MOVE (that.value)])])[
|
| 700 |
+
// that is emptied.
|
| 701 |
+
that.kind_ = ]b4_symbol(empty, kind)[;
|
| 702 |
+
}
|
| 703 |
+
|
| 704 |
+
#if YY_CPLUSPLUS < 201103L
|
| 705 |
+
]b4_parser_class[::stack_symbol_type&
|
| 706 |
+
]b4_parser_class[::stack_symbol_type::operator= (const stack_symbol_type& that)
|
| 707 |
+
{
|
| 708 |
+
state = that.state;
|
| 709 |
+
]b4_variant_if([b4_symbol_variant([that.kind ()],
|
| 710 |
+
[value], [copy], [that.value])],
|
| 711 |
+
[[value = that.value;]])[]b4_locations_if([
|
| 712 |
+
location = that.location;])[
|
| 713 |
+
return *this;
|
| 714 |
+
}
|
| 715 |
+
|
| 716 |
+
]b4_parser_class[::stack_symbol_type&
|
| 717 |
+
]b4_parser_class[::stack_symbol_type::operator= (stack_symbol_type& that)
|
| 718 |
+
{
|
| 719 |
+
state = that.state;
|
| 720 |
+
]b4_variant_if([b4_symbol_variant([that.kind ()],
|
| 721 |
+
[value], [move], [that.value])],
|
| 722 |
+
[[value = that.value;]])[]b4_locations_if([
|
| 723 |
+
location = that.location;])[
|
| 724 |
+
// that is emptied.
|
| 725 |
+
that.state = empty_state;
|
| 726 |
+
return *this;
|
| 727 |
+
}
|
| 728 |
+
#endif
|
| 729 |
+
|
| 730 |
+
template <typename Base>
|
| 731 |
+
void
|
| 732 |
+
]b4_parser_class[::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
|
| 733 |
+
{
|
| 734 |
+
if (yymsg)
|
| 735 |
+
YY_SYMBOL_PRINT (yymsg, yysym);]b4_variant_if([], [
|
| 736 |
+
|
| 737 |
+
// User destructor.
|
| 738 |
+
b4_symbol_actions([destructor], [yysym.kind ()])])[
|
| 739 |
+
}
|
| 740 |
+
|
| 741 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 742 |
+
template <typename Base>
|
| 743 |
+
void
|
| 744 |
+
]b4_parser_class[::yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const
|
| 745 |
+
{
|
| 746 |
+
std::ostream& yyoutput = yyo;
|
| 747 |
+
YY_USE (yyoutput);
|
| 748 |
+
if (yysym.empty ())
|
| 749 |
+
yyo << "empty symbol";
|
| 750 |
+
else
|
| 751 |
+
{
|
| 752 |
+
symbol_kind_type yykind = yysym.kind ();
|
| 753 |
+
yyo << (yykind < YYNTOKENS ? "token" : "nterm")
|
| 754 |
+
<< ' ' << yysym.name () << " ("]b4_locations_if([
|
| 755 |
+
<< yysym.location << ": "])[;
|
| 756 |
+
]b4_symbol_actions([printer])[
|
| 757 |
+
yyo << ')';
|
| 758 |
+
}
|
| 759 |
+
}
|
| 760 |
+
#endif
|
| 761 |
+
|
| 762 |
+
void
|
| 763 |
+
]b4_parser_class[::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym)
|
| 764 |
+
{
|
| 765 |
+
if (m)
|
| 766 |
+
YY_SYMBOL_PRINT (m, sym);
|
| 767 |
+
yystack_.push (YY_MOVE (sym));
|
| 768 |
+
}
|
| 769 |
+
|
| 770 |
+
void
|
| 771 |
+
]b4_parser_class[::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym)
|
| 772 |
+
{
|
| 773 |
+
#if 201103L <= YY_CPLUSPLUS
|
| 774 |
+
yypush_ (m, stack_symbol_type (s, std::move (sym)));
|
| 775 |
+
#else
|
| 776 |
+
stack_symbol_type ss (s, sym);
|
| 777 |
+
yypush_ (m, ss);
|
| 778 |
+
#endif
|
| 779 |
+
}
|
| 780 |
+
|
| 781 |
+
void
|
| 782 |
+
]b4_parser_class[::yypop_ (int n) YY_NOEXCEPT
|
| 783 |
+
{
|
| 784 |
+
yystack_.pop (n);
|
| 785 |
+
}
|
| 786 |
+
|
| 787 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 788 |
+
std::ostream&
|
| 789 |
+
]b4_parser_class[::debug_stream () const
|
| 790 |
+
{
|
| 791 |
+
return *yycdebug_;
|
| 792 |
+
}
|
| 793 |
+
|
| 794 |
+
void
|
| 795 |
+
]b4_parser_class[::set_debug_stream (std::ostream& o)
|
| 796 |
+
{
|
| 797 |
+
yycdebug_ = &o;
|
| 798 |
+
}
|
| 799 |
+
|
| 800 |
+
|
| 801 |
+
]b4_parser_class[::debug_level_type
|
| 802 |
+
]b4_parser_class[::debug_level () const
|
| 803 |
+
{
|
| 804 |
+
return yydebug_;
|
| 805 |
+
}
|
| 806 |
+
|
| 807 |
+
void
|
| 808 |
+
]b4_parser_class[::set_debug_level (debug_level_type l)
|
| 809 |
+
{
|
| 810 |
+
yydebug_ = l;
|
| 811 |
+
}
|
| 812 |
+
#endif // ]b4_api_PREFIX[DEBUG
|
| 813 |
+
|
| 814 |
+
]b4_parser_class[::state_type
|
| 815 |
+
]b4_parser_class[::yy_lr_goto_state_ (state_type yystate, int yysym)
|
| 816 |
+
{
|
| 817 |
+
int yyr = yypgoto_[yysym - YYNTOKENS] + yystate;
|
| 818 |
+
if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
|
| 819 |
+
return yytable_[yyr];
|
| 820 |
+
else
|
| 821 |
+
return yydefgoto_[yysym - YYNTOKENS];
|
| 822 |
+
}
|
| 823 |
+
|
| 824 |
+
bool
|
| 825 |
+
]b4_parser_class[::yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT
|
| 826 |
+
{
|
| 827 |
+
return yyvalue == yypact_ninf_;
|
| 828 |
+
}
|
| 829 |
+
|
| 830 |
+
bool
|
| 831 |
+
]b4_parser_class[::yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT
|
| 832 |
+
{
|
| 833 |
+
return yyvalue == yytable_ninf_;
|
| 834 |
+
}
|
| 835 |
+
|
| 836 |
+
int
|
| 837 |
+
]b4_parser_class[::operator() ()
|
| 838 |
+
{
|
| 839 |
+
return parse ();
|
| 840 |
+
}
|
| 841 |
+
|
| 842 |
+
int
|
| 843 |
+
]b4_parser_class[::parse ()
|
| 844 |
+
{
|
| 845 |
+
int yyn;
|
| 846 |
+
/// Length of the RHS of the rule being reduced.
|
| 847 |
+
int yylen = 0;
|
| 848 |
+
|
| 849 |
+
// Error handling.
|
| 850 |
+
int yynerrs_ = 0;
|
| 851 |
+
int yyerrstatus_ = 0;
|
| 852 |
+
|
| 853 |
+
/// The lookahead symbol.
|
| 854 |
+
symbol_type yyla;]b4_locations_if([[
|
| 855 |
+
|
| 856 |
+
/// The locations where the error started and ended.
|
| 857 |
+
stack_symbol_type yyerror_range[3];]])[
|
| 858 |
+
|
| 859 |
+
/// The return value of parse ().
|
| 860 |
+
int yyresult;]b4_lac_if([[
|
| 861 |
+
|
| 862 |
+
// Discard the LAC context in case there still is one left from a
|
| 863 |
+
// previous invocation.
|
| 864 |
+
yy_lac_discard_ ("init");]])[
|
| 865 |
+
|
| 866 |
+
#if YY_EXCEPTIONS
|
| 867 |
+
try
|
| 868 |
+
#endif // YY_EXCEPTIONS
|
| 869 |
+
{
|
| 870 |
+
YYCDEBUG << "Starting parse\n";
|
| 871 |
+
|
| 872 |
+
]m4_ifdef([b4_initial_action], [
|
| 873 |
+
b4_dollar_pushdef([yyla.value], [], [], [yyla.location])dnl
|
| 874 |
+
b4_user_initial_action
|
| 875 |
+
b4_dollar_popdef])[]dnl
|
| 876 |
+
|
| 877 |
+
[ /* Initialize the stack. The initial state will be set in
|
| 878 |
+
yynewstate, since the latter expects the semantical and the
|
| 879 |
+
location values to have been already stored, initialize these
|
| 880 |
+
stacks with a primary value. */
|
| 881 |
+
yystack_.clear ();
|
| 882 |
+
yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));
|
| 883 |
+
|
| 884 |
+
/*-----------------------------------------------.
|
| 885 |
+
| yynewstate -- push a new symbol on the stack. |
|
| 886 |
+
`-----------------------------------------------*/
|
| 887 |
+
yynewstate:
|
| 888 |
+
YYCDEBUG << "Entering state " << int (yystack_[0].state) << '\n';
|
| 889 |
+
YY_STACK_PRINT ();
|
| 890 |
+
|
| 891 |
+
// Accept?
|
| 892 |
+
if (yystack_[0].state == yyfinal_)
|
| 893 |
+
YYACCEPT;
|
| 894 |
+
|
| 895 |
+
goto yybackup;
|
| 896 |
+
|
| 897 |
+
|
| 898 |
+
/*-----------.
|
| 899 |
+
| yybackup. |
|
| 900 |
+
`-----------*/
|
| 901 |
+
yybackup:
|
| 902 |
+
// Try to take a decision without lookahead.
|
| 903 |
+
yyn = yypact_[+yystack_[0].state];
|
| 904 |
+
if (yy_pact_value_is_default_ (yyn))
|
| 905 |
+
goto yydefault;
|
| 906 |
+
|
| 907 |
+
// Read a lookahead token.
|
| 908 |
+
if (yyla.empty ())
|
| 909 |
+
{
|
| 910 |
+
YYCDEBUG << "Reading a token\n";
|
| 911 |
+
#if YY_EXCEPTIONS
|
| 912 |
+
try
|
| 913 |
+
#endif // YY_EXCEPTIONS
|
| 914 |
+
{]b4_token_ctor_if([[
|
| 915 |
+
symbol_type yylookahead (]b4_yylex[);
|
| 916 |
+
yyla.move (yylookahead);]], [[
|
| 917 |
+
yyla.kind_ = yytranslate_ (]b4_yylex[);]])[
|
| 918 |
+
}
|
| 919 |
+
#if YY_EXCEPTIONS
|
| 920 |
+
catch (const syntax_error& yyexc)
|
| 921 |
+
{
|
| 922 |
+
YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
|
| 923 |
+
error (yyexc);
|
| 924 |
+
goto yyerrlab1;
|
| 925 |
+
}
|
| 926 |
+
#endif // YY_EXCEPTIONS
|
| 927 |
+
}
|
| 928 |
+
YY_SYMBOL_PRINT ("Next token is", yyla);
|
| 929 |
+
|
| 930 |
+
if (yyla.kind () == ]b4_symbol(error, kind)[)
|
| 931 |
+
{
|
| 932 |
+
// The scanner already issued an error message, process directly
|
| 933 |
+
// to error recovery. But do not keep the error token as
|
| 934 |
+
// lookahead, it is too special and may lead us to an endless
|
| 935 |
+
// loop in error recovery. */
|
| 936 |
+
yyla.kind_ = ]b4_symbol(undef, kind)[;
|
| 937 |
+
goto yyerrlab1;
|
| 938 |
+
}
|
| 939 |
+
|
| 940 |
+
/* If the proper action on seeing token YYLA.TYPE is to reduce or
|
| 941 |
+
to detect an error, take that action. */
|
| 942 |
+
yyn += yyla.kind ();
|
| 943 |
+
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind ())
|
| 944 |
+
{]b4_lac_if([[
|
| 945 |
+
if (!yy_lac_establish_ (yyla.kind ()))
|
| 946 |
+
goto yyerrlab;]])[
|
| 947 |
+
goto yydefault;
|
| 948 |
+
}
|
| 949 |
+
|
| 950 |
+
// Reduce or error.
|
| 951 |
+
yyn = yytable_[yyn];
|
| 952 |
+
if (yyn <= 0)
|
| 953 |
+
{
|
| 954 |
+
if (yy_table_value_is_error_ (yyn))
|
| 955 |
+
goto yyerrlab;]b4_lac_if([[
|
| 956 |
+
if (!yy_lac_establish_ (yyla.kind ()))
|
| 957 |
+
goto yyerrlab;
|
| 958 |
+
]])[
|
| 959 |
+
yyn = -yyn;
|
| 960 |
+
goto yyreduce;
|
| 961 |
+
}
|
| 962 |
+
|
| 963 |
+
// Count tokens shifted since error; after three, turn off error status.
|
| 964 |
+
if (yyerrstatus_)
|
| 965 |
+
--yyerrstatus_;
|
| 966 |
+
|
| 967 |
+
// Shift the lookahead token.
|
| 968 |
+
yypush_ ("Shifting", state_type (yyn), YY_MOVE (yyla));]b4_lac_if([[
|
| 969 |
+
yy_lac_discard_ ("shift");]])[
|
| 970 |
+
goto yynewstate;
|
| 971 |
+
|
| 972 |
+
|
| 973 |
+
/*-----------------------------------------------------------.
|
| 974 |
+
| yydefault -- do the default action for the current state. |
|
| 975 |
+
`-----------------------------------------------------------*/
|
| 976 |
+
yydefault:
|
| 977 |
+
yyn = yydefact_[+yystack_[0].state];
|
| 978 |
+
if (yyn == 0)
|
| 979 |
+
goto yyerrlab;
|
| 980 |
+
goto yyreduce;
|
| 981 |
+
|
| 982 |
+
|
| 983 |
+
/*-----------------------------.
|
| 984 |
+
| yyreduce -- do a reduction. |
|
| 985 |
+
`-----------------------------*/
|
| 986 |
+
yyreduce:
|
| 987 |
+
yylen = yyr2_[yyn];
|
| 988 |
+
{
|
| 989 |
+
stack_symbol_type yylhs;
|
| 990 |
+
yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]);]b4_variant_if([[
|
| 991 |
+
/* Variants are always initialized to an empty instance of the
|
| 992 |
+
correct type. The default '$$ = $1' action is NOT applied
|
| 993 |
+
when using variants. */
|
| 994 |
+
]b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [emplace])], [[
|
| 995 |
+
/* If YYLEN is nonzero, implement the default value of the
|
| 996 |
+
action: '$$ = $1'. Otherwise, use the top of the stack.
|
| 997 |
+
|
| 998 |
+
Otherwise, the following line sets YYLHS.VALUE to garbage.
|
| 999 |
+
This behavior is undocumented and Bison users should not rely
|
| 1000 |
+
upon it. */
|
| 1001 |
+
if (yylen)
|
| 1002 |
+
yylhs.value = yystack_@{yylen - 1@}.value;
|
| 1003 |
+
else
|
| 1004 |
+
yylhs.value = yystack_@{0@}.value;]])[
|
| 1005 |
+
]b4_locations_if([dnl
|
| 1006 |
+
[
|
| 1007 |
+
// Default location.
|
| 1008 |
+
{
|
| 1009 |
+
stack_type::slice range (yystack_, yylen);
|
| 1010 |
+
YYLLOC_DEFAULT (yylhs.location, range, yylen);
|
| 1011 |
+
yyerror_range[1].location = yylhs.location;
|
| 1012 |
+
}]])[
|
| 1013 |
+
|
| 1014 |
+
// Perform the reduction.
|
| 1015 |
+
YY_REDUCE_PRINT (yyn);
|
| 1016 |
+
#if YY_EXCEPTIONS
|
| 1017 |
+
try
|
| 1018 |
+
#endif // YY_EXCEPTIONS
|
| 1019 |
+
{
|
| 1020 |
+
switch (yyn)
|
| 1021 |
+
{
|
| 1022 |
+
]b4_user_actions[
|
| 1023 |
+
default:
|
| 1024 |
+
break;
|
| 1025 |
+
}
|
| 1026 |
+
}
|
| 1027 |
+
#if YY_EXCEPTIONS
|
| 1028 |
+
catch (const syntax_error& yyexc)
|
| 1029 |
+
{
|
| 1030 |
+
YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
|
| 1031 |
+
error (yyexc);
|
| 1032 |
+
YYERROR;
|
| 1033 |
+
}
|
| 1034 |
+
#endif // YY_EXCEPTIONS
|
| 1035 |
+
YY_SYMBOL_PRINT ("-> $$ =", yylhs);
|
| 1036 |
+
yypop_ (yylen);
|
| 1037 |
+
yylen = 0;
|
| 1038 |
+
|
| 1039 |
+
// Shift the result of the reduction.
|
| 1040 |
+
yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
|
| 1041 |
+
}
|
| 1042 |
+
goto yynewstate;
|
| 1043 |
+
|
| 1044 |
+
|
| 1045 |
+
/*--------------------------------------.
|
| 1046 |
+
| yyerrlab -- here on detecting error. |
|
| 1047 |
+
`--------------------------------------*/
|
| 1048 |
+
yyerrlab:
|
| 1049 |
+
// If not already recovering from an error, report this error.
|
| 1050 |
+
if (!yyerrstatus_)
|
| 1051 |
+
{
|
| 1052 |
+
++yynerrs_;]b4_parse_error_case(
|
| 1053 |
+
[simple], [[
|
| 1054 |
+
std::string msg = YY_("syntax error");
|
| 1055 |
+
error (]b4_join(b4_locations_if([yyla.location]), [[YY_MOVE (msg)]])[);]],
|
| 1056 |
+
[custom], [[
|
| 1057 |
+
context yyctx (*this, yyla);
|
| 1058 |
+
report_syntax_error (yyctx);]],
|
| 1059 |
+
[[
|
| 1060 |
+
context yyctx (*this, yyla);
|
| 1061 |
+
std::string msg = yysyntax_error_ (yyctx);
|
| 1062 |
+
error (]b4_join(b4_locations_if([yyla.location]), [[YY_MOVE (msg)]])[);]])[
|
| 1063 |
+
}
|
| 1064 |
+
|
| 1065 |
+
]b4_locations_if([[
|
| 1066 |
+
yyerror_range[1].location = yyla.location;]])[
|
| 1067 |
+
if (yyerrstatus_ == 3)
|
| 1068 |
+
{
|
| 1069 |
+
/* If just tried and failed to reuse lookahead token after an
|
| 1070 |
+
error, discard it. */
|
| 1071 |
+
|
| 1072 |
+
// Return failure if at end of input.
|
| 1073 |
+
if (yyla.kind () == ]b4_symbol(eof, kind)[)
|
| 1074 |
+
YYABORT;
|
| 1075 |
+
else if (!yyla.empty ())
|
| 1076 |
+
{
|
| 1077 |
+
yy_destroy_ ("Error: discarding", yyla);
|
| 1078 |
+
yyla.clear ();
|
| 1079 |
+
}
|
| 1080 |
+
}
|
| 1081 |
+
|
| 1082 |
+
// Else will try to reuse lookahead token after shifting the error token.
|
| 1083 |
+
goto yyerrlab1;
|
| 1084 |
+
|
| 1085 |
+
|
| 1086 |
+
/*---------------------------------------------------.
|
| 1087 |
+
| yyerrorlab -- error raised explicitly by YYERROR. |
|
| 1088 |
+
`---------------------------------------------------*/
|
| 1089 |
+
yyerrorlab:
|
| 1090 |
+
/* Pacify compilers when the user code never invokes YYERROR and
|
| 1091 |
+
the label yyerrorlab therefore never appears in user code. */
|
| 1092 |
+
if (false)
|
| 1093 |
+
YYERROR;
|
| 1094 |
+
|
| 1095 |
+
/* Do not reclaim the symbols of the rule whose action triggered
|
| 1096 |
+
this YYERROR. */
|
| 1097 |
+
yypop_ (yylen);
|
| 1098 |
+
yylen = 0;
|
| 1099 |
+
YY_STACK_PRINT ();
|
| 1100 |
+
goto yyerrlab1;
|
| 1101 |
+
|
| 1102 |
+
|
| 1103 |
+
/*-------------------------------------------------------------.
|
| 1104 |
+
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
| 1105 |
+
`-------------------------------------------------------------*/
|
| 1106 |
+
yyerrlab1:
|
| 1107 |
+
yyerrstatus_ = 3; // Each real token shifted decrements this.
|
| 1108 |
+
// Pop stack until we find a state that shifts the error token.
|
| 1109 |
+
for (;;)
|
| 1110 |
+
{
|
| 1111 |
+
yyn = yypact_[+yystack_[0].state];
|
| 1112 |
+
if (!yy_pact_value_is_default_ (yyn))
|
| 1113 |
+
{
|
| 1114 |
+
yyn += ]b4_symbol(error, kind)[;
|
| 1115 |
+
if (0 <= yyn && yyn <= yylast_
|
| 1116 |
+
&& yycheck_[yyn] == ]b4_symbol(error, kind)[)
|
| 1117 |
+
{
|
| 1118 |
+
yyn = yytable_[yyn];
|
| 1119 |
+
if (0 < yyn)
|
| 1120 |
+
break;
|
| 1121 |
+
}
|
| 1122 |
+
}
|
| 1123 |
+
|
| 1124 |
+
// Pop the current state because it cannot handle the error token.
|
| 1125 |
+
if (yystack_.size () == 1)
|
| 1126 |
+
YYABORT;
|
| 1127 |
+
]b4_locations_if([[
|
| 1128 |
+
yyerror_range[1].location = yystack_[0].location;]])[
|
| 1129 |
+
yy_destroy_ ("Error: popping", yystack_[0]);
|
| 1130 |
+
yypop_ ();
|
| 1131 |
+
YY_STACK_PRINT ();
|
| 1132 |
+
}
|
| 1133 |
+
{
|
| 1134 |
+
stack_symbol_type error_token;
|
| 1135 |
+
]b4_locations_if([[
|
| 1136 |
+
yyerror_range[2].location = yyla.location;
|
| 1137 |
+
YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);]])[
|
| 1138 |
+
|
| 1139 |
+
// Shift the error token.]b4_lac_if([[
|
| 1140 |
+
yy_lac_discard_ ("error recovery");]])[
|
| 1141 |
+
error_token.state = state_type (yyn);
|
| 1142 |
+
yypush_ ("Shifting", YY_MOVE (error_token));
|
| 1143 |
+
}
|
| 1144 |
+
goto yynewstate;
|
| 1145 |
+
|
| 1146 |
+
|
| 1147 |
+
/*-------------------------------------.
|
| 1148 |
+
| yyacceptlab -- YYACCEPT comes here. |
|
| 1149 |
+
`-------------------------------------*/
|
| 1150 |
+
yyacceptlab:
|
| 1151 |
+
yyresult = 0;
|
| 1152 |
+
goto yyreturn;
|
| 1153 |
+
|
| 1154 |
+
|
| 1155 |
+
/*-----------------------------------.
|
| 1156 |
+
| yyabortlab -- YYABORT comes here. |
|
| 1157 |
+
`-----------------------------------*/
|
| 1158 |
+
yyabortlab:
|
| 1159 |
+
yyresult = 1;
|
| 1160 |
+
goto yyreturn;
|
| 1161 |
+
|
| 1162 |
+
|
| 1163 |
+
/*-----------------------------------------------------.
|
| 1164 |
+
| yyreturn -- parsing is finished, return the result. |
|
| 1165 |
+
`-----------------------------------------------------*/
|
| 1166 |
+
yyreturn:
|
| 1167 |
+
if (!yyla.empty ())
|
| 1168 |
+
yy_destroy_ ("Cleanup: discarding lookahead", yyla);
|
| 1169 |
+
|
| 1170 |
+
/* Do not reclaim the symbols of the rule whose action triggered
|
| 1171 |
+
this YYABORT or YYACCEPT. */
|
| 1172 |
+
yypop_ (yylen);
|
| 1173 |
+
YY_STACK_PRINT ();
|
| 1174 |
+
while (1 < yystack_.size ())
|
| 1175 |
+
{
|
| 1176 |
+
yy_destroy_ ("Cleanup: popping", yystack_[0]);
|
| 1177 |
+
yypop_ ();
|
| 1178 |
+
}
|
| 1179 |
+
|
| 1180 |
+
return yyresult;
|
| 1181 |
+
}
|
| 1182 |
+
#if YY_EXCEPTIONS
|
| 1183 |
+
catch (...)
|
| 1184 |
+
{
|
| 1185 |
+
YYCDEBUG << "Exception caught: cleaning lookahead and stack\n";
|
| 1186 |
+
// Do not try to display the values of the reclaimed symbols,
|
| 1187 |
+
// as their printers might throw an exception.
|
| 1188 |
+
if (!yyla.empty ())
|
| 1189 |
+
yy_destroy_ (YY_NULLPTR, yyla);
|
| 1190 |
+
|
| 1191 |
+
while (1 < yystack_.size ())
|
| 1192 |
+
{
|
| 1193 |
+
yy_destroy_ (YY_NULLPTR, yystack_[0]);
|
| 1194 |
+
yypop_ ();
|
| 1195 |
+
}
|
| 1196 |
+
throw;
|
| 1197 |
+
}
|
| 1198 |
+
#endif // YY_EXCEPTIONS
|
| 1199 |
+
}
|
| 1200 |
+
|
| 1201 |
+
void
|
| 1202 |
+
]b4_parser_class[::error (const syntax_error& yyexc)
|
| 1203 |
+
{
|
| 1204 |
+
error (]b4_join(b4_locations_if([yyexc.location]),
|
| 1205 |
+
[[yyexc.what ()]])[);
|
| 1206 |
+
}
|
| 1207 |
+
|
| 1208 |
+
]b4_parse_error_bmatch([custom\|detailed],
|
| 1209 |
+
[[ const char *
|
| 1210 |
+
]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
|
| 1211 |
+
{
|
| 1212 |
+
static const char *const yy_sname[] =
|
| 1213 |
+
{
|
| 1214 |
+
]b4_symbol_names[
|
| 1215 |
+
};]b4_has_translations_if([[
|
| 1216 |
+
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
|
| 1217 |
+
internationalizable. */
|
| 1218 |
+
static ]b4_int_type_for([b4_translatable])[ yytranslatable[] =
|
| 1219 |
+
{
|
| 1220 |
+
]b4_translatable[
|
| 1221 |
+
};
|
| 1222 |
+
return (yysymbol < YYNTOKENS && yytranslatable[yysymbol]
|
| 1223 |
+
? _(yy_sname[yysymbol])
|
| 1224 |
+
: yy_sname[yysymbol]);]], [[
|
| 1225 |
+
return yy_sname[yysymbol];]])[
|
| 1226 |
+
}
|
| 1227 |
+
]],
|
| 1228 |
+
[simple],
|
| 1229 |
+
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
| 1230 |
+
const char *
|
| 1231 |
+
]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
|
| 1232 |
+
{
|
| 1233 |
+
return yytname_[yysymbol];
|
| 1234 |
+
}
|
| 1235 |
+
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
| 1236 |
+
]],
|
| 1237 |
+
[verbose],
|
| 1238 |
+
[[ /* Return YYSTR after stripping away unnecessary quotes and
|
| 1239 |
+
backslashes, so that it's suitable for yyerror. The heuristic is
|
| 1240 |
+
that double-quoting is unnecessary unless the string contains an
|
| 1241 |
+
apostrophe, a comma, or backslash (other than backslash-backslash).
|
| 1242 |
+
YYSTR is taken from yytname. */
|
| 1243 |
+
std::string
|
| 1244 |
+
]b4_parser_class[::yytnamerr_ (const char *yystr)
|
| 1245 |
+
{
|
| 1246 |
+
if (*yystr == '"')
|
| 1247 |
+
{
|
| 1248 |
+
std::string yyr;
|
| 1249 |
+
char const *yyp = yystr;
|
| 1250 |
+
|
| 1251 |
+
for (;;)
|
| 1252 |
+
switch (*++yyp)
|
| 1253 |
+
{
|
| 1254 |
+
case '\'':
|
| 1255 |
+
case ',':
|
| 1256 |
+
goto do_not_strip_quotes;
|
| 1257 |
+
|
| 1258 |
+
case '\\':
|
| 1259 |
+
if (*++yyp != '\\')
|
| 1260 |
+
goto do_not_strip_quotes;
|
| 1261 |
+
else
|
| 1262 |
+
goto append;
|
| 1263 |
+
|
| 1264 |
+
append:
|
| 1265 |
+
default:
|
| 1266 |
+
yyr += *yyp;
|
| 1267 |
+
break;
|
| 1268 |
+
|
| 1269 |
+
case '"':
|
| 1270 |
+
return yyr;
|
| 1271 |
+
}
|
| 1272 |
+
do_not_strip_quotes: ;
|
| 1273 |
+
}
|
| 1274 |
+
|
| 1275 |
+
return yystr;
|
| 1276 |
+
}
|
| 1277 |
+
|
| 1278 |
+
std::string
|
| 1279 |
+
]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
|
| 1280 |
+
{
|
| 1281 |
+
return yytnamerr_ (yytname_[yysymbol]);
|
| 1282 |
+
}
|
| 1283 |
+
]])[
|
| 1284 |
+
|
| 1285 |
+
]b4_parse_error_bmatch([custom\|detailed\|verbose], [[
|
| 1286 |
+
// ]b4_parser_class[::context.
|
| 1287 |
+
]b4_parser_class[::context::context (const ]b4_parser_class[& yyparser, const symbol_type& yyla)
|
| 1288 |
+
: yyparser_ (yyparser)
|
| 1289 |
+
, yyla_ (yyla)
|
| 1290 |
+
{}
|
| 1291 |
+
|
| 1292 |
+
int
|
| 1293 |
+
]b4_parser_class[::context::expected_tokens (symbol_kind_type yyarg[], int yyargn) const
|
| 1294 |
+
{
|
| 1295 |
+
// Actual number of expected tokens
|
| 1296 |
+
int yycount = 0;
|
| 1297 |
+
]b4_lac_if([[
|
| 1298 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 1299 |
+
// Execute LAC once. We don't care if it is successful, we
|
| 1300 |
+
// only do it for the sake of debugging output.
|
| 1301 |
+
if (!yyparser_.yy_lac_established_)
|
| 1302 |
+
yyparser_.yy_lac_check_ (yyla_.kind ());
|
| 1303 |
+
#endif
|
| 1304 |
+
|
| 1305 |
+
for (int yyx = 0; yyx < YYNTOKENS; ++yyx)
|
| 1306 |
+
{
|
| 1307 |
+
symbol_kind_type yysym = YY_CAST (symbol_kind_type, yyx);
|
| 1308 |
+
if (yysym != ]b4_symbol(error, kind)[
|
| 1309 |
+
&& yysym != ]b4_symbol(undef, kind)[
|
| 1310 |
+
&& yyparser_.yy_lac_check_ (yysym))
|
| 1311 |
+
{
|
| 1312 |
+
if (!yyarg)
|
| 1313 |
+
++yycount;
|
| 1314 |
+
else if (yycount == yyargn)
|
| 1315 |
+
return 0;
|
| 1316 |
+
else
|
| 1317 |
+
yyarg[yycount++] = yysym;
|
| 1318 |
+
}
|
| 1319 |
+
}]], [[
|
| 1320 |
+
const int yyn = yypact_[+yyparser_.yystack_[0].state];
|
| 1321 |
+
if (!yy_pact_value_is_default_ (yyn))
|
| 1322 |
+
{
|
| 1323 |
+
/* Start YYX at -YYN if negative to avoid negative indexes in
|
| 1324 |
+
YYCHECK. In other words, skip the first -YYN actions for
|
| 1325 |
+
this state because they are default actions. */
|
| 1326 |
+
const int yyxbegin = yyn < 0 ? -yyn : 0;
|
| 1327 |
+
// Stay within bounds of both yycheck and yytname.
|
| 1328 |
+
const int yychecklim = yylast_ - yyn + 1;
|
| 1329 |
+
const int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
| 1330 |
+
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
|
| 1331 |
+
if (yycheck_[yyx + yyn] == yyx && yyx != ]b4_symbol(error, kind)[
|
| 1332 |
+
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))
|
| 1333 |
+
{
|
| 1334 |
+
if (!yyarg)
|
| 1335 |
+
++yycount;
|
| 1336 |
+
else if (yycount == yyargn)
|
| 1337 |
+
return 0;
|
| 1338 |
+
else
|
| 1339 |
+
yyarg[yycount++] = YY_CAST (symbol_kind_type, yyx);
|
| 1340 |
+
}
|
| 1341 |
+
}
|
| 1342 |
+
]])[
|
| 1343 |
+
if (yyarg && yycount == 0 && 0 < yyargn)
|
| 1344 |
+
yyarg[0] = ]b4_symbol(empty, kind)[;
|
| 1345 |
+
return yycount;
|
| 1346 |
+
}
|
| 1347 |
+
|
| 1348 |
+
]])[
|
| 1349 |
+
|
| 1350 |
+
]b4_lac_if([[
|
| 1351 |
+
bool
|
| 1352 |
+
]b4_parser_class[::yy_lac_check_ (symbol_kind_type yytoken) const
|
| 1353 |
+
{
|
| 1354 |
+
// Logically, the yylac_stack's lifetime is confined to this function.
|
| 1355 |
+
// Clear it, to get rid of potential left-overs from previous call.
|
| 1356 |
+
yylac_stack_.clear ();
|
| 1357 |
+
// Reduce until we encounter a shift and thereby accept the token.
|
| 1358 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 1359 |
+
YYCDEBUG << "LAC: checking lookahead " << symbol_name (yytoken) << ':';
|
| 1360 |
+
#endif
|
| 1361 |
+
std::ptrdiff_t lac_top = 0;
|
| 1362 |
+
while (true)
|
| 1363 |
+
{
|
| 1364 |
+
state_type top_state = (yylac_stack_.empty ()
|
| 1365 |
+
? yystack_[lac_top].state
|
| 1366 |
+
: yylac_stack_.back ());
|
| 1367 |
+
int yyrule = yypact_[+top_state];
|
| 1368 |
+
if (yy_pact_value_is_default_ (yyrule)
|
| 1369 |
+
|| (yyrule += yytoken) < 0 || yylast_ < yyrule
|
| 1370 |
+
|| yycheck_[yyrule] != yytoken)
|
| 1371 |
+
{
|
| 1372 |
+
// Use the default action.
|
| 1373 |
+
yyrule = yydefact_[+top_state];
|
| 1374 |
+
if (yyrule == 0)
|
| 1375 |
+
{
|
| 1376 |
+
YYCDEBUG << " Err\n";
|
| 1377 |
+
return false;
|
| 1378 |
+
}
|
| 1379 |
+
}
|
| 1380 |
+
else
|
| 1381 |
+
{
|
| 1382 |
+
// Use the action from yytable.
|
| 1383 |
+
yyrule = yytable_[yyrule];
|
| 1384 |
+
if (yy_table_value_is_error_ (yyrule))
|
| 1385 |
+
{
|
| 1386 |
+
YYCDEBUG << " Err\n";
|
| 1387 |
+
return false;
|
| 1388 |
+
}
|
| 1389 |
+
if (0 < yyrule)
|
| 1390 |
+
{
|
| 1391 |
+
YYCDEBUG << " S" << yyrule << '\n';
|
| 1392 |
+
return true;
|
| 1393 |
+
}
|
| 1394 |
+
yyrule = -yyrule;
|
| 1395 |
+
}
|
| 1396 |
+
// By now we know we have to simulate a reduce.
|
| 1397 |
+
YYCDEBUG << " R" << yyrule - 1;
|
| 1398 |
+
// Pop the corresponding number of values from the stack.
|
| 1399 |
+
{
|
| 1400 |
+
std::ptrdiff_t yylen = yyr2_[yyrule];
|
| 1401 |
+
// First pop from the LAC stack as many tokens as possible.
|
| 1402 |
+
std::ptrdiff_t lac_size = std::ptrdiff_t (yylac_stack_.size ());
|
| 1403 |
+
if (yylen < lac_size)
|
| 1404 |
+
{
|
| 1405 |
+
yylac_stack_.resize (std::size_t (lac_size - yylen));
|
| 1406 |
+
yylen = 0;
|
| 1407 |
+
}
|
| 1408 |
+
else if (lac_size)
|
| 1409 |
+
{
|
| 1410 |
+
yylac_stack_.clear ();
|
| 1411 |
+
yylen -= lac_size;
|
| 1412 |
+
}
|
| 1413 |
+
// Only afterwards look at the main stack.
|
| 1414 |
+
// We simulate popping elements by incrementing lac_top.
|
| 1415 |
+
lac_top += yylen;
|
| 1416 |
+
}
|
| 1417 |
+
// Keep top_state in sync with the updated stack.
|
| 1418 |
+
top_state = (yylac_stack_.empty ()
|
| 1419 |
+
? yystack_[lac_top].state
|
| 1420 |
+
: yylac_stack_.back ());
|
| 1421 |
+
// Push the resulting state of the reduction.
|
| 1422 |
+
state_type state = yy_lr_goto_state_ (top_state, yyr1_[yyrule]);
|
| 1423 |
+
YYCDEBUG << " G" << int (state);
|
| 1424 |
+
yylac_stack_.push_back (state);
|
| 1425 |
+
}
|
| 1426 |
+
}
|
| 1427 |
+
|
| 1428 |
+
// Establish the initial context if no initial context currently exists.
|
| 1429 |
+
bool
|
| 1430 |
+
]b4_parser_class[::yy_lac_establish_ (symbol_kind_type yytoken)
|
| 1431 |
+
{
|
| 1432 |
+
/* Establish the initial context for the current lookahead if no initial
|
| 1433 |
+
context is currently established.
|
| 1434 |
+
|
| 1435 |
+
We define a context as a snapshot of the parser stacks. We define
|
| 1436 |
+
the initial context for a lookahead as the context in which the
|
| 1437 |
+
parser initially examines that lookahead in order to select a
|
| 1438 |
+
syntactic action. Thus, if the lookahead eventually proves
|
| 1439 |
+
syntactically unacceptable (possibly in a later context reached via a
|
| 1440 |
+
series of reductions), the initial context can be used to determine
|
| 1441 |
+
the exact set of tokens that would be syntactically acceptable in the
|
| 1442 |
+
lookahead's place. Moreover, it is the context after which any
|
| 1443 |
+
further semantic actions would be erroneous because they would be
|
| 1444 |
+
determined by a syntactically unacceptable token.
|
| 1445 |
+
|
| 1446 |
+
yy_lac_establish_ should be invoked when a reduction is about to be
|
| 1447 |
+
performed in an inconsistent state (which, for the purposes of LAC,
|
| 1448 |
+
includes consistent states that don't know they're consistent because
|
| 1449 |
+
their default reductions have been disabled).
|
| 1450 |
+
|
| 1451 |
+
For parse.lac=full, the implementation of yy_lac_establish_ is as
|
| 1452 |
+
follows. If no initial context is currently established for the
|
| 1453 |
+
current lookahead, then check if that lookahead can eventually be
|
| 1454 |
+
shifted if syntactic actions continue from the current context. */
|
| 1455 |
+
if (yy_lac_established_)
|
| 1456 |
+
return true;
|
| 1457 |
+
else
|
| 1458 |
+
{
|
| 1459 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 1460 |
+
YYCDEBUG << "LAC: initial context established for "
|
| 1461 |
+
<< symbol_name (yytoken) << '\n';
|
| 1462 |
+
#endif
|
| 1463 |
+
yy_lac_established_ = true;
|
| 1464 |
+
return yy_lac_check_ (yytoken);
|
| 1465 |
+
}
|
| 1466 |
+
}
|
| 1467 |
+
|
| 1468 |
+
// Discard any previous initial lookahead context.
|
| 1469 |
+
void
|
| 1470 |
+
]b4_parser_class[::yy_lac_discard_ (const char* event)
|
| 1471 |
+
{
|
| 1472 |
+
/* Discard any previous initial lookahead context because of Event,
|
| 1473 |
+
which may be a lookahead change or an invalidation of the currently
|
| 1474 |
+
established initial context for the current lookahead.
|
| 1475 |
+
|
| 1476 |
+
The most common example of a lookahead change is a shift. An example
|
| 1477 |
+
of both cases is syntax error recovery. That is, a syntax error
|
| 1478 |
+
occurs when the lookahead is syntactically erroneous for the
|
| 1479 |
+
currently established initial context, so error recovery manipulates
|
| 1480 |
+
the parser stacks to try to find a new initial context in which the
|
| 1481 |
+
current lookahead is syntactically acceptable. If it fails to find
|
| 1482 |
+
such a context, it discards the lookahead. */
|
| 1483 |
+
if (yy_lac_established_)
|
| 1484 |
+
{
|
| 1485 |
+
YYCDEBUG << "LAC: initial context discarded due to "
|
| 1486 |
+
<< event << '\n';
|
| 1487 |
+
yy_lac_established_ = false;
|
| 1488 |
+
}
|
| 1489 |
+
}]])[
|
| 1490 |
+
|
| 1491 |
+
]b4_parse_error_bmatch([detailed\|verbose], [[
|
| 1492 |
+
int
|
| 1493 |
+
]b4_parser_class[::yy_syntax_error_arguments_ (const context& yyctx,
|
| 1494 |
+
symbol_kind_type yyarg[], int yyargn) const
|
| 1495 |
+
{
|
| 1496 |
+
/* There are many possibilities here to consider:
|
| 1497 |
+
- If this state is a consistent state with a default action, then
|
| 1498 |
+
the only way this function was invoked is if the default action
|
| 1499 |
+
is an error action. In that case, don't check for expected
|
| 1500 |
+
tokens because there are none.
|
| 1501 |
+
- The only way there can be no lookahead present (in yyla) is
|
| 1502 |
+
if this state is a consistent state with a default action.
|
| 1503 |
+
Thus, detecting the absence of a lookahead is sufficient to
|
| 1504 |
+
determine that there is no unexpected or expected token to
|
| 1505 |
+
report. In that case, just report a simple "syntax error".
|
| 1506 |
+
- Don't assume there isn't a lookahead just because this state is
|
| 1507 |
+
a consistent state with a default action. There might have
|
| 1508 |
+
been a previous inconsistent state, consistent state with a
|
| 1509 |
+
non-default action, or user semantic action that manipulated
|
| 1510 |
+
yyla. (However, yyla is currently not documented for users.)]b4_lac_if([[
|
| 1511 |
+
In the first two cases, it might appear that the current syntax
|
| 1512 |
+
error should have been detected in the previous state when
|
| 1513 |
+
yy_lac_check was invoked. However, at that time, there might
|
| 1514 |
+
have been a different syntax error that discarded a different
|
| 1515 |
+
initial context during error recovery, leaving behind the
|
| 1516 |
+
current lookahead.]], [[
|
| 1517 |
+
- Of course, the expected token list depends on states to have
|
| 1518 |
+
correct lookahead information, and it depends on the parser not
|
| 1519 |
+
to perform extra reductions after fetching a lookahead from the
|
| 1520 |
+
scanner and before detecting a syntax error. Thus, state merging
|
| 1521 |
+
(from LALR or IELR) and default reductions corrupt the expected
|
| 1522 |
+
token list. However, the list is correct for canonical LR with
|
| 1523 |
+
one exception: it will still contain any token that will not be
|
| 1524 |
+
accepted due to an error action in a later state.]])[
|
| 1525 |
+
*/
|
| 1526 |
+
|
| 1527 |
+
if (!yyctx.lookahead ().empty ())
|
| 1528 |
+
{
|
| 1529 |
+
if (yyarg)
|
| 1530 |
+
yyarg[0] = yyctx.token ();
|
| 1531 |
+
int yyn = yyctx.expected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn - 1);
|
| 1532 |
+
return yyn + 1;
|
| 1533 |
+
}
|
| 1534 |
+
return 0;
|
| 1535 |
+
}
|
| 1536 |
+
|
| 1537 |
+
// Generate an error message.
|
| 1538 |
+
std::string
|
| 1539 |
+
]b4_parser_class[::yysyntax_error_ (const context& yyctx) const
|
| 1540 |
+
{
|
| 1541 |
+
// Its maximum.
|
| 1542 |
+
enum { YYARGS_MAX = 5 };
|
| 1543 |
+
// Arguments of yyformat.
|
| 1544 |
+
symbol_kind_type yyarg[YYARGS_MAX];
|
| 1545 |
+
int yycount = yy_syntax_error_arguments_ (yyctx, yyarg, YYARGS_MAX);
|
| 1546 |
+
|
| 1547 |
+
char const* yyformat = YY_NULLPTR;
|
| 1548 |
+
switch (yycount)
|
| 1549 |
+
{
|
| 1550 |
+
#define YYCASE_(N, S) \
|
| 1551 |
+
case N: \
|
| 1552 |
+
yyformat = S; \
|
| 1553 |
+
break
|
| 1554 |
+
default: // Avoid compiler warnings.
|
| 1555 |
+
YYCASE_ (0, YY_("syntax error"));
|
| 1556 |
+
YYCASE_ (1, YY_("syntax error, unexpected %s"));
|
| 1557 |
+
YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s"));
|
| 1558 |
+
YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s"));
|
| 1559 |
+
YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
|
| 1560 |
+
YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
|
| 1561 |
+
#undef YYCASE_
|
| 1562 |
+
}
|
| 1563 |
+
|
| 1564 |
+
std::string yyres;
|
| 1565 |
+
// Argument number.
|
| 1566 |
+
std::ptrdiff_t yyi = 0;
|
| 1567 |
+
for (char const* yyp = yyformat; *yyp; ++yyp)
|
| 1568 |
+
if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
|
| 1569 |
+
{
|
| 1570 |
+
yyres += symbol_name (yyarg[yyi++]);
|
| 1571 |
+
++yyp;
|
| 1572 |
+
}
|
| 1573 |
+
else
|
| 1574 |
+
yyres += *yyp;
|
| 1575 |
+
return yyres;
|
| 1576 |
+
}]])[
|
| 1577 |
+
|
| 1578 |
+
|
| 1579 |
+
const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class::yypact_ninf_ = b4_pact_ninf[;
|
| 1580 |
+
|
| 1581 |
+
const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class::yytable_ninf_ = b4_table_ninf[;
|
| 1582 |
+
|
| 1583 |
+
]b4_parser_tables_define[
|
| 1584 |
+
|
| 1585 |
+
]b4_parse_error_bmatch([simple\|verbose],
|
| 1586 |
+
[[#if ]b4_api_PREFIX[DEBUG]b4_tname_if([[ || 1]])[
|
| 1587 |
+
// YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
| 1588 |
+
// First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
|
| 1589 |
+
const char*
|
| 1590 |
+
const ]b4_parser_class[::yytname_[] =
|
| 1591 |
+
{
|
| 1592 |
+
]b4_tname[
|
| 1593 |
+
};
|
| 1594 |
+
#endif
|
| 1595 |
+
]])[
|
| 1596 |
+
|
| 1597 |
+
#if ]b4_api_PREFIX[DEBUG][
|
| 1598 |
+
]b4_integral_parser_table_define([rline], [b4_rline])[
|
| 1599 |
+
|
| 1600 |
+
void
|
| 1601 |
+
]b4_parser_class[::yy_stack_print_ () const
|
| 1602 |
+
{
|
| 1603 |
+
*yycdebug_ << "Stack now";
|
| 1604 |
+
for (stack_type::const_iterator
|
| 1605 |
+
i = yystack_.begin (),
|
| 1606 |
+
i_end = yystack_.end ();
|
| 1607 |
+
i != i_end; ++i)
|
| 1608 |
+
*yycdebug_ << ' ' << int (i->state);
|
| 1609 |
+
*yycdebug_ << '\n';
|
| 1610 |
+
}
|
| 1611 |
+
|
| 1612 |
+
void
|
| 1613 |
+
]b4_parser_class[::yy_reduce_print_ (int yyrule) const
|
| 1614 |
+
{
|
| 1615 |
+
int yylno = yyrline_[yyrule];
|
| 1616 |
+
int yynrhs = yyr2_[yyrule];
|
| 1617 |
+
// Print the symbols being reduced, and their result.
|
| 1618 |
+
*yycdebug_ << "Reducing stack by rule " << yyrule - 1
|
| 1619 |
+
<< " (line " << yylno << "):\n";
|
| 1620 |
+
// The symbols being reduced.
|
| 1621 |
+
for (int yyi = 0; yyi < yynrhs; yyi++)
|
| 1622 |
+
YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
|
| 1623 |
+
]b4_rhs_data(yynrhs, yyi + 1)[);
|
| 1624 |
+
}
|
| 1625 |
+
#endif // ]b4_api_PREFIX[DEBUG
|
| 1626 |
+
|
| 1627 |
+
]b4_token_ctor_if([], [b4_yytranslate_define([cc])])[
|
| 1628 |
+
]b4_namespace_close[
|
| 1629 |
+
]b4_epilogue[]dnl
|
| 1630 |
+
b4_output_end
|
| 1631 |
+
|
| 1632 |
+
|
| 1633 |
+
m4_popdef([b4_copyright_years])dnl
|
platform/dbops/binaries/build/share/bison/skeletons/lalr1.d
ADDED
|
@@ -0,0 +1,1326 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# D skeleton for Bison -*- autoconf -*-
|
| 2 |
+
|
| 3 |
+
# Copyright (C) 2007-2012, 2019-2021 Free Software Foundation, Inc.
|
| 4 |
+
|
| 5 |
+
# This program is free software: you can redistribute it and/or modify
|
| 6 |
+
# it under the terms of the GNU General Public License as published by
|
| 7 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 8 |
+
# (at your option) any later version.
|
| 9 |
+
#
|
| 10 |
+
# This program is distributed in the hope that it will be useful,
|
| 11 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 13 |
+
# GNU General Public License for more details.
|
| 14 |
+
#
|
| 15 |
+
# You should have received a copy of the GNU General Public License
|
| 16 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 17 |
+
|
| 18 |
+
m4_include(b4_skeletonsdir/[d.m4])
|
| 19 |
+
|
| 20 |
+
b4_header_if([b4_complain([%header/%defines does not make sense in D])])
|
| 21 |
+
|
| 22 |
+
# parse.lac
|
| 23 |
+
b4_percent_define_default([[parse.lac]], [[none]])
|
| 24 |
+
b4_percent_define_check_values([[[[parse.lac]], [[full]], [[none]]]])
|
| 25 |
+
b4_define_flag_if([lac])
|
| 26 |
+
m4_define([b4_lac_flag],
|
| 27 |
+
[m4_if(b4_percent_define_get([[parse.lac]]),
|
| 28 |
+
[none], [[0]], [[1]])])
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
## --------------- ##
|
| 32 |
+
## api.push-pull. ##
|
| 33 |
+
## --------------- ##
|
| 34 |
+
|
| 35 |
+
b4_percent_define_default([[api.push-pull]], [[pull]])
|
| 36 |
+
b4_percent_define_check_values([[[[api.push-pull]],
|
| 37 |
+
[[pull]], [[push]], [[both]]]])
|
| 38 |
+
|
| 39 |
+
# Define m4 conditional macros that encode the value
|
| 40 |
+
# of the api.push-pull flag.
|
| 41 |
+
b4_define_flag_if([pull]) m4_define([b4_pull_flag], [[1]])
|
| 42 |
+
b4_define_flag_if([push]) m4_define([b4_push_flag], [[1]])
|
| 43 |
+
m4_case(b4_percent_define_get([[api.push-pull]]),
|
| 44 |
+
[pull], [m4_define([b4_push_flag], [[0]])],
|
| 45 |
+
[push], [m4_define([b4_pull_flag], [[0]])])
|
| 46 |
+
|
| 47 |
+
# Define a macro to be true when api.push-pull has the value "both".
|
| 48 |
+
m4_define([b4_both_if],[b4_push_if([b4_pull_if([$1],[$2])],[$2])])
|
| 49 |
+
|
| 50 |
+
# Handle BISON_USE_PUSH_FOR_PULL for the test suite. So that push parsing
|
| 51 |
+
# tests function as written, do not let BISON_USE_PUSH_FOR_PULL modify the
|
| 52 |
+
# behavior of Bison at all when push parsing is already requested.
|
| 53 |
+
b4_define_flag_if([use_push_for_pull])
|
| 54 |
+
b4_use_push_for_pull_if([
|
| 55 |
+
b4_push_if([m4_define([b4_use_push_for_pull_flag], [[0]])],
|
| 56 |
+
[m4_define([b4_push_flag], [[1]])])])
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
# Define a macro to encapsulate the parse state variables. This
|
| 60 |
+
# allows them to be defined either in parse() when doing pull parsing,
|
| 61 |
+
# or as class instance variable when doing push parsing.
|
| 62 |
+
b4_output_begin([b4_parser_file_name])
|
| 63 |
+
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in D],
|
| 64 |
+
[2007-2012, 2019-2021])[
|
| 65 |
+
]b4_disclaimer[
|
| 66 |
+
]b4_percent_define_ifdef([package], [module b4_percent_define_get([package]);
|
| 67 |
+
])[
|
| 68 |
+
version(D_Version2) {
|
| 69 |
+
} else {
|
| 70 |
+
static assert(false, "need compiler for D Version 2");
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
]b4_user_pre_prologue[
|
| 74 |
+
]b4_user_post_prologue[
|
| 75 |
+
]b4_percent_code_get([[imports]])[
|
| 76 |
+
import std.format;
|
| 77 |
+
import std.conv;
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Handle error message internationalisation.
|
| 81 |
+
*/
|
| 82 |
+
static if (!is(typeof(YY_))) {
|
| 83 |
+
version(YYENABLE_NLS)
|
| 84 |
+
{
|
| 85 |
+
version(ENABLE_NLS)
|
| 86 |
+
{
|
| 87 |
+
extern(C) char* dgettext(const char*, const char*);
|
| 88 |
+
string YY_(const char* s)
|
| 89 |
+
{
|
| 90 |
+
return to!string(dgettext("bison-runtime", s));
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
static if (!is(typeof(YY_)))
|
| 95 |
+
{
|
| 96 |
+
pragma(inline, true)
|
| 97 |
+
string YY_(string msg) { return msg; }
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
|
| 103 |
+
*
|
| 104 |
+
* @@author LALR (1) parser skeleton written by Paolo Bonzini.
|
| 105 |
+
* Port to D language was done by Oliver Mangold.
|
| 106 |
+
*/
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* Communication interface between the scanner and the Bison-generated
|
| 110 |
+
* parser <tt>]b4_parser_class[</tt>.
|
| 111 |
+
*/
|
| 112 |
+
public interface Lexer
|
| 113 |
+
{
|
| 114 |
+
/**
|
| 115 |
+
* Entry point for the scanner. Returns the token identifier corresponding
|
| 116 |
+
* to the next token and prepares to return the semantic value
|
| 117 |
+
* ]b4_locations_if([and beginning/ending positions ])[of the token.
|
| 118 |
+
* @@return the token identifier corresponding to the next token. */
|
| 119 |
+
Symbol yylex ();
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* Entry point for error reporting. Emits an error
|
| 123 |
+
* ]b4_locations_if([referring to the given location ])[in a user-defined way.
|
| 124 |
+
*]b4_locations_if([[
|
| 125 |
+
* @@param loc The location of the element to which the
|
| 126 |
+
* error message is related]])[
|
| 127 |
+
* @@param s The string for the error message. */
|
| 128 |
+
void yyerror (]b4_locations_if([[const Location loc, ]])[string s);
|
| 129 |
+
]b4_parse_error_bmatch([custom], [[
|
| 130 |
+
/**
|
| 131 |
+
* Build and emit a "syntax error" message in a user-defined way.
|
| 132 |
+
*
|
| 133 |
+
* @@param ctx The context of the error.
|
| 134 |
+
*/
|
| 135 |
+
void reportSyntaxError(]b4_parser_class[.Context ctx);
|
| 136 |
+
]])[
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
]b4_public_types_declare[
|
| 140 |
+
|
| 141 |
+
]b4_locations_if([b4_position_type_if([[
|
| 142 |
+
static assert(__traits(compiles,
|
| 143 |
+
(new Position[1])[0]=(new Position[1])[0]),
|
| 144 |
+
"struct/class Position must be default-constructible "
|
| 145 |
+
"and assignable");
|
| 146 |
+
static assert(__traits(compiles, (new string[1])[0]=(new Position).toString()),
|
| 147 |
+
"error: struct/class Position must have toString method");
|
| 148 |
+
]], [[
|
| 149 |
+
/**
|
| 150 |
+
* A struct denoting a point in the input.*/
|
| 151 |
+
public struct ]b4_position_type[ {
|
| 152 |
+
|
| 153 |
+
/** The column index within the line of input. */
|
| 154 |
+
public int column = 1;
|
| 155 |
+
/** The line number within an input file. */
|
| 156 |
+
public int line = 1;
|
| 157 |
+
/** The name of the input file. */
|
| 158 |
+
public string filename = null;
|
| 159 |
+
|
| 160 |
+
/**
|
| 161 |
+
* A string representation of the position. */
|
| 162 |
+
public string toString() const {
|
| 163 |
+
if (filename)
|
| 164 |
+
return format("%s:%d.%d", filename, line, column);
|
| 165 |
+
else
|
| 166 |
+
return format("%d.%d", line, column);
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
]])b4_location_type_if([[
|
| 170 |
+
static assert(__traits(compiles, (new Location((new Position[1])[0]))) &&
|
| 171 |
+
__traits(compiles, (new Location((new Position[1])[0], (new Position[1])[0]))),
|
| 172 |
+
"error: struct/class Location must have "
|
| 173 |
+
"default constructor and constructors this(Position) and this(Position, Position).");
|
| 174 |
+
static assert(__traits(compiles, (new Location[1])[0].begin=(new Location[1])[0].begin) &&
|
| 175 |
+
__traits(compiles, (new Location[1])[0].begin=(new Location[1])[0].end) &&
|
| 176 |
+
__traits(compiles, (new Location[1])[0].end=(new Location[1])[0].begin) &&
|
| 177 |
+
__traits(compiles, (new Location[1])[0].end=(new Location[1])[0].end),
|
| 178 |
+
"error: struct/class Location must have assignment-compatible "
|
| 179 |
+
"members/properties 'begin' and 'end'.");
|
| 180 |
+
static assert(__traits(compiles, (new string[1])[0]=(new Location[1])[0].toString()),
|
| 181 |
+
"error: struct/class Location must have toString method.");
|
| 182 |
+
|
| 183 |
+
private immutable bool yy_location_is_class = !__traits(compiles, *(new Location((new Position[1])[0])));]], [[
|
| 184 |
+
/**
|
| 185 |
+
* A struct defining a pair of positions. Positions, defined by the
|
| 186 |
+
* <code>Position</code> struct, denote a point in the input.
|
| 187 |
+
* Locations represent a part of the input through the beginning
|
| 188 |
+
* and ending positions. */
|
| 189 |
+
public struct ]b4_location_type[
|
| 190 |
+
{
|
| 191 |
+
/** The first, inclusive, position in the range. */
|
| 192 |
+
public Position begin;
|
| 193 |
+
|
| 194 |
+
/** The first position beyond the range. */
|
| 195 |
+
public Position end;
|
| 196 |
+
|
| 197 |
+
/**
|
| 198 |
+
* Create a <code>Location</code> denoting an empty range located at
|
| 199 |
+
* a given point.
|
| 200 |
+
* @@param loc The position at which the range is anchored. */
|
| 201 |
+
public this(Position loc)
|
| 202 |
+
{
|
| 203 |
+
this.begin = this.end = loc;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
/**
|
| 207 |
+
* Create a <code>Location</code> from the endpoints of the range.
|
| 208 |
+
* @@param begin The first position included in the range.
|
| 209 |
+
* @@param end The first position beyond the range. */
|
| 210 |
+
public this(Position begin, Position end)
|
| 211 |
+
{
|
| 212 |
+
this.begin = begin;
|
| 213 |
+
this.end = end;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
/**
|
| 217 |
+
* Reset initial location to final location.
|
| 218 |
+
*/
|
| 219 |
+
public void step()
|
| 220 |
+
{
|
| 221 |
+
this.begin = this.end;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
/**
|
| 225 |
+
* A representation of the location.
|
| 226 |
+
*/
|
| 227 |
+
public string toString() const
|
| 228 |
+
{
|
| 229 |
+
auto end_col = 0 < end.column ? end.column - 1 : 0;
|
| 230 |
+
auto res = begin.toString ();
|
| 231 |
+
if (end.filename && begin.filename != end.filename)
|
| 232 |
+
res ~= "-" ~ format("%s:%d.%d", end.filename, end.line, end_col);
|
| 233 |
+
else if (begin.line < end.line)
|
| 234 |
+
res ~= "-" ~ format("%d.%d", end.line, end_col);
|
| 235 |
+
else if (begin.column < end_col)
|
| 236 |
+
res ~= "-" ~ format("%d", end_col);
|
| 237 |
+
return res;
|
| 238 |
+
}
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
private immutable bool yy_location_is_class = false;
|
| 242 |
+
|
| 243 |
+
]])])[]b4_value_type_setup[]m4_ifdef([b4_user_union_members], [private union YYSemanticType
|
| 244 |
+
{
|
| 245 |
+
b4_user_union_members
|
| 246 |
+
};],
|
| 247 |
+
[m4_if(b4_tag_seen_flag, 0,
|
| 248 |
+
[[private alias int YYSemanticType;]])])[
|
| 249 |
+
]b4_token_enums[
|
| 250 |
+
]b4_parser_class_declaration[
|
| 251 |
+
{
|
| 252 |
+
]b4_identification[
|
| 253 |
+
|
| 254 |
+
]b4_declare_symbol_enum[
|
| 255 |
+
|
| 256 |
+
]b4_locations_if([[
|
| 257 |
+
private final Location yylloc_from_stack (ref YYStack rhs, int n)
|
| 258 |
+
{
|
| 259 |
+
static if (yy_location_is_class) {
|
| 260 |
+
if (n > 0)
|
| 261 |
+
return new Location (rhs.locationAt (n-1).begin, rhs.locationAt (0).end);
|
| 262 |
+
else
|
| 263 |
+
return new Location (rhs.locationAt (0).end);
|
| 264 |
+
} else {
|
| 265 |
+
if (n > 0)
|
| 266 |
+
return Location (rhs.locationAt (n-1).begin, rhs.locationAt (0).end);
|
| 267 |
+
else
|
| 268 |
+
return Location (rhs.locationAt (0).end);
|
| 269 |
+
}
|
| 270 |
+
}]])[
|
| 271 |
+
|
| 272 |
+
]b4_lexer_if([[ private class YYLexer implements Lexer {
|
| 273 |
+
]b4_percent_code_get([[lexer]])[
|
| 274 |
+
}
|
| 275 |
+
]])[
|
| 276 |
+
/** The object doing lexical analysis for us. */
|
| 277 |
+
private Lexer yylexer;
|
| 278 |
+
|
| 279 |
+
]b4_parse_param_vars[
|
| 280 |
+
|
| 281 |
+
]b4_lexer_if([[
|
| 282 |
+
/**
|
| 283 |
+
* Instantiate the Bison-generated parser.
|
| 284 |
+
*/
|
| 285 |
+
public this] (b4_parse_param_decl([b4_lex_param_decl])[) {
|
| 286 |
+
]b4_percent_code_get([[init]])[]b4_lac_if([[
|
| 287 |
+
this.yylacStack = new int[];
|
| 288 |
+
this.yylacEstablished = false;]])[
|
| 289 |
+
this (new YYLexer(]b4_lex_param_call[));
|
| 290 |
+
}
|
| 291 |
+
]])[
|
| 292 |
+
|
| 293 |
+
/**
|
| 294 |
+
* Instantiate the Bison-generated parser.
|
| 295 |
+
* @@param yylexer The scanner that will supply tokens to the parser.
|
| 296 |
+
*/
|
| 297 |
+
]b4_lexer_if([[protected]], [[public]]) [this (]b4_parse_param_decl([[Lexer yylexer]])[) {
|
| 298 |
+
this.yylexer = yylexer;]b4_parse_trace_if([[
|
| 299 |
+
this.yyDebugStream = stderr;]])[
|
| 300 |
+
]b4_parse_param_cons[
|
| 301 |
+
}
|
| 302 |
+
]b4_parse_trace_if([[
|
| 303 |
+
import std.stdio;
|
| 304 |
+
private File yyDebugStream;
|
| 305 |
+
|
| 306 |
+
/**
|
| 307 |
+
* The <tt>File</tt> on which the debugging output is
|
| 308 |
+
* printed.
|
| 309 |
+
*/
|
| 310 |
+
public File getDebugStream () { return yyDebugStream; }
|
| 311 |
+
|
| 312 |
+
/**
|
| 313 |
+
* Set the <tt>std.File</tt> on which the debug output is printed.
|
| 314 |
+
* @@param s The stream that is used for debugging output.
|
| 315 |
+
*/
|
| 316 |
+
public final void setDebugStream(File s) { yyDebugStream = s; }
|
| 317 |
+
|
| 318 |
+
private int yydebug = 0;
|
| 319 |
+
|
| 320 |
+
/**
|
| 321 |
+
* Answer the verbosity of the debugging output; 0 means that all kinds of
|
| 322 |
+
* output from the parser are suppressed.
|
| 323 |
+
*/
|
| 324 |
+
public final int getDebugLevel() { return yydebug; }
|
| 325 |
+
|
| 326 |
+
/**
|
| 327 |
+
* Set the verbosity of the debugging output; 0 means that all kinds of
|
| 328 |
+
* output from the parser are suppressed.
|
| 329 |
+
* @@param level The verbosity level for debugging output.
|
| 330 |
+
*/
|
| 331 |
+
public final void setDebugLevel(int level) { yydebug = level; }
|
| 332 |
+
|
| 333 |
+
protected final void yycdebug (string s) {
|
| 334 |
+
if (0 < yydebug)
|
| 335 |
+
yyDebugStream.write (s);
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
protected final void yycdebugln (string s) {
|
| 339 |
+
if (0 < yydebug)
|
| 340 |
+
yyDebugStream.writeln (s);
|
| 341 |
+
}
|
| 342 |
+
]])[
|
| 343 |
+
private final ]b4_parser_class[.Symbol yylex () {
|
| 344 |
+
return yylexer.yylex ();
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
protected final void yyerror (]b4_locations_if([[const Location loc, ]])[string s) {
|
| 348 |
+
yylexer.yyerror (]b4_locations_if([loc, ])[s);
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
/**
|
| 352 |
+
* The number of syntax errors so far.
|
| 353 |
+
*/
|
| 354 |
+
public int numberOfErrors() const { return yynerrs_; }
|
| 355 |
+
private int yynerrs_ = 0;
|
| 356 |
+
|
| 357 |
+
/**
|
| 358 |
+
* Returned by a Bison action in order to stop the parsing process and
|
| 359 |
+
* return success (<tt>true</tt>). */
|
| 360 |
+
public static immutable int YYACCEPT = 0;
|
| 361 |
+
|
| 362 |
+
/**
|
| 363 |
+
* Returned by a Bison action in order to stop the parsing process and
|
| 364 |
+
* return failure (<tt>false</tt>). */
|
| 365 |
+
public static immutable int YYABORT = 1;
|
| 366 |
+
]b4_push_if([
|
| 367 |
+
/**
|
| 368 |
+
* Returned by a Bison action in order to request a new token.
|
| 369 |
+
*/
|
| 370 |
+
public static immutable int YYPUSH_MORE = 4;])[
|
| 371 |
+
|
| 372 |
+
/**
|
| 373 |
+
* Returned by a Bison action in order to start error recovery without
|
| 374 |
+
* printing an error message. */
|
| 375 |
+
public static immutable int YYERROR = 2;
|
| 376 |
+
|
| 377 |
+
// Internal return codes that are not supported for user semantic
|
| 378 |
+
// actions.
|
| 379 |
+
private static immutable int YYERRLAB = 3;
|
| 380 |
+
private static immutable int YYNEWSTATE = 4;
|
| 381 |
+
private static immutable int YYDEFAULT = 5;
|
| 382 |
+
private static immutable int YYREDUCE = 6;
|
| 383 |
+
private static immutable int YYERRLAB1 = 7;
|
| 384 |
+
private static immutable int YYRETURN = 8;
|
| 385 |
+
]b4_push_if([[ private static immutable int YYGETTOKEN = 9; /* Signify that a new token is expected when doing push-parsing. */]])[
|
| 386 |
+
|
| 387 |
+
]b4_locations_if([
|
| 388 |
+
private static immutable YYSemanticType yy_semantic_null;])[
|
| 389 |
+
private int yyerrstatus_ = 0;
|
| 390 |
+
|
| 391 |
+
private void yyerrok()
|
| 392 |
+
{
|
| 393 |
+
yyerrstatus_ = 0;
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
// Lookahead symbol kind.
|
| 397 |
+
SymbolKind yytoken = ]b4_symbol(empty, kind)[;
|
| 398 |
+
|
| 399 |
+
/* State. */
|
| 400 |
+
int yyn = 0;
|
| 401 |
+
int yylen = 0;
|
| 402 |
+
int yystate = 0;
|
| 403 |
+
|
| 404 |
+
YYStack yystack;
|
| 405 |
+
|
| 406 |
+
int label = YYNEWSTATE;
|
| 407 |
+
|
| 408 |
+
/* Error handling. */
|
| 409 |
+
]b4_locations_if([[
|
| 410 |
+
/// The location where the error started.
|
| 411 |
+
Location yyerrloc;
|
| 412 |
+
|
| 413 |
+
/// Location of the lookahead.
|
| 414 |
+
Location yylloc;
|
| 415 |
+
|
| 416 |
+
/// @@$.
|
| 417 |
+
Location yyloc;]])[
|
| 418 |
+
|
| 419 |
+
/// Semantic value of the lookahead.
|
| 420 |
+
Value yylval;
|
| 421 |
+
|
| 422 |
+
/**
|
| 423 |
+
* Whether error recovery is being done. In this state, the parser
|
| 424 |
+
* reads token until it reaches a known state, and then restarts normal
|
| 425 |
+
* operation. */
|
| 426 |
+
public final bool recovering ()
|
| 427 |
+
{
|
| 428 |
+
return yyerrstatus_ == 0;
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
/** Compute post-reduction state.
|
| 432 |
+
* @@param yystate the current state
|
| 433 |
+
* @@param yysym the nonterminal to push on the stack
|
| 434 |
+
*/
|
| 435 |
+
private int yyLRGotoState(int yystate, int yysym) {
|
| 436 |
+
int yyr = yypgoto_[yysym - yyntokens_] + yystate;
|
| 437 |
+
if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
|
| 438 |
+
return yytable_[yyr];
|
| 439 |
+
else
|
| 440 |
+
return yydefgoto_[yysym - yyntokens_];
|
| 441 |
+
}
|
| 442 |
+
|
| 443 |
+
private int yyaction (int yyn, ref YYStack yystack, int yylen)
|
| 444 |
+
{
|
| 445 |
+
Value yyval;]b4_locations_if([[
|
| 446 |
+
Location yyloc = yylloc_from_stack (yystack, yylen);]])[
|
| 447 |
+
|
| 448 |
+
/* If YYLEN is nonzero, implement the default value of the action:
|
| 449 |
+
`$$ = $1'. Otherwise, use the top of the stack.
|
| 450 |
+
|
| 451 |
+
Otherwise, the following line sets YYVAL to garbage.
|
| 452 |
+
This behavior is undocumented and Bison
|
| 453 |
+
users should not rely upon it. */
|
| 454 |
+
if (yylen > 0)
|
| 455 |
+
yyval = yystack.valueAt (yylen - 1);
|
| 456 |
+
else
|
| 457 |
+
yyval = yystack.valueAt (0);
|
| 458 |
+
|
| 459 |
+
]b4_parse_trace_if([[
|
| 460 |
+
yy_reduce_print (yyn, yystack);]])[
|
| 461 |
+
|
| 462 |
+
switch (yyn)
|
| 463 |
+
{
|
| 464 |
+
]b4_user_actions[
|
| 465 |
+
default: break;
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
]b4_parse_trace_if([[
|
| 469 |
+
yy_symbol_print ("-> $$ =", to!SymbolKind (yyr1_[yyn]), yyval]b4_locations_if([, yyloc])[);]])[
|
| 470 |
+
|
| 471 |
+
yystack.pop (yylen);
|
| 472 |
+
yylen = 0;
|
| 473 |
+
|
| 474 |
+
/* Shift the result of the reduction. */
|
| 475 |
+
int yystate = yyLRGotoState(yystack.stateAt(0), yyr1_[yyn]);
|
| 476 |
+
yystack.push (yystate, yyval]b4_locations_if([, yyloc])[);
|
| 477 |
+
return YYNEWSTATE;
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
]b4_parse_trace_if([[
|
| 481 |
+
/*--------------------------------.
|
| 482 |
+
| Print this symbol on YYOUTPUT. |
|
| 483 |
+
`--------------------------------*/
|
| 484 |
+
|
| 485 |
+
private final void yy_symbol_print (string s, SymbolKind yykind,
|
| 486 |
+
ref Value yyval]b4_locations_if([, ref Location yyloc])[)
|
| 487 |
+
{
|
| 488 |
+
if (0 < yydebug)
|
| 489 |
+
{
|
| 490 |
+
File yyo = yyDebugStream;
|
| 491 |
+
yyo.write(s);
|
| 492 |
+
yyo.write(yykind < yyntokens_ ? " token " : " nterm ");
|
| 493 |
+
yyo.write(format("%s", yykind));
|
| 494 |
+
yyo.write(" ("]b4_locations_if([ ~ yyloc.toString() ~ ": "])[);
|
| 495 |
+
]b4_symbol_actions([printer])[
|
| 496 |
+
yyo.write(")\n");
|
| 497 |
+
}
|
| 498 |
+
}
|
| 499 |
+
]])[
|
| 500 |
+
]b4_symbol_type_define[
|
| 501 |
+
]b4_push_if([[
|
| 502 |
+
/**
|
| 503 |
+
* Push Parse input from external lexer
|
| 504 |
+
*
|
| 505 |
+
* @@param yyla current Symbol
|
| 506 |
+
*
|
| 507 |
+
* @@return <tt>YYACCEPT, YYABORT, YYPUSH_MORE</tt>
|
| 508 |
+
*/
|
| 509 |
+
public int pushParse(Symbol yyla)]], [[
|
| 510 |
+
/**
|
| 511 |
+
* Parse input from the scanner that was specified at object construction
|
| 512 |
+
* time. Return whether the end of the input was reached successfully.
|
| 513 |
+
*
|
| 514 |
+
* @@return <tt>true</tt> if the parsing succeeds. Note that this does not
|
| 515 |
+
* imply that there were no syntax errors.
|
| 516 |
+
*/
|
| 517 |
+
public bool parse()]])[
|
| 518 |
+
{]b4_push_if([[
|
| 519 |
+
if (!this.pushParseInitialized)
|
| 520 |
+
{
|
| 521 |
+
pushParseInitialize();
|
| 522 |
+
yyerrstatus_ = 0;
|
| 523 |
+
}
|
| 524 |
+
else
|
| 525 |
+
label = YYGETTOKEN;
|
| 526 |
+
|
| 527 |
+
bool push_token_consumed = true;
|
| 528 |
+
]], [[ bool yyresult;]b4_lac_if([[
|
| 529 |
+
// Discard the LAC context in case there still is one left from a
|
| 530 |
+
// previous invocation.
|
| 531 |
+
yylacDiscard("init");]])[]b4_parse_trace_if([[
|
| 532 |
+
|
| 533 |
+
yycdebugln ("Starting parse");]])[
|
| 534 |
+
yyerrstatus_ = 0;
|
| 535 |
+
|
| 536 |
+
]m4_ifdef([b4_initial_action], [
|
| 537 |
+
m4_pushdef([b4_at_dollar], [yylloc])dnl
|
| 538 |
+
m4_pushdef([b4_dollar_dollar], [yylval])dnl
|
| 539 |
+
/* User initialization code. */
|
| 540 |
+
b4_user_initial_action
|
| 541 |
+
m4_popdef([b4_dollar_dollar])dnl
|
| 542 |
+
m4_popdef([b4_at_dollar])])dnl
|
| 543 |
+
|
| 544 |
+
[ /* Initialize the stack. */
|
| 545 |
+
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
| 546 |
+
|
| 547 |
+
label = YYNEWSTATE;]])[
|
| 548 |
+
for (;;)
|
| 549 |
+
final switch (label)
|
| 550 |
+
{
|
| 551 |
+
/* New state. Unlike in the C/C++ skeletons, the state is already
|
| 552 |
+
pushed when we come here. */
|
| 553 |
+
case YYNEWSTATE:]b4_parse_trace_if([[
|
| 554 |
+
yycdebugln (format("Entering state %d", yystate));
|
| 555 |
+
if (0 < yydebug)
|
| 556 |
+
yystack.print (yyDebugStream);]])[
|
| 557 |
+
|
| 558 |
+
/* Accept? */
|
| 559 |
+
if (yystate == yyfinal_)]b4_push_if([[
|
| 560 |
+
{
|
| 561 |
+
label = YYACCEPT;
|
| 562 |
+
break;
|
| 563 |
+
}]], [[
|
| 564 |
+
return true;]])[
|
| 565 |
+
|
| 566 |
+
/* Take a decision. First try without lookahead. */
|
| 567 |
+
yyn = yypact_[yystate];
|
| 568 |
+
if (yyPactValueIsDefault(yyn))
|
| 569 |
+
{
|
| 570 |
+
label = YYDEFAULT;
|
| 571 |
+
break;
|
| 572 |
+
}]b4_push_if([[
|
| 573 |
+
goto case;
|
| 574 |
+
|
| 575 |
+
case YYGETTOKEN:]])[
|
| 576 |
+
|
| 577 |
+
/* Read a lookahead token. */
|
| 578 |
+
if (yytoken == ]b4_symbol(empty, kind)[)
|
| 579 |
+
{]b4_push_if([[
|
| 580 |
+
if (!push_token_consumed)
|
| 581 |
+
return YYPUSH_MORE;]])[]b4_parse_trace_if([[
|
| 582 |
+
yycdebugln ("Reading a token");]])[]b4_push_if([[
|
| 583 |
+
yytoken = yyla.token;
|
| 584 |
+
yylval = yyla.value;]b4_locations_if([[
|
| 585 |
+
yylloc = yyla.location;]])[
|
| 586 |
+
push_token_consumed = false;]], [[
|
| 587 |
+
Symbol yysymbol = yylex();
|
| 588 |
+
yytoken = yysymbol.token();
|
| 589 |
+
yylval = yysymbol.value();]b4_locations_if([[
|
| 590 |
+
yylloc = yysymbol.location();]])[]])[
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
/* Token already converted to internal form. */]b4_parse_trace_if([[
|
| 594 |
+
yy_symbol_print ("Next token is", yytoken, yylval]b4_locations_if([, yylloc])[);]])[
|
| 595 |
+
|
| 596 |
+
if (yytoken == ]b4_symbol(error, kind)[)
|
| 597 |
+
{
|
| 598 |
+
// The scanner already issued an error message, process directly
|
| 599 |
+
// to error recovery. But do not keep the error token as
|
| 600 |
+
// lookahead, it is too special and may lead us to an endless
|
| 601 |
+
// loop in error recovery. */
|
| 602 |
+
yytoken = ]b4_symbol(undef, kind)[;]b4_locations_if([[
|
| 603 |
+
yyerrloc = yylloc;]])[
|
| 604 |
+
label = YYERRLAB1;
|
| 605 |
+
}
|
| 606 |
+
else
|
| 607 |
+
{
|
| 608 |
+
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
| 609 |
+
detect an error, take that action. */
|
| 610 |
+
yyn += yytoken;
|
| 611 |
+
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) {]b4_lac_if([[
|
| 612 |
+
if (!yylacEstablish(yystack, yytoken))
|
| 613 |
+
label = YYERRLAB;
|
| 614 |
+
else]])[
|
| 615 |
+
label = YYDEFAULT;
|
| 616 |
+
}
|
| 617 |
+
/* <= 0 means reduce or error. */
|
| 618 |
+
else if ((yyn = yytable_[yyn]) <= 0)
|
| 619 |
+
{
|
| 620 |
+
if (yyTableValueIsError(yyn))
|
| 621 |
+
label = YYERRLAB;]b4_lac_if([[
|
| 622 |
+
else if (!yylacEstablish(yystack, yytoken))
|
| 623 |
+
label = YYERRLAB;]])[
|
| 624 |
+
else
|
| 625 |
+
{
|
| 626 |
+
yyn = -yyn;
|
| 627 |
+
label = YYREDUCE;
|
| 628 |
+
}
|
| 629 |
+
}
|
| 630 |
+
else
|
| 631 |
+
{
|
| 632 |
+
/* Shift the lookahead token. */]b4_parse_trace_if([[
|
| 633 |
+
yy_symbol_print ("Shifting", yytoken, yylval]b4_locations_if([, yylloc])[);]])[
|
| 634 |
+
|
| 635 |
+
/* Discard the token being shifted. */
|
| 636 |
+
yytoken = ]b4_symbol(empty, kind)[;
|
| 637 |
+
|
| 638 |
+
/* Count tokens shifted since error; after three, turn off error
|
| 639 |
+
* status. */
|
| 640 |
+
if (yyerrstatus_ > 0)
|
| 641 |
+
--yyerrstatus_;
|
| 642 |
+
|
| 643 |
+
yystate = yyn;
|
| 644 |
+
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);]b4_lac_if([[
|
| 645 |
+
yylacDiscard("shift");]])[
|
| 646 |
+
label = YYNEWSTATE;
|
| 647 |
+
}
|
| 648 |
+
}
|
| 649 |
+
break;
|
| 650 |
+
|
| 651 |
+
/*-----------------------------------------------------------.
|
| 652 |
+
| yydefault -- do the default action for the current state. |
|
| 653 |
+
`-----------------------------------------------------------*/
|
| 654 |
+
case YYDEFAULT:
|
| 655 |
+
yyn = yydefact_[yystate];
|
| 656 |
+
if (yyn == 0)
|
| 657 |
+
label = YYERRLAB;
|
| 658 |
+
else
|
| 659 |
+
label = YYREDUCE;
|
| 660 |
+
break;
|
| 661 |
+
|
| 662 |
+
/*-----------------------------.
|
| 663 |
+
| yyreduce -- Do a reduction. |
|
| 664 |
+
`-----------------------------*/
|
| 665 |
+
case YYREDUCE:
|
| 666 |
+
yylen = yyr2_[yyn];
|
| 667 |
+
label = yyaction (yyn, yystack, yylen);
|
| 668 |
+
yystate = yystack.stateAt (0);
|
| 669 |
+
break;
|
| 670 |
+
|
| 671 |
+
/*--------------------------------------.
|
| 672 |
+
| yyerrlab -- here on detecting error. |
|
| 673 |
+
`--------------------------------------*/
|
| 674 |
+
case YYERRLAB:
|
| 675 |
+
/* If not already recovering from an error, report this error. */
|
| 676 |
+
if (yyerrstatus_ == 0)
|
| 677 |
+
{
|
| 678 |
+
++yynerrs_;
|
| 679 |
+
yyreportSyntaxError(new Context(]b4_lac_if([[this, ]])[yystack, yytoken]b4_locations_if([[, yylloc]])[));
|
| 680 |
+
}
|
| 681 |
+
]b4_locations_if([
|
| 682 |
+
yyerrloc = yylloc;])[
|
| 683 |
+
if (yyerrstatus_ == 3)
|
| 684 |
+
{
|
| 685 |
+
/* If just tried and failed to reuse lookahead token after an
|
| 686 |
+
* error, discard it. */
|
| 687 |
+
|
| 688 |
+
/* Return failure if at end of input. */
|
| 689 |
+
if (yytoken == ]b4_symbol(eof, [kind])[)]b4_push_if([[
|
| 690 |
+
{
|
| 691 |
+
label = YYABORT;
|
| 692 |
+
break;
|
| 693 |
+
}]], [[
|
| 694 |
+
return false;]])[
|
| 695 |
+
else
|
| 696 |
+
yytoken = ]b4_symbol(empty, kind)[;
|
| 697 |
+
}
|
| 698 |
+
|
| 699 |
+
/* Else will try to reuse lookahead token after shifting the error
|
| 700 |
+
* token. */
|
| 701 |
+
label = YYERRLAB1;
|
| 702 |
+
break;
|
| 703 |
+
|
| 704 |
+
/*-------------------------------------------------.
|
| 705 |
+
| errorlab -- error raised explicitly by YYERROR. |
|
| 706 |
+
`-------------------------------------------------*/
|
| 707 |
+
case YYERROR:]b4_locations_if([
|
| 708 |
+
yyerrloc = yystack.locationAt (yylen - 1);])[
|
| 709 |
+
/* Do not reclaim the symbols of the rule which action triggered
|
| 710 |
+
this YYERROR. */
|
| 711 |
+
yystack.pop (yylen);
|
| 712 |
+
yylen = 0;
|
| 713 |
+
yystate = yystack.stateAt (0);
|
| 714 |
+
label = YYERRLAB1;
|
| 715 |
+
break;
|
| 716 |
+
|
| 717 |
+
/*-------------------------------------------------------------.
|
| 718 |
+
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
| 719 |
+
`-------------------------------------------------------------*/
|
| 720 |
+
case YYERRLAB1:
|
| 721 |
+
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
|
| 722 |
+
|
| 723 |
+
// Pop stack until we find a state that shifts the error token.
|
| 724 |
+
for (;;)
|
| 725 |
+
{
|
| 726 |
+
yyn = yypact_[yystate];
|
| 727 |
+
if (!yyPactValueIsDefault(yyn))
|
| 728 |
+
{
|
| 729 |
+
yyn += ]b4_symbol(error, kind)[;
|
| 730 |
+
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == ]b4_symbol(error, kind)[)
|
| 731 |
+
{
|
| 732 |
+
yyn = yytable_[yyn];
|
| 733 |
+
if (0 < yyn)
|
| 734 |
+
break;
|
| 735 |
+
}
|
| 736 |
+
}
|
| 737 |
+
|
| 738 |
+
/* Pop the current state because it cannot handle the error token. */
|
| 739 |
+
if (yystack.height == 1)]b4_push_if([[
|
| 740 |
+
{
|
| 741 |
+
label = YYABORT;
|
| 742 |
+
break;
|
| 743 |
+
}]],[[
|
| 744 |
+
return false;]])[
|
| 745 |
+
|
| 746 |
+
]b4_locations_if([ yyerrloc = yystack.locationAt (0);])[
|
| 747 |
+
yystack.pop ();
|
| 748 |
+
yystate = yystack.stateAt (0);]b4_parse_trace_if([[
|
| 749 |
+
if (0 < yydebug)
|
| 750 |
+
yystack.print (yyDebugStream);]])[
|
| 751 |
+
}]b4_push_if([[
|
| 752 |
+
if (label == YYABORT)
|
| 753 |
+
/* Leave the switch. */
|
| 754 |
+
break;
|
| 755 |
+
]])[
|
| 756 |
+
]b4_locations_if([
|
| 757 |
+
/* Muck with the stack to setup for yylloc. */
|
| 758 |
+
yystack.push (0, yy_semantic_null, yylloc);
|
| 759 |
+
yystack.push (0, yy_semantic_null, yyerrloc);
|
| 760 |
+
yyloc = yylloc_from_stack (yystack, 2);
|
| 761 |
+
yystack.pop (2);])[
|
| 762 |
+
|
| 763 |
+
/* Shift the error token. */]b4_lac_if([[
|
| 764 |
+
yylacDiscard("error recovery");]])[]b4_parse_trace_if([[
|
| 765 |
+
yy_symbol_print ("Shifting", to!SymbolKind (yystos_[yyn]), yylval]b4_locations_if([, yyloc])[);]])[
|
| 766 |
+
yystate = yyn;
|
| 767 |
+
yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
|
| 768 |
+
label = YYNEWSTATE;
|
| 769 |
+
break;
|
| 770 |
+
|
| 771 |
+
/* Accept. */
|
| 772 |
+
case YYACCEPT:]b4_push_if([[
|
| 773 |
+
this.pushParseInitialized = false;]b4_parse_trace_if([[
|
| 774 |
+
if (0 < yydebug)
|
| 775 |
+
yystack.print (yyDebugStream);]])[
|
| 776 |
+
return YYACCEPT;]], [[
|
| 777 |
+
yyresult = true;
|
| 778 |
+
label = YYRETURN;
|
| 779 |
+
break;]])[
|
| 780 |
+
|
| 781 |
+
/* Abort. */
|
| 782 |
+
case YYABORT:]b4_push_if([[
|
| 783 |
+
this.pushParseInitialized = false;]b4_parse_trace_if([[
|
| 784 |
+
if (0 < yydebug)
|
| 785 |
+
yystack.print (yyDebugStream);]])[
|
| 786 |
+
return YYABORT;]], [[
|
| 787 |
+
yyresult = false;
|
| 788 |
+
label = YYRETURN;
|
| 789 |
+
break;]])[
|
| 790 |
+
]b4_push_if([[]], [[ ][case YYRETURN:]b4_parse_trace_if([[
|
| 791 |
+
if (0 < yydebug)
|
| 792 |
+
yystack.print (yyDebugStream);]])[
|
| 793 |
+
return yyresult;]])[
|
| 794 |
+
}
|
| 795 |
+
assert(0);
|
| 796 |
+
}
|
| 797 |
+
|
| 798 |
+
]b4_push_if([[
|
| 799 |
+
bool pushParseInitialized = false;
|
| 800 |
+
|
| 801 |
+
/**
|
| 802 |
+
* (Re-)Initialize the state of the push parser.
|
| 803 |
+
*/
|
| 804 |
+
public void pushParseInitialize()
|
| 805 |
+
{
|
| 806 |
+
|
| 807 |
+
/* Lookahead and lookahead in internal form. */
|
| 808 |
+
this.yytoken = ]b4_symbol(empty, kind)[;
|
| 809 |
+
|
| 810 |
+
/* State. */
|
| 811 |
+
this.yyn = 0;
|
| 812 |
+
this.yylen = 0;
|
| 813 |
+
this.yystate = 0;
|
| 814 |
+
destroy(this.yystack);
|
| 815 |
+
this.label = YYNEWSTATE;
|
| 816 |
+
]b4_lac_if([[
|
| 817 |
+
destroy(this.yylacStack);
|
| 818 |
+
this.yylacEstablished = false;]])[
|
| 819 |
+
|
| 820 |
+
/* Error handling. */
|
| 821 |
+
this.yynerrs_ = 0;
|
| 822 |
+
]b4_locations_if([
|
| 823 |
+
/* The location where the error started. */
|
| 824 |
+
this.yyerrloc = Location(Position(), Position());
|
| 825 |
+
this.yylloc = Location(Position(), Position());])[
|
| 826 |
+
|
| 827 |
+
/* Semantic value of the lookahead. */
|
| 828 |
+
//destroy(this.yylval);
|
| 829 |
+
|
| 830 |
+
/* Initialize the stack. */
|
| 831 |
+
yystack.push(this.yystate, this.yylval]b4_locations_if([, this.yylloc])[);
|
| 832 |
+
|
| 833 |
+
this.pushParseInitialized = true;
|
| 834 |
+
}]])[]b4_both_if([[
|
| 835 |
+
/**
|
| 836 |
+
* Parse input from the scanner that was specified at object construction
|
| 837 |
+
* time. Return whether the end of the input was reached successfully.
|
| 838 |
+
* This version of parse() is defined only when api.push-push=both.
|
| 839 |
+
*
|
| 840 |
+
* @@return <tt>true</tt> if the parsing succeeds. Note that this does not
|
| 841 |
+
* imply that there were no syntax errors.
|
| 842 |
+
*/
|
| 843 |
+
bool parse()
|
| 844 |
+
{
|
| 845 |
+
int status = 0;
|
| 846 |
+
do {
|
| 847 |
+
status = this.pushParse(yylex());
|
| 848 |
+
} while (status == YYPUSH_MORE);
|
| 849 |
+
return status == YYACCEPT;
|
| 850 |
+
}]])[
|
| 851 |
+
|
| 852 |
+
// Generate an error message.
|
| 853 |
+
private final void yyreportSyntaxError(Context yyctx)
|
| 854 |
+
{]b4_parse_error_bmatch(
|
| 855 |
+
[custom], [[
|
| 856 |
+
yylexer.reportSyntaxError(yyctx);]],
|
| 857 |
+
[detailed], [[
|
| 858 |
+
if (yyctx.getToken() != ]b4_symbol(empty, kind)[)
|
| 859 |
+
{
|
| 860 |
+
// FIXME: This method of building the message is not compatible
|
| 861 |
+
// with internationalization.
|
| 862 |
+
immutable int argmax = 5;
|
| 863 |
+
SymbolKind[] yyarg = new SymbolKind[argmax];
|
| 864 |
+
int yycount = yysyntaxErrorArguments(yyctx, yyarg, argmax);
|
| 865 |
+
string res, yyformat;
|
| 866 |
+
switch (yycount)
|
| 867 |
+
{
|
| 868 |
+
case 1:
|
| 869 |
+
yyformat = YY_("syntax error, unexpected %s");
|
| 870 |
+
res = format(yyformat, yyarg[0]);
|
| 871 |
+
break;
|
| 872 |
+
case 2:
|
| 873 |
+
yyformat = YY_("syntax error, unexpected %s, expecting %s");
|
| 874 |
+
res = format(yyformat, yyarg[0], yyarg[1]);
|
| 875 |
+
break;
|
| 876 |
+
case 3:
|
| 877 |
+
yyformat = YY_("syntax error, unexpected %s, expecting %s or %s");
|
| 878 |
+
res = format(yyformat, yyarg[0], yyarg[1], yyarg[2]);
|
| 879 |
+
break;
|
| 880 |
+
case 4:
|
| 881 |
+
yyformat = YY_("syntax error, unexpected %s, expecting %s or %s or %s");
|
| 882 |
+
res = format(yyformat, yyarg[0], yyarg[1], yyarg[2], yyarg[3]);
|
| 883 |
+
break;
|
| 884 |
+
case 5:
|
| 885 |
+
yyformat = YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
|
| 886 |
+
res = format(yyformat, yyarg[0], yyarg[1], yyarg[2], yyarg[3], yyarg[4]);
|
| 887 |
+
break;
|
| 888 |
+
default:
|
| 889 |
+
res = YY_("syntax error");
|
| 890 |
+
break;
|
| 891 |
+
}
|
| 892 |
+
yyerror(]b4_locations_if([yyctx.getLocation(), ])[res);
|
| 893 |
+
}]],
|
| 894 |
+
[[simple]], [[
|
| 895 |
+
yyerror(]b4_locations_if([yyctx.getLocation(), ])[YY_("syntax error"));]])[
|
| 896 |
+
}
|
| 897 |
+
|
| 898 |
+
]b4_parse_error_bmatch(
|
| 899 |
+
[detailed], [[
|
| 900 |
+
private int yysyntaxErrorArguments(Context yyctx, SymbolKind[] yyarg, int yyargn) {
|
| 901 |
+
/* There are many possibilities here to consider:
|
| 902 |
+
- If this state is a consistent state with a default action,
|
| 903 |
+
then the only way this function was invoked is if the
|
| 904 |
+
default action is an error action. In that case, don't
|
| 905 |
+
check for expected tokens because there are none.
|
| 906 |
+
- The only way there can be no lookahead present (in tok) is
|
| 907 |
+
if this state is a consistent state with a default action.
|
| 908 |
+
Thus, detecting the absence of a lookahead is sufficient to
|
| 909 |
+
determine that there is no unexpected or expected token to
|
| 910 |
+
report. In that case, just report a simple "syntax error".
|
| 911 |
+
- Don't assume there isn't a lookahead just because this
|
| 912 |
+
state is a consistent state with a default action. There
|
| 913 |
+
might have been a previous inconsistent state, consistent
|
| 914 |
+
state with a non-default action, or user semantic action
|
| 915 |
+
that manipulated yychar. (However, yychar is currently out
|
| 916 |
+
of scope during semantic actions.)
|
| 917 |
+
- Of course, the expected token list depends on states to
|
| 918 |
+
have correct lookahead information, and it depends on the
|
| 919 |
+
parser not to perform extra reductions after fetching a
|
| 920 |
+
lookahead from the scanner and before detecting a syntax
|
| 921 |
+
error. Thus, state merging (from LALR or IELR) and default
|
| 922 |
+
reductions corrupt the expected token list. However, the
|
| 923 |
+
list is correct for canonical LR with one exception: it
|
| 924 |
+
will still contain any token that will not be accepted due
|
| 925 |
+
to an error action in a later state.
|
| 926 |
+
*/
|
| 927 |
+
int yycount = 0;
|
| 928 |
+
if (yyctx.getToken() != ]b4_symbol(empty, kind)[)
|
| 929 |
+
{
|
| 930 |
+
if (yyarg !is null)
|
| 931 |
+
yyarg[yycount] = yyctx.getToken();
|
| 932 |
+
yycount += 1;
|
| 933 |
+
yycount += yyctx.getExpectedTokens(yyarg, 1, yyargn);
|
| 934 |
+
}
|
| 935 |
+
return yycount;
|
| 936 |
+
}
|
| 937 |
+
]])[
|
| 938 |
+
|
| 939 |
+
|
| 940 |
+
/**
|
| 941 |
+
* Information needed to get the list of expected tokens and to forge
|
| 942 |
+
* a syntax error diagnostic.
|
| 943 |
+
*/
|
| 944 |
+
public static final class Context
|
| 945 |
+
{]b4_lac_if([[
|
| 946 |
+
private ]b4_parser_class[ yyparser;]])[
|
| 947 |
+
private const(YYStack) yystack;
|
| 948 |
+
private SymbolKind yytoken;]b4_locations_if([[
|
| 949 |
+
private const(Location) yylocation;]])[
|
| 950 |
+
|
| 951 |
+
this(]b4_lac_if([[]b4_parser_class[ parser, ]])[YYStack stack, SymbolKind kind]b4_locations_if([[, Location loc]])[)
|
| 952 |
+
{]b4_lac_if([[
|
| 953 |
+
yyparser = parser;]])[
|
| 954 |
+
yystack = stack;
|
| 955 |
+
yytoken = kind;]b4_locations_if([[
|
| 956 |
+
yylocation = loc;]])[
|
| 957 |
+
}
|
| 958 |
+
|
| 959 |
+
final SymbolKind getToken() const
|
| 960 |
+
{
|
| 961 |
+
return yytoken;
|
| 962 |
+
}]b4_locations_if([[
|
| 963 |
+
|
| 964 |
+
final const(Location) getLocation() const
|
| 965 |
+
{
|
| 966 |
+
return yylocation;
|
| 967 |
+
}]])[
|
| 968 |
+
/**
|
| 969 |
+
* Put in YYARG at most YYARGN of the expected tokens given the
|
| 970 |
+
* current YYCTX, and return the number of tokens stored in YYARG. If
|
| 971 |
+
* YYARG is null, return the number of expected tokens (guaranteed to
|
| 972 |
+
* be less than YYNTOKENS).
|
| 973 |
+
*/
|
| 974 |
+
int getExpectedTokens(SymbolKind[] yyarg, int yyargn)]b4_lac_if([[]], [[ const]])[
|
| 975 |
+
{
|
| 976 |
+
return getExpectedTokens(yyarg, 0, yyargn);
|
| 977 |
+
}
|
| 978 |
+
|
| 979 |
+
int getExpectedTokens(SymbolKind[] yyarg, int yyoffset, int yyargn)]b4_lac_if([[]], [[ const]])[
|
| 980 |
+
{
|
| 981 |
+
int yycount = yyoffset;]b4_lac_if([b4_parse_trace_if([[
|
| 982 |
+
// Execute LAC once. We don't care if it is successful, we
|
| 983 |
+
// only do it for the sake of debugging output.
|
| 984 |
+
|
| 985 |
+
if (!yyparser.yylacEstablished)
|
| 986 |
+
yyparser.yylacCheck(yystack, yytoken);
|
| 987 |
+
]])[
|
| 988 |
+
for (int yyx = 0; yyx < yyntokens_; ++yyx)
|
| 989 |
+
{
|
| 990 |
+
SymbolKind yysym = SymbolKind(yyx);
|
| 991 |
+
if (yysym != ]b4_symbol(error, kind)[
|
| 992 |
+
&& yysym != ]b4_symbol(undef, kind)[
|
| 993 |
+
&& yyparser.yylacCheck(yystack, yysym))
|
| 994 |
+
{
|
| 995 |
+
if (yyarg == null)
|
| 996 |
+
yycount += 1;
|
| 997 |
+
else if (yycount == yyargn)
|
| 998 |
+
return 0;
|
| 999 |
+
else
|
| 1000 |
+
yyarg[yycount++] = yysym;
|
| 1001 |
+
}
|
| 1002 |
+
}]], [[
|
| 1003 |
+
int yyn = yypact_[this.yystack.stateAt(0)];
|
| 1004 |
+
if (!yyPactValueIsDefault(yyn))
|
| 1005 |
+
{
|
| 1006 |
+
/* Start YYX at -YYN if negative to avoid negative
|
| 1007 |
+
indexes in YYCHECK. In other words, skip the first
|
| 1008 |
+
-YYN actions for this state because they are default
|
| 1009 |
+
actions. */
|
| 1010 |
+
int yyxbegin = yyn < 0 ? -yyn : 0;
|
| 1011 |
+
/* Stay within bounds of both yycheck and yytname. */
|
| 1012 |
+
int yychecklim = yylast_ - yyn + 1;
|
| 1013 |
+
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
|
| 1014 |
+
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
|
| 1015 |
+
if (yycheck_[yyx + yyn] == yyx && yyx != ]b4_symbol(error, kind)[
|
| 1016 |
+
&& !yyTableValueIsError(yytable_[yyx + yyn]))
|
| 1017 |
+
{
|
| 1018 |
+
if (yyarg is null)
|
| 1019 |
+
++yycount;
|
| 1020 |
+
else if (yycount == yyargn)
|
| 1021 |
+
return 0;
|
| 1022 |
+
else
|
| 1023 |
+
yyarg[yycount++] = SymbolKind(yyx);
|
| 1024 |
+
}
|
| 1025 |
+
}]])[
|
| 1026 |
+
if (yyarg !is null && yycount == yyoffset && yyoffset < yyargn)
|
| 1027 |
+
yyarg[yyoffset] = ]b4_symbol(empty, kind)[;
|
| 1028 |
+
return yycount - yyoffset;
|
| 1029 |
+
}
|
| 1030 |
+
}
|
| 1031 |
+
|
| 1032 |
+
]b4_lac_if([[
|
| 1033 |
+
/** Check the lookahead yytoken.
|
| 1034 |
+
* \returns true iff the token will be eventually shifted.
|
| 1035 |
+
*/
|
| 1036 |
+
bool yylacCheck(const YYStack yystack, SymbolKind yytoken)
|
| 1037 |
+
{
|
| 1038 |
+
// Logically, the yylacStack's lifetime is confined to this function.
|
| 1039 |
+
// Clear it, to get rid of potential left-overs from previous call.
|
| 1040 |
+
destroy(yylacStack);
|
| 1041 |
+
// Reduce until we encounter a shift and thereby accept the token.
|
| 1042 |
+
]b4_parse_trace_if([[
|
| 1043 |
+
yycdebug("LAC: checking lookahead " ~ format("%s", yytoken) ~ ":");]])[
|
| 1044 |
+
int lacTop = 0;
|
| 1045 |
+
while (true)
|
| 1046 |
+
{
|
| 1047 |
+
int topState = (yylacStack.length == 0
|
| 1048 |
+
? yystack.stateAt(lacTop)
|
| 1049 |
+
: yylacStack[$ - 1]);
|
| 1050 |
+
int yyrule = yypact_[topState];
|
| 1051 |
+
if (yyPactValueIsDefault(yyrule)
|
| 1052 |
+
|| (yyrule += yytoken) < 0 || yylast_ < yyrule
|
| 1053 |
+
|| yycheck_[yyrule] != yytoken)
|
| 1054 |
+
{
|
| 1055 |
+
// Use the default action.
|
| 1056 |
+
yyrule = yydefact_[+topState];
|
| 1057 |
+
if (yyrule == 0)
|
| 1058 |
+
{]b4_parse_trace_if([[
|
| 1059 |
+
yycdebugln(" Err");]])[
|
| 1060 |
+
return false;
|
| 1061 |
+
}
|
| 1062 |
+
}
|
| 1063 |
+
else
|
| 1064 |
+
{
|
| 1065 |
+
// Use the action from yytable.
|
| 1066 |
+
yyrule = yytable_[yyrule];
|
| 1067 |
+
if (yyTableValueIsError(yyrule))
|
| 1068 |
+
{]b4_parse_trace_if([[
|
| 1069 |
+
yycdebugln(" Err");]])[
|
| 1070 |
+
return false;
|
| 1071 |
+
}
|
| 1072 |
+
if (0 < yyrule)
|
| 1073 |
+
{]b4_parse_trace_if([[
|
| 1074 |
+
yycdebugln(" S" ~ to!string(yyrule));]])[
|
| 1075 |
+
return true;
|
| 1076 |
+
}
|
| 1077 |
+
yyrule = -yyrule;
|
| 1078 |
+
}
|
| 1079 |
+
// By now we know we have to simulate a reduce.
|
| 1080 |
+
]b4_parse_trace_if([[
|
| 1081 |
+
yycdebug(" R" ~ to!string(yyrule - 1));]])[
|
| 1082 |
+
// Pop the corresponding number of values from the stack.
|
| 1083 |
+
{
|
| 1084 |
+
int yylen = yyr2_[yyrule];
|
| 1085 |
+
// First pop from the LAC stack as many tokens as possible.
|
| 1086 |
+
int lacSize = cast (int) yylacStack.length;
|
| 1087 |
+
if (yylen < lacSize)
|
| 1088 |
+
{
|
| 1089 |
+
yylacStack.length -= yylen;
|
| 1090 |
+
yylen = 0;
|
| 1091 |
+
}
|
| 1092 |
+
else if (lacSize != 0)
|
| 1093 |
+
{
|
| 1094 |
+
destroy(yylacStack);
|
| 1095 |
+
yylen -= lacSize;
|
| 1096 |
+
}
|
| 1097 |
+
// Only afterwards look at the main stack.
|
| 1098 |
+
// We simulate popping elements by incrementing lacTop.
|
| 1099 |
+
lacTop += yylen;
|
| 1100 |
+
}
|
| 1101 |
+
// Keep topState in sync with the updated stack.
|
| 1102 |
+
topState = (yylacStack.length == 0
|
| 1103 |
+
? yystack.stateAt(lacTop)
|
| 1104 |
+
: yylacStack[$ - 1]);
|
| 1105 |
+
// Push the resulting state of the reduction.
|
| 1106 |
+
int state = yyLRGotoState(topState, yyr1_[yyrule]);]b4_parse_trace_if([[
|
| 1107 |
+
yycdebug(" G" ~ to!string(state));]])[
|
| 1108 |
+
yylacStack.length++;
|
| 1109 |
+
yylacStack[$ - 1] = state;
|
| 1110 |
+
}
|
| 1111 |
+
}
|
| 1112 |
+
|
| 1113 |
+
/** Establish the initial context if no initial context currently exists.
|
| 1114 |
+
* \returns true iff the token will be eventually shifted.
|
| 1115 |
+
*/
|
| 1116 |
+
bool yylacEstablish(YYStack yystack, SymbolKind yytoken)
|
| 1117 |
+
{
|
| 1118 |
+
/* Establish the initial context for the current lookahead if no initial
|
| 1119 |
+
context is currently established.
|
| 1120 |
+
|
| 1121 |
+
We define a context as a snapshot of the parser stacks. We define
|
| 1122 |
+
the initial context for a lookahead as the context in which the
|
| 1123 |
+
parser initially examines that lookahead in order to select a
|
| 1124 |
+
syntactic action. Thus, if the lookahead eventually proves
|
| 1125 |
+
syntactically unacceptable (possibly in a later context reached via a
|
| 1126 |
+
series of reductions), the initial context can be used to determine
|
| 1127 |
+
the exact set of tokens that would be syntactically acceptable in the
|
| 1128 |
+
lookahead's place. Moreover, it is the context after which any
|
| 1129 |
+
further semantic actions would be erroneous because they would be
|
| 1130 |
+
determined by a syntactically unacceptable token.
|
| 1131 |
+
|
| 1132 |
+
yylacEstablish should be invoked when a reduction is about to be
|
| 1133 |
+
performed in an inconsistent state (which, for the purposes of LAC,
|
| 1134 |
+
includes consistent states that don't know they're consistent because
|
| 1135 |
+
their default reductions have been disabled).
|
| 1136 |
+
|
| 1137 |
+
For parse.lac=full, the implementation of yylacEstablish is as
|
| 1138 |
+
follows. If no initial context is currently established for the
|
| 1139 |
+
current lookahead, then check if that lookahead can eventually be
|
| 1140 |
+
shifted if syntactic actions continue from the current context. */
|
| 1141 |
+
if (yylacEstablished)
|
| 1142 |
+
return true;
|
| 1143 |
+
else
|
| 1144 |
+
{]b4_parse_trace_if([[
|
| 1145 |
+
yycdebugln("LAC: initial context established for " ~ format("%s", yytoken));]])[
|
| 1146 |
+
yylacEstablished = true;
|
| 1147 |
+
return yylacCheck(yystack, yytoken);
|
| 1148 |
+
}
|
| 1149 |
+
}
|
| 1150 |
+
|
| 1151 |
+
/** Discard any previous initial lookahead context because of event.
|
| 1152 |
+
* \param event the event which caused the lookahead to be discarded.
|
| 1153 |
+
* Only used for debbuging output. */
|
| 1154 |
+
void yylacDiscard(string event)
|
| 1155 |
+
{
|
| 1156 |
+
/* Discard any previous initial lookahead context because of Event,
|
| 1157 |
+
which may be a lookahead change or an invalidation of the currently
|
| 1158 |
+
established initial context for the current lookahead.
|
| 1159 |
+
|
| 1160 |
+
The most common example of a lookahead change is a shift. An example
|
| 1161 |
+
of both cases is syntax error recovery. That is, a syntax error
|
| 1162 |
+
occurs when the lookahead is syntactically erroneous for the
|
| 1163 |
+
currently established initial context, so error recovery manipulates
|
| 1164 |
+
the parser stacks to try to find a new initial context in which the
|
| 1165 |
+
current lookahead is syntactically acceptable. If it fails to find
|
| 1166 |
+
such a context, it discards the lookahead. */
|
| 1167 |
+
if (yylacEstablished)
|
| 1168 |
+
{]b4_parse_trace_if([[
|
| 1169 |
+
yycdebugln("LAC: initial context discarded due to " ~ event);]])[
|
| 1170 |
+
yylacEstablished = false;
|
| 1171 |
+
}
|
| 1172 |
+
}
|
| 1173 |
+
|
| 1174 |
+
/** The stack for LAC.
|
| 1175 |
+
* Logically, the yylacStack's lifetime is confined to the function
|
| 1176 |
+
* yylacCheck. We just store it as a member of this class to hold
|
| 1177 |
+
* on to the memory and to avoid frequent reallocations.
|
| 1178 |
+
*/
|
| 1179 |
+
int[] yylacStack;
|
| 1180 |
+
/** Whether an initial LAC context was established. */
|
| 1181 |
+
bool yylacEstablished;
|
| 1182 |
+
]])[
|
| 1183 |
+
|
| 1184 |
+
/**
|
| 1185 |
+
* Whether the given <code>yypact_</code> value indicates a defaulted state.
|
| 1186 |
+
* @@param yyvalue the value to check
|
| 1187 |
+
*/
|
| 1188 |
+
private static bool yyPactValueIsDefault(int yyvalue)
|
| 1189 |
+
{
|
| 1190 |
+
return yyvalue == yypact_ninf_;
|
| 1191 |
+
}
|
| 1192 |
+
|
| 1193 |
+
/**
|
| 1194 |
+
* Whether the given <code>yytable_</code> value indicates a syntax error.
|
| 1195 |
+
* @@param yyvalue the value to check
|
| 1196 |
+
*/
|
| 1197 |
+
private static bool yyTableValueIsError(int yyvalue)
|
| 1198 |
+
{
|
| 1199 |
+
return yyvalue == yytable_ninf_;
|
| 1200 |
+
}
|
| 1201 |
+
|
| 1202 |
+
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
| 1203 |
+
STATE-NUM. */
|
| 1204 |
+
private static immutable ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[;
|
| 1205 |
+
|
| 1206 |
+
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
| 1207 |
+
positive, shift that token. If negative, reduce the rule which
|
| 1208 |
+
number is the opposite. If YYTABLE_NINF_, syntax error. */
|
| 1209 |
+
private static immutable ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;
|
| 1210 |
+
|
| 1211 |
+
]b4_parser_tables_define[
|
| 1212 |
+
|
| 1213 |
+
]b4_parse_trace_if([[
|
| 1214 |
+
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
|
| 1215 |
+
private static immutable ]b4_int_type_for([b4_rline])[[] yyrline_ =
|
| 1216 |
+
@{
|
| 1217 |
+
]b4_rline[
|
| 1218 |
+
@};
|
| 1219 |
+
|
| 1220 |
+
// Report on the debug stream that the rule yyrule is going to be reduced.
|
| 1221 |
+
private final void yy_reduce_print (int yyrule, ref YYStack yystack)
|
| 1222 |
+
{
|
| 1223 |
+
if (yydebug == 0)
|
| 1224 |
+
return;
|
| 1225 |
+
|
| 1226 |
+
int yylno = yyrline_[yyrule];
|
| 1227 |
+
int yynrhs = yyr2_[yyrule];
|
| 1228 |
+
/* Print the symbols being reduced, and their result. */
|
| 1229 |
+
yycdebugln (format("Reducing stack by rule %d (line %d):",
|
| 1230 |
+
yyrule - 1, yylno));
|
| 1231 |
+
|
| 1232 |
+
/* The symbols being reduced. */
|
| 1233 |
+
for (int yyi = 0; yyi < yynrhs; yyi++)
|
| 1234 |
+
yy_symbol_print (format(" $%d =", yyi + 1),
|
| 1235 |
+
to!SymbolKind (yystos_[yystack.stateAt(yynrhs - (yyi + 1))]),
|
| 1236 |
+
]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
|
| 1237 |
+
b4_rhs_location(yynrhs, yyi + 1)])[);
|
| 1238 |
+
}
|
| 1239 |
+
]])[
|
| 1240 |
+
|
| 1241 |
+
private static auto yytranslate_ (int t)
|
| 1242 |
+
{
|
| 1243 |
+
]b4_api_token_raw_if(
|
| 1244 |
+
[[ return SymbolKind(t);]],
|
| 1245 |
+
[[ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
| 1246 |
+
immutable ]b4_int_type_for([b4_translate])[[] translate_table =
|
| 1247 |
+
@{
|
| 1248 |
+
]b4_translate[
|
| 1249 |
+
@};
|
| 1250 |
+
|
| 1251 |
+
// Last valid token kind.
|
| 1252 |
+
immutable int code_max = ]b4_code_max[;
|
| 1253 |
+
|
| 1254 |
+
if (t <= 0)
|
| 1255 |
+
return ]b4_symbol(eof, kind)[;
|
| 1256 |
+
else if (t <= code_max)
|
| 1257 |
+
return SymbolKind(translate_table[t]);
|
| 1258 |
+
else
|
| 1259 |
+
return ]b4_symbol(undef, kind)[;]])[
|
| 1260 |
+
}
|
| 1261 |
+
|
| 1262 |
+
private static immutable int yylast_ = ]b4_last[;
|
| 1263 |
+
private static immutable int yynnts_ = ]b4_nterms_number[;
|
| 1264 |
+
private static immutable int yyfinal_ = ]b4_final_state_number[;
|
| 1265 |
+
private static immutable int yyntokens_ = ]b4_tokens_number[;
|
| 1266 |
+
|
| 1267 |
+
private final struct YYStackElement {
|
| 1268 |
+
int state;
|
| 1269 |
+
Value value;]b4_locations_if(
|
| 1270 |
+
b4_location_type[[] location;])[
|
| 1271 |
+
}
|
| 1272 |
+
|
| 1273 |
+
private final struct YYStack {
|
| 1274 |
+
private YYStackElement[] stack = [];
|
| 1275 |
+
|
| 1276 |
+
public final ulong height()
|
| 1277 |
+
{
|
| 1278 |
+
return stack.length;
|
| 1279 |
+
}
|
| 1280 |
+
|
| 1281 |
+
public final void push (int state, Value value]dnl
|
| 1282 |
+
b4_locations_if([, ref Location loc])[)
|
| 1283 |
+
{
|
| 1284 |
+
stack ~= YYStackElement(state, value]b4_locations_if([, loc])[);
|
| 1285 |
+
}
|
| 1286 |
+
|
| 1287 |
+
public final void pop ()
|
| 1288 |
+
{
|
| 1289 |
+
pop (1);
|
| 1290 |
+
}
|
| 1291 |
+
|
| 1292 |
+
public final void pop (int num)
|
| 1293 |
+
{
|
| 1294 |
+
stack.length -= num;
|
| 1295 |
+
}
|
| 1296 |
+
|
| 1297 |
+
public final int stateAt (int i) const
|
| 1298 |
+
{
|
| 1299 |
+
return stack[$-i-1].state;
|
| 1300 |
+
}
|
| 1301 |
+
|
| 1302 |
+
]b4_locations_if([[
|
| 1303 |
+
public final ref Location locationAt (int i)
|
| 1304 |
+
{
|
| 1305 |
+
return stack[$-i-1].location;
|
| 1306 |
+
}]])[
|
| 1307 |
+
|
| 1308 |
+
public final ref Value valueAt (int i)
|
| 1309 |
+
{
|
| 1310 |
+
return stack[$-i-1].value;
|
| 1311 |
+
}
|
| 1312 |
+
]b4_parse_trace_if([[
|
| 1313 |
+
// Print the state stack on the debug stream.
|
| 1314 |
+
public final void print (File stream)
|
| 1315 |
+
{
|
| 1316 |
+
stream.write ("Stack now");
|
| 1317 |
+
for (int i = 0; i < stack.length; i++)
|
| 1318 |
+
stream.write (" ", stack[i].state);
|
| 1319 |
+
stream.writeln ();
|
| 1320 |
+
}]])[
|
| 1321 |
+
}
|
| 1322 |
+
]b4_percent_code_get[
|
| 1323 |
+
}
|
| 1324 |
+
]b4_percent_code_get([[epilogue]])[]dnl
|
| 1325 |
+
b4_epilogue[]dnl
|
| 1326 |
+
b4_output_end
|
platform/db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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Java skeleton for Bison -*- java -*-
|
| 2 |
+
|
| 3 |
+
# Copyright (C) 2007-2015, 2018-2021 Free Software Foundation, Inc.
|
| 4 |
+
|
| 5 |
+
# This program is free software: you can redistribute it and/or modify
|
| 6 |
+
# it under the terms of the GNU General Public License as published by
|
| 7 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 8 |
+
# (at your option) any later version.
|
| 9 |
+
#
|
| 10 |
+
# This program is distributed in the hope that it will be useful,
|
| 11 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 13 |
+
# GNU General Public License for more details.
|
| 14 |
+
#
|
| 15 |
+
# You should have received a copy of the GNU General Public License
|
| 16 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 17 |
+
|
| 18 |
+
m4_include(b4_skeletonsdir/[java.m4])
|
| 19 |
+
|
| 20 |
+
b4_header_if([b4_complain([%header/%defines does not make sense in Java])])
|
| 21 |
+
|
| 22 |
+
m4_define([b4_symbol_no_destructor_assert],
|
| 23 |
+
[b4_symbol_if([$1], [has_destructor],
|
| 24 |
+
[b4_complain_at(m4_unquote(b4_symbol([$1], [destructor_loc])),
|
| 25 |
+
[%destructor does not make sense in Java])])])
|
| 26 |
+
b4_symbol_foreach([b4_symbol_no_destructor_assert])
|
| 27 |
+
|
| 28 |
+
## --------------- ##
|
| 29 |
+
## api.push-pull. ##
|
| 30 |
+
## --------------- ##
|
| 31 |
+
|
| 32 |
+
b4_percent_define_default([[api.push-pull]], [[pull]])
|
| 33 |
+
b4_percent_define_check_values([[[[api.push-pull]],
|
| 34 |
+
[[pull]], [[push]], [[both]]]])
|
| 35 |
+
|
| 36 |
+
# Define m4 conditional macros that encode the value
|
| 37 |
+
# of the api.push-pull flag.
|
| 38 |
+
b4_define_flag_if([pull]) m4_define([b4_pull_flag], [[1]])
|
| 39 |
+
b4_define_flag_if([push]) m4_define([b4_push_flag], [[1]])
|
| 40 |
+
m4_case(b4_percent_define_get([[api.push-pull]]),
|
| 41 |
+
[pull], [m4_define([b4_push_flag], [[0]])],
|
| 42 |
+
[push], [m4_define([b4_pull_flag], [[0]])])
|
| 43 |
+
|
| 44 |
+
# Define a macro to be true when api.push-pull has the value "both".
|
| 45 |
+
m4_define([b4_both_if],[b4_push_if([b4_pull_if([$1],[$2])],[$2])])
|
| 46 |
+
|
| 47 |
+
# Handle BISON_USE_PUSH_FOR_PULL for the test suite. So that push parsing
|
| 48 |
+
# tests function as written, do not let BISON_USE_PUSH_FOR_PULL modify the
|
| 49 |
+
# behavior of Bison at all when push parsing is already requested.
|
| 50 |
+
b4_define_flag_if([use_push_for_pull])
|
| 51 |
+
b4_use_push_for_pull_if([
|
| 52 |
+
b4_push_if([m4_define([b4_use_push_for_pull_flag], [[0]])],
|
| 53 |
+
[m4_define([b4_push_flag], [[1]])])])
|
| 54 |
+
|
| 55 |
+
# Define a macro to encapsulate the parse state variables. This
|
| 56 |
+
# allows them to be defined either in parse() when doing pull parsing,
|
| 57 |
+
# or as class instance variable when doing push parsing.
|
| 58 |
+
m4_define([b4_define_state],
|
| 59 |
+
[[
|
| 60 |
+
/* Lookahead token kind. */
|
| 61 |
+
int yychar = YYEMPTY_;
|
| 62 |
+
/* Lookahead symbol kind. */
|
| 63 |
+
SymbolKind yytoken = null;
|
| 64 |
+
|
| 65 |
+
/* State. */
|
| 66 |
+
int yyn = 0;
|
| 67 |
+
int yylen = 0;
|
| 68 |
+
int yystate = 0;
|
| 69 |
+
YYStack yystack = new YYStack ();
|
| 70 |
+
int label = YYNEWSTATE;
|
| 71 |
+
|
| 72 |
+
]b4_locations_if([[
|
| 73 |
+
/* The location where the error started. */
|
| 74 |
+
]b4_location_type[ yyerrloc = null;
|
| 75 |
+
|
| 76 |
+
/* Location. */
|
| 77 |
+
]b4_location_type[ yylloc = new ]b4_location_type[ (null, null);]])[
|
| 78 |
+
|
| 79 |
+
/* Semantic value of the lookahead. */
|
| 80 |
+
]b4_yystype[ yylval = null;
|
| 81 |
+
]])
|
| 82 |
+
|
| 83 |
+
# parse.lac
|
| 84 |
+
b4_percent_define_default([[parse.lac]], [[none]])
|
| 85 |
+
b4_percent_define_check_values([[[[parse.lac]], [[full]], [[none]]]])
|
| 86 |
+
b4_define_flag_if([lac])
|
| 87 |
+
m4_define([b4_lac_flag],
|
| 88 |
+
[m4_if(b4_percent_define_get([[parse.lac]]),
|
| 89 |
+
[none], [[0]], [[1]])])
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
## ------------- ##
|
| 93 |
+
## Parser File. ##
|
| 94 |
+
## ------------- ##
|
| 95 |
+
|
| 96 |
+
b4_output_begin([b4_parser_file_name])[
|
| 97 |
+
]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
|
| 98 |
+
[2007-2015, 2018-2021])[
|
| 99 |
+
]b4_disclaimer[
|
| 100 |
+
]b4_percent_define_ifdef([api.package], [package b4_percent_define_get([api.package]);[
|
| 101 |
+
]])[
|
| 102 |
+
]b4_user_pre_prologue[
|
| 103 |
+
]b4_user_post_prologue[
|
| 104 |
+
import java.text.MessageFormat;
|
| 105 |
+
import java.util.ArrayList;
|
| 106 |
+
]b4_percent_code_get([[imports]])[
|
| 107 |
+
/**
|
| 108 |
+
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
|
| 109 |
+
*
|
| 110 |
+
* @@author LALR (1) parser skeleton written by Paolo Bonzini.
|
| 111 |
+
*/
|
| 112 |
+
]b4_parser_class_declaration[
|
| 113 |
+
{
|
| 114 |
+
]b4_identification[
|
| 115 |
+
][
|
| 116 |
+
]b4_parse_error_bmatch(
|
| 117 |
+
[detailed\|verbose], [[
|
| 118 |
+
/**
|
| 119 |
+
* True if verbose error messages are enabled.
|
| 120 |
+
*/
|
| 121 |
+
private boolean yyErrorVerbose = true;
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* Whether verbose error messages are enabled.
|
| 125 |
+
*/
|
| 126 |
+
public final boolean getErrorVerbose() { return yyErrorVerbose; }
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
* Set the verbosity of error messages.
|
| 130 |
+
* @@param verbose True to request verbose error messages.
|
| 131 |
+
*/
|
| 132 |
+
public final void setErrorVerbose(boolean verbose)
|
| 133 |
+
{ yyErrorVerbose = verbose; }
|
| 134 |
+
]])[
|
| 135 |
+
|
| 136 |
+
]b4_locations_if([[
|
| 137 |
+
/**
|
| 138 |
+
* A class defining a pair of positions. Positions, defined by the
|
| 139 |
+
* <code>]b4_position_type[</code> class, denote a point in the input.
|
| 140 |
+
* Locations represent a part of the input through the beginning
|
| 141 |
+
* and ending positions.
|
| 142 |
+
*/
|
| 143 |
+
public static class ]b4_location_type[ {
|
| 144 |
+
/**
|
| 145 |
+
* The first, inclusive, position in the range.
|
| 146 |
+
*/
|
| 147 |
+
public ]b4_position_type[ begin;
|
| 148 |
+
|
| 149 |
+
/**
|
| 150 |
+
* The first position beyond the range.
|
| 151 |
+
*/
|
| 152 |
+
public ]b4_position_type[ end;
|
| 153 |
+
|
| 154 |
+
/**
|
| 155 |
+
* Create a <code>]b4_location_type[</code> denoting an empty range located at
|
| 156 |
+
* a given point.
|
| 157 |
+
* @@param loc The position at which the range is anchored.
|
| 158 |
+
*/
|
| 159 |
+
public ]b4_location_type[ (]b4_position_type[ loc) {
|
| 160 |
+
this.begin = this.end = loc;
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
/**
|
| 164 |
+
* Create a <code>]b4_location_type[</code> from the endpoints of the range.
|
| 165 |
+
* @@param begin The first position included in the range.
|
| 166 |
+
* @@param end The first position beyond the range.
|
| 167 |
+
*/
|
| 168 |
+
public ]b4_location_type[ (]b4_position_type[ begin, ]b4_position_type[ end) {
|
| 169 |
+
this.begin = begin;
|
| 170 |
+
this.end = end;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
/**
|
| 174 |
+
* Print a representation of the location. For this to be correct,
|
| 175 |
+
* <code>]b4_position_type[</code> should override the <code>equals</code>
|
| 176 |
+
* method.
|
| 177 |
+
*/
|
| 178 |
+
public String toString() {
|
| 179 |
+
if (begin.equals (end))
|
| 180 |
+
return begin.toString();
|
| 181 |
+
else
|
| 182 |
+
return begin.toString() + "-" + end.toString();
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
private ]b4_location_type[ yylloc(YYStack rhs, int n)
|
| 187 |
+
{
|
| 188 |
+
if (0 < n)
|
| 189 |
+
return new ]b4_location_type[(rhs.locationAt(n-1).begin, rhs.locationAt(0).end);
|
| 190 |
+
else
|
| 191 |
+
return new ]b4_location_type[(rhs.locationAt(0).end);
|
| 192 |
+
}]])[
|
| 193 |
+
|
| 194 |
+
]b4_declare_symbol_enum[
|
| 195 |
+
|
| 196 |
+
/**
|
| 197 |
+
* Communication interface between the scanner and the Bison-generated
|
| 198 |
+
* parser <tt>]b4_parser_class[</tt>.
|
| 199 |
+
*/
|
| 200 |
+
public interface Lexer {
|
| 201 |
+
]b4_token_enums[
|
| 202 |
+
/** Deprecated, use ]b4_symbol(eof, id)[ instead. */
|
| 203 |
+
public static final int EOF = ]b4_symbol(eof, id)[;
|
| 204 |
+
]b4_pull_if([b4_locations_if([[
|
| 205 |
+
/**
|
| 206 |
+
* Method to retrieve the beginning position of the last scanned token.
|
| 207 |
+
* @@return the position at which the last scanned token starts.
|
| 208 |
+
*/
|
| 209 |
+
]b4_position_type[ getStartPos();
|
| 210 |
+
|
| 211 |
+
/**
|
| 212 |
+
* Method to retrieve the ending position of the last scanned token.
|
| 213 |
+
* @@return the first position beyond the last scanned token.
|
| 214 |
+
*/
|
| 215 |
+
]b4_position_type[ getEndPos();]])[
|
| 216 |
+
|
| 217 |
+
/**
|
| 218 |
+
* Method to retrieve the semantic value of the last scanned token.
|
| 219 |
+
* @@return the semantic value of the last scanned token.
|
| 220 |
+
*/
|
| 221 |
+
]b4_yystype[ getLVal();
|
| 222 |
+
|
| 223 |
+
/**
|
| 224 |
+
* Entry point for the scanner. Returns the token identifier corresponding
|
| 225 |
+
* to the next token and prepares to return the semantic value
|
| 226 |
+
* ]b4_locations_if([and beginning/ending positions ])[of the token.
|
| 227 |
+
* @@return the token identifier corresponding to the next token.
|
| 228 |
+
*/
|
| 229 |
+
int yylex()]b4_maybe_throws([b4_lex_throws])[;
|
| 230 |
+
]])[
|
| 231 |
+
/**
|
| 232 |
+
* Emit an error]b4_locations_if([ referring to the given location])[in a user-defined way.
|
| 233 |
+
*
|
| 234 |
+
*]b4_locations_if([[ @@param loc The location of the element to which the
|
| 235 |
+
* error message is related.]])[
|
| 236 |
+
* @@param msg The string for the error message.
|
| 237 |
+
*/
|
| 238 |
+
void yyerror(]b4_locations_if([b4_location_type[ loc, ]])[String msg);
|
| 239 |
+
|
| 240 |
+
]b4_parse_error_bmatch(
|
| 241 |
+
[custom], [[
|
| 242 |
+
/**
|
| 243 |
+
* Build and emit a "syntax error" message in a user-defined way.
|
| 244 |
+
*
|
| 245 |
+
* @@param ctx The context of the error.
|
| 246 |
+
*/
|
| 247 |
+
void reportSyntaxError(Context ctx);
|
| 248 |
+
]])[
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
]b4_lexer_if([[
|
| 252 |
+
private class YYLexer implements Lexer {
|
| 253 |
+
]b4_percent_code_get([[lexer]])[
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
]])[
|
| 257 |
+
/**
|
| 258 |
+
* The object doing lexical analysis for us.
|
| 259 |
+
*/
|
| 260 |
+
private Lexer yylexer;
|
| 261 |
+
|
| 262 |
+
]b4_parse_param_vars[
|
| 263 |
+
|
| 264 |
+
]b4_lexer_if([[
|
| 265 |
+
/**
|
| 266 |
+
* Instantiates the Bison-generated parser.
|
| 267 |
+
*/
|
| 268 |
+
public ]b4_parser_class[(]b4_parse_param_decl([b4_lex_param_decl])[)]b4_maybe_throws([b4_init_throws])[
|
| 269 |
+
{
|
| 270 |
+
]b4_percent_code_get([[init]])[]b4_lac_if([[
|
| 271 |
+
this.yylacStack = new ArrayList<Integer>();
|
| 272 |
+
this.yylacEstablished = false;]])[
|
| 273 |
+
this.yylexer = new YYLexer(]b4_lex_param_call[);
|
| 274 |
+
]b4_parse_param_cons[
|
| 275 |
+
}
|
| 276 |
+
]])[
|
| 277 |
+
|
| 278 |
+
/**
|
| 279 |
+
* Instantiates the Bison-generated parser.
|
| 280 |
+
* @@param yylexer The scanner that will supply tokens to the parser.
|
| 281 |
+
*/
|
| 282 |
+
]b4_lexer_if([[protected]], [[public]]) b4_parser_class[(]b4_parse_param_decl([[Lexer yylexer]])[)]b4_maybe_throws([b4_init_throws])[
|
| 283 |
+
{
|
| 284 |
+
]b4_percent_code_get([[init]])[]b4_lac_if([[
|
| 285 |
+
this.yylacStack = new ArrayList<Integer>();
|
| 286 |
+
this.yylacEstablished = false;]])[
|
| 287 |
+
this.yylexer = yylexer;
|
| 288 |
+
]b4_parse_param_cons[
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
]b4_parse_trace_if([[
|
| 292 |
+
private java.io.PrintStream yyDebugStream = System.err;
|
| 293 |
+
|
| 294 |
+
/**
|
| 295 |
+
* The <tt>PrintStream</tt> on which the debugging output is printed.
|
| 296 |
+
*/
|
| 297 |
+
public final java.io.PrintStream getDebugStream() { return yyDebugStream; }
|
| 298 |
+
|
| 299 |
+
/**
|
| 300 |
+
* Set the <tt>PrintStream</tt> on which the debug output is printed.
|
| 301 |
+
* @@param s The stream that is used for debugging output.
|
| 302 |
+
*/
|
| 303 |
+
public final void setDebugStream(java.io.PrintStream s) { yyDebugStream = s; }
|
| 304 |
+
|
| 305 |
+
private int yydebug = 0;
|
| 306 |
+
|
| 307 |
+
/**
|
| 308 |
+
* Answer the verbosity of the debugging output; 0 means that all kinds of
|
| 309 |
+
* output from the parser are suppressed.
|
| 310 |
+
*/
|
| 311 |
+
public final int getDebugLevel() { return yydebug; }
|
| 312 |
+
|
| 313 |
+
/**
|
| 314 |
+
* Set the verbosity of the debugging output; 0 means that all kinds of
|
| 315 |
+
* output from the parser are suppressed.
|
| 316 |
+
* @@param level The verbosity level for debugging output.
|
| 317 |
+
*/
|
| 318 |
+
public final void setDebugLevel(int level) { yydebug = level; }
|
| 319 |
+
]])[
|
| 320 |
+
|
| 321 |
+
private int yynerrs = 0;
|
| 322 |
+
|
| 323 |
+
/**
|
| 324 |
+
* The number of syntax errors so far.
|
| 325 |
+
*/
|
| 326 |
+
public final int getNumberOfErrors() { return yynerrs; }
|
| 327 |
+
|
| 328 |
+
/**
|
| 329 |
+
* Print an error message via the lexer.
|
| 330 |
+
*]b4_locations_if([[ Use a <code>null</code> location.]])[
|
| 331 |
+
* @@param msg The error message.
|
| 332 |
+
*/
|
| 333 |
+
public final void yyerror(String msg) {
|
| 334 |
+
yylexer.yyerror(]b4_locations_if([[(]b4_location_type[)null, ]])[msg);
|
| 335 |
+
}
|
| 336 |
+
]b4_locations_if([[
|
| 337 |
+
/**
|
| 338 |
+
* Print an error message via the lexer.
|
| 339 |
+
* @@param loc The location associated with the message.
|
| 340 |
+
* @@param msg The error message.
|
| 341 |
+
*/
|
| 342 |
+
public final void yyerror(]b4_location_type[ loc, String msg) {
|
| 343 |
+
yylexer.yyerror(loc, msg);
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
/**
|
| 347 |
+
* Print an error message via the lexer.
|
| 348 |
+
* @@param pos The position associated with the message.
|
| 349 |
+
* @@param msg The error message.
|
| 350 |
+
*/
|
| 351 |
+
public final void yyerror(]b4_position_type[ pos, String msg) {
|
| 352 |
+
yylexer.yyerror(new ]b4_location_type[ (pos), msg);
|
| 353 |
+
}]])[
|
| 354 |
+
]b4_parse_trace_if([[
|
| 355 |
+
protected final void yycdebugNnl(String s) {
|
| 356 |
+
if (0 < yydebug)
|
| 357 |
+
yyDebugStream.print(s);
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
protected final void yycdebug(String s) {
|
| 361 |
+
if (0 < yydebug)
|
| 362 |
+
yyDebugStream.println(s);
|
| 363 |
+
}]])[
|
| 364 |
+
|
| 365 |
+
private final class YYStack {
|
| 366 |
+
private int[] stateStack = new int[16];]b4_locations_if([[
|
| 367 |
+
private ]b4_location_type[[] locStack = new ]b4_location_type[[16];]])[
|
| 368 |
+
private ]b4_yystype[[] valueStack = new ]b4_yystype[[16];
|
| 369 |
+
|
| 370 |
+
public int size = 16;
|
| 371 |
+
public int height = -1;
|
| 372 |
+
|
| 373 |
+
public final void push(int state, ]b4_yystype[ value]b4_locations_if([, ]b4_location_type[ loc])[) {
|
| 374 |
+
height++;
|
| 375 |
+
if (size == height) {
|
| 376 |
+
int[] newStateStack = new int[size * 2];
|
| 377 |
+
System.arraycopy(stateStack, 0, newStateStack, 0, height);
|
| 378 |
+
stateStack = newStateStack;]b4_locations_if([[
|
| 379 |
+
]b4_location_type[[] newLocStack = new ]b4_location_type[[size * 2];
|
| 380 |
+
System.arraycopy(locStack, 0, newLocStack, 0, height);
|
| 381 |
+
locStack = newLocStack;]])
|
| 382 |
+
|
| 383 |
+
b4_yystype[[] newValueStack = new ]b4_yystype[[size * 2];
|
| 384 |
+
System.arraycopy(valueStack, 0, newValueStack, 0, height);
|
| 385 |
+
valueStack = newValueStack;
|
| 386 |
+
|
| 387 |
+
size *= 2;
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
stateStack[height] = state;]b4_locations_if([[
|
| 391 |
+
locStack[height] = loc;]])[
|
| 392 |
+
valueStack[height] = value;
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
public final void pop() {
|
| 396 |
+
pop(1);
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
public final void pop(int num) {
|
| 400 |
+
// Avoid memory leaks... garbage collection is a white lie!
|
| 401 |
+
if (0 < num) {
|
| 402 |
+
java.util.Arrays.fill(valueStack, height - num + 1, height + 1, null);]b4_locations_if([[
|
| 403 |
+
java.util.Arrays.fill(locStack, height - num + 1, height + 1, null);]])[
|
| 404 |
+
}
|
| 405 |
+
height -= num;
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
public final int stateAt(int i) {
|
| 409 |
+
return stateStack[height - i];
|
| 410 |
+
}
|
| 411 |
+
]b4_locations_if([[
|
| 412 |
+
|
| 413 |
+
public final ]b4_location_type[ locationAt(int i) {
|
| 414 |
+
return locStack[height - i];
|
| 415 |
+
}
|
| 416 |
+
]])[
|
| 417 |
+
public final ]b4_yystype[ valueAt(int i) {
|
| 418 |
+
return valueStack[height - i];
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
// Print the state stack on the debug stream.
|
| 422 |
+
public void print(java.io.PrintStream out) {
|
| 423 |
+
out.print ("Stack now");
|
| 424 |
+
|
| 425 |
+
for (int i = 0; i <= height; i++) {
|
| 426 |
+
out.print(' ');
|
| 427 |
+
out.print(stateStack[i]);
|
| 428 |
+
}
|
| 429 |
+
out.println();
|
| 430 |
+
}
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
/**
|
| 434 |
+
* Returned by a Bison action in order to stop the parsing process and
|
| 435 |
+
* return success (<tt>true</tt>).
|
| 436 |
+
*/
|
| 437 |
+
public static final int YYACCEPT = 0;
|
| 438 |
+
|
| 439 |
+
/**
|
| 440 |
+
* Returned by a Bison action in order to stop the parsing process and
|
| 441 |
+
* return failure (<tt>false</tt>).
|
| 442 |
+
*/
|
| 443 |
+
public static final int YYABORT = 1;
|
| 444 |
+
|
| 445 |
+
]b4_push_if([
|
| 446 |
+
/**
|
| 447 |
+
* Returned by a Bison action in order to request a new token.
|
| 448 |
+
*/
|
| 449 |
+
public static final int YYPUSH_MORE = 4;])[
|
| 450 |
+
|
| 451 |
+
/**
|
| 452 |
+
* Returned by a Bison action in order to start error recovery without
|
| 453 |
+
* printing an error message.
|
| 454 |
+
*/
|
| 455 |
+
public static final int YYERROR = 2;
|
| 456 |
+
|
| 457 |
+
/**
|
| 458 |
+
* Internal return codes that are not supported for user semantic
|
| 459 |
+
* actions.
|
| 460 |
+
*/
|
| 461 |
+
private static final int YYERRLAB = 3;
|
| 462 |
+
private static final int YYNEWSTATE = 4;
|
| 463 |
+
private static final int YYDEFAULT = 5;
|
| 464 |
+
private static final int YYREDUCE = 6;
|
| 465 |
+
private static final int YYERRLAB1 = 7;
|
| 466 |
+
private static final int YYRETURN = 8;
|
| 467 |
+
]b4_push_if([[ private static final int YYGETTOKEN = 9; /* Signify that a new token is expected when doing push-parsing. */]])[
|
| 468 |
+
|
| 469 |
+
private int yyerrstatus_ = 0;
|
| 470 |
+
|
| 471 |
+
]b4_push_if([b4_define_state])[
|
| 472 |
+
/**
|
| 473 |
+
* Whether error recovery is being done. In this state, the parser
|
| 474 |
+
* reads token until it reaches a known state, and then restarts normal
|
| 475 |
+
* operation.
|
| 476 |
+
*/
|
| 477 |
+
public final boolean recovering ()
|
| 478 |
+
{
|
| 479 |
+
return yyerrstatus_ == 0;
|
| 480 |
+
}
|
| 481 |
+
|
| 482 |
+
/** Compute post-reduction state.
|
| 483 |
+
* @@param yystate the current state
|
| 484 |
+
* @@param yysym the nonterminal to push on the stack
|
| 485 |
+
*/
|
| 486 |
+
private int yyLRGotoState(int yystate, int yysym) {
|
| 487 |
+
int yyr = yypgoto_[yysym - YYNTOKENS_] + yystate;
|
| 488 |
+
if (0 <= yyr && yyr <= YYLAST_ && yycheck_[yyr] == yystate)
|
| 489 |
+
return yytable_[yyr];
|
| 490 |
+
else
|
| 491 |
+
return yydefgoto_[yysym - YYNTOKENS_];
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
private int yyaction(int yyn, YYStack yystack, int yylen)]b4_maybe_throws([b4_throws])[
|
| 495 |
+
{
|
| 496 |
+
/* If YYLEN is nonzero, implement the default value of the action:
|
| 497 |
+
'$$ = $1'. Otherwise, use the top of the stack.
|
| 498 |
+
|
| 499 |
+
Otherwise, the following line sets YYVAL to garbage.
|
| 500 |
+
This behavior is undocumented and Bison
|
| 501 |
+
users should not rely upon it. */
|
| 502 |
+
]b4_yystype[ yyval = (0 < yylen) ? yystack.valueAt(yylen - 1) : yystack.valueAt(0);]b4_locations_if([[
|
| 503 |
+
]b4_location_type[ yyloc = yylloc(yystack, yylen);]])[]b4_parse_trace_if([[
|
| 504 |
+
|
| 505 |
+
yyReducePrint(yyn, yystack);]])[
|
| 506 |
+
|
| 507 |
+
switch (yyn)
|
| 508 |
+
{
|
| 509 |
+
]b4_user_actions[
|
| 510 |
+
default: break;
|
| 511 |
+
}]b4_parse_trace_if([[
|
| 512 |
+
|
| 513 |
+
yySymbolPrint("-> $$ =", SymbolKind.get(yyr1_[yyn]), yyval]b4_locations_if([, yyloc])[);]])[
|
| 514 |
+
|
| 515 |
+
yystack.pop(yylen);
|
| 516 |
+
yylen = 0;
|
| 517 |
+
/* Shift the result of the reduction. */
|
| 518 |
+
int yystate = yyLRGotoState(yystack.stateAt(0), yyr1_[yyn]);
|
| 519 |
+
yystack.push(yystate, yyval]b4_locations_if([, yyloc])[);
|
| 520 |
+
return YYNEWSTATE;
|
| 521 |
+
}
|
| 522 |
+
|
| 523 |
+
]b4_parse_trace_if([[
|
| 524 |
+
/*--------------------------------.
|
| 525 |
+
| Print this symbol on YYOUTPUT. |
|
| 526 |
+
`--------------------------------*/
|
| 527 |
+
|
| 528 |
+
private void yySymbolPrint(String s, SymbolKind yykind,
|
| 529 |
+
]b4_yystype[ yyvalue]b4_locations_if([, ]b4_location_type[ yylocation])[) {
|
| 530 |
+
if (0 < yydebug) {
|
| 531 |
+
yycdebug(s
|
| 532 |
+
+ (yykind.getCode() < YYNTOKENS_ ? " token " : " nterm ")
|
| 533 |
+
+ yykind.getName() + " ("]b4_locations_if([
|
| 534 |
+
+ yylocation + ": "])[
|
| 535 |
+
+ (yyvalue == null ? "(null)" : yyvalue.toString()) + ")");
|
| 536 |
+
}
|
| 537 |
+
}]])[
|
| 538 |
+
|
| 539 |
+
]b4_push_if([],[[
|
| 540 |
+
/**
|
| 541 |
+
* Parse input from the scanner that was specified at object construction
|
| 542 |
+
* time. Return whether the end of the input was reached successfully.
|
| 543 |
+
*
|
| 544 |
+
* @@return <tt>true</tt> if the parsing succeeds. Note that this does not
|
| 545 |
+
* imply that there were no syntax errors.
|
| 546 |
+
*/
|
| 547 |
+
public boolean parse()]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[]])[
|
| 548 |
+
]b4_push_if([
|
| 549 |
+
/**
|
| 550 |
+
* Push Parse input from external lexer
|
| 551 |
+
*
|
| 552 |
+
* @@param yylextoken current token
|
| 553 |
+
* @@param yylexval current lval]b4_locations_if([[
|
| 554 |
+
* @@param yylexloc current position]])[
|
| 555 |
+
*
|
| 556 |
+
* @@return <tt>YYACCEPT, YYABORT, YYPUSH_MORE</tt>
|
| 557 |
+
*/
|
| 558 |
+
public int push_parse(int yylextoken, b4_yystype yylexval[]b4_locations_if([, b4_location_type yylexloc]))b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])])[
|
| 559 |
+
{]b4_locations_if([[
|
| 560 |
+
/* @@$. */
|
| 561 |
+
]b4_location_type[ yyloc;]])[
|
| 562 |
+
]b4_push_if([],[[
|
| 563 |
+
]b4_define_state[
|
| 564 |
+
]b4_lac_if([[
|
| 565 |
+
// Discard the LAC context in case there still is one left from a
|
| 566 |
+
// previous invocation.
|
| 567 |
+
yylacDiscard("init");]])[
|
| 568 |
+
]b4_parse_trace_if([[
|
| 569 |
+
yycdebug ("Starting parse");]])[
|
| 570 |
+
yyerrstatus_ = 0;
|
| 571 |
+
yynerrs = 0;
|
| 572 |
+
|
| 573 |
+
/* Initialize the stack. */
|
| 574 |
+
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
|
| 575 |
+
]m4_ifdef([b4_initial_action], [
|
| 576 |
+
b4_dollar_pushdef([yylval], [], [], [yylloc])dnl
|
| 577 |
+
b4_user_initial_action
|
| 578 |
+
b4_dollar_popdef[]dnl
|
| 579 |
+
])[
|
| 580 |
+
]])[
|
| 581 |
+
]b4_push_if([[
|
| 582 |
+
if (!this.push_parse_initialized)
|
| 583 |
+
{
|
| 584 |
+
push_parse_initialize ();
|
| 585 |
+
]m4_ifdef([b4_initial_action], [
|
| 586 |
+
b4_dollar_pushdef([yylval], [], [], [yylloc])dnl
|
| 587 |
+
b4_user_initial_action
|
| 588 |
+
b4_dollar_popdef[]dnl
|
| 589 |
+
])[]b4_parse_trace_if([[
|
| 590 |
+
yycdebug ("Starting parse");]])[
|
| 591 |
+
yyerrstatus_ = 0;
|
| 592 |
+
} else
|
| 593 |
+
label = YYGETTOKEN;
|
| 594 |
+
|
| 595 |
+
boolean push_token_consumed = true;
|
| 596 |
+
]])[
|
| 597 |
+
for (;;)
|
| 598 |
+
switch (label)
|
| 599 |
+
{
|
| 600 |
+
/* New state. Unlike in the C/C++ skeletons, the state is already
|
| 601 |
+
pushed when we come here. */
|
| 602 |
+
case YYNEWSTATE:]b4_parse_trace_if([[
|
| 603 |
+
yycdebug ("Entering state " + yystate);
|
| 604 |
+
if (0 < yydebug)
|
| 605 |
+
yystack.print (yyDebugStream);]])[
|
| 606 |
+
|
| 607 |
+
/* Accept? */
|
| 608 |
+
if (yystate == YYFINAL_)
|
| 609 |
+
]b4_push_if([{label = YYACCEPT; break;}],
|
| 610 |
+
[return true;])[
|
| 611 |
+
|
| 612 |
+
/* Take a decision. First try without lookahead. */
|
| 613 |
+
yyn = yypact_[yystate];
|
| 614 |
+
if (yyPactValueIsDefault (yyn))
|
| 615 |
+
{
|
| 616 |
+
label = YYDEFAULT;
|
| 617 |
+
break;
|
| 618 |
+
}
|
| 619 |
+
]b4_push_if([ /* Fall Through */
|
| 620 |
+
|
| 621 |
+
case YYGETTOKEN:])[
|
| 622 |
+
/* Read a lookahead token. */
|
| 623 |
+
if (yychar == YYEMPTY_)
|
| 624 |
+
{
|
| 625 |
+
]b4_push_if([[
|
| 626 |
+
if (!push_token_consumed)
|
| 627 |
+
return YYPUSH_MORE;]b4_parse_trace_if([[
|
| 628 |
+
yycdebug ("Reading a token");]])[
|
| 629 |
+
yychar = yylextoken;
|
| 630 |
+
yylval = yylexval;]b4_locations_if([
|
| 631 |
+
yylloc = yylexloc;])[
|
| 632 |
+
push_token_consumed = false;]], [b4_parse_trace_if([[
|
| 633 |
+
yycdebug ("Reading a token");]])[
|
| 634 |
+
yychar = yylexer.yylex ();
|
| 635 |
+
yylval = yylexer.getLVal();]b4_locations_if([[
|
| 636 |
+
yylloc = new ]b4_location_type[(yylexer.getStartPos(),
|
| 637 |
+
yylexer.getEndPos());]])[
|
| 638 |
+
]])[
|
| 639 |
+
}
|
| 640 |
+
|
| 641 |
+
/* Convert token to internal form. */
|
| 642 |
+
yytoken = yytranslate_ (yychar);]b4_parse_trace_if([[
|
| 643 |
+
yySymbolPrint("Next token is", yytoken,
|
| 644 |
+
yylval]b4_locations_if([, yylloc])[);]])[
|
| 645 |
+
|
| 646 |
+
if (yytoken == ]b4_symbol(error, kind)[)
|
| 647 |
+
{
|
| 648 |
+
// The scanner already issued an error message, process directly
|
| 649 |
+
// to error recovery. But do not keep the error token as
|
| 650 |
+
// lookahead, it is too special and may lead us to an endless
|
| 651 |
+
// loop in error recovery. */
|
| 652 |
+
yychar = Lexer.]b4_symbol(undef, id)[;
|
| 653 |
+
yytoken = ]b4_symbol(undef, kind)[;]b4_locations_if([[
|
| 654 |
+
yyerrloc = yylloc;]])[
|
| 655 |
+
label = YYERRLAB1;
|
| 656 |
+
}
|
| 657 |
+
else
|
| 658 |
+
{
|
| 659 |
+
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
| 660 |
+
detect an error, take that action. */
|
| 661 |
+
yyn += yytoken.getCode();
|
| 662 |
+
if (yyn < 0 || YYLAST_ < yyn || yycheck_[yyn] != yytoken.getCode()) {]b4_lac_if([[
|
| 663 |
+
if (!yylacEstablish(yystack, yytoken)) {
|
| 664 |
+
label = YYERRLAB;
|
| 665 |
+
} else]])[
|
| 666 |
+
label = YYDEFAULT;
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
/* <= 0 means reduce or error. */
|
| 670 |
+
else if ((yyn = yytable_[yyn]) <= 0)
|
| 671 |
+
{
|
| 672 |
+
if (yyTableValueIsError(yyn)) {
|
| 673 |
+
label = YYERRLAB;
|
| 674 |
+
}]b4_lac_if([[ else if (!yylacEstablish(yystack, yytoken)) {
|
| 675 |
+
label = YYERRLAB;
|
| 676 |
+
}]])[ else {
|
| 677 |
+
yyn = -yyn;
|
| 678 |
+
label = YYREDUCE;
|
| 679 |
+
}
|
| 680 |
+
}
|
| 681 |
+
|
| 682 |
+
else
|
| 683 |
+
{
|
| 684 |
+
/* Shift the lookahead token. */]b4_parse_trace_if([[
|
| 685 |
+
yySymbolPrint("Shifting", yytoken,
|
| 686 |
+
yylval]b4_locations_if([, yylloc])[);
|
| 687 |
+
]])[
|
| 688 |
+
/* Discard the token being shifted. */
|
| 689 |
+
yychar = YYEMPTY_;
|
| 690 |
+
|
| 691 |
+
/* Count tokens shifted since error; after three, turn off error
|
| 692 |
+
status. */
|
| 693 |
+
if (yyerrstatus_ > 0)
|
| 694 |
+
--yyerrstatus_;
|
| 695 |
+
|
| 696 |
+
yystate = yyn;
|
| 697 |
+
yystack.push(yystate, yylval]b4_locations_if([, yylloc])[);]b4_lac_if([[
|
| 698 |
+
yylacDiscard("shift");]])[
|
| 699 |
+
label = YYNEWSTATE;
|
| 700 |
+
}
|
| 701 |
+
}
|
| 702 |
+
break;
|
| 703 |
+
|
| 704 |
+
/*-----------------------------------------------------------.
|
| 705 |
+
| yydefault -- do the default action for the current state. |
|
| 706 |
+
`-----------------------------------------------------------*/
|
| 707 |
+
case YYDEFAULT:
|
| 708 |
+
yyn = yydefact_[yystate];
|
| 709 |
+
if (yyn == 0)
|
| 710 |
+
label = YYERRLAB;
|
| 711 |
+
else
|
| 712 |
+
label = YYREDUCE;
|
| 713 |
+
break;
|
| 714 |
+
|
| 715 |
+
/*-----------------------------.
|
| 716 |
+
| yyreduce -- Do a reduction. |
|
| 717 |
+
`-----------------------------*/
|
| 718 |
+
case YYREDUCE:
|
| 719 |
+
yylen = yyr2_[yyn];
|
| 720 |
+
label = yyaction(yyn, yystack, yylen);
|
| 721 |
+
yystate = yystack.stateAt(0);
|
| 722 |
+
break;
|
| 723 |
+
|
| 724 |
+
/*------------------------------------.
|
| 725 |
+
| yyerrlab -- here on detecting error |
|
| 726 |
+
`------------------------------------*/
|
| 727 |
+
case YYERRLAB:
|
| 728 |
+
/* If not already recovering from an error, report this error. */
|
| 729 |
+
if (yyerrstatus_ == 0)
|
| 730 |
+
{
|
| 731 |
+
++yynerrs;
|
| 732 |
+
if (yychar == YYEMPTY_)
|
| 733 |
+
yytoken = null;
|
| 734 |
+
yyreportSyntaxError(new Context(this, yystack, yytoken]b4_locations_if([[, yylloc]])[));
|
| 735 |
+
}
|
| 736 |
+
]b4_locations_if([[
|
| 737 |
+
yyerrloc = yylloc;]])[
|
| 738 |
+
if (yyerrstatus_ == 3)
|
| 739 |
+
{
|
| 740 |
+
/* If just tried and failed to reuse lookahead token after an
|
| 741 |
+
error, discard it. */
|
| 742 |
+
|
| 743 |
+
if (yychar <= Lexer.]b4_symbol(eof, id)[)
|
| 744 |
+
{
|
| 745 |
+
/* Return failure if at end of input. */
|
| 746 |
+
if (yychar == Lexer.]b4_symbol(eof, id)[)
|
| 747 |
+
]b4_push_if([{label = YYABORT; break;}], [return false;])[
|
| 748 |
+
}
|
| 749 |
+
else
|
| 750 |
+
yychar = YYEMPTY_;
|
| 751 |
+
}
|
| 752 |
+
|
| 753 |
+
/* Else will try to reuse lookahead token after shifting the error
|
| 754 |
+
token. */
|
| 755 |
+
label = YYERRLAB1;
|
| 756 |
+
break;
|
| 757 |
+
|
| 758 |
+
/*-------------------------------------------------.
|
| 759 |
+
| errorlab -- error raised explicitly by YYERROR. |
|
| 760 |
+
`-------------------------------------------------*/
|
| 761 |
+
case YYERROR:]b4_locations_if([[
|
| 762 |
+
yyerrloc = yystack.locationAt (yylen - 1);]])[
|
| 763 |
+
/* Do not reclaim the symbols of the rule which action triggered
|
| 764 |
+
this YYERROR. */
|
| 765 |
+
yystack.pop (yylen);
|
| 766 |
+
yylen = 0;
|
| 767 |
+
yystate = yystack.stateAt(0);
|
| 768 |
+
label = YYERRLAB1;
|
| 769 |
+
break;
|
| 770 |
+
|
| 771 |
+
/*-------------------------------------------------------------.
|
| 772 |
+
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
| 773 |
+
`-------------------------------------------------------------*/
|
| 774 |
+
case YYERRLAB1:
|
| 775 |
+
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
|
| 776 |
+
|
| 777 |
+
// Pop stack until we find a state that shifts the error token.
|
| 778 |
+
for (;;)
|
| 779 |
+
{
|
| 780 |
+
yyn = yypact_[yystate];
|
| 781 |
+
if (!yyPactValueIsDefault (yyn))
|
| 782 |
+
{
|
| 783 |
+
yyn += ]b4_symbol(error, kind)[.getCode();
|
| 784 |
+
if (0 <= yyn && yyn <= YYLAST_
|
| 785 |
+
&& yycheck_[yyn] == ]b4_symbol(error, kind)[.getCode())
|
| 786 |
+
{
|
| 787 |
+
yyn = yytable_[yyn];
|
| 788 |
+
if (0 < yyn)
|
| 789 |
+
break;
|
| 790 |
+
}
|
| 791 |
+
}
|
| 792 |
+
|
| 793 |
+
/* Pop the current state because it cannot handle the
|
| 794 |
+
* error token. */
|
| 795 |
+
if (yystack.height == 0)
|
| 796 |
+
]b4_push_if([{label = YYABORT; break;}],[return false;])[
|
| 797 |
+
|
| 798 |
+
]b4_locations_if([[
|
| 799 |
+
yyerrloc = yystack.locationAt (0);]])[
|
| 800 |
+
yystack.pop ();
|
| 801 |
+
yystate = yystack.stateAt(0);]b4_parse_trace_if([[
|
| 802 |
+
if (0 < yydebug)
|
| 803 |
+
yystack.print (yyDebugStream);]])[
|
| 804 |
+
}
|
| 805 |
+
|
| 806 |
+
if (label == YYABORT)
|
| 807 |
+
/* Leave the switch. */
|
| 808 |
+
break;
|
| 809 |
+
|
| 810 |
+
]b4_locations_if([[
|
| 811 |
+
/* Muck with the stack to setup for yylloc. */
|
| 812 |
+
yystack.push (0, null, yylloc);
|
| 813 |
+
yystack.push (0, null, yyerrloc);
|
| 814 |
+
yyloc = yylloc (yystack, 2);
|
| 815 |
+
yystack.pop (2);]])[
|
| 816 |
+
|
| 817 |
+
/* Shift the error token. */]b4_lac_if([[
|
| 818 |
+
yylacDiscard("error recovery");]])[]b4_parse_trace_if([[
|
| 819 |
+
yySymbolPrint("Shifting", SymbolKind.get(yystos_[yyn]),
|
| 820 |
+
yylval]b4_locations_if([, yyloc])[);]])[
|
| 821 |
+
|
| 822 |
+
yystate = yyn;
|
| 823 |
+
yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
|
| 824 |
+
label = YYNEWSTATE;
|
| 825 |
+
break;
|
| 826 |
+
|
| 827 |
+
/* Accept. */
|
| 828 |
+
case YYACCEPT:
|
| 829 |
+
]b4_push_if([this.push_parse_initialized = false; return YYACCEPT;],
|
| 830 |
+
[return true;])[
|
| 831 |
+
|
| 832 |
+
/* Abort. */
|
| 833 |
+
case YYABORT:
|
| 834 |
+
]b4_push_if([this.push_parse_initialized = false; return YYABORT;],
|
| 835 |
+
[return false;])[
|
| 836 |
+
}
|
| 837 |
+
}
|
| 838 |
+
]b4_push_if([[
|
| 839 |
+
boolean push_parse_initialized = false;
|
| 840 |
+
|
| 841 |
+
/**
|
| 842 |
+
* (Re-)Initialize the state of the push parser.
|
| 843 |
+
*/
|
| 844 |
+
public void push_parse_initialize ()
|
| 845 |
+
{
|
| 846 |
+
/* Lookahead and lookahead in internal form. */
|
| 847 |
+
this.yychar = YYEMPTY_;
|
| 848 |
+
this.yytoken = null;
|
| 849 |
+
|
| 850 |
+
/* State. */
|
| 851 |
+
this.yyn = 0;
|
| 852 |
+
this.yylen = 0;
|
| 853 |
+
this.yystate = 0;
|
| 854 |
+
this.yystack = new YYStack();]b4_lac_if([[
|
| 855 |
+
this.yylacStack = new ArrayList<Integer>();
|
| 856 |
+
this.yylacEstablished = false;]])[
|
| 857 |
+
this.label = YYNEWSTATE;
|
| 858 |
+
|
| 859 |
+
/* Error handling. */
|
| 860 |
+
this.yynerrs = 0;]b4_locations_if([[
|
| 861 |
+
/* The location where the error started. */
|
| 862 |
+
this.yyerrloc = null;
|
| 863 |
+
this.yylloc = new ]b4_location_type[ (null, null);]])[
|
| 864 |
+
|
| 865 |
+
/* Semantic value of the lookahead. */
|
| 866 |
+
this.yylval = null;
|
| 867 |
+
|
| 868 |
+
yystack.push (this.yystate, this.yylval]b4_locations_if([, this.yylloc])[);
|
| 869 |
+
|
| 870 |
+
this.push_parse_initialized = true;
|
| 871 |
+
|
| 872 |
+
}
|
| 873 |
+
]b4_locations_if([[
|
| 874 |
+
/**
|
| 875 |
+
* Push parse given input from an external lexer.
|
| 876 |
+
*
|
| 877 |
+
* @@param yylextoken current token
|
| 878 |
+
* @@param yylexval current lval
|
| 879 |
+
* @@param yyylexpos current position
|
| 880 |
+
*
|
| 881 |
+
* @@return <tt>YYACCEPT, YYABORT, YYPUSH_MORE</tt>
|
| 882 |
+
*/
|
| 883 |
+
public int push_parse(int yylextoken, ]b4_yystype[ yylexval, ]b4_position_type[ yylexpos)]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[ {
|
| 884 |
+
return push_parse(yylextoken, yylexval, new ]b4_location_type[(yylexpos));
|
| 885 |
+
}
|
| 886 |
+
]])])[
|
| 887 |
+
|
| 888 |
+
]b4_both_if([[
|
| 889 |
+
/**
|
| 890 |
+
* Parse input from the scanner that was specified at object construction
|
| 891 |
+
* time. Return whether the end of the input was reached successfully.
|
| 892 |
+
* This version of parse() is defined only when api.push-push=both.
|
| 893 |
+
*
|
| 894 |
+
* @@return <tt>true</tt> if the parsing succeeds. Note that this does not
|
| 895 |
+
* imply that there were no syntax errors.
|
| 896 |
+
*/
|
| 897 |
+
public boolean parse()]b4_maybe_throws([b4_list2([b4_lex_throws], [b4_throws])])[ {
|
| 898 |
+
if (yylexer == null)
|
| 899 |
+
throw new NullPointerException("Null Lexer");
|
| 900 |
+
int status;
|
| 901 |
+
do {
|
| 902 |
+
int token = yylexer.yylex();
|
| 903 |
+
]b4_yystype[ lval = yylexer.getLVal();]b4_locations_if([[
|
| 904 |
+
]b4_location_type[ yyloc = new ]b4_location_type[(yylexer.getStartPos(), yylexer.getEndPos());
|
| 905 |
+
status = push_parse(token, lval, yyloc);]], [[
|
| 906 |
+
status = push_parse(token, lval);]])[
|
| 907 |
+
} while (status == YYPUSH_MORE);
|
| 908 |
+
return status == YYACCEPT;
|
| 909 |
+
}
|
| 910 |
+
]])[
|
| 911 |
+
|
| 912 |
+
/**
|
| 913 |
+
* Information needed to get the list of expected tokens and to forge
|
| 914 |
+
* a syntax error diagnostic.
|
| 915 |
+
*/
|
| 916 |
+
public static final class Context {
|
| 917 |
+
Context(]b4_parser_class[ parser, YYStack stack, SymbolKind token]b4_locations_if([[, ]b4_location_type[ loc]])[) {
|
| 918 |
+
yyparser = parser;
|
| 919 |
+
yystack = stack;
|
| 920 |
+
yytoken = token;]b4_locations_if([[
|
| 921 |
+
yylocation = loc;]])[
|
| 922 |
+
}
|
| 923 |
+
|
| 924 |
+
private ]b4_parser_class[ yyparser;
|
| 925 |
+
private YYStack yystack;
|
| 926 |
+
|
| 927 |
+
|
| 928 |
+
/**
|
| 929 |
+
* The symbol kind of the lookahead token.
|
| 930 |
+
*/
|
| 931 |
+
public final SymbolKind getToken() {
|
| 932 |
+
return yytoken;
|
| 933 |
+
}
|
| 934 |
+
|
| 935 |
+
private SymbolKind yytoken;]b4_locations_if([[
|
| 936 |
+
|
| 937 |
+
/**
|
| 938 |
+
* The location of the lookahead.
|
| 939 |
+
*/
|
| 940 |
+
public final ]b4_location_type[ getLocation() {
|
| 941 |
+
return yylocation;
|
| 942 |
+
}
|
| 943 |
+
|
| 944 |
+
private ]b4_location_type[ yylocation;]])[
|
| 945 |
+
static final int NTOKENS = ]b4_parser_class[.YYNTOKENS_;
|
| 946 |
+
|
| 947 |
+
/**
|
| 948 |
+
* Put in YYARG at most YYARGN of the expected tokens given the
|
| 949 |
+
* current YYCTX, and return the number of tokens stored in YYARG. If
|
| 950 |
+
* YYARG is null, return the number of expected tokens (guaranteed to
|
| 951 |
+
* be less than YYNTOKENS).
|
| 952 |
+
*/
|
| 953 |
+
int getExpectedTokens(SymbolKind yyarg[], int yyargn) {
|
| 954 |
+
return getExpectedTokens (yyarg, 0, yyargn);
|
| 955 |
+
}
|
| 956 |
+
|
| 957 |
+
int getExpectedTokens(SymbolKind yyarg[], int yyoffset, int yyargn) {
|
| 958 |
+
int yycount = yyoffset;]b4_lac_if([b4_parse_trace_if([[
|
| 959 |
+
// Execute LAC once. We don't care if it is successful, we
|
| 960 |
+
// only do it for the sake of debugging output.
|
| 961 |
+
if (!yyparser.yylacEstablished)
|
| 962 |
+
yyparser.yylacCheck(yystack, yytoken);
|
| 963 |
+
]])[
|
| 964 |
+
for (int yyx = 0; yyx < YYNTOKENS_; ++yyx)
|
| 965 |
+
{
|
| 966 |
+
SymbolKind yysym = SymbolKind.get(yyx);
|
| 967 |
+
if (yysym != ]b4_symbol(error, kind)[
|
| 968 |
+
&& yysym != ]b4_symbol(undef, kind)[
|
| 969 |
+
&& yyparser.yylacCheck(yystack, yysym))
|
| 970 |
+
{
|
| 971 |
+
if (yyarg == null)
|
| 972 |
+
yycount += 1;
|
| 973 |
+
else if (yycount == yyargn)
|
| 974 |
+
return 0;
|
| 975 |
+
else
|
| 976 |
+
yyarg[yycount++] = yysym;
|
| 977 |
+
}
|
| 978 |
+
}]], [[
|
| 979 |
+
int yyn = yypact_[this.yystack.stateAt(0)];
|
| 980 |
+
if (!yyPactValueIsDefault(yyn))
|
| 981 |
+
{
|
| 982 |
+
/* Start YYX at -YYN if negative to avoid negative
|
| 983 |
+
indexes in YYCHECK. In other words, skip the first
|
| 984 |
+
-YYN actions for this state because they are default
|
| 985 |
+
actions. */
|
| 986 |
+
int yyxbegin = yyn < 0 ? -yyn : 0;
|
| 987 |
+
/* Stay within bounds of both yycheck and yytname. */
|
| 988 |
+
int yychecklim = YYLAST_ - yyn + 1;
|
| 989 |
+
int yyxend = yychecklim < NTOKENS ? yychecklim : NTOKENS;
|
| 990 |
+
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
|
| 991 |
+
if (yycheck_[yyx + yyn] == yyx && yyx != ]b4_symbol(error, kind)[.getCode()
|
| 992 |
+
&& !yyTableValueIsError(yytable_[yyx + yyn]))
|
| 993 |
+
{
|
| 994 |
+
if (yyarg == null)
|
| 995 |
+
yycount += 1;
|
| 996 |
+
else if (yycount == yyargn)
|
| 997 |
+
return 0; // FIXME: this is incorrect.
|
| 998 |
+
else
|
| 999 |
+
yyarg[yycount++] = SymbolKind.get(yyx);
|
| 1000 |
+
}
|
| 1001 |
+
}]])[
|
| 1002 |
+
if (yyarg != null && yycount == yyoffset && yyoffset < yyargn)
|
| 1003 |
+
yyarg[yycount] = null;
|
| 1004 |
+
return yycount - yyoffset;
|
| 1005 |
+
}
|
| 1006 |
+
}
|
| 1007 |
+
|
| 1008 |
+
]b4_lac_if([[
|
| 1009 |
+
/** Check the lookahead yytoken.
|
| 1010 |
+
* \returns true iff the token will be eventually shifted.
|
| 1011 |
+
*/
|
| 1012 |
+
boolean yylacCheck(YYStack yystack, SymbolKind yytoken)
|
| 1013 |
+
{
|
| 1014 |
+
// Logically, the yylacStack's lifetime is confined to this function.
|
| 1015 |
+
// Clear it, to get rid of potential left-overs from previous call.
|
| 1016 |
+
yylacStack.clear();
|
| 1017 |
+
// Reduce until we encounter a shift and thereby accept the token.
|
| 1018 |
+
yycdebugNnl("LAC: checking lookahead " + yytoken.getName() + ":");
|
| 1019 |
+
int lacTop = 0;
|
| 1020 |
+
while (true)
|
| 1021 |
+
{
|
| 1022 |
+
int topState = (yylacStack.isEmpty()
|
| 1023 |
+
? yystack.stateAt(lacTop)
|
| 1024 |
+
: yylacStack.get(yylacStack.size() - 1));
|
| 1025 |
+
int yyrule = yypact_[topState];
|
| 1026 |
+
if (yyPactValueIsDefault(yyrule)
|
| 1027 |
+
|| (yyrule += yytoken.getCode()) < 0 || YYLAST_ < yyrule
|
| 1028 |
+
|| yycheck_[yyrule] != yytoken.getCode())
|
| 1029 |
+
{
|
| 1030 |
+
// Use the default action.
|
| 1031 |
+
yyrule = yydefact_[+topState];
|
| 1032 |
+
if (yyrule == 0) {
|
| 1033 |
+
yycdebug(" Err");
|
| 1034 |
+
return false;
|
| 1035 |
+
}
|
| 1036 |
+
}
|
| 1037 |
+
else
|
| 1038 |
+
{
|
| 1039 |
+
// Use the action from yytable.
|
| 1040 |
+
yyrule = yytable_[yyrule];
|
| 1041 |
+
if (yyTableValueIsError(yyrule)) {
|
| 1042 |
+
yycdebug(" Err");
|
| 1043 |
+
return false;
|
| 1044 |
+
}
|
| 1045 |
+
if (0 < yyrule) {
|
| 1046 |
+
yycdebug(" S" + yyrule);
|
| 1047 |
+
return true;
|
| 1048 |
+
}
|
| 1049 |
+
yyrule = -yyrule;
|
| 1050 |
+
}
|
| 1051 |
+
// By now we know we have to simulate a reduce.
|
| 1052 |
+
yycdebugNnl(" R" + (yyrule - 1));
|
| 1053 |
+
// Pop the corresponding number of values from the stack.
|
| 1054 |
+
{
|
| 1055 |
+
int yylen = yyr2_[yyrule];
|
| 1056 |
+
// First pop from the LAC stack as many tokens as possible.
|
| 1057 |
+
int lacSize = yylacStack.size();
|
| 1058 |
+
if (yylen < lacSize) {
|
| 1059 |
+
// yylacStack.setSize(lacSize - yylen);
|
| 1060 |
+
for (/* Nothing */; 0 < yylen; yylen -= 1) {
|
| 1061 |
+
yylacStack.remove(yylacStack.size() - 1);
|
| 1062 |
+
}
|
| 1063 |
+
yylen = 0;
|
| 1064 |
+
} else if (lacSize != 0) {
|
| 1065 |
+
yylacStack.clear();
|
| 1066 |
+
yylen -= lacSize;
|
| 1067 |
+
}
|
| 1068 |
+
// Only afterwards look at the main stack.
|
| 1069 |
+
// We simulate popping elements by incrementing lacTop.
|
| 1070 |
+
lacTop += yylen;
|
| 1071 |
+
}
|
| 1072 |
+
// Keep topState in sync with the updated stack.
|
| 1073 |
+
topState = (yylacStack.isEmpty()
|
| 1074 |
+
? yystack.stateAt(lacTop)
|
| 1075 |
+
: yylacStack.get(yylacStack.size() - 1));
|
| 1076 |
+
// Push the resulting state of the reduction.
|
| 1077 |
+
int state = yyLRGotoState(topState, yyr1_[yyrule]);
|
| 1078 |
+
yycdebugNnl(" G" + state);
|
| 1079 |
+
yylacStack.add(state);
|
| 1080 |
+
}
|
| 1081 |
+
}
|
| 1082 |
+
|
| 1083 |
+
/** Establish the initial context if no initial context currently exists.
|
| 1084 |
+
* \returns true iff the token will be eventually shifted.
|
| 1085 |
+
*/
|
| 1086 |
+
boolean yylacEstablish(YYStack yystack, SymbolKind yytoken) {
|
| 1087 |
+
/* Establish the initial context for the current lookahead if no initial
|
| 1088 |
+
context is currently established.
|
| 1089 |
+
|
| 1090 |
+
We define a context as a snapshot of the parser stacks. We define
|
| 1091 |
+
the initial context for a lookahead as the context in which the
|
| 1092 |
+
parser initially examines that lookahead in order to select a
|
| 1093 |
+
syntactic action. Thus, if the lookahead eventually proves
|
| 1094 |
+
syntactically unacceptable (possibly in a later context reached via a
|
| 1095 |
+
series of reductions), the initial context can be used to determine
|
| 1096 |
+
the exact set of tokens that would be syntactically acceptable in the
|
| 1097 |
+
lookahead's place. Moreover, it is the context after which any
|
| 1098 |
+
further semantic actions would be erroneous because they would be
|
| 1099 |
+
determined by a syntactically unacceptable token.
|
| 1100 |
+
|
| 1101 |
+
yylacEstablish should be invoked when a reduction is about to be
|
| 1102 |
+
performed in an inconsistent state (which, for the purposes of LAC,
|
| 1103 |
+
includes consistent states that don't know they're consistent because
|
| 1104 |
+
their default reductions have been disabled).
|
| 1105 |
+
|
| 1106 |
+
For parse.lac=full, the implementation of yylacEstablish is as
|
| 1107 |
+
follows. If no initial context is currently established for the
|
| 1108 |
+
current lookahead, then check if that lookahead can eventually be
|
| 1109 |
+
shifted if syntactic actions continue from the current context. */
|
| 1110 |
+
if (yylacEstablished) {
|
| 1111 |
+
return true;
|
| 1112 |
+
} else {
|
| 1113 |
+
yycdebug("LAC: initial context established for " + yytoken.getName());
|
| 1114 |
+
yylacEstablished = true;
|
| 1115 |
+
return yylacCheck(yystack, yytoken);
|
| 1116 |
+
}
|
| 1117 |
+
}
|
| 1118 |
+
|
| 1119 |
+
/** Discard any previous initial lookahead context because of event.
|
| 1120 |
+
* \param event the event which caused the lookahead to be discarded.
|
| 1121 |
+
* Only used for debbuging output. */
|
| 1122 |
+
void yylacDiscard(String event) {
|
| 1123 |
+
/* Discard any previous initial lookahead context because of Event,
|
| 1124 |
+
which may be a lookahead change or an invalidation of the currently
|
| 1125 |
+
established initial context for the current lookahead.
|
| 1126 |
+
|
| 1127 |
+
The most common example of a lookahead change is a shift. An example
|
| 1128 |
+
of both cases is syntax error recovery. That is, a syntax error
|
| 1129 |
+
occurs when the lookahead is syntactically erroneous for the
|
| 1130 |
+
currently established initial context, so error recovery manipulates
|
| 1131 |
+
the parser stacks to try to find a new initial context in which the
|
| 1132 |
+
current lookahead is syntactically acceptable. If it fails to find
|
| 1133 |
+
such a context, it discards the lookahead. */
|
| 1134 |
+
if (yylacEstablished) {
|
| 1135 |
+
yycdebug("LAC: initial context discarded due to " + event);
|
| 1136 |
+
yylacEstablished = false;
|
| 1137 |
+
}
|
| 1138 |
+
}
|
| 1139 |
+
|
| 1140 |
+
/** The stack for LAC.
|
| 1141 |
+
* Logically, the yylacStack's lifetime is confined to the function
|
| 1142 |
+
* yylacCheck. We just store it as a member of this class to hold
|
| 1143 |
+
* on to the memory and to avoid frequent reallocations.
|
| 1144 |
+
*/
|
| 1145 |
+
ArrayList<Integer> yylacStack;
|
| 1146 |
+
/** Whether an initial LAC context was established. */
|
| 1147 |
+
boolean yylacEstablished;
|
| 1148 |
+
]])[
|
| 1149 |
+
|
| 1150 |
+
]b4_parse_error_bmatch(
|
| 1151 |
+
[detailed\|verbose], [[
|
| 1152 |
+
private int yysyntaxErrorArguments(Context yyctx, SymbolKind[] yyarg, int yyargn) {
|
| 1153 |
+
/* There are many possibilities here to consider:
|
| 1154 |
+
- If this state is a consistent state with a default action,
|
| 1155 |
+
then the only way this function was invoked is if the
|
| 1156 |
+
default action is an error action. In that case, don't
|
| 1157 |
+
check for expected tokens because there are none.
|
| 1158 |
+
- The only way there can be no lookahead present (in tok) is
|
| 1159 |
+
if this state is a consistent state with a default action.
|
| 1160 |
+
Thus, detecting the absence of a lookahead is sufficient to
|
| 1161 |
+
determine that there is no unexpected or expected token to
|
| 1162 |
+
report. In that case, just report a simple "syntax error".
|
| 1163 |
+
- Don't assume there isn't a lookahead just because this
|
| 1164 |
+
state is a consistent state with a default action. There
|
| 1165 |
+
might have been a previous inconsistent state, consistent
|
| 1166 |
+
state with a non-default action, or user semantic action
|
| 1167 |
+
that manipulated yychar. (However, yychar is currently out
|
| 1168 |
+
of scope during semantic actions.)
|
| 1169 |
+
- Of course, the expected token list depends on states to
|
| 1170 |
+
have correct lookahead information, and it depends on the
|
| 1171 |
+
parser not to perform extra reductions after fetching a
|
| 1172 |
+
lookahead from the scanner and before detecting a syntax
|
| 1173 |
+
error. Thus, state merging (from LALR or IELR) and default
|
| 1174 |
+
reductions corrupt the expected token list. However, the
|
| 1175 |
+
list is correct for canonical LR with one exception: it
|
| 1176 |
+
will still contain any token that will not be accepted due
|
| 1177 |
+
to an error action in a later state.
|
| 1178 |
+
*/
|
| 1179 |
+
int yycount = 0;
|
| 1180 |
+
if (yyctx.getToken() != null)
|
| 1181 |
+
{
|
| 1182 |
+
if (yyarg != null)
|
| 1183 |
+
yyarg[yycount] = yyctx.getToken();
|
| 1184 |
+
yycount += 1;
|
| 1185 |
+
yycount += yyctx.getExpectedTokens(yyarg, 1, yyargn);
|
| 1186 |
+
}
|
| 1187 |
+
return yycount;
|
| 1188 |
+
}
|
| 1189 |
+
]])[
|
| 1190 |
+
|
| 1191 |
+
/**
|
| 1192 |
+
* Build and emit a "syntax error" message in a user-defined way.
|
| 1193 |
+
*
|
| 1194 |
+
* @@param ctx The context of the error.
|
| 1195 |
+
*/
|
| 1196 |
+
private void yyreportSyntaxError(Context yyctx) {]b4_parse_error_bmatch(
|
| 1197 |
+
[custom], [[
|
| 1198 |
+
yylexer.reportSyntaxError(yyctx);]],
|
| 1199 |
+
[detailed\|verbose], [[
|
| 1200 |
+
if (yyErrorVerbose) {
|
| 1201 |
+
final int argmax = 5;
|
| 1202 |
+
SymbolKind[] yyarg = new SymbolKind[argmax];
|
| 1203 |
+
int yycount = yysyntaxErrorArguments(yyctx, yyarg, argmax);
|
| 1204 |
+
String[] yystr = new String[yycount];
|
| 1205 |
+
for (int yyi = 0; yyi < yycount; ++yyi) {
|
| 1206 |
+
yystr[yyi] = yyarg[yyi].getName();
|
| 1207 |
+
}
|
| 1208 |
+
String yyformat;
|
| 1209 |
+
switch (yycount) {
|
| 1210 |
+
default:
|
| 1211 |
+
case 0: yyformat = ]b4_trans(["syntax error"])[; break;
|
| 1212 |
+
case 1: yyformat = ]b4_trans(["syntax error, unexpected {0}"])[; break;
|
| 1213 |
+
case 2: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1}"])[; break;
|
| 1214 |
+
case 3: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1} or {2}"])[; break;
|
| 1215 |
+
case 4: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1} or {2} or {3}"])[; break;
|
| 1216 |
+
case 5: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1} or {2} or {3} or {4}"])[; break;
|
| 1217 |
+
}
|
| 1218 |
+
yyerror(]b4_locations_if([[yyctx.yylocation, ]])[new MessageFormat(yyformat).format(yystr));
|
| 1219 |
+
} else {
|
| 1220 |
+
yyerror(]b4_locations_if([[yyctx.yylocation, ]])[]b4_trans(["syntax error"])[);
|
| 1221 |
+
}]],
|
| 1222 |
+
[simple], [[
|
| 1223 |
+
yyerror(]b4_locations_if([[yyctx.yylocation, ]])[]b4_trans(["syntax error"])[);]])[
|
| 1224 |
+
}
|
| 1225 |
+
|
| 1226 |
+
/**
|
| 1227 |
+
* Whether the given <code>yypact_</code> value indicates a defaulted state.
|
| 1228 |
+
* @@param yyvalue the value to check
|
| 1229 |
+
*/
|
| 1230 |
+
private static boolean yyPactValueIsDefault(int yyvalue) {
|
| 1231 |
+
return yyvalue == yypact_ninf_;
|
| 1232 |
+
}
|
| 1233 |
+
|
| 1234 |
+
/**
|
| 1235 |
+
* Whether the given <code>yytable_</code>
|
| 1236 |
+
* value indicates a syntax error.
|
| 1237 |
+
* @@param yyvalue the value to check
|
| 1238 |
+
*/
|
| 1239 |
+
private static boolean yyTableValueIsError(int yyvalue) {
|
| 1240 |
+
return yyvalue == yytable_ninf_;
|
| 1241 |
+
}
|
| 1242 |
+
|
| 1243 |
+
private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[;
|
| 1244 |
+
private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;
|
| 1245 |
+
|
| 1246 |
+
]b4_parser_tables_define[
|
| 1247 |
+
|
| 1248 |
+
]b4_parse_trace_if([[
|
| 1249 |
+
]b4_integral_parser_table_define([rline], [b4_rline],
|
| 1250 |
+
[[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
|
| 1251 |
+
|
| 1252 |
+
|
| 1253 |
+
// Report on the debug stream that the rule yyrule is going to be reduced.
|
| 1254 |
+
private void yyReducePrint (int yyrule, YYStack yystack)
|
| 1255 |
+
{
|
| 1256 |
+
if (yydebug == 0)
|
| 1257 |
+
return;
|
| 1258 |
+
|
| 1259 |
+
int yylno = yyrline_[yyrule];
|
| 1260 |
+
int yynrhs = yyr2_[yyrule];
|
| 1261 |
+
/* Print the symbols being reduced, and their result. */
|
| 1262 |
+
yycdebug ("Reducing stack by rule " + (yyrule - 1)
|
| 1263 |
+
+ " (line " + yylno + "):");
|
| 1264 |
+
|
| 1265 |
+
/* The symbols being reduced. */
|
| 1266 |
+
for (int yyi = 0; yyi < yynrhs; yyi++)
|
| 1267 |
+
yySymbolPrint(" $" + (yyi + 1) + " =",
|
| 1268 |
+
SymbolKind.get(yystos_[yystack.stateAt(yynrhs - (yyi + 1))]),
|
| 1269 |
+
]b4_rhs_data(yynrhs, yyi + 1)b4_locations_if([,
|
| 1270 |
+
b4_rhs_location(yynrhs, yyi + 1)])[);
|
| 1271 |
+
}]])[
|
| 1272 |
+
|
| 1273 |
+
/* YYTRANSLATE_(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
|
| 1274 |
+
as returned by yylex, with out-of-bounds checking. */
|
| 1275 |
+
private static final SymbolKind yytranslate_(int t)
|
| 1276 |
+
]b4_api_token_raw_if(dnl
|
| 1277 |
+
[[ {
|
| 1278 |
+
return SymbolKind.get(t);
|
| 1279 |
+
}
|
| 1280 |
+
]],
|
| 1281 |
+
[[ {
|
| 1282 |
+
// Last valid token kind.
|
| 1283 |
+
int code_max = ]b4_code_max[;
|
| 1284 |
+
if (t <= 0)
|
| 1285 |
+
return ]b4_symbol(eof, kind)[;
|
| 1286 |
+
else if (t <= code_max)
|
| 1287 |
+
return SymbolKind.get(yytranslate_table_[t]);
|
| 1288 |
+
else
|
| 1289 |
+
return ]b4_symbol(undef, kind)[;
|
| 1290 |
+
}
|
| 1291 |
+
]b4_integral_parser_table_define([translate_table], [b4_translate])[
|
| 1292 |
+
]])[
|
| 1293 |
+
|
| 1294 |
+
private static final int YYLAST_ = ]b4_last[;
|
| 1295 |
+
private static final int YYEMPTY_ = -2;
|
| 1296 |
+
private static final int YYFINAL_ = ]b4_final_state_number[;
|
| 1297 |
+
private static final int YYNTOKENS_ = ]b4_tokens_number[;
|
| 1298 |
+
|
| 1299 |
+
]b4_percent_code_get[
|
| 1300 |
+
}
|
| 1301 |
+
]b4_percent_code_get([[epilogue]])[]dnl
|
| 1302 |
+
b4_epilogue[]dnl
|
| 1303 |
+
b4_output_end
|
platform/dbops/binaries/build/share/bison/skeletons/location.cc
ADDED
|
@@ -0,0 +1,380 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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istribute it and/or modify
|
| 6 |
+
# it under the terms of the GNU General Public License as published by
|
| 7 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 8 |
+
# (at your option) any later version.
|
| 9 |
+
#
|
| 10 |
+
# This program is distributed in the hope that it will be useful,
|
| 11 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 13 |
+
# GNU General Public License for more details.
|
| 14 |
+
#
|
| 15 |
+
# You should have received a copy of the GNU General Public License
|
| 16 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 17 |
+
|
| 18 |
+
m4_pushdef([b4_copyright_years],
|
| 19 |
+
[2002-2015, 2018-2021])
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
# b4_location_file
|
| 23 |
+
# ----------------
|
| 24 |
+
# Name of the file containing the position/location class,
|
| 25 |
+
# if we want this file.
|
| 26 |
+
b4_percent_define_check_file([b4_location_file],
|
| 27 |
+
[[api.location.file]],
|
| 28 |
+
b4_header_if([[location.hh]]))
|
| 29 |
+
|
| 30 |
+
# b4_location_include
|
| 31 |
+
# -------------------
|
| 32 |
+
# If location.hh is to be generated, the name under which should it be
|
| 33 |
+
# included.
|
| 34 |
+
#
|
| 35 |
+
# b4_location_path
|
| 36 |
+
# ----------------
|
| 37 |
+
# The path to use for the CPP guard.
|
| 38 |
+
m4_ifdef([b4_location_file],
|
| 39 |
+
[m4_define([b4_location_include],
|
| 40 |
+
[b4_percent_define_get([[api.location.include]],
|
| 41 |
+
["b4_location_file"])])
|
| 42 |
+
m4_define([b4_location_path],
|
| 43 |
+
b4_percent_define_get([[api.location.include]],
|
| 44 |
+
["b4_mapped_dir_prefix[]b4_location_file"]))
|
| 45 |
+
m4_define([b4_location_path],
|
| 46 |
+
m4_substr(m4_defn([b4_location_path]), 1, m4_eval(m4_len(m4_defn([b4_location_path])) - 2)))
|
| 47 |
+
])
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
# b4_position_file
|
| 51 |
+
# ----------------
|
| 52 |
+
# Name of the file containing the position class, if we want this file.
|
| 53 |
+
b4_header_if(
|
| 54 |
+
[b4_required_version_if(
|
| 55 |
+
[30200], [],
|
| 56 |
+
[m4_ifdef([b4_location_file],
|
| 57 |
+
[m4_define([b4_position_file], [position.hh])])])])
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
# b4_location_define
|
| 62 |
+
# ------------------
|
| 63 |
+
# Define the position and location classes.
|
| 64 |
+
m4_define([b4_location_define],
|
| 65 |
+
[[ /// A point in a source file.
|
| 66 |
+
class position
|
| 67 |
+
{
|
| 68 |
+
public:
|
| 69 |
+
/// Type for file name.
|
| 70 |
+
typedef ]b4_percent_define_get([[api.filename.type]])[ filename_type;
|
| 71 |
+
/// Type for line and column numbers.
|
| 72 |
+
typedef int counter_type;
|
| 73 |
+
]m4_ifdef([b4_location_constructors], [[
|
| 74 |
+
/// Construct a position.
|
| 75 |
+
explicit position (filename_type* f = YY_NULLPTR,
|
| 76 |
+
counter_type l = ]b4_location_initial_line[,
|
| 77 |
+
counter_type c = ]b4_location_initial_column[)
|
| 78 |
+
: filename (f)
|
| 79 |
+
, line (l)
|
| 80 |
+
, column (c)
|
| 81 |
+
{}
|
| 82 |
+
|
| 83 |
+
]])[
|
| 84 |
+
/// Initialization.
|
| 85 |
+
void initialize (filename_type* fn = YY_NULLPTR,
|
| 86 |
+
counter_type l = ]b4_location_initial_line[,
|
| 87 |
+
counter_type c = ]b4_location_initial_column[)
|
| 88 |
+
{
|
| 89 |
+
filename = fn;
|
| 90 |
+
line = l;
|
| 91 |
+
column = c;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/** \name Line and Column related manipulators
|
| 95 |
+
** \{ */
|
| 96 |
+
/// (line related) Advance to the COUNT next lines.
|
| 97 |
+
void lines (counter_type count = 1)
|
| 98 |
+
{
|
| 99 |
+
if (count)
|
| 100 |
+
{
|
| 101 |
+
column = ]b4_location_initial_column[;
|
| 102 |
+
line = add_ (line, count, ]b4_location_initial_line[);
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/// (column related) Advance to the COUNT next columns.
|
| 107 |
+
void columns (counter_type count = 1)
|
| 108 |
+
{
|
| 109 |
+
column = add_ (column, count, ]b4_location_initial_column[);
|
| 110 |
+
}
|
| 111 |
+
/** \} */
|
| 112 |
+
|
| 113 |
+
/// File name to which this position refers.
|
| 114 |
+
filename_type* filename;
|
| 115 |
+
/// Current line number.
|
| 116 |
+
counter_type line;
|
| 117 |
+
/// Current column number.
|
| 118 |
+
counter_type column;
|
| 119 |
+
|
| 120 |
+
private:
|
| 121 |
+
/// Compute max (min, lhs+rhs).
|
| 122 |
+
static counter_type add_ (counter_type lhs, counter_type rhs, counter_type min)
|
| 123 |
+
{
|
| 124 |
+
return lhs + rhs < min ? min : lhs + rhs;
|
| 125 |
+
}
|
| 126 |
+
};
|
| 127 |
+
|
| 128 |
+
/// Add \a width columns, in place.
|
| 129 |
+
inline position&
|
| 130 |
+
operator+= (position& res, position::counter_type width)
|
| 131 |
+
{
|
| 132 |
+
res.columns (width);
|
| 133 |
+
return res;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
/// Add \a width columns.
|
| 137 |
+
inline position
|
| 138 |
+
operator+ (position res, position::counter_type width)
|
| 139 |
+
{
|
| 140 |
+
return res += width;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
/// Subtract \a width columns, in place.
|
| 144 |
+
inline position&
|
| 145 |
+
operator-= (position& res, position::counter_type width)
|
| 146 |
+
{
|
| 147 |
+
return res += -width;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
/// Subtract \a width columns.
|
| 151 |
+
inline position
|
| 152 |
+
operator- (position res, position::counter_type width)
|
| 153 |
+
{
|
| 154 |
+
return res -= width;
|
| 155 |
+
}
|
| 156 |
+
]b4_percent_define_flag_if([[define_location_comparison]], [[
|
| 157 |
+
/// Compare two position objects.
|
| 158 |
+
inline bool
|
| 159 |
+
operator== (const position& pos1, const position& pos2)
|
| 160 |
+
{
|
| 161 |
+
return (pos1.line == pos2.line
|
| 162 |
+
&& pos1.column == pos2.column
|
| 163 |
+
&& (pos1.filename == pos2.filename
|
| 164 |
+
|| (pos1.filename && pos2.filename
|
| 165 |
+
&& *pos1.filename == *pos2.filename)));
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
/// Compare two position objects.
|
| 169 |
+
inline bool
|
| 170 |
+
operator!= (const position& pos1, const position& pos2)
|
| 171 |
+
{
|
| 172 |
+
return !(pos1 == pos2);
|
| 173 |
+
}
|
| 174 |
+
]])[
|
| 175 |
+
/** \brief Intercept output stream redirection.
|
| 176 |
+
** \param ostr the destination output stream
|
| 177 |
+
** \param pos a reference to the position to redirect
|
| 178 |
+
*/
|
| 179 |
+
template <typename YYChar>
|
| 180 |
+
std::basic_ostream<YYChar>&
|
| 181 |
+
operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)
|
| 182 |
+
{
|
| 183 |
+
if (pos.filename)
|
| 184 |
+
ostr << *pos.filename << ':';
|
| 185 |
+
return ostr << pos.line << '.' << pos.column;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
/// Two points in a source file.
|
| 189 |
+
class location
|
| 190 |
+
{
|
| 191 |
+
public:
|
| 192 |
+
/// Type for file name.
|
| 193 |
+
typedef position::filename_type filename_type;
|
| 194 |
+
/// Type for line and column numbers.
|
| 195 |
+
typedef position::counter_type counter_type;
|
| 196 |
+
]m4_ifdef([b4_location_constructors], [
|
| 197 |
+
/// Construct a location from \a b to \a e.
|
| 198 |
+
location (const position& b, const position& e)
|
| 199 |
+
: begin (b)
|
| 200 |
+
, end (e)
|
| 201 |
+
{}
|
| 202 |
+
|
| 203 |
+
/// Construct a 0-width location in \a p.
|
| 204 |
+
explicit location (const position& p = position ())
|
| 205 |
+
: begin (p)
|
| 206 |
+
, end (p)
|
| 207 |
+
{}
|
| 208 |
+
|
| 209 |
+
/// Construct a 0-width location in \a f, \a l, \a c.
|
| 210 |
+
explicit location (filename_type* f,
|
| 211 |
+
counter_type l = ]b4_location_initial_line[,
|
| 212 |
+
counter_type c = ]b4_location_initial_column[)
|
| 213 |
+
: begin (f, l, c)
|
| 214 |
+
, end (f, l, c)
|
| 215 |
+
{}
|
| 216 |
+
|
| 217 |
+
])[
|
| 218 |
+
/// Initialization.
|
| 219 |
+
void initialize (filename_type* f = YY_NULLPTR,
|
| 220 |
+
counter_type l = ]b4_location_initial_line[,
|
| 221 |
+
counter_type c = ]b4_location_initial_column[)
|
| 222 |
+
{
|
| 223 |
+
begin.initialize (f, l, c);
|
| 224 |
+
end = begin;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
/** \name Line and Column related manipulators
|
| 228 |
+
** \{ */
|
| 229 |
+
public:
|
| 230 |
+
/// Reset initial location to final location.
|
| 231 |
+
void step ()
|
| 232 |
+
{
|
| 233 |
+
begin = end;
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
/// Extend the current location to the COUNT next columns.
|
| 237 |
+
void columns (counter_type count = 1)
|
| 238 |
+
{
|
| 239 |
+
end += count;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
/// Extend the current location to the COUNT next lines.
|
| 243 |
+
void lines (counter_type count = 1)
|
| 244 |
+
{
|
| 245 |
+
end.lines (count);
|
| 246 |
+
}
|
| 247 |
+
/** \} */
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
public:
|
| 251 |
+
/// Beginning of the located region.
|
| 252 |
+
position begin;
|
| 253 |
+
/// End of the located region.
|
| 254 |
+
position end;
|
| 255 |
+
};
|
| 256 |
+
|
| 257 |
+
/// Join two locations, in place.
|
| 258 |
+
inline location&
|
| 259 |
+
operator+= (location& res, const location& end)
|
| 260 |
+
{
|
| 261 |
+
res.end = end.end;
|
| 262 |
+
return res;
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
/// Join two locations.
|
| 266 |
+
inline location
|
| 267 |
+
operator+ (location res, const location& end)
|
| 268 |
+
{
|
| 269 |
+
return res += end;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
/// Add \a width columns to the end position, in place.
|
| 273 |
+
inline location&
|
| 274 |
+
operator+= (location& res, location::counter_type width)
|
| 275 |
+
{
|
| 276 |
+
res.columns (width);
|
| 277 |
+
return res;
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
/// Add \a width columns to the end position.
|
| 281 |
+
inline location
|
| 282 |
+
operator+ (location res, location::counter_type width)
|
| 283 |
+
{
|
| 284 |
+
return res += width;
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
/// Subtract \a width columns to the end position, in place.
|
| 288 |
+
inline location&
|
| 289 |
+
operator-= (location& res, location::counter_type width)
|
| 290 |
+
{
|
| 291 |
+
return res += -width;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
/// Subtract \a width columns to the end position.
|
| 295 |
+
inline location
|
| 296 |
+
operator- (location res, location::counter_type width)
|
| 297 |
+
{
|
| 298 |
+
return res -= width;
|
| 299 |
+
}
|
| 300 |
+
]b4_percent_define_flag_if([[define_location_comparison]], [[
|
| 301 |
+
/// Compare two location objects.
|
| 302 |
+
inline bool
|
| 303 |
+
operator== (const location& loc1, const location& loc2)
|
| 304 |
+
{
|
| 305 |
+
return loc1.begin == loc2.begin && loc1.end == loc2.end;
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
/// Compare two location objects.
|
| 309 |
+
inline bool
|
| 310 |
+
operator!= (const location& loc1, const location& loc2)
|
| 311 |
+
{
|
| 312 |
+
return !(loc1 == loc2);
|
| 313 |
+
}
|
| 314 |
+
]])[
|
| 315 |
+
/** \brief Intercept output stream redirection.
|
| 316 |
+
** \param ostr the destination output stream
|
| 317 |
+
** \param loc a reference to the location to redirect
|
| 318 |
+
**
|
| 319 |
+
** Avoid duplicate information.
|
| 320 |
+
*/
|
| 321 |
+
template <typename YYChar>
|
| 322 |
+
std::basic_ostream<YYChar>&
|
| 323 |
+
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
| 324 |
+
{
|
| 325 |
+
location::counter_type end_col
|
| 326 |
+
= 0 < loc.end.column ? loc.end.column - 1 : 0;
|
| 327 |
+
ostr << loc.begin;
|
| 328 |
+
if (loc.end.filename
|
| 329 |
+
&& (!loc.begin.filename
|
| 330 |
+
|| *loc.begin.filename != *loc.end.filename))
|
| 331 |
+
ostr << '-' << loc.end.filename << ':' << loc.end.line << '.' << end_col;
|
| 332 |
+
else if (loc.begin.line < loc.end.line)
|
| 333 |
+
ostr << '-' << loc.end.line << '.' << end_col;
|
| 334 |
+
else if (loc.begin.column < end_col)
|
| 335 |
+
ostr << '-' << end_col;
|
| 336 |
+
return ostr;
|
| 337 |
+
}
|
| 338 |
+
]])
|
| 339 |
+
|
| 340 |
+
|
| 341 |
+
m4_ifdef([b4_position_file], [[
|
| 342 |
+
]b4_output_begin([b4_dir_prefix], [b4_position_file])[
|
| 343 |
+
]b4_generated_by[
|
| 344 |
+
// Starting with Bison 3.2, this file is useless: the structure it
|
| 345 |
+
// used to define is now defined in "]b4_location_file[".
|
| 346 |
+
//
|
| 347 |
+
// To get rid of this file:
|
| 348 |
+
// 1. add '%require "3.2"' (or newer) to your grammar file
|
| 349 |
+
// 2. remove references to this file from your build system
|
| 350 |
+
// 3. if you used to include it, include "]b4_location_file[" instead.
|
| 351 |
+
|
| 352 |
+
#include ]b4_location_include[
|
| 353 |
+
]b4_output_end[
|
| 354 |
+
]])
|
| 355 |
+
|
| 356 |
+
|
| 357 |
+
m4_ifdef([b4_location_file], [[
|
| 358 |
+
]b4_output_begin([b4_dir_prefix], [b4_location_file])[
|
| 359 |
+
]b4_copyright([Locations for Bison parsers in C++])[
|
| 360 |
+
/**
|
| 361 |
+
** \file ]b4_location_path[
|
| 362 |
+
** Define the ]b4_namespace_ref[::location class.
|
| 363 |
+
*/
|
| 364 |
+
|
| 365 |
+
]b4_cpp_guard_open([b4_location_path])[
|
| 366 |
+
|
| 367 |
+
# include <iostream>
|
| 368 |
+
# include <string>
|
| 369 |
+
|
| 370 |
+
]b4_null_define[
|
| 371 |
+
|
| 372 |
+
]b4_namespace_open[
|
| 373 |
+
]b4_location_define[
|
| 374 |
+
]b4_namespace_close[
|
| 375 |
+
]b4_cpp_guard_close([b4_location_path])[
|
| 376 |
+
]b4_output_end[
|
| 377 |
+
]])
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
m4_popdef([b4_copyright_years])
|
platform/dbops/binaries/build/share/bison/skeletons/stack.hh
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# C++ skeleton for Bison
|
| 2 |
+
|
| 3 |
+
# Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc.
|
| 4 |
+
|
| 5 |
+
# This program is free software: you can redistribute it and/or modify
|
| 6 |
+
# it under the terms of the GNU General Public License as published by
|
| 7 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 8 |
+
# (at your option) any later version.
|
| 9 |
+
#
|
| 10 |
+
# This program is distributed in the hope that it will be useful,
|
| 11 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 13 |
+
# GNU General Public License for more details.
|
| 14 |
+
#
|
| 15 |
+
# You should have received a copy of the GNU General Public License
|
| 16 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# b4_stack_file
|
| 20 |
+
# -------------
|
| 21 |
+
# Name of the file containing the stack class, if we want this file.
|
| 22 |
+
b4_header_if([b4_required_version_if([30200], [],
|
| 23 |
+
[m4_define([b4_stack_file], [stack.hh])])])
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
# b4_stack_define
|
| 27 |
+
# ---------------
|
| 28 |
+
m4_define([b4_stack_define],
|
| 29 |
+
[[ /// A stack with random access from its top.
|
| 30 |
+
template <typename T, typename S = std::vector<T> >
|
| 31 |
+
class stack
|
| 32 |
+
{
|
| 33 |
+
public:
|
| 34 |
+
// Hide our reversed order.
|
| 35 |
+
typedef typename S::iterator iterator;
|
| 36 |
+
typedef typename S::const_iterator const_iterator;
|
| 37 |
+
typedef typename S::size_type size_type;
|
| 38 |
+
typedef typename std::ptrdiff_t index_type;
|
| 39 |
+
|
| 40 |
+
stack (size_type n = 200) YY_NOEXCEPT
|
| 41 |
+
: seq_ (n)
|
| 42 |
+
{}
|
| 43 |
+
|
| 44 |
+
#if 201103L <= YY_CPLUSPLUS
|
| 45 |
+
/// Non copyable.
|
| 46 |
+
stack (const stack&) = delete;
|
| 47 |
+
/// Non copyable.
|
| 48 |
+
stack& operator= (const stack&) = delete;
|
| 49 |
+
#endif
|
| 50 |
+
|
| 51 |
+
/// Random access.
|
| 52 |
+
///
|
| 53 |
+
/// Index 0 returns the topmost element.
|
| 54 |
+
const T&
|
| 55 |
+
operator[] (index_type i) const
|
| 56 |
+
{
|
| 57 |
+
return seq_[size_type (size () - 1 - i)];
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
/// Random access.
|
| 61 |
+
///
|
| 62 |
+
/// Index 0 returns the topmost element.
|
| 63 |
+
T&
|
| 64 |
+
operator[] (index_type i)
|
| 65 |
+
{
|
| 66 |
+
return seq_[size_type (size () - 1 - i)];
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/// Steal the contents of \a t.
|
| 70 |
+
///
|
| 71 |
+
/// Close to move-semantics.
|
| 72 |
+
void
|
| 73 |
+
push (YY_MOVE_REF (T) t)
|
| 74 |
+
{
|
| 75 |
+
seq_.push_back (T ());
|
| 76 |
+
operator[] (0).move (t);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/// Pop elements from the stack.
|
| 80 |
+
void
|
| 81 |
+
pop (std::ptrdiff_t n = 1) YY_NOEXCEPT
|
| 82 |
+
{
|
| 83 |
+
for (; 0 < n; --n)
|
| 84 |
+
seq_.pop_back ();
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/// Pop all elements from the stack.
|
| 88 |
+
void
|
| 89 |
+
clear () YY_NOEXCEPT
|
| 90 |
+
{
|
| 91 |
+
seq_.clear ();
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/// Number of elements on the stack.
|
| 95 |
+
index_type
|
| 96 |
+
size () const YY_NOEXCEPT
|
| 97 |
+
{
|
| 98 |
+
return index_type (seq_.size ());
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/// Iterator on top of the stack (going downwards).
|
| 102 |
+
const_iterator
|
| 103 |
+
begin () const YY_NOEXCEPT
|
| 104 |
+
{
|
| 105 |
+
return seq_.begin ();
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
/// Bottom of the stack.
|
| 109 |
+
const_iterator
|
| 110 |
+
end () const YY_NOEXCEPT
|
| 111 |
+
{
|
| 112 |
+
return seq_.end ();
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
/// Present a slice of the top of a stack.
|
| 116 |
+
class slice
|
| 117 |
+
{
|
| 118 |
+
public:
|
| 119 |
+
slice (const stack& stack, index_type range) YY_NOEXCEPT
|
| 120 |
+
: stack_ (stack)
|
| 121 |
+
, range_ (range)
|
| 122 |
+
{}
|
| 123 |
+
|
| 124 |
+
const T&
|
| 125 |
+
operator[] (index_type i) const
|
| 126 |
+
{
|
| 127 |
+
return stack_[range_ - i];
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
private:
|
| 131 |
+
const stack& stack_;
|
| 132 |
+
index_type range_;
|
| 133 |
+
};
|
| 134 |
+
|
| 135 |
+
private:
|
| 136 |
+
#if YY_CPLUSPLUS < 201103L
|
| 137 |
+
/// Non copyable.
|
| 138 |
+
stack (const stack&);
|
| 139 |
+
/// Non copyable.
|
| 140 |
+
stack& operator= (const stack&);
|
| 141 |
+
#endif
|
| 142 |
+
/// The wrapped container.
|
| 143 |
+
S seq_;
|
| 144 |
+
};
|
| 145 |
+
]])
|
| 146 |
+
|
| 147 |
+
m4_ifdef([b4_stack_file],
|
| 148 |
+
[b4_output_begin([b4_dir_prefix], [b4_stack_file])[
|
| 149 |
+
]b4_generated_by[
|
| 150 |
+
// Starting with Bison 3.2, this file is useless: the structure it
|
| 151 |
+
// used to define is now defined with the parser itself.
|
| 152 |
+
//
|
| 153 |
+
// To get rid of this file:
|
| 154 |
+
// 1. add '%require "3.2"' (or newer) to your grammar file
|
| 155 |
+
// 2. remove references to this file from your build system.
|
| 156 |
+
]b4_output_end[
|
| 157 |
+
]])
|
platform/dbops/binaries/build/share/bison/skeletons/traceon.m4
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
dnl GNU M4 treats -dV in a position-independent manner.
|
| 2 |
+
m4_debugmode(V)m4_traceon()dnl
|
platform/dbops/binaries/build/share/bison/skeletons/variant.hh
ADDED
|
@@ -0,0 +1,525 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# C++ skeleton for Bison
|
| 2 |
+
|
| 3 |
+
# Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc.
|
| 4 |
+
|
| 5 |
+
# This program is free software: you can redistribute it and/or modify
|
| 6 |
+
# it under the terms of the GNU General Public License as published by
|
| 7 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 8 |
+
# (at your option) any later version.
|
| 9 |
+
#
|
| 10 |
+
# This program is distributed in the hope that it will be useful,
|
| 11 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 13 |
+
# GNU General Public License for more details.
|
| 14 |
+
#
|
| 15 |
+
# You should have received a copy of the GNU General Public License
|
| 16 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
## --------- ##
|
| 20 |
+
## variant. ##
|
| 21 |
+
## --------- ##
|
| 22 |
+
|
| 23 |
+
# b4_assert
|
| 24 |
+
# ---------
|
| 25 |
+
# The name of YY_ASSERT.
|
| 26 |
+
m4_define([b4_assert],
|
| 27 |
+
[b4_api_PREFIX[]_ASSERT])
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
# b4_symbol_variant(YYTYPE, YYVAL, ACTION, [ARGS])
|
| 31 |
+
# ------------------------------------------------
|
| 32 |
+
# Run some ACTION ("build", or "destroy") on YYVAL of symbol type
|
| 33 |
+
# YYTYPE.
|
| 34 |
+
m4_define([b4_symbol_variant],
|
| 35 |
+
[m4_pushdef([b4_dollar_dollar],
|
| 36 |
+
[$2.$3< $][3 > (m4_shift3($@))])dnl
|
| 37 |
+
switch ($1)
|
| 38 |
+
{
|
| 39 |
+
b4_type_foreach([_b4_type_action])[]dnl
|
| 40 |
+
default:
|
| 41 |
+
break;
|
| 42 |
+
}
|
| 43 |
+
m4_popdef([b4_dollar_dollar])dnl
|
| 44 |
+
])
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
# _b4_char_sizeof_counter
|
| 48 |
+
# -----------------------
|
| 49 |
+
# A counter used by _b4_char_sizeof_dummy to create fresh symbols.
|
| 50 |
+
m4_define([_b4_char_sizeof_counter],
|
| 51 |
+
[0])
|
| 52 |
+
|
| 53 |
+
# _b4_char_sizeof_dummy
|
| 54 |
+
# ---------------------
|
| 55 |
+
# At each call return a new C++ identifier.
|
| 56 |
+
m4_define([_b4_char_sizeof_dummy],
|
| 57 |
+
[m4_define([_b4_char_sizeof_counter], m4_incr(_b4_char_sizeof_counter))dnl
|
| 58 |
+
dummy[]_b4_char_sizeof_counter])
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
# b4_char_sizeof(SYMBOL-NUMS)
|
| 62 |
+
# ---------------------------
|
| 63 |
+
# To be mapped on the list of type names to produce:
|
| 64 |
+
#
|
| 65 |
+
# char dummy1[sizeof (type_name_1)];
|
| 66 |
+
# char dummy2[sizeof (type_name_2)];
|
| 67 |
+
#
|
| 68 |
+
# for defined type names.
|
| 69 |
+
m4_define([b4_char_sizeof],
|
| 70 |
+
[b4_symbol_if([$1], [has_type],
|
| 71 |
+
[
|
| 72 |
+
m4_map([ b4_symbol_tag_comment], [$@])dnl
|
| 73 |
+
char _b4_char_sizeof_dummy@{sizeof (b4_symbol([$1], [type]))@};
|
| 74 |
+
])])
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
# b4_variant_includes
|
| 78 |
+
# -------------------
|
| 79 |
+
# The needed includes for variants support.
|
| 80 |
+
m4_define([b4_variant_includes],
|
| 81 |
+
[b4_parse_assert_if([[#include <typeinfo>
|
| 82 |
+
#ifndef ]b4_assert[
|
| 83 |
+
# include <cassert>
|
| 84 |
+
# define ]b4_assert[ assert
|
| 85 |
+
#endif
|
| 86 |
+
]])])
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
## -------------------------- ##
|
| 91 |
+
## Adjustments for variants. ##
|
| 92 |
+
## -------------------------- ##
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
# b4_value_type_declare
|
| 96 |
+
# ---------------------
|
| 97 |
+
# Define value_type.
|
| 98 |
+
m4_define([b4_value_type_declare],
|
| 99 |
+
[[ /// A buffer to store and retrieve objects.
|
| 100 |
+
///
|
| 101 |
+
/// Sort of a variant, but does not keep track of the nature
|
| 102 |
+
/// of the stored data, since that knowledge is available
|
| 103 |
+
/// via the current parser state.
|
| 104 |
+
class value_type
|
| 105 |
+
{
|
| 106 |
+
public:
|
| 107 |
+
/// Type of *this.
|
| 108 |
+
typedef value_type self_type;
|
| 109 |
+
|
| 110 |
+
/// Empty construction.
|
| 111 |
+
value_type () YY_NOEXCEPT
|
| 112 |
+
: yyraw_ ()]b4_parse_assert_if([
|
| 113 |
+
, yytypeid_ (YY_NULLPTR)])[
|
| 114 |
+
{}
|
| 115 |
+
|
| 116 |
+
/// Construct and fill.
|
| 117 |
+
template <typename T>
|
| 118 |
+
value_type (YY_RVREF (T) t)]b4_parse_assert_if([
|
| 119 |
+
: yytypeid_ (&typeid (T))])[
|
| 120 |
+
{]b4_parse_assert_if([[
|
| 121 |
+
]b4_assert[ (sizeof (T) <= size);]])[
|
| 122 |
+
new (yyas_<T> ()) T (YY_MOVE (t));
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
#if 201103L <= YY_CPLUSPLUS
|
| 126 |
+
/// Non copyable.
|
| 127 |
+
value_type (const self_type&) = delete;
|
| 128 |
+
/// Non copyable.
|
| 129 |
+
self_type& operator= (const self_type&) = delete;
|
| 130 |
+
#endif
|
| 131 |
+
|
| 132 |
+
/// Destruction, allowed only if empty.
|
| 133 |
+
~value_type () YY_NOEXCEPT
|
| 134 |
+
{]b4_parse_assert_if([
|
| 135 |
+
]b4_assert[ (!yytypeid_);
|
| 136 |
+
])[}
|
| 137 |
+
|
| 138 |
+
# if 201103L <= YY_CPLUSPLUS
|
| 139 |
+
/// Instantiate a \a T in here from \a t.
|
| 140 |
+
template <typename T, typename... U>
|
| 141 |
+
T&
|
| 142 |
+
emplace (U&&... u)
|
| 143 |
+
{]b4_parse_assert_if([[
|
| 144 |
+
]b4_assert[ (!yytypeid_);
|
| 145 |
+
]b4_assert[ (sizeof (T) <= size);
|
| 146 |
+
yytypeid_ = & typeid (T);]])[
|
| 147 |
+
return *new (yyas_<T> ()) T (std::forward <U>(u)...);
|
| 148 |
+
}
|
| 149 |
+
# else
|
| 150 |
+
/// Instantiate an empty \a T in here.
|
| 151 |
+
template <typename T>
|
| 152 |
+
T&
|
| 153 |
+
emplace ()
|
| 154 |
+
{]b4_parse_assert_if([[
|
| 155 |
+
]b4_assert[ (!yytypeid_);
|
| 156 |
+
]b4_assert[ (sizeof (T) <= size);
|
| 157 |
+
yytypeid_ = & typeid (T);]])[
|
| 158 |
+
return *new (yyas_<T> ()) T ();
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
/// Instantiate a \a T in here from \a t.
|
| 162 |
+
template <typename T>
|
| 163 |
+
T&
|
| 164 |
+
emplace (const T& t)
|
| 165 |
+
{]b4_parse_assert_if([[
|
| 166 |
+
]b4_assert[ (!yytypeid_);
|
| 167 |
+
]b4_assert[ (sizeof (T) <= size);
|
| 168 |
+
yytypeid_ = & typeid (T);]])[
|
| 169 |
+
return *new (yyas_<T> ()) T (t);
|
| 170 |
+
}
|
| 171 |
+
# endif
|
| 172 |
+
|
| 173 |
+
/// Instantiate an empty \a T in here.
|
| 174 |
+
/// Obsolete, use emplace.
|
| 175 |
+
template <typename T>
|
| 176 |
+
T&
|
| 177 |
+
build ()
|
| 178 |
+
{
|
| 179 |
+
return emplace<T> ();
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
/// Instantiate a \a T in here from \a t.
|
| 183 |
+
/// Obsolete, use emplace.
|
| 184 |
+
template <typename T>
|
| 185 |
+
T&
|
| 186 |
+
build (const T& t)
|
| 187 |
+
{
|
| 188 |
+
return emplace<T> (t);
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
/// Accessor to a built \a T.
|
| 192 |
+
template <typename T>
|
| 193 |
+
T&
|
| 194 |
+
as () YY_NOEXCEPT
|
| 195 |
+
{]b4_parse_assert_if([[
|
| 196 |
+
]b4_assert[ (yytypeid_);
|
| 197 |
+
]b4_assert[ (*yytypeid_ == typeid (T));
|
| 198 |
+
]b4_assert[ (sizeof (T) <= size);]])[
|
| 199 |
+
return *yyas_<T> ();
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
/// Const accessor to a built \a T (for %printer).
|
| 203 |
+
template <typename T>
|
| 204 |
+
const T&
|
| 205 |
+
as () const YY_NOEXCEPT
|
| 206 |
+
{]b4_parse_assert_if([[
|
| 207 |
+
]b4_assert[ (yytypeid_);
|
| 208 |
+
]b4_assert[ (*yytypeid_ == typeid (T));
|
| 209 |
+
]b4_assert[ (sizeof (T) <= size);]])[
|
| 210 |
+
return *yyas_<T> ();
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
/// Swap the content with \a that, of same type.
|
| 214 |
+
///
|
| 215 |
+
/// Both variants must be built beforehand, because swapping the actual
|
| 216 |
+
/// data requires reading it (with as()), and this is not possible on
|
| 217 |
+
/// unconstructed variants: it would require some dynamic testing, which
|
| 218 |
+
/// should not be the variant's responsibility.
|
| 219 |
+
/// Swapping between built and (possibly) non-built is done with
|
| 220 |
+
/// self_type::move ().
|
| 221 |
+
template <typename T>
|
| 222 |
+
void
|
| 223 |
+
swap (self_type& that) YY_NOEXCEPT
|
| 224 |
+
{]b4_parse_assert_if([[
|
| 225 |
+
]b4_assert[ (yytypeid_);
|
| 226 |
+
]b4_assert[ (*yytypeid_ == *that.yytypeid_);]])[
|
| 227 |
+
std::swap (as<T> (), that.as<T> ());
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
/// Move the content of \a that to this.
|
| 231 |
+
///
|
| 232 |
+
/// Destroys \a that.
|
| 233 |
+
template <typename T>
|
| 234 |
+
void
|
| 235 |
+
move (self_type& that)
|
| 236 |
+
{
|
| 237 |
+
# if 201103L <= YY_CPLUSPLUS
|
| 238 |
+
emplace<T> (std::move (that.as<T> ()));
|
| 239 |
+
# else
|
| 240 |
+
emplace<T> ();
|
| 241 |
+
swap<T> (that);
|
| 242 |
+
# endif
|
| 243 |
+
that.destroy<T> ();
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
# if 201103L <= YY_CPLUSPLUS
|
| 247 |
+
/// Move the content of \a that to this.
|
| 248 |
+
template <typename T>
|
| 249 |
+
void
|
| 250 |
+
move (self_type&& that)
|
| 251 |
+
{
|
| 252 |
+
emplace<T> (std::move (that.as<T> ()));
|
| 253 |
+
that.destroy<T> ();
|
| 254 |
+
}
|
| 255 |
+
#endif
|
| 256 |
+
|
| 257 |
+
/// Copy the content of \a that to this.
|
| 258 |
+
template <typename T>
|
| 259 |
+
void
|
| 260 |
+
copy (const self_type& that)
|
| 261 |
+
{
|
| 262 |
+
emplace<T> (that.as<T> ());
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
/// Destroy the stored \a T.
|
| 266 |
+
template <typename T>
|
| 267 |
+
void
|
| 268 |
+
destroy ()
|
| 269 |
+
{
|
| 270 |
+
as<T> ().~T ();]b4_parse_assert_if([
|
| 271 |
+
yytypeid_ = YY_NULLPTR;])[
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
private:
|
| 275 |
+
#if YY_CPLUSPLUS < 201103L
|
| 276 |
+
/// Non copyable.
|
| 277 |
+
value_type (const self_type&);
|
| 278 |
+
/// Non copyable.
|
| 279 |
+
self_type& operator= (const self_type&);
|
| 280 |
+
#endif
|
| 281 |
+
|
| 282 |
+
/// Accessor to raw memory as \a T.
|
| 283 |
+
template <typename T>
|
| 284 |
+
T*
|
| 285 |
+
yyas_ () YY_NOEXCEPT
|
| 286 |
+
{
|
| 287 |
+
void *yyp = yyraw_;
|
| 288 |
+
return static_cast<T*> (yyp);
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
/// Const accessor to raw memory as \a T.
|
| 292 |
+
template <typename T>
|
| 293 |
+
const T*
|
| 294 |
+
yyas_ () const YY_NOEXCEPT
|
| 295 |
+
{
|
| 296 |
+
const void *yyp = yyraw_;
|
| 297 |
+
return static_cast<const T*> (yyp);
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
/// An auxiliary type to compute the largest semantic type.
|
| 301 |
+
union union_type
|
| 302 |
+
{]b4_type_foreach([b4_char_sizeof])[ };
|
| 303 |
+
|
| 304 |
+
/// The size of the largest semantic type.
|
| 305 |
+
enum { size = sizeof (union_type) };
|
| 306 |
+
|
| 307 |
+
/// A buffer to store semantic values.
|
| 308 |
+
union
|
| 309 |
+
{
|
| 310 |
+
/// Strongest alignment constraints.
|
| 311 |
+
long double yyalign_me_;
|
| 312 |
+
/// A buffer large enough to store any of the semantic values.
|
| 313 |
+
char yyraw_[size];
|
| 314 |
+
};]b4_parse_assert_if([
|
| 315 |
+
|
| 316 |
+
/// Whether the content is built: if defined, the name of the stored type.
|
| 317 |
+
const std::type_info *yytypeid_;])[
|
| 318 |
+
};
|
| 319 |
+
]])
|
| 320 |
+
|
| 321 |
+
|
| 322 |
+
# How the semantic value is extracted when using variants.
|
| 323 |
+
|
| 324 |
+
# b4_symbol_value(VAL, SYMBOL-NUM, [TYPE])
|
| 325 |
+
# ----------------------------------------
|
| 326 |
+
# See README.
|
| 327 |
+
m4_define([b4_symbol_value],
|
| 328 |
+
[m4_ifval([$3],
|
| 329 |
+
[$1.as< $3 > ()],
|
| 330 |
+
[m4_ifval([$2],
|
| 331 |
+
[b4_symbol_if([$2], [has_type],
|
| 332 |
+
[$1.as < b4_symbol([$2], [type]) > ()],
|
| 333 |
+
[$1])],
|
| 334 |
+
[$1])])])
|
| 335 |
+
|
| 336 |
+
# b4_symbol_value_template(VAL, SYMBOL-NUM, [TYPE])
|
| 337 |
+
# -------------------------------------------------
|
| 338 |
+
# Same as b4_symbol_value, but used in a template method.
|
| 339 |
+
m4_define([b4_symbol_value_template],
|
| 340 |
+
[m4_ifval([$3],
|
| 341 |
+
[$1.template as< $3 > ()],
|
| 342 |
+
[m4_ifval([$2],
|
| 343 |
+
[b4_symbol_if([$2], [has_type],
|
| 344 |
+
[$1.template as < b4_symbol([$2], [type]) > ()],
|
| 345 |
+
[$1])],
|
| 346 |
+
[$1])])])
|
| 347 |
+
|
| 348 |
+
|
| 349 |
+
|
| 350 |
+
## ------------- ##
|
| 351 |
+
## make_SYMBOL. ##
|
| 352 |
+
## ------------- ##
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
# _b4_includes_tokens(SYMBOL-NUM...)
|
| 356 |
+
# ----------------------------------
|
| 357 |
+
# Expands to non-empty iff one of the SYMBOL-NUM denotes
|
| 358 |
+
# a token.
|
| 359 |
+
m4_define([_b4_is_token],
|
| 360 |
+
[b4_symbol_if([$1], [is_token], [1])])
|
| 361 |
+
m4_define([_b4_includes_tokens],
|
| 362 |
+
[m4_map([_b4_is_token], [$@])])
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
# _b4_token_maker_define(SYMBOL-NUM)
|
| 366 |
+
# ----------------------------------
|
| 367 |
+
# Declare make_SYMBOL for SYMBOL-NUM. Use at class-level.
|
| 368 |
+
m4_define([_b4_token_maker_define],
|
| 369 |
+
[b4_token_visible_if([$1],
|
| 370 |
+
[#if 201103L <= YY_CPLUSPLUS
|
| 371 |
+
static
|
| 372 |
+
symbol_type
|
| 373 |
+
make_[]_b4_symbol([$1], [id]) (b4_join(
|
| 374 |
+
b4_symbol_if([$1], [has_type],
|
| 375 |
+
[b4_symbol([$1], [type]) v]),
|
| 376 |
+
b4_locations_if([location_type l])))
|
| 377 |
+
{
|
| 378 |
+
return symbol_type (b4_join([token::b4_symbol([$1], [id])],
|
| 379 |
+
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
| 380 |
+
b4_locations_if([std::move (l)])));
|
| 381 |
+
}
|
| 382 |
+
#else
|
| 383 |
+
static
|
| 384 |
+
symbol_type
|
| 385 |
+
make_[]_b4_symbol([$1], [id]) (b4_join(
|
| 386 |
+
b4_symbol_if([$1], [has_type],
|
| 387 |
+
[const b4_symbol([$1], [type])& v]),
|
| 388 |
+
b4_locations_if([const location_type& l])))
|
| 389 |
+
{
|
| 390 |
+
return symbol_type (b4_join([token::b4_symbol([$1], [id])],
|
| 391 |
+
b4_symbol_if([$1], [has_type], [v]),
|
| 392 |
+
b4_locations_if([l])));
|
| 393 |
+
}
|
| 394 |
+
#endif
|
| 395 |
+
])])
|
| 396 |
+
|
| 397 |
+
|
| 398 |
+
# b4_token_kind(SYMBOL-NUM)
|
| 399 |
+
# -------------------------
|
| 400 |
+
# Some tokens don't have an ID.
|
| 401 |
+
m4_define([b4_token_kind],
|
| 402 |
+
[b4_symbol_if([$1], [has_id],
|
| 403 |
+
[token::b4_symbol([$1], [id])],
|
| 404 |
+
[b4_symbol([$1], [code])])])
|
| 405 |
+
|
| 406 |
+
|
| 407 |
+
# _b4_tok_in(SYMBOL-NUM, ...)
|
| 408 |
+
# ---------------------------
|
| 409 |
+
# See b4_tok_in below. The SYMBOL-NUMs... are tokens only.
|
| 410 |
+
#
|
| 411 |
+
# We iterate over the tokens to group them by "range" of token numbers (not
|
| 412 |
+
# symbols numbers!).
|
| 413 |
+
#
|
| 414 |
+
# b4_fst is the start of that range.
|
| 415 |
+
# b4_prev is the previous value.
|
| 416 |
+
# b4_val is the current value.
|
| 417 |
+
# If b4_val is the successor of b4_prev in token numbers, update the latter,
|
| 418 |
+
# otherwise emit the code for range b4_fst .. b4_prev.
|
| 419 |
+
# $1 is also used as a terminator in the foreach, but it will not be printed.
|
| 420 |
+
#
|
| 421 |
+
m4_define([_b4_tok_in],
|
| 422 |
+
[m4_pushdef([b4_prev], [$1])dnl
|
| 423 |
+
m4_pushdef([b4_fst], [$1])dnl
|
| 424 |
+
m4_pushdef([b4_sep], [])dnl
|
| 425 |
+
m4_foreach([b4_val], m4_dquote(m4_shift($@, $1)),
|
| 426 |
+
[m4_if(b4_symbol(b4_val, [code]), m4_eval(b4_symbol(b4_prev, [code]) + 1), [],
|
| 427 |
+
[b4_sep[]m4_if(b4_fst, b4_prev,
|
| 428 |
+
[tok == b4_token_kind(b4_fst)],
|
| 429 |
+
[(b4_token_kind(b4_fst) <= tok && tok <= b4_token_kind(b4_prev))])[]dnl
|
| 430 |
+
m4_define([b4_fst], b4_val)dnl
|
| 431 |
+
m4_define([b4_sep], [
|
| 432 |
+
|| ])])dnl
|
| 433 |
+
m4_define([b4_prev], b4_val)])dnl
|
| 434 |
+
m4_popdef([b4_sep])dnl
|
| 435 |
+
m4_popdef([b4_fst])dnl
|
| 436 |
+
m4_popdef([b4_prev])dnl
|
| 437 |
+
])
|
| 438 |
+
|
| 439 |
+
|
| 440 |
+
# _b4_filter_tokens(SYMBOL-NUM, ...)
|
| 441 |
+
# ----------------------------------
|
| 442 |
+
# Expand as the list of tokens amongst SYMBOL-NUM.
|
| 443 |
+
m4_define([_b4_filter_tokens],
|
| 444 |
+
[m4_pushdef([b4_sep])dnl
|
| 445 |
+
m4_foreach([b4_val], [$@],
|
| 446 |
+
[b4_symbol_if(b4_val, [is_token], [b4_sep[]b4_val[]m4_define([b4_sep], [,])])])dnl
|
| 447 |
+
m4_popdef([b4_sep])dnl
|
| 448 |
+
])
|
| 449 |
+
|
| 450 |
+
|
| 451 |
+
# b4_tok_in(SYMBOL-NUM, ...)
|
| 452 |
+
# ---------------------------
|
| 453 |
+
# A C++ conditional that checks that `tok` is a member of this list of symbol
|
| 454 |
+
# numbers.
|
| 455 |
+
m4_define([b4_tok_in],
|
| 456 |
+
[_$0(_b4_filter_tokens($@))])
|
| 457 |
+
|
| 458 |
+
|
| 459 |
+
|
| 460 |
+
|
| 461 |
+
# _b4_symbol_constructor_define(SYMBOL-NUM...)
|
| 462 |
+
# --------------------------------------------
|
| 463 |
+
# Define a symbol_type constructor common to all the SYMBOL-NUM (they
|
| 464 |
+
# have the same type). Use at class-level.
|
| 465 |
+
m4_define([_b4_symbol_constructor_define],
|
| 466 |
+
[m4_ifval(_b4_includes_tokens($@),
|
| 467 |
+
[[#if 201103L <= YY_CPLUSPLUS
|
| 468 |
+
symbol_type (]b4_join(
|
| 469 |
+
[int tok],
|
| 470 |
+
b4_symbol_if([$1], [has_type],
|
| 471 |
+
[b4_symbol([$1], [type]) v]),
|
| 472 |
+
b4_locations_if([location_type l]))[)
|
| 473 |
+
: super_type (]b4_join([token_kind_type (tok)],
|
| 474 |
+
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
| 475 |
+
b4_locations_if([std::move (l)]))[)
|
| 476 |
+
#else
|
| 477 |
+
symbol_type (]b4_join(
|
| 478 |
+
[int tok],
|
| 479 |
+
b4_symbol_if([$1], [has_type],
|
| 480 |
+
[const b4_symbol([$1], [type])& v]),
|
| 481 |
+
b4_locations_if([const location_type& l]))[)
|
| 482 |
+
: super_type (]b4_join([token_kind_type (tok)],
|
| 483 |
+
b4_symbol_if([$1], [has_type], [v]),
|
| 484 |
+
b4_locations_if([l]))[)
|
| 485 |
+
#endif
|
| 486 |
+
{]b4_parse_assert_if([[
|
| 487 |
+
#if !defined _MSC_VER || defined __clang__
|
| 488 |
+
]b4_assert[ (]b4_tok_in($@)[);
|
| 489 |
+
#endif
|
| 490 |
+
]])[}
|
| 491 |
+
]])])
|
| 492 |
+
|
| 493 |
+
|
| 494 |
+
# b4_basic_symbol_constructor_define(SYMBOL-NUM)
|
| 495 |
+
# ----------------------------------------------
|
| 496 |
+
# Generate a constructor for basic_symbol from given type.
|
| 497 |
+
m4_define([b4_basic_symbol_constructor_define],
|
| 498 |
+
[[#if 201103L <= YY_CPLUSPLUS
|
| 499 |
+
basic_symbol (]b4_join(
|
| 500 |
+
[typename Base::kind_type t],
|
| 501 |
+
b4_symbol_if([$1], [has_type], [b4_symbol([$1], [type])&& v]),
|
| 502 |
+
b4_locations_if([location_type&& l]))[)
|
| 503 |
+
: Base (t)]b4_symbol_if([$1], [has_type], [
|
| 504 |
+
, value (std::move (v))])[]b4_locations_if([
|
| 505 |
+
, location (std::move (l))])[
|
| 506 |
+
{}
|
| 507 |
+
#else
|
| 508 |
+
basic_symbol (]b4_join(
|
| 509 |
+
[typename Base::kind_type t],
|
| 510 |
+
b4_symbol_if([$1], [has_type], [const b4_symbol([$1], [type])& v]),
|
| 511 |
+
b4_locations_if([const location_type& l]))[)
|
| 512 |
+
: Base (t)]b4_symbol_if([$1], [has_type], [
|
| 513 |
+
, value (v)])[]b4_locations_if([
|
| 514 |
+
, location (l)])[
|
| 515 |
+
{}
|
| 516 |
+
#endif
|
| 517 |
+
]])
|
| 518 |
+
|
| 519 |
+
|
| 520 |
+
# b4_token_constructor_define
|
| 521 |
+
# ---------------------------
|
| 522 |
+
# Define the overloaded versions of make_FOO for all the token kinds.
|
| 523 |
+
m4_define([b4_token_constructor_define],
|
| 524 |
+
[ // Implementation of make_symbol for each token kind.
|
| 525 |
+
b4_symbol_foreach([_b4_token_maker_define])])
|
platform/dbops/binaries/build/share/bison/skeletons/yacc.c
ADDED
|
@@ -0,0 +1,2209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 7 |
+
m4_pushdef([b4_copyright_years],
|
| 8 |
+
[1984, 1989-1990, 2000-2015, 2018-2021])
|
| 9 |
+
|
| 10 |
+
# This program is free software: you can redistribute it and/or modify
|
| 11 |
+
# it under the terms of the GNU General Public License as published by
|
| 12 |
+
# the Free Software Foundation, either version 3 of the License, or
|
| 13 |
+
# (at your option) any later version.
|
| 14 |
+
#
|
| 15 |
+
# This program is distributed in the hope that it will be useful,
|
| 16 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 17 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 18 |
+
# GNU General Public License for more details.
|
| 19 |
+
#
|
| 20 |
+
# You should have received a copy of the GNU General Public License
|
| 21 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 22 |
+
|
| 23 |
+
m4_include(b4_skeletonsdir/[c.m4])
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
## ---------- ##
|
| 27 |
+
## api.pure. ##
|
| 28 |
+
## ---------- ##
|
| 29 |
+
|
| 30 |
+
b4_percent_define_default([[api.pure]], [[false]])
|
| 31 |
+
b4_percent_define_check_values([[[[api.pure]],
|
| 32 |
+
[[false]], [[true]], [[]], [[full]]]])
|
| 33 |
+
|
| 34 |
+
m4_define([b4_pure_flag], [[0]])
|
| 35 |
+
m4_case(b4_percent_define_get([[api.pure]]),
|
| 36 |
+
[false], [m4_define([b4_pure_flag], [[0]])],
|
| 37 |
+
[true], [m4_define([b4_pure_flag], [[1]])],
|
| 38 |
+
[], [m4_define([b4_pure_flag], [[1]])],
|
| 39 |
+
[full], [m4_define([b4_pure_flag], [[2]])])
|
| 40 |
+
|
| 41 |
+
m4_define([b4_pure_if],
|
| 42 |
+
[m4_case(b4_pure_flag,
|
| 43 |
+
[0], [$2],
|
| 44 |
+
[1], [$1],
|
| 45 |
+
[2], [$1])])
|
| 46 |
+
[m4_fatal([invalid api.pure value: ]$1)])])
|
| 47 |
+
|
| 48 |
+
## --------------- ##
|
| 49 |
+
## api.push-pull. ##
|
| 50 |
+
## --------------- ##
|
| 51 |
+
|
| 52 |
+
# b4_pull_if, b4_push_if
|
| 53 |
+
# ----------------------
|
| 54 |
+
# Whether the pull/push APIs are needed. Both can be enabled.
|
| 55 |
+
|
| 56 |
+
b4_percent_define_default([[api.push-pull]], [[pull]])
|
| 57 |
+
b4_percent_define_check_values([[[[api.push-pull]],
|
| 58 |
+
[[pull]], [[push]], [[both]]]])
|
| 59 |
+
b4_define_flag_if([pull]) m4_define([b4_pull_flag], [[1]])
|
| 60 |
+
b4_define_flag_if([push]) m4_define([b4_push_flag], [[1]])
|
| 61 |
+
m4_case(b4_percent_define_get([[api.push-pull]]),
|
| 62 |
+
[pull], [m4_define([b4_push_flag], [[0]])],
|
| 63 |
+
[push], [m4_define([b4_pull_flag], [[0]])])
|
| 64 |
+
|
| 65 |
+
# Handle BISON_USE_PUSH_FOR_PULL for the test suite. So that push parsing
|
| 66 |
+
# tests function as written, do not let BISON_USE_PUSH_FOR_PULL modify the
|
| 67 |
+
# behavior of Bison at all when push parsing is already requested.
|
| 68 |
+
b4_define_flag_if([use_push_for_pull])
|
| 69 |
+
b4_use_push_for_pull_if([
|
| 70 |
+
b4_push_if([m4_define([b4_use_push_for_pull_flag], [[0]])],
|
| 71 |
+
[m4_define([b4_push_flag], [[1]])])])
|
| 72 |
+
|
| 73 |
+
## ----------- ##
|
| 74 |
+
## parse.lac. ##
|
| 75 |
+
## ----------- ##
|
| 76 |
+
|
| 77 |
+
b4_percent_define_default([[parse.lac]], [[none]])
|
| 78 |
+
b4_percent_define_default([[parse.lac.es-capacity-initial]], [[20]])
|
| 79 |
+
b4_percent_define_default([[parse.lac.memory-trace]], [[failures]])
|
| 80 |
+
b4_percent_define_check_values([[[[parse.lac]], [[full]], [[none]]]],
|
| 81 |
+
[[[[parse.lac.memory-trace]],
|
| 82 |
+
[[failures]], [[full]]]])
|
| 83 |
+
b4_define_flag_if([lac])
|
| 84 |
+
m4_define([b4_lac_flag],
|
| 85 |
+
[m4_if(b4_percent_define_get([[parse.lac]]),
|
| 86 |
+
[none], [[0]], [[1]])])
|
| 87 |
+
|
| 88 |
+
## ---------------- ##
|
| 89 |
+
## Default values. ##
|
| 90 |
+
## ---------------- ##
|
| 91 |
+
|
| 92 |
+
# Stack parameters.
|
| 93 |
+
m4_define_default([b4_stack_depth_max], [10000])
|
| 94 |
+
m4_define_default([b4_stack_depth_init], [200])
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
# b4_yyerror_arg_loc_if(ARG)
|
| 98 |
+
# --------------------------
|
| 99 |
+
# Expand ARG iff yyerror is to be given a location as argument.
|
| 100 |
+
m4_define([b4_yyerror_arg_loc_if],
|
| 101 |
+
[b4_locations_if([m4_case(b4_pure_flag,
|
| 102 |
+
[1], [m4_ifset([b4_parse_param], [$1])],
|
| 103 |
+
[2], [$1])])])
|
| 104 |
+
|
| 105 |
+
# b4_yyerror_formals
|
| 106 |
+
# ------------------
|
| 107 |
+
m4_define([b4_yyerror_formals],
|
| 108 |
+
[b4_pure_if([b4_locations_if([, [[const ]b4_api_PREFIX[LTYPE *yyllocp], [&yylloc]]])[]dnl
|
| 109 |
+
m4_ifdef([b4_parse_param], [, b4_parse_param])[]dnl
|
| 110 |
+
,])dnl
|
| 111 |
+
[[const char *msg], [msg]]])
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
# b4_yyerror_args
|
| 116 |
+
# ---------------
|
| 117 |
+
# Arguments passed to yyerror: user args plus yylloc.
|
| 118 |
+
m4_define([b4_yyerror_args],
|
| 119 |
+
[b4_yyerror_arg_loc_if([&yylloc, ])dnl
|
| 120 |
+
m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])])
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
## ----------------- ##
|
| 125 |
+
## Semantic Values. ##
|
| 126 |
+
## ----------------- ##
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
# b4_accept([SYMBOL-NUM])
|
| 130 |
+
# -----------------------
|
| 131 |
+
# Used in actions of the rules of accept, the initial symbol, to call
|
| 132 |
+
# YYACCEPT. If SYMBOL-NUM is specified, run "yyvalue->SLOT = $2;"
|
| 133 |
+
# before, using the slot of SYMBOL-NUM.
|
| 134 |
+
m4_define([b4_accept],
|
| 135 |
+
[m4_ifval([$1],
|
| 136 |
+
[b4_symbol_value(yyimpl->yyvalue, [$1]) = b4_rhs_value(2, 1, [$1]); ]) YYACCEPT])
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
# b4_lhs_value(SYMBOL-NUM, [TYPE])
|
| 140 |
+
# --------------------------------
|
| 141 |
+
# See README.
|
| 142 |
+
m4_define([b4_lhs_value],
|
| 143 |
+
[b4_symbol_value(yyval, [$1], [$2])])
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
# b4_rhs_value(RULE-LENGTH, POS, [SYMBOL-NUM], [TYPE])
|
| 147 |
+
# ----------------------------------------------------
|
| 148 |
+
# See README.
|
| 149 |
+
m4_define([b4_rhs_value],
|
| 150 |
+
[b4_symbol_value([yyvsp@{b4_subtract([$2], [$1])@}], [$3], [$4])])
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
## ----------- ##
|
| 154 |
+
## Locations. ##
|
| 155 |
+
## ----------- ##
|
| 156 |
+
|
| 157 |
+
# b4_lhs_location()
|
| 158 |
+
# -----------------
|
| 159 |
+
# Expansion of @$.
|
| 160 |
+
# Overparenthetized to avoid obscure problems with "foo$$bar = foo$1bar".
|
| 161 |
+
m4_define([b4_lhs_location],
|
| 162 |
+
[(yyloc)])
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
# b4_rhs_location(RULE-LENGTH, POS)
|
| 166 |
+
# ---------------------------------
|
| 167 |
+
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
| 168 |
+
# on RHS.
|
| 169 |
+
# Overparenthetized to avoid obscure problems with "foo$$bar = foo$1bar".
|
| 170 |
+
m4_define([b4_rhs_location],
|
| 171 |
+
[(yylsp@{b4_subtract([$2], [$1])@})])
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
## -------------- ##
|
| 175 |
+
## Declarations. ##
|
| 176 |
+
## -------------- ##
|
| 177 |
+
|
| 178 |
+
# _b4_declare_sub_yyparse(START-SYMBOL-NUM, SWITCHING-TOKEN-SYMBOL-NUM)
|
| 179 |
+
# ---------------------------------------------------------------------
|
| 180 |
+
# Define the return type of the parsing function for SYMBOL-NUM, and
|
| 181 |
+
# declare its parsing function.
|
| 182 |
+
m4_define([_b4_declare_sub_yyparse],
|
| 183 |
+
[[
|
| 184 |
+
// Return type when parsing one ]_b4_symbol($1, tag)[.
|
| 185 |
+
typedef struct
|
| 186 |
+
{]b4_symbol_if([$1], [has_type], [[
|
| 187 |
+
]_b4_symbol($1, type)[ yyvalue;]])[
|
| 188 |
+
int yystatus;
|
| 189 |
+
int yynerrs;
|
| 190 |
+
} ]b4_prefix[parse_]_b4_symbol($1, id)[_t;
|
| 191 |
+
|
| 192 |
+
// Parse one ]_b4_symbol($1, tag)[.
|
| 193 |
+
]b4_prefix[parse_]_b4_symbol($1, id)[_t ]b4_prefix[parse_]_b4_symbol($1, id)[ (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[);
|
| 194 |
+
]])
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
# _b4_first_switching_token
|
| 198 |
+
# -------------------------
|
| 199 |
+
m4_define([b4_first], [$1])
|
| 200 |
+
m4_define([b4_second], [$2])
|
| 201 |
+
m4_define([_b4_first_switching_token],
|
| 202 |
+
[b4_second(b4_first(b4_start_symbols))])
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
# _b4_define_sub_yyparse(START-SYMBOL-NUM, SWITCHING-TOKEN-SYMBOL-NUM)
|
| 206 |
+
# --------------------------------------------------------------------
|
| 207 |
+
# Define the parsing function for START-SYMBOL-NUM.
|
| 208 |
+
m4_define([_b4_define_sub_yyparse],
|
| 209 |
+
[[
|
| 210 |
+
]b4_prefix[parse_]_b4_symbol($1, id)[_t
|
| 211 |
+
]b4_prefix[parse_]_b4_symbol($1, id)[ (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)
|
| 212 |
+
{
|
| 213 |
+
]b4_prefix[parse_]_b4_symbol($1, id)[_t yyres;
|
| 214 |
+
yy_parse_impl_t yyimpl;
|
| 215 |
+
yyres.yystatus = yy_parse_impl (]b4_symbol($2, id)[, &yyimpl]m4_ifset([b4_parse_param],
|
| 216 |
+
[[, ]b4_args(b4_parse_param)])[);]b4_symbol_if([$1], [has_type], [[
|
| 217 |
+
yyres.yyvalue = yyimpl.yyvalue.]b4_symbol($1, slot)[;]])[
|
| 218 |
+
yyres.yynerrs = yyimpl.yynerrs;
|
| 219 |
+
return yyres;
|
| 220 |
+
}
|
| 221 |
+
]])
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
# b4_declare_scanner_communication_variables
|
| 225 |
+
# ------------------------------------------
|
| 226 |
+
# Declare the variables that are global, or local to YYPARSE if
|
| 227 |
+
# pure-parser.
|
| 228 |
+
m4_define([b4_declare_scanner_communication_variables], [[
|
| 229 |
+
]m4_ifdef([b4_start_symbols], [],
|
| 230 |
+
[[/* Lookahead token kind. */
|
| 231 |
+
int yychar;
|
| 232 |
+
]])[
|
| 233 |
+
]b4_pure_if([[
|
| 234 |
+
/* The semantic value of the lookahead symbol. */
|
| 235 |
+
/* Default value used for initialization, for pacifying older GCCs
|
| 236 |
+
or non-GCC compilers. */
|
| 237 |
+
YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
|
| 238 |
+
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);]b4_locations_if([[
|
| 239 |
+
|
| 240 |
+
/* Location data for the lookahead symbol. */
|
| 241 |
+
static YYLTYPE yyloc_default]b4_yyloc_default[;
|
| 242 |
+
YYLTYPE yylloc = yyloc_default;]])],
|
| 243 |
+
[[/* The semantic value of the lookahead symbol. */
|
| 244 |
+
YYSTYPE yylval;]b4_locations_if([[
|
| 245 |
+
/* Location data for the lookahead symbol. */
|
| 246 |
+
YYLTYPE yylloc]b4_yyloc_default[;]])[
|
| 247 |
+
/* Number of syntax errors so far. */
|
| 248 |
+
int yynerrs;]])])
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
# b4_declare_parser_state_variables([INIT])
|
| 252 |
+
# -----------------------------------------
|
| 253 |
+
# Declare all the variables that are needed to maintain the parser state
|
| 254 |
+
# between calls to yypush_parse.
|
| 255 |
+
# If INIT is non-null, initialize these variables.
|
| 256 |
+
m4_define([b4_declare_parser_state_variables],
|
| 257 |
+
[b4_pure_if([[
|
| 258 |
+
/* Number of syntax errors so far. */
|
| 259 |
+
int yynerrs]m4_ifval([$1], [ = 0])[;
|
| 260 |
+
]])[
|
| 261 |
+
yy_state_fast_t yystate]m4_ifval([$1], [ = 0])[;
|
| 262 |
+
/* Number of tokens to shift before error messages enabled. */
|
| 263 |
+
int yyerrstatus]m4_ifval([$1], [ = 0])[;
|
| 264 |
+
|
| 265 |
+
/* Refer to the stacks through separate pointers, to allow yyoverflow
|
| 266 |
+
to reallocate them elsewhere. */
|
| 267 |
+
|
| 268 |
+
/* Their size. */
|
| 269 |
+
YYPTRDIFF_T yystacksize]m4_ifval([$1], [ = YYINITDEPTH])[;
|
| 270 |
+
|
| 271 |
+
/* The state stack: array, bottom, top. */
|
| 272 |
+
yy_state_t yyssa[YYINITDEPTH];
|
| 273 |
+
yy_state_t *yyss]m4_ifval([$1], [ = yyssa])[;
|
| 274 |
+
yy_state_t *yyssp]m4_ifval([$1], [ = yyss])[;
|
| 275 |
+
|
| 276 |
+
/* The semantic value stack: array, bottom, top. */
|
| 277 |
+
YYSTYPE yyvsa[YYINITDEPTH];
|
| 278 |
+
YYSTYPE *yyvs]m4_ifval([$1], [ = yyvsa])[;
|
| 279 |
+
YYSTYPE *yyvsp]m4_ifval([$1], [ = yyvs])[;]b4_locations_if([[
|
| 280 |
+
|
| 281 |
+
/* The location stack: array, bottom, top. */
|
| 282 |
+
YYLTYPE yylsa[YYINITDEPTH];
|
| 283 |
+
YYLTYPE *yyls]m4_ifval([$1], [ = yylsa])[;
|
| 284 |
+
YYLTYPE *yylsp]m4_ifval([$1], [ = yyls])[;]])[]b4_lac_if([[
|
| 285 |
+
|
| 286 |
+
yy_state_t yyesa@{]b4_percent_define_get([[parse.lac.es-capacity-initial]])[@};
|
| 287 |
+
yy_state_t *yyes]m4_ifval([$1], [ = yyesa])[;
|
| 288 |
+
YYPTRDIFF_T yyes_capacity][]m4_ifval([$1],
|
| 289 |
+
[m4_do([ = b4_percent_define_get([[parse.lac.es-capacity-initial]]) < YYMAXDEPTH],
|
| 290 |
+
[ ? b4_percent_define_get([[parse.lac.es-capacity-initial]])],
|
| 291 |
+
[ : YYMAXDEPTH])])[;]])])
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
m4_define([b4_macro_define],
|
| 295 |
+
[[#]define $1 $2])
|
| 296 |
+
|
| 297 |
+
m4_define([b4_macro_undef],
|
| 298 |
+
[[#]undef $1])
|
| 299 |
+
|
| 300 |
+
m4_define([b4_pstate_macro_define],
|
| 301 |
+
[b4_macro_define([$1], [yyps->$1])])
|
| 302 |
+
|
| 303 |
+
# b4_parse_state_variable_macros(b4_macro_define|b4_macro_undef)
|
| 304 |
+
# --------------------------------------------------------------
|
| 305 |
+
m4_define([b4_parse_state_variable_macros],
|
| 306 |
+
[b4_pure_if([$1([b4_prefix[]nerrs])])
|
| 307 |
+
$1([yystate])
|
| 308 |
+
$1([yyerrstatus])
|
| 309 |
+
$1([yyssa])
|
| 310 |
+
$1([yyss])
|
| 311 |
+
$1([yyssp])
|
| 312 |
+
$1([yyvsa])
|
| 313 |
+
$1([yyvs])
|
| 314 |
+
$1([yyvsp])[]b4_locations_if([
|
| 315 |
+
$1([yylsa])
|
| 316 |
+
$1([yyls])
|
| 317 |
+
$1([yylsp])])
|
| 318 |
+
$1([yystacksize])[]b4_lac_if([
|
| 319 |
+
$1([yyesa])
|
| 320 |
+
$1([yyes])
|
| 321 |
+
$1([yyes_capacity])])])
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
# _b4_declare_yyparse_push
|
| 327 |
+
# ------------------------
|
| 328 |
+
# Declaration of yyparse (and dependencies) when using the push parser
|
| 329 |
+
# (including in pull mode).
|
| 330 |
+
m4_define([_b4_declare_yyparse_push],
|
| 331 |
+
[[#ifndef YYPUSH_MORE_DEFINED
|
| 332 |
+
# define YYPUSH_MORE_DEFINED
|
| 333 |
+
enum { YYPUSH_MORE = 4 };
|
| 334 |
+
#endif
|
| 335 |
+
|
| 336 |
+
typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
|
| 337 |
+
|
| 338 |
+
]b4_pull_if([[
|
| 339 |
+
int ]b4_prefix[parse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[);]])[
|
| 340 |
+
int ]b4_prefix[push_parse (]b4_prefix[pstate *ps]b4_pure_if([[,
|
| 341 |
+
int pushed_char, ]b4_api_PREFIX[STYPE const *pushed_val]b4_locations_if([[, ]b4_api_PREFIX[LTYPE *pushed_loc]])])b4_user_formals[);
|
| 342 |
+
]b4_pull_if([[int ]b4_prefix[pull_parse (]b4_prefix[pstate *ps]b4_user_formals[);]])[
|
| 343 |
+
]b4_prefix[pstate *]b4_prefix[pstate_new (void);
|
| 344 |
+
void ]b4_prefix[pstate_delete (]b4_prefix[pstate *ps);
|
| 345 |
+
]])
|
| 346 |
+
|
| 347 |
+
|
| 348 |
+
# _b4_declare_yyparse
|
| 349 |
+
# -------------------
|
| 350 |
+
# When not the push parser.
|
| 351 |
+
m4_define([_b4_declare_yyparse],
|
| 352 |
+
[[int ]b4_prefix[parse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[);
|
| 353 |
+
]m4_ifdef([b4_start_symbols],
|
| 354 |
+
[m4_map([_b4_declare_sub_yyparse], m4_defn([b4_start_symbols]))])])
|
| 355 |
+
|
| 356 |
+
|
| 357 |
+
# b4_declare_yyparse
|
| 358 |
+
# ------------------
|
| 359 |
+
m4_define([b4_declare_yyparse],
|
| 360 |
+
[b4_push_if([_b4_declare_yyparse_push],
|
| 361 |
+
[_b4_declare_yyparse])[]dnl
|
| 362 |
+
])
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
# b4_declare_yyerror_and_yylex
|
| 366 |
+
# ----------------------------
|
| 367 |
+
# Comply with POSIX Yacc.
|
| 368 |
+
# <https://austingroupbugs.net/view.php?id=1388#c5220>
|
| 369 |
+
m4_define([b4_declare_yyerror_and_yylex],
|
| 370 |
+
[b4_posix_if([[#if !defined ]b4_prefix[error && !defined ]b4_api_PREFIX[ERROR_IS_DECLARED
|
| 371 |
+
]b4_function_declare([b4_prefix[error]], void, b4_yyerror_formals)[
|
| 372 |
+
#endif
|
| 373 |
+
#if !defined ]b4_prefix[lex && !defined ]b4_api_PREFIX[LEX_IS_DECLARED
|
| 374 |
+
]b4_function_declare([b4_prefix[lex]], int, b4_yylex_formals)[
|
| 375 |
+
#endif
|
| 376 |
+
]])dnl
|
| 377 |
+
])
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
# b4_shared_declarations
|
| 381 |
+
# ----------------------
|
| 382 |
+
# Declarations that might either go into the header (if --header)
|
| 383 |
+
# or into the implementation file.
|
| 384 |
+
m4_define([b4_shared_declarations],
|
| 385 |
+
[b4_cpp_guard_open([b4_spec_mapped_header_file])[
|
| 386 |
+
]b4_declare_yydebug[
|
| 387 |
+
]b4_percent_code_get([[requires]])[
|
| 388 |
+
]b4_token_enums_defines[
|
| 389 |
+
]b4_declare_yylstype[
|
| 390 |
+
]b4_declare_yyerror_and_yylex[
|
| 391 |
+
]b4_declare_yyparse[
|
| 392 |
+
]b4_percent_code_get([[provides]])[
|
| 393 |
+
]b4_cpp_guard_close([b4_spec_mapped_header_file])[]dnl
|
| 394 |
+
])
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
# b4_header_include_if(IF-TRUE, IF-FALSE)
|
| 398 |
+
# ---------------------------------------
|
| 399 |
+
# Run IF-TRUE if we generate an output file and api.header.include
|
| 400 |
+
# is defined.
|
| 401 |
+
m4_define([b4_header_include_if],
|
| 402 |
+
[m4_ifval(m4_quote(b4_spec_header_file),
|
| 403 |
+
[b4_percent_define_ifdef([[api.header.include]],
|
| 404 |
+
[$1],
|
| 405 |
+
[$2])],
|
| 406 |
+
[$2])])
|
| 407 |
+
|
| 408 |
+
m4_if(b4_spec_header_file, [y.tab.h], [],
|
| 409 |
+
[b4_percent_define_default([[api.header.include]],
|
| 410 |
+
[["@basename(]b4_spec_header_file[@)"]])])
|
| 411 |
+
|
| 412 |
+
|
| 413 |
+
|
| 414 |
+
|
| 415 |
+
## -------------- ##
|
| 416 |
+
## Output files. ##
|
| 417 |
+
## -------------- ##
|
| 418 |
+
|
| 419 |
+
|
| 420 |
+
b4_header_if([[
|
| 421 |
+
]b4_output_begin([b4_spec_header_file])[
|
| 422 |
+
]b4_copyright([Bison interface for Yacc-like parsers in C])[
|
| 423 |
+
]b4_disclaimer[
|
| 424 |
+
]b4_shared_declarations[
|
| 425 |
+
]b4_output_end[
|
| 426 |
+
]])# b4_header_if
|
| 427 |
+
|
| 428 |
+
b4_output_begin([b4_parser_file_name])[
|
| 429 |
+
]b4_copyright([Bison implementation for Yacc-like parsers in C])[
|
| 430 |
+
/* C LALR(1) parser skeleton written by Richard Stallman, by
|
| 431 |
+
simplifying the original so-called "semantic" parser. */
|
| 432 |
+
|
| 433 |
+
]b4_disclaimer[
|
| 434 |
+
/* All symbols defined below should begin with yy or YY, to avoid
|
| 435 |
+
infringing on user name space. This should be done even for local
|
| 436 |
+
variables, as they might otherwise be expanded by user macros.
|
| 437 |
+
There are some unavoidable exceptions within include files to
|
| 438 |
+
define necessary library symbols; they are noted "INFRINGES ON
|
| 439 |
+
USER NAME SPACE" below. */
|
| 440 |
+
|
| 441 |
+
]b4_identification[
|
| 442 |
+
]b4_percent_code_get([[top]])[]dnl
|
| 443 |
+
m4_if(b4_api_prefix, [yy], [],
|
| 444 |
+
[[/* Substitute the type names. */
|
| 445 |
+
#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
|
| 446 |
+
#define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
|
| 447 |
+
]m4_if(b4_prefix, [yy], [],
|
| 448 |
+
[[/* Substitute the variable and function names. */]b4_pull_if([[
|
| 449 |
+
#define yyparse ]b4_prefix[parse]])b4_push_if([[
|
| 450 |
+
#define yypush_parse ]b4_prefix[push_parse]b4_pull_if([[
|
| 451 |
+
#define yypull_parse ]b4_prefix[pull_parse]])[
|
| 452 |
+
#define yypstate_new ]b4_prefix[pstate_new
|
| 453 |
+
#define yypstate_clear ]b4_prefix[pstate_clear
|
| 454 |
+
#define yypstate_delete ]b4_prefix[pstate_delete
|
| 455 |
+
#define yypstate ]b4_prefix[pstate]])[
|
| 456 |
+
#define yylex ]b4_prefix[lex
|
| 457 |
+
#define yyerror ]b4_prefix[error
|
| 458 |
+
#define yydebug ]b4_prefix[debug
|
| 459 |
+
#define yynerrs ]b4_prefix[nerrs]]b4_pure_if([], [[
|
| 460 |
+
#define yylval ]b4_prefix[lval
|
| 461 |
+
#define yychar ]b4_prefix[char]b4_locations_if([[
|
| 462 |
+
#define yylloc ]b4_prefix[lloc]])]))[
|
| 463 |
+
|
| 464 |
+
]b4_user_pre_prologue[
|
| 465 |
+
]b4_cast_define[
|
| 466 |
+
]b4_null_define[
|
| 467 |
+
|
| 468 |
+
]b4_header_include_if([[#include ]b4_percent_define_get([[api.header.include]])],
|
| 469 |
+
[m4_ifval(m4_quote(b4_spec_header_file),
|
| 470 |
+
[/* Use api.header.include to #include this header
|
| 471 |
+
instead of duplicating it here. */
|
| 472 |
+
])b4_shared_declarations])[
|
| 473 |
+
]b4_declare_symbol_enum[
|
| 474 |
+
|
| 475 |
+
]b4_user_post_prologue[
|
| 476 |
+
]b4_percent_code_get[
|
| 477 |
+
]b4_c99_int_type_define[
|
| 478 |
+
|
| 479 |
+
]b4_sizes_types_define[
|
| 480 |
+
|
| 481 |
+
/* Stored state numbers (used for stacks). */
|
| 482 |
+
typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ yy_state_t;
|
| 483 |
+
|
| 484 |
+
/* State numbers in computations. */
|
| 485 |
+
typedef int yy_state_fast_t;
|
| 486 |
+
|
| 487 |
+
#ifndef YY_
|
| 488 |
+
# if defined YYENABLE_NLS && YYENABLE_NLS
|
| 489 |
+
# if ENABLE_NLS
|
| 490 |
+
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
|
| 491 |
+
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
|
| 492 |
+
# endif
|
| 493 |
+
# endif
|
| 494 |
+
# ifndef YY_
|
| 495 |
+
# define YY_(Msgid) Msgid
|
| 496 |
+
# endif
|
| 497 |
+
#endif
|
| 498 |
+
]b4_has_translations_if([
|
| 499 |
+
#ifndef N_
|
| 500 |
+
# define N_(Msgid) Msgid
|
| 501 |
+
#endif
|
| 502 |
+
])[
|
| 503 |
+
|
| 504 |
+
]b4_attribute_define[
|
| 505 |
+
|
| 506 |
+
]b4_parse_assert_if([[#ifdef NDEBUG
|
| 507 |
+
# define YY_ASSERT(E) ((void) (0 && (E)))
|
| 508 |
+
#else
|
| 509 |
+
# include <assert.h> /* INFRINGES ON USER NAME SPACE */
|
| 510 |
+
# define YY_ASSERT(E) assert (E)
|
| 511 |
+
#endif
|
| 512 |
+
]],
|
| 513 |
+
[[#define YY_ASSERT(E) ((void) (0 && (E)))]])[
|
| 514 |
+
|
| 515 |
+
#if ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[
|
| 516 |
+
|
| 517 |
+
/* The parser invokes alloca or malloc; define the necessary symbols. */]dnl
|
| 518 |
+
b4_push_if([], [b4_lac_if([], [[
|
| 519 |
+
|
| 520 |
+
# ifdef YYSTACK_USE_ALLOCA
|
| 521 |
+
# if YYSTACK_USE_ALLOCA
|
| 522 |
+
# ifdef __GNUC__
|
| 523 |
+
# define YYSTACK_ALLOC __builtin_alloca
|
| 524 |
+
# elif defined __BUILTIN_VA_ARG_INCR
|
| 525 |
+
# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
|
| 526 |
+
# elif defined _AIX
|
| 527 |
+
# define YYSTACK_ALLOC __alloca
|
| 528 |
+
# elif defined _MSC_VER
|
| 529 |
+
# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
|
| 530 |
+
# define alloca _alloca
|
| 531 |
+
# else
|
| 532 |
+
# define YYSTACK_ALLOC alloca
|
| 533 |
+
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
|
| 534 |
+
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
| 535 |
+
/* Use EXIT_SUCCESS as a witness for stdlib.h. */
|
| 536 |
+
# ifndef EXIT_SUCCESS
|
| 537 |
+
# define EXIT_SUCCESS 0
|
| 538 |
+
# endif
|
| 539 |
+
# endif
|
| 540 |
+
# endif
|
| 541 |
+
# endif
|
| 542 |
+
# endif]])])[
|
| 543 |
+
|
| 544 |
+
# ifdef YYSTACK_ALLOC
|
| 545 |
+
/* Pacify GCC's 'empty if-body' warning. */
|
| 546 |
+
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
|
| 547 |
+
# ifndef YYSTACK_ALLOC_MAXIMUM
|
| 548 |
+
/* The OS might guarantee only one guard page at the bottom of the stack,
|
| 549 |
+
and a page size can be as small as 4096 bytes. So we cannot safely
|
| 550 |
+
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
|
| 551 |
+
to allow for a few compiler-allocated temporary stack slots. */
|
| 552 |
+
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
|
| 553 |
+
# endif
|
| 554 |
+
# else
|
| 555 |
+
# define YYSTACK_ALLOC YYMALLOC
|
| 556 |
+
# define YYSTACK_FREE YYFREE
|
| 557 |
+
# ifndef YYSTACK_ALLOC_MAXIMUM
|
| 558 |
+
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
|
| 559 |
+
# endif
|
| 560 |
+
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
|
| 561 |
+
&& ! ((defined YYMALLOC || defined malloc) \
|
| 562 |
+
&& (defined YYFREE || defined free)))
|
| 563 |
+
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
| 564 |
+
# ifndef EXIT_SUCCESS
|
| 565 |
+
# define EXIT_SUCCESS 0
|
| 566 |
+
# endif
|
| 567 |
+
# endif
|
| 568 |
+
# ifndef YYMALLOC
|
| 569 |
+
# define YYMALLOC malloc
|
| 570 |
+
# if ! defined malloc && ! defined EXIT_SUCCESS
|
| 571 |
+
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
|
| 572 |
+
# endif
|
| 573 |
+
# endif
|
| 574 |
+
# ifndef YYFREE
|
| 575 |
+
# define YYFREE free
|
| 576 |
+
# if ! defined free && ! defined EXIT_SUCCESS
|
| 577 |
+
void free (void *); /* INFRINGES ON USER NAME SPACE */
|
| 578 |
+
# endif
|
| 579 |
+
# endif
|
| 580 |
+
# endif]b4_lac_if([[
|
| 581 |
+
# define YYCOPY_NEEDED 1]])[
|
| 582 |
+
#endif /* ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[ */
|
| 583 |
+
|
| 584 |
+
#if (! defined yyoverflow \
|
| 585 |
+
&& (! defined __cplusplus \
|
| 586 |
+
|| (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
|
| 587 |
+
&& ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL)))
|
| 588 |
+
|
| 589 |
+
/* A type that is properly aligned for any stack member. */
|
| 590 |
+
union yyalloc
|
| 591 |
+
{
|
| 592 |
+
yy_state_t yyss_alloc;
|
| 593 |
+
YYSTYPE yyvs_alloc;]b4_locations_if([
|
| 594 |
+
YYLTYPE yyls_alloc;])[
|
| 595 |
+
};
|
| 596 |
+
|
| 597 |
+
/* The size of the maximum gap between one aligned stack and the next. */
|
| 598 |
+
# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
|
| 599 |
+
|
| 600 |
+
/* The size of an array large to enough to hold all stacks, each with
|
| 601 |
+
N elements. */
|
| 602 |
+
]b4_locations_if(
|
| 603 |
+
[# define YYSTACK_BYTES(N) \
|
| 604 |
+
((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \
|
| 605 |
+
+ YYSIZEOF (YYLTYPE)) \
|
| 606 |
+
+ 2 * YYSTACK_GAP_MAXIMUM)],
|
| 607 |
+
[# define YYSTACK_BYTES(N) \
|
| 608 |
+
((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
|
| 609 |
+
+ YYSTACK_GAP_MAXIMUM)])[
|
| 610 |
+
|
| 611 |
+
# define YYCOPY_NEEDED 1
|
| 612 |
+
|
| 613 |
+
/* Relocate STACK from its old location to the new one. The
|
| 614 |
+
local variables YYSIZE and YYSTACKSIZE give the old and new number of
|
| 615 |
+
elements in the stack, and YYPTR gives the new location of the
|
| 616 |
+
stack. Advance YYPTR to a properly aligned location for the next
|
| 617 |
+
stack. */
|
| 618 |
+
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
|
| 619 |
+
do \
|
| 620 |
+
{ \
|
| 621 |
+
YYPTRDIFF_T yynewbytes; \
|
| 622 |
+
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
|
| 623 |
+
Stack = &yyptr->Stack_alloc; \
|
| 624 |
+
yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
|
| 625 |
+
yyptr += yynewbytes / YYSIZEOF (*yyptr); \
|
| 626 |
+
} \
|
| 627 |
+
while (0)
|
| 628 |
+
|
| 629 |
+
#endif
|
| 630 |
+
|
| 631 |
+
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
|
| 632 |
+
/* Copy COUNT objects from SRC to DST. The source and destination do
|
| 633 |
+
not overlap. */
|
| 634 |
+
# ifndef YYCOPY
|
| 635 |
+
# if defined __GNUC__ && 1 < __GNUC__
|
| 636 |
+
# define YYCOPY(Dst, Src, Count) \
|
| 637 |
+
__builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
|
| 638 |
+
# else
|
| 639 |
+
# define YYCOPY(Dst, Src, Count) \
|
| 640 |
+
do \
|
| 641 |
+
{ \
|
| 642 |
+
YYPTRDIFF_T yyi; \
|
| 643 |
+
for (yyi = 0; yyi < (Count); yyi++) \
|
| 644 |
+
(Dst)[yyi] = (Src)[yyi]; \
|
| 645 |
+
} \
|
| 646 |
+
while (0)
|
| 647 |
+
# endif
|
| 648 |
+
# endif
|
| 649 |
+
#endif /* !YYCOPY_NEEDED */
|
| 650 |
+
|
| 651 |
+
/* YYFINAL -- State number of the termination state. */
|
| 652 |
+
#define YYFINAL ]b4_final_state_number[
|
| 653 |
+
/* YYLAST -- Last index in YYTABLE. */
|
| 654 |
+
#define YYLAST ]b4_last[
|
| 655 |
+
|
| 656 |
+
/* YYNTOKENS -- Number of terminals. */
|
| 657 |
+
#define YYNTOKENS ]b4_tokens_number[
|
| 658 |
+
/* YYNNTS -- Number of nonterminals. */
|
| 659 |
+
#define YYNNTS ]b4_nterms_number[
|
| 660 |
+
/* YYNRULES -- Number of rules. */
|
| 661 |
+
#define YYNRULES ]b4_rules_number[
|
| 662 |
+
/* YYNSTATES -- Number of states. */
|
| 663 |
+
#define YYNSTATES ]b4_states_number[
|
| 664 |
+
|
| 665 |
+
/* YYMAXUTOK -- Last valid token kind. */
|
| 666 |
+
#define YYMAXUTOK ]b4_code_max[
|
| 667 |
+
|
| 668 |
+
|
| 669 |
+
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
|
| 670 |
+
as returned by yylex, with out-of-bounds checking. */
|
| 671 |
+
]b4_api_token_raw_if(dnl
|
| 672 |
+
[[#define YYTRANSLATE(YYX) YY_CAST (yysymbol_kind_t, YYX)]],
|
| 673 |
+
[[#define YYTRANSLATE(YYX) \
|
| 674 |
+
(0 <= (YYX) && (YYX) <= YYMAXUTOK \
|
| 675 |
+
? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
|
| 676 |
+
: ]b4_symbol_prefix[YYUNDEF)
|
| 677 |
+
|
| 678 |
+
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
| 679 |
+
as returned by yylex. */
|
| 680 |
+
static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
|
| 681 |
+
{
|
| 682 |
+
]b4_translate[
|
| 683 |
+
};]])[
|
| 684 |
+
|
| 685 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 686 |
+
]b4_integral_parser_table_define([rline], [b4_rline],
|
| 687 |
+
[[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
|
| 688 |
+
#endif
|
| 689 |
+
|
| 690 |
+
/** Accessing symbol of state STATE. */
|
| 691 |
+
#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
|
| 692 |
+
|
| 693 |
+
#if ]b4_parse_error_case([simple], [b4_api_PREFIX[DEBUG || ]b4_token_table_flag], [[1]])[
|
| 694 |
+
/* The user-facing name of the symbol whose (internal) number is
|
| 695 |
+
YYSYMBOL. No bounds checking. */
|
| 696 |
+
static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
|
| 697 |
+
|
| 698 |
+
]b4_parse_error_bmatch([simple\|verbose],
|
| 699 |
+
[[/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
| 700 |
+
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
|
| 701 |
+
static const char *const yytname[] =
|
| 702 |
+
{
|
| 703 |
+
]b4_tname[
|
| 704 |
+
};
|
| 705 |
+
|
| 706 |
+
static const char *
|
| 707 |
+
yysymbol_name (yysymbol_kind_t yysymbol)
|
| 708 |
+
{
|
| 709 |
+
return yytname[yysymbol];
|
| 710 |
+
}]],
|
| 711 |
+
[[static const char *
|
| 712 |
+
yysymbol_name (yysymbol_kind_t yysymbol)
|
| 713 |
+
{
|
| 714 |
+
static const char *const yy_sname[] =
|
| 715 |
+
{
|
| 716 |
+
]b4_symbol_names[
|
| 717 |
+
};]b4_has_translations_if([[
|
| 718 |
+
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
|
| 719 |
+
internationalizable. */
|
| 720 |
+
static ]b4_int_type_for([b4_translatable])[ yytranslatable[] =
|
| 721 |
+
{
|
| 722 |
+
]b4_translatable[
|
| 723 |
+
};
|
| 724 |
+
return (yysymbol < YYNTOKENS && yytranslatable[yysymbol]
|
| 725 |
+
? _(yy_sname[yysymbol])
|
| 726 |
+
: yy_sname[yysymbol]);]], [[
|
| 727 |
+
return yy_sname[yysymbol];]])[
|
| 728 |
+
}]])[
|
| 729 |
+
#endif
|
| 730 |
+
|
| 731 |
+
#define YYPACT_NINF (]b4_pact_ninf[)
|
| 732 |
+
|
| 733 |
+
#define yypact_value_is_default(Yyn) \
|
| 734 |
+
]b4_table_value_equals([[pact]], [[Yyn]], [b4_pact_ninf], [YYPACT_NINF])[
|
| 735 |
+
|
| 736 |
+
#define YYTABLE_NINF (]b4_table_ninf[)
|
| 737 |
+
|
| 738 |
+
#define yytable_value_is_error(Yyn) \
|
| 739 |
+
]b4_table_value_equals([[table]], [[Yyn]], [b4_table_ninf], [YYTABLE_NINF])[
|
| 740 |
+
|
| 741 |
+
]b4_parser_tables_define[
|
| 742 |
+
|
| 743 |
+
enum { YYENOMEM = -2 };
|
| 744 |
+
|
| 745 |
+
#define yyerrok (yyerrstatus = 0)
|
| 746 |
+
#define yyclearin (yychar = ]b4_symbol(empty, id)[)
|
| 747 |
+
|
| 748 |
+
#define YYACCEPT goto yyacceptlab
|
| 749 |
+
#define YYABORT goto yyabortlab
|
| 750 |
+
#define YYERROR goto yyerrorlab
|
| 751 |
+
#define YYNOMEM goto yyexhaustedlab
|
| 752 |
+
|
| 753 |
+
|
| 754 |
+
#define YYRECOVERING() (!!yyerrstatus)
|
| 755 |
+
|
| 756 |
+
#define YYBACKUP(Token, Value) \
|
| 757 |
+
do \
|
| 758 |
+
if (yychar == ]b4_symbol(empty, id)[) \
|
| 759 |
+
{ \
|
| 760 |
+
yychar = (Token); \
|
| 761 |
+
yylval = (Value); \
|
| 762 |
+
YYPOPSTACK (yylen); \
|
| 763 |
+
yystate = *yyssp; \]b4_lac_if([[
|
| 764 |
+
YY_LAC_DISCARD ("YYBACKUP"); \]])[
|
| 765 |
+
goto yybackup; \
|
| 766 |
+
} \
|
| 767 |
+
else \
|
| 768 |
+
{ \
|
| 769 |
+
yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
|
| 770 |
+
YYERROR; \
|
| 771 |
+
} \
|
| 772 |
+
while (0)
|
| 773 |
+
|
| 774 |
+
/* Backward compatibility with an undocumented macro.
|
| 775 |
+
Use ]b4_symbol(error, id)[ or ]b4_symbol(undef, id)[. */
|
| 776 |
+
#define YYERRCODE ]b4_symbol(undef, id)[
|
| 777 |
+
]b4_locations_if([[
|
| 778 |
+
]b4_yylloc_default_define[
|
| 779 |
+
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
| 780 |
+
]])[
|
| 781 |
+
|
| 782 |
+
/* Enable debugging if requested. */
|
| 783 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 784 |
+
|
| 785 |
+
# ifndef YYFPRINTF
|
| 786 |
+
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
|
| 787 |
+
# define YYFPRINTF fprintf
|
| 788 |
+
# endif
|
| 789 |
+
|
| 790 |
+
# define YYDPRINTF(Args) \
|
| 791 |
+
do { \
|
| 792 |
+
if (yydebug) \
|
| 793 |
+
YYFPRINTF Args; \
|
| 794 |
+
} while (0)
|
| 795 |
+
|
| 796 |
+
]b4_yylocation_print_define[
|
| 797 |
+
|
| 798 |
+
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
|
| 799 |
+
do { \
|
| 800 |
+
if (yydebug) \
|
| 801 |
+
{ \
|
| 802 |
+
YYFPRINTF (stderr, "%s ", Title); \
|
| 803 |
+
yy_symbol_print (stderr, \
|
| 804 |
+
Kind, Value]b4_locations_if([, Location])[]b4_user_args[); \
|
| 805 |
+
YYFPRINTF (stderr, "\n"); \
|
| 806 |
+
} \
|
| 807 |
+
} while (0)
|
| 808 |
+
|
| 809 |
+
]b4_yy_symbol_print_define[
|
| 810 |
+
|
| 811 |
+
/*------------------------------------------------------------------.
|
| 812 |
+
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
|
| 813 |
+
| TOP (included). |
|
| 814 |
+
`------------------------------------------------------------------*/
|
| 815 |
+
|
| 816 |
+
static void
|
| 817 |
+
yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
|
| 818 |
+
{
|
| 819 |
+
YYFPRINTF (stderr, "Stack now");
|
| 820 |
+
for (; yybottom <= yytop; yybottom++)
|
| 821 |
+
{
|
| 822 |
+
int yybot = *yybottom;
|
| 823 |
+
YYFPRINTF (stderr, " %d", yybot);
|
| 824 |
+
}
|
| 825 |
+
YYFPRINTF (stderr, "\n");
|
| 826 |
+
}
|
| 827 |
+
|
| 828 |
+
# define YY_STACK_PRINT(Bottom, Top) \
|
| 829 |
+
do { \
|
| 830 |
+
if (yydebug) \
|
| 831 |
+
yy_stack_print ((Bottom), (Top)); \
|
| 832 |
+
} while (0)
|
| 833 |
+
|
| 834 |
+
|
| 835 |
+
/*------------------------------------------------.
|
| 836 |
+
| Report that the YYRULE is going to be reduced. |
|
| 837 |
+
`------------------------------------------------*/
|
| 838 |
+
|
| 839 |
+
static void
|
| 840 |
+
yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,]b4_locations_if([[ YYLTYPE *yylsp,]])[
|
| 841 |
+
int yyrule]b4_user_formals[)
|
| 842 |
+
{
|
| 843 |
+
int yylno = yyrline[yyrule];
|
| 844 |
+
int yynrhs = yyr2[yyrule];
|
| 845 |
+
int yyi;
|
| 846 |
+
YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
|
| 847 |
+
yyrule - 1, yylno);
|
| 848 |
+
/* The symbols being reduced. */
|
| 849 |
+
for (yyi = 0; yyi < yynrhs; yyi++)
|
| 850 |
+
{
|
| 851 |
+
YYFPRINTF (stderr, " $%d = ", yyi + 1);
|
| 852 |
+
yy_symbol_print (stderr,
|
| 853 |
+
YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
|
| 854 |
+
&]b4_rhs_value(yynrhs, yyi + 1)[]b4_locations_if([,
|
| 855 |
+
&]b4_rhs_location(yynrhs, yyi + 1))[]b4_user_args[);
|
| 856 |
+
YYFPRINTF (stderr, "\n");
|
| 857 |
+
}
|
| 858 |
+
}
|
| 859 |
+
|
| 860 |
+
# define YY_REDUCE_PRINT(Rule) \
|
| 861 |
+
do { \
|
| 862 |
+
if (yydebug) \
|
| 863 |
+
yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
|
| 864 |
+
} while (0)
|
| 865 |
+
|
| 866 |
+
/* Nonzero means print parse trace. It is left uninitialized so that
|
| 867 |
+
multiple parsers can coexist. */
|
| 868 |
+
int yydebug;
|
| 869 |
+
#else /* !]b4_api_PREFIX[DEBUG */
|
| 870 |
+
# define YYDPRINTF(Args) ((void) 0)
|
| 871 |
+
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
|
| 872 |
+
# define YY_STACK_PRINT(Bottom, Top)
|
| 873 |
+
# define YY_REDUCE_PRINT(Rule)
|
| 874 |
+
#endif /* !]b4_api_PREFIX[DEBUG */
|
| 875 |
+
|
| 876 |
+
|
| 877 |
+
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
| 878 |
+
#ifndef YYINITDEPTH
|
| 879 |
+
# define YYINITDEPTH ]b4_stack_depth_init[
|
| 880 |
+
#endif
|
| 881 |
+
|
| 882 |
+
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
|
| 883 |
+
if the built-in stack extension method is used).
|
| 884 |
+
|
| 885 |
+
Do not make this value too large; the results are undefined if
|
| 886 |
+
YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
|
| 887 |
+
evaluated with infinite-precision integer arithmetic. */
|
| 888 |
+
|
| 889 |
+
#ifndef YYMAXDEPTH
|
| 890 |
+
# define YYMAXDEPTH ]b4_stack_depth_max[
|
| 891 |
+
#endif]b4_push_if([[
|
| 892 |
+
/* Parser data structure. */
|
| 893 |
+
struct yypstate
|
| 894 |
+
{]b4_declare_parser_state_variables[
|
| 895 |
+
/* Whether this instance has not started parsing yet.
|
| 896 |
+
* If 2, it corresponds to a finished parsing. */
|
| 897 |
+
int yynew;
|
| 898 |
+
};]b4_pure_if([], [[
|
| 899 |
+
|
| 900 |
+
/* Whether the only allowed instance of yypstate is allocated. */
|
| 901 |
+
static char yypstate_allocated = 0;]])])[
|
| 902 |
+
]b4_lac_if([[
|
| 903 |
+
|
| 904 |
+
/* Given a state stack such that *YYBOTTOM is its bottom, such that
|
| 905 |
+
*YYTOP is either its top or is YYTOP_EMPTY to indicate an empty
|
| 906 |
+
stack, and such that *YYCAPACITY is the maximum number of elements it
|
| 907 |
+
can hold without a reallocation, make sure there is enough room to
|
| 908 |
+
store YYADD more elements. If not, allocate a new stack using
|
| 909 |
+
YYSTACK_ALLOC, copy the existing elements, and adjust *YYBOTTOM,
|
| 910 |
+
*YYTOP, and *YYCAPACITY to reflect the new capacity and memory
|
| 911 |
+
location. If *YYBOTTOM != YYBOTTOM_NO_FREE, then free the old stack
|
| 912 |
+
using YYSTACK_FREE. Return 0 if successful or if no reallocation is
|
| 913 |
+
required. Return YYENOMEM if memory is exhausted. */
|
| 914 |
+
static int
|
| 915 |
+
yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
|
| 916 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 917 |
+
char const *yydebug_prefix,
|
| 918 |
+
char const *yydebug_suffix,
|
| 919 |
+
#endif
|
| 920 |
+
yy_state_t **yybottom,
|
| 921 |
+
yy_state_t *yybottom_no_free,
|
| 922 |
+
yy_state_t **yytop, yy_state_t *yytop_empty)
|
| 923 |
+
{
|
| 924 |
+
YYPTRDIFF_T yysize_old =
|
| 925 |
+
*yytop == yytop_empty ? 0 : *yytop - *yybottom + 1;
|
| 926 |
+
YYPTRDIFF_T yysize_new = yysize_old + yyadd;
|
| 927 |
+
if (*yycapacity < yysize_new)
|
| 928 |
+
{
|
| 929 |
+
YYPTRDIFF_T yyalloc = 2 * yysize_new;
|
| 930 |
+
yy_state_t *yybottom_new;
|
| 931 |
+
/* Use YYMAXDEPTH for maximum stack size given that the stack
|
| 932 |
+
should never need to grow larger than the main state stack
|
| 933 |
+
needs to grow without LAC. */
|
| 934 |
+
if (YYMAXDEPTH < yysize_new)
|
| 935 |
+
{
|
| 936 |
+
YYDPRINTF ((stderr, "%smax size exceeded%s", yydebug_prefix,
|
| 937 |
+
yydebug_suffix));
|
| 938 |
+
return YYENOMEM;
|
| 939 |
+
}
|
| 940 |
+
if (YYMAXDEPTH < yyalloc)
|
| 941 |
+
yyalloc = YYMAXDEPTH;
|
| 942 |
+
yybottom_new =
|
| 943 |
+
YY_CAST (yy_state_t *,
|
| 944 |
+
YYSTACK_ALLOC (YY_CAST (YYSIZE_T,
|
| 945 |
+
yyalloc * YYSIZEOF (*yybottom_new))));
|
| 946 |
+
if (!yybottom_new)
|
| 947 |
+
{
|
| 948 |
+
YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix,
|
| 949 |
+
yydebug_suffix));
|
| 950 |
+
return YYENOMEM;
|
| 951 |
+
}
|
| 952 |
+
if (*yytop != yytop_empty)
|
| 953 |
+
{
|
| 954 |
+
YYCOPY (yybottom_new, *yybottom, yysize_old);
|
| 955 |
+
*yytop = yybottom_new + (yysize_old - 1);
|
| 956 |
+
}
|
| 957 |
+
if (*yybottom != yybottom_no_free)
|
| 958 |
+
YYSTACK_FREE (*yybottom);
|
| 959 |
+
*yybottom = yybottom_new;
|
| 960 |
+
*yycapacity = yyalloc;]m4_if(b4_percent_define_get([[parse.lac.memory-trace]]),
|
| 961 |
+
[full], [[
|
| 962 |
+
YY_IGNORE_USELESS_CAST_BEGIN
|
| 963 |
+
YYDPRINTF ((stderr, "%srealloc to %ld%s", yydebug_prefix,
|
| 964 |
+
YY_CAST (long, yyalloc), yydebug_suffix));
|
| 965 |
+
YY_IGNORE_USELESS_CAST_END]])[
|
| 966 |
+
}
|
| 967 |
+
return 0;
|
| 968 |
+
}
|
| 969 |
+
|
| 970 |
+
/* Establish the initial context for the current lookahead if no initial
|
| 971 |
+
context is currently established.
|
| 972 |
+
|
| 973 |
+
We define a context as a snapshot of the parser stacks. We define
|
| 974 |
+
the initial context for a lookahead as the context in which the
|
| 975 |
+
parser initially examines that lookahead in order to select a
|
| 976 |
+
syntactic action. Thus, if the lookahead eventually proves
|
| 977 |
+
syntactically unacceptable (possibly in a later context reached via a
|
| 978 |
+
series of reductions), the initial context can be used to determine
|
| 979 |
+
the exact set of tokens that would be syntactically acceptable in the
|
| 980 |
+
lookahead's place. Moreover, it is the context after which any
|
| 981 |
+
further semantic actions would be erroneous because they would be
|
| 982 |
+
determined by a syntactically unacceptable token.
|
| 983 |
+
|
| 984 |
+
YY_LAC_ESTABLISH should be invoked when a reduction is about to be
|
| 985 |
+
performed in an inconsistent state (which, for the purposes of LAC,
|
| 986 |
+
includes consistent states that don't know they're consistent because
|
| 987 |
+
their default reductions have been disabled). Iff there is a
|
| 988 |
+
lookahead token, it should also be invoked before reporting a syntax
|
| 989 |
+
error. This latter case is for the sake of the debugging output.
|
| 990 |
+
|
| 991 |
+
For parse.lac=full, the implementation of YY_LAC_ESTABLISH is as
|
| 992 |
+
follows. If no initial context is currently established for the
|
| 993 |
+
current lookahead, then check if that lookahead can eventually be
|
| 994 |
+
shifted if syntactic actions continue from the current context.
|
| 995 |
+
Report a syntax error if it cannot. */
|
| 996 |
+
#define YY_LAC_ESTABLISH \
|
| 997 |
+
do { \
|
| 998 |
+
if (!yy_lac_established) \
|
| 999 |
+
{ \
|
| 1000 |
+
YYDPRINTF ((stderr, \
|
| 1001 |
+
"LAC: initial context established for %s\n", \
|
| 1002 |
+
yysymbol_name (yytoken))); \
|
| 1003 |
+
yy_lac_established = 1; \
|
| 1004 |
+
switch (yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken)) \
|
| 1005 |
+
{ \
|
| 1006 |
+
case YYENOMEM: \
|
| 1007 |
+
YYNOMEM; \
|
| 1008 |
+
case 1: \
|
| 1009 |
+
goto yyerrlab; \
|
| 1010 |
+
} \
|
| 1011 |
+
} \
|
| 1012 |
+
} while (0)
|
| 1013 |
+
|
| 1014 |
+
/* Discard any previous initial lookahead context because of Event,
|
| 1015 |
+
which may be a lookahead change or an invalidation of the currently
|
| 1016 |
+
established initial context for the current lookahead.
|
| 1017 |
+
|
| 1018 |
+
The most common example of a lookahead change is a shift. An example
|
| 1019 |
+
of both cases is syntax error recovery. That is, a syntax error
|
| 1020 |
+
occurs when the lookahead is syntactically erroneous for the
|
| 1021 |
+
currently established initial context, so error recovery manipulates
|
| 1022 |
+
the parser stacks to try to find a new initial context in which the
|
| 1023 |
+
current lookahead is syntactically acceptable. If it fails to find
|
| 1024 |
+
such a context, it discards the lookahead. */
|
| 1025 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 1026 |
+
# define YY_LAC_DISCARD(Event) \
|
| 1027 |
+
do { \
|
| 1028 |
+
if (yy_lac_established) \
|
| 1029 |
+
{ \
|
| 1030 |
+
YYDPRINTF ((stderr, "LAC: initial context discarded due to " \
|
| 1031 |
+
Event "\n")); \
|
| 1032 |
+
yy_lac_established = 0; \
|
| 1033 |
+
} \
|
| 1034 |
+
} while (0)
|
| 1035 |
+
#else
|
| 1036 |
+
# define YY_LAC_DISCARD(Event) yy_lac_established = 0
|
| 1037 |
+
#endif
|
| 1038 |
+
|
| 1039 |
+
/* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can
|
| 1040 |
+
eventually (after perhaps some reductions) be shifted, return 1 if
|
| 1041 |
+
not, or return YYENOMEM if memory is exhausted. As preconditions and
|
| 1042 |
+
postconditions: *YYES_CAPACITY is the allocated size of the array to
|
| 1043 |
+
which *YYES points, and either *YYES = YYESA or *YYES points to an
|
| 1044 |
+
array allocated with YYSTACK_ALLOC. yy_lac may overwrite the
|
| 1045 |
+
contents of either array, alter *YYES and *YYES_CAPACITY, and free
|
| 1046 |
+
any old *YYES other than YYESA. */
|
| 1047 |
+
static int
|
| 1048 |
+
yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
|
| 1049 |
+
YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, yysymbol_kind_t yytoken)
|
| 1050 |
+
{
|
| 1051 |
+
yy_state_t *yyes_prev = yyssp;
|
| 1052 |
+
yy_state_t *yyesp = yyes_prev;
|
| 1053 |
+
/* Reduce until we encounter a shift and thereby accept the token. */
|
| 1054 |
+
YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yysymbol_name (yytoken)));
|
| 1055 |
+
if (yytoken == ]b4_symbol_prefix[YYUNDEF)
|
| 1056 |
+
{
|
| 1057 |
+
YYDPRINTF ((stderr, " Always Err\n"));
|
| 1058 |
+
return 1;
|
| 1059 |
+
}
|
| 1060 |
+
while (1)
|
| 1061 |
+
{
|
| 1062 |
+
int yyrule = yypact[+*yyesp];
|
| 1063 |
+
if (yypact_value_is_default (yyrule)
|
| 1064 |
+
|| (yyrule += yytoken) < 0 || YYLAST < yyrule
|
| 1065 |
+
|| yycheck[yyrule] != yytoken)
|
| 1066 |
+
{
|
| 1067 |
+
/* Use the default action. */
|
| 1068 |
+
yyrule = yydefact[+*yyesp];
|
| 1069 |
+
if (yyrule == 0)
|
| 1070 |
+
{
|
| 1071 |
+
YYDPRINTF ((stderr, " Err\n"));
|
| 1072 |
+
return 1;
|
| 1073 |
+
}
|
| 1074 |
+
}
|
| 1075 |
+
else
|
| 1076 |
+
{
|
| 1077 |
+
/* Use the action from yytable. */
|
| 1078 |
+
yyrule = yytable[yyrule];
|
| 1079 |
+
if (yytable_value_is_error (yyrule))
|
| 1080 |
+
{
|
| 1081 |
+
YYDPRINTF ((stderr, " Err\n"));
|
| 1082 |
+
return 1;
|
| 1083 |
+
}
|
| 1084 |
+
if (0 < yyrule)
|
| 1085 |
+
{
|
| 1086 |
+
YYDPRINTF ((stderr, " S%d\n", yyrule));
|
| 1087 |
+
return 0;
|
| 1088 |
+
}
|
| 1089 |
+
yyrule = -yyrule;
|
| 1090 |
+
}
|
| 1091 |
+
/* By now we know we have to simulate a reduce. */
|
| 1092 |
+
YYDPRINTF ((stderr, " R%d", yyrule - 1));
|
| 1093 |
+
{
|
| 1094 |
+
/* Pop the corresponding number of values from the stack. */
|
| 1095 |
+
YYPTRDIFF_T yylen = yyr2[yyrule];
|
| 1096 |
+
/* First pop from the LAC stack as many tokens as possible. */
|
| 1097 |
+
if (yyesp != yyes_prev)
|
| 1098 |
+
{
|
| 1099 |
+
YYPTRDIFF_T yysize = yyesp - *yyes + 1;
|
| 1100 |
+
if (yylen < yysize)
|
| 1101 |
+
{
|
| 1102 |
+
yyesp -= yylen;
|
| 1103 |
+
yylen = 0;
|
| 1104 |
+
}
|
| 1105 |
+
else
|
| 1106 |
+
{
|
| 1107 |
+
yyesp = yyes_prev;
|
| 1108 |
+
yylen -= yysize;
|
| 1109 |
+
}
|
| 1110 |
+
}
|
| 1111 |
+
/* Only afterwards look at the main stack. */
|
| 1112 |
+
if (yylen)
|
| 1113 |
+
yyesp = yyes_prev -= yylen;
|
| 1114 |
+
}
|
| 1115 |
+
/* Push the resulting state of the reduction. */
|
| 1116 |
+
{
|
| 1117 |
+
yy_state_fast_t yystate;
|
| 1118 |
+
{
|
| 1119 |
+
const int yylhs = yyr1[yyrule] - YYNTOKENS;
|
| 1120 |
+
const int yyi = yypgoto[yylhs] + *yyesp;
|
| 1121 |
+
yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyesp
|
| 1122 |
+
? yytable[yyi]
|
| 1123 |
+
: yydefgoto[yylhs]);
|
| 1124 |
+
}
|
| 1125 |
+
if (yyesp == yyes_prev)
|
| 1126 |
+
{
|
| 1127 |
+
yyesp = *yyes;
|
| 1128 |
+
YY_IGNORE_USELESS_CAST_BEGIN
|
| 1129 |
+
*yyesp = YY_CAST (yy_state_t, yystate);
|
| 1130 |
+
YY_IGNORE_USELESS_CAST_END
|
| 1131 |
+
}
|
| 1132 |
+
else
|
| 1133 |
+
{
|
| 1134 |
+
if (yy_lac_stack_realloc (yyes_capacity, 1,
|
| 1135 |
+
#if ]b4_api_PREFIX[DEBUG
|
| 1136 |
+
" (", ")",
|
| 1137 |
+
#endif
|
| 1138 |
+
yyes, yyesa, &yyesp, yyes_prev))
|
| 1139 |
+
{
|
| 1140 |
+
YYDPRINTF ((stderr, "\n"));
|
| 1141 |
+
return YYENOMEM;
|
| 1142 |
+
}
|
| 1143 |
+
YY_IGNORE_USELESS_CAST_BEGIN
|
| 1144 |
+
*++yyesp = YY_CAST (yy_state_t, yystate);
|
| 1145 |
+
YY_IGNORE_USELESS_CAST_END
|
| 1146 |
+
}
|
| 1147 |
+
YYDPRINTF ((stderr, " G%d", yystate));
|
| 1148 |
+
}
|
| 1149 |
+
}
|
| 1150 |
+
}]])[
|
| 1151 |
+
|
| 1152 |
+
]b4_parse_error_case([simple], [],
|
| 1153 |
+
[[/* Context of a parse error. */
|
| 1154 |
+
typedef struct
|
| 1155 |
+
{]b4_push_if([[
|
| 1156 |
+
yypstate* yyps;]], [[
|
| 1157 |
+
yy_state_t *yyssp;]b4_lac_if([[
|
| 1158 |
+
yy_state_t *yyesa;
|
| 1159 |
+
yy_state_t **yyes;
|
| 1160 |
+
YYPTRDIFF_T *yyes_capacity;]])])[
|
| 1161 |
+
yysymbol_kind_t yytoken;]b4_locations_if([[
|
| 1162 |
+
YYLTYPE *yylloc;]])[
|
| 1163 |
+
} yypcontext_t;
|
| 1164 |
+
|
| 1165 |
+
/* Put in YYARG at most YYARGN of the expected tokens given the
|
| 1166 |
+
current YYCTX, and return the number of tokens stored in YYARG. If
|
| 1167 |
+
YYARG is null, return the number of expected tokens (guaranteed to
|
| 1168 |
+
be less than YYNTOKENS). Return YYENOMEM on memory exhaustion.
|
| 1169 |
+
Return 0 if there are more than YYARGN expected tokens, yet fill
|
| 1170 |
+
YYARG up to YYARGN. */]b4_push_if([[
|
| 1171 |
+
static int
|
| 1172 |
+
yypstate_expected_tokens (yypstate *yyps,
|
| 1173 |
+
yysymbol_kind_t yyarg[], int yyargn)]], [[
|
| 1174 |
+
static int
|
| 1175 |
+
yypcontext_expected_tokens (const yypcontext_t *yyctx,
|
| 1176 |
+
yysymbol_kind_t yyarg[], int yyargn)]])[
|
| 1177 |
+
{
|
| 1178 |
+
/* Actual size of YYARG. */
|
| 1179 |
+
int yycount = 0;
|
| 1180 |
+
]b4_lac_if([[
|
| 1181 |
+
int yyx;
|
| 1182 |
+
for (yyx = 0; yyx < YYNTOKENS; ++yyx)
|
| 1183 |
+
{
|
| 1184 |
+
yysymbol_kind_t yysym = YY_CAST (yysymbol_kind_t, yyx);
|
| 1185 |
+
if (yysym != ]b4_symbol(error, kind)[ && yysym != ]b4_symbol_prefix[YYUNDEF)
|
| 1186 |
+
switch (yy_lac (]b4_push_if([[yyps->yyesa, &yyps->yyes, &yyps->yyes_capacity, yyps->yyssp, yysym]],
|
| 1187 |
+
[[yyctx->yyesa, yyctx->yyes, yyctx->yyes_capacity, yyctx->yyssp, yysym]])[))
|
| 1188 |
+
{
|
| 1189 |
+
case YYENOMEM:
|
| 1190 |
+
return YYENOMEM;
|
| 1191 |
+
case 1:
|
| 1192 |
+
continue;
|
| 1193 |
+
default:
|
| 1194 |
+
if (!yyarg)
|
| 1195 |
+
++yycount;
|
| 1196 |
+
else if (yycount == yyargn)
|
| 1197 |
+
return 0;
|
| 1198 |
+
else
|
| 1199 |
+
yyarg[yycount++] = yysym;
|
| 1200 |
+
}
|
| 1201 |
+
}]],
|
| 1202 |
+
[[ int yyn = yypact@{+*]b4_push_if([yyps], [yyctx])[->yyssp@};
|
| 1203 |
+
if (!yypact_value_is_default (yyn))
|
| 1204 |
+
{
|
| 1205 |
+
/* Start YYX at -YYN if negative to avoid negative indexes in
|
| 1206 |
+
YYCHECK. In other words, skip the first -YYN actions for
|
| 1207 |
+
this state because they are default actions. */
|
| 1208 |
+
int yyxbegin = yyn < 0 ? -yyn : 0;
|
| 1209 |
+
/* Stay within bounds of both yycheck and yytname. */
|
| 1210 |
+
int yychecklim = YYLAST - yyn + 1;
|
| 1211 |
+
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
| 1212 |
+
int yyx;
|
| 1213 |
+
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
|
| 1214 |
+
if (yycheck[yyx + yyn] == yyx && yyx != ]b4_symbol(error, kind)[
|
| 1215 |
+
&& !yytable_value_is_error (yytable[yyx + yyn]))
|
| 1216 |
+
{
|
| 1217 |
+
if (!yyarg)
|
| 1218 |
+
++yycount;
|
| 1219 |
+
else if (yycount == yyargn)
|
| 1220 |
+
return 0;
|
| 1221 |
+
else
|
| 1222 |
+
yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx);
|
| 1223 |
+
}
|
| 1224 |
+
}]])[
|
| 1225 |
+
if (yyarg && yycount == 0 && 0 < yyargn)
|
| 1226 |
+
yyarg[0] = ]b4_symbol(empty, kind)[;
|
| 1227 |
+
return yycount;
|
| 1228 |
+
}
|
| 1229 |
+
|
| 1230 |
+
]b4_push_if([[
|
| 1231 |
+
/* Similar to the previous function. */
|
| 1232 |
+
static int
|
| 1233 |
+
yypcontext_expected_tokens (const yypcontext_t *yyctx,
|
| 1234 |
+
yysymbol_kind_t yyarg[], int yyargn)
|
| 1235 |
+
{
|
| 1236 |
+
return yypstate_expected_tokens (yyctx->yyps, yyarg, yyargn);
|
| 1237 |
+
}]])[
|
| 1238 |
+
]])[
|
| 1239 |
+
|
| 1240 |
+
]b4_parse_error_bmatch(
|
| 1241 |
+
[custom],
|
| 1242 |
+
[[/* The kind of the lookahead of this context. */
|
| 1243 |
+
static yysymbol_kind_t
|
| 1244 |
+
yypcontext_token (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED;
|
| 1245 |
+
|
| 1246 |
+
static yysymbol_kind_t
|
| 1247 |
+
yypcontext_token (const yypcontext_t *yyctx)
|
| 1248 |
+
{
|
| 1249 |
+
return yyctx->yytoken;
|
| 1250 |
+
}
|
| 1251 |
+
|
| 1252 |
+
]b4_locations_if([[/* The location of the lookahead of this context. */
|
| 1253 |
+
static YYLTYPE *
|
| 1254 |
+
yypcontext_location (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED;
|
| 1255 |
+
|
| 1256 |
+
static YYLTYPE *
|
| 1257 |
+
yypcontext_location (const yypcontext_t *yyctx)
|
| 1258 |
+
{
|
| 1259 |
+
return yyctx->yylloc;
|
| 1260 |
+
}]])[
|
| 1261 |
+
|
| 1262 |
+
/* User defined function to report a syntax error. */
|
| 1263 |
+
static int
|
| 1264 |
+
yyreport_syntax_error (const yypcontext_t *yyctx]b4_user_formals[);]],
|
| 1265 |
+
[detailed\|verbose],
|
| 1266 |
+
[[#ifndef yystrlen
|
| 1267 |
+
# if defined __GLIBC__ && defined _STRING_H
|
| 1268 |
+
# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
|
| 1269 |
+
# else
|
| 1270 |
+
/* Return the length of YYSTR. */
|
| 1271 |
+
static YYPTRDIFF_T
|
| 1272 |
+
yystrlen (const char *yystr)
|
| 1273 |
+
{
|
| 1274 |
+
YYPTRDIFF_T yylen;
|
| 1275 |
+
for (yylen = 0; yystr[yylen]; yylen++)
|
| 1276 |
+
continue;
|
| 1277 |
+
return yylen;
|
| 1278 |
+
}
|
| 1279 |
+
# endif
|
| 1280 |
+
#endif
|
| 1281 |
+
|
| 1282 |
+
#ifndef yystpcpy
|
| 1283 |
+
# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
|
| 1284 |
+
# define yystpcpy stpcpy
|
| 1285 |
+
# else
|
| 1286 |
+
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
|
| 1287 |
+
YYDEST. */
|
| 1288 |
+
static char *
|
| 1289 |
+
yystpcpy (char *yydest, const char *yysrc)
|
| 1290 |
+
{
|
| 1291 |
+
char *yyd = yydest;
|
| 1292 |
+
const char *yys = yysrc;
|
| 1293 |
+
|
| 1294 |
+
while ((*yyd++ = *yys++) != '\0')
|
| 1295 |
+
continue;
|
| 1296 |
+
|
| 1297 |
+
return yyd - 1;
|
| 1298 |
+
}
|
| 1299 |
+
# endif
|
| 1300 |
+
#endif
|
| 1301 |
+
|
| 1302 |
+
]b4_parse_error_case(
|
| 1303 |
+
[verbose],
|
| 1304 |
+
[[#ifndef yytnamerr
|
| 1305 |
+
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
|
| 1306 |
+
quotes and backslashes, so that it's suitable for yyerror. The
|
| 1307 |
+
heuristic is that double-quoting is unnecessary unless the string
|
| 1308 |
+
contains an apostrophe, a comma, or backslash (other than
|
| 1309 |
+
backslash-backslash). YYSTR is taken from yytname. If YYRES is
|
| 1310 |
+
null, do not copy; instead, return the length of what the result
|
| 1311 |
+
would have been. */
|
| 1312 |
+
static YYPTRDIFF_T
|
| 1313 |
+
yytnamerr (char *yyres, const char *yystr)
|
| 1314 |
+
{
|
| 1315 |
+
if (*yystr == '"')
|
| 1316 |
+
{
|
| 1317 |
+
YYPTRDIFF_T yyn = 0;
|
| 1318 |
+
char const *yyp = yystr;
|
| 1319 |
+
for (;;)
|
| 1320 |
+
switch (*++yyp)
|
| 1321 |
+
{
|
| 1322 |
+
case '\'':
|
| 1323 |
+
case ',':
|
| 1324 |
+
goto do_not_strip_quotes;
|
| 1325 |
+
|
| 1326 |
+
case '\\':
|
| 1327 |
+
if (*++yyp != '\\')
|
| 1328 |
+
goto do_not_strip_quotes;
|
| 1329 |
+
else
|
| 1330 |
+
goto append;
|
| 1331 |
+
|
| 1332 |
+
append:
|
| 1333 |
+
default:
|
| 1334 |
+
if (yyres)
|
| 1335 |
+
yyres[yyn] = *yyp;
|
| 1336 |
+
yyn++;
|
| 1337 |
+
break;
|
| 1338 |
+
|
| 1339 |
+
case '"':
|
| 1340 |
+
if (yyres)
|
| 1341 |
+
yyres[yyn] = '\0';
|
| 1342 |
+
return yyn;
|
| 1343 |
+
}
|
| 1344 |
+
do_not_strip_quotes: ;
|
| 1345 |
+
}
|
| 1346 |
+
|
| 1347 |
+
if (yyres)
|
| 1348 |
+
return yystpcpy (yyres, yystr) - yyres;
|
| 1349 |
+
else
|
| 1350 |
+
return yystrlen (yystr);
|
| 1351 |
+
}
|
| 1352 |
+
#endif
|
| 1353 |
+
]])[
|
| 1354 |
+
|
| 1355 |
+
static int
|
| 1356 |
+
yy_syntax_error_arguments (const yypcontext_t *yyctx,
|
| 1357 |
+
yysymbol_kind_t yyarg[], int yyargn)
|
| 1358 |
+
{
|
| 1359 |
+
/* Actual size of YYARG. */
|
| 1360 |
+
int yycount = 0;
|
| 1361 |
+
/* There are many possibilities here to consider:
|
| 1362 |
+
- If this state is a consistent state with a default action, then
|
| 1363 |
+
the only way this function was invoked is if the default action
|
| 1364 |
+
is an error action. In that case, don't check for expected
|
| 1365 |
+
tokens because there are none.
|
| 1366 |
+
- The only way there can be no lookahead present (in yychar) is if
|
| 1367 |
+
this state is a consistent state with a default action. Thus,
|
| 1368 |
+
detecting the absence of a lookahead is sufficient to determine
|
| 1369 |
+
that there is no unexpected or expected token to report. In that
|
| 1370 |
+
case, just report a simple "syntax error".
|
| 1371 |
+
- Don't assume there isn't a lookahead just because this state is a
|
| 1372 |
+
consistent state with a default action. There might have been a
|
| 1373 |
+
previous inconsistent state, consistent state with a non-default
|
| 1374 |
+
action, or user semantic action that manipulated yychar.]b4_lac_if([[
|
| 1375 |
+
In the first two cases, it might appear that the current syntax
|
| 1376 |
+
error should have been detected in the previous state when yy_lac
|
| 1377 |
+
was invoked. However, at that time, there might have been a
|
| 1378 |
+
different syntax error that discarded a different initial context
|
| 1379 |
+
during error recovery, leaving behind the current lookahead.]], [[
|
| 1380 |
+
- Of course, the expected token list depends on states to have
|
| 1381 |
+
correct lookahead information, and it depends on the parser not
|
| 1382 |
+
to perform extra reductions after fetching a lookahead from the
|
| 1383 |
+
scanner and before detecting a syntax error. Thus, state merging
|
| 1384 |
+
(from LALR or IELR) and default reductions corrupt the expected
|
| 1385 |
+
token list. However, the list is correct for canonical LR with
|
| 1386 |
+
one exception: it will still contain any token that will not be
|
| 1387 |
+
accepted due to an error action in a later state.]])[
|
| 1388 |
+
*/
|
| 1389 |
+
if (yyctx->yytoken != ]b4_symbol(empty, kind)[)
|
| 1390 |
+
{
|
| 1391 |
+
int yyn;]b4_lac_if([[
|
| 1392 |
+
YYDPRINTF ((stderr, "Constructing syntax error message\n"));]])[
|
| 1393 |
+
if (yyarg)
|
| 1394 |
+
yyarg[yycount] = yyctx->yytoken;
|
| 1395 |
+
++yycount;
|
| 1396 |
+
yyn = yypcontext_expected_tokens (yyctx,
|
| 1397 |
+
yyarg ? yyarg + 1 : yyarg, yyargn - 1);
|
| 1398 |
+
if (yyn == YYENOMEM)
|
| 1399 |
+
return YYENOMEM;]b4_lac_if([[
|
| 1400 |
+
else if (yyn == 0)
|
| 1401 |
+
YYDPRINTF ((stderr, "No expected tokens.\n"));]])[
|
| 1402 |
+
else
|
| 1403 |
+
yycount += yyn;
|
| 1404 |
+
}
|
| 1405 |
+
return yycount;
|
| 1406 |
+
}
|
| 1407 |
+
|
| 1408 |
+
/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
|
| 1409 |
+
about the unexpected token YYTOKEN for the state stack whose top is
|
| 1410 |
+
YYSSP.]b4_lac_if([[ In order to see if a particular token T is a
|
| 1411 |
+
valid looakhead, invoke yy_lac (YYESA, YYES, YYES_CAPACITY, YYSSP, T).]])[
|
| 1412 |
+
|
| 1413 |
+
Return 0 if *YYMSG was successfully written. Return -1 if *YYMSG is
|
| 1414 |
+
not large enough to hold the message. In that case, also set
|
| 1415 |
+
*YYMSG_ALLOC to the required number of bytes. Return YYENOMEM if the
|
| 1416 |
+
required number of bytes is too large to store]b4_lac_if([[ or if
|
| 1417 |
+
yy_lac returned YYENOMEM]])[. */
|
| 1418 |
+
static int
|
| 1419 |
+
yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
|
| 1420 |
+
const yypcontext_t *yyctx)
|
| 1421 |
+
{
|
| 1422 |
+
enum { YYARGS_MAX = 5 };
|
| 1423 |
+
/* Internationalized format string. */
|
| 1424 |
+
const char *yyformat = YY_NULLPTR;
|
| 1425 |
+
/* Arguments of yyformat: reported tokens (one for the "unexpected",
|
| 1426 |
+
one per "expected"). */
|
| 1427 |
+
yysymbol_kind_t yyarg[YYARGS_MAX];
|
| 1428 |
+
/* Cumulated lengths of YYARG. */
|
| 1429 |
+
YYPTRDIFF_T yysize = 0;
|
| 1430 |
+
|
| 1431 |
+
/* Actual size of YYARG. */
|
| 1432 |
+
int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX);
|
| 1433 |
+
if (yycount == YYENOMEM)
|
| 1434 |
+
return YYENOMEM;
|
| 1435 |
+
|
| 1436 |
+
switch (yycount)
|
| 1437 |
+
{
|
| 1438 |
+
#define YYCASE_(N, S) \
|
| 1439 |
+
case N: \
|
| 1440 |
+
yyformat = S; \
|
| 1441 |
+
break
|
| 1442 |
+
default: /* Avoid compiler warnings. */
|
| 1443 |
+
YYCASE_(0, YY_("syntax error"));
|
| 1444 |
+
YYCASE_(1, YY_("syntax error, unexpected %s"));
|
| 1445 |
+
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
|
| 1446 |
+
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
|
| 1447 |
+
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
|
| 1448 |
+
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
|
| 1449 |
+
#undef YYCASE_
|
| 1450 |
+
}
|
| 1451 |
+
|
| 1452 |
+
/* Compute error message size. Don't count the "%s"s, but reserve
|
| 1453 |
+
room for the terminator. */
|
| 1454 |
+
yysize = yystrlen (yyformat) - 2 * yycount + 1;
|
| 1455 |
+
{
|
| 1456 |
+
int yyi;
|
| 1457 |
+
for (yyi = 0; yyi < yycount; ++yyi)
|
| 1458 |
+
{
|
| 1459 |
+
YYPTRDIFF_T yysize1
|
| 1460 |
+
= yysize + ]b4_parse_error_case(
|
| 1461 |
+
[verbose], [[yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]])]],
|
| 1462 |
+
[[yystrlen (yysymbol_name (yyarg[yyi]))]]);[
|
| 1463 |
+
if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
|
| 1464 |
+
yysize = yysize1;
|
| 1465 |
+
else
|
| 1466 |
+
return YYENOMEM;
|
| 1467 |
+
}
|
| 1468 |
+
}
|
| 1469 |
+
|
| 1470 |
+
if (*yymsg_alloc < yysize)
|
| 1471 |
+
{
|
| 1472 |
+
*yymsg_alloc = 2 * yysize;
|
| 1473 |
+
if (! (yysize <= *yymsg_alloc
|
| 1474 |
+
&& *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
|
| 1475 |
+
*yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
|
| 1476 |
+
return -1;
|
| 1477 |
+
}
|
| 1478 |
+
|
| 1479 |
+
/* Avoid sprintf, as that infringes on the user's name space.
|
| 1480 |
+
Don't have undefined behavior even if the translation
|
| 1481 |
+
produced a string with the wrong number of "%s"s. */
|
| 1482 |
+
{
|
| 1483 |
+
char *yyp = *yymsg;
|
| 1484 |
+
int yyi = 0;
|
| 1485 |
+
while ((*yyp = *yyformat) != '\0')
|
| 1486 |
+
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
|
| 1487 |
+
{]b4_parse_error_case([verbose], [[
|
| 1488 |
+
yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);]], [[
|
| 1489 |
+
yyp = yystpcpy (yyp, yysymbol_name (yyarg[yyi++]));]])[
|
| 1490 |
+
yyformat += 2;
|
| 1491 |
+
}
|
| 1492 |
+
else
|
| 1493 |
+
{
|
| 1494 |
+
++yyp;
|
| 1495 |
+
++yyformat;
|
| 1496 |
+
}
|
| 1497 |
+
}
|
| 1498 |
+
return 0;
|
| 1499 |
+
}
|
| 1500 |
+
]])[
|
| 1501 |
+
|
| 1502 |
+
]b4_yydestruct_define[
|
| 1503 |
+
|
| 1504 |
+
]b4_pure_if([], [b4_declare_scanner_communication_variables])[
|
| 1505 |
+
|
| 1506 |
+
]b4_push_if([b4_pull_if([[
|
| 1507 |
+
|
| 1508 |
+
int
|
| 1509 |
+
yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)
|
| 1510 |
+
{
|
| 1511 |
+
yypstate *yyps = yypstate_new ();
|
| 1512 |
+
if (!yyps)
|
| 1513 |
+
{]b4_pure_if([b4_locations_if([[
|
| 1514 |
+
static YYLTYPE yyloc_default][]b4_yyloc_default[;
|
| 1515 |
+
YYLTYPE yylloc = yyloc_default;]])[
|
| 1516 |
+
yyerror (]b4_yyerror_args[YY_("memory exhausted"));]], [[
|
| 1517 |
+
if (!yypstate_allocated)
|
| 1518 |
+
yyerror (]b4_yyerror_args[YY_("memory exhausted"));]])[
|
| 1519 |
+
return 2;
|
| 1520 |
+
}
|
| 1521 |
+
int yystatus = yypull_parse (yyps]b4_user_args[);
|
| 1522 |
+
yypstate_delete (yyps);
|
| 1523 |
+
return yystatus;
|
| 1524 |
+
}
|
| 1525 |
+
|
| 1526 |
+
int
|
| 1527 |
+
yypull_parse (yypstate *yyps]b4_user_formals[)
|
| 1528 |
+
{
|
| 1529 |
+
YY_ASSERT (yyps);]b4_pure_if([b4_locations_if([[
|
| 1530 |
+
static YYLTYPE yyloc_default][]b4_yyloc_default[;
|
| 1531 |
+
YYLTYPE yylloc = yyloc_default;]])])[
|
| 1532 |
+
int yystatus;
|
| 1533 |
+
do {
|
| 1534 |
+
]b4_pure_if([[ YYSTYPE yylval;
|
| 1535 |
+
int ]])[yychar = ]b4_yylex[;
|
| 1536 |
+
yystatus = yypush_parse (yyps]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])[);
|
| 1537 |
+
} while (yystatus == YYPUSH_MORE);
|
| 1538 |
+
return yystatus;
|
| 1539 |
+
}]])[
|
| 1540 |
+
|
| 1541 |
+
]b4_parse_state_variable_macros([b4_pstate_macro_define])[
|
| 1542 |
+
|
| 1543 |
+
/* Initialize the parser data structure. */
|
| 1544 |
+
static void
|
| 1545 |
+
yypstate_clear (yypstate *yyps)
|
| 1546 |
+
{
|
| 1547 |
+
yynerrs = 0;
|
| 1548 |
+
yystate = 0;
|
| 1549 |
+
yyerrstatus = 0;
|
| 1550 |
+
|
| 1551 |
+
yyssp = yyss;
|
| 1552 |
+
yyvsp = yyvs;]b4_locations_if([[
|
| 1553 |
+
yylsp = yyls;]])[
|
| 1554 |
+
|
| 1555 |
+
/* Initialize the state stack, in case yypcontext_expected_tokens is
|
| 1556 |
+
called before the first call to yyparse. */
|
| 1557 |
+
*yyssp = 0;
|
| 1558 |
+
yyps->yynew = 1;
|
| 1559 |
+
}
|
| 1560 |
+
|
| 1561 |
+
/* Initialize the parser data structure. */
|
| 1562 |
+
yypstate *
|
| 1563 |
+
yypstate_new (void)
|
| 1564 |
+
{
|
| 1565 |
+
yypstate *yyps;]b4_pure_if([], [[
|
| 1566 |
+
if (yypstate_allocated)
|
| 1567 |
+
return YY_NULLPTR;]])[
|
| 1568 |
+
yyps = YY_CAST (yypstate *, YYMALLOC (sizeof *yyps));
|
| 1569 |
+
if (!yyps)
|
| 1570 |
+
return YY_NULLPTR;]b4_pure_if([], [[
|
| 1571 |
+
yypstate_allocated = 1;]])[
|
| 1572 |
+
yystacksize = YYINITDEPTH;
|
| 1573 |
+
yyss = yyssa;
|
| 1574 |
+
yyvs = yyvsa;]b4_locations_if([[
|
| 1575 |
+
yyls = yylsa;]])[]b4_lac_if([[
|
| 1576 |
+
yyes = yyesa;
|
| 1577 |
+
yyes_capacity = ]b4_percent_define_get([[parse.lac.es-capacity-initial]])[;
|
| 1578 |
+
if (YYMAXDEPTH < yyes_capacity)
|
| 1579 |
+
yyes_capacity = YYMAXDEPTH;]])[
|
| 1580 |
+
yypstate_clear (yyps);
|
| 1581 |
+
return yyps;
|
| 1582 |
+
}
|
| 1583 |
+
|
| 1584 |
+
void
|
| 1585 |
+
yypstate_delete (yypstate *yyps)
|
| 1586 |
+
{
|
| 1587 |
+
if (yyps)
|
| 1588 |
+
{
|
| 1589 |
+
#ifndef yyoverflow
|
| 1590 |
+
/* If the stack was reallocated but the parse did not complete, then the
|
| 1591 |
+
stack still needs to be freed. */
|
| 1592 |
+
if (yyss != yyssa)
|
| 1593 |
+
YYSTACK_FREE (yyss);
|
| 1594 |
+
#endif]b4_lac_if([[
|
| 1595 |
+
if (yyes != yyesa)
|
| 1596 |
+
YYSTACK_FREE (yyes);]])[
|
| 1597 |
+
YYFREE (yyps);]b4_pure_if([], [[
|
| 1598 |
+
yypstate_allocated = 0;]])[
|
| 1599 |
+
}
|
| 1600 |
+
}
|
| 1601 |
+
]])[
|
| 1602 |
+
|
| 1603 |
+
]b4_push_if([[
|
| 1604 |
+
/*---------------.
|
| 1605 |
+
| yypush_parse. |
|
| 1606 |
+
`---------------*/
|
| 1607 |
+
|
| 1608 |
+
int
|
| 1609 |
+
yypush_parse (yypstate *yyps]b4_pure_if([[,
|
| 1610 |
+
int yypushed_char, YYSTYPE const *yypushed_val]b4_locations_if([[, YYLTYPE *yypushed_loc]])])b4_user_formals[)]],
|
| 1611 |
+
[[
|
| 1612 |
+
/*----------.
|
| 1613 |
+
| yyparse. |
|
| 1614 |
+
`----------*/
|
| 1615 |
+
|
| 1616 |
+
]m4_ifdef([b4_start_symbols],
|
| 1617 |
+
[[// Extract data from the parser.
|
| 1618 |
+
typedef struct
|
| 1619 |
+
{
|
| 1620 |
+
YYSTYPE yyvalue;
|
| 1621 |
+
int yynerrs;
|
| 1622 |
+
} yy_parse_impl_t;
|
| 1623 |
+
|
| 1624 |
+
// Run a full parse, using YYCHAR as switching token.
|
| 1625 |
+
static int
|
| 1626 |
+
yy_parse_impl (int yychar, yy_parse_impl_t *yyimpl]m4_ifset([b4_parse_param], [, b4_formals(b4_parse_param)])[);
|
| 1627 |
+
|
| 1628 |
+
]m4_map([_b4_define_sub_yyparse], m4_defn([b4_start_symbols]))[
|
| 1629 |
+
|
| 1630 |
+
int
|
| 1631 |
+
yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)
|
| 1632 |
+
{
|
| 1633 |
+
return yy_parse_impl (]b4_symbol(_b4_first_switching_token, id)[, YY_NULLPTR]m4_ifset([b4_parse_param],
|
| 1634 |
+
[[, ]b4_args(b4_parse_param)])[);
|
| 1635 |
+
}
|
| 1636 |
+
|
| 1637 |
+
static int
|
| 1638 |
+
yy_parse_impl (int yychar, yy_parse_impl_t *yyimpl]m4_ifset([b4_parse_param], [, b4_formals(b4_parse_param)])[)]],
|
| 1639 |
+
[[int
|
| 1640 |
+
yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)]])])[
|
| 1641 |
+
{]b4_pure_if([b4_declare_scanner_communication_variables
|
| 1642 |
+
])b4_push_if([b4_pure_if([], [[
|
| 1643 |
+
int yypushed_char = yychar;
|
| 1644 |
+
YYSTYPE yypushed_val = yylval;]b4_locations_if([[
|
| 1645 |
+
YYLTYPE yypushed_loc = yylloc;]])
|
| 1646 |
+
])],
|
| 1647 |
+
[b4_declare_parser_state_variables([init])
|
| 1648 |
+
])b4_lac_if([[
|
| 1649 |
+
/* Whether LAC context is established. A Boolean. */
|
| 1650 |
+
int yy_lac_established = 0;]])[
|
| 1651 |
+
int yyn;
|
| 1652 |
+
/* The return value of yyparse. */
|
| 1653 |
+
int yyresult;
|
| 1654 |
+
/* Lookahead symbol kind. */
|
| 1655 |
+
yysymbol_kind_t yytoken = ]b4_symbol(empty, kind)[;
|
| 1656 |
+
/* The variables used to return semantic value and location from the
|
| 1657 |
+
action routines. */
|
| 1658 |
+
YYSTYPE yyval;]b4_locations_if([[
|
| 1659 |
+
YYLTYPE yyloc;
|
| 1660 |
+
|
| 1661 |
+
/* The locations where the error started and ended. */
|
| 1662 |
+
YYLTYPE yyerror_range[3];]])[
|
| 1663 |
+
|
| 1664 |
+
]b4_parse_error_bmatch([detailed\|verbose],
|
| 1665 |
+
[[ /* Buffer for error messages, and its allocated size. */
|
| 1666 |
+
char yymsgbuf[128];
|
| 1667 |
+
char *yymsg = yymsgbuf;
|
| 1668 |
+
YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;]])[
|
| 1669 |
+
|
| 1670 |
+
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[)
|
| 1671 |
+
|
| 1672 |
+
/* The number of symbols on the RHS of the reduced rule.
|
| 1673 |
+
Keep to zero when no symbol should be popped. */
|
| 1674 |
+
int yylen = 0;]b4_push_if([[
|
| 1675 |
+
|
| 1676 |
+
switch (yyps->yynew)
|
| 1677 |
+
{
|
| 1678 |
+
case 0:
|
| 1679 |
+
yyn = yypact[yystate];
|
| 1680 |
+
goto yyread_pushed_token;
|
| 1681 |
+
|
| 1682 |
+
case 2:
|
| 1683 |
+
yypstate_clear (yyps);
|
| 1684 |
+
break;
|
| 1685 |
+
|
| 1686 |
+
default:
|
| 1687 |
+
break;
|
| 1688 |
+
}]])[
|
| 1689 |
+
|
| 1690 |
+
YYDPRINTF ((stderr, "Starting parse\n"));
|
| 1691 |
+
|
| 1692 |
+
]m4_ifdef([b4_start_symbols], [],
|
| 1693 |
+
[[ yychar = ]b4_symbol(empty, id)[; /* Cause a token to be read. */
|
| 1694 |
+
]])[
|
| 1695 |
+
]m4_ifdef([b4_initial_action], [
|
| 1696 |
+
b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [], [],
|
| 1697 |
+
[b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])])dnl
|
| 1698 |
+
b4_user_initial_action
|
| 1699 |
+
b4_dollar_popdef[]dnl
|
| 1700 |
+
m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval;
|
| 1701 |
+
]])])dnl
|
| 1702 |
+
b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])[;
|
| 1703 |
+
]])dnl
|
| 1704 |
+
[ goto yysetstate;
|
| 1705 |
+
|
| 1706 |
+
|
| 1707 |
+
/*------------------------------------------------------------.
|
| 1708 |
+
| yynewstate -- push a new state, which is found in yystate. |
|
| 1709 |
+
`------------------------------------------------------------*/
|
| 1710 |
+
yynewstate:
|
| 1711 |
+
/* In all cases, when you get here, the value and location stacks
|
| 1712 |
+
have just been pushed. So pushing a state here evens the stacks. */
|
| 1713 |
+
yyssp++;
|
| 1714 |
+
|
| 1715 |
+
|
| 1716 |
+
/*--------------------------------------------------------------------.
|
| 1717 |
+
| yysetstate -- set current state (the top of the stack) to yystate. |
|
| 1718 |
+
`--------------------------------------------------------------------*/
|
| 1719 |
+
yysetstate:
|
| 1720 |
+
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
| 1721 |
+
YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
|
| 1722 |
+
YY_IGNORE_USELESS_CAST_BEGIN
|
| 1723 |
+
*yyssp = YY_CAST (yy_state_t, yystate);
|
| 1724 |
+
YY_IGNORE_USELESS_CAST_END
|
| 1725 |
+
YY_STACK_PRINT (yyss, yyssp);
|
| 1726 |
+
|
| 1727 |
+
if (yyss + yystacksize - 1 <= yyssp)
|
| 1728 |
+
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
|
| 1729 |
+
YYNOMEM;
|
| 1730 |
+
#else
|
| 1731 |
+
{
|
| 1732 |
+
/* Get the current used size of the three stacks, in elements. */
|
| 1733 |
+
YYPTRDIFF_T yysize = yyssp - yyss + 1;
|
| 1734 |
+
|
| 1735 |
+
# if defined yyoverflow
|
| 1736 |
+
{
|
| 1737 |
+
/* Give user a chance to reallocate the stack. Use copies of
|
| 1738 |
+
these so that the &'s don't force the real ones into
|
| 1739 |
+
memory. */
|
| 1740 |
+
yy_state_t *yyss1 = yyss;
|
| 1741 |
+
YYSTYPE *yyvs1 = yyvs;]b4_locations_if([
|
| 1742 |
+
YYLTYPE *yyls1 = yyls;])[
|
| 1743 |
+
|
| 1744 |
+
/* Each stack pointer address is followed by the size of the
|
| 1745 |
+
data in use in that stack, in bytes. This used to be a
|
| 1746 |
+
conditional around just the two extra args, but that might
|
| 1747 |
+
be undefined if yyoverflow is a macro. */
|
| 1748 |
+
yyoverflow (YY_("memory exhausted"),
|
| 1749 |
+
&yyss1, yysize * YYSIZEOF (*yyssp),
|
| 1750 |
+
&yyvs1, yysize * YYSIZEOF (*yyvsp),]b4_locations_if([
|
| 1751 |
+
&yyls1, yysize * YYSIZEOF (*yylsp),])[
|
| 1752 |
+
&yystacksize);
|
| 1753 |
+
yyss = yyss1;
|
| 1754 |
+
yyvs = yyvs1;]b4_locations_if([
|
| 1755 |
+
yyls = yyls1;])[
|
| 1756 |
+
}
|
| 1757 |
+
# else /* defined YYSTACK_RELOCATE */
|
| 1758 |
+
/* Extend the stack our own way. */
|
| 1759 |
+
if (YYMAXDEPTH <= yystacksize)
|
| 1760 |
+
YYNOMEM;
|
| 1761 |
+
yystacksize *= 2;
|
| 1762 |
+
if (YYMAXDEPTH < yystacksize)
|
| 1763 |
+
yystacksize = YYMAXDEPTH;
|
| 1764 |
+
|
| 1765 |
+
{
|
| 1766 |
+
yy_state_t *yyss1 = yyss;
|
| 1767 |
+
union yyalloc *yyptr =
|
| 1768 |
+
YY_CAST (union yyalloc *,
|
| 1769 |
+
YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
|
| 1770 |
+
if (! yyptr)
|
| 1771 |
+
YYNOMEM;
|
| 1772 |
+
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
| 1773 |
+
YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
|
| 1774 |
+
YYSTACK_RELOCATE (yyls_alloc, yyls);])[
|
| 1775 |
+
# undef YYSTACK_RELOCATE
|
| 1776 |
+
if (yyss1 != yyssa)
|
| 1777 |
+
YYSTACK_FREE (yyss1);
|
| 1778 |
+
}
|
| 1779 |
+
# endif
|
| 1780 |
+
|
| 1781 |
+
yyssp = yyss + yysize - 1;
|
| 1782 |
+
yyvsp = yyvs + yysize - 1;]b4_locations_if([
|
| 1783 |
+
yylsp = yyls + yysize - 1;])[
|
| 1784 |
+
|
| 1785 |
+
YY_IGNORE_USELESS_CAST_BEGIN
|
| 1786 |
+
YYDPRINTF ((stderr, "Stack size increased to %ld\n",
|
| 1787 |
+
YY_CAST (long, yystacksize)));
|
| 1788 |
+
YY_IGNORE_USELESS_CAST_END
|
| 1789 |
+
|
| 1790 |
+
if (yyss + yystacksize - 1 <= yyssp)
|
| 1791 |
+
YYABORT;
|
| 1792 |
+
}
|
| 1793 |
+
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
|
| 1794 |
+
|
| 1795 |
+
]m4_ifdef([b4_start_symbols], [], [[
|
| 1796 |
+
if (yystate == YYFINAL)
|
| 1797 |
+
YYACCEPT;]])[
|
| 1798 |
+
|
| 1799 |
+
goto yybackup;
|
| 1800 |
+
|
| 1801 |
+
|
| 1802 |
+
/*-----------.
|
| 1803 |
+
| yybackup. |
|
| 1804 |
+
`-----------*/
|
| 1805 |
+
yybackup:
|
| 1806 |
+
/* Do appropriate processing given the current state. Read a
|
| 1807 |
+
lookahead token if we need one and don't already have one. */
|
| 1808 |
+
|
| 1809 |
+
/* First try to decide what to do without reference to lookahead token. */
|
| 1810 |
+
yyn = yypact[yystate];
|
| 1811 |
+
if (yypact_value_is_default (yyn))
|
| 1812 |
+
goto yydefault;
|
| 1813 |
+
|
| 1814 |
+
/* Not known => get a lookahead token if don't already have one. */
|
| 1815 |
+
|
| 1816 |
+
/* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
|
| 1817 |
+
if (yychar == ]b4_symbol(empty, id)[)
|
| 1818 |
+
{]b4_push_if([[
|
| 1819 |
+
if (!yyps->yynew)
|
| 1820 |
+
{]b4_use_push_for_pull_if([], [[
|
| 1821 |
+
YYDPRINTF ((stderr, "Return for a new token:\n"));]])[
|
| 1822 |
+
yyresult = YYPUSH_MORE;
|
| 1823 |
+
goto yypushreturn;
|
| 1824 |
+
}
|
| 1825 |
+
yyps->yynew = 0;]b4_pure_if([], [[
|
| 1826 |
+
/* Restoring the pushed token is only necessary for the first
|
| 1827 |
+
yypush_parse invocation since subsequent invocations don't overwrite
|
| 1828 |
+
it before jumping to yyread_pushed_token. */
|
| 1829 |
+
yychar = yypushed_char;
|
| 1830 |
+
yylval = yypushed_val;]b4_locations_if([[
|
| 1831 |
+
yylloc = yypushed_loc;]])])[
|
| 1832 |
+
yyread_pushed_token:]])[
|
| 1833 |
+
YYDPRINTF ((stderr, "Reading a token\n"));]b4_push_if([b4_pure_if([[
|
| 1834 |
+
yychar = yypushed_char;
|
| 1835 |
+
if (yypushed_val)
|
| 1836 |
+
yylval = *yypushed_val;]b4_locations_if([[
|
| 1837 |
+
if (yypushed_loc)
|
| 1838 |
+
yylloc = *yypushed_loc;]])])], [[
|
| 1839 |
+
yychar = ]b4_yylex[;]])[
|
| 1840 |
+
}
|
| 1841 |
+
|
| 1842 |
+
if (yychar <= ]b4_symbol(eof, [id])[)
|
| 1843 |
+
{
|
| 1844 |
+
yychar = ]b4_symbol(eof, [id])[;
|
| 1845 |
+
yytoken = ]b4_symbol(eof, [kind])[;
|
| 1846 |
+
YYDPRINTF ((stderr, "Now at end of input.\n"));
|
| 1847 |
+
}
|
| 1848 |
+
else if (yychar == ]b4_symbol(error, [id])[)
|
| 1849 |
+
{
|
| 1850 |
+
/* The scanner already issued an error message, process directly
|
| 1851 |
+
to error recovery. But do not keep the error token as
|
| 1852 |
+
lookahead, it is too special and may lead us to an endless
|
| 1853 |
+
loop in error recovery. */
|
| 1854 |
+
yychar = ]b4_symbol(undef, [id])[;
|
| 1855 |
+
yytoken = ]b4_symbol(error, [kind])[;]b4_locations_if([[
|
| 1856 |
+
yyerror_range[1] = yylloc;]])[
|
| 1857 |
+
goto yyerrlab1;
|
| 1858 |
+
}
|
| 1859 |
+
else
|
| 1860 |
+
{
|
| 1861 |
+
yytoken = YYTRANSLATE (yychar);
|
| 1862 |
+
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
|
| 1863 |
+
}
|
| 1864 |
+
|
| 1865 |
+
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
| 1866 |
+
detect an error, take that action. */
|
| 1867 |
+
yyn += yytoken;
|
| 1868 |
+
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)]b4_lac_if([[
|
| 1869 |
+
{
|
| 1870 |
+
YY_LAC_ESTABLISH;
|
| 1871 |
+
goto yydefault;
|
| 1872 |
+
}]], [[
|
| 1873 |
+
goto yydefault;]])[
|
| 1874 |
+
yyn = yytable[yyn];
|
| 1875 |
+
if (yyn <= 0)
|
| 1876 |
+
{
|
| 1877 |
+
if (yytable_value_is_error (yyn))
|
| 1878 |
+
goto yyerrlab;
|
| 1879 |
+
yyn = -yyn;]b4_lac_if([[
|
| 1880 |
+
YY_LAC_ESTABLISH;]])[
|
| 1881 |
+
goto yyreduce;
|
| 1882 |
+
}
|
| 1883 |
+
|
| 1884 |
+
/* Count tokens shifted since error; after three, turn off error
|
| 1885 |
+
status. */
|
| 1886 |
+
if (yyerrstatus)
|
| 1887 |
+
yyerrstatus--;
|
| 1888 |
+
|
| 1889 |
+
/* Shift the lookahead token. */
|
| 1890 |
+
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
|
| 1891 |
+
yystate = yyn;
|
| 1892 |
+
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
| 1893 |
+
*++yyvsp = yylval;
|
| 1894 |
+
YY_IGNORE_MAYBE_UNINITIALIZED_END]b4_locations_if([
|
| 1895 |
+
*++yylsp = yylloc;])[
|
| 1896 |
+
|
| 1897 |
+
/* Discard the shifted token. */
|
| 1898 |
+
yychar = ]b4_symbol(empty, id)[;]b4_lac_if([[
|
| 1899 |
+
YY_LAC_DISCARD ("shift");]])[
|
| 1900 |
+
goto yynewstate;
|
| 1901 |
+
|
| 1902 |
+
|
| 1903 |
+
/*-----------------------------------------------------------.
|
| 1904 |
+
| yydefault -- do the default action for the current state. |
|
| 1905 |
+
`-----------------------------------------------------------*/
|
| 1906 |
+
yydefault:
|
| 1907 |
+
yyn = yydefact[yystate];
|
| 1908 |
+
if (yyn == 0)
|
| 1909 |
+
goto yyerrlab;
|
| 1910 |
+
goto yyreduce;
|
| 1911 |
+
|
| 1912 |
+
|
| 1913 |
+
/*-----------------------------.
|
| 1914 |
+
| yyreduce -- do a reduction. |
|
| 1915 |
+
`-----------------------------*/
|
| 1916 |
+
yyreduce:
|
| 1917 |
+
/* yyn is the number of a rule to reduce with. */
|
| 1918 |
+
yylen = yyr2[yyn];
|
| 1919 |
+
|
| 1920 |
+
/* If YYLEN is nonzero, implement the default value of the action:
|
| 1921 |
+
'$$ = $1'.
|
| 1922 |
+
|
| 1923 |
+
Otherwise, the following line sets YYVAL to garbage.
|
| 1924 |
+
This behavior is undocumented and Bison
|
| 1925 |
+
users should not rely upon it. Assigning to YYVAL
|
| 1926 |
+
unconditionally makes the parser a bit smaller, and it avoids a
|
| 1927 |
+
GCC warning that YYVAL may be used uninitialized. */
|
| 1928 |
+
yyval = yyvsp[1-yylen];
|
| 1929 |
+
|
| 1930 |
+
]b4_locations_if(
|
| 1931 |
+
[[ /* Default location. */
|
| 1932 |
+
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
|
| 1933 |
+
yyerror_range[1] = yyloc;]])[
|
| 1934 |
+
YY_REDUCE_PRINT (yyn);]b4_lac_if([[
|
| 1935 |
+
{
|
| 1936 |
+
int yychar_backup = yychar;
|
| 1937 |
+
switch (yyn)
|
| 1938 |
+
{
|
| 1939 |
+
]b4_user_actions[
|
| 1940 |
+
default: break;
|
| 1941 |
+
}
|
| 1942 |
+
if (yychar_backup != yychar)
|
| 1943 |
+
YY_LAC_DISCARD ("yychar change");
|
| 1944 |
+
}]], [[
|
| 1945 |
+
switch (yyn)
|
| 1946 |
+
{
|
| 1947 |
+
]b4_user_actions[
|
| 1948 |
+
default: break;
|
| 1949 |
+
}]])[
|
| 1950 |
+
/* User semantic actions sometimes alter yychar, and that requires
|
| 1951 |
+
that yytoken be updated with the new translation. We take the
|
| 1952 |
+
approach of translating immediately before every use of yytoken.
|
| 1953 |
+
One alternative is translating here after every semantic action,
|
| 1954 |
+
but that translation would be missed if the semantic action invokes
|
| 1955 |
+
YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
|
| 1956 |
+
if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
|
| 1957 |
+
incorrect destructor might then be invoked immediately. In the
|
| 1958 |
+
case of YYERROR or YYBACKUP, subsequent parser actions might lead
|
| 1959 |
+
to an incorrect destructor call or verbose syntax error message
|
| 1960 |
+
before the lookahead is translated. */
|
| 1961 |
+
YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
|
| 1962 |
+
|
| 1963 |
+
YYPOPSTACK (yylen);
|
| 1964 |
+
yylen = 0;
|
| 1965 |
+
|
| 1966 |
+
*++yyvsp = yyval;]b4_locations_if([
|
| 1967 |
+
*++yylsp = yyloc;])[
|
| 1968 |
+
|
| 1969 |
+
/* Now 'shift' the result of the reduction. Determine what state
|
| 1970 |
+
that goes to, based on the state we popped back to and the rule
|
| 1971 |
+
number reduced by. */
|
| 1972 |
+
{
|
| 1973 |
+
const int yylhs = yyr1[yyn] - YYNTOKENS;
|
| 1974 |
+
const int yyi = yypgoto[yylhs] + *yyssp;
|
| 1975 |
+
yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
|
| 1976 |
+
? yytable[yyi]
|
| 1977 |
+
: yydefgoto[yylhs]);
|
| 1978 |
+
}
|
| 1979 |
+
|
| 1980 |
+
goto yynewstate;
|
| 1981 |
+
|
| 1982 |
+
|
| 1983 |
+
/*--------------------------------------.
|
| 1984 |
+
| yyerrlab -- here on detecting error. |
|
| 1985 |
+
`--------------------------------------*/
|
| 1986 |
+
yyerrlab:
|
| 1987 |
+
/* Make sure we have latest lookahead translation. See comments at
|
| 1988 |
+
user semantic actions for why this is necessary. */
|
| 1989 |
+
yytoken = yychar == ]b4_symbol(empty, id)[ ? ]b4_symbol(empty, kind)[ : YYTRANSLATE (yychar);
|
| 1990 |
+
/* If not already recovering from an error, report this error. */
|
| 1991 |
+
if (!yyerrstatus)
|
| 1992 |
+
{
|
| 1993 |
+
++yynerrs;
|
| 1994 |
+
]b4_parse_error_case(
|
| 1995 |
+
[custom],
|
| 1996 |
+
[[ {
|
| 1997 |
+
yypcontext_t yyctx
|
| 1998 |
+
= {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[};]b4_lac_if([[
|
| 1999 |
+
if (yychar != ]b4_symbol(empty, id)[)
|
| 2000 |
+
YY_LAC_ESTABLISH;]])[
|
| 2001 |
+
if (yyreport_syntax_error (&yyctx]m4_ifset([b4_parse_param],
|
| 2002 |
+
[[, ]b4_args(b4_parse_param)])[) == 2)
|
| 2003 |
+
YYNOMEM;
|
| 2004 |
+
}]],
|
| 2005 |
+
[simple],
|
| 2006 |
+
[[ yyerror (]b4_yyerror_args[YY_("syntax error"));]],
|
| 2007 |
+
[[ {
|
| 2008 |
+
yypcontext_t yyctx
|
| 2009 |
+
= {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[};
|
| 2010 |
+
char const *yymsgp = YY_("syntax error");
|
| 2011 |
+
int yysyntax_error_status;]b4_lac_if([[
|
| 2012 |
+
if (yychar != ]b4_symbol(empty, id)[)
|
| 2013 |
+
YY_LAC_ESTABLISH;]])[
|
| 2014 |
+
yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
|
| 2015 |
+
if (yysyntax_error_status == 0)
|
| 2016 |
+
yymsgp = yymsg;
|
| 2017 |
+
else if (yysyntax_error_status == -1)
|
| 2018 |
+
{
|
| 2019 |
+
if (yymsg != yymsgbuf)
|
| 2020 |
+
YYSTACK_FREE (yymsg);
|
| 2021 |
+
yymsg = YY_CAST (char *,
|
| 2022 |
+
YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
|
| 2023 |
+
if (yymsg)
|
| 2024 |
+
{
|
| 2025 |
+
yysyntax_error_status
|
| 2026 |
+
= yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
|
| 2027 |
+
yymsgp = yymsg;
|
| 2028 |
+
}
|
| 2029 |
+
else
|
| 2030 |
+
{
|
| 2031 |
+
yymsg = yymsgbuf;
|
| 2032 |
+
yymsg_alloc = sizeof yymsgbuf;
|
| 2033 |
+
yysyntax_error_status = YYENOMEM;
|
| 2034 |
+
}
|
| 2035 |
+
}
|
| 2036 |
+
yyerror (]b4_yyerror_args[yymsgp);
|
| 2037 |
+
if (yysyntax_error_status == YYENOMEM)
|
| 2038 |
+
YYNOMEM;
|
| 2039 |
+
}]])[
|
| 2040 |
+
}
|
| 2041 |
+
]b4_locations_if([[
|
| 2042 |
+
yyerror_range[1] = yylloc;]])[
|
| 2043 |
+
if (yyerrstatus == 3)
|
| 2044 |
+
{
|
| 2045 |
+
/* If just tried and failed to reuse lookahead token after an
|
| 2046 |
+
error, discard it. */
|
| 2047 |
+
|
| 2048 |
+
if (yychar <= ]b4_symbol(eof, [id])[)
|
| 2049 |
+
{
|
| 2050 |
+
/* Return failure if at end of input. */
|
| 2051 |
+
if (yychar == ]b4_symbol(eof, [id])[)
|
| 2052 |
+
YYABORT;
|
| 2053 |
+
}
|
| 2054 |
+
else
|
| 2055 |
+
{
|
| 2056 |
+
yydestruct ("Error: discarding",
|
| 2057 |
+
yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
|
| 2058 |
+
yychar = ]b4_symbol(empty, id)[;
|
| 2059 |
+
}
|
| 2060 |
+
}
|
| 2061 |
+
|
| 2062 |
+
/* Else will try to reuse lookahead token after shifting the error
|
| 2063 |
+
token. */
|
| 2064 |
+
goto yyerrlab1;
|
| 2065 |
+
|
| 2066 |
+
|
| 2067 |
+
/*---------------------------------------------------.
|
| 2068 |
+
| yyerrorlab -- error raised explicitly by YYERROR. |
|
| 2069 |
+
`---------------------------------------------------*/
|
| 2070 |
+
yyerrorlab:
|
| 2071 |
+
/* Pacify compilers when the user code never invokes YYERROR and the
|
| 2072 |
+
label yyerrorlab therefore never appears in user code. */
|
| 2073 |
+
if (0)
|
| 2074 |
+
YYERROR;
|
| 2075 |
+
++yynerrs;
|
| 2076 |
+
|
| 2077 |
+
/* Do not reclaim the symbols of the rule whose action triggered
|
| 2078 |
+
this YYERROR. */
|
| 2079 |
+
YYPOPSTACK (yylen);
|
| 2080 |
+
yylen = 0;
|
| 2081 |
+
YY_STACK_PRINT (yyss, yyssp);
|
| 2082 |
+
yystate = *yyssp;
|
| 2083 |
+
goto yyerrlab1;
|
| 2084 |
+
|
| 2085 |
+
|
| 2086 |
+
/*-------------------------------------------------------------.
|
| 2087 |
+
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
| 2088 |
+
`-------------------------------------------------------------*/
|
| 2089 |
+
yyerrlab1:
|
| 2090 |
+
yyerrstatus = 3; /* Each real token shifted decrements this. */
|
| 2091 |
+
|
| 2092 |
+
/* Pop stack until we find a state that shifts the error token. */
|
| 2093 |
+
for (;;)
|
| 2094 |
+
{
|
| 2095 |
+
yyn = yypact[yystate];
|
| 2096 |
+
if (!yypact_value_is_default (yyn))
|
| 2097 |
+
{
|
| 2098 |
+
yyn += ]b4_symbol(error, kind)[;
|
| 2099 |
+
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == ]b4_symbol(error, kind)[)
|
| 2100 |
+
{
|
| 2101 |
+
yyn = yytable[yyn];
|
| 2102 |
+
if (0 < yyn)
|
| 2103 |
+
break;
|
| 2104 |
+
}
|
| 2105 |
+
}
|
| 2106 |
+
|
| 2107 |
+
/* Pop the current state because it cannot handle the error token. */
|
| 2108 |
+
if (yyssp == yyss)
|
| 2109 |
+
YYABORT;
|
| 2110 |
+
|
| 2111 |
+
]b4_locations_if([[ yyerror_range[1] = *yylsp;]])[
|
| 2112 |
+
yydestruct ("Error: popping",
|
| 2113 |
+
YY_ACCESSING_SYMBOL (yystate), yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
|
| 2114 |
+
YYPOPSTACK (1);
|
| 2115 |
+
yystate = *yyssp;
|
| 2116 |
+
YY_STACK_PRINT (yyss, yyssp);
|
| 2117 |
+
}]b4_lac_if([[
|
| 2118 |
+
|
| 2119 |
+
/* If the stack popping above didn't lose the initial context for the
|
| 2120 |
+
current lookahead token, the shift below will for sure. */
|
| 2121 |
+
YY_LAC_DISCARD ("error recovery");]])[
|
| 2122 |
+
|
| 2123 |
+
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
|
| 2124 |
+
*++yyvsp = yylval;
|
| 2125 |
+
YY_IGNORE_MAYBE_UNINITIALIZED_END
|
| 2126 |
+
]b4_locations_if([[
|
| 2127 |
+
yyerror_range[2] = yylloc;
|
| 2128 |
+
++yylsp;
|
| 2129 |
+
YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);]])[
|
| 2130 |
+
|
| 2131 |
+
/* Shift the error token. */
|
| 2132 |
+
YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
|
| 2133 |
+
|
| 2134 |
+
yystate = yyn;
|
| 2135 |
+
goto yynewstate;
|
| 2136 |
+
|
| 2137 |
+
|
| 2138 |
+
/*-------------------------------------.
|
| 2139 |
+
| yyacceptlab -- YYACCEPT comes here. |
|
| 2140 |
+
`-------------------------------------*/
|
| 2141 |
+
yyacceptlab:
|
| 2142 |
+
yyresult = 0;
|
| 2143 |
+
goto yyreturnlab;
|
| 2144 |
+
|
| 2145 |
+
|
| 2146 |
+
/*-----------------------------------.
|
| 2147 |
+
| yyabortlab -- YYABORT comes here. |
|
| 2148 |
+
`-----------------------------------*/
|
| 2149 |
+
yyabortlab:
|
| 2150 |
+
yyresult = 1;
|
| 2151 |
+
goto yyreturnlab;
|
| 2152 |
+
|
| 2153 |
+
|
| 2154 |
+
/*-----------------------------------------------------------.
|
| 2155 |
+
| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
|
| 2156 |
+
`-----------------------------------------------------------*/
|
| 2157 |
+
yyexhaustedlab:
|
| 2158 |
+
yyerror (]b4_yyerror_args[YY_("memory exhausted"));
|
| 2159 |
+
yyresult = 2;
|
| 2160 |
+
goto yyreturnlab;
|
| 2161 |
+
|
| 2162 |
+
|
| 2163 |
+
/*----------------------------------------------------------.
|
| 2164 |
+
| yyreturnlab -- parsing is finished, clean up and return. |
|
| 2165 |
+
`----------------------------------------------------------*/
|
| 2166 |
+
yyreturnlab:
|
| 2167 |
+
if (yychar != ]b4_symbol(empty, id)[)
|
| 2168 |
+
{
|
| 2169 |
+
/* Make sure we have latest lookahead translation. See comments at
|
| 2170 |
+
user semantic actions for why this is necessary. */
|
| 2171 |
+
yytoken = YYTRANSLATE (yychar);
|
| 2172 |
+
yydestruct ("Cleanup: discarding lookahead",
|
| 2173 |
+
yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
|
| 2174 |
+
}
|
| 2175 |
+
/* Do not reclaim the symbols of the rule whose action triggered
|
| 2176 |
+
this YYABORT or YYACCEPT. */
|
| 2177 |
+
YYPOPSTACK (yylen);
|
| 2178 |
+
YY_STACK_PRINT (yyss, yyssp);
|
| 2179 |
+
while (yyssp != yyss)
|
| 2180 |
+
{
|
| 2181 |
+
yydestruct ("Cleanup: popping",
|
| 2182 |
+
YY_ACCESSING_SYMBOL (+*yyssp), yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
|
| 2183 |
+
YYPOPSTACK (1);
|
| 2184 |
+
}]b4_push_if([[
|
| 2185 |
+
yyps->yynew = 2;
|
| 2186 |
+
goto yypushreturn;
|
| 2187 |
+
|
| 2188 |
+
|
| 2189 |
+
/*-------------------------.
|
| 2190 |
+
| yypushreturn -- return. |
|
| 2191 |
+
`-------------------------*/
|
| 2192 |
+
yypushreturn:]], [[
|
| 2193 |
+
#ifndef yyoverflow
|
| 2194 |
+
if (yyss != yyssa)
|
| 2195 |
+
YYSTACK_FREE (yyss);
|
| 2196 |
+
#endif]b4_lac_if([[
|
| 2197 |
+
if (yyes != yyesa)
|
| 2198 |
+
YYSTACK_FREE (yyes);]])])[
|
| 2199 |
+
]b4_parse_error_bmatch([detailed\|verbose],
|
| 2200 |
+
[[ if (yymsg != yymsgbuf)
|
| 2201 |
+
YYSTACK_FREE (yymsg);]])[]m4_ifdef([b4_start_symbols], [[
|
| 2202 |
+
if (yyimpl)
|
| 2203 |
+
yyimpl->yynerrs = yynerrs;]])[
|
| 2204 |
+
return yyresult;
|
| 2205 |
+
}
|
| 2206 |
+
]b4_push_if([b4_parse_state_variable_macros([b4_macro_undef])])[
|
| 2207 |
+
]b4_percent_code_get([[epilogue]])[]dnl
|
| 2208 |
+
b4_epilogue[]dnl
|
| 2209 |
+
b4_output_end
|
platform/dbops/binaries/build/share/bison/xslt/bison.xsl
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
|
| 3 |
+
<!--
|
| 4 |
+
bison.xsl - common templates for Bison XSLT.
|
| 5 |
+
|
| 6 |
+
Copyright (C) 2007-2015, 2018-2021 Free Software Foundation, Inc.
|
| 7 |
+
|
| 8 |
+
This file is part of Bison, the GNU Compiler Compiler.
|
| 9 |
+
|
| 10 |
+
This program is free software: you can redistribute it and/or modify
|
| 11 |
+
it under the terms of the GNU General Public License as published by
|
| 12 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 13 |
+
(at your option) any later version.
|
| 14 |
+
|
| 15 |
+
This program is distributed in the hope that it will be useful,
|
| 16 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 17 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 18 |
+
GNU General Public License for more details.
|
| 19 |
+
|
| 20 |
+
You should have received a copy of the GNU General Public License
|
| 21 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 22 |
+
-->
|
| 23 |
+
|
| 24 |
+
<xsl:stylesheet version="1.0"
|
| 25 |
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
| 26 |
+
xmlns:bison="https://www.gnu.org/software/bison/">
|
| 27 |
+
|
| 28 |
+
<xsl:key
|
| 29 |
+
name="bison:symbolByName"
|
| 30 |
+
match="/bison-xml-report/grammar/nonterminals/nonterminal"
|
| 31 |
+
use="@name"
|
| 32 |
+
/>
|
| 33 |
+
<xsl:key
|
| 34 |
+
name="bison:symbolByName"
|
| 35 |
+
match="/bison-xml-report/grammar/terminals/terminal"
|
| 36 |
+
use="@name"
|
| 37 |
+
/>
|
| 38 |
+
<xsl:key
|
| 39 |
+
name="bison:ruleByNumber"
|
| 40 |
+
match="/bison-xml-report/grammar/rules/rule"
|
| 41 |
+
use="@number"
|
| 42 |
+
/>
|
| 43 |
+
<xsl:key
|
| 44 |
+
name="bison:ruleByLhs"
|
| 45 |
+
match="/bison-xml-report/grammar/rules/rule[
|
| 46 |
+
@usefulness != 'useless-in-grammar']"
|
| 47 |
+
use="lhs"
|
| 48 |
+
/>
|
| 49 |
+
<xsl:key
|
| 50 |
+
name="bison:ruleByRhs"
|
| 51 |
+
match="/bison-xml-report/grammar/rules/rule[
|
| 52 |
+
@usefulness != 'useless-in-grammar']"
|
| 53 |
+
use="rhs/symbol"
|
| 54 |
+
/>
|
| 55 |
+
|
| 56 |
+
<!-- For the specified state, output: #sr-conflicts,#rr-conflicts -->
|
| 57 |
+
<xsl:template match="state" mode="bison:count-conflicts">
|
| 58 |
+
<xsl:variable name="transitions" select="actions/transitions"/>
|
| 59 |
+
<xsl:variable name="reductions" select="actions/reductions"/>
|
| 60 |
+
<xsl:variable
|
| 61 |
+
name="terminals"
|
| 62 |
+
select="
|
| 63 |
+
$transitions/transition[@type='shift']/@symbol
|
| 64 |
+
| $reductions/reduction/@symbol
|
| 65 |
+
"
|
| 66 |
+
/>
|
| 67 |
+
<xsl:variable name="conflict-data">
|
| 68 |
+
<xsl:for-each select="$terminals">
|
| 69 |
+
<xsl:variable name="name" select="."/>
|
| 70 |
+
<xsl:if test="generate-id($terminals[. = $name][1]) = generate-id(.)">
|
| 71 |
+
<xsl:variable
|
| 72 |
+
name="shift-count"
|
| 73 |
+
select="count($transitions/transition[@symbol=$name])"
|
| 74 |
+
/>
|
| 75 |
+
<xsl:variable
|
| 76 |
+
name="reduce-count"
|
| 77 |
+
select="count($reductions/reduction[@symbol=$name])"
|
| 78 |
+
/>
|
| 79 |
+
<xsl:if test="$shift-count > 0 and $reduce-count > 0">
|
| 80 |
+
<xsl:text>s</xsl:text>
|
| 81 |
+
</xsl:if>
|
| 82 |
+
<xsl:if test="$reduce-count > 1">
|
| 83 |
+
<xsl:text>r</xsl:text>
|
| 84 |
+
</xsl:if>
|
| 85 |
+
</xsl:if>
|
| 86 |
+
</xsl:for-each>
|
| 87 |
+
</xsl:variable>
|
| 88 |
+
<xsl:value-of select="string-length(translate($conflict-data, 'r', ''))"/>
|
| 89 |
+
<xsl:text>,</xsl:text>
|
| 90 |
+
<xsl:value-of select="string-length(translate($conflict-data, 's', ''))"/>
|
| 91 |
+
</xsl:template>
|
| 92 |
+
|
| 93 |
+
<xsl:template name="space">
|
| 94 |
+
<xsl:param name="repeat">0</xsl:param>
|
| 95 |
+
<xsl:param name="fill" select="' '"/>
|
| 96 |
+
<xsl:if test="number($repeat) >= 1">
|
| 97 |
+
<xsl:call-template name="space">
|
| 98 |
+
<xsl:with-param name="repeat" select="$repeat - 1"/>
|
| 99 |
+
<xsl:with-param name="fill" select="$fill"/>
|
| 100 |
+
</xsl:call-template>
|
| 101 |
+
<xsl:value-of select="$fill"/>
|
| 102 |
+
</xsl:if>
|
| 103 |
+
</xsl:template>
|
| 104 |
+
|
| 105 |
+
</xsl:stylesheet>
|
plat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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
|
| 3 |
+
<!--
|
| 4 |
+
xml2dot.xsl - transform Bison XML Report into DOT.
|
| 5 |
+
|
| 6 |
+
Copyright (C) 2007-2015, 2018-2021 Free Software Foundation, Inc.
|
| 7 |
+
|
| 8 |
+
This file is part of Bison, the GNU Compiler Compiler.
|
| 9 |
+
|
| 10 |
+
This program is free software: you can redistribute it and/or modify
|
| 11 |
+
it under the terms of the GNU General Public License as published by
|
| 12 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 13 |
+
(at your option) any later version.
|
| 14 |
+
|
| 15 |
+
This program is distributed in the hope that it will be useful,
|
| 16 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 17 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 18 |
+
GNU General Public License for more details.
|
| 19 |
+
|
| 20 |
+
You should have received a copy of the GNU General Public License
|
| 21 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 22 |
+
|
| 23 |
+
Written by Wojciech Polak <polak@gnu.org>.
|
| 24 |
+
-->
|
| 25 |
+
|
| 26 |
+
<xsl:stylesheet version="1.0"
|
| 27 |
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
| 28 |
+
xmlns:bison="https://www.gnu.org/software/bison/">
|
| 29 |
+
|
| 30 |
+
<xsl:import href="bison.xsl"/>
|
| 31 |
+
<xsl:output method="text" encoding="UTF-8" indent="no"/>
|
| 32 |
+
|
| 33 |
+
<xsl:template match="/">
|
| 34 |
+
<xsl:apply-templates select="bison-xml-report"/>
|
| 35 |
+
</xsl:template>
|
| 36 |
+
|
| 37 |
+
<xsl:template match="bison-xml-report">
|
| 38 |
+
<xsl:text>// Generated by GNU Bison </xsl:text>
|
| 39 |
+
<xsl:value-of select="@version"/>
|
| 40 |
+
<xsl:text>. </xsl:text>
|
| 41 |
+
<xsl:text>// Report bugs to <</xsl:text>
|
| 42 |
+
<xsl:value-of select="@bug-report"/>
|
| 43 |
+
<xsl:text>>. </xsl:text>
|
| 44 |
+
<xsl:text>// Home page: <</xsl:text>
|
| 45 |
+
<xsl:value-of select="@url"/>
|
| 46 |
+
<xsl:text>>. </xsl:text>
|
| 47 |
+
<xsl:apply-templates select="automaton">
|
| 48 |
+
<xsl:with-param name="filename" select="filename"/>
|
| 49 |
+
</xsl:apply-templates>
|
| 50 |
+
</xsl:template>
|
| 51 |
+
|
| 52 |
+
<xsl:template match="automaton">
|
| 53 |
+
<xsl:param name="filename"/>
|
| 54 |
+
<xsl:text>digraph "</xsl:text>
|
| 55 |
+
<xsl:call-template name="escape">
|
| 56 |
+
<xsl:with-param name="subject" select="$filename"/>
|
| 57 |
+
</xsl:call-template>
|
| 58 |
+
<xsl:text>" {
|
| 59 |
+
node [fontname = courier, shape = box, colorscheme = paired6]
|
| 60 |
+
edge [fontname = courier]
|
| 61 |
+
|
| 62 |
+
</xsl:text>
|
| 63 |
+
<xsl:apply-templates select="state"/>
|
| 64 |
+
<xsl:text>} </xsl:text>
|
| 65 |
+
</xsl:template>
|
| 66 |
+
|
| 67 |
+
<xsl:template match="automaton/state">
|
| 68 |
+
<xsl:call-template name="output-node">
|
| 69 |
+
<xsl:with-param name="number" select="@number"/>
|
| 70 |
+
<xsl:with-param name="label">
|
| 71 |
+
<xsl:apply-templates select="itemset/item"/>
|
| 72 |
+
</xsl:with-param>
|
| 73 |
+
</xsl:call-template>
|
| 74 |
+
<xsl:apply-templates select="actions/transitions"/>
|
| 75 |
+
<xsl:apply-templates select="actions/reductions">
|
| 76 |
+
<xsl:with-param name="staten">
|
| 77 |
+
<xsl:value-of select="@number"/>
|
| 78 |
+
</xsl:with-param>
|
| 79 |
+
</xsl:apply-templates>
|
| 80 |
+
</xsl:template>
|
| 81 |
+
|
| 82 |
+
<xsl:template match="actions/reductions">
|
| 83 |
+
<xsl:param name="staten"/>
|
| 84 |
+
<xsl:for-each select='reduction'>
|
| 85 |
+
<!-- These variables are needed because the current context can't be
|
| 86 |
+
referred to directly in XPath expressions. -->
|
| 87 |
+
<xsl:variable name="rul">
|
| 88 |
+
<xsl:value-of select="@rule"/>
|
| 89 |
+
</xsl:variable>
|
| 90 |
+
<xsl:variable name="ena">
|
| 91 |
+
<xsl:value-of select="@enabled"/>
|
| 92 |
+
</xsl:variable>
|
| 93 |
+
<!-- The foreach's body is protected by this, so that we are actually
|
| 94 |
+
going to iterate once per reduction rule, and not per lookahead. -->
|
| 95 |
+
<xsl:if test='not(preceding-sibling::*[@rule=$rul and @enabled=$ena])'>
|
| 96 |
+
<xsl:variable name="rule">
|
| 97 |
+
<xsl:choose>
|
| 98 |
+
<!-- The acceptation state is referred to as 'accept' in the XML, but
|
| 99 |
+
just as '0' in the DOT. -->
|
| 100 |
+
<xsl:when test="@rule='accept'">
|
| 101 |
+
<xsl:text>0</xsl:text>
|
| 102 |
+
</xsl:when>
|
| 103 |
+
<xsl:otherwise>
|
| 104 |
+
<xsl:value-of select="@rule"/>
|
| 105 |
+
</xsl:otherwise>
|
| 106 |
+
</xsl:choose>
|
| 107 |
+
</xsl:variable>
|
| 108 |
+
|
| 109 |
+
<!-- The edge's beginning -->
|
| 110 |
+
<xsl:call-template name="reduction-edge-start">
|
| 111 |
+
<xsl:with-param name="state" select="$staten"/>
|
| 112 |
+
<xsl:with-param name="rule" select="$rule"/>
|
| 113 |
+
<xsl:with-param name="enabled" select="@enabled"/>
|
| 114 |
+
</xsl:call-template>
|
| 115 |
+
|
| 116 |
+
<!-- The edge's tokens -->
|
| 117 |
+
<!-- Don't show labels for the default action. In other cases, there will
|
| 118 |
+
always be at least one token, so 'label="[]"' will not occur. -->
|
| 119 |
+
<xsl:if test='$rule!=0 and not(../reduction[@enabled=$ena and @rule=$rule and @symbol="$default"])'>
|
| 120 |
+
<xsl:text>label="[</xsl:text>
|
| 121 |
+
<xsl:for-each select='../reduction[@enabled=$ena and @rule=$rule]'>
|
| 122 |
+
<xsl:call-template name="escape">
|
| 123 |
+
<xsl:with-param name="subject" select="@symbol"/>
|
| 124 |
+
</xsl:call-template>
|
| 125 |
+
<xsl:if test="position() != last ()">
|
| 126 |
+
<xsl:text>, </xsl:text>
|
| 127 |
+
</xsl:if>
|
| 128 |
+
</xsl:for-each>
|
| 129 |
+
<xsl:text>]", </xsl:text>
|
| 130 |
+
</xsl:if>
|
| 131 |
+
|
| 132 |
+
<!-- The edge's end -->
|
| 133 |
+
<xsl:text>style=solid] </xsl:text>
|
| 134 |
+
|
| 135 |
+
<!-- The diamond representing the reduction -->
|
| 136 |
+
<xsl:call-template name="reduction-node">
|
| 137 |
+
<xsl:with-param name="state" select="$staten"/>
|
| 138 |
+
<xsl:with-param name="rule" select="$rule"/>
|
| 139 |
+
<xsl:with-param name="color">
|
| 140 |
+
<xsl:choose>
|
| 141 |
+
<xsl:when test='@enabled="true"'>
|
| 142 |
+
<xsl:text>3</xsl:text>
|
| 143 |
+
</xsl:when>
|
| 144 |
+
<xsl:otherwise>
|
| 145 |
+
<xsl:text>5</xsl:text>
|
| 146 |
+
</xsl:otherwise>
|
| 147 |
+
</xsl:choose>
|
| 148 |
+
</xsl:with-param>
|
| 149 |
+
</xsl:call-template>
|
| 150 |
+
</xsl:if>
|
| 151 |
+
</xsl:for-each>
|
| 152 |
+
</xsl:template>
|
| 153 |
+
|
| 154 |
+
<xsl:template match="actions/transitions">
|
| 155 |
+
<xsl:apply-templates select="transition"/>
|
| 156 |
+
</xsl:template>
|
| 157 |
+
|
| 158 |
+
<xsl:template match="item">
|
| 159 |
+
<xsl:param name="prev-rule-number"
|
| 160 |
+
select="preceding-sibling::item[1]/@rule-number"/>
|
| 161 |
+
<xsl:apply-templates select="key('bison:ruleByNumber', @rule-number)">
|
| 162 |
+
<xsl:with-param name="dot" select="@dot"/>
|
| 163 |
+
<xsl:with-param name="num" select="@rule-number"/>
|
| 164 |
+
<xsl:with-param name="prev-lhs"
|
| 165 |
+
select="key('bison:ruleByNumber', $prev-rule-number)/lhs[text()]"
|
| 166 |
+
/>
|
| 167 |
+
</xsl:apply-templates>
|
| 168 |
+
<xsl:apply-templates select="lookaheads"/>
|
| 169 |
+
</xsl:template>
|
| 170 |
+
|
| 171 |
+
<xsl:template match="rule">
|
| 172 |
+
<xsl:param name="dot"/>
|
| 173 |
+
<xsl:param name="num"/>
|
| 174 |
+
<xsl:param name="prev-lhs"/>
|
| 175 |
+
<xsl:text> </xsl:text>
|
| 176 |
+
<xsl:choose>
|
| 177 |
+
<xsl:when test="$num < 10">
|
| 178 |
+
<xsl:text> </xsl:text>
|
| 179 |
+
</xsl:when>
|
| 180 |
+
<xsl:when test="$num < 100">
|
| 181 |
+
<xsl:text> </xsl:text>
|
| 182 |
+
</xsl:when>
|
| 183 |
+
<xsl:otherwise>
|
| 184 |
+
<xsl:text></xsl:text>
|
| 185 |
+
</xsl:otherwise>
|
| 186 |
+
</xsl:choose>
|
| 187 |
+
<xsl:value-of select="$num"/>
|
| 188 |
+
<xsl:text> </xsl:text>
|
| 189 |
+
<xsl:choose>
|
| 190 |
+
<xsl:when test="$prev-lhs = lhs[text()]">
|
| 191 |
+
<xsl:call-template name="lpad">
|
| 192 |
+
<xsl:with-param name="str" select="'|'"/>
|
| 193 |
+
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
|
| 194 |
+
</xsl:call-template>
|
| 195 |
+
</xsl:when>
|
| 196 |
+
<xsl:otherwise>
|
| 197 |
+
<xsl:value-of select="lhs"/>
|
| 198 |
+
<xsl:text>:</xsl:text>
|
| 199 |
+
</xsl:otherwise>
|
| 200 |
+
</xsl:choose>
|
| 201 |
+
<xsl:if test="$dot = 0">
|
| 202 |
+
<xsl:text> .</xsl:text>
|
| 203 |
+
</xsl:if>
|
| 204 |
+
|
| 205 |
+
<!-- RHS -->
|
| 206 |
+
<xsl:for-each select="rhs/symbol|rhs/empty">
|
| 207 |
+
<xsl:apply-templates select="."/>
|
| 208 |
+
<xsl:if test="$dot = position()">
|
| 209 |
+
<xsl:text> .</xsl:text>
|
| 210 |
+
</xsl:if>
|
| 211 |
+
</xsl:for-each>
|
| 212 |
+
</xsl:template>
|
| 213 |
+
|
| 214 |
+
<xsl:template match="symbol">
|
| 215 |
+
<xsl:text> </xsl:text>
|
| 216 |
+
<xsl:value-of select="."/>
|
| 217 |
+
</xsl:template>
|
| 218 |
+
|
| 219 |
+
<xsl:template match="empty">
|
| 220 |
+
<xsl:text> %empty</xsl:text>
|
| 221 |
+
</xsl:template>
|
| 222 |
+
|
| 223 |
+
<xsl:template match="lookaheads">
|
| 224 |
+
<xsl:text> [</xsl:text>
|
| 225 |
+
<xsl:apply-templates select="symbol"/>
|
| 226 |
+
<xsl:text>]</xsl:text>
|
| 227 |
+
</xsl:template>
|
| 228 |
+
|
| 229 |
+
<xsl:template match="lookaheads/symbol">
|
| 230 |
+
<xsl:value-of select="."/>
|
| 231 |
+
<xsl:if test="position() != last()">
|
| 232 |
+
<xsl:text>, </xsl:text>
|
| 233 |
+
</xsl:if>
|
| 234 |
+
</xsl:template>
|
| 235 |
+
|
| 236 |
+
<xsl:template name="reduction-edge-start">
|
| 237 |
+
<xsl:param name="state"/>
|
| 238 |
+
<xsl:param name="rule"/>
|
| 239 |
+
<xsl:param name="enabled"/>
|
| 240 |
+
|
| 241 |
+
<xsl:text> </xsl:text>
|
| 242 |
+
<xsl:value-of select="$state"/>
|
| 243 |
+
<xsl:text> -> "</xsl:text>
|
| 244 |
+
<xsl:value-of select="$state"/>
|
| 245 |
+
<xsl:text>R</xsl:text>
|
| 246 |
+
<xsl:value-of select="$rule"/>
|
| 247 |
+
<xsl:if test='$enabled = "false"'>
|
| 248 |
+
<xsl:text>d</xsl:text>
|
| 249 |
+
</xsl:if>
|
| 250 |
+
<xsl:text>" [</xsl:text>
|
| 251 |
+
</xsl:template>
|
| 252 |
+
|
| 253 |
+
<xsl:template name="reduction-node">
|
| 254 |
+
<xsl:param name="state"/>
|
| 255 |
+
<xsl:param name="rule"/>
|
| 256 |
+
<xsl:param name="color"/>
|
| 257 |
+
|
| 258 |
+
<xsl:text> "</xsl:text>
|
| 259 |
+
<xsl:value-of select="$state"/>
|
| 260 |
+
<xsl:text>R</xsl:text>
|
| 261 |
+
<xsl:value-of select="$rule"/>
|
| 262 |
+
<xsl:if test="$color = 5">
|
| 263 |
+
<xsl:text>d</xsl:text>
|
| 264 |
+
</xsl:if>
|
| 265 |
+
<xsl:text>" [label="</xsl:text>
|
| 266 |
+
<xsl:choose>
|
| 267 |
+
<xsl:when test="$rule = 0">
|
| 268 |
+
<xsl:text>Acc", fillcolor=1</xsl:text>
|
| 269 |
+
</xsl:when>
|
| 270 |
+
<xsl:otherwise>
|
| 271 |
+
<xsl:text>R</xsl:text>
|
| 272 |
+
<xsl:value-of select="$rule"/>
|
| 273 |
+
<xsl:text>", fillcolor=</xsl:text>
|
| 274 |
+
<xsl:value-of select="$color"/>
|
| 275 |
+
</xsl:otherwise>
|
| 276 |
+
</xsl:choose>
|
| 277 |
+
<xsl:text>, shape=diamond, style=filled] </xsl:text>
|
| 278 |
+
</xsl:template>
|
| 279 |
+
|
| 280 |
+
<xsl:template match="transition">
|
| 281 |
+
<xsl:call-template name="output-edge">
|
| 282 |
+
<xsl:with-param name="src" select="../../../@number"/>
|
| 283 |
+
<xsl:with-param name="dst" select="@state"/>
|
| 284 |
+
<xsl:with-param name="style">
|
| 285 |
+
<xsl:choose>
|
| 286 |
+
<xsl:when test="@symbol = 'error'">
|
| 287 |
+
<xsl:text>dotted</xsl:text>
|
| 288 |
+
</xsl:when>
|
| 289 |
+
<xsl:when test="@type = 'shift'">
|
| 290 |
+
<xsl:text>solid</xsl:text>
|
| 291 |
+
</xsl:when>
|
| 292 |
+
<xsl:otherwise>
|
| 293 |
+
<xsl:text>dashed</xsl:text>
|
| 294 |
+
</xsl:otherwise>
|
| 295 |
+
</xsl:choose>
|
| 296 |
+
</xsl:with-param>
|
| 297 |
+
<xsl:with-param name="label">
|
| 298 |
+
<xsl:if test="not(@symbol = 'error')">
|
| 299 |
+
<xsl:value-of select="@symbol"/>
|
| 300 |
+
</xsl:if>
|
| 301 |
+
</xsl:with-param>
|
| 302 |
+
</xsl:call-template>
|
| 303 |
+
</xsl:template>
|
| 304 |
+
|
| 305 |
+
<xsl:template name="output-node">
|
| 306 |
+
<xsl:param name="number"/>
|
| 307 |
+
<xsl:param name="label"/>
|
| 308 |
+
<xsl:text> </xsl:text>
|
| 309 |
+
<xsl:value-of select="$number"/>
|
| 310 |
+
<xsl:text> [label="</xsl:text>
|
| 311 |
+
<xsl:text>State </xsl:text>
|
| 312 |
+
<xsl:value-of select="$number"/>
|
| 313 |
+
<xsl:text>\n</xsl:text>
|
| 314 |
+
<xsl:call-template name="escape">
|
| 315 |
+
<xsl:with-param name="subject" select="$label"/>
|
| 316 |
+
</xsl:call-template>
|
| 317 |
+
<xsl:text>\l"] </xsl:text>
|
| 318 |
+
</xsl:template>
|
| 319 |
+
|
| 320 |
+
<xsl:template name="output-edge">
|
| 321 |
+
<xsl:param name="src"/>
|
| 322 |
+
<xsl:param name="dst"/>
|
| 323 |
+
<xsl:param name="style"/>
|
| 324 |
+
<xsl:param name="label"/>
|
| 325 |
+
<xsl:text> </xsl:text>
|
| 326 |
+
<xsl:value-of select="$src"/>
|
| 327 |
+
<xsl:text> -> </xsl:text>
|
| 328 |
+
<xsl:value-of select="$dst"/>
|
| 329 |
+
<xsl:text> [style=</xsl:text>
|
| 330 |
+
<xsl:value-of select="$style"/>
|
| 331 |
+
<xsl:if test="$label and $label != ''">
|
| 332 |
+
<xsl:text> label="</xsl:text>
|
| 333 |
+
<xsl:call-template name="escape">
|
| 334 |
+
<xsl:with-param name="subject" select="$label"/>
|
| 335 |
+
</xsl:call-template>
|
| 336 |
+
<xsl:text>"</xsl:text>
|
| 337 |
+
</xsl:if>
|
| 338 |
+
<xsl:text>] </xsl:text>
|
| 339 |
+
</xsl:template>
|
| 340 |
+
|
| 341 |
+
<xsl:template name="escape">
|
| 342 |
+
<xsl:param name="subject"/> <!-- required -->
|
| 343 |
+
<xsl:call-template name="string-replace">
|
| 344 |
+
<xsl:with-param name="subject">
|
| 345 |
+
<xsl:call-template name="string-replace">
|
| 346 |
+
<xsl:with-param name="subject">
|
| 347 |
+
<xsl:call-template name="string-replace">
|
| 348 |
+
<xsl:with-param name="subject" select="$subject"/>
|
| 349 |
+
<xsl:with-param name="search" select="'\'"/>
|
| 350 |
+
<xsl:with-param name="replace" select="'\\'"/>
|
| 351 |
+
</xsl:call-template>
|
| 352 |
+
</xsl:with-param>
|
| 353 |
+
<xsl:with-param name="search" select="'"'"/>
|
| 354 |
+
<xsl:with-param name="replace" select="'\"'"/>
|
| 355 |
+
</xsl:call-template>
|
| 356 |
+
</xsl:with-param>
|
| 357 |
+
<xsl:with-param name="search" select="' '"/>
|
| 358 |
+
<xsl:with-param name="replace" select="'\l'"/>
|
| 359 |
+
</xsl:call-template>
|
| 360 |
+
</xsl:template>
|
| 361 |
+
|
| 362 |
+
<xsl:template name="string-replace">
|
| 363 |
+
<xsl:param name="subject"/>
|
| 364 |
+
<xsl:param name="search"/>
|
| 365 |
+
<xsl:param name="replace"/>
|
| 366 |
+
<xsl:choose>
|
| 367 |
+
<xsl:when test="contains($subject, $search)">
|
| 368 |
+
<xsl:variable name="before" select="substring-before($subject, $search)"/>
|
| 369 |
+
<xsl:variable name="after" select="substring-after($subject, $search)"/>
|
| 370 |
+
<xsl:value-of select="$before"/>
|
| 371 |
+
<xsl:value-of select="$replace"/>
|
| 372 |
+
<xsl:call-template name="string-replace">
|
| 373 |
+
<xsl:with-param name="subject" select="$after"/>
|
| 374 |
+
<xsl:with-param name="search" select="$search"/>
|
| 375 |
+
<xsl:with-param name="replace" select="$replace"/>
|
| 376 |
+
</xsl:call-template>
|
| 377 |
+
</xsl:when>
|
| 378 |
+
<xsl:otherwise>
|
| 379 |
+
<xsl:value-of select="$subject"/>
|
| 380 |
+
</xsl:otherwise>
|
| 381 |
+
</xsl:choose>
|
| 382 |
+
</xsl:template>
|
| 383 |
+
|
| 384 |
+
<xsl:template name="lpad">
|
| 385 |
+
<xsl:param name="str" select="''"/>
|
| 386 |
+
<xsl:param name="pad" select="0"/>
|
| 387 |
+
<xsl:variable name="diff" select="$pad - string-length($str)" />
|
| 388 |
+
<xsl:choose>
|
| 389 |
+
<xsl:when test="$diff < 0">
|
| 390 |
+
<xsl:value-of select="$str"/>
|
| 391 |
+
</xsl:when>
|
| 392 |
+
<xsl:otherwise>
|
| 393 |
+
<xsl:call-template name="space">
|
| 394 |
+
<xsl:with-param name="repeat" select="$diff"/>
|
| 395 |
+
</xsl:call-template>
|
| 396 |
+
<xsl:value-of select="$str"/>
|
| 397 |
+
</xsl:otherwise>
|
| 398 |
+
</xsl:choose>
|
| 399 |
+
</xsl:template>
|
| 400 |
+
|
| 401 |
+
</xsl:stylesheet>
|
platform/dbops/binaries/build/share/bison/xslt/xml2text.xsl
ADDED
|
@@ -0,0 +1,572 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
|
| 3 |
+
<!--
|
| 4 |
+
xml2text.xsl - transform Bison XML Report into plain text.
|
| 5 |
+
|
| 6 |
+
Copyright (C) 2007-2015, 2018-2021 Free Software Foundation, Inc.
|
| 7 |
+
|
| 8 |
+
This file is part of Bison, the GNU Compiler Compiler.
|
| 9 |
+
|
| 10 |
+
This program is free software: you can redistribute it and/or modify
|
| 11 |
+
it under the terms of the GNU General Public License as published by
|
| 12 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 13 |
+
(at your option) any later version.
|
| 14 |
+
|
| 15 |
+
This program is distributed in the hope that it will be useful,
|
| 16 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 17 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 18 |
+
GNU General Public License for more details.
|
| 19 |
+
|
| 20 |
+
You should have received a copy of the GNU General Public License
|
| 21 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 22 |
+
|
| 23 |
+
Written by Wojciech Polak <polak@gnu.org>.
|
| 24 |
+
-->
|
| 25 |
+
|
| 26 |
+
<xsl:stylesheet version="1.0"
|
| 27 |
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
| 28 |
+
xmlns:bison="https://www.gnu.org/software/bison/">
|
| 29 |
+
|
| 30 |
+
<xsl:import href="bison.xsl"/>
|
| 31 |
+
<xsl:output method="text" encoding="UTF-8" indent="no"/>
|
| 32 |
+
|
| 33 |
+
<xsl:template match="/">
|
| 34 |
+
<xsl:apply-templates select="bison-xml-report"/>
|
| 35 |
+
</xsl:template>
|
| 36 |
+
|
| 37 |
+
<xsl:template match="bison-xml-report">
|
| 38 |
+
<xsl:apply-templates select="grammar" mode="reductions"/>
|
| 39 |
+
<xsl:apply-templates select="grammar" mode="useless-in-parser"/>
|
| 40 |
+
<xsl:apply-templates select="automaton" mode="conflicts"/>
|
| 41 |
+
<xsl:apply-templates select="grammar"/>
|
| 42 |
+
<xsl:apply-templates select="automaton"/>
|
| 43 |
+
</xsl:template>
|
| 44 |
+
|
| 45 |
+
<xsl:template match="grammar" mode="reductions">
|
| 46 |
+
<xsl:apply-templates select="nonterminals" mode="useless-in-grammar"/>
|
| 47 |
+
<xsl:apply-templates select="terminals" mode="unused-in-grammar"/>
|
| 48 |
+
<xsl:apply-templates select="rules" mode="useless-in-grammar"/>
|
| 49 |
+
</xsl:template>
|
| 50 |
+
|
| 51 |
+
<xsl:template match="nonterminals" mode="useless-in-grammar">
|
| 52 |
+
<xsl:if test="nonterminal[@usefulness='useless-in-grammar']">
|
| 53 |
+
<xsl:text>Nonterminals useless in grammar </xsl:text>
|
| 54 |
+
<xsl:for-each select="nonterminal[@usefulness='useless-in-grammar']">
|
| 55 |
+
<xsl:text> </xsl:text>
|
| 56 |
+
<xsl:value-of select="@name"/>
|
| 57 |
+
<xsl:text> </xsl:text>
|
| 58 |
+
</xsl:for-each>
|
| 59 |
+
<xsl:text> </xsl:text>
|
| 60 |
+
</xsl:if>
|
| 61 |
+
</xsl:template>
|
| 62 |
+
|
| 63 |
+
<xsl:template match="terminals" mode="unused-in-grammar">
|
| 64 |
+
<xsl:if test="terminal[@usefulness='unused-in-grammar']">
|
| 65 |
+
<xsl:text>Terminals unused in grammar </xsl:text>
|
| 66 |
+
<xsl:for-each select="terminal[@usefulness='unused-in-grammar']">
|
| 67 |
+
<xsl:sort select="@symbol-number" data-type="number"/>
|
| 68 |
+
<xsl:text> </xsl:text>
|
| 69 |
+
<xsl:value-of select="@name"/>
|
| 70 |
+
<xsl:text> </xsl:text>
|
| 71 |
+
</xsl:for-each>
|
| 72 |
+
<xsl:text> </xsl:text>
|
| 73 |
+
</xsl:if>
|
| 74 |
+
</xsl:template>
|
| 75 |
+
|
| 76 |
+
<xsl:template match="rules" mode="useless-in-grammar">
|
| 77 |
+
<xsl:variable name="set" select="rule[@usefulness='useless-in-grammar']"/>
|
| 78 |
+
<xsl:if test="$set">
|
| 79 |
+
<xsl:text>Rules useless in grammar </xsl:text>
|
| 80 |
+
<xsl:call-template name="style-rule-set">
|
| 81 |
+
<xsl:with-param name="rule-set" select="$set"/>
|
| 82 |
+
</xsl:call-template>
|
| 83 |
+
<xsl:text> </xsl:text>
|
| 84 |
+
</xsl:if>
|
| 85 |
+
</xsl:template>
|
| 86 |
+
|
| 87 |
+
<xsl:template match="grammar" mode="useless-in-parser">
|
| 88 |
+
<xsl:variable
|
| 89 |
+
name="set" select="rules/rule[@usefulness='useless-in-parser']"
|
| 90 |
+
/>
|
| 91 |
+
<xsl:if test="$set">
|
| 92 |
+
<xsl:text>Rules useless in parser due to conflicts </xsl:text>
|
| 93 |
+
<xsl:call-template name="style-rule-set">
|
| 94 |
+
<xsl:with-param name="rule-set" select="$set"/>
|
| 95 |
+
</xsl:call-template>
|
| 96 |
+
<xsl:text> </xsl:text>
|
| 97 |
+
</xsl:if>
|
| 98 |
+
</xsl:template>
|
| 99 |
+
|
| 100 |
+
<xsl:template match="grammar">
|
| 101 |
+
<xsl:text>Grammar </xsl:text>
|
| 102 |
+
<xsl:call-template name="style-rule-set">
|
| 103 |
+
<xsl:with-param
|
| 104 |
+
name="rule-set" select="rules/rule[@usefulness!='useless-in-grammar']"
|
| 105 |
+
/>
|
| 106 |
+
</xsl:call-template>
|
| 107 |
+
<xsl:text> </xsl:text>
|
| 108 |
+
<xsl:apply-templates select="terminals"/>
|
| 109 |
+
<xsl:apply-templates select="nonterminals"/>
|
| 110 |
+
</xsl:template>
|
| 111 |
+
|
| 112 |
+
<xsl:template name="style-rule-set">
|
| 113 |
+
<xsl:param name="rule-set"/>
|
| 114 |
+
<xsl:for-each select="$rule-set">
|
| 115 |
+
<xsl:apply-templates select=".">
|
| 116 |
+
<xsl:with-param name="pad" select="'3'"/>
|
| 117 |
+
<xsl:with-param name="prev-lhs">
|
| 118 |
+
<xsl:if test="position()>1">
|
| 119 |
+
<xsl:variable name="position" select="position()"/>
|
| 120 |
+
<xsl:value-of select="$rule-set[$position - 1]/lhs"/>
|
| 121 |
+
</xsl:if>
|
| 122 |
+
</xsl:with-param>
|
| 123 |
+
</xsl:apply-templates>
|
| 124 |
+
</xsl:for-each>
|
| 125 |
+
</xsl:template>
|
| 126 |
+
|
| 127 |
+
<xsl:template match="grammar/terminals">
|
| 128 |
+
<xsl:text>Terminals, with rules where they appear </xsl:text>
|
| 129 |
+
<xsl:apply-templates select="terminal"/>
|
| 130 |
+
<xsl:text> </xsl:text>
|
| 131 |
+
</xsl:template>
|
| 132 |
+
|
| 133 |
+
<xsl:template match="grammar/nonterminals">
|
| 134 |
+
<xsl:text>Nonterminals, with rules where they appear </xsl:text>
|
| 135 |
+
<xsl:apply-templates select="nonterminal[@usefulness!='useless-in-grammar']"/>
|
| 136 |
+
</xsl:template>
|
| 137 |
+
|
| 138 |
+
<xsl:template match="terminal">
|
| 139 |
+
<xsl:text> </xsl:text>
|
| 140 |
+
<xsl:value-of select="@name"/>
|
| 141 |
+
<xsl:call-template name="line-wrap">
|
| 142 |
+
<xsl:with-param name="first-line-length">
|
| 143 |
+
<xsl:choose>
|
| 144 |
+
<xsl:when test="string-length(@name) > 66">0</xsl:when>
|
| 145 |
+
<xsl:otherwise>
|
| 146 |
+
<xsl:value-of select="66 - string-length(@name)" />
|
| 147 |
+
</xsl:otherwise>
|
| 148 |
+
</xsl:choose>
|
| 149 |
+
</xsl:with-param>
|
| 150 |
+
<xsl:with-param name="line-length" select="66" />
|
| 151 |
+
<xsl:with-param name="text">
|
| 152 |
+
<xsl:if test="string-length(@type) != 0">
|
| 153 |
+
<xsl:value-of select="concat(' <', @type, '>')"/>
|
| 154 |
+
</xsl:if>
|
| 155 |
+
<xsl:value-of select="concat(' (', @token-number, ')')"/>
|
| 156 |
+
<xsl:for-each select="key('bison:ruleByRhs', @name)">
|
| 157 |
+
<xsl:value-of select="concat(' ', @number)"/>
|
| 158 |
+
</xsl:for-each>
|
| 159 |
+
</xsl:with-param>
|
| 160 |
+
</xsl:call-template>
|
| 161 |
+
</xsl:template>
|
| 162 |
+
|
| 163 |
+
<xsl:template match="nonterminal">
|
| 164 |
+
<xsl:text> </xsl:text>
|
| 165 |
+
<xsl:value-of select="@name"/>
|
| 166 |
+
<xsl:if test="string-length(@type) != 0">
|
| 167 |
+
<xsl:value-of select="concat(' <', @type, '>')"/>
|
| 168 |
+
</xsl:if>
|
| 169 |
+
<xsl:value-of select="concat(' (', @symbol-number, ')')"/>
|
| 170 |
+
<xsl:text> </xsl:text>
|
| 171 |
+
<xsl:variable name="output">
|
| 172 |
+
<xsl:call-template name="line-wrap">
|
| 173 |
+
<xsl:with-param name="line-length" select="66" />
|
| 174 |
+
<xsl:with-param name="text">
|
| 175 |
+
<xsl:text> </xsl:text>
|
| 176 |
+
<xsl:if test="key('bison:ruleByLhs', @name)">
|
| 177 |
+
<xsl:text>on@left:</xsl:text>
|
| 178 |
+
<xsl:for-each select="key('bison:ruleByLhs', @name)">
|
| 179 |
+
<xsl:value-of select="concat(' ', @number)"/>
|
| 180 |
+
</xsl:for-each>
|
| 181 |
+
</xsl:if>
|
| 182 |
+
<xsl:if test="key('bison:ruleByRhs', @name)">
|
| 183 |
+
<xsl:if test="key('bison:ruleByLhs', @name)">
|
| 184 |
+
<xsl:text> </xsl:text>
|
| 185 |
+
</xsl:if>
|
| 186 |
+
<xsl:text>on@right:</xsl:text>
|
| 187 |
+
<xsl:for-each select="key('bison:ruleByRhs', @name)">
|
| 188 |
+
<xsl:value-of select="concat(' ', @number)"/>
|
| 189 |
+
</xsl:for-each>
|
| 190 |
+
</xsl:if>
|
| 191 |
+
</xsl:with-param>
|
| 192 |
+
</xsl:call-template>
|
| 193 |
+
</xsl:variable>
|
| 194 |
+
<xsl:value-of select="translate($output, '@', ' ')" />
|
| 195 |
+
</xsl:template>
|
| 196 |
+
|
| 197 |
+
<xsl:template match="automaton" mode="conflicts">
|
| 198 |
+
<xsl:variable name="conflict-report">
|
| 199 |
+
<xsl:apply-templates select="state" mode="conflicts"/>
|
| 200 |
+
</xsl:variable>
|
| 201 |
+
<xsl:if test="string-length($conflict-report) != 0">
|
| 202 |
+
<xsl:value-of select="$conflict-report"/>
|
| 203 |
+
<xsl:text> </xsl:text>
|
| 204 |
+
</xsl:if>
|
| 205 |
+
</xsl:template>
|
| 206 |
+
|
| 207 |
+
<xsl:template match="state" mode="conflicts">
|
| 208 |
+
<xsl:variable name="conflict-counts">
|
| 209 |
+
<xsl:apply-templates select="." mode="bison:count-conflicts" />
|
| 210 |
+
</xsl:variable>
|
| 211 |
+
<xsl:variable
|
| 212 |
+
name="sr-count" select="substring-before($conflict-counts, ',')"
|
| 213 |
+
/>
|
| 214 |
+
<xsl:variable
|
| 215 |
+
name="rr-count" select="substring-after($conflict-counts, ',')"
|
| 216 |
+
/>
|
| 217 |
+
<xsl:if test="$sr-count > 0 or $rr-count > 0">
|
| 218 |
+
<xsl:value-of select="concat('State ', @number, ' conflicts:')"/>
|
| 219 |
+
<xsl:if test="$sr-count > 0">
|
| 220 |
+
<xsl:value-of select="concat(' ', $sr-count, ' shift/reduce')"/>
|
| 221 |
+
<xsl:if test="$rr-count > 0">
|
| 222 |
+
<xsl:value-of select="(',')"/>
|
| 223 |
+
</xsl:if>
|
| 224 |
+
</xsl:if>
|
| 225 |
+
<xsl:if test="$rr-count > 0">
|
| 226 |
+
<xsl:value-of select="concat(' ', $rr-count, ' reduce/reduce')"/>
|
| 227 |
+
</xsl:if>
|
| 228 |
+
<xsl:value-of select="' '"/>
|
| 229 |
+
</xsl:if>
|
| 230 |
+
</xsl:template>
|
| 231 |
+
|
| 232 |
+
<xsl:template match="automaton">
|
| 233 |
+
<xsl:apply-templates select="state">
|
| 234 |
+
<xsl:with-param name="pad" select="'3'"/>
|
| 235 |
+
</xsl:apply-templates>
|
| 236 |
+
</xsl:template>
|
| 237 |
+
|
| 238 |
+
<xsl:template match="automaton/state">
|
| 239 |
+
<xsl:param name="pad"/>
|
| 240 |
+
<xsl:text> </xsl:text>
|
| 241 |
+
<xsl:text>State </xsl:text>
|
| 242 |
+
<xsl:value-of select="@number"/>
|
| 243 |
+
<xsl:text> </xsl:text>
|
| 244 |
+
<xsl:apply-templates select="itemset/item">
|
| 245 |
+
<xsl:with-param name="pad" select="$pad"/>
|
| 246 |
+
</xsl:apply-templates>
|
| 247 |
+
<xsl:apply-templates select="actions/transitions">
|
| 248 |
+
<xsl:with-param name="type" select="'shift'"/>
|
| 249 |
+
</xsl:apply-templates>
|
| 250 |
+
<xsl:apply-templates select="actions/errors"/>
|
| 251 |
+
<xsl:apply-templates select="actions/reductions"/>
|
| 252 |
+
<xsl:apply-templates select="actions/transitions">
|
| 253 |
+
<xsl:with-param name="type" select="'goto'"/>
|
| 254 |
+
</xsl:apply-templates>
|
| 255 |
+
<xsl:apply-templates select="solved-conflicts"/>
|
| 256 |
+
</xsl:template>
|
| 257 |
+
|
| 258 |
+
<xsl:template match="actions/transitions">
|
| 259 |
+
<xsl:param name="type"/>
|
| 260 |
+
<xsl:if test="transition[@type = $type]">
|
| 261 |
+
<xsl:text> </xsl:text>
|
| 262 |
+
<xsl:apply-templates select="transition[@type = $type]">
|
| 263 |
+
<xsl:with-param name="pad">
|
| 264 |
+
<xsl:call-template name="max-width-symbol">
|
| 265 |
+
<xsl:with-param name="node" select="transition[@type = $type]"/>
|
| 266 |
+
</xsl:call-template>
|
| 267 |
+
</xsl:with-param>
|
| 268 |
+
</xsl:apply-templates>
|
| 269 |
+
</xsl:if>
|
| 270 |
+
</xsl:template>
|
| 271 |
+
|
| 272 |
+
<xsl:template match="actions/errors">
|
| 273 |
+
<xsl:if test="error">
|
| 274 |
+
<xsl:text> </xsl:text>
|
| 275 |
+
<xsl:apply-templates select="error">
|
| 276 |
+
<xsl:with-param name="pad">
|
| 277 |
+
<xsl:call-template name="max-width-symbol">
|
| 278 |
+
<xsl:with-param name="node" select="error"/>
|
| 279 |
+
</xsl:call-template>
|
| 280 |
+
</xsl:with-param>
|
| 281 |
+
</xsl:apply-templates>
|
| 282 |
+
</xsl:if>
|
| 283 |
+
</xsl:template>
|
| 284 |
+
|
| 285 |
+
<xsl:template match="actions/reductions">
|
| 286 |
+
<xsl:if test="reduction">
|
| 287 |
+
<xsl:text> </xsl:text>
|
| 288 |
+
<xsl:apply-templates select="reduction">
|
| 289 |
+
<xsl:with-param name="pad">
|
| 290 |
+
<xsl:call-template name="max-width-symbol">
|
| 291 |
+
<xsl:with-param name="node" select="reduction"/>
|
| 292 |
+
</xsl:call-template>
|
| 293 |
+
</xsl:with-param>
|
| 294 |
+
</xsl:apply-templates>
|
| 295 |
+
</xsl:if>
|
| 296 |
+
</xsl:template>
|
| 297 |
+
|
| 298 |
+
<xsl:template match="item">
|
| 299 |
+
<xsl:param name="pad"/>
|
| 300 |
+
<xsl:param name="prev-rule-number"
|
| 301 |
+
select="preceding-sibling::item[1]/@rule-number"/>
|
| 302 |
+
<xsl:apply-templates
|
| 303 |
+
select="key('bison:ruleByNumber', current()/@rule-number)"
|
| 304 |
+
>
|
| 305 |
+
<xsl:with-param name="itemset" select="'true'"/>
|
| 306 |
+
<xsl:with-param name="pad" select="$pad"/>
|
| 307 |
+
<xsl:with-param
|
| 308 |
+
name="prev-lhs"
|
| 309 |
+
select="key('bison:ruleByNumber', $prev-rule-number)/lhs[text()]"
|
| 310 |
+
/>
|
| 311 |
+
<xsl:with-param name="dot" select="@dot"/>
|
| 312 |
+
<xsl:with-param name="lookaheads">
|
| 313 |
+
<xsl:apply-templates select="lookaheads"/>
|
| 314 |
+
</xsl:with-param>
|
| 315 |
+
</xsl:apply-templates>
|
| 316 |
+
</xsl:template>
|
| 317 |
+
|
| 318 |
+
<xsl:template match="rule">
|
| 319 |
+
<xsl:param name="itemset"/>
|
| 320 |
+
<xsl:param name="pad"/>
|
| 321 |
+
<xsl:param name="prev-lhs"/>
|
| 322 |
+
<xsl:param name="dot"/>
|
| 323 |
+
<xsl:param name="lookaheads"/>
|
| 324 |
+
|
| 325 |
+
<xsl:if test="$itemset != 'true' and not($prev-lhs = lhs[text()])">
|
| 326 |
+
<xsl:text> </xsl:text>
|
| 327 |
+
</xsl:if>
|
| 328 |
+
|
| 329 |
+
<xsl:text> </xsl:text>
|
| 330 |
+
<xsl:call-template name="lpad">
|
| 331 |
+
<xsl:with-param name="str" select="string(@number)"/>
|
| 332 |
+
<xsl:with-param name="pad" select="number($pad)"/>
|
| 333 |
+
</xsl:call-template>
|
| 334 |
+
<xsl:text> </xsl:text>
|
| 335 |
+
|
| 336 |
+
<!-- LHS -->
|
| 337 |
+
<xsl:choose>
|
| 338 |
+
<xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">
|
| 339 |
+
<xsl:call-template name="lpad">
|
| 340 |
+
<xsl:with-param name="str" select="'|'"/>
|
| 341 |
+
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
|
| 342 |
+
</xsl:call-template>
|
| 343 |
+
</xsl:when>
|
| 344 |
+
<xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">
|
| 345 |
+
<xsl:call-template name="lpad">
|
| 346 |
+
<xsl:with-param name="str" select="'|'"/>
|
| 347 |
+
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
|
| 348 |
+
</xsl:call-template>
|
| 349 |
+
</xsl:when>
|
| 350 |
+
<xsl:otherwise>
|
| 351 |
+
<xsl:value-of select="lhs"/>
|
| 352 |
+
<xsl:text>:</xsl:text>
|
| 353 |
+
</xsl:otherwise>
|
| 354 |
+
</xsl:choose>
|
| 355 |
+
|
| 356 |
+
<!-- RHS -->
|
| 357 |
+
<xsl:for-each select="rhs/*">
|
| 358 |
+
<xsl:if test="position() = $dot + 1">
|
| 359 |
+
<xsl:text> •</xsl:text>
|
| 360 |
+
</xsl:if>
|
| 361 |
+
<xsl:apply-templates select="."/>
|
| 362 |
+
<xsl:if test="position() = last() and position() = $dot">
|
| 363 |
+
<xsl:text> •</xsl:text>
|
| 364 |
+
</xsl:if>
|
| 365 |
+
</xsl:for-each>
|
| 366 |
+
<xsl:if test="$lookaheads">
|
| 367 |
+
<xsl:value-of select="$lookaheads"/>
|
| 368 |
+
</xsl:if>
|
| 369 |
+
|
| 370 |
+
<xsl:text> </xsl:text>
|
| 371 |
+
</xsl:template>
|
| 372 |
+
|
| 373 |
+
<xsl:template match="symbol">
|
| 374 |
+
<xsl:text> </xsl:text>
|
| 375 |
+
<xsl:value-of select="."/>
|
| 376 |
+
</xsl:template>
|
| 377 |
+
|
| 378 |
+
<xsl:template match="empty">
|
| 379 |
+
<xsl:text> %empty</xsl:text>
|
| 380 |
+
</xsl:template>
|
| 381 |
+
|
| 382 |
+
<xsl:template match="lookaheads">
|
| 383 |
+
<xsl:text> [</xsl:text>
|
| 384 |
+
<xsl:apply-templates select="symbol"/>
|
| 385 |
+
<xsl:text>]</xsl:text>
|
| 386 |
+
</xsl:template>
|
| 387 |
+
|
| 388 |
+
<xsl:template match="lookaheads/symbol">
|
| 389 |
+
<xsl:value-of select="."/>
|
| 390 |
+
<xsl:if test="position() != last()">
|
| 391 |
+
<xsl:text>, </xsl:text>
|
| 392 |
+
</xsl:if>
|
| 393 |
+
</xsl:template>
|
| 394 |
+
|
| 395 |
+
<xsl:template match="transition">
|
| 396 |
+
<xsl:param name="pad"/>
|
| 397 |
+
<xsl:text> </xsl:text>
|
| 398 |
+
<xsl:call-template name="rpad">
|
| 399 |
+
<xsl:with-param name="str" select="string(@symbol)"/>
|
| 400 |
+
<xsl:with-param name="pad" select="number($pad) + 2"/>
|
| 401 |
+
</xsl:call-template>
|
| 402 |
+
<xsl:choose>
|
| 403 |
+
<xsl:when test="@type = 'shift'">
|
| 404 |
+
<xsl:text>shift, and go to state </xsl:text>
|
| 405 |
+
<xsl:value-of select="@state"/>
|
| 406 |
+
</xsl:when>
|
| 407 |
+
<xsl:when test="@type = 'goto'">
|
| 408 |
+
<xsl:text>go to state </xsl:text>
|
| 409 |
+
<xsl:value-of select="@state"/>
|
| 410 |
+
</xsl:when>
|
| 411 |
+
</xsl:choose>
|
| 412 |
+
<xsl:text> </xsl:text>
|
| 413 |
+
</xsl:template>
|
| 414 |
+
|
| 415 |
+
<xsl:template match="error">
|
| 416 |
+
<xsl:param name="pad"/>
|
| 417 |
+
<xsl:text> </xsl:text>
|
| 418 |
+
<xsl:call-template name="rpad">
|
| 419 |
+
<xsl:with-param name="str" select="string(@symbol)"/>
|
| 420 |
+
<xsl:with-param name="pad" select="number($pad) + 2"/>
|
| 421 |
+
</xsl:call-template>
|
| 422 |
+
<xsl:text>error</xsl:text>
|
| 423 |
+
<xsl:text> (</xsl:text>
|
| 424 |
+
<xsl:value-of select="text()"/>
|
| 425 |
+
<xsl:text>)</xsl:text>
|
| 426 |
+
<xsl:text> </xsl:text>
|
| 427 |
+
</xsl:template>
|
| 428 |
+
|
| 429 |
+
<xsl:template match="reduction">
|
| 430 |
+
<xsl:param name="pad"/>
|
| 431 |
+
<xsl:text> </xsl:text>
|
| 432 |
+
<xsl:call-template name="rpad">
|
| 433 |
+
<xsl:with-param name="str" select="string(@symbol)"/>
|
| 434 |
+
<xsl:with-param name="pad" select="number($pad) + 2"/>
|
| 435 |
+
</xsl:call-template>
|
| 436 |
+
<xsl:if test="@enabled = 'false'">
|
| 437 |
+
<xsl:text>[</xsl:text>
|
| 438 |
+
</xsl:if>
|
| 439 |
+
<xsl:choose>
|
| 440 |
+
<xsl:when test="@rule = 'accept'">
|
| 441 |
+
<xsl:text>accept</xsl:text>
|
| 442 |
+
</xsl:when>
|
| 443 |
+
<xsl:otherwise>
|
| 444 |
+
<xsl:text>reduce using rule </xsl:text>
|
| 445 |
+
<xsl:value-of select="@rule"/>
|
| 446 |
+
<xsl:text> (</xsl:text>
|
| 447 |
+
<xsl:value-of
|
| 448 |
+
select="key('bison:ruleByNumber', current()/@rule)/lhs[text()]"/>
|
| 449 |
+
<xsl:text>)</xsl:text>
|
| 450 |
+
</xsl:otherwise>
|
| 451 |
+
</xsl:choose>
|
| 452 |
+
<xsl:if test="@enabled = 'false'">
|
| 453 |
+
<xsl:text>]</xsl:text>
|
| 454 |
+
</xsl:if>
|
| 455 |
+
<xsl:text> </xsl:text>
|
| 456 |
+
</xsl:template>
|
| 457 |
+
|
| 458 |
+
<xsl:template match="solved-conflicts">
|
| 459 |
+
<xsl:if test="resolution">
|
| 460 |
+
<xsl:text> </xsl:text>
|
| 461 |
+
<xsl:apply-templates select="resolution"/>
|
| 462 |
+
</xsl:if>
|
| 463 |
+
</xsl:template>
|
| 464 |
+
|
| 465 |
+
<xsl:template match="resolution">
|
| 466 |
+
<xsl:text> Conflict between rule </xsl:text>
|
| 467 |
+
<xsl:value-of select="@rule"/>
|
| 468 |
+
<xsl:text> and token </xsl:text>
|
| 469 |
+
<xsl:value-of select="@symbol"/>
|
| 470 |
+
<xsl:text> resolved as </xsl:text>
|
| 471 |
+
<xsl:if test="@type = 'error'">
|
| 472 |
+
<xsl:text>an </xsl:text>
|
| 473 |
+
</xsl:if>
|
| 474 |
+
<xsl:value-of select="@type"/>
|
| 475 |
+
<xsl:text> (</xsl:text>
|
| 476 |
+
<xsl:value-of select="."/>
|
| 477 |
+
<xsl:text>). </xsl:text>
|
| 478 |
+
</xsl:template>
|
| 479 |
+
|
| 480 |
+
<xsl:template name="max-width-symbol">
|
| 481 |
+
<xsl:param name="node"/>
|
| 482 |
+
<xsl:variable name="longest">
|
| 483 |
+
<xsl:for-each select="$node">
|
| 484 |
+
<xsl:sort data-type="number" select="string-length(@symbol)"
|
| 485 |
+
order="descending"/>
|
| 486 |
+
<xsl:if test="position() = 1">
|
| 487 |
+
<xsl:value-of select="string-length(@symbol)"/>
|
| 488 |
+
</xsl:if>
|
| 489 |
+
</xsl:for-each>
|
| 490 |
+
</xsl:variable>
|
| 491 |
+
<xsl:value-of select="$longest"/>
|
| 492 |
+
</xsl:template>
|
| 493 |
+
|
| 494 |
+
<xsl:template name="lpad">
|
| 495 |
+
<xsl:param name="str" select="''"/>
|
| 496 |
+
<xsl:param name="pad" select="0"/>
|
| 497 |
+
<xsl:variable name="diff" select="$pad - string-length($str)" />
|
| 498 |
+
<xsl:choose>
|
| 499 |
+
<xsl:when test="$diff < 0">
|
| 500 |
+
<xsl:value-of select="$str"/>
|
| 501 |
+
</xsl:when>
|
| 502 |
+
<xsl:otherwise>
|
| 503 |
+
<xsl:call-template name="space">
|
| 504 |
+
<xsl:with-param name="repeat" select="$diff"/>
|
| 505 |
+
</xsl:call-template>
|
| 506 |
+
<xsl:value-of select="$str"/>
|
| 507 |
+
</xsl:otherwise>
|
| 508 |
+
</xsl:choose>
|
| 509 |
+
</xsl:template>
|
| 510 |
+
|
| 511 |
+
<xsl:template name="rpad">
|
| 512 |
+
<xsl:param name="str" select="''"/>
|
| 513 |
+
<xsl:param name="pad" select="0"/>
|
| 514 |
+
<xsl:variable name="diff" select="$pad - string-length($str)"/>
|
| 515 |
+
<xsl:choose>
|
| 516 |
+
<xsl:when test="$diff < 0">
|
| 517 |
+
<xsl:value-of select="$str"/>
|
| 518 |
+
</xsl:when>
|
| 519 |
+
<xsl:otherwise>
|
| 520 |
+
<xsl:value-of select="$str"/>
|
| 521 |
+
<xsl:call-template name="space">
|
| 522 |
+
<xsl:with-param name="repeat" select="$diff"/>
|
| 523 |
+
</xsl:call-template>
|
| 524 |
+
</xsl:otherwise>
|
| 525 |
+
</xsl:choose>
|
| 526 |
+
</xsl:template>
|
| 527 |
+
|
| 528 |
+
<xsl:template name="line-wrap">
|
| 529 |
+
<xsl:param name="line-length"/> <!-- required -->
|
| 530 |
+
<xsl:param name="first-line-length" select="$line-length"/>
|
| 531 |
+
<xsl:param name="text"/> <!-- required -->
|
| 532 |
+
<xsl:choose>
|
| 533 |
+
<xsl:when test="normalize-space($text) = ''" />
|
| 534 |
+
<xsl:when test="string-length($text) <= $first-line-length">
|
| 535 |
+
<xsl:value-of select="concat($text, ' ')" />
|
| 536 |
+
</xsl:when>
|
| 537 |
+
<xsl:otherwise>
|
| 538 |
+
<xsl:variable name="break-pos">
|
| 539 |
+
<xsl:call-template name="ws-search">
|
| 540 |
+
<xsl:with-param name="text" select="$text" />
|
| 541 |
+
<xsl:with-param name="start" select="$first-line-length+1" />
|
| 542 |
+
</xsl:call-template>
|
| 543 |
+
</xsl:variable>
|
| 544 |
+
<xsl:value-of select="substring($text, 1, $break-pos - 1)" />
|
| 545 |
+
<xsl:text> </xsl:text>
|
| 546 |
+
<xsl:call-template name="line-wrap">
|
| 547 |
+
<xsl:with-param name="line-length" select="$line-length" />
|
| 548 |
+
<xsl:with-param
|
| 549 |
+
name="text" select="concat(' ', substring($text, $break-pos+1))"
|
| 550 |
+
/>
|
| 551 |
+
</xsl:call-template>
|
| 552 |
+
</xsl:otherwise>
|
| 553 |
+
</xsl:choose>
|
| 554 |
+
</xsl:template>
|
| 555 |
+
|
| 556 |
+
<xsl:template name="ws-search">
|
| 557 |
+
<xsl:param name="text"/> <!-- required -->
|
| 558 |
+
<xsl:param name="start"/> <!-- required -->
|
| 559 |
+
<xsl:variable name="search-text" select="substring($text, $start)" />
|
| 560 |
+
<xsl:choose>
|
| 561 |
+
<xsl:when test="not(contains($search-text, ' '))">
|
| 562 |
+
<xsl:value-of select="string-length($text)+1" />
|
| 563 |
+
</xsl:when>
|
| 564 |
+
<xsl:otherwise>
|
| 565 |
+
<xsl:value-of
|
| 566 |
+
select="$start + string-length(substring-before($search-text, ' '))"
|
| 567 |
+
/>
|
| 568 |
+
</xsl:otherwise>
|
| 569 |
+
</xsl:choose>
|
| 570 |
+
</xsl:template>
|
| 571 |
+
|
| 572 |
+
</xsl:stylesheet>
|
platform/dbops/binaries/build/share/bison/xslt/xml2xhtml.xsl
ADDED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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
|
| 3 |
+
<!--
|
| 4 |
+
xml2html.xsl - transform Bison XML Report into XHTML.
|
| 5 |
+
|
| 6 |
+
Copyright (C) 2007-2015, 2018-2021 Free Software Foundation, Inc.
|
| 7 |
+
|
| 8 |
+
This file is part of Bison, the GNU Compiler Compiler.
|
| 9 |
+
|
| 10 |
+
This program is free software: you can redistribute it and/or modify
|
| 11 |
+
it under the terms of the GNU General Public License as published by
|
| 12 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 13 |
+
(at your option) any later version.
|
| 14 |
+
|
| 15 |
+
This program is distributed in the hope that it will be useful,
|
| 16 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 17 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 18 |
+
GNU General Public License for more details.
|
| 19 |
+
|
| 20 |
+
You should have received a copy of the GNU General Public License
|
| 21 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 22 |
+
|
| 23 |
+
Written by Wojciech Polak <polak@gnu.org>.
|
| 24 |
+
-->
|
| 25 |
+
|
| 26 |
+
<xsl:stylesheet version="1.0"
|
| 27 |
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
| 28 |
+
xmlns="http://www.w3.org/1999/xhtml"
|
| 29 |
+
xmlns:bison="https://www.gnu.org/software/bison/">
|
| 30 |
+
|
| 31 |
+
<xsl:import href="bison.xsl"/>
|
| 32 |
+
|
| 33 |
+
<xsl:output method="xml" encoding="UTF-8"
|
| 34 |
+
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
|
| 35 |
+
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
|
| 36 |
+
indent="yes"/>
|
| 37 |
+
|
| 38 |
+
<xsl:template match="/">
|
| 39 |
+
<html>
|
| 40 |
+
<head>
|
| 41 |
+
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
| 42 |
+
<title>
|
| 43 |
+
<xsl:value-of select="bison-xml-report/filename"/>
|
| 44 |
+
<xsl:text> - GNU Bison XML Automaton Report</xsl:text>
|
| 45 |
+
</title>
|
| 46 |
+
<style type="text/css"><![CDATA[
|
| 47 |
+
body {
|
| 48 |
+
font-family: "Nimbus Sans L", Arial, sans-serif;
|
| 49 |
+
font-size: 9pt;
|
| 50 |
+
}
|
| 51 |
+
a:link {
|
| 52 |
+
color: #1f00ff;
|
| 53 |
+
text-decoration: none;
|
| 54 |
+
}
|
| 55 |
+
a:visited {
|
| 56 |
+
color: #1f00ff;
|
| 57 |
+
text-decoration: none;
|
| 58 |
+
}
|
| 59 |
+
a:hover {
|
| 60 |
+
color: red;
|
| 61 |
+
}
|
| 62 |
+
#menu a {
|
| 63 |
+
text-decoration: underline;
|
| 64 |
+
}
|
| 65 |
+
.i {
|
| 66 |
+
font-style: italic;
|
| 67 |
+
}
|
| 68 |
+
.pre {
|
| 69 |
+
font-family: monospace;
|
| 70 |
+
white-space: pre;
|
| 71 |
+
}
|
| 72 |
+
ol.decimal {
|
| 73 |
+
list-style-type: decimal;
|
| 74 |
+
}
|
| 75 |
+
ol.lower-alpha {
|
| 76 |
+
list-style-type: lower-alpha;
|
| 77 |
+
}
|
| 78 |
+
.dot {
|
| 79 |
+
color: #cc0000;
|
| 80 |
+
}
|
| 81 |
+
#footer {
|
| 82 |
+
margin-top: 3.5em;
|
| 83 |
+
font-size: 7pt;
|
| 84 |
+
}
|
| 85 |
+
]]></style>
|
| 86 |
+
</head>
|
| 87 |
+
<body>
|
| 88 |
+
<xsl:apply-templates select="bison-xml-report"/>
|
| 89 |
+
<xsl:text> </xsl:text>
|
| 90 |
+
<div id="footer"><hr />This document was generated using
|
| 91 |
+
<a href="https://www.gnu.org/software/bison/" title="GNU Bison">
|
| 92 |
+
GNU Bison <xsl:value-of select="/bison-xml-report/@version"/></a>
|
| 93 |
+
XML Automaton Report.<br />
|
| 94 |
+
<!-- default copying notice -->
|
| 95 |
+
Verbatim copying and distribution of this entire page is
|
| 96 |
+
permitted in any medium, provided this notice is preserved.</div>
|
| 97 |
+
</body>
|
| 98 |
+
</html>
|
| 99 |
+
</xsl:template>
|
| 100 |
+
|
| 101 |
+
<xsl:template match="bison-xml-report">
|
| 102 |
+
<h1>GNU Bison XML Automaton Report</h1>
|
| 103 |
+
<p>
|
| 104 |
+
input grammar: <span class="i"><xsl:value-of select="filename"/></span>
|
| 105 |
+
</p>
|
| 106 |
+
|
| 107 |
+
<xsl:text> </xsl:text>
|
| 108 |
+
<h3>Table of Contents</h3>
|
| 109 |
+
<ul id="menu">
|
| 110 |
+
<li>
|
| 111 |
+
<a href="#reductions">Reductions</a>
|
| 112 |
+
<ul class="lower-alpha">
|
| 113 |
+
<li><a href="#nonterminals_useless_in_grammar">Nonterminals useless in grammar</a></li>
|
| 114 |
+
<li><a href="#terminals_unused_in_grammar">Terminals unused in grammar</a></li>
|
| 115 |
+
<li><a href="#rules_useless_in_grammar">Rules useless in grammar</a></li>
|
| 116 |
+
<xsl:if test="grammar/rules/rule[@usefulness='useless-in-parser']">
|
| 117 |
+
<li><a href="#rules_useless_in_parser">Rules useless in parser due to conflicts</a></li>
|
| 118 |
+
</xsl:if>
|
| 119 |
+
</ul>
|
| 120 |
+
</li>
|
| 121 |
+
<li><a href="#conflicts">Conflicts</a></li>
|
| 122 |
+
<li>
|
| 123 |
+
<a href="#grammar">Grammar</a>
|
| 124 |
+
<ul class="lower-alpha">
|
| 125 |
+
<li><a href="#grammar">Itemset</a></li>
|
| 126 |
+
<li><a href="#terminals">Terminal symbols</a></li>
|
| 127 |
+
<li><a href="#nonterminals">Nonterminal symbols</a></li>
|
| 128 |
+
</ul>
|
| 129 |
+
</li>
|
| 130 |
+
<li><a href="#automaton">Automaton</a></li>
|
| 131 |
+
</ul>
|
| 132 |
+
<xsl:apply-templates select="grammar" mode="reductions"/>
|
| 133 |
+
<xsl:apply-templates select="grammar" mode="useless-in-parser"/>
|
| 134 |
+
<xsl:apply-templates select="automaton" mode="conflicts"/>
|
| 135 |
+
<xsl:apply-templates select="grammar"/>
|
| 136 |
+
<xsl:apply-templates select="automaton"/>
|
| 137 |
+
</xsl:template>
|
| 138 |
+
|
| 139 |
+
<xsl:template match="grammar" mode="reductions">
|
| 140 |
+
<h2>
|
| 141 |
+
<a name="reductions"/>
|
| 142 |
+
<xsl:text> Reductions</xsl:text>
|
| 143 |
+
</h2>
|
| 144 |
+
<xsl:apply-templates select="nonterminals" mode="useless-in-grammar"/>
|
| 145 |
+
<xsl:apply-templates select="terminals" mode="unused-in-grammar"/>
|
| 146 |
+
<xsl:apply-templates select="rules" mode="useless-in-grammar"/>
|
| 147 |
+
</xsl:template>
|
| 148 |
+
|
| 149 |
+
<xsl:template match="nonterminals" mode="useless-in-grammar">
|
| 150 |
+
<h3>
|
| 151 |
+
<a name="nonterminals_useless_in_grammar"/>
|
| 152 |
+
<xsl:text> Nonterminals useless in grammar</xsl:text>
|
| 153 |
+
</h3>
|
| 154 |
+
<xsl:text> </xsl:text>
|
| 155 |
+
<xsl:if test="nonterminal[@usefulness='useless-in-grammar']">
|
| 156 |
+
<p class="pre">
|
| 157 |
+
<xsl:for-each select="nonterminal[@usefulness='useless-in-grammar']">
|
| 158 |
+
<xsl:text> </xsl:text>
|
| 159 |
+
<xsl:value-of select="@name"/>
|
| 160 |
+
<xsl:text> </xsl:text>
|
| 161 |
+
</xsl:for-each>
|
| 162 |
+
<xsl:text> </xsl:text>
|
| 163 |
+
</p>
|
| 164 |
+
</xsl:if>
|
| 165 |
+
</xsl:template>
|
| 166 |
+
|
| 167 |
+
<xsl:template match="terminals" mode="unused-in-grammar">
|
| 168 |
+
<h3>
|
| 169 |
+
<a name="terminals_unused_in_grammar"/>
|
| 170 |
+
<xsl:text> Terminals unused in grammar</xsl:text>
|
| 171 |
+
</h3>
|
| 172 |
+
<xsl:text> </xsl:text>
|
| 173 |
+
<xsl:if test="terminal[@usefulness='unused-in-grammar']">
|
| 174 |
+
<p class="pre">
|
| 175 |
+
<xsl:for-each select="terminal[@usefulness='unused-in-grammar']">
|
| 176 |
+
<xsl:sort select="@symbol-number" data-type="number"/>
|
| 177 |
+
<xsl:text> </xsl:text>
|
| 178 |
+
<xsl:value-of select="@name"/>
|
| 179 |
+
<xsl:text> </xsl:text>
|
| 180 |
+
</xsl:for-each>
|
| 181 |
+
<xsl:text> </xsl:text>
|
| 182 |
+
</p>
|
| 183 |
+
</xsl:if>
|
| 184 |
+
</xsl:template>
|
| 185 |
+
|
| 186 |
+
<xsl:template match="rules" mode="useless-in-grammar">
|
| 187 |
+
<h3>
|
| 188 |
+
<a name="rules_useless_in_grammar"/>
|
| 189 |
+
<xsl:text> Rules useless in grammar</xsl:text>
|
| 190 |
+
</h3>
|
| 191 |
+
<xsl:text> </xsl:text>
|
| 192 |
+
<xsl:variable name="set" select="rule[@usefulness='useless-in-grammar']"/>
|
| 193 |
+
<xsl:if test="$set">
|
| 194 |
+
<p class="pre">
|
| 195 |
+
<xsl:call-template name="style-rule-set">
|
| 196 |
+
<xsl:with-param name="rule-set" select="$set"/>
|
| 197 |
+
</xsl:call-template>
|
| 198 |
+
<xsl:text> </xsl:text>
|
| 199 |
+
</p>
|
| 200 |
+
</xsl:if>
|
| 201 |
+
</xsl:template>
|
| 202 |
+
|
| 203 |
+
<xsl:template match="grammar" mode="useless-in-parser">
|
| 204 |
+
<xsl:variable
|
| 205 |
+
name="set" select="rules/rule[@usefulness='useless-in-parser']"
|
| 206 |
+
/>
|
| 207 |
+
<xsl:if test="$set">
|
| 208 |
+
<h2>
|
| 209 |
+
<a name="rules_useless_in_parser"/>
|
| 210 |
+
<xsl:text> Rules useless in parser due to conflicts</xsl:text>
|
| 211 |
+
</h2>
|
| 212 |
+
<xsl:text> </xsl:text>
|
| 213 |
+
<p class="pre">
|
| 214 |
+
<xsl:call-template name="style-rule-set">
|
| 215 |
+
<xsl:with-param name="rule-set" select="$set"/>
|
| 216 |
+
</xsl:call-template>
|
| 217 |
+
</p>
|
| 218 |
+
<xsl:text> </xsl:text>
|
| 219 |
+
</xsl:if>
|
| 220 |
+
</xsl:template>
|
| 221 |
+
|
| 222 |
+
<xsl:template match="grammar">
|
| 223 |
+
<h2>
|
| 224 |
+
<a name="grammar"/>
|
| 225 |
+
<xsl:text> Grammar</xsl:text>
|
| 226 |
+
</h2>
|
| 227 |
+
<xsl:text> </xsl:text>
|
| 228 |
+
<p class="pre">
|
| 229 |
+
<xsl:call-template name="style-rule-set">
|
| 230 |
+
<xsl:with-param name="anchor" select="'true'" />
|
| 231 |
+
<xsl:with-param
|
| 232 |
+
name="rule-set" select="rules/rule[@usefulness!='useless-in-grammar']"
|
| 233 |
+
/>
|
| 234 |
+
</xsl:call-template>
|
| 235 |
+
</p>
|
| 236 |
+
<xsl:text> </xsl:text>
|
| 237 |
+
<xsl:apply-templates select="terminals"/>
|
| 238 |
+
<xsl:apply-templates select="nonterminals"/>
|
| 239 |
+
</xsl:template>
|
| 240 |
+
|
| 241 |
+
<xsl:template name="style-rule-set">
|
| 242 |
+
<xsl:param name="anchor"/>
|
| 243 |
+
<xsl:param name="rule-set"/>
|
| 244 |
+
<xsl:for-each select="$rule-set">
|
| 245 |
+
<xsl:apply-templates select=".">
|
| 246 |
+
<xsl:with-param name="anchor" select="$anchor"/>
|
| 247 |
+
<xsl:with-param name="pad" select="'3'"/>
|
| 248 |
+
<xsl:with-param name="prev-lhs">
|
| 249 |
+
<xsl:if test="position()>1">
|
| 250 |
+
<xsl:variable name="position" select="position()"/>
|
| 251 |
+
<xsl:value-of select="$rule-set[$position - 1]/lhs"/>
|
| 252 |
+
</xsl:if>
|
| 253 |
+
</xsl:with-param>
|
| 254 |
+
</xsl:apply-templates>
|
| 255 |
+
</xsl:for-each>
|
| 256 |
+
</xsl:template>
|
| 257 |
+
|
| 258 |
+
<xsl:template match="automaton" mode="conflicts">
|
| 259 |
+
<h2>
|
| 260 |
+
<a name="conflicts"/>
|
| 261 |
+
<xsl:text> Conflicts</xsl:text>
|
| 262 |
+
</h2>
|
| 263 |
+
<xsl:text> </xsl:text>
|
| 264 |
+
<xsl:variable name="conflict-report">
|
| 265 |
+
<xsl:apply-templates select="state" mode="conflicts"/>
|
| 266 |
+
</xsl:variable>
|
| 267 |
+
<xsl:if test="string-length($conflict-report) != 0">
|
| 268 |
+
<p class="pre">
|
| 269 |
+
<xsl:copy-of select="$conflict-report"/>
|
| 270 |
+
<xsl:text> </xsl:text>
|
| 271 |
+
</p>
|
| 272 |
+
</xsl:if>
|
| 273 |
+
</xsl:template>
|
| 274 |
+
|
| 275 |
+
<xsl:template match="state" mode="conflicts">
|
| 276 |
+
<xsl:variable name="conflict-counts">
|
| 277 |
+
<xsl:apply-templates select="." mode="bison:count-conflicts" />
|
| 278 |
+
</xsl:variable>
|
| 279 |
+
<xsl:variable
|
| 280 |
+
name="sr-count" select="substring-before($conflict-counts, ',')"
|
| 281 |
+
/>
|
| 282 |
+
<xsl:variable
|
| 283 |
+
name="rr-count" select="substring-after($conflict-counts, ',')"
|
| 284 |
+
/>
|
| 285 |
+
<xsl:if test="$sr-count > 0 or $rr-count > 0">
|
| 286 |
+
<a>
|
| 287 |
+
<xsl:attribute name="href">
|
| 288 |
+
<xsl:value-of select="concat('#state_', @number)"/>
|
| 289 |
+
</xsl:attribute>
|
| 290 |
+
<xsl:value-of select="concat('State ', @number)"/>
|
| 291 |
+
</a>
|
| 292 |
+
<xsl:text> conflicts:</xsl:text>
|
| 293 |
+
<xsl:if test="$sr-count > 0">
|
| 294 |
+
<xsl:value-of select="concat(' ', $sr-count, ' shift/reduce')"/>
|
| 295 |
+
<xsl:if test="$rr-count > 0">
|
| 296 |
+
<xsl:value-of select="(',')"/>
|
| 297 |
+
</xsl:if>
|
| 298 |
+
</xsl:if>
|
| 299 |
+
<xsl:if test="$rr-count > 0">
|
| 300 |
+
<xsl:value-of select="concat(' ', $rr-count, ' reduce/reduce')"/>
|
| 301 |
+
</xsl:if>
|
| 302 |
+
<xsl:value-of select="' '"/>
|
| 303 |
+
</xsl:if>
|
| 304 |
+
</xsl:template>
|
| 305 |
+
|
| 306 |
+
<xsl:template match="grammar/terminals">
|
| 307 |
+
<h3>
|
| 308 |
+
<a name="terminals"/>
|
| 309 |
+
<xsl:text> Terminals, with rules where they appear</xsl:text>
|
| 310 |
+
</h3>
|
| 311 |
+
<xsl:text> </xsl:text>
|
| 312 |
+
<ul>
|
| 313 |
+
<xsl:text> </xsl:text>
|
| 314 |
+
<xsl:apply-templates select="terminal"/>
|
| 315 |
+
</ul>
|
| 316 |
+
<xsl:text> </xsl:text>
|
| 317 |
+
</xsl:template>
|
| 318 |
+
|
| 319 |
+
<xsl:template match="grammar/nonterminals">
|
| 320 |
+
<h3>
|
| 321 |
+
<a name="nonterminals"/>
|
| 322 |
+
<xsl:text> Nonterminals, with rules where they appear</xsl:text>
|
| 323 |
+
</h3>
|
| 324 |
+
<xsl:text> </xsl:text>
|
| 325 |
+
<ul>
|
| 326 |
+
<xsl:text> </xsl:text>
|
| 327 |
+
<xsl:apply-templates
|
| 328 |
+
select="nonterminal[@usefulness!='useless-in-grammar']"
|
| 329 |
+
/>
|
| 330 |
+
</ul>
|
| 331 |
+
</xsl:template>
|
| 332 |
+
|
| 333 |
+
<xsl:template match="terminal">
|
| 334 |
+
<xsl:text> </xsl:text>
|
| 335 |
+
<li>
|
| 336 |
+
<b><xsl:value-of select="@name"/></b>
|
| 337 |
+
<xsl:if test="string-length(@type) != 0">
|
| 338 |
+
<xsl:value-of select="concat(' <', @type, '>')"/>
|
| 339 |
+
</xsl:if>
|
| 340 |
+
<xsl:value-of select="concat(' (', @token-number, ')')"/>
|
| 341 |
+
<xsl:for-each select="key('bison:ruleByRhs', @name)">
|
| 342 |
+
<xsl:apply-templates select="." mode="number-link"/>
|
| 343 |
+
</xsl:for-each>
|
| 344 |
+
</li>
|
| 345 |
+
<xsl:text> </xsl:text>
|
| 346 |
+
</xsl:template>
|
| 347 |
+
|
| 348 |
+
<xsl:template match="nonterminal">
|
| 349 |
+
<xsl:text> </xsl:text>
|
| 350 |
+
<li>
|
| 351 |
+
<b><xsl:value-of select="@name"/></b>
|
| 352 |
+
<xsl:if test="string-length(@type) != 0">
|
| 353 |
+
<xsl:value-of select="concat(' <', @type, '>')"/>
|
| 354 |
+
</xsl:if>
|
| 355 |
+
<xsl:value-of select="concat(' (', @symbol-number, ')')"/>
|
| 356 |
+
<xsl:text> </xsl:text>
|
| 357 |
+
<ul>
|
| 358 |
+
<xsl:text> </xsl:text>
|
| 359 |
+
<xsl:if test="key('bison:ruleByLhs', @name)">
|
| 360 |
+
<xsl:text> </xsl:text>
|
| 361 |
+
<li>
|
| 362 |
+
<xsl:text>on left:</xsl:text>
|
| 363 |
+
<xsl:for-each select="key('bison:ruleByLhs', @name)">
|
| 364 |
+
<xsl:apply-templates select="." mode="number-link"/>
|
| 365 |
+
</xsl:for-each>
|
| 366 |
+
</li>
|
| 367 |
+
<xsl:text> </xsl:text>
|
| 368 |
+
</xsl:if>
|
| 369 |
+
<xsl:if test="key('bison:ruleByRhs', @name)">
|
| 370 |
+
<xsl:text> </xsl:text>
|
| 371 |
+
<li>
|
| 372 |
+
<xsl:text>on right:</xsl:text>
|
| 373 |
+
<xsl:for-each select="key('bison:ruleByRhs', @name)">
|
| 374 |
+
<xsl:apply-templates select="." mode="number-link"/>
|
| 375 |
+
</xsl:for-each>
|
| 376 |
+
</li>
|
| 377 |
+
<xsl:text> </xsl:text>
|
| 378 |
+
</xsl:if>
|
| 379 |
+
<xsl:text> </xsl:text>
|
| 380 |
+
</ul>
|
| 381 |
+
<xsl:text> </xsl:text>
|
| 382 |
+
</li>
|
| 383 |
+
<xsl:text> </xsl:text>
|
| 384 |
+
</xsl:template>
|
| 385 |
+
|
| 386 |
+
<xsl:template match="rule" mode="number-link">
|
| 387 |
+
<xsl:text> </xsl:text>
|
| 388 |
+
<a>
|
| 389 |
+
<xsl:attribute name="href">
|
| 390 |
+
<xsl:value-of select="concat('#rule_', @number)"/>
|
| 391 |
+
</xsl:attribute>
|
| 392 |
+
<xsl:value-of select="@number"/>
|
| 393 |
+
</a>
|
| 394 |
+
</xsl:template>
|
| 395 |
+
|
| 396 |
+
<xsl:template match="automaton">
|
| 397 |
+
<h2>
|
| 398 |
+
<a name="automaton"/>
|
| 399 |
+
<xsl:text> Automaton</xsl:text>
|
| 400 |
+
</h2>
|
| 401 |
+
<xsl:apply-templates select="state">
|
| 402 |
+
<xsl:with-param name="pad" select="'3'"/>
|
| 403 |
+
</xsl:apply-templates>
|
| 404 |
+
</xsl:template>
|
| 405 |
+
|
| 406 |
+
<xsl:template match="automaton/state">
|
| 407 |
+
<xsl:param name="pad"/>
|
| 408 |
+
<xsl:text> </xsl:text>
|
| 409 |
+
<h3>
|
| 410 |
+
<a>
|
| 411 |
+
<xsl:attribute name="name">
|
| 412 |
+
<xsl:value-of select="concat('state_', @number)"/>
|
| 413 |
+
</xsl:attribute>
|
| 414 |
+
</a>
|
| 415 |
+
<xsl:text>State </xsl:text>
|
| 416 |
+
<xsl:value-of select="@number"/>
|
| 417 |
+
</h3>
|
| 418 |
+
<xsl:text> </xsl:text>
|
| 419 |
+
<p class="pre">
|
| 420 |
+
<xsl:apply-templates select="itemset/item">
|
| 421 |
+
<xsl:with-param name="pad" select="$pad"/>
|
| 422 |
+
</xsl:apply-templates>
|
| 423 |
+
<xsl:apply-templates select="actions/transitions">
|
| 424 |
+
<xsl:with-param name="type" select="'shift'"/>
|
| 425 |
+
</xsl:apply-templates>
|
| 426 |
+
<xsl:apply-templates select="actions/errors"/>
|
| 427 |
+
<xsl:apply-templates select="actions/reductions"/>
|
| 428 |
+
<xsl:apply-templates select="actions/transitions">
|
| 429 |
+
<xsl:with-param name="type" select="'goto'"/>
|
| 430 |
+
</xsl:apply-templates>
|
| 431 |
+
<xsl:apply-templates select="solved-conflicts"/>
|
| 432 |
+
</p>
|
| 433 |
+
</xsl:template>
|
| 434 |
+
|
| 435 |
+
<xsl:template match="actions/transitions">
|
| 436 |
+
<xsl:param name="type"/>
|
| 437 |
+
<xsl:if test="transition[@type = $type]">
|
| 438 |
+
<xsl:text> </xsl:text>
|
| 439 |
+
<xsl:apply-templates select="transition[@type = $type]">
|
| 440 |
+
<xsl:with-param name="pad">
|
| 441 |
+
<xsl:call-template name="max-width-symbol">
|
| 442 |
+
<xsl:with-param name="node" select="transition[@type = $type]"/>
|
| 443 |
+
</xsl:call-template>
|
| 444 |
+
</xsl:with-param>
|
| 445 |
+
</xsl:apply-templates>
|
| 446 |
+
</xsl:if>
|
| 447 |
+
</xsl:template>
|
| 448 |
+
|
| 449 |
+
<xsl:template match="actions/errors">
|
| 450 |
+
<xsl:if test="error">
|
| 451 |
+
<xsl:text> </xsl:text>
|
| 452 |
+
<xsl:apply-templates select="error">
|
| 453 |
+
<xsl:with-param name="pad">
|
| 454 |
+
<xsl:call-template name="max-width-symbol">
|
| 455 |
+
<xsl:with-param name="node" select="error"/>
|
| 456 |
+
</xsl:call-template>
|
| 457 |
+
</xsl:with-param>
|
| 458 |
+
</xsl:apply-templates>
|
| 459 |
+
</xsl:if>
|
| 460 |
+
</xsl:template>
|
| 461 |
+
|
| 462 |
+
<xsl:template match="actions/reductions">
|
| 463 |
+
<xsl:if test="reduction">
|
| 464 |
+
<xsl:text> </xsl:text>
|
| 465 |
+
<xsl:apply-templates select="reduction">
|
| 466 |
+
<xsl:with-param name="pad">
|
| 467 |
+
<xsl:call-template name="max-width-symbol">
|
| 468 |
+
<xsl:with-param name="node" select="reduction"/>
|
| 469 |
+
</xsl:call-template>
|
| 470 |
+
</xsl:with-param>
|
| 471 |
+
</xsl:apply-templates>
|
| 472 |
+
</xsl:if>
|
| 473 |
+
</xsl:template>
|
| 474 |
+
|
| 475 |
+
<xsl:template match="item">
|
| 476 |
+
<xsl:param name="pad"/>
|
| 477 |
+
<xsl:param name="prev-rule-number"
|
| 478 |
+
select="preceding-sibling::item[1]/@rule-number"/>
|
| 479 |
+
<xsl:apply-templates
|
| 480 |
+
select="key('bison:ruleByNumber', current()/@rule-number)"
|
| 481 |
+
>
|
| 482 |
+
<xsl:with-param name="itemset" select="'true'"/>
|
| 483 |
+
<xsl:with-param name="pad" select="$pad"/>
|
| 484 |
+
<xsl:with-param name="prev-lhs"
|
| 485 |
+
select="key('bison:ruleByNumber', $prev-rule-number)/lhs[text()]"
|
| 486 |
+
/>
|
| 487 |
+
<xsl:with-param name="dot" select="@dot"/>
|
| 488 |
+
<xsl:with-param name="lookaheads">
|
| 489 |
+
<xsl:apply-templates select="lookaheads"/>
|
| 490 |
+
</xsl:with-param>
|
| 491 |
+
</xsl:apply-templates>
|
| 492 |
+
</xsl:template>
|
| 493 |
+
|
| 494 |
+
<!--
|
| 495 |
+
anchor = 'true': define as an <a> anchor.
|
| 496 |
+
itemset = 'true': show the items.
|
| 497 |
+
-->
|
| 498 |
+
<xsl:template match="rule">
|
| 499 |
+
<xsl:param name="anchor"/>
|
| 500 |
+
<xsl:param name="itemset"/>
|
| 501 |
+
<xsl:param name="pad"/>
|
| 502 |
+
<xsl:param name="prev-lhs"/>
|
| 503 |
+
<xsl:param name="dot"/>
|
| 504 |
+
<xsl:param name="lookaheads"/>
|
| 505 |
+
|
| 506 |
+
<xsl:if test="$itemset != 'true' and not($prev-lhs = lhs[text()])">
|
| 507 |
+
<xsl:text> </xsl:text>
|
| 508 |
+
</xsl:if>
|
| 509 |
+
|
| 510 |
+
<xsl:text> </xsl:text>
|
| 511 |
+
|
| 512 |
+
<xsl:choose>
|
| 513 |
+
<xsl:when test="$anchor = 'true'">
|
| 514 |
+
<a>
|
| 515 |
+
<xsl:attribute name="name">
|
| 516 |
+
<xsl:value-of select="concat('rule_', @number)"/>
|
| 517 |
+
</xsl:attribute>
|
| 518 |
+
<xsl:call-template name="lpad">
|
| 519 |
+
<xsl:with-param name="str" select="string(@number)"/>
|
| 520 |
+
<xsl:with-param name="pad" select="number($pad)"/>
|
| 521 |
+
</xsl:call-template>
|
| 522 |
+
</a>
|
| 523 |
+
</xsl:when>
|
| 524 |
+
<xsl:otherwise>
|
| 525 |
+
<a>
|
| 526 |
+
<xsl:attribute name="href">
|
| 527 |
+
<xsl:value-of select="concat('#rule_', @number)"/>
|
| 528 |
+
</xsl:attribute>
|
| 529 |
+
<xsl:call-template name="lpad">
|
| 530 |
+
<xsl:with-param name="str" select="string(@number)"/>
|
| 531 |
+
<xsl:with-param name="pad" select="number($pad)"/>
|
| 532 |
+
</xsl:call-template>
|
| 533 |
+
</a>
|
| 534 |
+
</xsl:otherwise>
|
| 535 |
+
</xsl:choose>
|
| 536 |
+
<xsl:text> </xsl:text>
|
| 537 |
+
|
| 538 |
+
<!-- LHS -->
|
| 539 |
+
<xsl:choose>
|
| 540 |
+
<xsl:when test="$prev-lhs = lhs[text()]">
|
| 541 |
+
<xsl:call-template name="lpad">
|
| 542 |
+
<xsl:with-param name="str" select="'|'"/>
|
| 543 |
+
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
|
| 544 |
+
</xsl:call-template>
|
| 545 |
+
</xsl:when>
|
| 546 |
+
<xsl:otherwise>
|
| 547 |
+
<span class="i">
|
| 548 |
+
<xsl:value-of select="lhs"/>
|
| 549 |
+
</span>
|
| 550 |
+
<xsl:text> →</xsl:text>
|
| 551 |
+
</xsl:otherwise>
|
| 552 |
+
</xsl:choose>
|
| 553 |
+
|
| 554 |
+
<!-- RHS -->
|
| 555 |
+
<xsl:for-each select="rhs/*">
|
| 556 |
+
<xsl:if test="position() = $dot + 1">
|
| 557 |
+
<xsl:text> </xsl:text>
|
| 558 |
+
<span class="dot">•</span>
|
| 559 |
+
</xsl:if>
|
| 560 |
+
<xsl:apply-templates select="."/>
|
| 561 |
+
<xsl:if test="position() = last() and position() = $dot">
|
| 562 |
+
<xsl:text> </xsl:text>
|
| 563 |
+
<span class="dot">•</span>
|
| 564 |
+
</xsl:if>
|
| 565 |
+
</xsl:for-each>
|
| 566 |
+
<xsl:if test="$lookaheads">
|
| 567 |
+
<xsl:value-of select="$lookaheads"/>
|
| 568 |
+
</xsl:if>
|
| 569 |
+
|
| 570 |
+
<xsl:text> </xsl:text>
|
| 571 |
+
</xsl:template>
|
| 572 |
+
|
| 573 |
+
<xsl:template match="symbol">
|
| 574 |
+
<xsl:text> </xsl:text>
|
| 575 |
+
<xsl:choose>
|
| 576 |
+
<xsl:when test="name(key('bison:symbolByName', .)) = 'nonterminal'">
|
| 577 |
+
<span class="i"><xsl:value-of select="."/></span>
|
| 578 |
+
</xsl:when>
|
| 579 |
+
<xsl:otherwise>
|
| 580 |
+
<b><xsl:value-of select="."/></b>
|
| 581 |
+
</xsl:otherwise>
|
| 582 |
+
</xsl:choose>
|
| 583 |
+
</xsl:template>
|
| 584 |
+
|
| 585 |
+
<xsl:template match="empty">
|
| 586 |
+
<xsl:text> %empty</xsl:text>
|
| 587 |
+
</xsl:template>
|
| 588 |
+
|
| 589 |
+
<xsl:template match="lookaheads">
|
| 590 |
+
<xsl:text> [</xsl:text>
|
| 591 |
+
<xsl:apply-templates select="symbol"/>
|
| 592 |
+
<xsl:text>]</xsl:text>
|
| 593 |
+
</xsl:template>
|
| 594 |
+
|
| 595 |
+
<xsl:template match="lookaheads/symbol">
|
| 596 |
+
<xsl:value-of select="."/>
|
| 597 |
+
<xsl:if test="position() != last()">
|
| 598 |
+
<xsl:text>, </xsl:text>
|
| 599 |
+
</xsl:if>
|
| 600 |
+
</xsl:template>
|
| 601 |
+
|
| 602 |
+
<xsl:template match="transition">
|
| 603 |
+
<xsl:param name="pad"/>
|
| 604 |
+
<xsl:text> </xsl:text>
|
| 605 |
+
<xsl:call-template name="rpad">
|
| 606 |
+
<xsl:with-param name="str" select="string(@symbol)"/>
|
| 607 |
+
<xsl:with-param name="pad" select="number($pad) + 2"/>
|
| 608 |
+
</xsl:call-template>
|
| 609 |
+
<xsl:choose>
|
| 610 |
+
<xsl:when test="@type = 'shift'">
|
| 611 |
+
<a>
|
| 612 |
+
<xsl:attribute name="href">
|
| 613 |
+
<xsl:value-of select="concat('#state_', @state)"/>
|
| 614 |
+
</xsl:attribute>
|
| 615 |
+
<xsl:value-of select="concat('shift, and go to state ', @state)"/>
|
| 616 |
+
</a>
|
| 617 |
+
</xsl:when>
|
| 618 |
+
<xsl:when test="@type = 'goto'">
|
| 619 |
+
<a>
|
| 620 |
+
<xsl:attribute name="href">
|
| 621 |
+
<xsl:value-of select="concat('#state_', @state)"/>
|
| 622 |
+
</xsl:attribute>
|
| 623 |
+
<xsl:value-of select="concat('go to state ', @state)"/>
|
| 624 |
+
</a>
|
| 625 |
+
</xsl:when>
|
| 626 |
+
</xsl:choose>
|
| 627 |
+
<xsl:text> </xsl:text>
|
| 628 |
+
</xsl:template>
|
| 629 |
+
|
| 630 |
+
<xsl:template match="error">
|
| 631 |
+
<xsl:param name="pad"/>
|
| 632 |
+
<xsl:text> </xsl:text>
|
| 633 |
+
<xsl:call-template name="rpad">
|
| 634 |
+
<xsl:with-param name="str" select="string(@symbol)"/>
|
| 635 |
+
<xsl:with-param name="pad" select="number($pad) + 2"/>
|
| 636 |
+
</xsl:call-template>
|
| 637 |
+
<xsl:text>error</xsl:text>
|
| 638 |
+
<xsl:text> (</xsl:text>
|
| 639 |
+
<xsl:value-of select="text()"/>
|
| 640 |
+
<xsl:text>)</xsl:text>
|
| 641 |
+
<xsl:text> </xsl:text>
|
| 642 |
+
</xsl:template>
|
| 643 |
+
|
| 644 |
+
<xsl:template match="reduction">
|
| 645 |
+
<xsl:param name="pad"/>
|
| 646 |
+
<xsl:text> </xsl:text>
|
| 647 |
+
<xsl:call-template name="rpad">
|
| 648 |
+
<xsl:with-param name="str" select="string(@symbol)"/>
|
| 649 |
+
<xsl:with-param name="pad" select="number($pad) + 2"/>
|
| 650 |
+
</xsl:call-template>
|
| 651 |
+
<xsl:if test="@enabled = 'false'">
|
| 652 |
+
<xsl:text>[</xsl:text>
|
| 653 |
+
</xsl:if>
|
| 654 |
+
<xsl:choose>
|
| 655 |
+
<xsl:when test="@rule = 'accept'">
|
| 656 |
+
<xsl:text>accept</xsl:text>
|
| 657 |
+
</xsl:when>
|
| 658 |
+
<xsl:otherwise>
|
| 659 |
+
<a>
|
| 660 |
+
<xsl:attribute name="href">
|
| 661 |
+
<xsl:value-of select="concat('#rule_', @rule)"/>
|
| 662 |
+
</xsl:attribute>
|
| 663 |
+
<xsl:value-of select="concat('reduce using rule ', @rule)"/>
|
| 664 |
+
</a>
|
| 665 |
+
<xsl:text> (</xsl:text>
|
| 666 |
+
<xsl:value-of
|
| 667 |
+
select="key('bison:ruleByNumber', current()/@rule)/lhs[text()]"
|
| 668 |
+
/>
|
| 669 |
+
<xsl:text>)</xsl:text>
|
| 670 |
+
</xsl:otherwise>
|
| 671 |
+
</xsl:choose>
|
| 672 |
+
<xsl:if test="@enabled = 'false'">
|
| 673 |
+
<xsl:text>]</xsl:text>
|
| 674 |
+
</xsl:if>
|
| 675 |
+
<xsl:text> </xsl:text>
|
| 676 |
+
</xsl:template>
|
| 677 |
+
|
| 678 |
+
<xsl:template match="solved-conflicts">
|
| 679 |
+
<xsl:if test="resolution">
|
| 680 |
+
<xsl:text> </xsl:text>
|
| 681 |
+
<xsl:apply-templates select="resolution"/>
|
| 682 |
+
</xsl:if>
|
| 683 |
+
</xsl:template>
|
| 684 |
+
|
| 685 |
+
<xsl:template match="resolution">
|
| 686 |
+
<xsl:text> Conflict between </xsl:text>
|
| 687 |
+
<a>
|
| 688 |
+
<xsl:attribute name="href">
|
| 689 |
+
<xsl:value-of select="concat('#rule_', @rule)"/>
|
| 690 |
+
</xsl:attribute>
|
| 691 |
+
<xsl:value-of select="concat('rule ',@rule)"/>
|
| 692 |
+
</a>
|
| 693 |
+
<xsl:text> and token </xsl:text>
|
| 694 |
+
<xsl:value-of select="@symbol"/>
|
| 695 |
+
<xsl:text> resolved as </xsl:text>
|
| 696 |
+
<xsl:if test="@type = 'error'">
|
| 697 |
+
<xsl:text>an </xsl:text>
|
| 698 |
+
</xsl:if>
|
| 699 |
+
<xsl:value-of select="@type"/>
|
| 700 |
+
<xsl:text> (</xsl:text>
|
| 701 |
+
<xsl:value-of select="."/>
|
| 702 |
+
<xsl:text>). </xsl:text>
|
| 703 |
+
</xsl:template>
|
| 704 |
+
|
| 705 |
+
<xsl:template name="max-width-symbol">
|
| 706 |
+
<xsl:param name="node"/>
|
| 707 |
+
<xsl:variable name="longest">
|
| 708 |
+
<xsl:for-each select="$node">
|
| 709 |
+
<xsl:sort data-type="number" select="string-length(@symbol)"
|
| 710 |
+
order="descending"/>
|
| 711 |
+
<xsl:if test="position() = 1">
|
| 712 |
+
<xsl:value-of select="string-length(@symbol)"/>
|
| 713 |
+
</xsl:if>
|
| 714 |
+
</xsl:for-each>
|
| 715 |
+
</xsl:variable>
|
| 716 |
+
<xsl:value-of select="$longest"/>
|
| 717 |
+
</xsl:template>
|
| 718 |
+
|
| 719 |
+
<xsl:template name="lpad">
|
| 720 |
+
<xsl:param name="str" select="''"/>
|
| 721 |
+
<xsl:param name="pad" select="0"/>
|
| 722 |
+
<xsl:variable name="diff" select="$pad - string-length($str)" />
|
| 723 |
+
<xsl:choose>
|
| 724 |
+
<xsl:when test="$diff < 0">
|
| 725 |
+
<xsl:value-of select="$str"/>
|
| 726 |
+
</xsl:when>
|
| 727 |
+
<xsl:otherwise>
|
| 728 |
+
<xsl:call-template name="space">
|
| 729 |
+
<xsl:with-param name="repeat" select="$diff"/>
|
| 730 |
+
</xsl:call-template>
|
| 731 |
+
<xsl:value-of select="$str"/>
|
| 732 |
+
</xsl:otherwise>
|
| 733 |
+
</xsl:choose>
|
| 734 |
+
</xsl:template>
|
| 735 |
+
|
| 736 |
+
<xsl:template name="rpad">
|
| 737 |
+
<xsl:param name="str" select="''"/>
|
| 738 |
+
<xsl:param name="pad" select="0"/>
|
| 739 |
+
<xsl:variable name="diff" select="$pad - string-length($str)"/>
|
| 740 |
+
<xsl:choose>
|
| 741 |
+
<xsl:when test="$diff < 0">
|
| 742 |
+
<xsl:value-of select="$str"/>
|
| 743 |
+
</xsl:when>
|
| 744 |
+
<xsl:otherwise>
|
| 745 |
+
<xsl:value-of select="$str"/>
|
| 746 |
+
<xsl:call-template name="space">
|
| 747 |
+
<xsl:with-param name="repeat" select="$diff"/>
|
| 748 |
+
</xsl:call-template>
|
| 749 |
+
</xsl:otherwise>
|
| 750 |
+
</xsl:choose>
|
| 751 |
+
</xsl:template>
|
| 752 |
+
|
| 753 |
+
<xsl:template name="space">
|
| 754 |
+
<xsl:param name="repeat">0</xsl:param>
|
| 755 |
+
<xsl:param name="fill" select="' '"/>
|
| 756 |
+
<xsl:if test="number($repeat) >= 1">
|
| 757 |
+
<xsl:call-template name="space">
|
| 758 |
+
<xsl:with-param name="repeat" select="$repeat - 1"/>
|
| 759 |
+
<xsl:with-param name="fill" select="$fill"/>
|
| 760 |
+
</xsl:call-template>
|
| 761 |
+
<xsl:value-of select="$fill"/>
|
| 762 |
+
</xsl:if>
|
| 763 |
+
</xsl:template>
|
| 764 |
+
|
| 765 |
+
</xsl:stylesheet>
|
platform/dbops/binaries/build/share/doc/bison/AUTHORS
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Authors of GNU Bison.
|
| 2 |
+
|
| 3 |
+
Bison was written primarily by Robert Corbett.
|
| 4 |
+
|
| 5 |
+
Richard Stallman made it Yacc-compatible.
|
| 6 |
+
|
| 7 |
+
Wilfred Hansen of Carnegie Mellon University added multicharacter
|
| 8 |
+
string literals and other features (Bison 1.25, 1995).
|
| 9 |
+
|
| 10 |
+
Akim Demaille rewrote the parser in Bison, and changed the back end to
|
| 11 |
+
use M4 (1.50, 2002).
|
| 12 |
+
|
| 13 |
+
Paul Hilfinger added GLR support (Bison 1.50, 2002).
|
| 14 |
+
|
| 15 |
+
Joel E. Denny contributed canonical-LR support, and invented and added
|
| 16 |
+
IELR and LAC (Lookahead Correction) support (Bison 2.5, 2011).
|
| 17 |
+
|
| 18 |
+
Paolo Bonzini contributed Java support (Bison 2.4, 2008).
|
| 19 |
+
|
| 20 |
+
Alex Rozenman added named reference support (Bison 2.5, 2011).
|
| 21 |
+
|
| 22 |
+
Paul Eggert fixed a million portability issues, arbitrary limitations,
|
| 23 |
+
and nasty bugs.
|
| 24 |
+
|
| 25 |
+
-----
|
| 26 |
+
|
| 27 |
+
Copyright (C) 1998-2015, 2018-2021 Free Software Foundation, Inc.
|
| 28 |
+
|
| 29 |
+
This file is part of Bison, the GNU Compiler Compiler.
|
| 30 |
+
|
| 31 |
+
This program is free software: you can redistribute it and/or modify
|
| 32 |
+
it under the terms of the GNU General Public License as published by
|
| 33 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 34 |
+
(at your option) any later version.
|
| 35 |
+
|
| 36 |
+
This program is distributed in the hope that it will be useful,
|
| 37 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 38 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 39 |
+
GNU General Public License for more details.
|
| 40 |
+
|
| 41 |
+
You should have received a copy of the GNU General Public License
|
| 42 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
platform/dbops/binaries/build/share/doc/bison/COPYING
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
GNU GENERAL PUBLIC LICENSE
|
| 2 |
+
Version 3, 29 June 2007
|
| 3 |
+
|
| 4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
| 5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
| 6 |
+
of this license document, but changing it is not allowed.
|
| 7 |
+
|
| 8 |
+
Preamble
|
| 9 |
+
|
| 10 |
+
The GNU General Public License is a free, copyleft license for
|
| 11 |
+
software and other kinds of works.
|
| 12 |
+
|
| 13 |
+
The licenses for most software and other practical works are designed
|
| 14 |
+
to take away your freedom to share and change the works. By contrast,
|
| 15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
| 16 |
+
share and change all versions of a program--to make sure it remains free
|
| 17 |
+
software for all its users. We, the Free Software Foundation, use the
|
| 18 |
+
GNU General Public License for most of our software; it applies also to
|
| 19 |
+
any other work released this way by its authors. You can apply it to
|
| 20 |
+
your programs, too.
|
| 21 |
+
|
| 22 |
+
When we speak of free software, we are referring to freedom, not
|
| 23 |
+
price. Our General Public Licenses are designed to make sure that you
|
| 24 |
+
have the freedom to distribute copies of free software (and charge for
|
| 25 |
+
them if you wish), that you receive source code or can get it if you
|
| 26 |
+
want it, that you can change the software or use pieces of it in new
|
| 27 |
+
free programs, and that you know you can do these things.
|
| 28 |
+
|
| 29 |
+
To protect your rights, we need to prevent others from denying you
|
| 30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
| 31 |
+
certain responsibilities if you distribute copies of the software, or if
|
| 32 |
+
you modify it: responsibilities to respect the freedom of others.
|
| 33 |
+
|
| 34 |
+
For example, if you distribute copies of such a program, whether
|
| 35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
| 36 |
+
freedoms that you received. You must make sure that they, too, receive
|
| 37 |
+
or can get the source code. And you must show them these terms so they
|
| 38 |
+
know their rights.
|
| 39 |
+
|
| 40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
| 41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
| 42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
| 43 |
+
|
| 44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
| 45 |
+
that there is no warranty for this free software. For both users' and
|
| 46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
| 47 |
+
changed, so that their problems will not be attributed erroneously to
|
| 48 |
+
authors of previous versions.
|
| 49 |
+
|
| 50 |
+
Some devices are designed to deny users access to install or run
|
| 51 |
+
modified versions of the software inside them, although the manufacturer
|
| 52 |
+
can do so. This is fundamentally incompatible with the aim of
|
| 53 |
+
protecting users' freedom to change the software. The systematic
|
| 54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
| 55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
| 56 |
+
have designed this version of the GPL to prohibit the practice for those
|
| 57 |
+
products. If such problems arise substantially in other domains, we
|
| 58 |
+
stand ready to extend this provision to those domains in future versions
|
| 59 |
+
of the GPL, as needed to protect the freedom of users.
|
| 60 |
+
|
| 61 |
+
Finally, every program is threatened constantly by software patents.
|
| 62 |
+
States should not allow patents to restrict development and use of
|
| 63 |
+
software on general-purpose computers, but in those that do, we wish to
|
| 64 |
+
avoid the special danger that patents applied to a free program could
|
| 65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
| 66 |
+
patents cannot be used to render the program non-free.
|
| 67 |
+
|
| 68 |
+
The precise terms and conditions for copying, distribution and
|
| 69 |
+
modification follow.
|
| 70 |
+
|
| 71 |
+
TERMS AND CONDITIONS
|
| 72 |
+
|
| 73 |
+
0. Definitions.
|
| 74 |
+
|
| 75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
| 76 |
+
|
| 77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
| 78 |
+
works, such as semiconductor masks.
|
| 79 |
+
|
| 80 |
+
"The Program" refers to any copyrightable work licensed under this
|
| 81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
| 82 |
+
"recipients" may be individuals or organizations.
|
| 83 |
+
|
| 84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
| 85 |
+
in a fashion requiring copyright permission, other than the making of an
|
| 86 |
+
exact copy. The resulting work is called a "modified version" of the
|
| 87 |
+
earlier work or a work "based on" the earlier work.
|
| 88 |
+
|
| 89 |
+
A "covered work" means either the unmodified Program or a work based
|
| 90 |
+
on the Program.
|
| 91 |
+
|
| 92 |
+
To "propagate" a work means to do anything with it that, without
|
| 93 |
+
permission, would make you directly or secondarily liable for
|
| 94 |
+
infringement under applicable copyright law, except executing it on a
|
| 95 |
+
computer or modifying a private copy. Propagation includes copying,
|
| 96 |
+
distribution (with or without modification), making available to the
|
| 97 |
+
public, and in some countries other activities as well.
|
| 98 |
+
|
| 99 |
+
To "convey" a work means any kind of propagation that enables other
|
| 100 |
+
parties to make or receive copies. Mere interaction with a user through
|
| 101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
| 102 |
+
|
| 103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
| 104 |
+
to the extent that it includes a convenient and prominently visible
|
| 105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
| 106 |
+
tells the user that there is no warranty for the work (except to the
|
| 107 |
+
extent that warranties are provided), that licensees may convey the
|
| 108 |
+
work under this License, and how to view a copy of this License. If
|
| 109 |
+
the interface presents a list of user commands or options, such as a
|
| 110 |
+
menu, a prominent item in the list meets this criterion.
|
| 111 |
+
|
| 112 |
+
1. Source Code.
|
| 113 |
+
|
| 114 |
+
The "source code" for a work means the preferred form of the work
|
| 115 |
+
for making modifications to it. "Object code" means any non-source
|
| 116 |
+
form of a work.
|
| 117 |
+
|
| 118 |
+
A "Standard Interface" means an interface that either is an official
|
| 119 |
+
standard defined by a recognized standards body, or, in the case of
|
| 120 |
+
interfaces specified for a particular programming language, one that
|
| 121 |
+
is widely used among developers working in that language.
|
| 122 |
+
|
| 123 |
+
The "System Libraries" of an executable work include anything, other
|
| 124 |
+
than the work as a whole, that (a) is included in the normal form of
|
| 125 |
+
packaging a Major Component, but which is not part of that Major
|
| 126 |
+
Component, and (b) serves only to enable use of the work with that
|
| 127 |
+
Major Component, or to implement a Standard Interface for which an
|
| 128 |
+
implementation is available to the public in source code form. A
|
| 129 |
+
"Major Component", in this context, means a major essential component
|
| 130 |
+
(kernel, window system, and so on) of the specific operating system
|
| 131 |
+
(if any) on which the executable work runs, or a compiler used to
|
| 132 |
+
produce the work, or an object code interpreter used to run it.
|
| 133 |
+
|
| 134 |
+
The "Corresponding Source" for a work in object code form means all
|
| 135 |
+
the source code needed to generate, install, and (for an executable
|
| 136 |
+
work) run the object code and to modify the work, including scripts to
|
| 137 |
+
control those activities. However, it does not include the work's
|
| 138 |
+
System Libraries, or general-purpose tools or generally available free
|
| 139 |
+
programs which are used unmodified in performing those activities but
|
| 140 |
+
which are not part of the work. For example, Corresponding Source
|
| 141 |
+
includes interface definition files associated with source files for
|
| 142 |
+
the work, and the source code for shared libraries and dynamically
|
| 143 |
+
linked subprograms that the work is specifically designed to require,
|
| 144 |
+
such as by intimate data communication or control flow between those
|
| 145 |
+
subprograms and other parts of the work.
|
| 146 |
+
|
| 147 |
+
The Corresponding Source need not include anything that users
|
| 148 |
+
can regenerate automatically from other parts of the Corresponding
|
| 149 |
+
Source.
|
| 150 |
+
|
| 151 |
+
The Corresponding Source for a work in source code form is that
|
| 152 |
+
same work.
|
| 153 |
+
|
| 154 |
+
2. Basic Permissions.
|
| 155 |
+
|
| 156 |
+
All rights granted under this License are granted for the term of
|
| 157 |
+
copyright on the Program, and are irrevocable provided the stated
|
| 158 |
+
conditions are met. This License explicitly affirms your unlimited
|
| 159 |
+
permission to run the unmodified Program. The output from running a
|
| 160 |
+
covered work is covered by this License only if the output, given its
|
| 161 |
+
content, constitutes a covered work. This License acknowledges your
|
| 162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
| 163 |
+
|
| 164 |
+
You may make, run and propagate covered works that you do not
|
| 165 |
+
convey, without conditions so long as your license otherwise remains
|
| 166 |
+
in force. You may convey covered works to others for the sole purpose
|
| 167 |
+
of having them make modifications exclusively for you, or provide you
|
| 168 |
+
with facilities for running those works, provided that you comply with
|
| 169 |
+
the terms of this License in conveying all material for which you do
|
| 170 |
+
not control copyright. Those thus making or running the covered works
|
| 171 |
+
for you must do so exclusively on your behalf, under your direction
|
| 172 |
+
and control, on terms that prohibit them from making any copies of
|
| 173 |
+
your copyrighted material outside their relationship with you.
|
| 174 |
+
|
| 175 |
+
Conveying under any other circumstances is permitted solely under
|
| 176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
| 177 |
+
makes it unnecessary.
|
| 178 |
+
|
| 179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
| 180 |
+
|
| 181 |
+
No covered work shall be deemed part of an effective technological
|
| 182 |
+
measure under any applicable law fulfilling obligations under article
|
| 183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
| 184 |
+
similar laws prohibiting or restricting circumvention of such
|
| 185 |
+
measures.
|
| 186 |
+
|
| 187 |
+
When you convey a covered work, you waive any legal power to forbid
|
| 188 |
+
circumvention of technological measures to the extent such circumvention
|
| 189 |
+
is effected by exercising rights under this License with respect to
|
| 190 |
+
the covered work, and you disclaim any intention to limit operation or
|
| 191 |
+
modification of the work as a means of enforcing, against the work's
|
| 192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
| 193 |
+
technological measures.
|
| 194 |
+
|
| 195 |
+
4. Conveying Verbatim Copies.
|
| 196 |
+
|
| 197 |
+
You may convey verbatim copies of the Program's source code as you
|
| 198 |
+
receive it, in any medium, provided that you conspicuously and
|
| 199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
| 200 |
+
keep intact all notices stating that this License and any
|
| 201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
| 202 |
+
keep intact all notices of the absence of any warranty; and give all
|
| 203 |
+
recipients a copy of this License along with the Program.
|
| 204 |
+
|
| 205 |
+
You may charge any price or no price for each copy that you convey,
|
| 206 |
+
and you may offer support or warranty protection for a fee.
|
| 207 |
+
|
| 208 |
+
5. Conveying Modified Source Versions.
|
| 209 |
+
|
| 210 |
+
You may convey a work based on the Program, or the modifications to
|
| 211 |
+
produce it from the Program, in the form of source code under the
|
| 212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
| 213 |
+
|
| 214 |
+
a) The work must carry prominent notices stating that you modified
|
| 215 |
+
it, and giving a relevant date.
|
| 216 |
+
|
| 217 |
+
b) The work must carry prominent notices stating that it is
|
| 218 |
+
released under this License and any conditions added under section
|
| 219 |
+
7. This requirement modifies the requirement in section 4 to
|
| 220 |
+
"keep intact all notices".
|
| 221 |
+
|
| 222 |
+
c) You must license the entire work, as a whole, under this
|
| 223 |
+
License to anyone who comes into possession of a copy. This
|
| 224 |
+
License will therefore apply, along with any applicable section 7
|
| 225 |
+
additional terms, to the whole of the work, and all its parts,
|
| 226 |
+
regardless of how they are packaged. This License gives no
|
| 227 |
+
permission to license the work in any other way, but it does not
|
| 228 |
+
invalidate such permission if you have separately received it.
|
| 229 |
+
|
| 230 |
+
d) If the work has interactive user interfaces, each must display
|
| 231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
| 232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
| 233 |
+
work need not make them do so.
|
| 234 |
+
|
| 235 |
+
A compilation of a covered work with other separate and independent
|
| 236 |
+
works, which are not by their nature extensions of the covered work,
|
| 237 |
+
and which are not combined with it such as to form a larger program,
|
| 238 |
+
in or on a volume of a storage or distribution medium, is called an
|
| 239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
| 240 |
+
used to limit the access or legal rights of the compilation's users
|
| 241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
| 242 |
+
in an aggregate does not cause this License to apply to the other
|
| 243 |
+
parts of the aggregate.
|
| 244 |
+
|
| 245 |
+
6. Conveying Non-Source Forms.
|
| 246 |
+
|
| 247 |
+
You may convey a covered work in object code form under the terms
|
| 248 |
+
of sections 4 and 5, provided that you also convey the
|
| 249 |
+
machine-readable Corresponding Source under the terms of this License,
|
| 250 |
+
in one of these ways:
|
| 251 |
+
|
| 252 |
+
a) Convey the object code in, or embodied in, a physical product
|
| 253 |
+
(including a physical distribution medium), accompanied by the
|
| 254 |
+
Corresponding Source fixed on a durable physical medium
|
| 255 |
+
customarily used for software interchange.
|
| 256 |
+
|
| 257 |
+
b) Convey the object code in, or embodied in, a physical product
|
| 258 |
+
(including a physical distribution medium), accompanied by a
|
| 259 |
+
written offer, valid for at least three years and valid for as
|
| 260 |
+
long as you offer spare parts or customer support for that product
|
| 261 |
+
model, to give anyone who possesses the object code either (1) a
|
| 262 |
+
copy of the Corresponding Source for all the software in the
|
| 263 |
+
product that is covered by this License, on a durable physical
|
| 264 |
+
medium customarily used for software interchange, for a price no
|
| 265 |
+
more than your reasonable cost of physically performing this
|
| 266 |
+
conveying of source, or (2) access to copy the
|
| 267 |
+
Corresponding Source from a network server at no charge.
|
| 268 |
+
|
| 269 |
+
c) Convey individual copies of the object code with a copy of the
|
| 270 |
+
written offer to provide the Corresponding Source. This
|
| 271 |
+
alternative is allowed only occasionally and noncommercially, and
|
| 272 |
+
only if you received the object code with such an offer, in accord
|
| 273 |
+
with subsection 6b.
|
| 274 |
+
|
| 275 |
+
d) Convey the object code by offering access from a designated
|
| 276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
| 277 |
+
Corresponding Source in the same way through the same place at no
|
| 278 |
+
further charge. You need not require recipients to copy the
|
| 279 |
+
Corresponding Source along with the object code. If the place to
|
| 280 |
+
copy the object code is a network server, the Corresponding Source
|
| 281 |
+
may be on a different server (operated by you or a third party)
|
| 282 |
+
that supports equivalent copying facilities, provided you maintain
|
| 283 |
+
clear directions next to the object code saying where to find the
|
| 284 |
+
Corresponding Source. Regardless of what server hosts the
|
| 285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
| 286 |
+
available for as long as needed to satisfy these requirements.
|
| 287 |
+
|
| 288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
| 289 |
+
you inform other peers where the object code and Corresponding
|
| 290 |
+
Source of the work are being offered to the general public at no
|
| 291 |
+
charge under subsection 6d.
|
| 292 |
+
|
| 293 |
+
A separable portion of the object code, whose source code is excluded
|
| 294 |
+
from the Corresponding Source as a System Library, need not be
|
| 295 |
+
included in conveying the object code work.
|
| 296 |
+
|
| 297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
| 298 |
+
tangible personal property which is normally used for personal, family,
|
| 299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
| 300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
| 301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
| 302 |
+
product received by a particular user, "normally used" refers to a
|
| 303 |
+
typical or common use of that class of product, regardless of the status
|
| 304 |
+
of the particular user or of the way in which the particular user
|
| 305 |
+
actually uses, or expects or is expected to use, the product. A product
|
| 306 |
+
is a consumer product regardless of whether the product has substantial
|
| 307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
| 308 |
+
the only significant mode of use of the product.
|
| 309 |
+
|
| 310 |
+
"Installation Information" for a User Product means any methods,
|
| 311 |
+
procedures, authorization keys, or other information required to install
|
| 312 |
+
and execute modified versions of a covered work in that User Product from
|
| 313 |
+
a modified version of its Corresponding Source. The information must
|
| 314 |
+
suffice to ensure that the continued functioning of the modified object
|
| 315 |
+
code is in no case prevented or interfered with solely because
|
| 316 |
+
modification has been made.
|
| 317 |
+
|
| 318 |
+
If you convey an object code work under this section in, or with, or
|
| 319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
| 320 |
+
part of a transaction in which the right of possession and use of the
|
| 321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
| 322 |
+
fixed term (regardless of how the transaction is characterized), the
|
| 323 |
+
Corresponding Source conveyed under this section must be accompanied
|
| 324 |
+
by the Installation Information. But this requirement does not apply
|
| 325 |
+
if neither you nor any third party retains the ability to install
|
| 326 |
+
modified object code on the User Product (for example, the work has
|
| 327 |
+
been installed in ROM).
|
| 328 |
+
|
| 329 |
+
The requirement to provide Installation Information does not include a
|
| 330 |
+
requirement to continue to provide support service, warranty, or updates
|
| 331 |
+
for a work that has been modified or installed by the recipient, or for
|
| 332 |
+
the User Product in which it has been modified or installed. Access to a
|
| 333 |
+
network may be denied when the modification itself materially and
|
| 334 |
+
adversely affects the operation of the network or violates the rules and
|
| 335 |
+
protocols for communication across the network.
|
| 336 |
+
|
| 337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
| 338 |
+
in accord with this section must be in a format that is publicly
|
| 339 |
+
documented (and with an implementation available to the public in
|
| 340 |
+
source code form), and must require no special password or key for
|
| 341 |
+
unpacking, reading or copying.
|
| 342 |
+
|
| 343 |
+
7. Additional Terms.
|
| 344 |
+
|
| 345 |
+
"Additional permissions" are terms that supplement the terms of this
|
| 346 |
+
License by making exceptions from one or more of its conditions.
|
| 347 |
+
Additional permissions that are applicable to the entire Program shall
|
| 348 |
+
be treated as though they were included in this License, to the extent
|
| 349 |
+
that they are valid under applicable law. If additional permissions
|
| 350 |
+
apply only to part of the Program, that part may be used separately
|
| 351 |
+
under those permissions, but the entire Program remains governed by
|
| 352 |
+
this License without regard to the additional permissions.
|
| 353 |
+
|
| 354 |
+
When you convey a copy of a covered work, you may at your option
|
| 355 |
+
remove any additional permissions from that copy, or from any part of
|
| 356 |
+
it. (Additional permissions may be written to require their own
|
| 357 |
+
removal in certain cases when you modify the work.) You may place
|
| 358 |
+
additional permissions on material, added by you to a covered work,
|
| 359 |
+
for which you have or can give appropriate copyright permission.
|
| 360 |
+
|
| 361 |
+
Notwithstanding any other provision of this License, for material you
|
| 362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
| 363 |
+
that material) supplement the terms of this License with terms:
|
| 364 |
+
|
| 365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
| 366 |
+
terms of sections 15 and 16 of this License; or
|
| 367 |
+
|
| 368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
| 369 |
+
author attributions in that material or in the Appropriate Legal
|
| 370 |
+
Notices displayed by works containing it; or
|
| 371 |
+
|
| 372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
| 373 |
+
requiring that modified versions of such material be marked in
|
| 374 |
+
reasonable ways as different from the original version; or
|
| 375 |
+
|
| 376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
| 377 |
+
authors of the material; or
|
| 378 |
+
|
| 379 |
+
e) Declining to grant rights under trademark law for use of some
|
| 380 |
+
trade names, trademarks, or service marks; or
|
| 381 |
+
|
| 382 |
+
f) Requiring indemnification of licensors and authors of that
|
| 383 |
+
material by anyone who conveys the material (or modified versions of
|
| 384 |
+
it) with contractual assumptions of liability to the recipient, for
|
| 385 |
+
any liability that these contractual assumptions directly impose on
|
| 386 |
+
those licensors and authors.
|
| 387 |
+
|
| 388 |
+
All other non-permissive additional terms are considered "further
|
| 389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
| 390 |
+
received it, or any part of it, contains a notice stating that it is
|
| 391 |
+
governed by this License along with a term that is a further
|
| 392 |
+
restriction, you may remove that term. If a license document contains
|
| 393 |
+
a further restriction but permits relicensing or conveying under this
|
| 394 |
+
License, you may add to a covered work material governed by the terms
|
| 395 |
+
of that license document, provided that the further restriction does
|
| 396 |
+
not survive such relicensing or conveying.
|
| 397 |
+
|
| 398 |
+
If you add terms to a covered work in accord with this section, you
|
| 399 |
+
must place, in the relevant source files, a statement of the
|
| 400 |
+
additional terms that apply to those files, or a notice indicating
|
| 401 |
+
where to find the applicable terms.
|
| 402 |
+
|
| 403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
| 404 |
+
form of a separately written license, or stated as exceptions;
|
| 405 |
+
the above requirements apply either way.
|
| 406 |
+
|
| 407 |
+
8. Termination.
|
| 408 |
+
|
| 409 |
+
You may not propagate or modify a covered work except as expressly
|
| 410 |
+
provided under this License. Any attempt otherwise to propagate or
|
| 411 |
+
modify it is void, and will automatically terminate your rights under
|
| 412 |
+
this License (including any patent licenses granted under the third
|
| 413 |
+
paragraph of section 11).
|
| 414 |
+
|
| 415 |
+
However, if you cease all violation of this License, then your
|
| 416 |
+
license from a particular copyright holder is reinstated (a)
|
| 417 |
+
provisionally, unless and until the copyright holder explicitly and
|
| 418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
| 419 |
+
holder fails to notify you of the violation by some reasonable means
|
| 420 |
+
prior to 60 days after the cessation.
|
| 421 |
+
|
| 422 |
+
Moreover, your license from a particular copyright holder is
|
| 423 |
+
reinstated permanently if the copyright holder notifies you of the
|
| 424 |
+
violation by some reasonable means, this is the first time you have
|
| 425 |
+
received notice of violation of this License (for any work) from that
|
| 426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
| 427 |
+
your receipt of the notice.
|
| 428 |
+
|
| 429 |
+
Termination of your rights under this section does not terminate the
|
| 430 |
+
licenses of parties who have received copies or rights from you under
|
| 431 |
+
this License. If your rights have been terminated and not permanently
|
| 432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
| 433 |
+
material under section 10.
|
| 434 |
+
|
| 435 |
+
9. Acceptance Not Required for Having Copies.
|
| 436 |
+
|
| 437 |
+
You are not required to accept this License in order to receive or
|
| 438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
| 439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
| 440 |
+
to receive a copy likewise does not require acceptance. However,
|
| 441 |
+
nothing other than this License grants you permission to propagate or
|
| 442 |
+
modify any covered work. These actions infringe copyright if you do
|
| 443 |
+
not accept this License. Therefore, by modifying or propagating a
|
| 444 |
+
covered work, you indicate your acceptance of this License to do so.
|
| 445 |
+
|
| 446 |
+
10. Automatic Licensing of Downstream Recipients.
|
| 447 |
+
|
| 448 |
+
Each time you convey a covered work, the recipient automatically
|
| 449 |
+
receives a license from the original licensors, to run, modify and
|
| 450 |
+
propagate that work, subject to this License. You are not responsible
|
| 451 |
+
for enforcing compliance by third parties with this License.
|
| 452 |
+
|
| 453 |
+
An "entity transaction" is a transaction transferring control of an
|
| 454 |
+
organization, or substantially all assets of one, or subdividing an
|
| 455 |
+
organization, or merging organizations. If propagation of a covered
|
| 456 |
+
work results from an entity transaction, each party to that
|
| 457 |
+
transaction who receives a copy of the work also receives whatever
|
| 458 |
+
licenses to the work the party's predecessor in interest had or could
|
| 459 |
+
give under the previous paragraph, plus a right to possession of the
|
| 460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
| 461 |
+
the predecessor has it or can get it with reasonable efforts.
|
| 462 |
+
|
| 463 |
+
You may not impose any further restrictions on the exercise of the
|
| 464 |
+
rights granted or affirmed under this License. For example, you may
|
| 465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
| 466 |
+
rights granted under this License, and you may not initiate litigation
|
| 467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
| 468 |
+
any patent claim is infringed by making, using, selling, offering for
|
| 469 |
+
sale, or importing the Program or any portion of it.
|
| 470 |
+
|
| 471 |
+
11. Patents.
|
| 472 |
+
|
| 473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
| 474 |
+
License of the Program or a work on which the Program is based. The
|
| 475 |
+
work thus licensed is called the contributor's "contributor version".
|
| 476 |
+
|
| 477 |
+
A contributor's "essential patent claims" are all patent claims
|
| 478 |
+
owned or controlled by the contributor, whether already acquired or
|
| 479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
| 480 |
+
by this License, of making, using, or selling its contributor version,
|
| 481 |
+
but do not include claims that would be infringed only as a
|
| 482 |
+
consequence of further modification of the contributor version. For
|
| 483 |
+
purposes of this definition, "control" includes the right to grant
|
| 484 |
+
patent sublicenses in a manner consistent with the requirements of
|
| 485 |
+
this License.
|
| 486 |
+
|
| 487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
| 488 |
+
patent license under the contributor's essential patent claims, to
|
| 489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
| 490 |
+
propagate the contents of its contributor version.
|
| 491 |
+
|
| 492 |
+
In the following three paragraphs, a "patent license" is any express
|
| 493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
| 494 |
+
(such as an express permission to practice a patent or covenant not to
|
| 495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
| 496 |
+
party means to make such an agreement or commitment not to enforce a
|
| 497 |
+
patent against the party.
|
| 498 |
+
|
| 499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
| 500 |
+
and the Corresponding Source of the work is not available for anyone
|
| 501 |
+
to copy, free of charge and under the terms of this License, through a
|
| 502 |
+
publicly available network server or other readily accessible means,
|
| 503 |
+
then you must either (1) cause the Corresponding Source to be so
|
| 504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
| 505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
| 506 |
+
consistent with the requirements of this License, to extend the patent
|
| 507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
| 508 |
+
actual knowledge that, but for the patent license, your conveying the
|
| 509 |
+
covered work in a country, or your recipient's use of the covered work
|
| 510 |
+
in a country, would infringe one or more identifiable patents in that
|
| 511 |
+
country that you have reason to believe are valid.
|
| 512 |
+
|
| 513 |
+
If, pursuant to or in connection with a single transaction or
|
| 514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
| 515 |
+
covered work, and grant a patent license to some of the parties
|
| 516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
| 517 |
+
or convey a specific copy of the covered work, then the patent license
|
| 518 |
+
you grant is automatically extended to all recipients of the covered
|
| 519 |
+
work and works based on it.
|
| 520 |
+
|
| 521 |
+
A patent license is "discriminatory" if it does not include within
|
| 522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
| 523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
| 524 |
+
specifically granted under this License. You may not convey a covered
|
| 525 |
+
work if you are a party to an arrangement with a third party that is
|
| 526 |
+
in the business of distributing software, under which you make payment
|
| 527 |
+
to the third party based on the extent of your activity of conveying
|
| 528 |
+
the work, and under which the third party grants, to any of the
|
| 529 |
+
parties who would receive the covered work from you, a discriminatory
|
| 530 |
+
patent license (a) in connection with copies of the covered work
|
| 531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
| 532 |
+
for and in connection with specific products or compilations that
|
| 533 |
+
contain the covered work, unless you entered into that arrangement,
|
| 534 |
+
or that patent license was granted, prior to 28 March 2007.
|
| 535 |
+
|
| 536 |
+
Nothing in this License shall be construed as excluding or limiting
|
| 537 |
+
any implied license or other defenses to infringement that may
|
| 538 |
+
otherwise be available to you under applicable patent law.
|
| 539 |
+
|
| 540 |
+
12. No Surrender of Others' Freedom.
|
| 541 |
+
|
| 542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
| 543 |
+
otherwise) that contradict the conditions of this License, they do not
|
| 544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
| 545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
| 546 |
+
License and any other pertinent obligations, then as a consequence you may
|
| 547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
| 548 |
+
to collect a royalty for further conveying from those to whom you convey
|
| 549 |
+
the Program, the only way you could satisfy both those terms and this
|
| 550 |
+
License would be to refrain entirely from conveying the Program.
|
| 551 |
+
|
| 552 |
+
13. Use with the GNU Affero General Public License.
|
| 553 |
+
|
| 554 |
+
Notwithstanding any other provision of this License, you have
|
| 555 |
+
permission to link or combine any covered work with a work licensed
|
| 556 |
+
under version 3 of the GNU Affero General Public License into a single
|
| 557 |
+
combined work, and to convey the resulting work. The terms of this
|
| 558 |
+
License will continue to apply to the part which is the covered work,
|
| 559 |
+
but the special requirements of the GNU Affero General Public License,
|
| 560 |
+
section 13, concerning interaction through a network will apply to the
|
| 561 |
+
combination as such.
|
| 562 |
+
|
| 563 |
+
14. Revised Versions of this License.
|
| 564 |
+
|
| 565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
| 566 |
+
the GNU General Public License from time to time. Such new versions will
|
| 567 |
+
be similar in spirit to the present version, but may differ in detail to
|
| 568 |
+
address new problems or concerns.
|
| 569 |
+
|
| 570 |
+
Each version is given a distinguishing version number. If the
|
| 571 |
+
Program specifies that a certain numbered version of the GNU General
|
| 572 |
+
Public License "or any later version" applies to it, you have the
|
| 573 |
+
option of following the terms and conditions either of that numbered
|
| 574 |
+
version or of any later version published by the Free Software
|
| 575 |
+
Foundation. If the Program does not specify a version number of the
|
| 576 |
+
GNU General Public License, you may choose any version ever published
|
| 577 |
+
by the Free Software Foundation.
|
| 578 |
+
|
| 579 |
+
If the Program specifies that a proxy can decide which future
|
| 580 |
+
versions of the GNU General Public License can be used, that proxy's
|
| 581 |
+
public statement of acceptance of a version permanently authorizes you
|
| 582 |
+
to choose that version for the Program.
|
| 583 |
+
|
| 584 |
+
Later license versions may give you additional or different
|
| 585 |
+
permissions. However, no additional obligations are imposed on any
|
| 586 |
+
author or copyright holder as a result of your choosing to follow a
|
| 587 |
+
later version.
|
| 588 |
+
|
| 589 |
+
15. Disclaimer of Warranty.
|
| 590 |
+
|
| 591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
| 592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
| 593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
| 594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
| 595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
| 596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
| 597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
| 598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
| 599 |
+
|
| 600 |
+
16. Limitation of Liability.
|
| 601 |
+
|
| 602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
| 603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
| 604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
| 605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
| 606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
| 607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
| 608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
| 609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
| 610 |
+
SUCH DAMAGES.
|
| 611 |
+
|
| 612 |
+
17. Interpretation of Sections 15 and 16.
|
| 613 |
+
|
| 614 |
+
If the disclaimer of warranty and limitation of liability provided
|
| 615 |
+
above cannot be given local legal effect according to their terms,
|
| 616 |
+
reviewing courts shall apply local law that most closely approximates
|
| 617 |
+
an absolute waiver of all civil liability in connection with the
|
| 618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
| 619 |
+
copy of the Program in return for a fee.
|
| 620 |
+
|
| 621 |
+
END OF TERMS AND CONDITIONS
|
| 622 |
+
|
| 623 |
+
How to Apply These Terms to Your New Programs
|
| 624 |
+
|
| 625 |
+
If you develop a new program, and you want it to be of the greatest
|
| 626 |
+
possible use to the public, the best way to achieve this is to make it
|
| 627 |
+
free software which everyone can redistribute and change under these terms.
|
| 628 |
+
|
| 629 |
+
To do so, attach the following notices to the program. It is safest
|
| 630 |
+
to attach them to the start of each source file to most effectively
|
| 631 |
+
state the exclusion of warranty; and each file should have at least
|
| 632 |
+
the "copyright" line and a pointer to where the full notice is found.
|
| 633 |
+
|
| 634 |
+
<one line to give the program's name and a brief idea of what it does.>
|
| 635 |
+
Copyright (C) <year> <name of author>
|
| 636 |
+
|
| 637 |
+
This program is free software: you can redistribute it and/or modify
|
| 638 |
+
it under the terms of the GNU General Public License as published by
|
| 639 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 640 |
+
(at your option) any later version.
|
| 641 |
+
|
| 642 |
+
This program is distributed in the hope that it will be useful,
|
| 643 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 644 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 645 |
+
GNU General Public License for more details.
|
| 646 |
+
|
| 647 |
+
You should have received a copy of the GNU General Public License
|
| 648 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 649 |
+
|
| 650 |
+
Also add information on how to contact you by electronic and paper mail.
|
| 651 |
+
|
| 652 |
+
If the program does terminal interaction, make it output a short
|
| 653 |
+
notice like this when it starts in an interactive mode:
|
| 654 |
+
|
| 655 |
+
<program> Copyright (C) <year> <name of author>
|
| 656 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
| 657 |
+
This is free software, and you are welcome to redistribute it
|
| 658 |
+
under certain conditions; type `show c' for details.
|
| 659 |
+
|
| 660 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
| 661 |
+
parts of the General Public License. Of course, your program's commands
|
| 662 |
+
might be different; for a GUI interface, you would use an "about box".
|
| 663 |
+
|
| 664 |
+
You should also get your employer (if you work as a programmer) or school,
|
| 665 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
| 666 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
| 667 |
+
<https://www.gnu.org/licenses/>.
|
| 668 |
+
|
| 669 |
+
The GNU General Public License does not permit incorporating your program
|
| 670 |
+
into proprietary programs. If your program is a subroutine library, you
|
| 671 |
+
may consider it more useful to permit linking proprietary applications with
|
| 672 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
| 673 |
+
Public License instead of this License. But first, please read
|
| 674 |
+
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
platform/dbops/binaries/build/share/doc/bison/NEWS
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
platform/dbops/binaries/build/share/doc/bison/README
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
GNU Bison is a general-purpose parser generator that converts an annotated
|
| 2 |
+
context-free grammar into a deterministic LR or generalized LR (GLR) parser
|
| 3 |
+
employing LALR(1) parser tables. Bison can also generate IELR(1) or
|
| 4 |
+
canonical LR(1) parser tables. Once you are proficient with Bison, you can
|
| 5 |
+
use it to develop a wide range of language parsers, from those used in
|
| 6 |
+
simple desk calculators to complex programming languages.
|
| 7 |
+
|
| 8 |
+
Bison is upward compatible with Yacc: all properly-written Yacc grammars
|
| 9 |
+
work with Bison with no change. Anyone familiar with Yacc should be able to
|
| 10 |
+
use Bison with little trouble. You need to be fluent in C, C++, D or Java
|
| 11 |
+
programming in order to use Bison.
|
| 12 |
+
|
| 13 |
+
Bison and the parsers it generates are portable, they do not require any
|
| 14 |
+
specific compilers.
|
| 15 |
+
|
| 16 |
+
GNU Bison's home page is https://gnu.org/software/bison/.
|
| 17 |
+
|
| 18 |
+
# Installation
|
| 19 |
+
## Build from git
|
| 20 |
+
The [README-hacking.md file](README-hacking.md) is about building, modifying
|
| 21 |
+
and checking Bison. See its "Working from the Repository" section to build
|
| 22 |
+
Bison from the git repo. Roughly, run:
|
| 23 |
+
|
| 24 |
+
$ git submodule update --init
|
| 25 |
+
$ ./bootstrap
|
| 26 |
+
|
| 27 |
+
then proceed with the usual `configure && make` steps.
|
| 28 |
+
|
| 29 |
+
## Build from tarball
|
| 30 |
+
See the [INSTALL file](INSTALL) for generic compilation and installation
|
| 31 |
+
instructions.
|
| 32 |
+
|
| 33 |
+
Bison requires GNU m4 1.4.6 or later. See
|
| 34 |
+
https://ftp.gnu.org/gnu/m4/m4-1.4.6.tar.gz.
|
| 35 |
+
|
| 36 |
+
## Running a non installed bison
|
| 37 |
+
Once you ran `make`, you might want to toy with this fresh bison before
|
| 38 |
+
installing it. In that case, do not use `src/bison`: it would use the
|
| 39 |
+
*installed* files (skeletons, etc.), not the local ones. Use `tests/bison`.
|
| 40 |
+
|
| 41 |
+
## Colored diagnostics
|
| 42 |
+
As an experimental feature, diagnostics are now colored, controlled by the
|
| 43 |
+
`--color` and `--style` options.
|
| 44 |
+
|
| 45 |
+
To use them, install the libtextstyle library, 0.20.5 or newer, before
|
| 46 |
+
configuring Bison. It is available from https://alpha.gnu.org/gnu/gettext/,
|
| 47 |
+
for instance https://alpha.gnu.org/gnu/gettext/libtextstyle-0.20.5.tar.gz,
|
| 48 |
+
or as part of Gettext 0.21 or newer, for instance
|
| 49 |
+
https://ftp.gnu.org/gnu/gettext/gettext-0.21.tar.gz.
|
| 50 |
+
|
| 51 |
+
The option --color supports the following arguments:
|
| 52 |
+
- always, yes: Enable colors.
|
| 53 |
+
- never, no: Disable colors.
|
| 54 |
+
- auto, tty (default): Enable colors if the output device is a tty.
|
| 55 |
+
|
| 56 |
+
To customize the styles, create a CSS file, say `bison-bw.css`, similar to
|
| 57 |
+
|
| 58 |
+
/* bison-bw.css */
|
| 59 |
+
.warning { }
|
| 60 |
+
.error { font-weight: 800; text-decoration: underline; }
|
| 61 |
+
.note { }
|
| 62 |
+
|
| 63 |
+
then invoke bison with `--style=bison-bw.css`, or set the `BISON_STYLE`
|
| 64 |
+
environment variable to `bison-bw.css`.
|
| 65 |
+
|
| 66 |
+
In some diagnostics, bison uses libtextstyle to emit special escapes to
|
| 67 |
+
generate clickable hyperlinks. The environment variable
|
| 68 |
+
`NO_TERM_HYPERLINKS` can be used to suppress them. This may be useful for
|
| 69 |
+
terminal emulators which produce garbage output when they receive the escape
|
| 70 |
+
sequence for a hyperlink. Currently (as of 2020), this affects some versions
|
| 71 |
+
of emacs, guake, konsole, lxterminal, rxvt, yakuake.
|
| 72 |
+
|
| 73 |
+
## Relocatability
|
| 74 |
+
If you pass `--enable-relocatable` to `configure`, Bison is relocatable.
|
| 75 |
+
|
| 76 |
+
A relocatable program can be moved or copied to a different location on the
|
| 77 |
+
file system. It can also be used through mount points for network sharing.
|
| 78 |
+
It is possible to make symlinks to the installed and moved programs, and
|
| 79 |
+
invoke them through the symlink.
|
| 80 |
+
|
| 81 |
+
See "Enabling Relocatability" in the documentation.
|
| 82 |
+
|
| 83 |
+
## Internationalization
|
| 84 |
+
Bison supports two catalogs: one for Bison itself (i.e., for the
|
| 85 |
+
maintainer-side parser generation), and one for the generated parsers (i.e.,
|
| 86 |
+
for the user-side parser execution). The requirements between both differ:
|
| 87 |
+
bison needs ngettext, the generated parsers do not. To simplify the build
|
| 88 |
+
system, neither are installed if ngettext is not supported, even if
|
| 89 |
+
generated parsers could have been localized. See
|
| 90 |
+
https://lists.gnu.org/r/bug-bison/2009-08/msg00006.html for more
|
| 91 |
+
details.
|
| 92 |
+
|
| 93 |
+
# Questions
|
| 94 |
+
See the section FAQ in the documentation (doc/bison.info) for frequently
|
| 95 |
+
asked questions. The documentation is also available in PDF and HTML,
|
| 96 |
+
provided you have a recent version of Texinfo installed: run `make pdf` or
|
| 97 |
+
`make html`.
|
| 98 |
+
|
| 99 |
+
If you have questions about using Bison and the documentation does not
|
| 100 |
+
answer them, please send mail to <help-bison@gnu.org>.
|
| 101 |
+
|
| 102 |
+
# Bug reports
|
| 103 |
+
Please send bug reports to <bug-bison@gnu.org>. Be sure to include the
|
| 104 |
+
version number from `bison --version`, and a complete, self-contained test
|
| 105 |
+
case in each bug report.
|
| 106 |
+
|
| 107 |
+
# Copyright statements
|
| 108 |
+
For any copyright year range specified as YYYY-ZZZZ in this package, note
|
| 109 |
+
that the range specifies every single year in that closed interval.
|
| 110 |
+
|
| 111 |
+
<!--
|
| 112 |
+
|
| 113 |
+
LocalWords: parsers ngettext Texinfo pdf html YYYY ZZZZ ispell american md
|
| 114 |
+
LocalWords: MERCHANTABILITY GLR LALR IELR submodule init README src bw
|
| 115 |
+
LocalWords: Relocatability symlinks symlink
|
| 116 |
+
|
| 117 |
+
Local Variables:
|
| 118 |
+
mode: markdown
|
| 119 |
+
fill-column: 76
|
| 120 |
+
ispell-dictionary: "american"
|
| 121 |
+
End:
|
| 122 |
+
|
| 123 |
+
Copyright (C) 1992, 1998-1999, 2003-2005, 2008-2015, 2018-2021 Free
|
| 124 |
+
Software Foundation, Inc.
|
| 125 |
+
|
| 126 |
+
This file is part of GNU bison, the GNU Compiler Compiler.
|
| 127 |
+
|
| 128 |
+
Permission is granted to copy, distribute and/or modify this document
|
| 129 |
+
under the terms of the GNU Free Documentation License, Version 1.3 or
|
| 130 |
+
any later version published by the Free Software Foundation; with no
|
| 131 |
+
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
| 132 |
+
Texts. A copy of the license is included in the "GNU Free
|
| 133 |
+
Documentation License" file as part of this distribution.
|
| 134 |
+
|
| 135 |
+
-->
|
platform/dbops/binaries/build/share/doc/bison/THANKS
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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3 |
+
|
| 4 |
+
Aaro Koskinen aaro.koskinen@iki.fi
|
| 5 |
+
Аскар Сафин safinaskar@mail.ru
|
| 6 |
+
Adam Sampson ats@offog.org
|
| 7 |
+
Adrian Vogelsgesang avogelsgesang@tableau.com
|
| 8 |
+
Ahcheong Lee dkcjd2000@gmail.com
|
| 9 |
+
Airy Andre Airy.Andre@edf.fr
|
| 10 |
+
Akim Demaille akim@gnu.org
|
| 11 |
+
Albert Chin-A-Young china@thewrittenword.com
|
| 12 |
+
Alexander Belopolsky alexb@rentec.com
|
| 13 |
+
Alexandre Duret-Lutz adl@lrde.epita.fr
|
| 14 |
+
Andre da Costa Barros andre.cbarros@yahoo.com
|
| 15 |
+
Andreas Damm adamm@onica.com
|
| 16 |
+
Andreas Schwab schwab@suse.de
|
| 17 |
+
Andrew Suffield asuffield@users.sourceforge.net
|
| 18 |
+
Angelo Borsotti angelo.borsotti@gmail.com
|
| 19 |
+
Anthony Heading ajrh@ajrh.net
|
| 20 |
+
Antonio Silva Correia amsilvacorreia@hotmail.com
|
| 21 |
+
Arnold Robbins arnold@skeeve.com
|
| 22 |
+
Art Haas ahaas@neosoft.com
|
| 23 |
+
Arthur Schwarz aschwarz1309@att.net
|
| 24 |
+
Askar Safin safinaskar@mail.ru
|
| 25 |
+
Balázs Scheidler balazs.scheidler@oneidentity.com
|
| 26 |
+
Baron Schwartz baron@sequent.org
|
| 27 |
+
Ben Pfaff blp@cs.stanford.edu
|
| 28 |
+
Benoit Perrot benoit.perrot@epita.fr
|
| 29 |
+
Bernd Edlinger bernd.edlinger@hotmail.de
|
| 30 |
+
Bernd Kiefer kiefer@dfki.de
|
| 31 |
+
Bert Deknuydt Bert.Deknuydt@esat.kuleuven.ac.be
|
| 32 |
+
Bill Allombert Bill.Allombert@math.u-bordeaux1.fr
|
| 33 |
+
Bob Rossi bob@brasko.net
|
| 34 |
+
Brandon Lucia blucia@gmail.com
|
| 35 |
+
Brooks Moses bmoses@google.com
|
| 36 |
+
Bruce Lilly blilly@erols.com
|
| 37 |
+
Bruno Belanyi bruno.belanyi@epita.fr
|
| 38 |
+
Bruno Haible bruno@clisp.org
|
| 39 |
+
Charles-Henri de Boysson de-boy_c@epita.fr
|
| 40 |
+
Christian Burger cburger@sunysb.edu
|
| 41 |
+
Clément Démoulins demoulins@lrde.epita.fr
|
| 42 |
+
Colin Daley colin.daley@outlook.com
|
| 43 |
+
Cris Bailiff c.bailiff+bison@awayweb.com
|
| 44 |
+
Cris van Pelt cris@amf03054.office.wxs.nl
|
| 45 |
+
Csaba Raduly csaba_22@yahoo.co.uk
|
| 46 |
+
Dagobert Michelsen dam@baltic-online.de
|
| 47 |
+
Daniel Frużyński daniel@poradnik-webmastera.com
|
| 48 |
+
Daniel Galloway dg1751@att.com
|
| 49 |
+
Daniela Becker daniela@lrde.epita.fr
|
| 50 |
+
Daniel Hagerty hag@gnu.org
|
| 51 |
+
David Barto david.barto@sparqlcity.com
|
| 52 |
+
David J. MacKenzie djm@gnu.org
|
| 53 |
+
David Kastrup dak@gnu.org
|
| 54 |
+
David Michael fedora.dm0@gmail.com
|
| 55 |
+
Dengke Du dengke.du@windriver.com
|
| 56 |
+
Denis Excoffier gcc@Denis-Excoffier.org
|
| 57 |
+
Dennis Clarke dclarke@blastwave.org
|
| 58 |
+
Derek Clegg derek@me.com
|
| 59 |
+
Derek M. Jones derek@knosof.co.uk
|
| 60 |
+
Di-an Jan dianj@freeshell.org
|
| 61 |
+
Dick Streefland dick.streefland@altium.nl
|
| 62 |
+
Didier Godefroy dg@ulysium.net
|
| 63 |
+
Don Macpherson donmac703@gmail.com
|
| 64 |
+
Dwight Guth dwight.guth@runtimeverification.com
|
| 65 |
+
Efi Fogel efifogel@gmail.com
|
| 66 |
+
Enrico Scholz enrico.scholz@informatik.tu-chemnitz.de
|
| 67 |
+
Eric Blake ebb9@byu.net
|
| 68 |
+
Eric S. Raymond esr@thyrsus.com
|
| 69 |
+
Étienne Renault renault@lrde.epita.fr
|
| 70 |
+
Evan Lavelle eml-bison@cyconix.com
|
| 71 |
+
Evan Nemerson evan@nemerson.com
|
| 72 |
+
Evgeny Stambulchik fnevgeny@plasma-gate.weizmann.ac.il
|
| 73 |
+
Fabrice Bauzac noon@cote-dazur.com
|
| 74 |
+
Ferdinand Thiessen ferdinand@fthiessen.de
|
| 75 |
+
Florian Krohm florian@edamail.fishkill.ibm.com
|
| 76 |
+
Frank Heckenbach frank@g-n-u.de
|
| 77 |
+
Frans Englich frans.englich@telia.com
|
| 78 |
+
Gabriel Rassoul gabriel.rassoul@epita.fr
|
| 79 |
+
Gary L Peskin garyp@firstech.com
|
| 80 |
+
Gavin Smith gavinsmith0123@gmail.com
|
| 81 |
+
Georg Sauthoff gsauthof@TechFak.Uni-Bielefeld.DE
|
| 82 |
+
George Neuner gneuner2@comcast.net
|
| 83 |
+
Gilles Espinasse g.esp@free.fr
|
| 84 |
+
Goran Uddeborg goeran@uddeborg.se
|
| 85 |
+
Guido Trentalancia trentalg@aston.ac.uk
|
| 86 |
+
H. Merijn Brand h.m.brand@hccnet.nl
|
| 87 |
+
Hans Åberg haberg-1@telia.com
|
| 88 |
+
Horst Von Brand vonbrand@inf.utfsm.cl
|
| 89 |
+
Jacob L. Mandelson jlm-bbison@jlm.ofb.net
|
| 90 |
+
Jan Nieuwenhuizen janneke@gnu.org
|
| 91 |
+
Jannick thirdedition@gmx.net
|
| 92 |
+
Jeff Hammond jeff_hammond@acm.org
|
| 93 |
+
Jerry Quinn jlquinn@optonline.net
|
| 94 |
+
Jesse Thilo jthilo@gnu.org
|
| 95 |
+
Jim Kent jkent@arch.sel.sony.com
|
| 96 |
+
Jim Meyering jim@meyering.net
|
| 97 |
+
Joel E. Denny joeldenny@joeldenny.org
|
| 98 |
+
Johan van Selst johans@stack.nl
|
| 99 |
+
John Horigan john@glyphic.com
|
| 100 |
+
Jonathan Fabrizio jonathan.fabrizio@lrde.epita.fr
|
| 101 |
+
Jonathan Nieder jrnieder@gmail.com
|
| 102 |
+
Josh Soref jsoref@gmail.com
|
| 103 |
+
Juan Manuel Guerrero juan.guerrero@gmx.de
|
| 104 |
+
Karl Berry karl@freefriends.org
|
| 105 |
+
Kees Zeelenberg kzlg@users.sourceforge.net
|
| 106 |
+
Keith Browne kbrowne@legato.com
|
| 107 |
+
Ken Moffat zarniwhoop@ntlworld.com
|
| 108 |
+
Kiyoshi Kanazawa yoi_no_myoujou@yahoo.co.jp
|
| 109 |
+
Lars Maier lars.maier@tefax.net
|
| 110 |
+
Lars Wendler polynomial-c@gentoo.org
|
| 111 |
+
László Várady laszlo.varady93@gmail.com
|
| 112 |
+
Laurent Mascherpa laurent.mascherpa@epita.fr
|
| 113 |
+
Lie Yan lie.yan@kaust.edu.sa
|
| 114 |
+
Maarten De Braekeleer maarten.debraekeleer@gmail.com
|
| 115 |
+
Magnus Fromreide magfr@lysator.liu.se
|
| 116 |
+
Marc Autret autret_m@epita.fr
|
| 117 |
+
Marc Mendiola mmendiol@usc.edu
|
| 118 |
+
Marc Schönefeld marc.schoenefeld@gmx.org
|
| 119 |
+
Mark Boyall wolfeinstein@gmail.com
|
| 120 |
+
Martin Blais blais@furius.ca
|
| 121 |
+
Martin Jacobs martin.jacobs@arcor.de
|
| 122 |
+
Martin Mokrejs mmokrejs@natur.cuni.cz
|
| 123 |
+
Martin Nylin martin.nylin@linuxmail.org
|
| 124 |
+
Matt Kraai kraai@alumni.cmu.edu
|
| 125 |
+
Matt Rosing rosing@peakfive.com
|
| 126 |
+
Maxim Prohorenko Maxim.Prohorenko@gmail.com
|
| 127 |
+
Michael Catanzaro mcatanzaro@gnome.org
|
| 128 |
+
Michael Felt mamfelt@gmail.com
|
| 129 |
+
Michael Hayes m.hayes@elec.canterbury.ac.nz
|
| 130 |
+
Michael Raskin 7c6f434c@mail.ru
|
| 131 |
+
Michel d'Hooge michel.dhooge@gmail.com
|
| 132 |
+
Michiel De Wilde mdewilde.agilent@gmail.com
|
| 133 |
+
Mickael Labau labau_m@epita.fr
|
| 134 |
+
Mike Castle dalgoda@ix.netcom.com
|
| 135 |
+
Mike Frysinger vapier@gentoo.org
|
| 136 |
+
Mike Sullivan Mike.sullivan@Oracle.COM
|
| 137 |
+
Nate Guerin nathan.guerin@riseup.net
|
| 138 |
+
Neil Booth NeilB@earthling.net
|
| 139 |
+
Nelson H. F. Beebe beebe@math.utah.edu
|
| 140 |
+
neok m4700 neok.m4700@gmail.com
|
| 141 |
+
Nick Bowler nbowler@elliptictech.com
|
| 142 |
+
Nicolas Bedon nicolas.bedon@univ-rouen.fr
|
| 143 |
+
Nicolas Burrus nicolas.burrus@epita.fr
|
| 144 |
+
Nicolas Tisserand nicolas.tisserand@epita.fr
|
| 145 |
+
Nikki Valen nicolettavalencia.nv@gmail.com
|
| 146 |
+
Noah Friedman friedman@gnu.org
|
| 147 |
+
Odd Arild Olsen oao@fibula.no
|
| 148 |
+
Oleg Smolsky oleg.smolsky@pacific-simulators.co.nz
|
| 149 |
+
Oleksii Taran oleksii.taran@gmail.com
|
| 150 |
+
Oliver Mangold o.mangold@gmail.com
|
| 151 |
+
Paolo Bonzini bonzini@gnu.org
|
| 152 |
+
Paolo Simone Gasparello djgaspa@gmail.com
|
| 153 |
+
Pascal Bart pascal.bart@epita.fr
|
| 154 |
+
Patrice Dumas pertusus@free.fr
|
| 155 |
+
Paul Eggert eggert@cs.ucla.edu
|
| 156 |
+
Paul Hilfinger Hilfinger@CS.Berkeley.EDU
|
| 157 |
+
Per Allansson per@appgate.com
|
| 158 |
+
Peter Eisentraut peter_e@gmx.net
|
| 159 |
+
Peter Fales psfales@lucent.com
|
| 160 |
+
Peter Hamorsky hamo@upjs.sk
|
| 161 |
+
Peter Simons simons@cryp.to
|
| 162 |
+
Petr Machata pmachata@redhat.com
|
| 163 |
+
Pho pho@cielonegro.org
|
| 164 |
+
Piotr Gackiewicz gacek@intertel.com.pl
|
| 165 |
+
Piotr Marcińczyk piomar123@gmail.com
|
| 166 |
+
Pramod Kumbhar pramod.s.kumbhar@gmail.com
|
| 167 |
+
Quentin Hocquet hocquet@gostai.com
|
| 168 |
+
Quoc Peyrot chojin@lrde.epita.fr
|
| 169 |
+
R Blake blakers@mac.com
|
| 170 |
+
Raja R Harinath harinath@cs.umn.edu
|
| 171 |
+
Ralf Wildenhues Ralf.Wildenhues@gmx.de
|
| 172 |
+
Ryan dev@splintermail.com
|
| 173 |
+
Rich Wilson richaw@gmail.com
|
| 174 |
+
Richard Stallman rms@gnu.org
|
| 175 |
+
Rici Lake ricilake@gmail.com
|
| 176 |
+
Rob Conde rob.conde@ai-solutions.com
|
| 177 |
+
Rob Vermaas rob.vermaas@gmail.com
|
| 178 |
+
Robert Anisko anisko_r@epita.fr
|
| 179 |
+
Robert Yang liezhi.yang@windriver.com
|
| 180 |
+
Roland Levillain roland@lrde.epita.fr
|
| 181 |
+
Satya Kiran Popuri satyakiran@gmail.com
|
| 182 |
+
Sebastian Setzer sebastian.setzer.ext@siemens.com
|
| 183 |
+
Sebastien Fricker sebastien.fricker@gmail.com
|
| 184 |
+
Sébastien Villemot sebastien@debian.org
|
| 185 |
+
Sergei Steshenko sergstesh@yahoo.com
|
| 186 |
+
Shura debil_urod@ngs.ru
|
| 187 |
+
Simon Sobisch simonsobisch@web.de
|
| 188 |
+
Stefano Lattarini stefano.lattarini@gmail.com
|
| 189 |
+
Stephen Cameron stephenmcameron@gmail.com
|
| 190 |
+
Steve Murphy murf@parsetree.com
|
| 191 |
+
Suhwan Song prada960808@gmail.com
|
| 192 |
+
Sum Wu sum@geekhouse.org
|
| 193 |
+
Théophile Ranquet theophile.ranquet@gmail.com
|
| 194 |
+
Thiru Ramakrishnan thiru.ramakrishnan@gmail.com
|
| 195 |
+
Thomas Jahns jahns@dkrz.de
|
| 196 |
+
Thomas Petazzoni thomas.petazzoni@bootlin.com
|
| 197 |
+
Tim Josling tej@melbpc.org.au
|
| 198 |
+
Tim Landscheidt tim@tim-landscheidt.de
|
| 199 |
+
Tim Van Holder tim.van.holder@pandora.be
|
| 200 |
+
Tobias Frost tobi@debian.org
|
| 201 |
+
Todd Freed todd.freed@gmail.com
|
| 202 |
+
Tom Kramer kramer@nist.gov
|
| 203 |
+
Tom Lane tgl@sss.pgh.pa.us
|
| 204 |
+
Tom Tromey tromey@cygnus.com
|
| 205 |
+
Tomasz Kłoczko kloczko.tomasz@gmail.com
|
| 206 |
+
Tommy Nordgren tommy.nordgren@chello.se
|
| 207 |
+
Troy A. Johnson troyj@ecn.purdue.edu
|
| 208 |
+
Tys Lefering gccbison@gmail.com
|
| 209 |
+
Uxio Prego uxio@uma.es
|
| 210 |
+
Valentin Tolmer nitnelave1@gmail.com
|
| 211 |
+
wcventure wcventure@126.com
|
| 212 |
+
Victor Khomenko victor.khomenko@newcastle.ac.uk
|
| 213 |
+
Victor Zverovich victor.zverovich@gmail.com
|
| 214 |
+
Vin Shelton acs@alumni.princeton.edu
|
| 215 |
+
W.C.A. Wijngaards wouter@NLnetLabs.nl
|
| 216 |
+
Wayne Green wayne@infosavvy.com
|
| 217 |
+
Wei Song wsong83@gmail.com
|
| 218 |
+
Wojciech Polak polak@gnu.org
|
| 219 |
+
Wolfgang S. Kechel wolfgang.kechel@prs.de
|
| 220 |
+
Wolfgang Thaller wolfgang.thaller@gmx.net
|
| 221 |
+
Wolfram Wagner ww@mpi-sb.mpg.de
|
| 222 |
+
Wwp subscript@free.fr
|
| 223 |
+
xolodho xolodho@gmail.com
|
| 224 |
+
Yuichiro Kaneko spiketeika@gmail.com
|
| 225 |
+
Yuriy Solodkyy solodon@gmail.com
|
| 226 |
+
Zack Weinberg zack@codesourcery.com
|
| 227 |
+
江 祖铭 jjzuming@outlook.com
|
| 228 |
+
長田偉伸 cbh34680@iret.co.jp
|
| 229 |
+
马俊 majun123@whu.edu.cn
|
| 230 |
+
|
| 231 |
+
Many people are not named here because we lost track of them. We
|
| 232 |
+
thank them! Please, help us keeping this list up to date.
|
| 233 |
+
|
| 234 |
+
Local Variables:
|
| 235 |
+
mode: text
|
| 236 |
+
coding: utf-8
|
| 237 |
+
End:
|
| 238 |
+
|
| 239 |
+
-----
|
| 240 |
+
|
| 241 |
+
Copyright (C) 2000-2015, 2018-2021 Free Software Foundation, Inc.
|
| 242 |
+
|
| 243 |
+
This file is part of Bison, the GNU Parser Generator.
|
| 244 |
+
|
| 245 |
+
This program is free software: you can redistribute it and/or modify
|
| 246 |
+
it under the terms of the GNU General Public License as published by
|
| 247 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 248 |
+
(at your option) any later version.
|
| 249 |
+
|
| 250 |
+
This program is distributed in the hope that it will be useful,
|
| 251 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 252 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 253 |
+
GNU General Public License for more details.
|
| 254 |
+
|
| 255 |
+
You should have received a copy of the GNU General Public License
|
| 256 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
platform/dbops/binaries/build/share/doc/bison/TODO
ADDED
|
@@ -0,0 +1,723 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
* Soon
|
| 2 |
+
** scan-code
|
| 3 |
+
The default case is scanning char-per-char.
|
| 4 |
+
|
| 5 |
+
/* By default, grow the string obstack with the input. */
|
| 6 |
+
.|\n STRING_GROW ();
|
| 7 |
+
|
| 8 |
+
make it more eager?
|
| 9 |
+
|
| 10 |
+
** Missing tests
|
| 11 |
+
commit 2c294c132528ede23d8ae4959783a67e9ff05ac5
|
| 12 |
+
Author: Vincent Imbimbo <vmi6@cornell.edu>
|
| 13 |
+
Date: Sat Jan 23 13:25:18 2021 -0500
|
| 14 |
+
|
| 15 |
+
cex: fix state-item pruning
|
| 16 |
+
|
| 17 |
+
See https://lists.gnu.org/r/bug-bison/2021-01/msg00002.html
|
| 18 |
+
|
| 19 |
+
** pos_set_set
|
| 20 |
+
The current approach is correct, but with poor performances. Bitsets need
|
| 21 |
+
to support 'assign' and 'shift'. And instead of extending POS_SET just for
|
| 22 |
+
the out-of-range new values, we need something like doubling the size.
|
| 23 |
+
|
| 24 |
+
** glr
|
| 25 |
+
There is no test with "Parse on stack %ld rejected by rule %d" in it.
|
| 26 |
+
|
| 27 |
+
** yyrline etc.
|
| 28 |
+
Clarify that rule numbers in the skeletons are 1-based.
|
| 29 |
+
|
| 30 |
+
** Macros in C++
|
| 31 |
+
There are many macros that should obey api.prefix: YY_CPLUSPLUS, YY_MOVE,
|
| 32 |
+
etc.
|
| 33 |
+
|
| 34 |
+
** yyerrok in Java
|
| 35 |
+
And add tests in calc.at, to prepare work for D.
|
| 36 |
+
|
| 37 |
+
** YYERROR and yynerrs
|
| 38 |
+
We are missing some cases. Write a test case, and check all the skeletons.
|
| 39 |
+
|
| 40 |
+
** Cex
|
| 41 |
+
*** Improve gnulib
|
| 42 |
+
Don't do this (counterexample.c):
|
| 43 |
+
|
| 44 |
+
// This is the fastest way to get the tail node from the gl_list API.
|
| 45 |
+
gl_list_node_t
|
| 46 |
+
list_get_end (gl_list_t list)
|
| 47 |
+
{
|
| 48 |
+
gl_list_node_t sentinel = gl_list_add_last (list, NULL);
|
| 49 |
+
gl_list_node_t res = gl_list_previous_node (list, sentinel);
|
| 50 |
+
gl_list_remove_node (list, sentinel);
|
| 51 |
+
return res;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
*** Ambiguous rewriting
|
| 55 |
+
If the user is stupid enough to have equal rules, then the derivations are
|
| 56 |
+
harder to read:
|
| 57 |
+
|
| 58 |
+
Reduce/reduce conflict on tokens $end, "+", "⊕":
|
| 59 |
+
2 exp: exp "+" exp .
|
| 60 |
+
3 exp: exp "+" exp .
|
| 61 |
+
Example exp "+" exp •
|
| 62 |
+
First derivation exp ::=[ exp "+" exp • ]
|
| 63 |
+
Example exp "+" exp •
|
| 64 |
+
Second derivation exp ::=[ exp "+" exp • ]
|
| 65 |
+
|
| 66 |
+
Do we care about this? In color, we use twice the same color here, but we
|
| 67 |
+
could try to use the same color for the same rule.
|
| 68 |
+
|
| 69 |
+
*** XML reports
|
| 70 |
+
Show the counterexamples. This is going to be really hard and/or painful.
|
| 71 |
+
Unless we play it dumb (little structure).
|
| 72 |
+
|
| 73 |
+
** Bistromathic
|
| 74 |
+
- How about not evaluating incomplete lines when the text is not finished
|
| 75 |
+
(as shells do).
|
| 76 |
+
|
| 77 |
+
** Questions
|
| 78 |
+
*** Java
|
| 79 |
+
- Should i18n be part of the Lexer? Currently it's a static method of
|
| 80 |
+
Lexer.
|
| 81 |
+
|
| 82 |
+
- is there a migration path that would allow to use TokenKinds in
|
| 83 |
+
yylex?
|
| 84 |
+
|
| 85 |
+
- define the tokens as an enum too.
|
| 86 |
+
|
| 87 |
+
- promote YYEOF rather than EOF.
|
| 88 |
+
|
| 89 |
+
** YYerror
|
| 90 |
+
https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gettext-runtime/intl/plural.y;h=a712255af4f2f739c93336d4ff6556d932a426a5;hb=HEAD
|
| 91 |
+
|
| 92 |
+
should be updated to not use YYERRCODE. Returning an undef token is good
|
| 93 |
+
enough.
|
| 94 |
+
|
| 95 |
+
** Java
|
| 96 |
+
*** calc.at
|
| 97 |
+
Stop hard-coding "Calc". Adjust local.at (look for FIXME).
|
| 98 |
+
|
| 99 |
+
** doc
|
| 100 |
+
I feel it's ugly to use the GNU style to declare functions in the doc. It
|
| 101 |
+
generates tons of white space in the page, and may contribute to bad page
|
| 102 |
+
breaks.
|
| 103 |
+
|
| 104 |
+
** consistency
|
| 105 |
+
token vs terminal.
|
| 106 |
+
|
| 107 |
+
** api.token.raw
|
| 108 |
+
The YYUNDEFTOK could be assigned a semantic value so that yyerror could be
|
| 109 |
+
used to report invalid lexemes.
|
| 110 |
+
|
| 111 |
+
** push parsers
|
| 112 |
+
Consider deprecating impure push parsers. They add a lot of complexity, for
|
| 113 |
+
a bad feature. On the other hand, that would make it much harder to sit
|
| 114 |
+
push parsers on top of pull parser. Which is currently not relevant, since
|
| 115 |
+
push parsers are measurably slower.
|
| 116 |
+
|
| 117 |
+
** %define parse.error formatted
|
| 118 |
+
How about pushing Bistromathic's yyreport_syntax_error as another standard
|
| 119 |
+
way to generate the error message, and leave to the user the task of
|
| 120 |
+
providing the message formats? Currently in bistro, it reads:
|
| 121 |
+
|
| 122 |
+
const char *
|
| 123 |
+
error_format_string (int argc)
|
| 124 |
+
{
|
| 125 |
+
switch (argc)
|
| 126 |
+
{
|
| 127 |
+
default: /* Avoid compiler warnings. */
|
| 128 |
+
case 0: return _("%@: syntax error");
|
| 129 |
+
case 1: return _("%@: syntax error: unexpected %u");
|
| 130 |
+
// TRANSLATORS: '%@' is a location in a file, '%u' is an
|
| 131 |
+
// "unexpected token", and '%0e', '%1e'... are expected tokens
|
| 132 |
+
// at this point.
|
| 133 |
+
//
|
| 134 |
+
// For instance on the expression "1 + * 2", you'd get
|
| 135 |
+
//
|
| 136 |
+
// 1.5: syntax error: expected - or ( or number or function or variable before *
|
| 137 |
+
case 2: return _("%@: syntax error: expected %0e before %u");
|
| 138 |
+
case 3: return _("%@: syntax error: expected %0e or %1e before %u");
|
| 139 |
+
case 4: return _("%@: syntax error: expected %0e or %1e or %2e before %u");
|
| 140 |
+
case 5: return _("%@: syntax error: expected %0e or %1e or %2e or %3e before %u");
|
| 141 |
+
case 6: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e before %u");
|
| 142 |
+
case 7: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e before %u");
|
| 143 |
+
case 8: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e or %6e before %u");
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
The message would have to be generated in a string, and pushed to yyerror.
|
| 148 |
+
Which will be a pain in the neck in yacc.c.
|
| 149 |
+
|
| 150 |
+
If we want to do that, we should think very carefully about the syntax of
|
| 151 |
+
the format string.
|
| 152 |
+
|
| 153 |
+
** yyclearin does not invoke the lookahead token's %destructor
|
| 154 |
+
https://lists.gnu.org/r/bug-bison/2018-02/msg00000.html
|
| 155 |
+
Rici:
|
| 156 |
+
|
| 157 |
+
> Modifying yyclearin so that it calls yydestruct seems like the simplest
|
| 158 |
+
> solution to this issue, but it is conceivable that such a change would
|
| 159 |
+
> break programs which already perform some kind of workaround in order to
|
| 160 |
+
> destruct the lookahead symbol. So it might be necessary to use some kind of
|
| 161 |
+
> compatibility %define, or to create a new replacement macro with a
|
| 162 |
+
> different name such as yydiscardin.
|
| 163 |
+
>
|
| 164 |
+
> At a minimum, the fact that yyclearin does not invoke the %destructor
|
| 165 |
+
> should be highlighted in the documentation, since it is not at all obvious.
|
| 166 |
+
|
| 167 |
+
** Issues in i18n
|
| 168 |
+
|
| 169 |
+
Les catégories d'avertissements incluent :
|
| 170 |
+
conflicts-sr conflits S/R (activé par défaut)
|
| 171 |
+
conflicts-rr conflits R/R (activé par défaut)
|
| 172 |
+
dangling-alias l'alias chaîne n'est pas attaché à un symbole
|
| 173 |
+
deprecated construction obsolète
|
| 174 |
+
empty-rule règle vide sans %empty
|
| 175 |
+
midrule-values valeurs de règle intermédiaire non définies ou inutilisées
|
| 176 |
+
precedence priorité et associativité inutiles
|
| 177 |
+
yacc incompatibilités avec POSIX Yacc
|
| 178 |
+
other tous les autres avertissements (activé par défaut)
|
| 179 |
+
all tous les avertissements sauf « dangling-alias » et « yacc »
|
| 180 |
+
no-CATEGORY désactiver les avertissements dans CATEGORIE
|
| 181 |
+
none désactiver tous les avertissements
|
| 182 |
+
error[=CATEGORY] traiter les avertissements comme des erreurs
|
| 183 |
+
|
| 184 |
+
Line -1 and -3 should mention CATEGORIE, not CATEGORY.
|
| 185 |
+
|
| 186 |
+
* Bison 3.9
|
| 187 |
+
** Rewrite glr.cc (currently glr2.cc)
|
| 188 |
+
*** custom error messages
|
| 189 |
+
|
| 190 |
+
*** Remove jumps
|
| 191 |
+
We can probably replace setjmp/longjmp with exceptions. That would help
|
| 192 |
+
tremendously other languages such as D and Java that probably have no
|
| 193 |
+
similar feature. If we remove jumps, we probably no longer need _Noreturn,
|
| 194 |
+
so simplify `b4_attribute_define([noreturn])` into `b4_attribute_define`.
|
| 195 |
+
|
| 196 |
+
After discussing with Valentin, it was decided that it's better to stay with
|
| 197 |
+
jumps, since in some places exceptions are ruled out from C++.
|
| 198 |
+
|
| 199 |
+
*** Coding style
|
| 200 |
+
Move to our coding conventions. In particular names such as yy_glr_stack,
|
| 201 |
+
not yyGLRStack.
|
| 202 |
+
|
| 203 |
+
*** yydebug
|
| 204 |
+
It should be a member of the parser object, see lalr1.cc. Let the parser
|
| 205 |
+
object decide what the debug stream is, rather than open coding std::cerr.
|
| 206 |
+
|
| 207 |
+
*** Avoid pointers
|
| 208 |
+
There are many places where pointers should be replaced with references.
|
| 209 |
+
Some occurrences were fixed, but now some have improper names:
|
| 210 |
+
|
| 211 |
+
-yygetToken (int *yycharp, ]b4_namespace_ref[::]b4_parser_class[& yyparser][]b4_pure_if([, glr_stack* yystackp])[]b4_user_formals[)
|
| 212 |
+
+yygetToken (int& yycharp, ]b4_namespace_ref[::]b4_parser_class[& yyparser][]b4_pure_if([, glr_stack* yystackp])[]b4_user_formals[)
|
| 213 |
+
|
| 214 |
+
yycharp is no longer a Pointer. And yystackp should probably also be a reference.
|
| 215 |
+
|
| 216 |
+
*** parse.assert
|
| 217 |
+
Currently all the assertions are enabled. Once we are confident in glr2.cc,
|
| 218 |
+
let parse.assert use the same approach as in lalr1.cc.
|
| 219 |
+
|
| 220 |
+
*** debug_stream
|
| 221 |
+
Stop using std::cerr everywhere.
|
| 222 |
+
|
| 223 |
+
*** glr.c
|
| 224 |
+
When glr2.cc fully replaces glr.cc, get rid of the glr.cc scaffolding in
|
| 225 |
+
glr.c.
|
| 226 |
+
|
| 227 |
+
* Chains
|
| 228 |
+
** Unit rules / Injection rules (Akim Demaille)
|
| 229 |
+
Maybe we could expand unit rules (or "injections", see
|
| 230 |
+
https://homepages.cwi.nl/~daybuild/daily-books/syntax/2-sdf/sdf.html), i.e.,
|
| 231 |
+
transform
|
| 232 |
+
|
| 233 |
+
exp: arith | bool;
|
| 234 |
+
arith: exp '+' exp;
|
| 235 |
+
bool: exp '&' exp;
|
| 236 |
+
|
| 237 |
+
into
|
| 238 |
+
|
| 239 |
+
exp: exp '+' exp | exp '&' exp;
|
| 240 |
+
|
| 241 |
+
when there are no actions. This can significantly speed up some grammars.
|
| 242 |
+
I can't find the papers. In particular the book 'LR parsing: Theory and
|
| 243 |
+
Practice' is impossible to find, but according to 'Parsing Techniques: a
|
| 244 |
+
Practical Guide', it includes information about this issue. Does anybody
|
| 245 |
+
have it?
|
| 246 |
+
|
| 247 |
+
** clean up (Akim Demaille)
|
| 248 |
+
Do not work on these items now, as I (Akim) have branches with a lot of
|
| 249 |
+
changes in this area (hitting several files), and no desire to have to fix
|
| 250 |
+
conflicts. Addressing these items will happen after my branches have been
|
| 251 |
+
merged.
|
| 252 |
+
|
| 253 |
+
*** lalr.c
|
| 254 |
+
Introduce a goto struct, and use it in place of from_state/to_state.
|
| 255 |
+
Rename states1 as path, length as pathlen.
|
| 256 |
+
Introduce inline functions for things such as nullable[*rp - ntokens]
|
| 257 |
+
where we need to map from symbol number to nterm number.
|
| 258 |
+
|
| 259 |
+
There are probably a significant part of the relations management that
|
| 260 |
+
should be migrated on top of a bitsetv.
|
| 261 |
+
|
| 262 |
+
*** closure
|
| 263 |
+
It should probably take a "state*" instead of two arguments.
|
| 264 |
+
|
| 265 |
+
*** traces
|
| 266 |
+
The "automaton" and "set" categories are not so useful. We should probably
|
| 267 |
+
introduce lr(0) and lalr, just the way we have ielr categories. The
|
| 268 |
+
"closure" function is too verbose, it should probably have its own category.
|
| 269 |
+
|
| 270 |
+
"set" can still be used for summarizing the important sets. That would make
|
| 271 |
+
tests easy to maintain.
|
| 272 |
+
|
| 273 |
+
*** complain.*
|
| 274 |
+
Rename these guys as "diagnostics.*" (or "diagnose.*"), since that's the
|
| 275 |
+
name they have in GCC, clang, etc. Likewise for the complain_* series of
|
| 276 |
+
functions.
|
| 277 |
+
|
| 278 |
+
*** ritem
|
| 279 |
+
states/nstates, rules/nrules, ..., ritem/nritems
|
| 280 |
+
Fix the latter.
|
| 281 |
+
|
| 282 |
+
*** m4: slot, type, type_tag
|
| 283 |
+
The meaning of type_tag varies depending on api.value.type. We should avoid
|
| 284 |
+
that and using clear definitions with stable semantics.
|
| 285 |
+
|
| 286 |
+
* D programming language
|
| 287 |
+
There's a number of features that are missing, here sorted in _suggested_
|
| 288 |
+
order of implementation.
|
| 289 |
+
|
| 290 |
+
When copying code from other skeletons, keep the comments exactly as they
|
| 291 |
+
are. Keep the same variable names. If you change the wording in one place,
|
| 292 |
+
do it in the others too. In other words: make sure to keep the
|
| 293 |
+
maintenance *simple* by avoiding any gratuitous difference.
|
| 294 |
+
|
| 295 |
+
** CI
|
| 296 |
+
Check when gdc and ldc.
|
| 297 |
+
|
| 298 |
+
** GLR Parser
|
| 299 |
+
This is very ambitious. That's the final boss. There are currently no
|
| 300 |
+
"clean" implementation to get inspiration from.
|
| 301 |
+
|
| 302 |
+
glr.c is very clean but:
|
| 303 |
+
- is low-level C
|
| 304 |
+
- is a different skeleton from yacc.c
|
| 305 |
+
|
| 306 |
+
glr.cc is (currently) an ugly hack: a C++ shell around glr.c. Valentin
|
| 307 |
+
Tolmer is currently rewriting glr.cc to be clean C++, but he is not
|
| 308 |
+
finished. There will be a lot a common code between lalr1.cc and glr.cc, so
|
| 309 |
+
eventually I would like them to be fused into a single skeleton, supporting
|
| 310 |
+
both deterministic and generalized parsing.
|
| 311 |
+
|
| 312 |
+
It would be great for D to also support this.
|
| 313 |
+
|
| 314 |
+
The basic ideas of GLR are explained here:
|
| 315 |
+
|
| 316 |
+
https://www.codeproject.com/Articles/5259825/GLR-Parsing-in-Csharp-How-to-Use-The-Most-Powerful
|
| 317 |
+
|
| 318 |
+
* Better error messages
|
| 319 |
+
The users are not provided with enough tools to forge their error messages.
|
| 320 |
+
See for instance "Is there an option to change the message produced by
|
| 321 |
+
YYERROR_VERBOSE?" by Simon Sobisch, on bison-help.
|
| 322 |
+
|
| 323 |
+
See also
|
| 324 |
+
https://www.cs.tufts.edu/~nr/cs257/archive/clinton-jefferey/lr-error-messages.pdf
|
| 325 |
+
https://research.swtch.com/yyerror
|
| 326 |
+
http://gallium.inria.fr/~fpottier/publis/fpottier-reachability-cc2016.pdf
|
| 327 |
+
|
| 328 |
+
* Modernization
|
| 329 |
+
Fix data/skeletons/yacc.c so that it defines YYPTRDIFF_T properly for modern
|
| 330 |
+
and older C++ compilers. Currently the code defaults to defining it to
|
| 331 |
+
'long' for non-GCC compilers, but it should use the proper C++ magic to
|
| 332 |
+
define it to the same type as the C ptrdiff_t type.
|
| 333 |
+
|
| 334 |
+
* Completion
|
| 335 |
+
Several features are not available in all the back-ends.
|
| 336 |
+
|
| 337 |
+
- push parsers: glr.c, glr.cc, lalr1.cc (not very difficult)
|
| 338 |
+
- token constructors: Java, C, D (a bit difficult)
|
| 339 |
+
- glr: D, Java (super difficult)
|
| 340 |
+
|
| 341 |
+
* Bugs
|
| 342 |
+
** Autotest has quotation issues
|
| 343 |
+
tests/input.at:1730:AT_SETUP([%define errors])
|
| 344 |
+
|
| 345 |
+
->
|
| 346 |
+
|
| 347 |
+
$ ./tests/testsuite -l | grep errors | sed q
|
| 348 |
+
38: input.at:1730 errors
|
| 349 |
+
|
| 350 |
+
* Short term
|
| 351 |
+
** Better design for diagnostics
|
| 352 |
+
The current implementation of diagnostics is ad hoc, it grew organically.
|
| 353 |
+
It works as a series of calls to several functions, with dependency of the
|
| 354 |
+
latter calls on the former. For instance:
|
| 355 |
+
|
| 356 |
+
complain (&sym->location,
|
| 357 |
+
sym->content->status == needed ? complaint : Wother,
|
| 358 |
+
_("symbol %s is used, but is not defined as a token"
|
| 359 |
+
" and has no rules; did you mean %s?"),
|
| 360 |
+
quote_n (0, sym->tag),
|
| 361 |
+
quote_n (1, best->tag));
|
| 362 |
+
if (feature_flag & feature_caret)
|
| 363 |
+
location_caret_suggestion (sym->location, best->tag, stderr);
|
| 364 |
+
|
| 365 |
+
We should rewrite this in a more FP way:
|
| 366 |
+
|
| 367 |
+
1. build a rich structure that denotes the (complete) diagnostic.
|
| 368 |
+
"Complete" in the sense that it also contains the suggestions, the list
|
| 369 |
+
of possible matches, etc.
|
| 370 |
+
|
| 371 |
+
2. send this to the pretty-printing routine. The diagnostic structure
|
| 372 |
+
should be sufficient so that we can generate all the 'format' of
|
| 373 |
+
diagnostics, including the fixits.
|
| 374 |
+
|
| 375 |
+
If properly done, this diagnostic module can be detached from Bison and be
|
| 376 |
+
put in gnulib. It could be used, for instance, for errors caught by
|
| 377 |
+
xgettext.
|
| 378 |
+
|
| 379 |
+
There's certainly already something alike in GCC. At least that's the
|
| 380 |
+
impression I get from reading the "-fdiagnostics-format=FORMAT" part of this
|
| 381 |
+
page:
|
| 382 |
+
|
| 383 |
+
https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html
|
| 384 |
+
|
| 385 |
+
** Graphviz display code thoughts
|
| 386 |
+
The code for the --graph option is over two files: print_graph, and
|
| 387 |
+
graphviz. This is because Bison used to also produce VCG graphs, but since
|
| 388 |
+
this is no longer true, maybe we could consider these files for fusion.
|
| 389 |
+
|
| 390 |
+
An other consideration worth noting is that print_graph.c (correct me if I
|
| 391 |
+
am wrong) should contain generic functions, whereas graphviz.c and other
|
| 392 |
+
potential files should contain just the specific code for that output
|
| 393 |
+
format. It will probably prove difficult to tell if the implementation is
|
| 394 |
+
actually generic whilst only having support for a single format, but it
|
| 395 |
+
would be nice to keep stuff a bit tidier: right now, the construction of the
|
| 396 |
+
bitset used to show reductions is in the graphviz-specific code, and on the
|
| 397 |
+
opposite side we have some use of \l, which is graphviz-specific, in what
|
| 398 |
+
should be generic code.
|
| 399 |
+
|
| 400 |
+
Little effort seems to have been given to factoring these files and their
|
| 401 |
+
print{,-xml} counterpart. We would very much like to re-use the pretty format
|
| 402 |
+
of states from .output for the graphs, etc.
|
| 403 |
+
|
| 404 |
+
Since graphviz dies on medium-to-big grammars, maybe consider an other tool?
|
| 405 |
+
|
| 406 |
+
** push-parser
|
| 407 |
+
Check it too when checking the different kinds of parsers. And be
|
| 408 |
+
sure to check that the initial-action is performed once per parsing.
|
| 409 |
+
|
| 410 |
+
** m4 names
|
| 411 |
+
b4_shared_declarations is no longer what it is. Make it
|
| 412 |
+
b4_parser_declaration for instance.
|
| 413 |
+
|
| 414 |
+
** yychar in lalr1.cc
|
| 415 |
+
There is a large difference bw maint and master on the handling of
|
| 416 |
+
yychar (which was removed in lalr1.cc). See what needs to be
|
| 417 |
+
back-ported.
|
| 418 |
+
|
| 419 |
+
|
| 420 |
+
/* User semantic actions sometimes alter yychar, and that requires
|
| 421 |
+
that yytoken be updated with the new translation. We take the
|
| 422 |
+
approach of translating immediately before every use of yytoken.
|
| 423 |
+
One alternative is translating here after every semantic action,
|
| 424 |
+
but that translation would be missed if the semantic action
|
| 425 |
+
invokes YYABORT, YYACCEPT, or YYERROR immediately after altering
|
| 426 |
+
yychar. In the case of YYABORT or YYACCEPT, an incorrect
|
| 427 |
+
destructor might then be invoked immediately. In the case of
|
| 428 |
+
YYERROR, subsequent parser actions might lead to an incorrect
|
| 429 |
+
destructor call or verbose syntax error message before the
|
| 430 |
+
lookahead is translated. */
|
| 431 |
+
|
| 432 |
+
/* Make sure we have latest lookahead translation. See comments at
|
| 433 |
+
user semantic actions for why this is necessary. */
|
| 434 |
+
yytoken = yytranslate_ (yychar);
|
| 435 |
+
|
| 436 |
+
|
| 437 |
+
** Get rid of fake #lines [Bison: ...]
|
| 438 |
+
Possibly as simple as checking whether the column number is nonnegative.
|
| 439 |
+
|
| 440 |
+
I have seen messages like the following from GCC.
|
| 441 |
+
|
| 442 |
+
<built-in>:0: fatal error: opening dependency file .deps/libltdl/argz.Tpo: No such file or directory
|
| 443 |
+
|
| 444 |
+
|
| 445 |
+
** Discuss about %printer/%destroy in the case of C++.
|
| 446 |
+
It would be very nice to provide the symbol classes with an operator<<
|
| 447 |
+
and a destructor. Unfortunately the syntax we have chosen for
|
| 448 |
+
%destroy and %printer make them hard to reuse. For instance, the user
|
| 449 |
+
is invited to write something like
|
| 450 |
+
|
| 451 |
+
%printer { debug_stream() << $$; } <my_type>;
|
| 452 |
+
|
| 453 |
+
which is hard to reuse elsewhere since it wants to use
|
| 454 |
+
"debug_stream()" to find the stream to use. The same applies to
|
| 455 |
+
%destroy: we told the user she could use the members of the Parser
|
| 456 |
+
class in the printers/destructors, which is not good for an operator<<
|
| 457 |
+
since it is no longer bound to a particular parser, it's just a
|
| 458 |
+
(standalone symbol).
|
| 459 |
+
|
| 460 |
+
* Various
|
| 461 |
+
** Rewrite glr.cc in C++ (Valentin Tolmer)
|
| 462 |
+
As a matter of fact, it would be very interesting to see how much we can
|
| 463 |
+
share between lalr1.cc and glr.cc. Most of the skeletons should be common.
|
| 464 |
+
It would be a very nice source of inspiration for the other languages.
|
| 465 |
+
|
| 466 |
+
Valentin Tolmer is working on this.
|
| 467 |
+
|
| 468 |
+
* From lalr1.cc to yacc.c
|
| 469 |
+
** Single stack
|
| 470 |
+
Merging the three stacks in lalr1.cc simplified the code, prompted for
|
| 471 |
+
other improvements and also made it faster (probably because memory
|
| 472 |
+
management is performed once instead of three times). I suggest that
|
| 473 |
+
we do the same in yacc.c.
|
| 474 |
+
|
| 475 |
+
(Some time later): it's also very nice to have three stacks: it's more dense
|
| 476 |
+
as we don't lose bits to padding. For instance the typical stack for states
|
| 477 |
+
will use 8 bits, while it is likely to consume 32 bits in a struct.
|
| 478 |
+
|
| 479 |
+
We need trustworthy benchmarks for Bison, for all our backends. Akim has a
|
| 480 |
+
few things scattered around; we need to put them in the repo, and make them
|
| 481 |
+
more useful.
|
| 482 |
+
|
| 483 |
+
* Report
|
| 484 |
+
|
| 485 |
+
** Figures
|
| 486 |
+
Some statistics about the grammar and the parser would be useful,
|
| 487 |
+
especially when asking the user to send some information about the
|
| 488 |
+
grammars she is working on. We should probably also include some
|
| 489 |
+
information about the variables (I'm not sure for instance we even
|
| 490 |
+
specify what LR variant was used).
|
| 491 |
+
|
| 492 |
+
** GLR
|
| 493 |
+
How would Paul like to display the conflicted actions? In particular,
|
| 494 |
+
what when two reductions are possible on a given lookahead token, but one is
|
| 495 |
+
part of $default. Should we make the two reductions explicit, or just
|
| 496 |
+
keep $default? See the following point.
|
| 497 |
+
|
| 498 |
+
** Disabled Reductions
|
| 499 |
+
See 'tests/conflicts.at (Defaulted Conflicted Reduction)', and decide
|
| 500 |
+
what we want to do.
|
| 501 |
+
|
| 502 |
+
** Documentation
|
| 503 |
+
Extend with error productions. The hard part will probably be finding
|
| 504 |
+
the right rule so that a single state does not exhibit too many yet
|
| 505 |
+
undocumented ''features''. Maybe an empty action ought to be
|
| 506 |
+
presented too. Shall we try to make a single grammar with all these
|
| 507 |
+
features, or should we have several very small grammars?
|
| 508 |
+
|
| 509 |
+
* Extensions
|
| 510 |
+
** More languages?
|
| 511 |
+
Well, only if there is really some demand for it.
|
| 512 |
+
|
| 513 |
+
*** PHP
|
| 514 |
+
https://github.com/scfc/bison-php/blob/master/data/lalr1.php
|
| 515 |
+
|
| 516 |
+
*** Python
|
| 517 |
+
https://lists.gnu.org/r/bison-patches/2013-09/msg00000.html and following
|
| 518 |
+
|
| 519 |
+
** Multiple start symbols
|
| 520 |
+
Revert a70e75b8a41755ab96ab211a0ea111ac68a4aadd.
|
| 521 |
+
Revert tests: disable "Multistart reports".
|
| 522 |
+
|
| 523 |
+
Would be very useful when parsing closely related languages. The idea is to
|
| 524 |
+
declare several start symbols, for instance
|
| 525 |
+
|
| 526 |
+
%start stmt expr
|
| 527 |
+
%%
|
| 528 |
+
stmt: ...
|
| 529 |
+
expr: ...
|
| 530 |
+
|
| 531 |
+
and to generate parse(), parse_stmt() and parse_expr(). Technically, the
|
| 532 |
+
above grammar would be transformed into
|
| 533 |
+
|
| 534 |
+
%start yy_start
|
| 535 |
+
%token YY_START_STMT YY_START_EXPR
|
| 536 |
+
%%
|
| 537 |
+
yy_start: YY_START_STMT stmt | YY_START_EXPR expr
|
| 538 |
+
|
| 539 |
+
so that there are no new conflicts in the grammar (as would undoubtedly
|
| 540 |
+
happen with yy_start: stmt | expr). Then adjust the skeletons so that this
|
| 541 |
+
initial token (YY_START_STMT, YY_START_EXPR) be shifted first in the
|
| 542 |
+
corresponding parse function.
|
| 543 |
+
|
| 544 |
+
*** Number of useless symbols
|
| 545 |
+
AT_TEST(
|
| 546 |
+
[[%start exp;
|
| 547 |
+
exp: exp;]],
|
| 548 |
+
[[input.y: warning: 2 nonterminals useless in grammar [-Wother]
|
| 549 |
+
input.y: warning: 2 rules useless in grammar [-Wother]
|
| 550 |
+
input.y:2.8-10: error: start symbol exp does not derive any sentence]])
|
| 551 |
+
|
| 552 |
+
We should say "1 nonterminal": the other one is $accept, which should not
|
| 553 |
+
participate in the count.
|
| 554 |
+
|
| 555 |
+
*** Tokens
|
| 556 |
+
Do we want to disallow terminal start symbols? The limitation is not
|
| 557 |
+
technical. Can it be useful to someone to "parse" a token?
|
| 558 |
+
|
| 559 |
+
** %include
|
| 560 |
+
This is a popular demand. We already made many changes in the parser that
|
| 561 |
+
should make this reasonably easy to implement.
|
| 562 |
+
|
| 563 |
+
Bruce Mardle <marblypup@yahoo.co.uk>
|
| 564 |
+
https://lists.gnu.org/r/bison-patches/2015-09/msg00000.html
|
| 565 |
+
|
| 566 |
+
However, there are many other things to do before having such a feature,
|
| 567 |
+
because I don't want a % equivalent to #include (which we all learned to
|
| 568 |
+
hate). I want something that builds "modules" of grammars, and assembles
|
| 569 |
+
them together, paying attention to keep separate bits separated, in pseudo
|
| 570 |
+
name spaces.
|
| 571 |
+
|
| 572 |
+
** Push parsers
|
| 573 |
+
There is demand for push parsers in C++.
|
| 574 |
+
|
| 575 |
+
** Generate code instead of tables
|
| 576 |
+
This is certainly quite a lot of work. See
|
| 577 |
+
https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.50.4539.
|
| 578 |
+
|
| 579 |
+
** $-1
|
| 580 |
+
We should find a means to provide an access to values deep in the
|
| 581 |
+
stack. For instance, instead of
|
| 582 |
+
|
| 583 |
+
baz: qux { $$ = $<foo>-1 + $<bar>0 + $1; }
|
| 584 |
+
|
| 585 |
+
we should be able to have:
|
| 586 |
+
|
| 587 |
+
foo($foo) bar($bar) baz($bar): qux($qux) { $baz = $foo + $bar + $qux; }
|
| 588 |
+
|
| 589 |
+
Or something like this.
|
| 590 |
+
|
| 591 |
+
** %if and the like
|
| 592 |
+
It should be possible to have %if/%else/%endif. The implementation is
|
| 593 |
+
not clear: should it be lexical or syntactic. Vadim Maslow thinks it
|
| 594 |
+
must be in the scanner: we must not parse what is in a switched off
|
| 595 |
+
part of %if. Akim Demaille thinks it should be in the parser, so as
|
| 596 |
+
to avoid falling into another CPP mistake.
|
| 597 |
+
|
| 598 |
+
(Later): I'm sure there's actually good case for this. People who need that
|
| 599 |
+
feature can use m4/cpp on top of Bison. I don't think it is worth the
|
| 600 |
+
trouble in Bison itself.
|
| 601 |
+
|
| 602 |
+
** XML Output
|
| 603 |
+
There are couple of available extensions of Bison targeting some XML
|
| 604 |
+
output. Some day we should consider including them. One issue is
|
| 605 |
+
that they seem to be quite orthogonal to the parsing technique, and
|
| 606 |
+
seem to depend mostly on the possibility to have some code triggered
|
| 607 |
+
for each reduction. As a matter of fact, such hooks could also be
|
| 608 |
+
used to generate the yydebug traces. Some generic scheme probably
|
| 609 |
+
exists in there.
|
| 610 |
+
|
| 611 |
+
XML output for GNU Bison and gcc
|
| 612 |
+
http://www.cs.may.ie/~jpower/Research/bisonXML/
|
| 613 |
+
|
| 614 |
+
XML output for GNU Bison
|
| 615 |
+
http://yaxx.sourceforge.net/
|
| 616 |
+
|
| 617 |
+
* Coding system independence
|
| 618 |
+
Paul notes:
|
| 619 |
+
|
| 620 |
+
Currently Bison assumes 8-bit bytes (i.e. that UCHAR_MAX is
|
| 621 |
+
255). It also assumes that the 8-bit character encoding is
|
| 622 |
+
the same for the invocation of 'bison' as it is for the
|
| 623 |
+
invocation of 'cc', but this is not necessarily true when
|
| 624 |
+
people run bison on an ASCII host and then use cc on an EBCDIC
|
| 625 |
+
host. I don't think these topics are worth our time
|
| 626 |
+
addressing (unless we find a gung-ho volunteer for EBCDIC or
|
| 627 |
+
PDP-10 ports :-) but they should probably be documented
|
| 628 |
+
somewhere.
|
| 629 |
+
|
| 630 |
+
More importantly, Bison does not currently allow NUL bytes in
|
| 631 |
+
tokens, either via escapes (e.g., "x\0y") or via a NUL byte in
|
| 632 |
+
the source code. This should get fixed.
|
| 633 |
+
|
| 634 |
+
* Broken options?
|
| 635 |
+
** %token-table
|
| 636 |
+
** Skeleton strategy
|
| 637 |
+
Must we keep %token-table?
|
| 638 |
+
|
| 639 |
+
* Precedence
|
| 640 |
+
|
| 641 |
+
** Partial order
|
| 642 |
+
It is unfortunate that there is a total order for precedence. It
|
| 643 |
+
makes it impossible to have modular precedence information. We should
|
| 644 |
+
move to partial orders (sounds like series/parallel orders to me).
|
| 645 |
+
|
| 646 |
+
This is a prerequisite for modules.
|
| 647 |
+
|
| 648 |
+
* Pre and post actions.
|
| 649 |
+
From: Florian Krohm <florian@edamail.fishkill.ibm.com>
|
| 650 |
+
Subject: YYACT_EPILOGUE
|
| 651 |
+
To: bug-bison@gnu.org
|
| 652 |
+
X-Sent: 1 week, 4 days, 14 hours, 38 minutes, 11 seconds ago
|
| 653 |
+
|
| 654 |
+
The other day I had the need for explicitly building the parse tree. I
|
| 655 |
+
used %locations for that and defined YYLLOC_DEFAULT to call a function
|
| 656 |
+
that returns the tree node for the production. Easy. But I also needed
|
| 657 |
+
to assign the S-attribute to the tree node. That cannot be done in
|
| 658 |
+
YYLLOC_DEFAULT, because it is invoked before the action is executed.
|
| 659 |
+
The way I solved this was to define a macro YYACT_EPILOGUE that would
|
| 660 |
+
be invoked after the action. For reasons of symmetry I also added
|
| 661 |
+
YYACT_PROLOGUE. Although I had no use for that I can envision how it
|
| 662 |
+
might come in handy for debugging purposes.
|
| 663 |
+
All is needed is to add
|
| 664 |
+
|
| 665 |
+
#if YYLSP_NEEDED
|
| 666 |
+
YYACT_EPILOGUE (yyval, (yyvsp - yylen), yylen, yyloc, (yylsp - yylen));
|
| 667 |
+
#else
|
| 668 |
+
YYACT_EPILOGUE (yyval, (yyvsp - yylen), yylen);
|
| 669 |
+
#endif
|
| 670 |
+
|
| 671 |
+
at the proper place to bison.simple. Ditto for YYACT_PROLOGUE.
|
| 672 |
+
|
| 673 |
+
I was wondering what you think about adding YYACT_PROLOGUE/EPILOGUE
|
| 674 |
+
to bison. If you're interested, I'll work on a patch.
|
| 675 |
+
|
| 676 |
+
* Better graphics
|
| 677 |
+
Equip the parser with a means to create the (visual) parse tree.
|
| 678 |
+
|
| 679 |
+
|
| 680 |
+
-----
|
| 681 |
+
|
| 682 |
+
# LocalWords: Cex gnulib gl Bistromathic TokenKinds yylex enum YYEOF EOF
|
| 683 |
+
# LocalWords: YYerror gettext af hb YYERRCODE undef calc FIXME dev yyerror
|
| 684 |
+
# LocalWords: Autoconf YYUNDEFTOK lexemes parsers Bistromathic's yyreport
|
| 685 |
+
# LocalWords: const argc yacc yyclearin lookahead destructor Rici incluent
|
| 686 |
+
# LocalWords: yydestruct yydiscardin catégories d'avertissements sr activé
|
| 687 |
+
# LocalWords: conflits défaut rr l'alias chaîne n'est attaché un symbole
|
| 688 |
+
# LocalWords: obsolète règle vide midrule valeurs de intermédiaire ou avec
|
| 689 |
+
# LocalWords: définies inutilisées priorité associativité inutiles POSIX
|
| 690 |
+
# LocalWords: incompatibilités tous les autres avertissements sauf dans rp
|
| 691 |
+
# LocalWords: désactiver CATEGORIE traiter comme des erreurs glr Akim bool
|
| 692 |
+
# LocalWords: Demaille arith lalr goto struct pathlen nullable ntokens lr
|
| 693 |
+
# LocalWords: nterm bitsetv ielr ritem nstates nrules nritems yysymbol EQ
|
| 694 |
+
# LocalWords: SymbolKind YYEMPTY YYUNDEF YYTNAME NUM yyntokens yytname sed
|
| 695 |
+
# LocalWords: nonterminals yykind yycode YYNAMES yynames init getName conv
|
| 696 |
+
# LocalWords: TokenKind ival yychar yylval yylexer Tolmer hoc
|
| 697 |
+
# LocalWords: Sobisch YYPTRDIFF ptrdiff Autotest toknum yytoknum
|
| 698 |
+
# LocalWords: sym Wother stderr FP fixits xgettext fdiagnostics Graphviz
|
| 699 |
+
# LocalWords: graphviz VCG bitset xml bw maint yytoken YYABORT deps
|
| 700 |
+
# LocalWords: YYACCEPT yytranslate nonnegative destructors yyerrlab repo
|
| 701 |
+
# LocalWords: backends stmt expr yy Mardle baz qux Vadim Maslow CPP cpp
|
| 702 |
+
# LocalWords: yydebug gcc UCHAR EBCDIC gung PDP NUL Pre Florian Krohm utf
|
| 703 |
+
# LocalWords: YYACT YYLLOC YYLSP yyval yyvsp yylen yyloc yylsp endif
|
| 704 |
+
# LocalWords: ispell american
|
| 705 |
+
|
| 706 |
+
Local Variables:
|
| 707 |
+
mode: outline
|
| 708 |
+
coding: utf-8
|
| 709 |
+
fill-column: 76
|
| 710 |
+
ispell-dictionary: "american"
|
| 711 |
+
End:
|
| 712 |
+
|
| 713 |
+
Copyright (C) 2001-2004, 2006, 2008-2015, 2018-2021 Free Software
|
| 714 |
+
Foundation, Inc.
|
| 715 |
+
|
| 716 |
+
This file is part of Bison, the GNU Compiler Compiler.
|
| 717 |
+
|
| 718 |
+
Permission is granted to copy, distribute and/or modify this document
|
| 719 |
+
under the terms of the GNU Free Documentation License, Version 1.3 or
|
| 720 |
+
any later version published by the Free Software Foundation; with no
|
| 721 |
+
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
| 722 |
+
Texts. A copy of the license is included in the "GNU Free
|
| 723 |
+
Documentation License" file as part of this distribution.
|
platform/dbops/binaries/build/share/doc/bison/examples/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This directory contains examples of Bison grammar files, sorted per
|
| 2 |
+
language.
|
| 3 |
+
|
| 4 |
+
Several of them come from the documentation, which should be installed
|
| 5 |
+
together with Bison. The URLs are provided for convenience.
|
| 6 |
+
|
| 7 |
+
These examples come with a README and a Makefile. Not only can they be used
|
| 8 |
+
to toy with Bison, they can also be starting points for your own grammars.
|
| 9 |
+
|
| 10 |
+
Please, be sure to read the C examples before looking at the other
|
| 11 |
+
languages, as these examples are simpler.
|
| 12 |
+
|
| 13 |
+
<!---
|
| 14 |
+
|
| 15 |
+
Local Variables:
|
| 16 |
+
fill-column: 76
|
| 17 |
+
ispell-dictionary: "american"
|
| 18 |
+
End:
|
| 19 |
+
|
| 20 |
+
Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
| 21 |
+
|
| 22 |
+
Permission is granted to copy, distribute and/or modify this document
|
| 23 |
+
under the terms of the GNU Free Documentation License, Version 1.3 or
|
| 24 |
+
any later version published by the Free Software Foundation; with no
|
| 25 |
+
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
| 26 |
+
Texts. A copy of the license is included in the "GNU Free
|
| 27 |
+
Documentation License" file as part of this distribution.
|
| 28 |
+
--->
|
platform/dbops/binaries/build/share/doc/bison/examples/c++/Makefile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This Makefile is designed to be simple and readable. It does not
|
| 2 |
+
# aim at portability. It requires GNU Make.
|
| 3 |
+
|
| 4 |
+
BISON = bison
|
| 5 |
+
CXX = g++
|
| 6 |
+
CXXFLAGS =
|
| 7 |
+
PROGS = simple variant variant-11
|
| 8 |
+
|
| 9 |
+
simple: CXXFLAGS = -std=c++14
|
| 10 |
+
variant-11: CXXFLAGS = -std=c++11
|
| 11 |
+
|
| 12 |
+
all: $(PROGS)
|
| 13 |
+
|
| 14 |
+
%.cc %.hh %.html %.gv: %.yy
|
| 15 |
+
$(BISON) $(BISONFLAGS) --html --graph -o $*.cc $<
|
| 16 |
+
|
| 17 |
+
%: %.cc
|
| 18 |
+
$(CXX) $(CXXFLAGS) -o$@ $<
|
| 19 |
+
|
| 20 |
+
clean:
|
| 21 |
+
rm -f $(PROGS:=.cc) $(PROGS)
|
platform/dbops/binaries/build/share/doc/bison/examples/c++/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Examples in C++
|
| 2 |
+
|
| 3 |
+
This directory contains examples of Bison grammar files in C++.
|
| 4 |
+
|
| 5 |
+
You can run `make` to compile these examples. And `make clean` to tidy
|
| 6 |
+
afterwards.
|
| 7 |
+
|
| 8 |
+
## simple.yy - Simple example in C++14
|
| 9 |
+
A very simple example in C++, based on variants and symbol constructors.
|
| 10 |
+
Variants allow to use any C++ type as semantic value type, and symbol
|
| 11 |
+
constructors ensure consistency between declared token kind and effective
|
| 12 |
+
semantic value.
|
| 13 |
+
|
| 14 |
+
Run as `./simple`.
|
| 15 |
+
|
| 16 |
+
Extracted from the documentation: [A Simple C++
|
| 17 |
+
Example](https://www.gnu.org/software/bison/manual/html_node/A-Simple-C_002b_002b-Example.html).
|
| 18 |
+
|
| 19 |
+
## variant.yy - Self-contained example in C++98
|
| 20 |
+
A variation of simple.yy, in C++98.
|
| 21 |
+
|
| 22 |
+
Run as `./variant`.
|
| 23 |
+
|
| 24 |
+
## variant-11.yy - Self-contained example in modern C++
|
| 25 |
+
Another variation of simple.yy, closely related to the previous one, but
|
| 26 |
+
exhibiting support for C++11's move semantics.
|
| 27 |
+
|
| 28 |
+
Run as `./variant` or `./variant NUMBER`.
|
| 29 |
+
|
| 30 |
+
## calc++ - A Complete C++ Example
|
| 31 |
+
A fully featured C++ version of the canonical example for parsers: a
|
| 32 |
+
calculator. Also uses Flex for the scanner.
|
| 33 |
+
|
| 34 |
+
Don't look at this example first: it is fully featured and can serve as a
|
| 35 |
+
starting point for a clean parser in C++. The previous examples are better
|
| 36 |
+
introductory examples, and the C examples are also useful introductory
|
| 37 |
+
examples.
|
| 38 |
+
|
| 39 |
+
Extracted from the documentation: [A Complete C++
|
| 40 |
+
Example](https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html).
|
| 41 |
+
|
| 42 |
+
## glr
|
| 43 |
+
|
| 44 |
+
This example demonstrates the use of GLR parsers to handle (local)
|
| 45 |
+
ambiguities in the C++ language. See the node "Merging GLR Parses" in
|
| 46 |
+
Bison's documentation.
|
| 47 |
+
|
| 48 |
+
It uses (Bison) variants to store objects as semantic values. It also
|
| 49 |
+
demonstrates custom error messages in C++.
|
| 50 |
+
|
| 51 |
+
<!---
|
| 52 |
+
|
| 53 |
+
Local Variables:
|
| 54 |
+
fill-column: 76
|
| 55 |
+
ispell-dictionary: "american"
|
| 56 |
+
End:
|
| 57 |
+
|
| 58 |
+
Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
| 59 |
+
|
| 60 |
+
Permission is granted to copy, distribute and/or modify this document
|
| 61 |
+
under the terms of the GNU Free Documentation License, Version 1.3 or
|
| 62 |
+
any later version published by the Free Software Foundation; with no
|
| 63 |
+
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
| 64 |
+
Texts. A copy of the license is included in the "GNU Free
|
| 65 |
+
Documentation License" file as part of this distribution.
|
| 66 |
+
|
| 67 |
+
LocalWords: mfcalc calc parsers yy ispell american
|
| 68 |
+
--->
|
platform/dbops/binaries/build/share/doc/bison/examples/c++/calc++/Makefile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This Makefile is designed to be simple and readable. It does not
|
| 2 |
+
# aim at portability. It requires GNU Make.
|
| 3 |
+
|
| 4 |
+
BASE = calc++
|
| 5 |
+
BISON = bison
|
| 6 |
+
CXX = g++
|
| 7 |
+
FLEX = flex
|
| 8 |
+
|
| 9 |
+
all: $(BASE)
|
| 10 |
+
|
| 11 |
+
%.cc %.hh %.html %.gv: %.yy
|
| 12 |
+
$(BISON) $(BISONFLAGS) --html --graph -o $*.cc $<
|
| 13 |
+
|
| 14 |
+
%.cc: %.ll
|
| 15 |
+
$(FLEX) $(FLEXFLAGS) -o$@ $<
|
| 16 |
+
|
| 17 |
+
%.o: %.cc
|
| 18 |
+
$(CXX) $(CXXFLAGS) -c -o$@ $<
|
| 19 |
+
|
| 20 |
+
$(BASE): $(BASE).o driver.o parser.o scanner.o
|
| 21 |
+
$(CXX) -o $@ $^
|
| 22 |
+
|
| 23 |
+
$(BASE).o: parser.hh
|
| 24 |
+
parser.o: parser.hh
|
| 25 |
+
scanner.o: parser.hh
|
| 26 |
+
|
| 27 |
+
run: $(BASE)
|
| 28 |
+
@echo "Type arithmetic expressions. Quit with ctrl-d."
|
| 29 |
+
./$< -
|
| 30 |
+
|
| 31 |
+
CLEANFILES = \
|
| 32 |
+
$(BASE) *.o \
|
| 33 |
+
parser.hh parser.cc parser.output parser.xml parser.html parser.gv location.hh \
|
| 34 |
+
scanner.cc
|
| 35 |
+
clean:
|
| 36 |
+
rm -f $(CLEANFILES)
|
platform/dbops/binaries/build/share/doc/bison/examples/c++/calc++/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# calc++ - A Flex+Bison calculator
|
| 2 |
+
|
| 3 |
+
This directory contains calc++, a Bison grammar file in C++. If you never
|
| 4 |
+
saw the traditional implementation in C, please first read
|
| 5 |
+
examples/c/lexcalc, which can be seen as a C precursor of this example.
|
| 6 |
+
|
| 7 |
+
Read the corresponding chapter in the documentation: "A Complete C++
|
| 8 |
+
Example". It is also available [on
|
| 9 |
+
line](https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html)
|
| 10 |
+
(maybe with a different version of Bison).
|
| 11 |
+
|
| 12 |
+
To use it, copy this directory into some work directory, and run `make` to
|
| 13 |
+
compile the executable, and try it. It is a simple calculator which accepts
|
| 14 |
+
several variable definitions, one per line, and then a single expression to
|
| 15 |
+
evaluate.
|
| 16 |
+
|
| 17 |
+
The program calc++ expects the file to parse as argument; pass `-` to read
|
| 18 |
+
the standard input (and then hit <Ctrl-d>, control-d, to end your input).
|
| 19 |
+
|
| 20 |
+
```
|
| 21 |
+
$ ./calc++ -
|
| 22 |
+
one := 1
|
| 23 |
+
two := 2
|
| 24 |
+
three := 3
|
| 25 |
+
(one + two * three) * two * three
|
| 26 |
+
<Ctrl-d>
|
| 27 |
+
42
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
You may pass `-p` to activate the parser debug traces, and `-s` to activate
|
| 31 |
+
the scanner's.
|
| 32 |
+
|
| 33 |
+
<!---
|
| 34 |
+
Local Variables:
|
| 35 |
+
fill-column: 76
|
| 36 |
+
ispell-dictionary: "american"
|
| 37 |
+
End:
|
| 38 |
+
|
| 39 |
+
Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
| 40 |
+
|
| 41 |
+
Permission is granted to copy, distribute and/or modify this document
|
| 42 |
+
under the terms of the GNU Free Documentation License, Version 1.3 or
|
| 43 |
+
any later version published by the Free Software Foundation; with no
|
| 44 |
+
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
| 45 |
+
Texts. A copy of the license is included in the "GNU Free
|
| 46 |
+
Documentation License" file as part of this distribution.
|
| 47 |
+
|
| 48 |
+
LocalWords: calc parsers yy MERCHANTABILITY Ctrl ispell american
|
| 49 |
+
--->
|
platform/dbops/binaries/build/share/doc/bison/examples/c++/calc++/calc++.cc
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Main for calc++. -*- C++ -*-
|
| 2 |
+
|
| 3 |
+
Copyright (C) 2005-2015, 2018-2021 Free Software Foundation, Inc.
|
| 4 |
+
|
| 5 |
+
This file is part of Bison, the GNU Compiler Compiler.
|
| 6 |
+
|
| 7 |
+
This program is free software: you can redistribute it and/or modify
|
| 8 |
+
it under the terms of the GNU General Public License as published by
|
| 9 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 10 |
+
(at your option) any later version.
|
| 11 |
+
|
| 12 |
+
This program is distributed in the hope that it will be useful,
|
| 13 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
GNU General Public License for more details.
|
| 16 |
+
|
| 17 |
+
You should have received a copy of the GNU General Public License
|
| 18 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
| 19 |
+
|
| 20 |
+
#include <iostream>
|
| 21 |
+
#include "driver.hh"
|
| 22 |
+
|
| 23 |
+
int
|
| 24 |
+
main (int argc, char *argv[])
|
| 25 |
+
{
|
| 26 |
+
int res = 0;
|
| 27 |
+
driver drv;
|
| 28 |
+
for (int i = 1; i < argc; ++i)
|
| 29 |
+
if (argv[i] == std::string ("-p"))
|
| 30 |
+
drv.trace_parsing = true;
|
| 31 |
+
else if (argv[i] == std::string ("-s"))
|
| 32 |
+
drv.trace_scanning = true;
|
| 33 |
+
else if (!drv.parse (argv[i]))
|
| 34 |
+
std::cout << drv.result << '\n';
|
| 35 |
+
else
|
| 36 |
+
res = 1;
|
| 37 |
+
return res;
|
| 38 |
+
}
|
platform/dbops/binaries/build/share/doc/bison/examples/c++/calc++/driver.cc
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Driver for calc++. -*- C++ -*-
|
| 2 |
+
|
| 3 |
+
Copyright (C) 2005-2015, 2018-2021 Free Software Foundation, Inc.
|
| 4 |
+
|
| 5 |
+
This file is part of Bison, the GNU Compiler Compiler.
|
| 6 |
+
|
| 7 |
+
This program is free software: you can redistribute it and/or modify
|
| 8 |
+
it under the terms of the GNU General Public License as published by
|
| 9 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 10 |
+
(at your option) any later version.
|
| 11 |
+
|
| 12 |
+
This program is distributed in the hope that it will be useful,
|
| 13 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
GNU General Public License for more details.
|
| 16 |
+
|
| 17 |
+
You should have received a copy of the GNU General Public License
|
| 18 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
| 19 |
+
|
| 20 |
+
#include "driver.hh"
|
| 21 |
+
#include "parser.hh"
|
| 22 |
+
|
| 23 |
+
driver::driver ()
|
| 24 |
+
: trace_parsing (false), trace_scanning (false)
|
| 25 |
+
{
|
| 26 |
+
variables["one"] = 1;
|
| 27 |
+
variables["two"] = 2;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
int
|
| 31 |
+
driver::parse (const std::string &f)
|
| 32 |
+
{
|
| 33 |
+
file = f;
|
| 34 |
+
location.initialize (&file);
|
| 35 |
+
scan_begin ();
|
| 36 |
+
yy::parser parse (*this);
|
| 37 |
+
parse.set_debug_level (trace_parsing);
|
| 38 |
+
int res = parse ();
|
| 39 |
+
scan_end ();
|
| 40 |
+
return res;
|
| 41 |
+
}
|
platform/dbops/binaries/build/share/doc/bison/examples/c++/calc++/driver.hh
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Driver for calc++. -*- C++ -*-
|
| 2 |
+
|
| 3 |
+
Copyright (C) 2005-2015, 2018-2021 Free Software Foundation, Inc.
|
| 4 |
+
|
| 5 |
+
This file is part of Bison, the GNU Compiler Compiler.
|
| 6 |
+
|
| 7 |
+
This program is free software: you can redistribute it and/or modify
|
| 8 |
+
it under the terms of the GNU General Public License as published by
|
| 9 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 10 |
+
(at your option) any later version.
|
| 11 |
+
|
| 12 |
+
This program is distributed in the hope that it will be useful,
|
| 13 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
GNU General Public License for more details.
|
| 16 |
+
|
| 17 |
+
You should have received a copy of the GNU General Public License
|
| 18 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
| 19 |
+
|
| 20 |
+
#ifndef DRIVER_HH
|
| 21 |
+
# define DRIVER_HH
|
| 22 |
+
# include <string>
|
| 23 |
+
# include <map>
|
| 24 |
+
# include "parser.hh"
|
| 25 |
+
|
| 26 |
+
// Give Flex the prototype of yylex we want ...
|
| 27 |
+
# define YY_DECL \
|
| 28 |
+
yy::parser::symbol_type yylex (driver& drv)
|
| 29 |
+
// ... and declare it for the parser's sake.
|
| 30 |
+
YY_DECL;
|
| 31 |
+
|
| 32 |
+
// Conducting the whole scanning and parsing of Calc++.
|
| 33 |
+
class driver
|
| 34 |
+
{
|
| 35 |
+
public:
|
| 36 |
+
driver ();
|
| 37 |
+
|
| 38 |
+
std::map<std::string, int> variables;
|
| 39 |
+
|
| 40 |
+
int result;
|
| 41 |
+
|
| 42 |
+
// Run the parser on file F. Return 0 on success.
|
| 43 |
+
int parse (const std::string& f);
|
| 44 |
+
// The name of the file being parsed.
|
| 45 |
+
std::string file;
|
| 46 |
+
// Whether to generate parser debug traces.
|
| 47 |
+
bool trace_parsing;
|
| 48 |
+
|
| 49 |
+
// Handling the scanner.
|
| 50 |
+
void scan_begin ();
|
| 51 |
+
void scan_end ();
|
| 52 |
+
// Whether to generate scanner debug traces.
|
| 53 |
+
bool trace_scanning;
|
| 54 |
+
// The token's location used by the scanner.
|
| 55 |
+
yy::location location;
|
| 56 |
+
};
|
| 57 |
+
#endif // ! DRIVER_HH
|
platform/dbops/binaries/build/share/doc/bison/examples/c++/calc++/parser.yy
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Parser for calc++. -*- C++ -*-
|
| 2 |
+
|
| 3 |
+
Copyright (C) 2005-2015, 2018-2021 Free Software Foundation, Inc.
|
| 4 |
+
|
| 5 |
+
This file is part of Bison, the GNU Compiler Compiler.
|
| 6 |
+
|
| 7 |
+
This program is free software: you can redistribute it and/or modify
|
| 8 |
+
it under the terms of the GNU General Public License as published by
|
| 9 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 10 |
+
(at your option) any later version.
|
| 11 |
+
|
| 12 |
+
This program is distributed in the hope that it will be useful,
|
| 13 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
GNU General Public License for more details.
|
| 16 |
+
|
| 17 |
+
You should have received a copy of the GNU General Public License
|
| 18 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
| 19 |
+
|
| 20 |
+
%skeleton "lalr1.cc" // -*- C++ -*-
|
| 21 |
+
%require "3.8.2"
|
| 22 |
+
%header
|
| 23 |
+
|
| 24 |
+
%define api.token.raw
|
| 25 |
+
|
| 26 |
+
%define api.token.constructor
|
| 27 |
+
%define api.value.type variant
|
| 28 |
+
%define parse.assert
|
| 29 |
+
|
| 30 |
+
%code requires {
|
| 31 |
+
# include <string>
|
| 32 |
+
class driver;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
// The parsing context.
|
| 36 |
+
%param { driver& drv }
|
| 37 |
+
|
| 38 |
+
%locations
|
| 39 |
+
|
| 40 |
+
%define parse.trace
|
| 41 |
+
%define parse.error detailed
|
| 42 |
+
%define parse.lac full
|
| 43 |
+
|
| 44 |
+
%code {
|
| 45 |
+
# include "driver.hh"
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
%define api.token.prefix {TOK_}
|
| 49 |
+
%token
|
| 50 |
+
ASSIGN ":="
|
| 51 |
+
MINUS "-"
|
| 52 |
+
PLUS "+"
|
| 53 |
+
STAR "*"
|
| 54 |
+
SLASH "/"
|
| 55 |
+
LPAREN "("
|
| 56 |
+
RPAREN ")"
|
| 57 |
+
;
|
| 58 |
+
|
| 59 |
+
%token <std::string> IDENTIFIER "identifier"
|
| 60 |
+
%token <int> NUMBER "number"
|
| 61 |
+
%nterm <int> exp
|
| 62 |
+
|
| 63 |
+
%printer { yyo << $$; } <*>;
|
| 64 |
+
|
| 65 |
+
%%
|
| 66 |
+
%start unit;
|
| 67 |
+
unit: assignments exp { drv.result = $2; };
|
| 68 |
+
|
| 69 |
+
assignments:
|
| 70 |
+
%empty {}
|
| 71 |
+
| assignments assignment {};
|
| 72 |
+
|
| 73 |
+
assignment:
|
| 74 |
+
"identifier" ":=" exp { drv.variables[$1] = $3; };
|
| 75 |
+
|
| 76 |
+
%left "+" "-";
|
| 77 |
+
%left "*" "/";
|
| 78 |
+
exp:
|
| 79 |
+
"number"
|
| 80 |
+
| "identifier" { $$ = drv.variables[$1]; }
|
| 81 |
+
| exp "+" exp { $$ = $1 + $3; }
|
| 82 |
+
| exp "-" exp { $$ = $1 - $3; }
|
| 83 |
+
| exp "*" exp { $$ = $1 * $3; }
|
| 84 |
+
| exp "/" exp { $$ = $1 / $3; }
|
| 85 |
+
| "(" exp ")" { $$ = $2; }
|
| 86 |
+
%%
|
| 87 |
+
|
| 88 |
+
void
|
| 89 |
+
yy::parser::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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Scanner for calc++. -*- C++ -*-
|
| 2 |
+
|
| 3 |
+
Copyright (C) 2005-2015, 2018-2021 Free Software Foundation, Inc.
|
| 4 |
+
|
| 5 |
+
This file is part of Bison, the GNU Compiler Compiler.
|
| 6 |
+
|
| 7 |
+
This program is free software: you can redistribute it and/or modify
|
| 8 |
+
it under the terms of the GNU General Public License as published by
|
| 9 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 10 |
+
(at your option) any later version.
|
| 11 |
+
|
| 12 |
+
This program is distributed in the hope that it will be useful,
|
| 13 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
GNU General Public License for more details.
|
| 16 |
+
|
| 17 |
+
You should have received a copy of the GNU General Public License
|
| 18 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
| 19 |
+
|
| 20 |
+
%{ /* -*- C++ -*- */
|
| 21 |
+
# include <cerrno>
|
| 22 |
+
# include <climits>
|
| 23 |
+
# include <cstdlib>
|
| 24 |
+
# include <cstring> // strerror
|
| 25 |
+
# include <string>
|
| 26 |
+
# include "driver.hh"
|
| 27 |
+
# include "parser.hh"
|
| 28 |
+
%}
|
| 29 |
+
|
| 30 |
+
%{
|
| 31 |
+
#if defined __clang__
|
| 32 |
+
# define CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
|
| 33 |
+
#endif
|
| 34 |
+
|
| 35 |
+
// Clang and ICC like to pretend they are GCC.
|
| 36 |
+
#if defined __GNUC__ && !defined __clang__ && !defined __ICC
|
| 37 |
+
# define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
| 38 |
+
#endif
|
| 39 |
+
|
| 40 |
+
// Pacify warnings in yy_init_buffer (observed with Flex 2.6.4)
|
| 41 |
+
// and GCC 6.4.0, 7.3.0 with -O3.
|
| 42 |
+
#if defined GCC_VERSION && 600 <= GCC_VERSION
|
| 43 |
+
# pragma GCC diagnostic ignored "-Wnull-dereference"
|
| 44 |
+
#endif
|
| 45 |
+
|
| 46 |
+
// This example uses Flex's C back end, yet compiles it as C++.
|
| 47 |
+
// So expect warnings about C style casts and NULL.
|
| 48 |
+
#if defined CLANG_VERSION && 500 <= CLANG_VERSION
|
| 49 |
+
# pragma clang diagnostic ignored "-Wold-style-cast"
|
| 50 |
+
# pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
| 51 |
+
#elif defined GCC_VERSION && 407 <= GCC_VERSION
|
| 52 |
+
# pragma GCC diagnostic ignored "-Wold-style-cast"
|
| 53 |
+
# pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
|
| 54 |
+
#endif
|
| 55 |
+
|
| 56 |
+
#define FLEX_VERSION (YY_FLEX_MAJOR_VERSION * 100 + YY_FLEX_MINOR_VERSION)
|
| 57 |
+
|
| 58 |
+
// Old versions of Flex (2.5.35) generate an incomplete documentation comment.
|
| 59 |
+
//
|
| 60 |
+
// In file included from src/scan-code-c.c:3:
|
| 61 |
+
// src/scan-code.c:2198:21: error: empty paragraph passed to '@param' command
|
| 62 |
+
// [-Werror,-Wdocumentation]
|
| 63 |
+
// * @param line_number
|
| 64 |
+
// ~~~~~~~~~~~~~~~~~^
|
| 65 |
+
// 1 error generated.
|
| 66 |
+
#if FLEX_VERSION < 206 && defined CLANG_VERSION
|
| 67 |
+
# pragma clang diagnostic ignored "-Wdocumentation"
|
| 68 |
+
#endif
|
| 69 |
+
|
| 70 |
+
// Old versions of Flex (2.5.35) use 'register'. Warnings introduced in
|
| 71 |
+
// GCC 7 and Clang 6.
|
| 72 |
+
#if FLEX_VERSION < 206
|
| 73 |
+
# if defined CLANG_VERSION && 600 <= CLANG_VERSION
|
| 74 |
+
# pragma clang diagnostic ignored "-Wdeprecated-register"
|
| 75 |
+
# elif defined GCC_VERSION && 700 <= GCC_VERSION
|
| 76 |
+
# pragma GCC diagnostic ignored "-Wregister"
|
| 77 |
+
# endif
|
| 78 |
+
#endif
|
| 79 |
+
|
| 80 |
+
#if FLEX_VERSION < 206
|
| 81 |
+
# if defined CLANG_VERSION
|
| 82 |
+
# pragma clang diagnostic ignored "-Wconversion"
|
| 83 |
+
# pragma clang diagnostic ignored "-Wdocumentation"
|
| 84 |
+
# pragma clang diagnostic ignored "-Wshorten-64-to-32"
|
| 85 |
+
# pragma clang diagnostic ignored "-Wsign-conversion"
|
| 86 |
+
# elif defined GCC_VERSION
|
| 87 |
+
# pragma GCC diagnostic ignored "-Wconversion"
|
| 88 |
+
# pragma GCC diagnostic ignored "-Wsign-conversion"
|
| 89 |
+
# endif
|
| 90 |
+
#endif
|
| 91 |
+
|
| 92 |
+
// Flex 2.6.4, GCC 9
|
| 93 |
+
// warning: useless cast to type 'int' [-Wuseless-cast]
|
| 94 |
+
// 1361 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
|
| 95 |
+
// | ^
|
| 96 |
+
#if defined GCC_VERSION && 900 <= GCC_VERSION
|
| 97 |
+
# pragma GCC diagnostic ignored "-Wuseless-cast"
|
| 98 |
+
#endif
|
| 99 |
+
%}
|
| 100 |
+
|
| 101 |
+
%option noyywrap nounput noinput batch debug
|
| 102 |
+
|
| 103 |
+
%{
|
| 104 |
+
// A number symbol corresponding to the value in S.
|
| 105 |
+
yy::parser::symbol_type
|
| 106 |
+
make_NUMBER (const std::string &s, const yy::parser::location_type& loc);
|
| 107 |
+
%}
|
| 108 |
+
|
| 109 |
+
id [a-zA-Z][a-zA-Z_0-9]*
|
| 110 |
+
int [0-9]+
|
| 111 |
+
blank [ \t\r]
|
| 112 |
+
|
| 113 |
+
%{
|
| 114 |
+
// Code run each time a pattern is matched.
|
| 115 |
+
# define YY_USER_ACTION loc.columns (yyleng);
|
| 116 |
+
%}
|
| 117 |
+
%%
|
| 118 |
+
%{
|
| 119 |
+
// A handy shortcut to the location held by the driver.
|
| 120 |
+
yy::location& loc = drv.location;
|
| 121 |
+
// Code run each time yylex is called.
|
| 122 |
+
loc.step ();
|
| 123 |
+
%}
|
| 124 |
+
{blank}+ loc.step ();
|
| 125 |
+
\n+ loc.lines (yyleng); loc.step ();
|
| 126 |
+
|
| 127 |
+
"-" return yy::parser::make_MINUS (loc);
|
| 128 |
+
"+" return yy::parser::make_PLUS (loc);
|
| 129 |
+
"*" return yy::parser::make_STAR (loc);
|
| 130 |
+
"/" return yy::parser::make_SLASH (loc);
|
| 131 |
+
"(" return yy::parser::make_LPAREN (loc);
|
| 132 |
+
")" return yy::parser::make_RPAREN (loc);
|
| 133 |
+
":=" return yy::parser::make_ASSIGN (loc);
|
| 134 |
+
|
| 135 |
+
{int} return make_NUMBER (yytext, loc);
|
| 136 |
+
{id} return yy::parser::make_IDENTIFIER (yytext, loc);
|
| 137 |
+
. {
|
| 138 |
+
throw yy::parser::syntax_error
|
| 139 |
+
(loc, "invalid character: " + std::string(yytext));
|
| 140 |
+
}
|
| 141 |
+
<<EOF>> return yy::parser::make_YYEOF (loc);
|
| 142 |
+
%%
|
| 143 |
+
|
| 144 |
+
yy::parser::symbol_type
|
| 145 |
+
make_NUMBER (const std::string &s, const yy::parser::location_type& loc)
|
| 146 |
+
{
|
| 147 |
+
errno = 0;
|
| 148 |
+
long n = strtol (s.c_str(), NULL, 10);
|
| 149 |
+
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
|
| 150 |
+
throw yy::parser::syntax_error (loc, "integer is out of range: " + s);
|
| 151 |
+
return yy::parser::make_NUMBER ((int) n, loc);
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
void
|
| 155 |
+
driver::scan_begin ()
|
| 156 |
+
{
|
| 157 |
+
yy_flex_debug = trace_scanning;
|
| 158 |
+
if (file.empty () || file == "-")
|
| 159 |
+
yyin = stdin;
|
| 160 |
+
else if (!(yyin = fopen (file.c_str (), "r")))
|
| 161 |
+
{
|
| 162 |
+
std::cerr << "cannot open " << file << ": " << strerror (errno) << '\n';
|
| 163 |
+
exit (EXIT_FAILURE);
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
void
|
| 168 |
+
driver::scan_end ()
|
| 169 |
+
{
|
| 170 |
+
fclose (yyin);
|
| 171 |
+
}
|
platform/dbops/binaries/build/share/doc/bison/examples/c++/simple.yy
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Simple variant-based parser. -*- C++ -*-
|
| 2 |
+
|
| 3 |
+
Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
| 4 |
+
|
| 5 |
+
This file is part of Bison, the GNU Compiler Compiler.
|
| 6 |
+
|
| 7 |
+
This program is free software: you can redistribute it and/or modify
|
| 8 |
+
it under the terms of the GNU General Public License as published by
|
| 9 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 10 |
+
(at your option) any later version.
|
| 11 |
+
|
| 12 |
+
This program is distributed in the hope that it will be useful,
|
| 13 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
GNU General Public License for more details.
|
| 16 |
+
|
| 17 |
+
You should have received a copy of the GNU General Public License
|
| 18 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
| 19 |
+
|
| 20 |
+
%require "3.2"
|
| 21 |
+
%language "c++"
|
| 22 |
+
|
| 23 |
+
%define api.value.type variant
|
| 24 |
+
|
| 25 |
+
%code
|
| 26 |
+
{
|
| 27 |
+
// Print a list of strings.
|
| 28 |
+
auto
|
| 29 |
+
operator<< (std::ostream& o, const std::vector<std::string>& ss)
|
| 30 |
+
-> std::ostream&
|
| 31 |
+
{
|
| 32 |
+
o << '{';
|
| 33 |
+
const char *sep = "";
|
| 34 |
+
for (const auto& s: ss)
|
| 35 |
+
{
|
| 36 |
+
o << sep << s;
|
| 37 |
+
sep = ", ";
|
| 38 |
+
}
|
| 39 |
+
return o << '}';
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
%define api.token.constructor
|
| 44 |
+
|
| 45 |
+
%code
|
| 46 |
+
{
|
| 47 |
+
namespace yy
|
| 48 |
+
{
|
| 49 |
+
// Return the next token.
|
| 50 |
+
auto yylex () -> parser::symbol_type
|
| 51 |
+
{
|
| 52 |
+
static int count = 0;
|
| 53 |
+
switch (int stage = count++)
|
| 54 |
+
{
|
| 55 |
+
case 0:
|
| 56 |
+
return parser::make_TEXT ("I have three numbers for you.");
|
| 57 |
+
case 1: case 2: case 3:
|
| 58 |
+
return parser::make_NUMBER (stage);
|
| 59 |
+
case 4:
|
| 60 |
+
return parser::make_TEXT ("And that's all!");
|
| 61 |
+
default:
|
| 62 |
+
return parser::make_YYEOF ();
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
%%
|
| 68 |
+
result:
|
| 69 |
+
list { std::cout << $1 << '\n'; }
|
| 70 |
+
;
|
| 71 |
+
|
| 72 |
+
%nterm <std::vector<std::string>> list;
|
| 73 |
+
list:
|
| 74 |
+
%empty { /* Generates an empty string list */ }
|
| 75 |
+
| list item { $$ = $1; $$.push_back ($2); }
|
| 76 |
+
;
|
| 77 |
+
|
| 78 |
+
%nterm <std::string> item;
|
| 79 |
+
%token <std::string> TEXT;
|
| 80 |
+
%token <int> NUMBER;
|
| 81 |
+
item:
|
| 82 |
+
TEXT
|
| 83 |
+
| NUMBER { $$ = std::to_string ($1); }
|
| 84 |
+
;
|
| 85 |
+
%%
|
| 86 |
+
namespace yy
|
| 87 |
+
{
|
| 88 |
+
// Report an error to the user.
|
| 89 |
+
auto parser::error (const std::string& msg) -> void
|
| 90 |
+
{
|
| 91 |
+
std::cerr << msg << '\n';
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
int main ()
|
| 96 |
+
{
|
| 97 |
+
yy::parser parse;
|
| 98 |
+
return parse ();
|
| 99 |
+
}
|
platform/dbops/binaries/build/share/doc/bison/examples/c++/variant-11.yy
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
Copyright (C) 2008-2015, 2018-2021 Free Software Foundation, Inc.
|
| 3 |
+
|
| 4 |
+
This program is free software: you can redistribute it and/or modify
|
| 5 |
+
it under the terms of the GNU General Public License as published by
|
| 6 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 7 |
+
(at your option) any later version.
|
| 8 |
+
|
| 9 |
+
This program is distributed in the hope that it will be useful,
|
| 10 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
+
GNU General Public License for more details.
|
| 13 |
+
|
| 14 |
+
You should have received a copy of the GNU General Public License
|
| 15 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
%require "3.2"
|
| 19 |
+
%debug
|
| 20 |
+
%language "c++"
|
| 21 |
+
%define api.token.constructor
|
| 22 |
+
%define api.value.type variant
|
| 23 |
+
%define api.value.automove
|
| 24 |
+
%define api.location.file none
|
| 25 |
+
%define parse.assert
|
| 26 |
+
%locations
|
| 27 |
+
|
| 28 |
+
%code requires // *.hh
|
| 29 |
+
{
|
| 30 |
+
#include <memory> // std::unique_ptr
|
| 31 |
+
#include <string>
|
| 32 |
+
#include <vector>
|
| 33 |
+
|
| 34 |
+
using string_uptr = std::unique_ptr<std::string>;
|
| 35 |
+
using string_uptrs = std::vector<string_uptr>;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
%code // *.cc
|
| 39 |
+
{
|
| 40 |
+
#include <climits> // INT_MIN, INT_MAX
|
| 41 |
+
#include <iostream>
|
| 42 |
+
#include <sstream>
|
| 43 |
+
|
| 44 |
+
namespace yy
|
| 45 |
+
{
|
| 46 |
+
// Prototype of the yylex function providing subsequent tokens.
|
| 47 |
+
static parser::symbol_type yylex ();
|
| 48 |
+
|
| 49 |
+
// Print a vector of strings.
|
| 50 |
+
std::ostream&
|
| 51 |
+
operator<< (std::ostream& o, const string_uptrs& ss)
|
| 52 |
+
{
|
| 53 |
+
o << '{';
|
| 54 |
+
const char *sep = "";
|
| 55 |
+
for (const auto& s: ss)
|
| 56 |
+
{
|
| 57 |
+
o << sep << *s;
|
| 58 |
+
sep = ", ";
|
| 59 |
+
}
|
| 60 |
+
return o << '}';
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
template <typename... Args>
|
| 65 |
+
string_uptr
|
| 66 |
+
make_string_uptr (Args&&... args)
|
| 67 |
+
{
|
| 68 |
+
// std::make_unique is C++14.
|
| 69 |
+
return string_uptr (new std::string{std::forward<Args> (args)...});
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
%token <string_uptr> TEXT;
|
| 74 |
+
%token <int> NUMBER;
|
| 75 |
+
%printer { yyo << '(' << &$$ << ") " << $$; } <*>;
|
| 76 |
+
%printer { yyo << *$$; } <string_uptr>;
|
| 77 |
+
%token END_OF_FILE 0;
|
| 78 |
+
|
| 79 |
+
%type <string_uptr> item;
|
| 80 |
+
%type <string_uptrs> list;
|
| 81 |
+
|
| 82 |
+
%%
|
| 83 |
+
|
| 84 |
+
result:
|
| 85 |
+
list { std::cout << $1 << '\n'; }
|
| 86 |
+
;
|
| 87 |
+
|
| 88 |
+
list:
|
| 89 |
+
%empty { /* Generates an empty string list */ }
|
| 90 |
+
| list item { $$ = $1; $$.emplace_back ($2); }
|
| 91 |
+
;
|
| 92 |
+
|
| 93 |
+
item:
|
| 94 |
+
TEXT
|
| 95 |
+
| NUMBER { $$ = make_string_uptr (std::to_string ($1)); }
|
| 96 |
+
;
|
| 97 |
+
%%
|
| 98 |
+
|
| 99 |
+
// The last number return by the scanner is max - 1.
|
| 100 |
+
int max = 4;
|
| 101 |
+
|
| 102 |
+
namespace yy
|
| 103 |
+
{
|
| 104 |
+
// The yylex function providing subsequent tokens:
|
| 105 |
+
// TEXT "I have three numbers for you."
|
| 106 |
+
// NUMBER 1
|
| 107 |
+
// NUMBER 2
|
| 108 |
+
// NUMBER ...
|
| 109 |
+
// NUMBER max - 1
|
| 110 |
+
// TEXT "And that's all!"
|
| 111 |
+
// END_OF_FILE
|
| 112 |
+
|
| 113 |
+
static
|
| 114 |
+
parser::symbol_type
|
| 115 |
+
yylex ()
|
| 116 |
+
{
|
| 117 |
+
static int count = 0;
|
| 118 |
+
const int stage = count;
|
| 119 |
+
++count;
|
| 120 |
+
auto loc = parser::location_type{nullptr, stage + 1, stage + 1};
|
| 121 |
+
if (stage == 0)
|
| 122 |
+
return parser::make_TEXT (make_string_uptr ("I have numbers for you."), std::move (loc));
|
| 123 |
+
else if (stage < max)
|
| 124 |
+
return parser::make_NUMBER (stage, std::move (loc));
|
| 125 |
+
else if (stage == max)
|
| 126 |
+
return parser::make_TEXT (make_string_uptr ("And that's all!"), std::move (loc));
|
| 127 |
+
else
|
| 128 |
+
return parser::make_END_OF_FILE (std::move (loc));
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
// Mandatory error function
|
| 132 |
+
void
|
| 133 |
+
parser::error (const parser::location_type& loc, const std::string& msg)
|
| 134 |
+
{
|
| 135 |
+
std::cerr << loc << ": " << msg << '\n';
|
| 136 |
+
}
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
int
|
| 140 |
+
main (int argc, const char *argv[])
|
| 141 |
+
{
|
| 142 |
+
if (2 <= argc && isdigit (static_cast<unsigned char> (*argv[1])))
|
| 143 |
+
{
|
| 144 |
+
auto maxl = strtol (argv[1], nullptr, 10);
|
| 145 |
+
max = INT_MIN <= maxl && maxl <= INT_MAX ? int(maxl) : 4;
|
| 146 |
+
}
|
| 147 |
+
auto&& p = yy::parser{};
|
| 148 |
+
p.set_debug_level (!!getenv ("YYDEBUG"));
|
| 149 |
+
return p.parse ();
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
// Local Variables:
|
| 153 |
+
// mode: C++
|
| 154 |
+
// End:
|
platform/dbops/binaries/build/share/doc/bison/examples/c++/variant.yy
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
Copyright (C) 2008-2015, 2018-2021 Free Software Foundation, Inc.
|
| 3 |
+
|
| 4 |
+
This program is free software: you can redistribute it and/or modify
|
| 5 |
+
it under the terms of the GNU General Public License as published by
|
| 6 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 7 |
+
(at your option) any later version.
|
| 8 |
+
|
| 9 |
+
This program is distributed in the hope that it will be useful,
|
| 10 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
+
GNU General Public License for more details.
|
| 13 |
+
|
| 14 |
+
You should have received a copy of the GNU General Public License
|
| 15 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
%require "3.2"
|
| 19 |
+
%debug
|
| 20 |
+
%language "c++"
|
| 21 |
+
%define api.token.constructor
|
| 22 |
+
%define api.value.type variant
|
| 23 |
+
%define api.location.file none
|
| 24 |
+
%define parse.assert
|
| 25 |
+
%locations
|
| 26 |
+
|
| 27 |
+
%code requires // *.hh
|
| 28 |
+
{
|
| 29 |
+
#include <string>
|
| 30 |
+
#include <vector>
|
| 31 |
+
typedef std::vector<std::string> strings_type;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
%code // *.cc
|
| 35 |
+
{
|
| 36 |
+
#include <iostream>
|
| 37 |
+
#include <sstream>
|
| 38 |
+
|
| 39 |
+
namespace yy
|
| 40 |
+
{
|
| 41 |
+
// Prototype of the yylex function providing subsequent tokens.
|
| 42 |
+
static parser::symbol_type yylex ();
|
| 43 |
+
|
| 44 |
+
// Print a vector of strings.
|
| 45 |
+
std::ostream&
|
| 46 |
+
operator<< (std::ostream& o, const strings_type& ss)
|
| 47 |
+
{
|
| 48 |
+
o << '{';
|
| 49 |
+
const char *sep = "";
|
| 50 |
+
for (strings_type::const_iterator i = ss.begin (), end = ss.end ();
|
| 51 |
+
i != end; ++i)
|
| 52 |
+
{
|
| 53 |
+
o << sep << *i;
|
| 54 |
+
sep = ", ";
|
| 55 |
+
}
|
| 56 |
+
return o << '}';
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
// Convert to string.
|
| 61 |
+
template <typename T>
|
| 62 |
+
std::string
|
| 63 |
+
to_string (const T& t)
|
| 64 |
+
{
|
| 65 |
+
std::ostringstream o;
|
| 66 |
+
o << t;
|
| 67 |
+
return o.str ();
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
%token <::std::string> TEXT;
|
| 72 |
+
%token <int> NUMBER;
|
| 73 |
+
%printer { yyo << '(' << &$$ << ") " << $$; } <*>;
|
| 74 |
+
%token END_OF_FILE 0;
|
| 75 |
+
|
| 76 |
+
%type <::std::string> item;
|
| 77 |
+
%type <::std::vector<std::string>> list;
|
| 78 |
+
|
| 79 |
+
%%
|
| 80 |
+
|
| 81 |
+
result:
|
| 82 |
+
list { std::cout << $1 << '\n'; }
|
| 83 |
+
;
|
| 84 |
+
|
| 85 |
+
list:
|
| 86 |
+
%empty { /* Generates an empty string list */ }
|
| 87 |
+
| list item { std::swap ($$, $1); $$.push_back ($2); }
|
| 88 |
+
;
|
| 89 |
+
|
| 90 |
+
item:
|
| 91 |
+
TEXT
|
| 92 |
+
| NUMBER { $$ = to_string ($1); }
|
| 93 |
+
;
|
| 94 |
+
%%
|
| 95 |
+
|
| 96 |
+
namespace yy
|
| 97 |
+
{
|
| 98 |
+
// Use nullptr with pre-C++11.
|
| 99 |
+
#if !defined __cplusplus || __cplusplus < 201103L
|
| 100 |
+
# define NULLPTR 0
|
| 101 |
+
#else
|
| 102 |
+
# define NULLPTR nullptr
|
| 103 |
+
#endif
|
| 104 |
+
|
| 105 |
+
// The yylex function providing subsequent tokens:
|
| 106 |
+
// TEXT "I have three numbers for you."
|
| 107 |
+
// NUMBER 1
|
| 108 |
+
// NUMBER 2
|
| 109 |
+
// NUMBER 3
|
| 110 |
+
// TEXT "And that's all!"
|
| 111 |
+
// END_OF_FILE
|
| 112 |
+
|
| 113 |
+
static
|
| 114 |
+
parser::symbol_type
|
| 115 |
+
yylex ()
|
| 116 |
+
{
|
| 117 |
+
static int count = 0;
|
| 118 |
+
const int stage = count;
|
| 119 |
+
++count;
|
| 120 |
+
parser::location_type loc (NULLPTR, stage + 1, stage + 1);
|
| 121 |
+
switch (stage)
|
| 122 |
+
{
|
| 123 |
+
case 0:
|
| 124 |
+
return parser::make_TEXT ("I have three numbers for you.", loc);
|
| 125 |
+
case 1:
|
| 126 |
+
case 2:
|
| 127 |
+
case 3:
|
| 128 |
+
return parser::make_NUMBER (stage, loc);
|
| 129 |
+
case 4:
|
| 130 |
+
return parser::make_TEXT ("And that's all!", loc);
|
| 131 |
+
default:
|
| 132 |
+
return parser::make_END_OF_FILE (loc);
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
// Mandatory error function
|
| 137 |
+
void
|
| 138 |
+
parser::error (const parser::location_type& loc, const std::string& msg)
|
| 139 |
+
{
|
| 140 |
+
std::cerr << loc << ": " << msg << '\n';
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
int
|
| 145 |
+
main ()
|
| 146 |
+
{
|
| 147 |
+
yy::parser p;
|
| 148 |
+
p.set_debug_level (!!getenv ("YYDEBUG"));
|
| 149 |
+
return p.parse ();
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
// Local Variables:
|
| 153 |
+
// mode: C++
|
| 154 |
+
// End:
|
platform/dbops/binaries/build/share/doc/bison/examples/c/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Examples in C
|
| 2 |
+
|
| 3 |
+
This directory contains simple examples of Bison grammar files in C.
|
| 4 |
+
|
| 5 |
+
Some of them come from the documentation, which should be installed together
|
| 6 |
+
with Bison. The URLs are provided for convenience.
|
| 7 |
+
|
| 8 |
+
## rpcalc - Reverse Polish Notation Calculator
|
| 9 |
+
The first example is that of a simple double-precision Reverse Polish
|
| 10 |
+
Notation calculator (a calculator using postfix operators). This example
|
| 11 |
+
provides a good starting point, since operator precedence is not an issue.
|
| 12 |
+
|
| 13 |
+
Extracted from the documentation: [Reverse Polish Notation
|
| 14 |
+
Calculator](https://www.gnu.org/software/bison/manual/html_node/RPN-Calc.html).
|
| 15 |
+
|
| 16 |
+
## calc - Simple Calculator
|
| 17 |
+
This example is slightly more complex than rpcalc: it features infix
|
| 18 |
+
operators (`1 + 2`, instead of `1 2 +` in rpcalc), but it does so using a
|
| 19 |
+
unambiguous grammar of the arithmetic instead of using precedence
|
| 20 |
+
directives (%left, etc.).
|
| 21 |
+
|
| 22 |
+
## mfcalc - Multi-Function Calculator
|
| 23 |
+
A more complete C example: a multi-function calculator. More complex than
|
| 24 |
+
the previous example. Using precedence directives to support infix
|
| 25 |
+
operators.
|
| 26 |
+
|
| 27 |
+
Extracted from the documentation: [Multi-Function Calculator:
|
| 28 |
+
mfcalc](https://www.gnu.org/software/bison/manual/html_node/Multi_002dfunction-Calc.html).
|
| 29 |
+
|
| 30 |
+
## lexcalc - calculator with Flex and Bison
|
| 31 |
+
The calculator with precedence directives and location tracking. It uses
|
| 32 |
+
Flex to generate the scanner.
|
| 33 |
+
|
| 34 |
+
## reccalc - recursive calculator with Flex and Bison
|
| 35 |
+
This example builds on top of the previous one to provide a reentrant
|
| 36 |
+
parser. Such parsers can be called concurrently in different threads, or
|
| 37 |
+
even recursively. To demonstrate this feature, expressions in parentheses
|
| 38 |
+
are tokenized as strings, and then recursively parsed from the parser. So
|
| 39 |
+
`(((1)+(2))*((3)+(4)))` uses eight parsers, with a depth of four.
|
| 40 |
+
|
| 41 |
+
## pushcalc - calculator implemented with a push parser
|
| 42 |
+
All the previous examples are so called "pull parsers": the user invokes the
|
| 43 |
+
parser once, which repeatedly calls the scanner until the input is drained.
|
| 44 |
+
|
| 45 |
+
This example demonstrates the "push parsers": the user calls the scanner to
|
| 46 |
+
fetch the next token, passes it to the parser, and repeats the operation
|
| 47 |
+
until the input is drained.
|
| 48 |
+
|
| 49 |
+
This example is a straightforward conversion of the 'calc' example to the
|
| 50 |
+
push-parser model.
|
| 51 |
+
|
| 52 |
+
## bistromathic - all the bells and whistles
|
| 53 |
+
This example demonstrates best practices when using Bison.
|
| 54 |
+
- Its hand-written scanner tracks locations.
|
| 55 |
+
- Its interface is pure.
|
| 56 |
+
- It uses %params to pass user information to the parser and scanner.
|
| 57 |
+
- Its scanner uses the `error` token to signal lexical errors and enter
|
| 58 |
+
error recovery.
|
| 59 |
+
- Its interface is "incremental", well suited for interaction: it uses the
|
| 60 |
+
push-parser API to feed the parser with the incoming tokens.
|
| 61 |
+
- It features an interactive command line with completion based on the
|
| 62 |
+
parser state, based on `yyexpected_tokens`.
|
| 63 |
+
- It uses Bison's standard catalog for internationalization of generated
|
| 64 |
+
messages.
|
| 65 |
+
- It uses a custom syntax error with location, lookahead correction and
|
| 66 |
+
token internationalization.
|
| 67 |
+
- Error messages quote the source with squiggles that underline the error:
|
| 68 |
+
```
|
| 69 |
+
> 123 456
|
| 70 |
+
1.5-7: syntax error: expected end of file or + or - or * or / or ^ before number
|
| 71 |
+
1 | 123 456
|
| 72 |
+
| ^~~
|
| 73 |
+
```
|
| 74 |
+
- It supports debug traces with semantic values.
|
| 75 |
+
- It uses named references instead of the traditional $1, $2, etc.
|
| 76 |
+
|
| 77 |
+
<!---
|
| 78 |
+
|
| 79 |
+
Local Variables:
|
| 80 |
+
fill-column: 76
|
| 81 |
+
ispell-dictionary: "american"
|
| 82 |
+
End:
|
| 83 |
+
|
| 84 |
+
Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
| 85 |
+
|
| 86 |
+
This file is part of GNU bison, the GNU Compiler Compiler.
|
| 87 |
+
|
| 88 |
+
Permission is granted to copy, distribute and/or modify this document
|
| 89 |
+
under the terms of the GNU Free Documentation License, Version 1.3 or
|
| 90 |
+
any later version published by the Free Software Foundation; with no
|
| 91 |
+
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
| 92 |
+
Texts. A copy of the license is included in the "GNU Free
|
| 93 |
+
Documentation License" file as part of this distribution.
|
| 94 |
+
|
| 95 |
+
LocalWords: mfcalc calc parsers yy rpcalc lexcalc redux reccalc ispell
|
| 96 |
+
LocalWords: reentrant tokenized american postfix pushcalc bistromathic
|
| 97 |
+
LocalWords: lookahead
|
| 98 |
+
|
| 99 |
+
-->
|
platform/dbops/binaries/build/share/doc/bison/examples/c/bistromathic/Makefile
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This Makefile is designed to be simple and readable. It does not
|
| 2 |
+
# aim at portability. It requires GNU Make.
|
| 3 |
+
|
| 4 |
+
BASE = bistromathic
|
| 5 |
+
BISON = bison
|
| 6 |
+
|
| 7 |
+
# We need to find the headers and libs for readline (and possibly intl).
|
| 8 |
+
# You probably need to customize this for your own environment.
|
| 9 |
+
CPPFLAGS = -I/opt/local/include
|
| 10 |
+
LDFLAGS = -L/opt/local/lib
|
| 11 |
+
|
| 12 |
+
# Find the translation catalog for Bison's generated messagess.
|
| 13 |
+
BISON_LOCALEDIR = $(shell $(BISON) $(BISON_FLAGS) --print-localedir)
|
| 14 |
+
CPPFLAGS += -DENABLE_NLS -DBISON_LOCALEDIR='"$(BISON_LOCALEDIR)"'
|
| 15 |
+
|
| 16 |
+
LIBS = -lreadline -lm # In some environments, -lintl is needed.
|
| 17 |
+
|
| 18 |
+
all: $(BASE)
|
| 19 |
+
|
| 20 |
+
%.c %.h %.html %.xml %.gv: %.y
|
| 21 |
+
$(BISON) $(BISONFLAGS) --header --html --graph -o $*.c $<
|
| 22 |
+
|
| 23 |
+
$(BASE): parse.o
|
| 24 |
+
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
|
| 25 |
+
|
| 26 |
+
run: $(BASE)
|
| 27 |
+
@echo "Type bistromathic expressions. Quit with ctrl-d."
|
| 28 |
+
./$<
|
| 29 |
+
|
| 30 |
+
CLEANFILES = \
|
| 31 |
+
$(BASE) *.o \
|
| 32 |
+
parse.[ch] parse.output parse.xml parse.html parse.gv
|
| 33 |
+
|
| 34 |
+
clean:
|
| 35 |
+
rm -f $(CLEANFILES)
|
platform/dbops/binaries/build/share/doc/bison/examples/c/bistromathic/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# bistromathic - all the bells and whistles
|
| 2 |
+
This example demonstrates best practices when using Bison.
|
| 3 |
+
- Its hand-written scanner tracks locations.
|
| 4 |
+
- Its interface is pure.
|
| 5 |
+
- It uses %params to pass user information to the parser and scanner.
|
| 6 |
+
- Its scanner uses the `error` token to signal lexical errors and enter
|
| 7 |
+
error recovery.
|
| 8 |
+
- Its interface is "incremental", well suited for interaction: it uses the
|
| 9 |
+
push-parser API to feed the parser with the incoming tokens.
|
| 10 |
+
- It features an interactive command line with completion based on the
|
| 11 |
+
parser state, based on `yyexpected_tokens`.
|
| 12 |
+
- It uses Bison's standard catalog for internationalization of generated
|
| 13 |
+
messages.
|
| 14 |
+
- It uses a custom syntax error with location, lookahead correction and
|
| 15 |
+
token internationalization.
|
| 16 |
+
- Error messages quote the source with squiggles that underline the error:
|
| 17 |
+
```
|
| 18 |
+
> 123 456
|
| 19 |
+
1.5-7: syntax error: expected end of file or + or - or * or / or ^ before number
|
| 20 |
+
1 | 123 456
|
| 21 |
+
| ^~~
|
| 22 |
+
```
|
| 23 |
+
- It supports debug traces with semantic values.
|
| 24 |
+
- It uses named references instead of the traditional $1, $2, etc.
|
| 25 |
+
|
| 26 |
+
To customize the interaction with bistromathic, see the GNU Readline user
|
| 27 |
+
manual (see `info rluserman`).
|
| 28 |
+
|
| 29 |
+
<!---
|
| 30 |
+
Local Variables:
|
| 31 |
+
fill-column: 76
|
| 32 |
+
ispell-dictionary: "american"
|
| 33 |
+
End:
|
| 34 |
+
|
| 35 |
+
Copyright (C) 2020-2021 Free Software Foundation, Inc.
|
| 36 |
+
|
| 37 |
+
This file is part of Bison, the GNU Compiler Compiler.
|
| 38 |
+
|
| 39 |
+
Permission is granted to copy, distribute and/or modify this document
|
| 40 |
+
under the terms of the GNU Free Documentation License, Version 1.3 or
|
| 41 |
+
any later version published by the Free Software Foundation; with no
|
| 42 |
+
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
| 43 |
+
Texts. A copy of the license is included in the "GNU Free
|
| 44 |
+
Documentation License" file as part of this distribution.
|
| 45 |
+
|
| 46 |
+
LocalWords: bistromathic yyexpected lookahead ispell american
|
| 47 |
+
LocalWords: MERCHANTABILITY
|
| 48 |
+
|
| 49 |
+
--->
|
platform/dbops/binaries/build/share/doc/bison/examples/c/bistromathic/parse.y
ADDED
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Parser and scanner for bistromathic. -*- C -*-
|
| 2 |
+
|
| 3 |
+
Copyright (C) 2019-2021 Free Software Foundation, Inc.
|
| 4 |
+
|
| 5 |
+
This file is part of Bison, the GNU Compiler Compiler.
|
| 6 |
+
|
| 7 |
+
This program is free software: you can redistribute it and/or modify
|
| 8 |
+
it under the terms of the GNU General Public License as published by
|
| 9 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 10 |
+
(at your option) any later version.
|
| 11 |
+
|
| 12 |
+
This program is distributed in the hope that it will be useful,
|
| 13 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
GNU General Public License for more details.
|
| 16 |
+
|
| 17 |
+
You should have received a copy of the GNU General Public License
|
| 18 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
| 19 |
+
|
| 20 |
+
%require "3.7"
|
| 21 |
+
|
| 22 |
+
// Emitted on top of the implementation file.
|
| 23 |
+
%code top {
|
| 24 |
+
#include <ctype.h> // isdigit
|
| 25 |
+
#include <locale.h> // LC_ALL
|
| 26 |
+
#include <math.h> // cos, sin, etc.
|
| 27 |
+
#include <stdarg.h> // va_start
|
| 28 |
+
#include <stdio.h> // printf
|
| 29 |
+
#include <stdlib.h> // calloc
|
| 30 |
+
#include <string.h> // strcmp
|
| 31 |
+
|
| 32 |
+
#include <readline/readline.h>
|
| 33 |
+
#include <readline/history.h>
|
| 34 |
+
|
| 35 |
+
#if defined ENABLE_NLS && ENABLE_NLS
|
| 36 |
+
// Unable the translation of Bison's generated messages.
|
| 37 |
+
# define YYENABLE_NLS 1
|
| 38 |
+
# include <libintl.h>
|
| 39 |
+
// Unless specified otherwise, we expect bistromathic's own
|
| 40 |
+
// catalog to be installed in the same tree as Bison's catalog.
|
| 41 |
+
# ifndef LOCALEDIR
|
| 42 |
+
# define LOCALEDIR BISON_LOCALEDIR
|
| 43 |
+
# endif
|
| 44 |
+
#endif
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
// Emitted in the header file, before the definition of YYSTYPE.
|
| 48 |
+
%code requires {
|
| 49 |
+
// Function type.
|
| 50 |
+
typedef double (func_t) (double);
|
| 51 |
+
|
| 52 |
+
// Data type for links in the chain of symbols.
|
| 53 |
+
typedef struct symrec symrec;
|
| 54 |
+
struct symrec
|
| 55 |
+
{
|
| 56 |
+
char *name; // name of symbol
|
| 57 |
+
int type; // type of symbol: either VAR or FUN
|
| 58 |
+
union
|
| 59 |
+
{
|
| 60 |
+
double var; // value of a VAR
|
| 61 |
+
func_t *fun; // value of a FUN
|
| 62 |
+
} value;
|
| 63 |
+
symrec *next; // link field
|
| 64 |
+
};
|
| 65 |
+
|
| 66 |
+
symrec *putsym (char const *name, int sym_type);
|
| 67 |
+
symrec *getsym (char const *name);
|
| 68 |
+
|
| 69 |
+
// Exchanging information with the parser.
|
| 70 |
+
typedef struct
|
| 71 |
+
{
|
| 72 |
+
// Whether to not emit error messages.
|
| 73 |
+
int silent;
|
| 74 |
+
// The current input line.
|
| 75 |
+
const char *line;
|
| 76 |
+
} user_context;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
// Emitted in the header file, after the definition of YYSTYPE.
|
| 80 |
+
%code provides {
|
| 81 |
+
# ifndef __attribute__
|
| 82 |
+
# ifndef __GNUC__
|
| 83 |
+
# define __attribute__(Spec) /* empty */
|
| 84 |
+
# endif
|
| 85 |
+
# endif
|
| 86 |
+
|
| 87 |
+
yytoken_kind_t
|
| 88 |
+
yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc,
|
| 89 |
+
const user_context *uctx);
|
| 90 |
+
void yyerror (const YYLTYPE *loc, const user_context *uctx,
|
| 91 |
+
char const *format, ...)
|
| 92 |
+
__attribute__ ((__format__ (__printf__, 3, 4)));
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
// Emitted in the implementation file.
|
| 96 |
+
%code {
|
| 97 |
+
// Print *LOC on OUT.
|
| 98 |
+
static void location_print (FILE *out, YYLTYPE const * const loc);
|
| 99 |
+
#define YYLOCATION_PRINT location_print
|
| 100 |
+
|
| 101 |
+
#if defined ENABLE_NLS && ENABLE_NLS
|
| 102 |
+
# define _(Msgid) gettext (Msgid)
|
| 103 |
+
#else
|
| 104 |
+
# define _(Msgid) (Msgid)
|
| 105 |
+
#endif
|
| 106 |
+
|
| 107 |
+
// Whether to quit.
|
| 108 |
+
int done = 0;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
// Include the header in the implementation rather than duplicating it.
|
| 112 |
+
%define api.header.include {"parse.h"}
|
| 113 |
+
|
| 114 |
+
// Don't share global variables between the scanner and the parser.
|
| 115 |
+
%define api.pure full
|
| 116 |
+
|
| 117 |
+
// Generate a push parser.
|
| 118 |
+
%define api.push-pull push
|
| 119 |
+
|
| 120 |
+
// To avoid name clashes (e.g., with C's EOF) prefix token definitions
|
| 121 |
+
// with TOK_ (e.g., TOK_EOF).
|
| 122 |
+
%define api.token.prefix {TOK_}
|
| 123 |
+
|
| 124 |
+
// Customized syntax error messages (see yyreport_syntax_error)...
|
| 125 |
+
%define parse.error custom
|
| 126 |
+
|
| 127 |
+
// ... with locations...
|
| 128 |
+
%locations
|
| 129 |
+
|
| 130 |
+
// ... and accurate list of expected tokens.
|
| 131 |
+
%define parse.lac full
|
| 132 |
+
|
| 133 |
+
// Generate the parser description file (calc.output).
|
| 134 |
+
%verbose
|
| 135 |
+
|
| 136 |
+
// User information exchanged with the parser and scanner.
|
| 137 |
+
%param {const user_context *uctx}
|
| 138 |
+
|
| 139 |
+
// Generate YYSTYPE from the types assigned to symbols.
|
| 140 |
+
%define api.value.type union
|
| 141 |
+
%token
|
| 142 |
+
PLUS "+"
|
| 143 |
+
MINUS "-"
|
| 144 |
+
STAR "*"
|
| 145 |
+
SLASH "/"
|
| 146 |
+
CARET "^"
|
| 147 |
+
LPAREN "("
|
| 148 |
+
RPAREN ")"
|
| 149 |
+
EQUAL "="
|
| 150 |
+
EXIT "exit"
|
| 151 |
+
<double>
|
| 152 |
+
NUM _("number")
|
| 153 |
+
<symrec*>
|
| 154 |
+
FUN _("function")
|
| 155 |
+
VAR _("variable")
|
| 156 |
+
|
| 157 |
+
%nterm <double> exp
|
| 158 |
+
|
| 159 |
+
// Enable run-time traces (yydebug).
|
| 160 |
+
%define parse.trace
|
| 161 |
+
|
| 162 |
+
// Formatting semantic values in debug traces.
|
| 163 |
+
%printer { fprintf (yyo, "%s", $$->name); } VAR;
|
| 164 |
+
%printer { fprintf (yyo, "%s()", $$->name); } FUN;
|
| 165 |
+
%printer { fprintf (yyo, "%g", $$); } <double>;
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
// Precedence (from lowest to highest) and associativity.
|
| 169 |
+
%precedence "="
|
| 170 |
+
%left "+" "-"
|
| 171 |
+
%left "*" "/"
|
| 172 |
+
%precedence NEG // negation--unary minus
|
| 173 |
+
%right "^" // exponentiation
|
| 174 |
+
|
| 175 |
+
%% // The grammar follows.
|
| 176 |
+
input:
|
| 177 |
+
%empty
|
| 178 |
+
| exp { printf ("%.10g\n", $exp); }
|
| 179 |
+
| "exit" { done = 1; }
|
| 180 |
+
;
|
| 181 |
+
|
| 182 |
+
exp:
|
| 183 |
+
NUM
|
| 184 |
+
| VAR { $$ = $VAR->value.var; }
|
| 185 |
+
| VAR "=" exp { $$ = $3; $VAR->value.var = $3; }
|
| 186 |
+
| FUN "(" exp ")" { $$ = $FUN->value.fun ($3); }
|
| 187 |
+
| exp[l] "+" exp[r] { $$ = $l + $r; }
|
| 188 |
+
| exp[l] "-" exp[r] { $$ = $l - $r; }
|
| 189 |
+
| exp[l] "*" exp[r] { $$ = $l * $r; }
|
| 190 |
+
| exp[l] "/" exp[r]
|
| 191 |
+
{
|
| 192 |
+
if ($r == 0)
|
| 193 |
+
{
|
| 194 |
+
yyerror (&@$, uctx, _("error: division by zero"));
|
| 195 |
+
YYERROR;
|
| 196 |
+
}
|
| 197 |
+
else
|
| 198 |
+
$$ = $l / $r;
|
| 199 |
+
}
|
| 200 |
+
| "-" exp %prec NEG { $$ = -$2; }
|
| 201 |
+
| exp[l] "^" exp[r] { $$ = pow ($l, $r); }
|
| 202 |
+
| "(" exp ")" { $$ = $2; }
|
| 203 |
+
| "(" error ")" { $$ = 666; }
|
| 204 |
+
;
|
| 205 |
+
|
| 206 |
+
// End of grammar.
|
| 207 |
+
%%
|
| 208 |
+
|
| 209 |
+
/*------------.
|
| 210 |
+
| Functions. |
|
| 211 |
+
`------------*/
|
| 212 |
+
|
| 213 |
+
struct init
|
| 214 |
+
{
|
| 215 |
+
char const *name;
|
| 216 |
+
func_t *fun;
|
| 217 |
+
};
|
| 218 |
+
|
| 219 |
+
static struct init const funs[] =
|
| 220 |
+
{
|
| 221 |
+
{ "atan", atan },
|
| 222 |
+
{ "cos", cos },
|
| 223 |
+
{ "exp", exp },
|
| 224 |
+
{ "ln", log },
|
| 225 |
+
{ "sin", sin },
|
| 226 |
+
{ "sqrt", sqrt },
|
| 227 |
+
{ 0, 0 },
|
| 228 |
+
};
|
| 229 |
+
|
| 230 |
+
// The symbol table: a chain of 'struct symrec'.
|
| 231 |
+
static symrec *sym_table;
|
| 232 |
+
|
| 233 |
+
// Put functions in table.
|
| 234 |
+
static void
|
| 235 |
+
init_table (void)
|
| 236 |
+
{
|
| 237 |
+
for (int i = 0; funs[i].name; i++)
|
| 238 |
+
{
|
| 239 |
+
symrec *ptr = putsym (funs[i].name, TOK_FUN);
|
| 240 |
+
ptr->value.fun = funs[i].fun;
|
| 241 |
+
}
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
symrec *
|
| 245 |
+
putsym (char const *name, int sym_type)
|
| 246 |
+
{
|
| 247 |
+
symrec *res = (symrec *) malloc (sizeof (symrec));
|
| 248 |
+
res->name = strdup (name);
|
| 249 |
+
res->type = sym_type;
|
| 250 |
+
res->value.var = 0; // Set value to 0 even if fun.
|
| 251 |
+
res->next = sym_table;
|
| 252 |
+
sym_table = res;
|
| 253 |
+
return res;
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
symrec *
|
| 257 |
+
getsym (char const *name)
|
| 258 |
+
{
|
| 259 |
+
for (symrec *p = sym_table; p; p = p->next)
|
| 260 |
+
if (strcmp (p->name, name) == 0)
|
| 261 |
+
return p;
|
| 262 |
+
return NULL;
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
// How many symbols are registered.
|
| 266 |
+
static int
|
| 267 |
+
symbol_count (void)
|
| 268 |
+
{
|
| 269 |
+
int res = 0;
|
| 270 |
+
for (symrec *p = sym_table; p; p = p->next)
|
| 271 |
+
++res;
|
| 272 |
+
return res;
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
/*------------.
|
| 278 |
+
| Locations. |
|
| 279 |
+
`------------*/
|
| 280 |
+
|
| 281 |
+
// Print *LOC on OUT. Do it in a compact way, that avoids redundancy.
|
| 282 |
+
|
| 283 |
+
static void
|
| 284 |
+
location_print (FILE *out, YYLTYPE const * const loc)
|
| 285 |
+
{
|
| 286 |
+
fprintf (out, "%d.%d", loc->first_line, loc->first_column);
|
| 287 |
+
|
| 288 |
+
int end_col = 0 != loc->last_column ? loc->last_column - 1 : 0;
|
| 289 |
+
if (loc->first_line < loc->last_line)
|
| 290 |
+
fprintf (out, "-%d.%d", loc->last_line, end_col);
|
| 291 |
+
else if (loc->first_column < end_col)
|
| 292 |
+
fprintf (out, "-%d", end_col);
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
/*----------.
|
| 297 |
+
| Scanner. |
|
| 298 |
+
`----------*/
|
| 299 |
+
|
| 300 |
+
yytoken_kind_t
|
| 301 |
+
yylex (const char **line, YYSTYPE *yylval, YYLTYPE *yylloc,
|
| 302 |
+
const user_context *uctx)
|
| 303 |
+
{
|
| 304 |
+
int c;
|
| 305 |
+
|
| 306 |
+
// Ignore white space, get first nonwhite character.
|
| 307 |
+
do {
|
| 308 |
+
// Move the first position onto the last.
|
| 309 |
+
yylloc->first_line = yylloc->last_line;
|
| 310 |
+
yylloc->first_column = yylloc->last_column;
|
| 311 |
+
|
| 312 |
+
yylloc->last_column += 1;
|
| 313 |
+
c = *((*line)++);
|
| 314 |
+
} while (c == ' ' || c == '\t');
|
| 315 |
+
|
| 316 |
+
switch (c)
|
| 317 |
+
{
|
| 318 |
+
case '+': return TOK_PLUS;
|
| 319 |
+
case '-': return TOK_MINUS;
|
| 320 |
+
case '*': return TOK_STAR;
|
| 321 |
+
case '/': return TOK_SLASH;
|
| 322 |
+
case '^': return TOK_CARET;
|
| 323 |
+
case '=': return TOK_EQUAL;
|
| 324 |
+
case '(': return TOK_LPAREN;
|
| 325 |
+
case ')': return TOK_RPAREN;
|
| 326 |
+
|
| 327 |
+
case '!': return TOK_YYUNDEF;
|
| 328 |
+
|
| 329 |
+
case '\0': return TOK_YYEOF;
|
| 330 |
+
|
| 331 |
+
// Numbers.
|
| 332 |
+
case '.':
|
| 333 |
+
case '0': case '1': case '2': case '3': case '4':
|
| 334 |
+
case '5': case '6': case '7': case '8': case '9':
|
| 335 |
+
{
|
| 336 |
+
int nchars = 0;
|
| 337 |
+
if (sscanf (*line - 1, "%lf%n", &yylval->TOK_NUM, &nchars) != 1)
|
| 338 |
+
abort ();
|
| 339 |
+
*line += nchars - 1;
|
| 340 |
+
yylloc->last_column += nchars - 1;
|
| 341 |
+
return TOK_NUM;
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
// Identifiers.
|
| 345 |
+
case 'a': case 'b': case 'c': case 'd': case 'e':
|
| 346 |
+
case 'f': case 'g': case 'h': case 'i': case 'j':
|
| 347 |
+
case 'k': case 'l': case 'm': case 'n': case 'o':
|
| 348 |
+
case 'p': case 'q': case 'r': case 's': case 't':
|
| 349 |
+
case 'u': case 'v': case 'w': case 'x': case 'y':
|
| 350 |
+
case 'z':
|
| 351 |
+
{
|
| 352 |
+
int nchars = 0;
|
| 353 |
+
char buf[100];
|
| 354 |
+
if (sscanf (*line - 1, "%99[a-z]%n", buf, &nchars) != 1)
|
| 355 |
+
abort ();
|
| 356 |
+
*line += nchars - 1;
|
| 357 |
+
yylloc->last_column += nchars - 1;
|
| 358 |
+
if (strcmp (buf, "exit") == 0)
|
| 359 |
+
return TOK_EXIT;
|
| 360 |
+
else
|
| 361 |
+
{
|
| 362 |
+
symrec *s = getsym (buf);
|
| 363 |
+
if (!s)
|
| 364 |
+
s = putsym (buf, TOK_VAR);
|
| 365 |
+
yylval->TOK_VAR = s;
|
| 366 |
+
return s->type;
|
| 367 |
+
}
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
// Stray characters.
|
| 371 |
+
default:
|
| 372 |
+
yyerror (yylloc, uctx, _("syntax error: invalid character: %c"), c);
|
| 373 |
+
return TOK_YYerror;
|
| 374 |
+
}
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
/*---------.
|
| 379 |
+
| Parser. |
|
| 380 |
+
`---------*/
|
| 381 |
+
|
| 382 |
+
|
| 383 |
+
static const char *
|
| 384 |
+
error_format_string (int argc)
|
| 385 |
+
{
|
| 386 |
+
switch (argc)
|
| 387 |
+
{
|
| 388 |
+
default: // Avoid compiler warnings.
|
| 389 |
+
case 0: return _("%@: syntax error");
|
| 390 |
+
case 1: return _("%@: syntax error: unexpected %u");
|
| 391 |
+
// TRANSLATORS: '%@' is a location in a file, '%u' is an
|
| 392 |
+
// "unexpected token", and '%0e', '%1e'... are expected tokens
|
| 393 |
+
// at this point.
|
| 394 |
+
//
|
| 395 |
+
// For instance on the expression "1 + * 2", you'd get
|
| 396 |
+
//
|
| 397 |
+
// 1.5: syntax error: expected - or ( or number or function or variable before *
|
| 398 |
+
case 2: return _("%@: syntax error: expected %0e before %u");
|
| 399 |
+
case 3: return _("%@: syntax error: expected %0e or %1e before %u");
|
| 400 |
+
case 4: return _("%@: syntax error: expected %0e or %1e or %2e before %u");
|
| 401 |
+
case 5: return _("%@: syntax error: expected %0e or %1e or %2e or %3e before %u");
|
| 402 |
+
case 6: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e before %u");
|
| 403 |
+
case 7: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e before %u");
|
| 404 |
+
case 8: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e etc., before %u");
|
| 405 |
+
}
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
int
|
| 410 |
+
yyreport_syntax_error (const yypcontext_t *ctx, const user_context *uctx)
|
| 411 |
+
{
|
| 412 |
+
if (uctx->silent)
|
| 413 |
+
return 0;
|
| 414 |
+
|
| 415 |
+
enum { ARGS_MAX = 6 };
|
| 416 |
+
yysymbol_kind_t arg[ARGS_MAX];
|
| 417 |
+
int argsize = yypcontext_expected_tokens (ctx, arg, ARGS_MAX);
|
| 418 |
+
if (argsize < 0)
|
| 419 |
+
return argsize;
|
| 420 |
+
const int too_many_expected_tokens = argsize == 0 && arg[0] != YYSYMBOL_YYEMPTY;
|
| 421 |
+
if (too_many_expected_tokens)
|
| 422 |
+
argsize = ARGS_MAX;
|
| 423 |
+
const char *format = error_format_string (1 + argsize + too_many_expected_tokens);
|
| 424 |
+
|
| 425 |
+
const YYLTYPE *loc = yypcontext_location (ctx);
|
| 426 |
+
while (*format)
|
| 427 |
+
// %@: location.
|
| 428 |
+
if (format[0] == '%' && format[1] == '@')
|
| 429 |
+
{
|
| 430 |
+
YYLOCATION_PRINT (stderr, loc);
|
| 431 |
+
format += 2;
|
| 432 |
+
}
|
| 433 |
+
// %u: unexpected token.
|
| 434 |
+
else if (format[0] == '%' && format[1] == 'u')
|
| 435 |
+
{
|
| 436 |
+
fputs (yysymbol_name (yypcontext_token (ctx)), stderr);
|
| 437 |
+
format += 2;
|
| 438 |
+
}
|
| 439 |
+
// %0e, %1e...: expected token.
|
| 440 |
+
else if (format[0] == '%'
|
| 441 |
+
&& isdigit ((unsigned char) format[1])
|
| 442 |
+
&& format[2] == 'e'
|
| 443 |
+
&& (format[1] - '0') < argsize)
|
| 444 |
+
{
|
| 445 |
+
int i = format[1] - '0';
|
| 446 |
+
fputs (yysymbol_name (arg[i]), stderr);
|
| 447 |
+
format += 3;
|
| 448 |
+
}
|
| 449 |
+
else
|
| 450 |
+
{
|
| 451 |
+
fputc (*format, stderr);
|
| 452 |
+
++format;
|
| 453 |
+
}
|
| 454 |
+
fputc ('\n', stderr);
|
| 455 |
+
|
| 456 |
+
// Quote the source line.
|
| 457 |
+
{
|
| 458 |
+
fprintf (stderr, "%5d | %s\n", loc->first_line, uctx->line);
|
| 459 |
+
fprintf (stderr, "%5s | %*s", "", loc->first_column, "^");
|
| 460 |
+
for (int i = loc->last_column - loc->first_column - 1; 0 < i; --i)
|
| 461 |
+
putc ('~', stderr);
|
| 462 |
+
putc ('\n', stderr);
|
| 463 |
+
}
|
| 464 |
+
return 0;
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
|
| 468 |
+
// Called by yyparse on errors to report the error to the user.
|
| 469 |
+
void
|
| 470 |
+
yyerror (const YYLTYPE *loc, const user_context *uctx, char const *format, ...)
|
| 471 |
+
{
|
| 472 |
+
if (uctx->silent)
|
| 473 |
+
return;
|
| 474 |
+
|
| 475 |
+
YYLOCATION_PRINT (stderr, loc);
|
| 476 |
+
fputs (": ", stderr);
|
| 477 |
+
va_list args;
|
| 478 |
+
va_start (args, format);
|
| 479 |
+
vfprintf (stderr, format, args);
|
| 480 |
+
va_end (args);
|
| 481 |
+
putc ('\n', stderr);
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
|
| 485 |
+
// Return a newly allocated copy of at most N bytes of STRING. In
|
| 486 |
+
// other words, return a copy of the initial segment of length N of
|
| 487 |
+
// STRING.
|
| 488 |
+
static char *
|
| 489 |
+
xstrndup (const char *string, size_t n)
|
| 490 |
+
{
|
| 491 |
+
// len = strnlen (string, n), portably.
|
| 492 |
+
const char *end = memchr (string, '\0', n);
|
| 493 |
+
size_t len = end ? (size_t) (end - string) : n;
|
| 494 |
+
char *new = malloc (len + 1);
|
| 495 |
+
if (!new)
|
| 496 |
+
abort ();
|
| 497 |
+
new[len] = '\0';
|
| 498 |
+
return memcpy (new, string, len);
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
|
| 502 |
+
/*-----------.
|
| 503 |
+
| Readline. |
|
| 504 |
+
`-----------*/
|
| 505 |
+
|
| 506 |
+
// Parse (and execute) this line.
|
| 507 |
+
static int
|
| 508 |
+
process_line (YYLTYPE *lloc, const char *line)
|
| 509 |
+
{
|
| 510 |
+
user_context uctx = {0, line};
|
| 511 |
+
yypstate *ps = yypstate_new ();
|
| 512 |
+
int status = 0;
|
| 513 |
+
do {
|
| 514 |
+
YYSTYPE lval;
|
| 515 |
+
yytoken_kind_t token = yylex (&line, &lval, lloc, &uctx);
|
| 516 |
+
status = yypush_parse (ps, token, &lval, lloc, &uctx);
|
| 517 |
+
} while (status == YYPUSH_MORE);
|
| 518 |
+
yypstate_delete (ps);
|
| 519 |
+
lloc->last_line++;
|
| 520 |
+
lloc->last_column = 1;
|
| 521 |
+
return status;
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
// Get the list of possible tokens after INPUT was read.
|
| 525 |
+
// Returns a nonnegative.
|
| 526 |
+
static int
|
| 527 |
+
expected_tokens (const char *input,
|
| 528 |
+
int *tokens, int ntokens)
|
| 529 |
+
{
|
| 530 |
+
YYDPRINTF ((stderr, "expected_tokens (\"%s\")", input));
|
| 531 |
+
user_context uctx = {1, input};
|
| 532 |
+
|
| 533 |
+
// Parse the current state of the line.
|
| 534 |
+
yypstate *ps = yypstate_new ();
|
| 535 |
+
int status = 0;
|
| 536 |
+
YYLTYPE lloc = { 1, 1, 1, 1 };
|
| 537 |
+
do {
|
| 538 |
+
YYSTYPE lval;
|
| 539 |
+
yytoken_kind_t token = yylex (&input, &lval, &lloc, &uctx);
|
| 540 |
+
// Don't let the parse know when we reach the end of input.
|
| 541 |
+
if (token == TOK_YYEOF)
|
| 542 |
+
break;
|
| 543 |
+
status = yypush_parse (ps, token, &lval, &lloc, &uctx);
|
| 544 |
+
} while (status == YYPUSH_MORE);
|
| 545 |
+
|
| 546 |
+
int res = 0;
|
| 547 |
+
// If there were parse errors, don't propose completions.
|
| 548 |
+
if (!ps->yynerrs)
|
| 549 |
+
{
|
| 550 |
+
// Then query for the accepted tokens at this point.
|
| 551 |
+
res = yypstate_expected_tokens (ps, tokens, ntokens);
|
| 552 |
+
if (res < 0)
|
| 553 |
+
abort ();
|
| 554 |
+
}
|
| 555 |
+
yypstate_delete (ps);
|
| 556 |
+
return res;
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
// Attempt to complete on the contents of TEXT. START and END bound
|
| 560 |
+
// the region of rl_line_buffer that contains the word to complete.
|
| 561 |
+
// TEXT is the word to complete. We can use the entire contents of
|
| 562 |
+
// rl_line_buffer in case we want to do some simple parsing. Return
|
| 563 |
+
// the array of matches, or NULL if there aren't any.
|
| 564 |
+
static char **
|
| 565 |
+
completion (const char *text, int start, int end)
|
| 566 |
+
{
|
| 567 |
+
YYDPRINTF ((stderr, "completion (\"%.*s[%.*s]%s\")\n",
|
| 568 |
+
start, rl_line_buffer,
|
| 569 |
+
end - start, rl_line_buffer + start,
|
| 570 |
+
rl_line_buffer + end));
|
| 571 |
+
|
| 572 |
+
// Get list of token numbers.
|
| 573 |
+
int tokens[YYNTOKENS];
|
| 574 |
+
char *line = xstrndup (rl_line_buffer, (size_t) start);
|
| 575 |
+
int ntokens = expected_tokens (line, tokens, YYNTOKENS);
|
| 576 |
+
free (line);
|
| 577 |
+
|
| 578 |
+
// Build MATCHES, the list of possible completions.
|
| 579 |
+
const size_t len = strlen (text);
|
| 580 |
+
// Need initial prefix and final NULL.
|
| 581 |
+
char **matches
|
| 582 |
+
= calloc ((size_t) ntokens + (size_t) symbol_count () + 2, sizeof *matches);
|
| 583 |
+
if (!matches)
|
| 584 |
+
abort ();
|
| 585 |
+
int match = 1;
|
| 586 |
+
for (int i = 0; i < ntokens; ++i)
|
| 587 |
+
switch (tokens[i])
|
| 588 |
+
{
|
| 589 |
+
case YYSYMBOL_FUN:
|
| 590 |
+
for (symrec *s = sym_table; s; s = s->next)
|
| 591 |
+
if (s->type == TOK_FUN && strncmp (text, s->name, len) == 0)
|
| 592 |
+
matches[match++] = strdup (s->name);
|
| 593 |
+
break;
|
| 594 |
+
case YYSYMBOL_VAR:
|
| 595 |
+
for (symrec *s = sym_table; s; s = s->next)
|
| 596 |
+
if (s->type == TOK_VAR && strncmp (text, s->name, len) == 0)
|
| 597 |
+
matches[match++] = strdup (s->name);
|
| 598 |
+
break;
|
| 599 |
+
default:
|
| 600 |
+
{
|
| 601 |
+
const char* token = yysymbol_name (tokens[i]);
|
| 602 |
+
if (strncmp (text, token, len) == 0)
|
| 603 |
+
matches[match++] = strdup (token);
|
| 604 |
+
break;
|
| 605 |
+
}
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
// Find the longest common prefix, and install it in matches[0], as
|
| 609 |
+
// required by readline.
|
| 610 |
+
if (match == 1)
|
| 611 |
+
matches[0] = strdup (text);
|
| 612 |
+
else
|
| 613 |
+
{
|
| 614 |
+
size_t lcplen = strlen (matches[1]);
|
| 615 |
+
for (int i = 2; i < match && lcplen; ++i)
|
| 616 |
+
for (size_t j = 0; j < lcplen; ++j)
|
| 617 |
+
if (matches[1][j] != matches[i][j])
|
| 618 |
+
lcplen = j;
|
| 619 |
+
matches[0] = xstrndup (matches[1], lcplen);
|
| 620 |
+
}
|
| 621 |
+
|
| 622 |
+
if (yydebug)
|
| 623 |
+
{
|
| 624 |
+
fprintf (stderr, "completion (\"%.*s[%.*s]%s\") = ",
|
| 625 |
+
start, rl_line_buffer,
|
| 626 |
+
end - start, rl_line_buffer + start,
|
| 627 |
+
rl_line_buffer + end);
|
| 628 |
+
for (int i = 1; matches[i]; ++i)
|
| 629 |
+
fprintf (stderr, "%s%s",
|
| 630 |
+
i == 1 ? "{" : ", ",
|
| 631 |
+
matches[i]);
|
| 632 |
+
fprintf (stderr, "}\n");
|
| 633 |
+
}
|
| 634 |
+
|
| 635 |
+
// Don't fall back to proposing file names.
|
| 636 |
+
rl_attempted_completion_over = 1;
|
| 637 |
+
return matches;
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
static void
|
| 641 |
+
init_readline (void)
|
| 642 |
+
{
|
| 643 |
+
// Allow conditional parsing of the ~/.inputrc file.
|
| 644 |
+
rl_readline_name = "bistromathic";
|
| 645 |
+
|
| 646 |
+
// Tell the completer that we want a crack first.
|
| 647 |
+
rl_attempted_completion_function = completion;
|
| 648 |
+
|
| 649 |
+
// The basic list of characters that signal a break between words
|
| 650 |
+
// for the completer routine.
|
| 651 |
+
rl_basic_word_break_characters = " \t\n\"\\'`@$><=;|&{(+-*/^)";
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
|
| 655 |
+
|
| 656 |
+
/*-------.
|
| 657 |
+
| Main. |
|
| 658 |
+
`-------*/
|
| 659 |
+
|
| 660 |
+
int
|
| 661 |
+
main (int argc, char const* argv[])
|
| 662 |
+
{
|
| 663 |
+
#if defined ENABLE_NLS && ENABLE_NLS
|
| 664 |
+
// Set up internationalization.
|
| 665 |
+
setlocale (LC_ALL, "");
|
| 666 |
+
// Use Bison's standard translation catalog for error messages
|
| 667 |
+
// (the generated messages).
|
| 668 |
+
bindtextdomain ("bison-runtime", BISON_LOCALEDIR);
|
| 669 |
+
// The translation catalog of bistromathic is actually included in
|
| 670 |
+
// Bison's. In your own project, use the name of your project.
|
| 671 |
+
bindtextdomain ("bison", LOCALEDIR);
|
| 672 |
+
textdomain ("bison");
|
| 673 |
+
#endif
|
| 674 |
+
|
| 675 |
+
// Enable parse traces on option -p.
|
| 676 |
+
if (1 < argc && strcmp (argv[1], "-p") == 0)
|
| 677 |
+
yydebug = 1;
|
| 678 |
+
init_table ();
|
| 679 |
+
init_readline ();
|
| 680 |
+
YYLTYPE lloc = {1, 1, 1, 1};
|
| 681 |
+
while (!done)
|
| 682 |
+
{
|
| 683 |
+
char *line = readline ("> ");
|
| 684 |
+
if (!line)
|
| 685 |
+
{
|
| 686 |
+
// Finish the line started by the prompt.
|
| 687 |
+
putchar ('\n');
|
| 688 |
+
break;
|
| 689 |
+
}
|
| 690 |
+
if (*line)
|
| 691 |
+
add_history (line);
|
| 692 |
+
process_line (&lloc, line);
|
| 693 |
+
free (line);
|
| 694 |
+
}
|
| 695 |
+
}
|