mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-24 22:05:40 +00:00
update bison flex
-Updated bison flex exe files to the latest windows version i could find -Regenned the compiler..... alot of changes.....
This commit is contained in:
parent
0954b081d0
commit
83b3f01928
65 changed files with 31010 additions and 11607 deletions
227
Engine/bin/bison-flex/data/README.md
Normal file
227
Engine/bin/bison-flex/data/README.md
Normal file
|
|
@ -0,0 +1,227 @@
|
|||
This directory contains data needed by Bison.
|
||||
|
||||
# Directory Content
|
||||
## Skeletons
|
||||
Bison skeletons: the general shapes of the different parser kinds, that are
|
||||
specialized for specific grammars by the bison program.
|
||||
|
||||
Currently, the supported skeletons are:
|
||||
|
||||
- yacc.c
|
||||
It used to be named bison.simple: it corresponds to C Yacc
|
||||
compatible LALR(1) parsers.
|
||||
|
||||
- lalr1.cc
|
||||
Produces a C++ parser class.
|
||||
|
||||
- lalr1.java
|
||||
Produces a Java parser class.
|
||||
|
||||
- glr.c
|
||||
A Generalized LR C parser based on Bison's LALR(1) tables.
|
||||
|
||||
- glr.cc
|
||||
A Generalized LR C++ parser. Actually a C++ wrapper around glr.c.
|
||||
|
||||
These skeletons are the only ones supported by the Bison team. Because the
|
||||
interface between skeletons and the bison program is not finished, *we are
|
||||
not bound to it*. In particular, Bison is not mature enough for us to
|
||||
consider that "foreign skeletons" are supported.
|
||||
|
||||
## m4sugar
|
||||
This directory contains M4sugar, sort of an extended library for M4, which
|
||||
is used by Bison to instantiate the skeletons.
|
||||
|
||||
## xslt
|
||||
This directory contains XSLT programs that transform Bison's XML output into
|
||||
various formats.
|
||||
|
||||
- bison.xsl
|
||||
A library of routines used by the other XSLT programs.
|
||||
|
||||
- xml2dot.xsl
|
||||
Conversion into GraphViz's dot format.
|
||||
|
||||
- xml2text.xsl
|
||||
Conversion into text.
|
||||
|
||||
- xml2xhtml.xsl
|
||||
Conversion into XHTML.
|
||||
|
||||
# Implementation Notes About the Skeletons
|
||||
|
||||
"Skeleton" in Bison parlance means "backend": a skeleton is fed by the bison
|
||||
executable with LR tables, facts about the symbols, etc. and they generate
|
||||
the output (say parser.cc, parser.hh, location.hh, etc.). They are only in
|
||||
charge of generating the parser and its auxiliary files, they do not
|
||||
generate the XML output, the parser.output reports, nor the graphical
|
||||
rendering.
|
||||
|
||||
The bits of information passing from bison to the backend is named
|
||||
"muscles". Muscles are passed to M4 via its standard input: it's a set of
|
||||
m4 definitions. To see them, use `--trace=muscles`.
|
||||
|
||||
Except for muscles, whose names are generated by bison, the skeletons have
|
||||
no constraint at all on the macro names: there is no technical/theoretical
|
||||
limitation, as long as you generate the output, you can do what you want.
|
||||
However, of course, that would be a bad idea if, say, the C and C++
|
||||
skeletons used different approaches and had completely different
|
||||
implementations. That would be a maintenance nightmare.
|
||||
|
||||
Below, we document some of the macros that we use in several of the
|
||||
skeletons. If you are to write a new skeleton, please, implement them for
|
||||
your language. Overall, be sure to follow the same patterns as the existing
|
||||
skeletons.
|
||||
|
||||
## Vocabulary
|
||||
|
||||
We use "formal arguments", or "formals" for short, to denote the declared
|
||||
parameters of a function (e.g., `int argc, const char **argv`). Yes, this
|
||||
is somewhat contradictory with `param` in the `%param` directives.
|
||||
|
||||
We use "effective arguments", or "args" for short, to denote the values
|
||||
passed in function calls (e.g., `argc, argv`).
|
||||
|
||||
## Symbols
|
||||
|
||||
### `b4_symbol(NUM, FIELD)`
|
||||
In order to unify the handling of the various aspects of symbols (tag, type
|
||||
name, whether terminal, etc.), bison.exe defines one macro per (token,
|
||||
field), where field can `has_id`, `id`, etc.: see
|
||||
`prepare_symbol_definitions()` in `src/output.c`.
|
||||
|
||||
NUM can be:
|
||||
- `empty` to denote the "empty" pseudo-symbol when it exists,
|
||||
- `eof`, `error`, or `undef`
|
||||
- a symbol number.
|
||||
|
||||
FIELD can be:
|
||||
|
||||
- `has_id`: 0 or 1
|
||||
Whether the symbol has an `id`.
|
||||
|
||||
- `id`: string (e.g., `exp`, `NUM`, or `TOK_NUM` with api.token.prefix)
|
||||
If `has_id`, the name of the token kind (prefixed by api.token.prefix if
|
||||
defined), otherwise empty. Guaranteed to be usable as a C identifier.
|
||||
This is used to define the token kind (i.e., the enum used by the return
|
||||
value of yylex). Should be named `token_kind`.
|
||||
|
||||
- `tag`: string
|
||||
A human readable representation of the symbol. Can be `'foo'`,
|
||||
`'foo.id'`, `'"foo"'` etc.
|
||||
|
||||
- `code`: integer
|
||||
The token code associated to the token kind `id`.
|
||||
The external number as used by yylex. Can be ASCII code when a character,
|
||||
some number chosen by bison, or some user number in the case of `%token
|
||||
FOO <NUM>`. Corresponds to `yychar` in `yacc.c`.
|
||||
|
||||
- `is_token`: 0 or 1
|
||||
Whether this is a terminal symbol.
|
||||
|
||||
- `kind_base`: string (e.g., `YYSYMBOL_exp`, `YYSYMBOL_NUM`)
|
||||
The base of the symbol kind, i.e., the enumerator of this symbol (token or
|
||||
nonterminal) which is mapped to its `number`.
|
||||
|
||||
- `kind`: string
|
||||
Same as `kind_base`, but possibly with a prefix in some languages. E.g.,
|
||||
EOF's `kind_base` and `kind` are `YYSYMBOL_YYEOF` in C, but are
|
||||
`S_YYEMPTY` and `symbol_kind::S_YYEMPTY` in C++.
|
||||
|
||||
- `number`: integer
|
||||
The code associated to the `kind`.
|
||||
The internal number (computed from the external number by yytranslate).
|
||||
Corresponds to yytoken in yacc.c. This is the same number that serves as
|
||||
key in b4_symbol(NUM, FIELD).
|
||||
|
||||
In bison, symbols are first assigned increasing numbers in order of
|
||||
appearance (but tokens first, then nterms). After grammar reduction,
|
||||
unused nterms are then renumbered to appear last (i.e., first tokens, then
|
||||
used nterms and finally unused nterms). This final number NUM is the one
|
||||
contained in this field, and it is the one used as key in `b4_symbol(NUM,
|
||||
FIELD)`.
|
||||
|
||||
The code of the rule actions, however, is emitted before we know what
|
||||
symbols are unused, so they use the original numbers. To avoid confusion,
|
||||
they actually use "orig NUM" instead of just "NUM". bison also emits
|
||||
definitions for `b4_symbol(orig NUM, number)` that map from original
|
||||
numbers to the new ones. `b4_symbol` actually resolves `orig NUM` in the
|
||||
other case, i.e., `b4_symbol(orig 42, tag)` would return the tag of the
|
||||
symbols whose original number was 42.
|
||||
|
||||
- `has_type`: 0, 1
|
||||
Whether has a semantic value.
|
||||
|
||||
- `type_tag`: string
|
||||
When api.value.type=union, the generated name for the union member.
|
||||
yytype_INT etc. for symbols that has_id, otherwise yytype_1 etc.
|
||||
|
||||
- `type`: string
|
||||
If it has a semantic value, its type tag, or, if variant are used,
|
||||
its type.
|
||||
In the case of api.value.type=union, type is the real type (e.g. int).
|
||||
|
||||
- `slot`: string
|
||||
If it has a semantic value, the name of the union member (i.e., bounces to
|
||||
either `type_tag` or `type`). It would be better to fix our mess and
|
||||
always use `type` for the true type of the member, and `type_tag` for the
|
||||
name of the union member.
|
||||
|
||||
- `has_printer`: 0, 1
|
||||
- `printer`: string
|
||||
- `printer_file`: string
|
||||
- `printer_line`: integer
|
||||
- `printer_loc`: location
|
||||
If the symbol has a printer, everything about it.
|
||||
|
||||
- `has_destructor`, `destructor`, `destructor_file`, `destructor_line`, `destructor_loc`
|
||||
Likewise.
|
||||
|
||||
### `b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])`
|
||||
Expansion of $$, $1, $<TYPE-TAG>3, etc.
|
||||
|
||||
The semantic value from a given VAL.
|
||||
- `VAL`: some semantic value storage (typically a union). e.g., `yylval`
|
||||
- `SYMBOL-NUM`: the symbol number from which we extract the type tag.
|
||||
- `TYPE-TAG`, the user forced the `<TYPE-TAG>`.
|
||||
|
||||
The result can be used safely, it is put in parens to avoid nasty precedence
|
||||
issues.
|
||||
|
||||
### `b4_lhs_value(SYMBOL-NUM, [TYPE])`
|
||||
Expansion of `$$` or `$<TYPE>$`, for symbol `SYMBOL-NUM`.
|
||||
|
||||
### `b4_rhs_data(RULE-LENGTH, POS)`
|
||||
The data corresponding to the symbol `#POS`, where the current rule has
|
||||
`RULE-LENGTH` symbols on RHS.
|
||||
|
||||
### `b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])`
|
||||
Expansion of `$<TYPE>POS`, where the current rule has `RULE-LENGTH` symbols
|
||||
on RHS.
|
||||
|
||||
<!--
|
||||
|
||||
Local Variables:
|
||||
mode: markdown
|
||||
fill-column: 76
|
||||
ispell-dictionary: "american"
|
||||
End:
|
||||
|
||||
Copyright (C) 2002, 2008-2015, 2018-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bison.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-->
|
||||
61
Engine/bin/bison-flex/data/bison-default.css
Normal file
61
Engine/bin/bison-flex/data/bison-default.css
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* Default styling rules for Bison when doing terminal output.
|
||||
Copyright (C) 2019-2021 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* This is an experimental feature. The class names may change in the
|
||||
future. */
|
||||
|
||||
/* Diagnostics. */
|
||||
.warning { color: purple; }
|
||||
.error { color: red; }
|
||||
.note { color: cyan; }
|
||||
|
||||
.fixit-insert { color: green; }
|
||||
|
||||
/* Semantic values in Bison's own parser traces. */
|
||||
.value { color: green; }
|
||||
|
||||
/* "Sections" in traces (--trace). */
|
||||
.trace0 { color: green; }
|
||||
|
||||
/* Syntax error messages. */
|
||||
.expected { color: green; }
|
||||
.unexpected { color: red; }
|
||||
|
||||
|
||||
/* Counterexamples. */
|
||||
|
||||
/* Cex: point in rule. */
|
||||
.cex-dot { color: red; }
|
||||
|
||||
/* Cex: coloring various rules. */
|
||||
.cex-0 { color: yellow; }
|
||||
.cex-1 { color: green; }
|
||||
.cex-2 { color: blue; }
|
||||
.cex-3 { color: purple; }
|
||||
.cex-4 { color: violet; }
|
||||
.cex-5 { color: orange; }
|
||||
.cex-6 { color: brown; }
|
||||
.cex-7 { color: mauve; }
|
||||
.cex-8 { color: #013220; } /* Dark green. */
|
||||
.cex-9 { color: #e75480; } /* Dark pink. */
|
||||
.cex-10 { color: cyan; }
|
||||
.cex-11 { color: orange; }
|
||||
|
||||
/* Cex: derivation rewriting steps. */
|
||||
.cex-step { font-style: italic; }
|
||||
|
||||
/* Cex: leaves of a derivation. */
|
||||
.cex-leaf { font-weight: 600; }
|
||||
58
Engine/bin/bison-flex/data/local.mk
Normal file
58
Engine/bin/bison-flex/data/local.mk
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
## Copyright (C) 2002, 2005-2015, 2018-2021 Free Software Foundation,
|
||||
## Inc.
|
||||
|
||||
## This program is free software: you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
dist_pkgdata_DATA = \
|
||||
data/README.md \
|
||||
data/bison-default.css
|
||||
|
||||
skeletonsdir = $(pkgdatadir)/skeletons
|
||||
dist_skeletons_DATA = \
|
||||
data/skeletons/bison.m4 \
|
||||
data/skeletons/c++-skel.m4 \
|
||||
data/skeletons/c++.m4 \
|
||||
data/skeletons/c-like.m4 \
|
||||
data/skeletons/c-skel.m4 \
|
||||
data/skeletons/c.m4 \
|
||||
data/skeletons/glr.c \
|
||||
data/skeletons/glr.cc \
|
||||
data/skeletons/glr2.cc \
|
||||
data/skeletons/java-skel.m4 \
|
||||
data/skeletons/java.m4 \
|
||||
data/skeletons/lalr1.cc \
|
||||
data/skeletons/lalr1.java \
|
||||
data/skeletons/location.cc \
|
||||
data/skeletons/stack.hh \
|
||||
data/skeletons/traceon.m4 \
|
||||
data/skeletons/variant.hh \
|
||||
data/skeletons/yacc.c
|
||||
|
||||
# Experimental support for the D language.
|
||||
dist_skeletons_DATA += \
|
||||
data/skeletons/d-skel.m4 \
|
||||
data/skeletons/d.m4 \
|
||||
data/skeletons/lalr1.d
|
||||
|
||||
m4sugardir = $(pkgdatadir)/m4sugar
|
||||
dist_m4sugar_DATA = \
|
||||
data/m4sugar/foreach.m4 \
|
||||
data/m4sugar/m4sugar.m4
|
||||
|
||||
xsltdir = $(pkgdatadir)/xslt
|
||||
dist_xslt_DATA = \
|
||||
data/xslt/bison.xsl \
|
||||
data/xslt/xml2dot.xsl \
|
||||
data/xslt/xml2text.xsl \
|
||||
data/xslt/xml2xhtml.xsl
|
||||
362
Engine/bin/bison-flex/data/m4sugar/foreach.m4
Normal file
362
Engine/bin/bison-flex/data/m4sugar/foreach.m4
Normal file
|
|
@ -0,0 +1,362 @@
|
|||
# -*- Autoconf -*-
|
||||
# This file is part of Autoconf.
|
||||
# foreach-based replacements for recursive functions.
|
||||
# Speeds up GNU M4 1.4.x by avoiding quadratic $@ recursion, but penalizes
|
||||
# GNU M4 1.6 by requiring more memory and macro expansions.
|
||||
#
|
||||
# Copyright (C) 2008-2017, 2020 Free Software Foundation, Inc.
|
||||
|
||||
# This file is part of Autoconf. This program is free
|
||||
# software; you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# Under Section 7 of GPL version 3, you are granted additional
|
||||
# permissions described in the Autoconf Configure Script Exception,
|
||||
# version 3.0, as published by the Free Software Foundation.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# and a copy of the Autoconf Configure Script Exception along with
|
||||
# this program; see the files COPYINGv3 and COPYING.EXCEPTION
|
||||
# respectively. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# Written by Eric Blake.
|
||||
|
||||
# In M4 1.4.x, every byte of $@ is rescanned. This means that an
|
||||
# algorithm on n arguments that recurses with one less argument each
|
||||
# iteration will scan n * (n + 1) / 2 arguments, for O(n^2) time. In
|
||||
# M4 1.6, this was fixed so that $@ is only scanned once, then
|
||||
# back-references are made to information stored about the scan.
|
||||
# Thus, n iterations need only scan n arguments, for O(n) time.
|
||||
# Additionally, in M4 1.4.x, recursive algorithms did not clean up
|
||||
# memory very well, requiring O(n^2) memory rather than O(n) for n
|
||||
# iterations.
|
||||
#
|
||||
# This file is designed to overcome the quadratic nature of $@
|
||||
# recursion by writing a variant of m4_foreach that uses m4_for rather
|
||||
# than $@ recursion to operate on the list. This involves more macro
|
||||
# expansions, but avoids the need to rescan a quadratic number of
|
||||
# arguments, making these replacements very attractive for M4 1.4.x.
|
||||
# On the other hand, in any version of M4, expanding additional macros
|
||||
# costs additional time; therefore, in M4 1.6, where $@ recursion uses
|
||||
# fewer macros, these replacements actually pessimize performance.
|
||||
# Additionally, the use of $10 to mean the tenth argument violates
|
||||
# POSIX; although all versions of m4 1.4.x support this meaning, a
|
||||
# future m4 version may switch to take it as the first argument
|
||||
# concatenated with a literal 0, so the implementations in this file
|
||||
# are not future-proof. Thus, this file is conditionally included as
|
||||
# part of m4_init(), only when it is detected that M4 probably has
|
||||
# quadratic behavior (ie. it lacks the macro __m4_version__).
|
||||
#
|
||||
# Please keep this file in sync with m4sugar.m4.
|
||||
|
||||
# _m4_foreach(PRE, POST, IGNORED, ARG...)
|
||||
# ---------------------------------------
|
||||
# Form the common basis of the m4_foreach and m4_map macros. For each
|
||||
# ARG, expand PRE[ARG]POST[]. The IGNORED argument makes recursion
|
||||
# easier, and must be supplied rather than implicit.
|
||||
#
|
||||
# This version minimizes the number of times that $@ is evaluated by
|
||||
# using m4_for to generate a boilerplate into _m4_f then passing $@ to
|
||||
# that temporary macro. Thus, the recursion is done in m4_for without
|
||||
# reparsing any user input, and is not quadratic. For an idea of how
|
||||
# this works, note that m4_foreach(i,[1,2],[i]) calls
|
||||
# _m4_foreach([m4_define([i],],[)i],[],[1],[2])
|
||||
# which defines _m4_f:
|
||||
# $1[$4]$2[]$1[$5]$2[]_m4_popdef([_m4_f])
|
||||
# then calls _m4_f([m4_define([i],],[)i],[],[1],[2]) for a net result:
|
||||
# m4_define([i],[1])i[]m4_define([i],[2])i[]_m4_popdef([_m4_f]).
|
||||
m4_define([_m4_foreach],
|
||||
[m4_if([$#], [3], [],
|
||||
[m4_pushdef([_m4_f], _m4_for([4], [$#], [1],
|
||||
[$0_([1], [2],], [)])[_m4_popdef([_m4_f])])_m4_f($@)])])
|
||||
|
||||
m4_define([_m4_foreach_],
|
||||
[[$$1[$$3]$$2[]]])
|
||||
|
||||
# m4_case(SWITCH, VAL1, IF-VAL1, VAL2, IF-VAL2, ..., DEFAULT)
|
||||
# -----------------------------------------------------------
|
||||
# Find the first VAL that SWITCH matches, and expand the corresponding
|
||||
# IF-VAL. If there are no matches, expand DEFAULT.
|
||||
#
|
||||
# Use m4_for to create a temporary macro in terms of a boilerplate
|
||||
# m4_if with final cleanup. If $# is even, we have DEFAULT; if it is
|
||||
# odd, then rounding the last $# up in the temporary macro is
|
||||
# harmless. For example, both m4_case(1,2,3,4,5) and
|
||||
# m4_case(1,2,3,4,5,6) result in the intermediate _m4_case being
|
||||
# m4_if([$1],[$2],[$3],[$1],[$4],[$5],_m4_popdef([_m4_case])[$6])
|
||||
m4_define([m4_case],
|
||||
[m4_if(m4_eval([$# <= 2]), [1], [$2],
|
||||
[m4_pushdef([_$0], [m4_if(]_m4_for([2], m4_eval([($# - 1) / 2 * 2]), [2],
|
||||
[_$0_(], [)])[_m4_popdef(
|
||||
[_$0])]m4_dquote($m4_eval([($# + 1) & ~1]))[)])_$0($@)])])
|
||||
|
||||
m4_define([_m4_case_],
|
||||
[$0_([1], [$1], m4_incr([$1]))])
|
||||
|
||||
m4_define([_m4_case__],
|
||||
[[[$$1],[$$2],[$$3],]])
|
||||
|
||||
# m4_bmatch(SWITCH, RE1, VAL1, RE2, VAL2, ..., DEFAULT)
|
||||
# -----------------------------------------------------
|
||||
# m4 equivalent of
|
||||
#
|
||||
# if (SWITCH =~ RE1)
|
||||
# VAL1;
|
||||
# elif (SWITCH =~ RE2)
|
||||
# VAL2;
|
||||
# elif ...
|
||||
# ...
|
||||
# else
|
||||
# DEFAULT
|
||||
#
|
||||
# We build the temporary macro _m4_b:
|
||||
# m4_define([_m4_b], _m4_defn([_m4_bmatch]))_m4_b([$1], [$2], [$3])...
|
||||
# _m4_b([$1], [$m-1], [$m])_m4_b([], [], [$m+1]_m4_popdef([_m4_b]))
|
||||
# then invoke m4_unquote(_m4_b($@)), for concatenation with later text.
|
||||
m4_define([m4_bmatch],
|
||||
[m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])],
|
||||
[$#], 1, [m4_fatal([$0: too few arguments: $#: $1])],
|
||||
[$#], 2, [$2],
|
||||
[m4_pushdef([_m4_b], [m4_define([_m4_b],
|
||||
_m4_defn([_$0]))]_m4_for([3], m4_eval([($# + 1) / 2 * 2 - 1]),
|
||||
[2], [_$0_(], [)])[_m4_b([], [],]m4_dquote([$]m4_eval(
|
||||
[($# + 1) / 2 * 2]))[_m4_popdef([_m4_b]))])m4_unquote(_m4_b($@))])])
|
||||
|
||||
m4_define([_m4_bmatch],
|
||||
[m4_if(m4_bregexp([$1], [$2]), [-1], [], [[$3]m4_define([$0])])])
|
||||
|
||||
m4_define([_m4_bmatch_],
|
||||
[$0_([1], m4_decr([$1]), [$1])])
|
||||
|
||||
m4_define([_m4_bmatch__],
|
||||
[[_m4_b([$$1], [$$2], [$$3])]])
|
||||
|
||||
|
||||
# m4_cond(TEST1, VAL1, IF-VAL1, TEST2, VAL2, IF-VAL2, ..., [DEFAULT])
|
||||
# -------------------------------------------------------------------
|
||||
# Similar to m4_if, except that each TEST is expanded when encountered.
|
||||
# If the expansion of TESTn matches the string VALn, the result is IF-VALn.
|
||||
# The result is DEFAULT if no tests passed. This macro allows
|
||||
# short-circuiting of expensive tests, where it pays to arrange quick
|
||||
# filter tests to run first.
|
||||
#
|
||||
# m4_cond already guarantees either 3*n or 3*n + 1 arguments, 1 <= n.
|
||||
# We only have to speed up _m4_cond, by building the temporary _m4_c:
|
||||
# m4_define([_m4_c], _m4_defn([m4_unquote]))_m4_c([m4_if(($1), [($2)],
|
||||
# [[$3]m4_define([_m4_c])])])_m4_c([m4_if(($4), [($5)],
|
||||
# [[$6]m4_define([_m4_c])])])..._m4_c([m4_if(($m-2), [($m-1)],
|
||||
# [[$m]m4_define([_m4_c])])])_m4_c([[$m+1]]_m4_popdef([_m4_c]))
|
||||
# We invoke m4_unquote(_m4_c($@)), for concatenation with later text.
|
||||
m4_define([_m4_cond],
|
||||
[m4_pushdef([_m4_c], [m4_define([_m4_c],
|
||||
_m4_defn([m4_unquote]))]_m4_for([2], m4_eval([$# / 3 * 3 - 1]), [3],
|
||||
[$0_(], [)])[_m4_c(]m4_dquote(m4_dquote(
|
||||
[$]m4_eval([$# / 3 * 3 + 1])))[_m4_popdef([_m4_c]))])m4_unquote(_m4_c($@))])
|
||||
|
||||
m4_define([_m4_cond_],
|
||||
[$0_(m4_decr([$1]), [$1], m4_incr([$1]))])
|
||||
|
||||
m4_define([_m4_cond__],
|
||||
[[_m4_c([m4_if(($$1), [($$2)], [[$$3]m4_define([_m4_c])])])]])
|
||||
|
||||
# m4_bpatsubsts(STRING, RE1, SUBST1, RE2, SUBST2, ...)
|
||||
# ----------------------------------------------------
|
||||
# m4 equivalent of
|
||||
#
|
||||
# $_ = STRING;
|
||||
# s/RE1/SUBST1/g;
|
||||
# s/RE2/SUBST2/g;
|
||||
# ...
|
||||
#
|
||||
# m4_bpatsubsts already validated an odd number of arguments; we only
|
||||
# need to speed up _m4_bpatsubsts. To avoid nesting, we build the
|
||||
# temporary _m4_p:
|
||||
# m4_define([_m4_p], [$1])m4_define([_m4_p],
|
||||
# m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$2], [$3]))m4_define([_m4_p],
|
||||
# m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$4], [$5]))m4_define([_m4_p],...
|
||||
# m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$m-1], [$m]))m4_unquote(
|
||||
# _m4_defn([_m4_p])_m4_popdef([_m4_p]))
|
||||
m4_define([_m4_bpatsubsts],
|
||||
[m4_pushdef([_m4_p], [m4_define([_m4_p],
|
||||
]m4_dquote([$]1)[)]_m4_for([3], [$#], [2], [$0_(],
|
||||
[)])[m4_unquote(_m4_defn([_m4_p])_m4_popdef([_m4_p]))])_m4_p($@)])
|
||||
|
||||
m4_define([_m4_bpatsubsts_],
|
||||
[$0_(m4_decr([$1]), [$1])])
|
||||
|
||||
m4_define([_m4_bpatsubsts__],
|
||||
[[m4_define([_m4_p],
|
||||
m4_bpatsubst(m4_dquote(_m4_defn([_m4_p])), [$$1], [$$2]))]])
|
||||
|
||||
# m4_shiftn(N, ...)
|
||||
# -----------------
|
||||
# Returns ... shifted N times. Useful for recursive "varargs" constructs.
|
||||
#
|
||||
# m4_shiftn already validated arguments; we only need to speed up
|
||||
# _m4_shiftn. If N is 3, then we build the temporary _m4_s, defined as
|
||||
# ,[$5],[$6],...,[$m]_m4_popdef([_m4_s])
|
||||
# before calling m4_shift(_m4_s($@)).
|
||||
m4_define([_m4_shiftn],
|
||||
[m4_if(m4_incr([$1]), [$#], [], [m4_pushdef([_m4_s],
|
||||
_m4_for(m4_eval([$1 + 2]), [$#], [1],
|
||||
[[,]m4_dquote($], [)])[_m4_popdef([_m4_s])])m4_shift(_m4_s($@))])])
|
||||
|
||||
# m4_do(STRING, ...)
|
||||
# ------------------
|
||||
# This macro invokes all its arguments (in sequence, of course). It is
|
||||
# useful for making your macros more structured and readable by dropping
|
||||
# unnecessary dnl's and have the macros indented properly.
|
||||
#
|
||||
# Here, we use the temporary macro _m4_do, defined as
|
||||
# $1[]$2[]...[]$n[]_m4_popdef([_m4_do])
|
||||
m4_define([m4_do],
|
||||
[m4_if([$#], [0], [],
|
||||
[m4_pushdef([_$0], _m4_for([1], [$#], [1],
|
||||
[$], [[[]]])[_m4_popdef([_$0])])_$0($@)])])
|
||||
|
||||
# m4_dquote_elt(ARGS)
|
||||
# -------------------
|
||||
# Return ARGS as an unquoted list of double-quoted arguments.
|
||||
#
|
||||
# _m4_foreach to the rescue.
|
||||
m4_define([m4_dquote_elt],
|
||||
[m4_if([$#], [0], [], [[[$1]]_m4_foreach([,m4_dquote(], [)], $@)])])
|
||||
|
||||
# m4_reverse(ARGS)
|
||||
# ----------------
|
||||
# Output ARGS in reverse order.
|
||||
#
|
||||
# Invoke _m4_r($@) with the temporary _m4_r built as
|
||||
# [$m], [$m-1], ..., [$2], [$1]_m4_popdef([_m4_r])
|
||||
m4_define([m4_reverse],
|
||||
[m4_if([$#], [0], [], [$#], [1], [[$1]],
|
||||
[m4_pushdef([_m4_r], [[$$#]]_m4_for(m4_decr([$#]), [1], [-1],
|
||||
[[, ]m4_dquote($], [)])[_m4_popdef([_m4_r])])_m4_r($@)])])
|
||||
|
||||
|
||||
# m4_map_args_pair(EXPRESSION, [END-EXPR = EXPRESSION], ARG...)
|
||||
# -------------------------------------------------------------
|
||||
# Perform a pairwise grouping of consecutive ARGs, by expanding
|
||||
# EXPRESSION([ARG1], [ARG2]). If there are an odd number of ARGs, the
|
||||
# final argument is expanded with END-EXPR([ARGn]).
|
||||
#
|
||||
# Build the temporary macro _m4_map_args_pair, with the $2([$m+1])
|
||||
# only output if $# is odd:
|
||||
# $1([$3], [$4])[]$1([$5], [$6])[]...$1([$m-1],
|
||||
# [$m])[]m4_default([$2], [$1])([$m+1])[]_m4_popdef([_m4_map_args_pair])
|
||||
m4_define([m4_map_args_pair],
|
||||
[m4_if([$#], [0], [m4_fatal([$0: too few arguments: $#])],
|
||||
[$#], [1], [m4_fatal([$0: too few arguments: $#: $1])],
|
||||
[$#], [2], [],
|
||||
[$#], [3], [m4_default([$2], [$1])([$3])[]],
|
||||
[m4_pushdef([_$0], _m4_for([3],
|
||||
m4_eval([$# / 2 * 2 - 1]), [2], [_$0_(], [)])_$0_end(
|
||||
[1], [2], [$#])[_m4_popdef([_$0])])_$0($@)])])
|
||||
|
||||
m4_define([_m4_map_args_pair_],
|
||||
[$0_([1], [$1], m4_incr([$1]))])
|
||||
|
||||
m4_define([_m4_map_args_pair__],
|
||||
[[$$1([$$2], [$$3])[]]])
|
||||
|
||||
m4_define([_m4_map_args_pair_end],
|
||||
[m4_if(m4_eval([$3 & 1]), [1], [[m4_default([$$2], [$$1])([$$3])[]]])])
|
||||
|
||||
# m4_join(SEP, ARG1, ARG2...)
|
||||
# ---------------------------
|
||||
# Produce ARG1SEPARG2...SEPARGn. Avoid back-to-back SEP when a given ARG
|
||||
# is the empty string. No expansion is performed on SEP or ARGs.
|
||||
#
|
||||
# Use a self-modifying separator, since we don't know how many
|
||||
# arguments might be skipped before a separator is first printed, but
|
||||
# be careful if the separator contains $. _m4_foreach to the rescue.
|
||||
m4_define([m4_join],
|
||||
[m4_pushdef([_m4_sep], [m4_define([_m4_sep], _m4_defn([m4_echo]))])]dnl
|
||||
[_m4_foreach([_$0([$1],], [)], $@)_m4_popdef([_m4_sep])])
|
||||
|
||||
m4_define([_m4_join],
|
||||
[m4_if([$2], [], [], [_m4_sep([$1])[$2]])])
|
||||
|
||||
# m4_joinall(SEP, ARG1, ARG2...)
|
||||
# ------------------------------
|
||||
# Produce ARG1SEPARG2...SEPARGn. An empty ARG results in back-to-back SEP.
|
||||
# No expansion is performed on SEP or ARGs.
|
||||
#
|
||||
# A bit easier than m4_join. _m4_foreach to the rescue.
|
||||
m4_define([m4_joinall],
|
||||
[[$2]m4_if(m4_eval([$# <= 2]), [1], [],
|
||||
[_m4_foreach([$1], [], m4_shift($@))])])
|
||||
|
||||
# m4_list_cmp(A, B)
|
||||
# -----------------
|
||||
# Compare the two lists of integer expressions A and B.
|
||||
#
|
||||
# m4_list_cmp takes care of any side effects; we only override
|
||||
# _m4_list_cmp_raw, where we can safely expand lists multiple times.
|
||||
# First, insert padding so that both lists are the same length; the
|
||||
# trailing +0 is necessary to handle a missing list. Next, create a
|
||||
# temporary macro to perform pairwise comparisons until an inequality
|
||||
# is found. For example, m4_list_cmp([1], [1,2]) creates _m4_cmp as
|
||||
# m4_if(m4_eval([($1) != ($3)]), [1], [m4_cmp([$1], [$3])],
|
||||
# m4_eval([($2) != ($4)]), [1], [m4_cmp([$2], [$4])],
|
||||
# [0]_m4_popdef([_m4_cmp]))
|
||||
# then calls _m4_cmp([1+0], [0*2], [1], [2+0])
|
||||
m4_define([_m4_list_cmp_raw],
|
||||
[m4_if([$1], [$2], 0,
|
||||
[_m4_list_cmp($1+0_m4_list_pad(m4_count($1), m4_count($2)),
|
||||
$2+0_m4_list_pad(m4_count($2), m4_count($1)))])])
|
||||
|
||||
m4_define([_m4_list_pad],
|
||||
[m4_if(m4_eval($1 < $2), [1],
|
||||
[_m4_for(m4_incr([$1]), [$2], [1], [,0*])])])
|
||||
|
||||
m4_define([_m4_list_cmp],
|
||||
[m4_pushdef([_m4_cmp], [m4_if(]_m4_for(
|
||||
[1], m4_eval([$# >> 1]), [1], [$0_(], [,]m4_eval([$# >> 1])[)])[
|
||||
[0]_m4_popdef([_m4_cmp]))])_m4_cmp($@)])
|
||||
|
||||
m4_define([_m4_list_cmp_],
|
||||
[$0_([$1], m4_eval([$1 + $2]))])
|
||||
|
||||
m4_define([_m4_list_cmp__],
|
||||
[[m4_eval([($$1) != ($$2)]), [1], [m4_cmp([$$1], [$$2])],
|
||||
]])
|
||||
|
||||
# m4_max(EXPR, ...)
|
||||
# m4_min(EXPR, ...)
|
||||
# -----------------
|
||||
# Return the decimal value of the maximum (or minimum) in a series of
|
||||
# integer expressions.
|
||||
#
|
||||
# _m4_foreach to the rescue; we only need to replace _m4_minmax. Here,
|
||||
# we need a temporary macro to track the best answer so far, so that
|
||||
# the foreach expression is tractable.
|
||||
m4_define([_m4_minmax],
|
||||
[m4_pushdef([_m4_best], m4_eval([$2]))_m4_foreach(
|
||||
[m4_define([_m4_best], $1(_m4_best,], [))], m4_shift($@))]dnl
|
||||
[_m4_best[]_m4_popdef([_m4_best])])
|
||||
|
||||
# m4_set_add_all(SET, VALUE...)
|
||||
# -----------------------------
|
||||
# Add each VALUE into SET. This is O(n) in the number of VALUEs, and
|
||||
# can be faster than calling m4_set_add for each VALUE.
|
||||
#
|
||||
# _m4_foreach to the rescue. If no deletions have occurred, then
|
||||
# avoid the speed penalty of m4_set_add.
|
||||
m4_define([m4_set_add_all],
|
||||
[m4_if([$#], [0], [], [$#], [1], [],
|
||||
[m4_define([_m4_set_size($1)], m4_eval(m4_set_size([$1])
|
||||
+ m4_len(_m4_foreach(m4_ifdef([_m4_set_cleanup($1)],
|
||||
[[m4_set_add]], [[_$0]])[([$1],], [)], $@))))])])
|
||||
|
||||
m4_define([_m4_set_add_all],
|
||||
[m4_ifdef([_m4_set([$1],$2)], [],
|
||||
[m4_define([_m4_set([$1],$2)],
|
||||
[1])m4_pushdef([_m4_set([$1])], [$2])-])])
|
||||
3329
Engine/bin/bison-flex/data/m4sugar/m4sugar.m4
Normal file
3329
Engine/bin/bison-flex/data/m4sugar/m4sugar.m4
Normal file
File diff suppressed because it is too large
Load diff
1241
Engine/bin/bison-flex/data/skeletons/bison.m4
Normal file
1241
Engine/bin/bison-flex/data/skeletons/bison.m4
Normal file
File diff suppressed because it is too large
Load diff
27
Engine/bin/bison-flex/data/skeletons/c++-skel.m4
Normal file
27
Engine/bin/bison-flex/data/skeletons/c++-skel.m4
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# C++ skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2006-2007, 2009-2015, 2018-2021 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
b4_glr_if( [m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.cc]])])
|
||||
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.cc]])])
|
||||
|
||||
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[lalr1.cc]])
|
||||
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
||||
|
||||
m4_include(b4_used_skeleton)
|
||||
778
Engine/bin/bison-flex/data/skeletons/c++.m4
Normal file
778
Engine/bin/bison-flex/data/skeletons/c++.m4
Normal file
|
|
@ -0,0 +1,778 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# Sanity checks, before defaults installed by c.m4.
|
||||
b4_percent_define_ifdef([[api.value.union.name]],
|
||||
[b4_complain_at(b4_percent_define_get_loc([[api.value.union.name]]),
|
||||
[named %union is invalid in C++])])
|
||||
|
||||
b4_percent_define_default([[api.symbol.prefix]], [[S_]])
|
||||
|
||||
m4_include(b4_skeletonsdir/[c.m4])
|
||||
|
||||
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
|
||||
b4_percent_define_check_kind([api.parser.class], [code], [deprecated])
|
||||
|
||||
|
||||
## ----- ##
|
||||
## C++. ##
|
||||
## ----- ##
|
||||
|
||||
# b4_comment(TEXT, [PREFIX])
|
||||
# --------------------------
|
||||
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
||||
m4_define([b4_comment],
|
||||
[_b4_comment([$1], [$2// ], [$2// ])])
|
||||
|
||||
|
||||
# b4_inline(hh|cc)
|
||||
# ----------------
|
||||
# Expand to `inline\n ` if $1 is hh.
|
||||
m4_define([b4_inline],
|
||||
[m4_case([$1],
|
||||
[cc], [],
|
||||
[hh], [[inline
|
||||
]],
|
||||
[m4_fatal([$0: invalid argument: $1])])])
|
||||
|
||||
|
||||
# b4_cxx_portability
|
||||
# ------------------
|
||||
m4_define([b4_cxx_portability],
|
||||
[#if defined __cplusplus
|
||||
# define YY_CPLUSPLUS __cplusplus
|
||||
#else
|
||||
# define YY_CPLUSPLUS 199711L
|
||||
#endif
|
||||
|
||||
// Support move semantics when possible.
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
# define YY_MOVE std::move
|
||||
# define YY_MOVE_OR_COPY move
|
||||
# define YY_MOVE_REF(Type) Type&&
|
||||
# define YY_RVREF(Type) Type&&
|
||||
# define YY_COPY(Type) Type
|
||||
#else
|
||||
# define YY_MOVE
|
||||
# define YY_MOVE_OR_COPY copy
|
||||
# define YY_MOVE_REF(Type) Type&
|
||||
# define YY_RVREF(Type) const Type&
|
||||
# define YY_COPY(Type) const Type&
|
||||
#endif
|
||||
|
||||
// Support noexcept when possible.
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
# define YY_NOEXCEPT noexcept
|
||||
# define YY_NOTHROW
|
||||
#else
|
||||
# define YY_NOEXCEPT
|
||||
# define YY_NOTHROW throw ()
|
||||
#endif
|
||||
|
||||
// Support constexpr when possible.
|
||||
#if 201703 <= YY_CPLUSPLUS
|
||||
# define YY_CONSTEXPR constexpr
|
||||
#else
|
||||
# define YY_CONSTEXPR
|
||||
#endif[]dnl
|
||||
])
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## Default values. ##
|
||||
## ---------------- ##
|
||||
|
||||
b4_percent_define_default([[api.parser.class]], [[parser]])
|
||||
|
||||
# Don't do that so that we remember whether we're using a user
|
||||
# request, or the default value.
|
||||
#
|
||||
# b4_percent_define_default([[api.location.type]], [[location]])
|
||||
|
||||
b4_percent_define_default([[api.filename.type]], [[const std::string]])
|
||||
# Make it a warning for those who used betas of Bison 3.0.
|
||||
b4_percent_define_default([[api.namespace]], m4_defn([b4_prefix]))
|
||||
|
||||
b4_percent_define_default([[define_location_comparison]],
|
||||
[m4_if(b4_percent_define_get([[filename_type]]),
|
||||
[std::string], [[true]], [[false]])])
|
||||
|
||||
|
||||
|
||||
## ----------- ##
|
||||
## Namespace. ##
|
||||
## ----------- ##
|
||||
|
||||
m4_define([b4_namespace_ref], [b4_percent_define_get([[api.namespace]])])
|
||||
|
||||
|
||||
# Don't permit an empty b4_namespace_ref. Any '::parser::foo' appended to it
|
||||
# would compile as an absolute reference with 'parser' in the global namespace.
|
||||
# b4_namespace_open would open an anonymous namespace and thus establish
|
||||
# internal linkage. This would compile. However, it's cryptic, and internal
|
||||
# linkage for the parser would be specified in all translation units that
|
||||
# include the header, which is always generated. If we ever need to permit
|
||||
# internal linkage somehow, surely we can find a cleaner approach.
|
||||
m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
|
||||
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
||||
[[namespace reference is empty]])])
|
||||
|
||||
# Instead of assuming the C++ compiler will do it, Bison should reject any
|
||||
# invalid b4_namespace_ref that would be converted to a valid
|
||||
# b4_namespace_open. The problem is that Bison doesn't always output
|
||||
# b4_namespace_ref to uncommented code but should reserve the ability to do so
|
||||
# in future releases without risking breaking any existing user grammars.
|
||||
# Specifically, don't allow empty names as b4_namespace_open would just convert
|
||||
# those into anonymous namespaces, and that might tempt some users.
|
||||
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*::]), [-1], [],
|
||||
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
||||
[[namespace reference has consecutive "::"]])])
|
||||
m4_if(m4_bregexp(b4_namespace_ref, [::[ ]*$]), [-1], [],
|
||||
[b4_complain_at(b4_percent_define_get_loc([[api.namespace]]),
|
||||
[[namespace reference has a trailing "::"]])])
|
||||
|
||||
m4_define([b4_namespace_open],
|
||||
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])dnl
|
||||
[namespace ]m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref),
|
||||
[^\(.\)[ ]*::], [\1])),
|
||||
[::], [ { namespace ])[ {]])])
|
||||
|
||||
m4_define([b4_namespace_close],
|
||||
[b4_user_code([b4_percent_define_get_syncline([[api.namespace]])dnl
|
||||
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(b4_namespace_ref[ ]),
|
||||
[^\(.\)[ ]*\(::\)?\([^][:]\|:[^:]\)*],
|
||||
[\1])),
|
||||
[::\([^][:]\|:[^:]\)*], [} ])[} // ]b4_namespace_ref])])
|
||||
|
||||
|
||||
## ------------- ##
|
||||
## Token kinds. ##
|
||||
## ------------- ##
|
||||
|
||||
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
# Output the definition of the token kinds.
|
||||
m4_define([b4_token_enums],
|
||||
[[enum token_kind_type
|
||||
{
|
||||
]b4_symbol([-2], [id])[ = -2,
|
||||
]b4_symbol_foreach([b4_token_enum])dnl
|
||||
[ };]dnl
|
||||
])
|
||||
|
||||
|
||||
|
||||
## -------------- ##
|
||||
## Symbol kinds. ##
|
||||
## -------------- ##
|
||||
|
||||
# b4_declare_symbol_enum
|
||||
# ----------------------
|
||||
# The definition of the symbol internal numbers as an enum.
|
||||
# Defining YYEMPTY here is important: it forces the compiler
|
||||
# to use a signed type, which matters for yytoken.
|
||||
m4_define([b4_declare_symbol_enum],
|
||||
[[enum symbol_kind_type
|
||||
{
|
||||
YYNTOKENS = ]b4_tokens_number[, ///< Number of tokens.
|
||||
]b4_symbol(empty, kind_base)[ = -2,
|
||||
]b4_symbol_foreach([ b4_symbol_enum])dnl
|
||||
[ };]])
|
||||
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
## Semantic Values. ##
|
||||
## ----------------- ##
|
||||
|
||||
|
||||
|
||||
# b4_value_type_declare
|
||||
# ---------------------
|
||||
# Declare value_type.
|
||||
m4_define([b4_value_type_declare],
|
||||
[b4_value_type_setup[]dnl
|
||||
[ /// Symbol semantic values.
|
||||
]m4_bmatch(b4_percent_define_get_kind([[api.value.type]]),
|
||||
[code],
|
||||
[[ typedef ]b4_percent_define_get([[api.value.type]])[ value_type;]],
|
||||
[m4_bmatch(b4_percent_define_get([[api.value.type]]),
|
||||
[union\|union-directive],
|
||||
[[ union value_type
|
||||
{
|
||||
]b4_user_union_members[
|
||||
};]])])dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_public_types_declare
|
||||
# -----------------------
|
||||
# Define the public types: token, semantic value, location, and so forth.
|
||||
# Depending on %define token_lex, may be output in the header or source file.
|
||||
m4_define([b4_public_types_declare],
|
||||
[b4_glr2_cc_if(
|
||||
[b4_value_type_declare],
|
||||
[[#ifdef ]b4_api_PREFIX[STYPE
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC message "bison: do not #define ]b4_api_PREFIX[STYPE in C++, use %define api.value.type"
|
||||
# endif
|
||||
typedef ]b4_api_PREFIX[STYPE value_type;
|
||||
#else
|
||||
]b4_value_type_declare[
|
||||
#endif
|
||||
/// Backward compatibility (Bison 3.8).
|
||||
typedef value_type semantic_type;
|
||||
]])[]b4_locations_if([
|
||||
/// Symbol locations.
|
||||
typedef b4_percent_define_get([[api.location.type]],
|
||||
[[location]]) location_type;])[
|
||||
|
||||
/// Syntax errors thrown from user actions.
|
||||
struct syntax_error : std::runtime_error
|
||||
{
|
||||
syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m)
|
||||
: std::runtime_error (m)]b4_locations_if([
|
||||
, location (l)])[
|
||||
{}
|
||||
|
||||
syntax_error (const syntax_error& s)
|
||||
: std::runtime_error (s.what ())]b4_locations_if([
|
||||
, location (s.location)])[
|
||||
{}
|
||||
|
||||
~syntax_error () YY_NOEXCEPT YY_NOTHROW;]b4_locations_if([
|
||||
|
||||
location_type location;])[
|
||||
};
|
||||
|
||||
/// Token kinds.
|
||||
struct token
|
||||
{
|
||||
]b4_token_enums[]b4_glr2_cc_if([], [[
|
||||
/// Backward compatibility alias (Bison 3.6).
|
||||
typedef token_kind_type yytokentype;]])[
|
||||
};
|
||||
|
||||
/// Token kind, as returned by yylex.
|
||||
typedef token::token_kind_type token_kind_type;]b4_glr2_cc_if([], [[
|
||||
|
||||
/// Backward compatibility alias (Bison 3.6).
|
||||
typedef token_kind_type token_type;]])[
|
||||
|
||||
/// Symbol kinds.
|
||||
struct symbol_kind
|
||||
{
|
||||
]b4_declare_symbol_enum[
|
||||
};
|
||||
|
||||
/// (Internal) symbol kind.
|
||||
typedef symbol_kind::symbol_kind_type symbol_kind_type;
|
||||
|
||||
/// The number of tokens.
|
||||
static const symbol_kind_type YYNTOKENS = symbol_kind::YYNTOKENS;
|
||||
]])
|
||||
|
||||
|
||||
# b4_symbol_type_define
|
||||
# ---------------------
|
||||
# Define symbol_type, the external type for symbols used for symbol
|
||||
# constructors.
|
||||
m4_define([b4_symbol_type_define],
|
||||
[[ /// A complete symbol.
|
||||
///
|
||||
/// Expects its Base type to provide access to the symbol kind
|
||||
/// via kind ().
|
||||
///
|
||||
/// Provide access to semantic value]b4_locations_if([ and location])[.
|
||||
template <typename Base>
|
||||
struct basic_symbol : Base
|
||||
{
|
||||
/// Alias to Base.
|
||||
typedef Base super_type;
|
||||
|
||||
/// Default constructor.
|
||||
basic_symbol () YY_NOEXCEPT
|
||||
: value ()]b4_locations_if([
|
||||
, location ()])[
|
||||
{}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Move constructor.
|
||||
basic_symbol (basic_symbol&& that)
|
||||
: Base (std::move (that))
|
||||
, value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([
|
||||
, location (std::move (that.location))])[
|
||||
{]b4_variant_if([
|
||||
b4_symbol_variant([this->kind ()], [value], [move],
|
||||
[std::move (that.value)])
|
||||
])[}
|
||||
#endif
|
||||
|
||||
/// Copy constructor.
|
||||
basic_symbol (const basic_symbol& that);]b4_variant_if([[
|
||||
|
||||
/// Constructors for typed symbols.
|
||||
]b4_type_foreach([b4_basic_symbol_constructor_define], [
|
||||
])], [[
|
||||
/// Constructor for valueless symbols.
|
||||
basic_symbol (typename Base::kind_type t]b4_locations_if([,
|
||||
YY_MOVE_REF (location_type) l])[);
|
||||
|
||||
/// Constructor for symbols with semantic value.
|
||||
basic_symbol (typename Base::kind_type t,
|
||||
YY_RVREF (value_type) v]b4_locations_if([,
|
||||
YY_RVREF (location_type) l])[);
|
||||
]])[
|
||||
/// Destroy the symbol.
|
||||
~basic_symbol ()
|
||||
{
|
||||
clear ();
|
||||
}
|
||||
|
||||
]b4_glr2_cc_if([[
|
||||
/// Copy assignment.
|
||||
basic_symbol& operator= (const basic_symbol& that)
|
||||
{
|
||||
Base::operator= (that);]b4_variant_if([[
|
||||
]b4_symbol_variant([this->kind ()], [value], [copy],
|
||||
[that.value])], [[
|
||||
value = that.value]])[;]b4_locations_if([[
|
||||
location = that.location;]])[
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Move assignment.
|
||||
basic_symbol& operator= (basic_symbol&& that)
|
||||
{
|
||||
Base::operator= (std::move (that));]b4_variant_if([[
|
||||
]b4_symbol_variant([this->kind ()], [value], [move],
|
||||
[std::move (that.value)])], [[
|
||||
value = std::move (that.value)]])[;]b4_locations_if([[
|
||||
location = std::move (that.location);]])[
|
||||
return *this;
|
||||
}
|
||||
]])[
|
||||
|
||||
/// Destroy contents, and record that is empty.
|
||||
void clear () YY_NOEXCEPT
|
||||
{]b4_variant_if([[
|
||||
// User destructor.
|
||||
symbol_kind_type yykind = this->kind ();
|
||||
basic_symbol<Base>& yysym = *this;
|
||||
(void) yysym;
|
||||
switch (yykind)
|
||||
{
|
||||
]b4_symbol_foreach([b4_symbol_destructor])dnl
|
||||
[ default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Value type destructor.
|
||||
]b4_symbol_variant([[yykind]], [[value]], [[template destroy]])])[
|
||||
Base::clear ();
|
||||
}
|
||||
|
||||
]b4_parse_error_bmatch(
|
||||
[custom\|detailed],
|
||||
[[ /// The user-facing name of this symbol.
|
||||
const char *name () const YY_NOEXCEPT
|
||||
{
|
||||
return ]b4_parser_class[::symbol_name (this->kind ());
|
||||
}]],
|
||||
[simple],
|
||||
[[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
/// The user-facing name of this symbol.
|
||||
const char *name () const YY_NOEXCEPT
|
||||
{
|
||||
return ]b4_parser_class[::symbol_name (this->kind ());
|
||||
}
|
||||
#endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
|
||||
]],
|
||||
[verbose],
|
||||
[[ /// The user-facing name of this symbol.
|
||||
std::string name () const YY_NOEXCEPT
|
||||
{
|
||||
return ]b4_parser_class[::symbol_name (this->kind ());
|
||||
}]])[]b4_glr2_cc_if([], [[
|
||||
|
||||
/// Backward compatibility (Bison 3.6).
|
||||
symbol_kind_type type_get () const YY_NOEXCEPT;]])[
|
||||
|
||||
/// Whether empty.
|
||||
bool empty () const YY_NOEXCEPT;
|
||||
|
||||
/// Destructive move, \a s is emptied into this.
|
||||
void move (basic_symbol& s);
|
||||
|
||||
/// The semantic value.
|
||||
value_type value;]b4_locations_if([
|
||||
|
||||
/// The location.
|
||||
location_type location;])[
|
||||
|
||||
private:
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
/// Assignment operator.
|
||||
basic_symbol& operator= (const basic_symbol& that);
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Type access provider for token (enum) based symbols.
|
||||
struct by_kind
|
||||
{
|
||||
/// The symbol kind as needed by the constructor.
|
||||
typedef token_kind_type kind_type;
|
||||
|
||||
/// Default constructor.
|
||||
by_kind () YY_NOEXCEPT;
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Move constructor.
|
||||
by_kind (by_kind&& that) YY_NOEXCEPT;
|
||||
#endif
|
||||
|
||||
/// Copy constructor.
|
||||
by_kind (const by_kind& that) YY_NOEXCEPT;
|
||||
|
||||
/// Constructor from (external) token numbers.
|
||||
by_kind (kind_type t) YY_NOEXCEPT;
|
||||
|
||||
]b4_glr2_cc_if([[
|
||||
/// Copy assignment.
|
||||
by_kind& operator= (const by_kind& that);
|
||||
|
||||
/// Move assignment.
|
||||
by_kind& operator= (by_kind&& that);
|
||||
]])[
|
||||
|
||||
/// Record that this symbol is empty.
|
||||
void clear () YY_NOEXCEPT;
|
||||
|
||||
/// Steal the symbol kind from \a that.
|
||||
void move (by_kind& that);
|
||||
|
||||
/// The (internal) type number (corresponding to \a type).
|
||||
/// \a empty when empty.
|
||||
symbol_kind_type kind () const YY_NOEXCEPT;]b4_glr2_cc_if([], [[
|
||||
|
||||
/// Backward compatibility (Bison 3.6).
|
||||
symbol_kind_type type_get () const YY_NOEXCEPT;]])[
|
||||
|
||||
/// The symbol kind.
|
||||
/// \a ]b4_symbol_prefix[YYEMPTY when empty.
|
||||
symbol_kind_type kind_;
|
||||
};]b4_glr2_cc_if([], [[
|
||||
|
||||
/// Backward compatibility for a private implementation detail (Bison 3.6).
|
||||
typedef by_kind by_type;]])[
|
||||
|
||||
/// "External" symbols: returned by the scanner.
|
||||
struct symbol_type : basic_symbol<by_kind>
|
||||
{]b4_variant_if([[
|
||||
/// Superclass.
|
||||
typedef basic_symbol<by_kind> super_type;
|
||||
|
||||
/// Empty symbol.
|
||||
symbol_type () YY_NOEXCEPT {}
|
||||
|
||||
/// Constructor for valueless symbols, and symbols from each type.
|
||||
]b4_type_foreach([_b4_symbol_constructor_define])dnl
|
||||
])[};
|
||||
]])
|
||||
|
||||
|
||||
# b4_public_types_define(hh|cc)
|
||||
# -----------------------------
|
||||
# Provide the implementation needed by the public types.
|
||||
m4_define([b4_public_types_define],
|
||||
[[ // basic_symbol.
|
||||
template <typename Base>
|
||||
]b4_parser_class[::basic_symbol<Base>::basic_symbol (const basic_symbol& that)
|
||||
: Base (that)
|
||||
, value (]b4_variant_if([], [that.value]))b4_locations_if([
|
||||
, location (that.location)])[
|
||||
{]b4_variant_if([
|
||||
b4_symbol_variant([this->kind ()], [value], [copy],
|
||||
[YY_MOVE (that.value)])
|
||||
])[}
|
||||
|
||||
]b4_variant_if([], [[
|
||||
/// Constructor for valueless symbols.
|
||||
template <typename Base>
|
||||
]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||
[typename Base::kind_type t],
|
||||
b4_locations_if([YY_MOVE_REF (location_type) l]))[)
|
||||
: Base (t)
|
||||
, value ()]b4_locations_if([
|
||||
, location (l)])[
|
||||
{}
|
||||
|
||||
template <typename Base>
|
||||
]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join(
|
||||
[typename Base::kind_type t],
|
||||
[YY_RVREF (value_type) v],
|
||||
b4_locations_if([YY_RVREF (location_type) l]))[)
|
||||
: Base (t)
|
||||
, value (]b4_variant_if([], [YY_MOVE (v)])[)]b4_locations_if([
|
||||
, location (YY_MOVE (l))])[
|
||||
{]b4_variant_if([[
|
||||
(void) v;
|
||||
]b4_symbol_variant([this->kind ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
|
||||
|
||||
]b4_glr2_cc_if([], [[
|
||||
template <typename Base>
|
||||
]b4_parser_class[::symbol_kind_type
|
||||
]b4_parser_class[::basic_symbol<Base>::type_get () const YY_NOEXCEPT
|
||||
{
|
||||
return this->kind ();
|
||||
}
|
||||
]])[
|
||||
|
||||
template <typename Base>
|
||||
bool
|
||||
]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT
|
||||
{
|
||||
return this->kind () == ]b4_symbol(empty, kind)[;
|
||||
}
|
||||
|
||||
template <typename Base>
|
||||
void
|
||||
]b4_parser_class[::basic_symbol<Base>::move (basic_symbol& s)
|
||||
{
|
||||
super_type::move (s);
|
||||
]b4_variant_if([b4_symbol_variant([this->kind ()], [value], [move],
|
||||
[YY_MOVE (s.value)])],
|
||||
[value = YY_MOVE (s.value);])[]b4_locations_if([
|
||||
location = YY_MOVE (s.location);])[
|
||||
}
|
||||
|
||||
// by_kind.
|
||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind () YY_NOEXCEPT
|
||||
: kind_ (]b4_symbol(empty, kind)[)
|
||||
{}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (by_kind&& that) YY_NOEXCEPT
|
||||
: kind_ (that.kind_)
|
||||
{
|
||||
that.clear ();
|
||||
}
|
||||
#endif
|
||||
|
||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (const by_kind& that) YY_NOEXCEPT
|
||||
: kind_ (that.kind_)
|
||||
{}
|
||||
|
||||
]b4_inline([$1])b4_parser_class[::by_kind::by_kind (token_kind_type t) YY_NOEXCEPT
|
||||
: kind_ (yytranslate_ (t))
|
||||
{}
|
||||
|
||||
]b4_glr2_cc_if([[
|
||||
]b4_inline([$1])]b4_parser_class[::by_kind&
|
||||
b4_parser_class[::by_kind::by_kind::operator= (const by_kind& that)
|
||||
{
|
||||
kind_ = that.kind_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
]b4_inline([$1])]b4_parser_class[::by_kind&
|
||||
b4_parser_class[::by_kind::by_kind::operator= (by_kind&& that)
|
||||
{
|
||||
kind_ = that.kind_;
|
||||
that.clear ();
|
||||
return *this;
|
||||
}
|
||||
]])[
|
||||
|
||||
]b4_inline([$1])[void
|
||||
]b4_parser_class[::by_kind::clear () YY_NOEXCEPT
|
||||
{
|
||||
kind_ = ]b4_symbol(empty, kind)[;
|
||||
}
|
||||
|
||||
]b4_inline([$1])[void
|
||||
]b4_parser_class[::by_kind::move (by_kind& that)
|
||||
{
|
||||
kind_ = that.kind_;
|
||||
that.clear ();
|
||||
}
|
||||
|
||||
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
||||
]b4_parser_class[::by_kind::kind () const YY_NOEXCEPT
|
||||
{
|
||||
return kind_;
|
||||
}
|
||||
|
||||
]b4_glr2_cc_if([], [[
|
||||
]b4_inline([$1])[]b4_parser_class[::symbol_kind_type
|
||||
]b4_parser_class[::by_kind::type_get () const YY_NOEXCEPT
|
||||
{
|
||||
return this->kind ();
|
||||
}
|
||||
]])[
|
||||
]])
|
||||
|
||||
|
||||
# b4_token_constructor_define
|
||||
# ----------------------------
|
||||
# Define make_FOO for all the token kinds.
|
||||
# Use at class-level. Redefined in variant.hh.
|
||||
m4_define([b4_token_constructor_define], [])
|
||||
|
||||
|
||||
# b4_yytranslate_define(cc|hh)
|
||||
# ----------------------------
|
||||
# Define yytranslate_. Sometimes used in the header file ($1=hh),
|
||||
# sometimes in the cc file.
|
||||
m4_define([b4_yytranslate_define],
|
||||
[ b4_inline([$1])b4_parser_class[::symbol_kind_type
|
||||
]b4_parser_class[::yytranslate_ (int t) YY_NOEXCEPT
|
||||
{
|
||||
]b4_api_token_raw_if(
|
||||
[[ return static_cast<symbol_kind_type> (t);]],
|
||||
[[ // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to
|
||||
// TOKEN-NUM as returned by yylex.
|
||||
static
|
||||
const ]b4_int_type_for([b4_translate])[
|
||||
translate_table[] =
|
||||
{
|
||||
]b4_translate[
|
||||
};
|
||||
// Last valid token kind.
|
||||
const int code_max = ]b4_code_max[;
|
||||
|
||||
if (t <= 0)
|
||||
return symbol_kind::]b4_symbol_prefix[YYEOF;
|
||||
else if (t <= code_max)
|
||||
return static_cast <symbol_kind_type> (translate_table[t]);
|
||||
else
|
||||
return symbol_kind::]b4_symbol_prefix[YYUNDEF;]])[
|
||||
}
|
||||
]])
|
||||
|
||||
|
||||
# b4_lhs_value([TYPE])
|
||||
# --------------------
|
||||
m4_define([b4_lhs_value],
|
||||
[b4_symbol_value([yyval], [$1])])
|
||||
|
||||
|
||||
# b4_rhs_value(RULE-LENGTH, POS, [TYPE])
|
||||
# --------------------------------------
|
||||
# FIXME: Dead code.
|
||||
m4_define([b4_rhs_value],
|
||||
[b4_symbol_value([yysemantic_stack_@{($1) - ($2)@}], [$3])])
|
||||
|
||||
|
||||
# b4_lhs_location()
|
||||
# -----------------
|
||||
# Expansion of @$.
|
||||
m4_define([b4_lhs_location],
|
||||
[(yyloc)])
|
||||
|
||||
|
||||
# b4_rhs_location(RULE-LENGTH, POS)
|
||||
# ---------------------------------
|
||||
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
||||
# on RHS.
|
||||
m4_define([b4_rhs_location],
|
||||
[(yylocation_stack_@{($1) - ($2)@})])
|
||||
|
||||
|
||||
# b4_parse_param_decl
|
||||
# -------------------
|
||||
# Extra formal arguments of the constructor.
|
||||
# Change the parameter names from "foo" into "foo_yyarg", so that
|
||||
# there is no collision bw the user chosen attribute name, and the
|
||||
# argument name in the constructor.
|
||||
m4_define([b4_parse_param_decl],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
|
||||
|
||||
m4_define([b4_parse_param_decl_1],
|
||||
[$1_yyarg])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_cons
|
||||
# -------------------
|
||||
# Extra initialisations of the constructor.
|
||||
m4_define([b4_parse_param_cons],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[
|
||||
b4_cc_constructor_calls(b4_parse_param)])])
|
||||
m4_define([b4_cc_constructor_calls],
|
||||
[m4_map_sep([b4_cc_constructor_call], [,
|
||||
], [$@])])
|
||||
m4_define([b4_cc_constructor_call],
|
||||
[$2 ($2_yyarg)])
|
||||
|
||||
# b4_parse_param_vars
|
||||
# -------------------
|
||||
# Extra instance variables.
|
||||
m4_define([b4_parse_param_vars],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[
|
||||
// User arguments.
|
||||
b4_cc_var_decls(b4_parse_param)])])
|
||||
m4_define([b4_cc_var_decls],
|
||||
[m4_map_sep([b4_cc_var_decl], [
|
||||
], [$@])])
|
||||
m4_define([b4_cc_var_decl],
|
||||
[ $1;])
|
||||
|
||||
|
||||
## ---------##
|
||||
## Values. ##
|
||||
## ---------##
|
||||
|
||||
# b4_yylloc_default_define
|
||||
# ------------------------
|
||||
# Define YYLLOC_DEFAULT.
|
||||
m4_define([b4_yylloc_default_define],
|
||||
[[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
||||
If N is 0, then set CURRENT to the empty location which ends
|
||||
the previous symbol: RHS[0] (always defined). */
|
||||
|
||||
# ifndef YYLLOC_DEFAULT
|
||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||
do \
|
||||
if (N) \
|
||||
{ \
|
||||
(Current).begin = YYRHSLOC (Rhs, 1).begin; \
|
||||
(Current).end = YYRHSLOC (Rhs, N).end; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
||||
} \
|
||||
while (false)
|
||||
# endif
|
||||
]])
|
||||
|
||||
## -------- ##
|
||||
## Checks. ##
|
||||
## -------- ##
|
||||
|
||||
b4_token_ctor_if([b4_variant_if([],
|
||||
[b4_fatal_at(b4_percent_define_get_loc(api.token.constructor),
|
||||
[cannot use '%s' without '%s'],
|
||||
[%define api.token.constructor],
|
||||
[%define api.value.type variant]))])])
|
||||
72
Engine/bin/bison-flex/data/skeletons/c-like.m4
Normal file
72
Engine/bin/bison-flex/data/skeletons/c-like.m4
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# Common code for C-like languages (C, C++, Java, etc.)
|
||||
|
||||
# Copyright (C) 2012-2015, 2018-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
# _b4_comment(TEXT, OPEN, CONTINUE, END)
|
||||
# --------------------------------------
|
||||
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
|
||||
# Avoid adding indentation to the first line, as the indentation comes
|
||||
# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]).
|
||||
# Turn "*/" in TEXT into "* /" so that we don't unexpectedly close
|
||||
# the comments before its end.
|
||||
#
|
||||
# Prefix all the output lines with PREFIX.
|
||||
m4_define([_b4_comment],
|
||||
[$2[]b4_gsub(m4_expand([$1]),
|
||||
[[*]/], [*\\/],
|
||||
[/[*]], [/\\*],
|
||||
[
|
||||
\(.\)], [
|
||||
$3\1])$4])
|
||||
|
||||
|
||||
# b4_comment(TEXT, [PREFIX])
|
||||
# --------------------------
|
||||
# Put TEXT in comment. Prefix all the output lines with PREFIX.
|
||||
m4_define([b4_comment],
|
||||
[_b4_comment([$1], [$2/* ], [$2 ], [ */])])
|
||||
|
||||
|
||||
|
||||
|
||||
# _b4_dollar_dollar(VALUE, SYMBOL-NUM, FIELD, DEFAULT-FIELD)
|
||||
# ----------------------------------------------------------
|
||||
# If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD",
|
||||
# otherwise just VALUE. Be sure to pass "(VALUE)" if VALUE is a
|
||||
# pointer.
|
||||
m4_define([_b4_dollar_dollar],
|
||||
[b4_symbol_value([$1],
|
||||
[$2],
|
||||
m4_if([$3], [[]],
|
||||
[[$4]], [[$3]]))])
|
||||
|
||||
# b4_dollar_pushdef(VALUE-POINTER, SYMBOL-NUM, [TYPE_TAG], LOCATION)
|
||||
# b4_dollar_popdef
|
||||
# ------------------------------------------------------------------
|
||||
# Define b4_dollar_dollar for VALUE-POINTER and DEFAULT-FIELD,
|
||||
# and b4_at_dollar for LOCATION.
|
||||
m4_define([b4_dollar_pushdef],
|
||||
[m4_pushdef([b4_dollar_dollar],
|
||||
[_b4_dollar_dollar([$1], [$2], m4_dquote($][1), [$3])])dnl
|
||||
m4_pushdef([b4_at_dollar], [$4])dnl
|
||||
])
|
||||
m4_define([b4_dollar_popdef],
|
||||
[m4_popdef([b4_at_dollar])dnl
|
||||
m4_popdef([b4_dollar_dollar])dnl
|
||||
])
|
||||
27
Engine/bin/bison-flex/data/skeletons/c-skel.m4
Normal file
27
Engine/bin/bison-flex/data/skeletons/c-skel.m4
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# C skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2006-2007, 2009-2015, 2018-2021 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
b4_glr_if( [m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.c]])])
|
||||
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.c]])])
|
||||
|
||||
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[yacc.c]])
|
||||
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
||||
|
||||
m4_include(b4_used_skeleton)
|
||||
1125
Engine/bin/bison-flex/data/skeletons/c.m4
Normal file
1125
Engine/bin/bison-flex/data/skeletons/c.m4
Normal file
File diff suppressed because it is too large
Load diff
26
Engine/bin/bison-flex/data/skeletons/d-skel.m4
Normal file
26
Engine/bin/bison-flex/data/skeletons/d-skel.m4
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# D skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
b4_glr_if( [b4_complain([%%glr-parser not supported for D])])
|
||||
b4_nondeterministic_if([b4_complain([%%nondeterministic-parser not supported for D])])
|
||||
|
||||
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[lalr1.d]])
|
||||
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
||||
|
||||
m4_include(b4_used_skeleton)
|
||||
628
Engine/bin/bison-flex/data/skeletons/d.m4
Normal file
628
Engine/bin/bison-flex/data/skeletons/d.m4
Normal file
|
|
@ -0,0 +1,628 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# D language support for Bison
|
||||
|
||||
# Copyright (C) 2018-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
m4_include(b4_skeletonsdir/[c-like.m4])
|
||||
|
||||
|
||||
# b4_symbol_action(SYMBOL-NUM, ACTION)
|
||||
# ------------------------------------
|
||||
# Run the action ACTION ("destructor" or "printer") for SYMBOL-NUM.
|
||||
m4_define([b4_symbol_action],
|
||||
[b4_symbol_if([$1], [has_$2],
|
||||
[b4_dollar_pushdef([yyval],
|
||||
[$1],
|
||||
[],
|
||||
[yyloc])dnl
|
||||
_b4_symbol_case([$1])[]dnl
|
||||
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])dnl
|
||||
b4_symbol([$1], [$2])
|
||||
b4_syncline([@oline@], [@ofile@])dnl
|
||||
break;
|
||||
|
||||
b4_dollar_popdef[]dnl
|
||||
])])
|
||||
|
||||
|
||||
# b4_use(EXPR)
|
||||
# ------------
|
||||
# Pacify the compiler about some maybe unused value.
|
||||
m4_define([b4_use],
|
||||
[])
|
||||
|
||||
|
||||
# b4_sync_start(LINE, FILE)
|
||||
# -------------------------
|
||||
m4_define([b4_sync_start], [[#]line $1 $2])
|
||||
|
||||
|
||||
# b4_list2(LIST1, LIST2)
|
||||
# ----------------------
|
||||
# Join two lists with a comma if necessary.
|
||||
m4_define([b4_list2],
|
||||
[$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2])
|
||||
|
||||
|
||||
# b4_percent_define_get3(DEF, PRE, POST, NOT)
|
||||
# -------------------------------------------
|
||||
# Expand to the value of DEF surrounded by PRE and POST if it's %define'ed,
|
||||
# otherwise NOT.
|
||||
m4_define([b4_percent_define_get3],
|
||||
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
||||
[$2[]b4_percent_define_get([$1])[]$3], [$4])])
|
||||
|
||||
# b4_percent_define_if_get2(ARG1, ARG2, DEF, NOT)
|
||||
# -----------------------------------------------
|
||||
# Expand to the value of DEF if ARG1 or ARG2 are %define'ed,
|
||||
# otherwise NOT.
|
||||
m4_define([b4_percent_define_if_get2],
|
||||
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
||||
[$3], [m4_ifval(m4_quote(b4_percent_define_get([$2])),
|
||||
[$3], [$4])])])
|
||||
|
||||
# b4_percent_define_class_before_interface(CLASS, INTERFACE)
|
||||
# ----------------------------------------------------------
|
||||
# Expand to a ', ' if both a class and an interface have been %define'ed
|
||||
m4_define([b4_percent_define_class_before_interface],
|
||||
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
||||
[m4_ifval(m4_quote(b4_percent_define_get([$2])),
|
||||
[, ])])])
|
||||
|
||||
|
||||
# b4_flag_value(BOOLEAN-FLAG)
|
||||
# ---------------------------
|
||||
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
|
||||
|
||||
|
||||
# b4_parser_class_declaration
|
||||
# ---------------------------
|
||||
# The declaration of the parser class ("class YYParser"), with all its
|
||||
# qualifiers/annotations.
|
||||
b4_percent_define_default([[api.parser.abstract]], [[false]])
|
||||
b4_percent_define_default([[api.parser.final]], [[false]])
|
||||
b4_percent_define_default([[api.parser.public]], [[false]])
|
||||
|
||||
m4_define([b4_parser_class_declaration],
|
||||
[b4_percent_define_get3([api.parser.annotations], [], [ ])dnl
|
||||
b4_percent_define_flag_if([api.parser.public], [public ])dnl
|
||||
b4_percent_define_flag_if([api.parser.abstract], [abstract ])dnl
|
||||
b4_percent_define_flag_if([api.parser.final], [final ])dnl
|
||||
[class ]b4_parser_class[]dnl
|
||||
b4_percent_define_if_get2([api.parser.extends], [api.parser.implements], [ : ])dnl
|
||||
b4_percent_define_get([api.parser.extends])dnl
|
||||
b4_percent_define_class_before_interface([api.parser.extends], [api.parser.implements])dnl
|
||||
b4_percent_define_get([api.parser.implements])])
|
||||
|
||||
|
||||
# b4_lexer_if(TRUE, FALSE)
|
||||
# ------------------------
|
||||
m4_define([b4_lexer_if],
|
||||
[b4_percent_code_ifdef([[lexer]], [$1], [$2])])
|
||||
|
||||
|
||||
# b4_position_type_if(TRUE, FALSE)
|
||||
# --------------------------------
|
||||
m4_define([b4_position_type_if],
|
||||
[b4_percent_define_ifdef([[position_type]], [$1], [$2])])
|
||||
|
||||
|
||||
# b4_location_type_if(TRUE, FALSE)
|
||||
# --------------------------------
|
||||
m4_define([b4_location_type_if],
|
||||
[b4_percent_define_ifdef([[location_type]], [$1], [$2])])
|
||||
|
||||
|
||||
# b4_identification
|
||||
# -----------------
|
||||
m4_define([b4_identification],
|
||||
[[/** Version number for the Bison executable that generated this parser. */
|
||||
public static immutable string yy_bison_version = "]b4_version_string[";
|
||||
|
||||
/** Name of the skeleton that generated this parser. */
|
||||
public static immutable string yy_bison_skeleton = ]b4_skeleton[;
|
||||
]])
|
||||
|
||||
|
||||
## ------------ ##
|
||||
## Data types. ##
|
||||
## ------------ ##
|
||||
|
||||
# b4_int_type(MIN, MAX)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# MIN to MAX (included).
|
||||
m4_define([b4_int_type],
|
||||
[m4_if(b4_ints_in($@, [-128], [127]), [1], [byte],
|
||||
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
||||
[int])])
|
||||
|
||||
# b4_int_type_for(NAME)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# `NAME_min' to `NAME_max' (included).
|
||||
m4_define([b4_int_type_for],
|
||||
[b4_int_type($1_min, $1_max)])
|
||||
|
||||
# b4_null
|
||||
# -------
|
||||
m4_define([b4_null], [null])
|
||||
|
||||
|
||||
# b4_integral_parser_table_define(NAME, DATA, COMMENT)
|
||||
#-----------------------------------------------------
|
||||
# Define "yy<TABLE-NAME>" whose contents is CONTENT.
|
||||
m4_define([b4_integral_parser_table_define],
|
||||
[m4_ifvaln([$3], [b4_comment([$3], [ ])])dnl
|
||||
private static immutable b4_int_type_for([$2])[[]] yy$1_ =
|
||||
@{
|
||||
$2
|
||||
@};dnl
|
||||
])
|
||||
|
||||
|
||||
## ------------- ##
|
||||
## Token kinds. ##
|
||||
## ------------- ##
|
||||
|
||||
m4_define([b4_symbol(-2, id)], [[YYEMPTY]])
|
||||
b4_percent_define_default([[api.token.raw]], [[true]])
|
||||
|
||||
# b4_token_enum(TOKEN-NAME, TOKEN-NUMBER)
|
||||
# ---------------------------------------
|
||||
# Output the definition of this token as an enum.
|
||||
m4_define([b4_token_enum],
|
||||
[b4_token_format([ %s = %s,
|
||||
], [$1])])
|
||||
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
# Output the definition of the tokens as enums.
|
||||
m4_define([b4_token_enums],
|
||||
[/* Token kinds. */
|
||||
public enum TokenKind {
|
||||
]b4_symbol(empty, id)[ = -2,
|
||||
b4_symbol_foreach([b4_token_enum])dnl
|
||||
}
|
||||
])
|
||||
|
||||
# b4_symbol_translate(STRING)
|
||||
# ---------------------------
|
||||
# Used by "bison" in the array of symbol names to mark those that
|
||||
# require translation.
|
||||
m4_define([b4_symbol_translate],
|
||||
[[_($1)]])
|
||||
|
||||
|
||||
# _b4_token_constructor_define(SYMBOL-NUM)
|
||||
# ----------------------------------------
|
||||
# Define Symbol.FOO for SYMBOL-NUM.
|
||||
m4_define([_b4_token_constructor_define],
|
||||
[b4_token_visible_if([$1],
|
||||
[[
|
||||
static auto ]b4_symbol([$1], [id])[(]b4_symbol_if([$1], [has_type],
|
||||
[b4_union_if([b4_symbol([$1], [type]],
|
||||
[[typeof(YYSemanticType.]b4_symbol([$1], [type])[]])) [val]])dnl
|
||||
[]b4_locations_if([b4_symbol_if([$1], [has_type], [[, ]])[Location l]])[)
|
||||
{
|
||||
return Symbol(TokenKind.]b4_symbol([$1], [id])[]b4_symbol_if([$1], [has_type],
|
||||
[[, val]])[]b4_locations_if([[, l]])[);
|
||||
}]])])
|
||||
|
||||
# b4_token_constructor_define
|
||||
# ---------------------------
|
||||
# Define Symbol.FOO for each token kind FOO.
|
||||
m4_define([b4_token_constructor_define],
|
||||
[[
|
||||
/* Implementation of token constructors for each symbol type visible to
|
||||
* the user. The code generates static methods that have the same names
|
||||
* as the TokenKinds.
|
||||
*/]b4_symbol_foreach([_b4_token_constructor_define])dnl
|
||||
])
|
||||
|
||||
## -------------- ##
|
||||
## Symbol kinds. ##
|
||||
## -------------- ##
|
||||
|
||||
# b4_symbol_kind(NUM)
|
||||
# -------------------
|
||||
m4_define([b4_symbol_kind],
|
||||
[SymbolKind.b4_symbol_kind_base($@)])
|
||||
|
||||
|
||||
# b4_symbol_enum(SYMBOL-NUM)
|
||||
# --------------------------
|
||||
# Output the definition of this symbol as an enum.
|
||||
m4_define([b4_symbol_enum],
|
||||
[m4_format([ %-30s %s],
|
||||
m4_format([[%s = %s,]],
|
||||
b4_symbol([$1], [kind_base]),
|
||||
[$1]),
|
||||
[b4_symbol_tag_comment([$1])])])
|
||||
|
||||
|
||||
# b4_declare_symbol_enum
|
||||
# ----------------------
|
||||
# The definition of the symbol internal numbers as an enum.
|
||||
# Defining YYEMPTY here is important: it forces the compiler
|
||||
# to use a signed type, which matters for yytoken.
|
||||
m4_define([b4_declare_symbol_enum],
|
||||
[[ /* Symbol kinds. */
|
||||
struct SymbolKind
|
||||
{
|
||||
enum
|
||||
{
|
||||
]b4_symbol(empty, kind_base)[ = -2, /* No symbol. */
|
||||
]b4_symbol_foreach([b4_symbol_enum])dnl
|
||||
[ }
|
||||
|
||||
private int yycode_;
|
||||
alias yycode_ this;
|
||||
|
||||
this(int code)
|
||||
{
|
||||
yycode_ = code;
|
||||
}
|
||||
|
||||
/* Return YYSTR after stripping away unnecessary quotes and
|
||||
backslashes, so that it's suitable for yyerror. The heuristic is
|
||||
that double-quoting is unnecessary unless the string contains an
|
||||
apostrophe, a comma, or backslash (other than backslash-backslash).
|
||||
YYSTR is taken from yytname. */
|
||||
final void toString(W)(W sink) const
|
||||
if (isOutputRange!(W, char))
|
||||
{
|
||||
immutable string[] yy_sname = @{
|
||||
]b4_symbol_names[
|
||||
@};]b4_has_translations_if([[
|
||||
/* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
|
||||
internationalizable. */
|
||||
immutable ]b4_int_type_for([b4_translatable])[[] yytranslatable = @{
|
||||
]b4_translatable[
|
||||
@};]])[
|
||||
|
||||
put(sink, yy_sname[yycode_]);
|
||||
}
|
||||
}
|
||||
]])
|
||||
|
||||
|
||||
# b4_case(ID, CODE, [COMMENTS])
|
||||
# -----------------------------
|
||||
m4_define([b4_case], [ case $1:m4_ifval([$3], [ b4_comment([$3])])
|
||||
$2
|
||||
break;])
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## Default values. ##
|
||||
## ---------------- ##
|
||||
|
||||
m4_define([b4_yystype], [b4_percent_define_get([[stype]])])
|
||||
b4_percent_define_default([[stype]], [[YYSemanticType]])])
|
||||
|
||||
# %name-prefix
|
||||
m4_define_default([b4_prefix], [[YY]])
|
||||
|
||||
b4_percent_define_default([[api.parser.class]], [b4_prefix[]Parser])])
|
||||
m4_define([b4_parser_class], [b4_percent_define_get([[api.parser.class]])])
|
||||
|
||||
#b4_percent_define_default([[location_type]], [Location])])
|
||||
m4_define([b4_location_type], b4_percent_define_ifdef([[location_type]],[b4_percent_define_get([[location_type]])],[YYLocation]))
|
||||
|
||||
#b4_percent_define_default([[position_type]], [Position])])
|
||||
m4_define([b4_position_type], b4_percent_define_ifdef([[position_type]],[b4_percent_define_get([[position_type]])],[YYPosition]))
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## api.value.type. ##
|
||||
## ---------------- ##
|
||||
|
||||
|
||||
# ---------------------- #
|
||||
# api.value.type=union. #
|
||||
# ---------------------- #
|
||||
|
||||
# b4_symbol_type_register(SYMBOL-NUM)
|
||||
# -----------------------------------
|
||||
# Symbol SYMBOL-NUM has a type (for union) instead of a type-tag.
|
||||
# Extend the definition of %union's body (b4_union_members) with a
|
||||
# field of that type, and extend the symbol's "type" field to point to
|
||||
# the field name, instead of the type name.
|
||||
m4_define([b4_symbol_type_register],
|
||||
[m4_define([b4_symbol($1, type_tag)],
|
||||
[b4_symbol_if([$1], [has_id],
|
||||
[b4_symbol([$1], [id])],
|
||||
[yykind_[]b4_symbol([$1], [number])])])dnl
|
||||
m4_append([b4_union_members],
|
||||
m4_expand([m4_format([ %-40s %s],
|
||||
m4_expand([b4_symbol([$1], [type]) b4_symbol([$1], [type_tag]);]),
|
||||
[b4_symbol_tag_comment([$1])])]))
|
||||
])
|
||||
|
||||
|
||||
# b4_type_define_tag(SYMBOL1-NUM, ...)
|
||||
# ------------------------------------
|
||||
# For the batch of symbols SYMBOL1-NUM... (which all have the same
|
||||
# type), enhance the %union definition for each of them, and set
|
||||
# there "type" field to the field tag name, instead of the type name.
|
||||
m4_define([b4_type_define_tag],
|
||||
[b4_symbol_if([$1], [has_type],
|
||||
[m4_map([b4_symbol_type_register], [$@])])
|
||||
])
|
||||
|
||||
|
||||
# b4_symbol_value_union(VAL, SYMBOL-NUM, [TYPE])
|
||||
# ----------------------------------------------
|
||||
# Same of b4_symbol_value, but when api.value.type=union.
|
||||
m4_define([b4_symbol_value_union],
|
||||
[m4_ifval([$3],
|
||||
[(*($3*)(&$1))],
|
||||
[m4_ifval([$2],
|
||||
[b4_symbol_if([$2], [has_type],
|
||||
[($1.b4_symbol([$2], [type_tag]))],
|
||||
[$1])],
|
||||
[$1])])])
|
||||
|
||||
|
||||
# b4_value_type_setup_union
|
||||
# -------------------------
|
||||
# Setup support for api.value.type=union. Symbols are defined with a
|
||||
# type instead of a union member name: build the corresponding union,
|
||||
# and give the symbols their tag.
|
||||
m4_define([b4_value_type_setup_union],
|
||||
[m4_define([b4_union_members])
|
||||
b4_type_foreach([b4_type_define_tag])
|
||||
m4_copy_force([b4_symbol_value_union], [b4_symbol_value])
|
||||
])
|
||||
|
||||
|
||||
# _b4_value_type_setup_keyword
|
||||
# ----------------------------
|
||||
# api.value.type is defined with a keyword/string syntax. Check if
|
||||
# that is properly defined, and prepare its use.
|
||||
m4_define([_b4_value_type_setup_keyword],
|
||||
[b4_percent_define_check_values([[[[api.value.type]],
|
||||
[[none]],
|
||||
[[union]],
|
||||
[[union-directive]],
|
||||
[[yystype]]]])dnl
|
||||
m4_case(b4_percent_define_get([[api.value.type]]),
|
||||
[union], [b4_value_type_setup_union])])
|
||||
|
||||
|
||||
# b4_value_type_setup
|
||||
# -------------------
|
||||
# Check if api.value.type is properly defined, and possibly prepare
|
||||
# its use.
|
||||
b4_define_silent([b4_value_type_setup],
|
||||
[
|
||||
# Define default value.
|
||||
b4_percent_define_ifdef([[api.value.type]], [],
|
||||
[# %union => api.value.type=union-directive
|
||||
m4_ifdef([b4_union_members],
|
||||
[m4_define([b4_percent_define_kind(api.value.type)], [keyword])
|
||||
m4_define([b4_percent_define(api.value.type)], [union-directive])],
|
||||
[# no tag seen => api.value.type={int}
|
||||
m4_if(b4_tag_seen_flag, 0,
|
||||
[m4_define([b4_percent_define_kind(api.value.type)], [code])
|
||||
m4_define([b4_percent_define(api.value.type)], [int])],
|
||||
[# otherwise api.value.type=yystype
|
||||
m4_define([b4_percent_define_kind(api.value.type)], [keyword])
|
||||
m4_define([b4_percent_define(api.value.type)], [yystype])])])])
|
||||
|
||||
# Set up.
|
||||
m4_bmatch(b4_percent_define_get_kind([[api.value.type]]),
|
||||
[keyword], [_b4_value_type_setup_keyword])
|
||||
])
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
## Semantic Values. ##
|
||||
## ----------------- ##
|
||||
|
||||
|
||||
# b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
|
||||
# ----------------------------------------------
|
||||
# See README. FIXME: factor in c-like?
|
||||
m4_define([b4_symbol_value],
|
||||
[m4_ifval([$3],
|
||||
[($1.$3)],
|
||||
[m4_ifval([$2],
|
||||
[b4_symbol_if([$2], [has_type],
|
||||
[($1.b4_symbol([$2], [type]))],
|
||||
[$1])],
|
||||
[$1])])])
|
||||
|
||||
# b4_lhs_value(SYMBOL-NUM, [TYPE])
|
||||
# --------------------------------
|
||||
# See README.
|
||||
m4_define([b4_lhs_value],
|
||||
[b4_symbol_value([yyval], [$1], [$2])])
|
||||
|
||||
|
||||
# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
|
||||
# --------------------------------------------------
|
||||
# See README.
|
||||
#
|
||||
# In this simple implementation, %token and %type have class names
|
||||
# between the angle brackets.
|
||||
m4_define([b4_rhs_value],
|
||||
[b4_symbol_value([(yystack.valueAt (b4_subtract([$1], [$2])))], [$3], [$4])])
|
||||
|
||||
|
||||
# b4_lhs_location()
|
||||
# -----------------
|
||||
# Expansion of @$.
|
||||
m4_define([b4_lhs_location],
|
||||
[(yyloc)])
|
||||
|
||||
|
||||
# b4_rhs_location(RULE-LENGTH, POS)
|
||||
# ---------------------------------
|
||||
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
||||
# on RHS.
|
||||
m4_define([b4_rhs_location],
|
||||
[yystack.locationAt (b4_subtract($@))])
|
||||
|
||||
|
||||
# b4_lex_param
|
||||
# b4_parse_param
|
||||
# --------------
|
||||
# If defined, b4_lex_param arrives double quoted, but below we prefer
|
||||
# it to be single quoted. Same for b4_parse_param.
|
||||
|
||||
# TODO: should be in bison.m4
|
||||
m4_define_default([b4_lex_param], [[]]))
|
||||
m4_define([b4_lex_param], b4_lex_param))
|
||||
m4_define([b4_parse_param], b4_parse_param))
|
||||
|
||||
# b4_lex_param_decl
|
||||
# -------------------
|
||||
# Extra formal arguments of the constructor.
|
||||
m4_define([b4_lex_param_decl],
|
||||
[m4_ifset([b4_lex_param],
|
||||
[b4_remove_comma([$1],
|
||||
b4_param_decls(b4_lex_param))],
|
||||
[$1])])
|
||||
|
||||
m4_define([b4_param_decls],
|
||||
[m4_map([b4_param_decl], [$@])])
|
||||
m4_define([b4_param_decl], [, $1])
|
||||
|
||||
m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_decl
|
||||
# -------------------
|
||||
# Extra formal arguments of the constructor.
|
||||
m4_define([b4_parse_param_decl],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[b4_remove_comma([$1],
|
||||
b4_param_decls(b4_parse_param))],
|
||||
[$1])])
|
||||
|
||||
|
||||
|
||||
# b4_lex_param_call
|
||||
# -------------------
|
||||
# Delegating the lexer parameters to the lexer constructor.
|
||||
m4_define([b4_lex_param_call],
|
||||
[m4_ifset([b4_lex_param],
|
||||
[b4_remove_comma([$1],
|
||||
b4_param_calls(b4_lex_param))],
|
||||
[$1])])
|
||||
m4_define([b4_param_calls],
|
||||
[m4_map([b4_param_call], [$@])])
|
||||
m4_define([b4_param_call], [, $2])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_cons
|
||||
# -------------------
|
||||
# Extra initialisations of the constructor.
|
||||
m4_define([b4_parse_param_cons],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[b4_constructor_calls(b4_parse_param)])])
|
||||
|
||||
m4_define([b4_constructor_calls],
|
||||
[m4_map([b4_constructor_call], [$@])])
|
||||
m4_define([b4_constructor_call],
|
||||
[this.$2 = $2;
|
||||
])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_vars
|
||||
# -------------------
|
||||
# Extra instance variables.
|
||||
m4_define([b4_parse_param_vars],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[
|
||||
/* User arguments. */
|
||||
b4_var_decls(b4_parse_param)])])
|
||||
|
||||
m4_define([b4_var_decls],
|
||||
[m4_map_sep([b4_var_decl], [
|
||||
], [$@])])
|
||||
m4_define([b4_var_decl],
|
||||
[ protected $1;])
|
||||
|
||||
|
||||
# b4_public_types_declare
|
||||
# -----------------------
|
||||
# Define the public types: token, semantic value, location, and so forth.
|
||||
# Depending on %define token_lex, may be output in the header or source file.
|
||||
m4_define([b4_public_types_declare],
|
||||
[[
|
||||
alias Symbol = ]b4_parser_class[.Symbol;
|
||||
alias Value = ]b4_yystype[;]b4_locations_if([[
|
||||
alias Location = ]b4_location_type[;
|
||||
alias Position = ]b4_position_type[;]b4_push_if([[
|
||||
alias PUSH_MORE = ]b4_parser_class[.YYPUSH_MORE;
|
||||
alias ABORT = ]b4_parser_class[.YYABORT;
|
||||
alias ACCEPT = ]b4_parser_class[.YYACCEPT;]])[]])[
|
||||
]])
|
||||
|
||||
|
||||
# b4_basic_symbol_constructor_define
|
||||
# ----------------------------------
|
||||
# Create Symbol struct constructors for all the visible types.
|
||||
m4_define([b4_basic_symbol_constructor_define],
|
||||
[b4_token_visible_if([$1],
|
||||
[[ this(TokenKind token]b4_symbol_if([$1], [has_type],
|
||||
[[, ]b4_union_if([], [[typeof(YYSemanticType.]])b4_symbol([$1], [type])dnl
|
||||
[]b4_union_if([], [[) ]])[ val]])[]b4_locations_if([[, Location loc]])[)
|
||||
{
|
||||
kind = yytranslate_(token);]b4_union_if([b4_symbol_if([$1], [has_type], [[
|
||||
static foreach (member; __traits(allMembers, YYSemanticType))
|
||||
{
|
||||
static if (is(typeof(mixin("value_." ~ member)) == ]b4_symbol([$1], [type])[))
|
||||
{
|
||||
mixin("value_." ~ member ~ " = val;");
|
||||
}
|
||||
}]])], [b4_symbol_if([$1], [has_type], [[
|
||||
value_.]b4_symbol([$1], [type])[ = val;]])])[]b4_locations_if([
|
||||
location_ = loc;])[
|
||||
}
|
||||
]])])
|
||||
|
||||
|
||||
# b4_symbol_type_define
|
||||
# ---------------------
|
||||
# Define symbol_type, the external type for symbols used for symbol
|
||||
# constructors.
|
||||
m4_define([b4_symbol_type_define],
|
||||
[[
|
||||
/**
|
||||
* A complete symbol
|
||||
*/
|
||||
struct Symbol
|
||||
{
|
||||
private SymbolKind kind;
|
||||
private Value value_;]b4_locations_if([[
|
||||
private Location location_;]])[
|
||||
|
||||
]b4_type_foreach([b4_basic_symbol_constructor_define])[
|
||||
SymbolKind token() { return kind; }
|
||||
Value value() { return value_; }]b4_locations_if([[
|
||||
Location location() { return location_; }]])[
|
||||
]b4_token_ctor_if([b4_token_constructor_define])[
|
||||
}
|
||||
]])
|
||||
2763
Engine/bin/bison-flex/data/skeletons/glr.c
Normal file
2763
Engine/bin/bison-flex/data/skeletons/glr.c
Normal file
File diff suppressed because it is too large
Load diff
397
Engine/bin/bison-flex/data/skeletons/glr.cc
Normal file
397
Engine/bin/bison-flex/data/skeletons/glr.cc
Normal file
|
|
@ -0,0 +1,397 @@
|
|||
# C++ GLR skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
# This skeleton produces a C++ class that encapsulates a C glr parser.
|
||||
# This is in order to reduce the maintenance burden. The glr.c
|
||||
# skeleton is clean and pure enough so that there are no real
|
||||
# problems. The C++ interface is the same as that of lalr1.cc. In
|
||||
# fact, glr.c can replace yacc.c without the user noticing any
|
||||
# difference, and similarly for glr.cc replacing lalr1.cc.
|
||||
#
|
||||
# The passing of parse-params
|
||||
#
|
||||
# The additional arguments are stored as members of the parser
|
||||
# object, yyparser. The C routines need to carry yyparser
|
||||
# throughout the C parser; that's easy: make yyparser an
|
||||
# additional parse-param. But because the C++ skeleton needs to
|
||||
# know the "real" original parse-param, we save them
|
||||
# (b4_parse_param_orig). Note that b4_parse_param is overquoted
|
||||
# (and c.m4 strips one level of quotes). This is a PITA, and
|
||||
# explains why there are so many levels of quotes.
|
||||
#
|
||||
# The locations
|
||||
#
|
||||
# We use location.cc just like lalr1.cc, but because glr.c stores
|
||||
# the locations in a union, the position and location classes
|
||||
# must not have a constructor. Therefore, contrary to lalr1.cc, we
|
||||
# must not define "b4_location_constructors". As a consequence the
|
||||
# user must initialize the first positions (in particular the
|
||||
# filename member).
|
||||
|
||||
# We require a pure interface.
|
||||
m4_define([b4_pure_flag], [1])
|
||||
|
||||
m4_include(b4_skeletonsdir/[c++.m4])
|
||||
b4_bison_locations_if([m4_include(b4_skeletonsdir/[location.cc])])
|
||||
|
||||
m4_define([b4_parser_class],
|
||||
[b4_percent_define_get([[api.parser.class]])])
|
||||
|
||||
# Save the parse parameters.
|
||||
m4_define([b4_parse_param_orig], m4_defn([b4_parse_param]))
|
||||
|
||||
# b4_parse_param_wrap
|
||||
# -------------------
|
||||
# New ones.
|
||||
m4_ifset([b4_parse_param],
|
||||
[m4_define([b4_parse_param_wrap],
|
||||
[[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]],]
|
||||
m4_defn([b4_parse_param]))],
|
||||
[m4_define([b4_parse_param_wrap],
|
||||
[[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]]])
|
||||
])
|
||||
|
||||
|
||||
# b4_yy_symbol_print_define
|
||||
# -------------------------
|
||||
# Bypass the default implementation to generate the "yy_symbol_print"
|
||||
# and "yy_symbol_value_print" functions.
|
||||
m4_define([b4_yy_symbol_print_define],
|
||||
[[/*--------------------.
|
||||
| Print this symbol. |
|
||||
`--------------------*/
|
||||
|
||||
static void
|
||||
yy_symbol_print (FILE *, ]b4_namespace_ref::b4_parser_class[::symbol_kind_type yytoken,
|
||||
const ]b4_namespace_ref::b4_parser_class[::value_type *yyvaluep]b4_locations_if([[,
|
||||
const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp]])[]b4_user_formals[)
|
||||
{
|
||||
]b4_parse_param_use[]dnl
|
||||
[ yyparser.yy_symbol_print_ (yytoken, yyvaluep]b4_locations_if([, yylocationp])[);
|
||||
}
|
||||
]])[
|
||||
|
||||
# Hijack the initial action to initialize the locations.
|
||||
]b4_bison_locations_if([m4_define([b4_initial_action],
|
||||
[yylloc.initialize ();]m4_ifdef([b4_initial_action], [
|
||||
m4_defn([b4_initial_action])]))])[
|
||||
|
||||
# Hijack the post prologue to declare yyerror.
|
||||
]m4_append([b4_post_prologue],
|
||||
[b4_syncline([@oline@], [@ofile@])dnl
|
||||
[static void
|
||||
yyerror (]b4_locations_if([[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp,
|
||||
]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param),
|
||||
])[const char* msg);]])[
|
||||
|
||||
# Inserted before the epilogue to define implementations (yyerror, parser member
|
||||
# functions etc.).
|
||||
]m4_define([b4_glr_cc_pre_epilogue],
|
||||
[b4_syncline([@oline@], [@ofile@])dnl
|
||||
[
|
||||
/*------------------.
|
||||
| Report an error. |
|
||||
`------------------*/
|
||||
|
||||
static void
|
||||
yyerror (]b4_locations_if([[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp,
|
||||
]])[]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param),
|
||||
])[const char* msg)
|
||||
{
|
||||
]b4_parse_param_use[]dnl
|
||||
[ yyparser.error (]b4_locations_if([[*yylocationp, ]])[msg);
|
||||
}
|
||||
|
||||
|
||||
]b4_namespace_open[
|
||||
]dnl In this section, the parse params are the original parse_params.
|
||||
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
[ /// Build a parser object.
|
||||
]b4_parser_class::b4_parser_class[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
||||
:])[
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
]m4_ifset([b4_parse_param], [ ], [ :])[yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
||||
#endif]b4_parse_param_cons[
|
||||
{}
|
||||
|
||||
]b4_parser_class::~b4_parser_class[ ()
|
||||
{}
|
||||
|
||||
]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
|
||||
{}
|
||||
|
||||
int
|
||||
]b4_parser_class[::operator() ()
|
||||
{
|
||||
return parse ();
|
||||
}
|
||||
|
||||
int
|
||||
]b4_parser_class[::parse ()
|
||||
{
|
||||
return ::yy_parse_impl (*this]b4_user_args[);
|
||||
}
|
||||
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
/*--------------------.
|
||||
| Print this symbol. |
|
||||
`--------------------*/
|
||||
|
||||
void
|
||||
]b4_parser_class[::yy_symbol_value_print_ (symbol_kind_type yykind,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const
|
||||
{]b4_locations_if([[
|
||||
YY_USE (yylocationp);]])[
|
||||
YY_USE (yyvaluep);
|
||||
std::ostream& yyo = debug_stream ();
|
||||
std::ostream& yyoutput = yyo;
|
||||
YY_USE (yyoutput);
|
||||
]b4_symbol_actions([printer])[
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
]b4_parser_class[::yy_symbol_print_ (symbol_kind_type yykind,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const
|
||||
{
|
||||
*yycdebug_ << (yykind < YYNTOKENS ? "token" : "nterm")
|
||||
<< ' ' << yysymbol_name (yykind) << " ("]b4_locations_if([[
|
||||
<< *yylocationp << ": "]])[;
|
||||
yy_symbol_value_print_ (yykind, yyvaluep]b4_locations_if([[, yylocationp]])[);
|
||||
*yycdebug_ << ')';
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
]b4_parser_class[::debug_stream () const
|
||||
{
|
||||
return *yycdebug_;
|
||||
}
|
||||
|
||||
void
|
||||
]b4_parser_class[::set_debug_stream (std::ostream& o)
|
||||
{
|
||||
yycdebug_ = &o;
|
||||
}
|
||||
|
||||
|
||||
]b4_parser_class[::debug_level_type
|
||||
]b4_parser_class[::debug_level () const
|
||||
{
|
||||
return yydebug;
|
||||
}
|
||||
|
||||
void
|
||||
]b4_parser_class[::set_debug_level (debug_level_type l)
|
||||
{
|
||||
// Actually, it is yydebug which is really used.
|
||||
yydebug = l;
|
||||
}
|
||||
|
||||
#endif
|
||||
]m4_popdef([b4_parse_param])dnl
|
||||
b4_namespace_close[]dnl
|
||||
])
|
||||
|
||||
|
||||
m4_define([b4_define_symbol_kind],
|
||||
[m4_format([#define %-15s %s],
|
||||
b4_symbol($][1, kind_base),
|
||||
b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol($1, kind_base))
|
||||
])
|
||||
|
||||
# b4_glr_cc_setup
|
||||
# ---------------
|
||||
# Setup redirections for glr.c: Map the names used in c.m4 to the ones used
|
||||
# in c++.m4.
|
||||
m4_define([b4_glr_cc_setup],
|
||||
[[]b4_attribute_define[
|
||||
]b4_null_define[
|
||||
|
||||
// This skeleton is based on C, yet compiles it as C++.
|
||||
// So expect warnings about C style casts.
|
||||
#if defined __clang__ && 306 <= __clang_major__ * 100 + __clang_minor__
|
||||
# pragma clang diagnostic ignored "-Wold-style-cast"
|
||||
#elif defined __GNUC__ && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
# pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#endif
|
||||
|
||||
// On MacOS, PTRDIFF_MAX is defined as long long, which Clang's
|
||||
// -pedantic reports as being a C++11 extension.
|
||||
#if defined __APPLE__ && YY_CPLUSPLUS < 201103L \
|
||||
&& defined __clang__ && 4 <= __clang_major__
|
||||
# pragma clang diagnostic ignored "-Wc++11-long-long"
|
||||
#endif
|
||||
|
||||
#undef ]b4_symbol(empty, [id])[
|
||||
#define ]b4_symbol(empty, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(empty, [id])[
|
||||
#undef ]b4_symbol(eof, [id])[
|
||||
#define ]b4_symbol(eof, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(eof, [id])[
|
||||
#undef ]b4_symbol(error, [id])[
|
||||
#define ]b4_symbol(error, [id])[ ]b4_namespace_ref[::]b4_parser_class[::token::]b4_symbol(error, [id])[
|
||||
|
||||
#ifndef ]b4_api_PREFIX[STYPE
|
||||
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class[::value_type
|
||||
#endif
|
||||
#ifndef ]b4_api_PREFIX[LTYPE
|
||||
# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class[::location_type
|
||||
#endif
|
||||
|
||||
typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type yysymbol_kind_t;
|
||||
|
||||
// Expose C++ symbol kinds to C.
|
||||
]b4_define_symbol_kind(-2)dnl
|
||||
b4_symbol_foreach([b4_define_symbol_kind])])[
|
||||
]])
|
||||
|
||||
|
||||
m4_define([b4_undef_symbol_kind],
|
||||
[[#undef ]b4_symbol($1, kind_base)[
|
||||
]])
|
||||
|
||||
|
||||
# b4_glr_cc_cleanup
|
||||
# -----------------
|
||||
# Remove redirections for glr.c.
|
||||
m4_define([b4_glr_cc_cleanup],
|
||||
[[#undef ]b4_symbol(empty, [id])[
|
||||
#undef ]b4_symbol(eof, [id])[
|
||||
#undef ]b4_symbol(error, [id])[
|
||||
|
||||
]b4_undef_symbol_kind(-2)dnl
|
||||
b4_symbol_foreach([b4_undef_symbol_kind])dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_shared_declarations(hh|cc)
|
||||
# -----------------------------
|
||||
# Declaration that might either go into the header (if --header, $1 = hh)
|
||||
# or in the implementation file.
|
||||
m4_define([b4_shared_declarations],
|
||||
[m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
b4_percent_code_get([[requires]])[
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
]b4_cxx_portability[
|
||||
]m4_ifdef([b4_location_include],
|
||||
[[# include ]b4_location_include])[
|
||||
]b4_variant_if([b4_variant_includes])[
|
||||
|
||||
// Whether we are compiled with exception support.
|
||||
#ifndef YY_EXCEPTIONS
|
||||
# if defined __GNUC__ && !defined __EXCEPTIONS
|
||||
# define YY_EXCEPTIONS 0
|
||||
# else
|
||||
# define YY_EXCEPTIONS 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
]b4_YYDEBUG_define[
|
||||
|
||||
]b4_namespace_open[
|
||||
|
||||
]b4_bison_locations_if([m4_ifndef([b4_location_file],
|
||||
[b4_location_define])])[
|
||||
|
||||
/// A Bison parser.
|
||||
class ]b4_parser_class[
|
||||
{
|
||||
public:
|
||||
]b4_public_types_declare[
|
||||
|
||||
/// Build a parser object.
|
||||
]b4_parser_class[ (]b4_parse_param_decl[);
|
||||
virtual ~]b4_parser_class[ ();
|
||||
|
||||
/// Parse. An alias for parse ().
|
||||
/// \returns 0 iff parsing succeeded.
|
||||
int operator() ();
|
||||
|
||||
/// Parse.
|
||||
/// \returns 0 iff parsing succeeded.
|
||||
virtual int parse ();
|
||||
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
/// The current debugging stream.
|
||||
std::ostream& debug_stream () const;
|
||||
/// Set the current debugging stream.
|
||||
void set_debug_stream (std::ostream &);
|
||||
|
||||
/// Type for debugging levels.
|
||||
typedef int debug_level_type;
|
||||
/// The current debugging level.
|
||||
debug_level_type debug_level () const;
|
||||
/// Set the current debugging level.
|
||||
void set_debug_level (debug_level_type l);
|
||||
#endif
|
||||
|
||||
/// Report a syntax error.]b4_locations_if([[
|
||||
/// \param loc where the syntax error is found.]])[
|
||||
/// \param msg a description of the syntax error.
|
||||
virtual void error (]b4_locations_if([[const location_type& loc, ]])[const std::string& msg);
|
||||
|
||||
# if ]b4_api_PREFIX[DEBUG
|
||||
public:
|
||||
/// \brief Report a symbol value on the debug stream.
|
||||
/// \param yykind The symbol kind.
|
||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
||||
/// \param yylocationp Its location.]])[
|
||||
virtual void yy_symbol_value_print_ (symbol_kind_type yykind,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const;
|
||||
/// \brief Report a symbol on the debug stream.
|
||||
/// \param yykind The symbol kind.
|
||||
/// \param yyvaluep Its semantic value.]b4_locations_if([[
|
||||
/// \param yylocationp Its location.]])[
|
||||
virtual void yy_symbol_print_ (symbol_kind_type yykind,
|
||||
const value_type* yyvaluep]b4_locations_if([[,
|
||||
const location_type* yylocationp]])[) const;
|
||||
private:
|
||||
/// Debug stream.
|
||||
std::ostream* yycdebug_;
|
||||
#endif
|
||||
|
||||
]b4_parse_param_vars[
|
||||
};
|
||||
|
||||
]b4_namespace_close[
|
||||
|
||||
]b4_percent_code_get([[provides]])[
|
||||
]m4_popdef([b4_parse_param])dnl
|
||||
])[
|
||||
|
||||
]b4_header_if(
|
||||
[b4_output_begin([b4_spec_header_file])
|
||||
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
||||
[2002-2015, 2018-2021])[
|
||||
// C++ GLR parser skeleton written by Akim Demaille.
|
||||
|
||||
]b4_disclaimer[
|
||||
]b4_cpp_guard_open([b4_spec_mapped_header_file])[
|
||||
]b4_shared_declarations[
|
||||
]b4_cpp_guard_close([b4_spec_mapped_header_file])[
|
||||
]b4_output_end])
|
||||
|
||||
# Let glr.c (and b4_shared_declarations) believe that the user
|
||||
# arguments include the parser itself.
|
||||
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_wrap]))
|
||||
m4_include(b4_skeletonsdir/[glr.c])
|
||||
m4_popdef([b4_parse_param])
|
||||
3533
Engine/bin/bison-flex/data/skeletons/glr2.cc
Normal file
3533
Engine/bin/bison-flex/data/skeletons/glr2.cc
Normal file
File diff suppressed because it is too large
Load diff
27
Engine/bin/bison-flex/data/skeletons/java-skel.m4
Normal file
27
Engine/bin/bison-flex/data/skeletons/java-skel.m4
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# Java skeleton dispatching for Bison.
|
||||
|
||||
# Copyright (C) 2007, 2009-2015, 2018-2021 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
b4_glr_if( [b4_complain([%%glr-parser not supported for Java])])
|
||||
b4_nondeterministic_if([b4_complain([%%nondeterministic-parser not supported for Java])])
|
||||
|
||||
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[lalr1.java]])
|
||||
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
|
||||
|
||||
m4_include(b4_used_skeleton)
|
||||
502
Engine/bin/bison-flex/data/skeletons/java.m4
Normal file
502
Engine/bin/bison-flex/data/skeletons/java.m4
Normal file
|
|
@ -0,0 +1,502 @@
|
|||
-*- Autoconf -*-
|
||||
|
||||
# Java language support for Bison
|
||||
|
||||
# Copyright (C) 2007-2015, 2018-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
m4_include(b4_skeletonsdir/[c-like.m4])
|
||||
|
||||
|
||||
# b4_list2(LIST1, LIST2)
|
||||
# ----------------------
|
||||
# Join two lists with a comma if necessary.
|
||||
m4_define([b4_list2],
|
||||
[$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2])
|
||||
|
||||
|
||||
# b4_percent_define_get3(DEF, PRE, POST, NOT)
|
||||
# -------------------------------------------
|
||||
# Expand to the value of DEF surrounded by PRE and POST if it's %define'ed,
|
||||
# otherwise NOT.
|
||||
m4_define([b4_percent_define_get3],
|
||||
[m4_ifval(m4_quote(b4_percent_define_get([$1])),
|
||||
[$2[]b4_percent_define_get([$1])[]$3], [$4])])
|
||||
|
||||
|
||||
|
||||
# b4_flag_value(BOOLEAN-FLAG)
|
||||
# ---------------------------
|
||||
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
|
||||
|
||||
|
||||
# b4_parser_class_declaration
|
||||
# ---------------------------
|
||||
# The declaration of the parser class ("class YYParser"), with all its
|
||||
# qualifiers/annotations.
|
||||
b4_percent_define_default([[api.parser.abstract]], [[false]])
|
||||
b4_percent_define_default([[api.parser.final]], [[false]])
|
||||
b4_percent_define_default([[api.parser.public]], [[false]])
|
||||
b4_percent_define_default([[api.parser.strictfp]], [[false]])
|
||||
|
||||
m4_define([b4_parser_class_declaration],
|
||||
[b4_percent_define_get3([api.parser.annotations], [], [ ])dnl
|
||||
b4_percent_define_flag_if([api.parser.public], [public ])dnl
|
||||
b4_percent_define_flag_if([api.parser.abstract], [abstract ])dnl
|
||||
b4_percent_define_flag_if([api.parser.final], [final ])dnl
|
||||
b4_percent_define_flag_if([api.parser.strictfp], [strictfp ])dnl
|
||||
[class ]b4_parser_class[]dnl
|
||||
b4_percent_define_get3([api.parser.extends], [ extends ])dnl
|
||||
b4_percent_define_get3([api.parser.implements], [ implements ])])
|
||||
|
||||
|
||||
# b4_lexer_if(TRUE, FALSE)
|
||||
# ------------------------
|
||||
m4_define([b4_lexer_if],
|
||||
[b4_percent_code_ifdef([[lexer]], [$1], [$2])])
|
||||
|
||||
|
||||
# b4_identification
|
||||
# -----------------
|
||||
m4_define([b4_identification],
|
||||
[[ /** Version number for the Bison executable that generated this parser. */
|
||||
public static final String bisonVersion = "]b4_version_string[";
|
||||
|
||||
/** Name of the skeleton that generated this parser. */
|
||||
public static final String bisonSkeleton = ]b4_skeleton[;
|
||||
]])
|
||||
|
||||
|
||||
## ------------ ##
|
||||
## Data types. ##
|
||||
## ------------ ##
|
||||
|
||||
# b4_int_type(MIN, MAX)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# MIN to MAX (included).
|
||||
m4_define([b4_int_type],
|
||||
[m4_if(b4_ints_in($@, [-128], [127]), [1], [byte],
|
||||
b4_ints_in($@, [-32768], [32767]), [1], [short],
|
||||
[int])])
|
||||
|
||||
# b4_int_type_for(NAME)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# 'NAME_min' to 'NAME_max' (included).
|
||||
m4_define([b4_int_type_for],
|
||||
[b4_int_type($1_min, $1_max)])
|
||||
|
||||
# b4_null
|
||||
# -------
|
||||
m4_define([b4_null], [null])
|
||||
|
||||
|
||||
# b4_typed_parser_table_define(TYPE, NAME, DATA, COMMENT)
|
||||
# -------------------------------------------------------
|
||||
# We use intermediate functions (e.g., yypact_init) to work around the
|
||||
# 64KB limit for JVM methods. See
|
||||
# https://lists.gnu.org/r/help-bison/2008-11/msg00004.html.
|
||||
m4_define([b4_typed_parser_table_define],
|
||||
[m4_ifval([$4], [b4_comment([$4])
|
||||
])dnl
|
||||
[private static final ]$1[[] yy$2_ = yy$2_init();
|
||||
private static final ]$1[[] yy$2_init()
|
||||
{
|
||||
return new ]$1[[]
|
||||
{
|
||||
]$3[
|
||||
};
|
||||
}]])
|
||||
|
||||
|
||||
# b4_integral_parser_table_define(NAME, DATA, COMMENT)
|
||||
#-----------------------------------------------------
|
||||
m4_define([b4_integral_parser_table_define],
|
||||
[b4_typed_parser_table_define([b4_int_type_for([$2])], [$1], [$2], [$3])])
|
||||
|
||||
|
||||
## ------------- ##
|
||||
## Token kinds. ##
|
||||
## ------------- ##
|
||||
|
||||
|
||||
# b4_token_enum(TOKEN-NUM)
|
||||
# ------------------------
|
||||
# Output the definition of this token as an enum.
|
||||
m4_define([b4_token_enum],
|
||||
[b4_token_visible_if([$1],
|
||||
[m4_format([[ /** Token %s, to be returned by the scanner. */
|
||||
static final int %s = %s%s;
|
||||
]],
|
||||
b4_symbol([$1], [tag]),
|
||||
b4_symbol([$1], [id]),
|
||||
b4_symbol([$1], b4_api_token_raw_if([[number]], [[code]])))])])
|
||||
|
||||
|
||||
# b4_token_enums
|
||||
# --------------
|
||||
# Output the definition of the tokens (if there are) as enums.
|
||||
m4_define([b4_token_enums],
|
||||
[b4_any_token_visible_if([ /* Token kinds. */
|
||||
b4_symbol_foreach([b4_token_enum])])])
|
||||
|
||||
|
||||
|
||||
## -------------- ##
|
||||
## Symbol kinds. ##
|
||||
## -------------- ##
|
||||
|
||||
|
||||
# b4_symbol_kind(NUM)
|
||||
# -------------------
|
||||
m4_define([b4_symbol_kind],
|
||||
[SymbolKind.b4_symbol_kind_base($@)])
|
||||
|
||||
|
||||
# b4_symbol_enum(SYMBOL-NUM)
|
||||
# --------------------------
|
||||
# Output the definition of this symbol as an enum.
|
||||
m4_define([b4_symbol_enum],
|
||||
[m4_format([ %-30s %s],
|
||||
m4_format([[%s(%s)%s]],
|
||||
b4_symbol([$1], [kind_base]),
|
||||
[$1],
|
||||
m4_if([$1], b4_last_symbol, [[;]], [[,]])),
|
||||
[b4_symbol_tag_comment([$1])])])
|
||||
|
||||
|
||||
# b4_declare_symbol_enum
|
||||
# ----------------------
|
||||
# The definition of the symbol internal numbers as an enum.
|
||||
m4_define([b4_declare_symbol_enum],
|
||||
[[ public enum SymbolKind
|
||||
{
|
||||
]b4_symbol_foreach([b4_symbol_enum])[
|
||||
|
||||
private final int yycode_;
|
||||
|
||||
SymbolKind (int n) {
|
||||
this.yycode_ = n;
|
||||
}
|
||||
|
||||
private static final SymbolKind[] values_ = {
|
||||
]m4_map_args_sep([b4_symbol_kind(], [)], [,
|
||||
], b4_symbol_numbers)[
|
||||
};
|
||||
|
||||
static final SymbolKind get(int code) {
|
||||
return values_[code];
|
||||
}
|
||||
|
||||
public final int getCode() {
|
||||
return this.yycode_;
|
||||
}
|
||||
|
||||
]b4_parse_error_bmatch(
|
||||
[simple\|verbose],
|
||||
[[ /* Return YYSTR after stripping away unnecessary quotes and
|
||||
backslashes, so that it's suitable for yyerror. The heuristic is
|
||||
that double-quoting is unnecessary unless the string contains an
|
||||
apostrophe, a comma, or backslash (other than backslash-backslash).
|
||||
YYSTR is taken from yytname. */
|
||||
private static String yytnamerr_(String yystr)
|
||||
{
|
||||
if (yystr.charAt (0) == '"')
|
||||
{
|
||||
StringBuffer yyr = new StringBuffer();
|
||||
strip_quotes: for (int i = 1; i < yystr.length(); i++)
|
||||
switch (yystr.charAt(i))
|
||||
{
|
||||
case '\'':
|
||||
case ',':
|
||||
break strip_quotes;
|
||||
|
||||
case '\\':
|
||||
if (yystr.charAt(++i) != '\\')
|
||||
break strip_quotes;
|
||||
/* Fall through. */
|
||||
default:
|
||||
yyr.append(yystr.charAt(i));
|
||||
break;
|
||||
|
||||
case '"':
|
||||
return yyr.toString();
|
||||
}
|
||||
}
|
||||
return yystr;
|
||||
}
|
||||
|
||||
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at \a YYNTOKENS_, nonterminals. */
|
||||
]b4_typed_parser_table_define([String], [tname], [b4_tname])[
|
||||
|
||||
/* The user-facing name of this symbol. */
|
||||
public final String getName() {
|
||||
return yytnamerr_(yytname_[yycode_]);
|
||||
}
|
||||
]],
|
||||
[custom\|detailed],
|
||||
[[ /* YYNAMES_[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
First, the terminals, then, starting at \a YYNTOKENS_, nonterminals. */
|
||||
]b4_typed_parser_table_define([String], [names], [b4_symbol_names])[
|
||||
|
||||
/* The user-facing name of this symbol. */
|
||||
public final String getName() {
|
||||
return yynames_[yycode_];
|
||||
}]])[
|
||||
};
|
||||
]])])
|
||||
|
||||
|
||||
|
||||
# b4_case(ID, CODE, [COMMENTS])
|
||||
# -----------------------------
|
||||
# We need to fool Java's stupid unreachable code detection.
|
||||
m4_define([b4_case],
|
||||
[ case $1:m4_ifval([$3], [ b4_comment([$3])])
|
||||
if (yyn == $1)
|
||||
$2;
|
||||
break;
|
||||
])
|
||||
|
||||
|
||||
# b4_predicate_case(LABEL, CONDITIONS)
|
||||
# ------------------------------------
|
||||
m4_define([b4_predicate_case],
|
||||
[ case $1:
|
||||
if (! ($2)) YYERROR;
|
||||
break;
|
||||
])
|
||||
|
||||
|
||||
## -------- ##
|
||||
## Checks. ##
|
||||
## -------- ##
|
||||
|
||||
b4_percent_define_check_kind([[api.value.type]], [code], [deprecated])
|
||||
|
||||
b4_percent_define_check_kind([[annotations]], [code], [deprecated])
|
||||
b4_percent_define_check_kind([[extends]], [code], [deprecated])
|
||||
b4_percent_define_check_kind([[implements]], [code], [deprecated])
|
||||
b4_percent_define_check_kind([[init_throws]], [code], [deprecated])
|
||||
b4_percent_define_check_kind([[lex_throws]], [code], [deprecated])
|
||||
b4_percent_define_check_kind([[api.parser.class]], [code], [deprecated])
|
||||
b4_percent_define_check_kind([[throws]], [code], [deprecated])
|
||||
|
||||
|
||||
|
||||
## ---------------- ##
|
||||
## Default values. ##
|
||||
## ---------------- ##
|
||||
|
||||
m4_define([b4_yystype], [b4_percent_define_get([[api.value.type]])])
|
||||
b4_percent_define_default([[api.value.type]], [[Object]])
|
||||
b4_percent_define_default([[api.symbol.prefix]], [[S_]])
|
||||
|
||||
# b4_api_prefix, b4_api_PREFIX
|
||||
# ----------------------------
|
||||
# Corresponds to %define api.prefix
|
||||
b4_percent_define_default([[api.prefix]], [[YY]])
|
||||
m4_define([b4_api_prefix],
|
||||
[b4_percent_define_get([[api.prefix]])])
|
||||
m4_define([b4_api_PREFIX],
|
||||
[m4_toupper(b4_api_prefix)])
|
||||
|
||||
# b4_prefix
|
||||
# ---------
|
||||
# If the %name-prefix is not given, it is api.prefix.
|
||||
m4_define_default([b4_prefix], [b4_api_prefix])
|
||||
|
||||
b4_percent_define_default([[api.parser.class]], [b4_prefix[]Parser])
|
||||
m4_define([b4_parser_class], [b4_percent_define_get([[api.parser.class]])])
|
||||
|
||||
b4_percent_define_default([[lex_throws]], [[java.io.IOException]])
|
||||
m4_define([b4_lex_throws], [b4_percent_define_get([[lex_throws]])])
|
||||
|
||||
b4_percent_define_default([[throws]], [])
|
||||
m4_define([b4_throws], [b4_percent_define_get([[throws]])])
|
||||
|
||||
b4_percent_define_default([[init_throws]], [])
|
||||
m4_define([b4_init_throws], [b4_percent_define_get([[init_throws]])])
|
||||
|
||||
b4_percent_define_default([[api.location.type]], [Location])
|
||||
m4_define([b4_location_type], [b4_percent_define_get([[api.location.type]])])
|
||||
|
||||
b4_percent_define_default([[api.position.type]], [Position])
|
||||
m4_define([b4_position_type], [b4_percent_define_get([[api.position.type]])])
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
## Semantic Values. ##
|
||||
## ----------------- ##
|
||||
|
||||
|
||||
# b4_symbol_translate(STRING)
|
||||
# ---------------------------
|
||||
# Used by "bison" in the array of symbol names to mark those that
|
||||
# require translation.
|
||||
m4_define([b4_symbol_translate],
|
||||
[[i18n($1)]])
|
||||
|
||||
|
||||
# b4_trans(STRING)
|
||||
# ----------------
|
||||
# Translate a string if i18n is enabled. Avoid collision with b4_translate.
|
||||
m4_define([b4_trans],
|
||||
[b4_has_translations_if([i18n($1)], [$1])])
|
||||
|
||||
|
||||
|
||||
# b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
|
||||
# ----------------------------------------------
|
||||
# See README.
|
||||
m4_define([b4_symbol_value],
|
||||
[m4_ifval([$3],
|
||||
[(($3)($1))],
|
||||
[m4_ifval([$2],
|
||||
[b4_symbol_if([$2], [has_type],
|
||||
[((b4_symbol([$2], [type]))($1))],
|
||||
[$1])],
|
||||
[$1])])])
|
||||
|
||||
|
||||
# b4_lhs_value([SYMBOL-NUM], [TYPE])
|
||||
# ----------------------------------
|
||||
# See README.
|
||||
m4_define([b4_lhs_value], [yyval])
|
||||
|
||||
|
||||
# b4_rhs_data(RULE-LENGTH, POS)
|
||||
# -----------------------------
|
||||
# See README.
|
||||
m4_define([b4_rhs_data],
|
||||
[yystack.valueAt (b4_subtract($@))])
|
||||
|
||||
# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
|
||||
# --------------------------------------------------
|
||||
# See README.
|
||||
#
|
||||
# In this simple implementation, %token and %type have class names
|
||||
# between the angle brackets.
|
||||
m4_define([b4_rhs_value],
|
||||
[b4_symbol_value([b4_rhs_data([$1], [$2])], [$3], [$4])])
|
||||
|
||||
|
||||
# b4_lhs_location()
|
||||
# -----------------
|
||||
# Expansion of @$.
|
||||
m4_define([b4_lhs_location],
|
||||
[(yyloc)])
|
||||
|
||||
|
||||
# b4_rhs_location(RULE-LENGTH, POS)
|
||||
# ---------------------------------
|
||||
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
|
||||
# on RHS.
|
||||
m4_define([b4_rhs_location],
|
||||
[yystack.locationAt (b4_subtract($@))])
|
||||
|
||||
|
||||
# b4_lex_param
|
||||
# b4_parse_param
|
||||
# --------------
|
||||
# If defined, b4_lex_param arrives double quoted, but below we prefer
|
||||
# it to be single quoted. Same for b4_parse_param.
|
||||
|
||||
# TODO: should be in bison.m4
|
||||
m4_define_default([b4_lex_param], [[]])
|
||||
m4_define([b4_lex_param], b4_lex_param)
|
||||
m4_define([b4_parse_param], b4_parse_param)
|
||||
|
||||
# b4_lex_param_decl
|
||||
# -----------------
|
||||
# Extra formal arguments of the constructor.
|
||||
m4_define([b4_lex_param_decl],
|
||||
[m4_ifset([b4_lex_param],
|
||||
[b4_remove_comma([$1],
|
||||
b4_param_decls(b4_lex_param))],
|
||||
[$1])])
|
||||
|
||||
m4_define([b4_param_decls],
|
||||
[m4_map([b4_param_decl], [$@])])
|
||||
m4_define([b4_param_decl], [, $1])
|
||||
|
||||
m4_define([b4_remove_comma], [m4_ifval(m4_quote($1), [$1, ], [])m4_shift2($@)])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_decl
|
||||
# -------------------
|
||||
# Extra formal arguments of the constructor.
|
||||
m4_define([b4_parse_param_decl],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[b4_remove_comma([$1],
|
||||
b4_param_decls(b4_parse_param))],
|
||||
[$1])])
|
||||
|
||||
|
||||
|
||||
# b4_lex_param_call
|
||||
# -----------------
|
||||
# Delegating the lexer parameters to the lexer constructor.
|
||||
m4_define([b4_lex_param_call],
|
||||
[m4_ifset([b4_lex_param],
|
||||
[b4_remove_comma([$1],
|
||||
b4_param_calls(b4_lex_param))],
|
||||
[$1])])
|
||||
m4_define([b4_param_calls],
|
||||
[m4_map([b4_param_call], [$@])])
|
||||
m4_define([b4_param_call], [, $2])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_cons
|
||||
# -------------------
|
||||
# Extra initialisations of the constructor.
|
||||
m4_define([b4_parse_param_cons],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[b4_constructor_calls(b4_parse_param)])])
|
||||
|
||||
m4_define([b4_constructor_calls],
|
||||
[m4_map([b4_constructor_call], [$@])])
|
||||
m4_define([b4_constructor_call],
|
||||
[this.$2 = $2;
|
||||
])
|
||||
|
||||
|
||||
|
||||
# b4_parse_param_vars
|
||||
# -------------------
|
||||
# Extra instance variables.
|
||||
m4_define([b4_parse_param_vars],
|
||||
[m4_ifset([b4_parse_param],
|
||||
[
|
||||
/* User arguments. */
|
||||
b4_var_decls(b4_parse_param)])])
|
||||
|
||||
m4_define([b4_var_decls],
|
||||
[m4_map_sep([b4_var_decl], [
|
||||
], [$@])])
|
||||
m4_define([b4_var_decl],
|
||||
[ protected final $1;])
|
||||
|
||||
|
||||
|
||||
# b4_maybe_throws(THROWS)
|
||||
# -----------------------
|
||||
# Expand to either an empty string or "throws THROWS".
|
||||
m4_define([b4_maybe_throws],
|
||||
[m4_ifval($1, [ throws $1])])
|
||||
1633
Engine/bin/bison-flex/data/skeletons/lalr1.cc
Normal file
1633
Engine/bin/bison-flex/data/skeletons/lalr1.cc
Normal file
File diff suppressed because it is too large
Load diff
1326
Engine/bin/bison-flex/data/skeletons/lalr1.d
Normal file
1326
Engine/bin/bison-flex/data/skeletons/lalr1.d
Normal file
File diff suppressed because it is too large
Load diff
1303
Engine/bin/bison-flex/data/skeletons/lalr1.java
Normal file
1303
Engine/bin/bison-flex/data/skeletons/lalr1.java
Normal file
File diff suppressed because it is too large
Load diff
380
Engine/bin/bison-flex/data/skeletons/location.cc
Normal file
380
Engine/bin/bison-flex/data/skeletons/location.cc
Normal file
|
|
@ -0,0 +1,380 @@
|
|||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
m4_pushdef([b4_copyright_years],
|
||||
[2002-2015, 2018-2021])
|
||||
|
||||
|
||||
# b4_location_file
|
||||
# ----------------
|
||||
# Name of the file containing the position/location class,
|
||||
# if we want this file.
|
||||
b4_percent_define_check_file([b4_location_file],
|
||||
[[api.location.file]],
|
||||
b4_header_if([[location.hh]]))
|
||||
|
||||
# b4_location_include
|
||||
# -------------------
|
||||
# If location.hh is to be generated, the name under which should it be
|
||||
# included.
|
||||
#
|
||||
# b4_location_path
|
||||
# ----------------
|
||||
# The path to use for the CPP guard.
|
||||
m4_ifdef([b4_location_file],
|
||||
[m4_define([b4_location_include],
|
||||
[b4_percent_define_get([[api.location.include]],
|
||||
["b4_location_file"])])
|
||||
m4_define([b4_location_path],
|
||||
b4_percent_define_get([[api.location.include]],
|
||||
["b4_mapped_dir_prefix[]b4_location_file"]))
|
||||
m4_define([b4_location_path],
|
||||
m4_substr(m4_defn([b4_location_path]), 1, m4_eval(m4_len(m4_defn([b4_location_path])) - 2)))
|
||||
])
|
||||
|
||||
|
||||
# b4_position_file
|
||||
# ----------------
|
||||
# Name of the file containing the position class, if we want this file.
|
||||
b4_header_if(
|
||||
[b4_required_version_if(
|
||||
[30200], [],
|
||||
[m4_ifdef([b4_location_file],
|
||||
[m4_define([b4_position_file], [position.hh])])])])
|
||||
|
||||
|
||||
|
||||
# b4_location_define
|
||||
# ------------------
|
||||
# Define the position and location classes.
|
||||
m4_define([b4_location_define],
|
||||
[[ /// A point in a source file.
|
||||
class position
|
||||
{
|
||||
public:
|
||||
/// Type for file name.
|
||||
typedef ]b4_percent_define_get([[api.filename.type]])[ filename_type;
|
||||
/// Type for line and column numbers.
|
||||
typedef int counter_type;
|
||||
]m4_ifdef([b4_location_constructors], [[
|
||||
/// Construct a position.
|
||||
explicit position (filename_type* f = YY_NULLPTR,
|
||||
counter_type l = ]b4_location_initial_line[,
|
||||
counter_type c = ]b4_location_initial_column[)
|
||||
: filename (f)
|
||||
, line (l)
|
||||
, column (c)
|
||||
{}
|
||||
|
||||
]])[
|
||||
/// Initialization.
|
||||
void initialize (filename_type* fn = YY_NULLPTR,
|
||||
counter_type l = ]b4_location_initial_line[,
|
||||
counter_type c = ]b4_location_initial_column[)
|
||||
{
|
||||
filename = fn;
|
||||
line = l;
|
||||
column = c;
|
||||
}
|
||||
|
||||
/** \name Line and Column related manipulators
|
||||
** \{ */
|
||||
/// (line related) Advance to the COUNT next lines.
|
||||
void lines (counter_type count = 1)
|
||||
{
|
||||
if (count)
|
||||
{
|
||||
column = ]b4_location_initial_column[;
|
||||
line = add_ (line, count, ]b4_location_initial_line[);
|
||||
}
|
||||
}
|
||||
|
||||
/// (column related) Advance to the COUNT next columns.
|
||||
void columns (counter_type count = 1)
|
||||
{
|
||||
column = add_ (column, count, ]b4_location_initial_column[);
|
||||
}
|
||||
/** \} */
|
||||
|
||||
/// File name to which this position refers.
|
||||
filename_type* filename;
|
||||
/// Current line number.
|
||||
counter_type line;
|
||||
/// Current column number.
|
||||
counter_type column;
|
||||
|
||||
private:
|
||||
/// Compute max (min, lhs+rhs).
|
||||
static counter_type add_ (counter_type lhs, counter_type rhs, counter_type min)
|
||||
{
|
||||
return lhs + rhs < min ? min : lhs + rhs;
|
||||
}
|
||||
};
|
||||
|
||||
/// Add \a width columns, in place.
|
||||
inline position&
|
||||
operator+= (position& res, position::counter_type width)
|
||||
{
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add \a width columns.
|
||||
inline position
|
||||
operator+ (position res, position::counter_type width)
|
||||
{
|
||||
return res += width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns, in place.
|
||||
inline position&
|
||||
operator-= (position& res, position::counter_type width)
|
||||
{
|
||||
return res += -width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns.
|
||||
inline position
|
||||
operator- (position res, position::counter_type width)
|
||||
{
|
||||
return res -= width;
|
||||
}
|
||||
]b4_percent_define_flag_if([[define_location_comparison]], [[
|
||||
/// Compare two position objects.
|
||||
inline bool
|
||||
operator== (const position& pos1, const position& pos2)
|
||||
{
|
||||
return (pos1.line == pos2.line
|
||||
&& pos1.column == pos2.column
|
||||
&& (pos1.filename == pos2.filename
|
||||
|| (pos1.filename && pos2.filename
|
||||
&& *pos1.filename == *pos2.filename)));
|
||||
}
|
||||
|
||||
/// Compare two position objects.
|
||||
inline bool
|
||||
operator!= (const position& pos1, const position& pos2)
|
||||
{
|
||||
return !(pos1 == pos2);
|
||||
}
|
||||
]])[
|
||||
/** \brief Intercept output stream redirection.
|
||||
** \param ostr the destination output stream
|
||||
** \param pos a reference to the position to redirect
|
||||
*/
|
||||
template <typename YYChar>
|
||||
std::basic_ostream<YYChar>&
|
||||
operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)
|
||||
{
|
||||
if (pos.filename)
|
||||
ostr << *pos.filename << ':';
|
||||
return ostr << pos.line << '.' << pos.column;
|
||||
}
|
||||
|
||||
/// Two points in a source file.
|
||||
class location
|
||||
{
|
||||
public:
|
||||
/// Type for file name.
|
||||
typedef position::filename_type filename_type;
|
||||
/// Type for line and column numbers.
|
||||
typedef position::counter_type counter_type;
|
||||
]m4_ifdef([b4_location_constructors], [
|
||||
/// Construct a location from \a b to \a e.
|
||||
location (const position& b, const position& e)
|
||||
: begin (b)
|
||||
, end (e)
|
||||
{}
|
||||
|
||||
/// Construct a 0-width location in \a p.
|
||||
explicit location (const position& p = position ())
|
||||
: begin (p)
|
||||
, end (p)
|
||||
{}
|
||||
|
||||
/// Construct a 0-width location in \a f, \a l, \a c.
|
||||
explicit location (filename_type* f,
|
||||
counter_type l = ]b4_location_initial_line[,
|
||||
counter_type c = ]b4_location_initial_column[)
|
||||
: begin (f, l, c)
|
||||
, end (f, l, c)
|
||||
{}
|
||||
|
||||
])[
|
||||
/// Initialization.
|
||||
void initialize (filename_type* f = YY_NULLPTR,
|
||||
counter_type l = ]b4_location_initial_line[,
|
||||
counter_type c = ]b4_location_initial_column[)
|
||||
{
|
||||
begin.initialize (f, l, c);
|
||||
end = begin;
|
||||
}
|
||||
|
||||
/** \name Line and Column related manipulators
|
||||
** \{ */
|
||||
public:
|
||||
/// Reset initial location to final location.
|
||||
void step ()
|
||||
{
|
||||
begin = end;
|
||||
}
|
||||
|
||||
/// Extend the current location to the COUNT next columns.
|
||||
void columns (counter_type count = 1)
|
||||
{
|
||||
end += count;
|
||||
}
|
||||
|
||||
/// Extend the current location to the COUNT next lines.
|
||||
void lines (counter_type count = 1)
|
||||
{
|
||||
end.lines (count);
|
||||
}
|
||||
/** \} */
|
||||
|
||||
|
||||
public:
|
||||
/// Beginning of the located region.
|
||||
position begin;
|
||||
/// End of the located region.
|
||||
position end;
|
||||
};
|
||||
|
||||
/// Join two locations, in place.
|
||||
inline location&
|
||||
operator+= (location& res, const location& end)
|
||||
{
|
||||
res.end = end.end;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Join two locations.
|
||||
inline location
|
||||
operator+ (location res, const location& end)
|
||||
{
|
||||
return res += end;
|
||||
}
|
||||
|
||||
/// Add \a width columns to the end position, in place.
|
||||
inline location&
|
||||
operator+= (location& res, location::counter_type width)
|
||||
{
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add \a width columns to the end position.
|
||||
inline location
|
||||
operator+ (location res, location::counter_type width)
|
||||
{
|
||||
return res += width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns to the end position, in place.
|
||||
inline location&
|
||||
operator-= (location& res, location::counter_type width)
|
||||
{
|
||||
return res += -width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns to the end position.
|
||||
inline location
|
||||
operator- (location res, location::counter_type width)
|
||||
{
|
||||
return res -= width;
|
||||
}
|
||||
]b4_percent_define_flag_if([[define_location_comparison]], [[
|
||||
/// Compare two location objects.
|
||||
inline bool
|
||||
operator== (const location& loc1, const location& loc2)
|
||||
{
|
||||
return loc1.begin == loc2.begin && loc1.end == loc2.end;
|
||||
}
|
||||
|
||||
/// Compare two location objects.
|
||||
inline bool
|
||||
operator!= (const location& loc1, const location& loc2)
|
||||
{
|
||||
return !(loc1 == loc2);
|
||||
}
|
||||
]])[
|
||||
/** \brief Intercept output stream redirection.
|
||||
** \param ostr the destination output stream
|
||||
** \param loc a reference to the location to redirect
|
||||
**
|
||||
** Avoid duplicate information.
|
||||
*/
|
||||
template <typename YYChar>
|
||||
std::basic_ostream<YYChar>&
|
||||
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
||||
{
|
||||
location::counter_type end_col
|
||||
= 0 < loc.end.column ? loc.end.column - 1 : 0;
|
||||
ostr << loc.begin;
|
||||
if (loc.end.filename
|
||||
&& (!loc.begin.filename
|
||||
|| *loc.begin.filename != *loc.end.filename))
|
||||
ostr << '-' << loc.end.filename << ':' << loc.end.line << '.' << end_col;
|
||||
else if (loc.begin.line < loc.end.line)
|
||||
ostr << '-' << loc.end.line << '.' << end_col;
|
||||
else if (loc.begin.column < end_col)
|
||||
ostr << '-' << end_col;
|
||||
return ostr;
|
||||
}
|
||||
]])
|
||||
|
||||
|
||||
m4_ifdef([b4_position_file], [[
|
||||
]b4_output_begin([b4_dir_prefix], [b4_position_file])[
|
||||
]b4_generated_by[
|
||||
// Starting with Bison 3.2, this file is useless: the structure it
|
||||
// used to define is now defined in "]b4_location_file[".
|
||||
//
|
||||
// To get rid of this file:
|
||||
// 1. add '%require "3.2"' (or newer) to your grammar file
|
||||
// 2. remove references to this file from your build system
|
||||
// 3. if you used to include it, include "]b4_location_file[" instead.
|
||||
|
||||
#include ]b4_location_include[
|
||||
]b4_output_end[
|
||||
]])
|
||||
|
||||
|
||||
m4_ifdef([b4_location_file], [[
|
||||
]b4_output_begin([b4_dir_prefix], [b4_location_file])[
|
||||
]b4_copyright([Locations for Bison parsers in C++])[
|
||||
/**
|
||||
** \file ]b4_location_path[
|
||||
** Define the ]b4_namespace_ref[::location class.
|
||||
*/
|
||||
|
||||
]b4_cpp_guard_open([b4_location_path])[
|
||||
|
||||
# include <iostream>
|
||||
# include <string>
|
||||
|
||||
]b4_null_define[
|
||||
|
||||
]b4_namespace_open[
|
||||
]b4_location_define[
|
||||
]b4_namespace_close[
|
||||
]b4_cpp_guard_close([b4_location_path])[
|
||||
]b4_output_end[
|
||||
]])
|
||||
|
||||
|
||||
m4_popdef([b4_copyright_years])
|
||||
157
Engine/bin/bison-flex/data/skeletons/stack.hh
Normal file
157
Engine/bin/bison-flex/data/skeletons/stack.hh
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
# b4_stack_file
|
||||
# -------------
|
||||
# Name of the file containing the stack class, if we want this file.
|
||||
b4_header_if([b4_required_version_if([30200], [],
|
||||
[m4_define([b4_stack_file], [stack.hh])])])
|
||||
|
||||
|
||||
# b4_stack_define
|
||||
# ---------------
|
||||
m4_define([b4_stack_define],
|
||||
[[ /// A stack with random access from its top.
|
||||
template <typename T, typename S = std::vector<T> >
|
||||
class stack
|
||||
{
|
||||
public:
|
||||
// Hide our reversed order.
|
||||
typedef typename S::iterator iterator;
|
||||
typedef typename S::const_iterator const_iterator;
|
||||
typedef typename S::size_type size_type;
|
||||
typedef typename std::ptrdiff_t index_type;
|
||||
|
||||
stack (size_type n = 200) YY_NOEXCEPT
|
||||
: seq_ (n)
|
||||
{}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Non copyable.
|
||||
stack (const stack&) = delete;
|
||||
/// Non copyable.
|
||||
stack& operator= (const stack&) = delete;
|
||||
#endif
|
||||
|
||||
/// Random access.
|
||||
///
|
||||
/// Index 0 returns the topmost element.
|
||||
const T&
|
||||
operator[] (index_type i) const
|
||||
{
|
||||
return seq_[size_type (size () - 1 - i)];
|
||||
}
|
||||
|
||||
/// Random access.
|
||||
///
|
||||
/// Index 0 returns the topmost element.
|
||||
T&
|
||||
operator[] (index_type i)
|
||||
{
|
||||
return seq_[size_type (size () - 1 - i)];
|
||||
}
|
||||
|
||||
/// Steal the contents of \a t.
|
||||
///
|
||||
/// Close to move-semantics.
|
||||
void
|
||||
push (YY_MOVE_REF (T) t)
|
||||
{
|
||||
seq_.push_back (T ());
|
||||
operator[] (0).move (t);
|
||||
}
|
||||
|
||||
/// Pop elements from the stack.
|
||||
void
|
||||
pop (std::ptrdiff_t n = 1) YY_NOEXCEPT
|
||||
{
|
||||
for (; 0 < n; --n)
|
||||
seq_.pop_back ();
|
||||
}
|
||||
|
||||
/// Pop all elements from the stack.
|
||||
void
|
||||
clear () YY_NOEXCEPT
|
||||
{
|
||||
seq_.clear ();
|
||||
}
|
||||
|
||||
/// Number of elements on the stack.
|
||||
index_type
|
||||
size () const YY_NOEXCEPT
|
||||
{
|
||||
return index_type (seq_.size ());
|
||||
}
|
||||
|
||||
/// Iterator on top of the stack (going downwards).
|
||||
const_iterator
|
||||
begin () const YY_NOEXCEPT
|
||||
{
|
||||
return seq_.begin ();
|
||||
}
|
||||
|
||||
/// Bottom of the stack.
|
||||
const_iterator
|
||||
end () const YY_NOEXCEPT
|
||||
{
|
||||
return seq_.end ();
|
||||
}
|
||||
|
||||
/// Present a slice of the top of a stack.
|
||||
class slice
|
||||
{
|
||||
public:
|
||||
slice (const stack& stack, index_type range) YY_NOEXCEPT
|
||||
: stack_ (stack)
|
||||
, range_ (range)
|
||||
{}
|
||||
|
||||
const T&
|
||||
operator[] (index_type i) const
|
||||
{
|
||||
return stack_[range_ - i];
|
||||
}
|
||||
|
||||
private:
|
||||
const stack& stack_;
|
||||
index_type range_;
|
||||
};
|
||||
|
||||
private:
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
/// Non copyable.
|
||||
stack (const stack&);
|
||||
/// Non copyable.
|
||||
stack& operator= (const stack&);
|
||||
#endif
|
||||
/// The wrapped container.
|
||||
S seq_;
|
||||
};
|
||||
]])
|
||||
|
||||
m4_ifdef([b4_stack_file],
|
||||
[b4_output_begin([b4_dir_prefix], [b4_stack_file])[
|
||||
]b4_generated_by[
|
||||
// Starting with Bison 3.2, this file is useless: the structure it
|
||||
// used to define is now defined with the parser itself.
|
||||
//
|
||||
// To get rid of this file:
|
||||
// 1. add '%require "3.2"' (or newer) to your grammar file
|
||||
// 2. remove references to this file from your build system.
|
||||
]b4_output_end[
|
||||
]])
|
||||
2
Engine/bin/bison-flex/data/skeletons/traceon.m4
Normal file
2
Engine/bin/bison-flex/data/skeletons/traceon.m4
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
dnl GNU M4 treats -dV in a position-independent manner.
|
||||
m4_debugmode(V)m4_traceon()dnl
|
||||
525
Engine/bin/bison-flex/data/skeletons/variant.hh
Normal file
525
Engine/bin/bison-flex/data/skeletons/variant.hh
Normal file
|
|
@ -0,0 +1,525 @@
|
|||
# C++ skeleton for Bison
|
||||
|
||||
# Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
## --------- ##
|
||||
## variant. ##
|
||||
## --------- ##
|
||||
|
||||
# b4_assert
|
||||
# ---------
|
||||
# The name of YY_ASSERT.
|
||||
m4_define([b4_assert],
|
||||
[b4_api_PREFIX[]_ASSERT])
|
||||
|
||||
|
||||
# b4_symbol_variant(YYTYPE, YYVAL, ACTION, [ARGS])
|
||||
# ------------------------------------------------
|
||||
# Run some ACTION ("build", or "destroy") on YYVAL of symbol type
|
||||
# YYTYPE.
|
||||
m4_define([b4_symbol_variant],
|
||||
[m4_pushdef([b4_dollar_dollar],
|
||||
[$2.$3< $][3 > (m4_shift3($@))])dnl
|
||||
switch ($1)
|
||||
{
|
||||
b4_type_foreach([_b4_type_action])[]dnl
|
||||
default:
|
||||
break;
|
||||
}
|
||||
m4_popdef([b4_dollar_dollar])dnl
|
||||
])
|
||||
|
||||
|
||||
# _b4_char_sizeof_counter
|
||||
# -----------------------
|
||||
# A counter used by _b4_char_sizeof_dummy to create fresh symbols.
|
||||
m4_define([_b4_char_sizeof_counter],
|
||||
[0])
|
||||
|
||||
# _b4_char_sizeof_dummy
|
||||
# ---------------------
|
||||
# At each call return a new C++ identifier.
|
||||
m4_define([_b4_char_sizeof_dummy],
|
||||
[m4_define([_b4_char_sizeof_counter], m4_incr(_b4_char_sizeof_counter))dnl
|
||||
dummy[]_b4_char_sizeof_counter])
|
||||
|
||||
|
||||
# b4_char_sizeof(SYMBOL-NUMS)
|
||||
# ---------------------------
|
||||
# To be mapped on the list of type names to produce:
|
||||
#
|
||||
# char dummy1[sizeof (type_name_1)];
|
||||
# char dummy2[sizeof (type_name_2)];
|
||||
#
|
||||
# for defined type names.
|
||||
m4_define([b4_char_sizeof],
|
||||
[b4_symbol_if([$1], [has_type],
|
||||
[
|
||||
m4_map([ b4_symbol_tag_comment], [$@])dnl
|
||||
char _b4_char_sizeof_dummy@{sizeof (b4_symbol([$1], [type]))@};
|
||||
])])
|
||||
|
||||
|
||||
# b4_variant_includes
|
||||
# -------------------
|
||||
# The needed includes for variants support.
|
||||
m4_define([b4_variant_includes],
|
||||
[b4_parse_assert_if([[#include <typeinfo>
|
||||
#ifndef ]b4_assert[
|
||||
# include <cassert>
|
||||
# define ]b4_assert[ assert
|
||||
#endif
|
||||
]])])
|
||||
|
||||
|
||||
|
||||
## -------------------------- ##
|
||||
## Adjustments for variants. ##
|
||||
## -------------------------- ##
|
||||
|
||||
|
||||
# b4_value_type_declare
|
||||
# ---------------------
|
||||
# Define value_type.
|
||||
m4_define([b4_value_type_declare],
|
||||
[[ /// A buffer to store and retrieve objects.
|
||||
///
|
||||
/// Sort of a variant, but does not keep track of the nature
|
||||
/// of the stored data, since that knowledge is available
|
||||
/// via the current parser state.
|
||||
class value_type
|
||||
{
|
||||
public:
|
||||
/// Type of *this.
|
||||
typedef value_type self_type;
|
||||
|
||||
/// Empty construction.
|
||||
value_type () YY_NOEXCEPT
|
||||
: yyraw_ ()]b4_parse_assert_if([
|
||||
, yytypeid_ (YY_NULLPTR)])[
|
||||
{}
|
||||
|
||||
/// Construct and fill.
|
||||
template <typename T>
|
||||
value_type (YY_RVREF (T) t)]b4_parse_assert_if([
|
||||
: yytypeid_ (&typeid (T))])[
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (sizeof (T) <= size);]])[
|
||||
new (yyas_<T> ()) T (YY_MOVE (t));
|
||||
}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Non copyable.
|
||||
value_type (const self_type&) = delete;
|
||||
/// Non copyable.
|
||||
self_type& operator= (const self_type&) = delete;
|
||||
#endif
|
||||
|
||||
/// Destruction, allowed only if empty.
|
||||
~value_type () YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([
|
||||
]b4_assert[ (!yytypeid_);
|
||||
])[}
|
||||
|
||||
# if 201103L <= YY_CPLUSPLUS
|
||||
/// Instantiate a \a T in here from \a t.
|
||||
template <typename T, typename... U>
|
||||
T&
|
||||
emplace (U&&... u)
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (!yytypeid_);
|
||||
]b4_assert[ (sizeof (T) <= size);
|
||||
yytypeid_ = & typeid (T);]])[
|
||||
return *new (yyas_<T> ()) T (std::forward <U>(u)...);
|
||||
}
|
||||
# else
|
||||
/// Instantiate an empty \a T in here.
|
||||
template <typename T>
|
||||
T&
|
||||
emplace ()
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (!yytypeid_);
|
||||
]b4_assert[ (sizeof (T) <= size);
|
||||
yytypeid_ = & typeid (T);]])[
|
||||
return *new (yyas_<T> ()) T ();
|
||||
}
|
||||
|
||||
/// Instantiate a \a T in here from \a t.
|
||||
template <typename T>
|
||||
T&
|
||||
emplace (const T& t)
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (!yytypeid_);
|
||||
]b4_assert[ (sizeof (T) <= size);
|
||||
yytypeid_ = & typeid (T);]])[
|
||||
return *new (yyas_<T> ()) T (t);
|
||||
}
|
||||
# endif
|
||||
|
||||
/// Instantiate an empty \a T in here.
|
||||
/// Obsolete, use emplace.
|
||||
template <typename T>
|
||||
T&
|
||||
build ()
|
||||
{
|
||||
return emplace<T> ();
|
||||
}
|
||||
|
||||
/// Instantiate a \a T in here from \a t.
|
||||
/// Obsolete, use emplace.
|
||||
template <typename T>
|
||||
T&
|
||||
build (const T& t)
|
||||
{
|
||||
return emplace<T> (t);
|
||||
}
|
||||
|
||||
/// Accessor to a built \a T.
|
||||
template <typename T>
|
||||
T&
|
||||
as () YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (yytypeid_);
|
||||
]b4_assert[ (*yytypeid_ == typeid (T));
|
||||
]b4_assert[ (sizeof (T) <= size);]])[
|
||||
return *yyas_<T> ();
|
||||
}
|
||||
|
||||
/// Const accessor to a built \a T (for %printer).
|
||||
template <typename T>
|
||||
const T&
|
||||
as () const YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (yytypeid_);
|
||||
]b4_assert[ (*yytypeid_ == typeid (T));
|
||||
]b4_assert[ (sizeof (T) <= size);]])[
|
||||
return *yyas_<T> ();
|
||||
}
|
||||
|
||||
/// Swap the content with \a that, of same type.
|
||||
///
|
||||
/// Both variants must be built beforehand, because swapping the actual
|
||||
/// data requires reading it (with as()), and this is not possible on
|
||||
/// unconstructed variants: it would require some dynamic testing, which
|
||||
/// should not be the variant's responsibility.
|
||||
/// Swapping between built and (possibly) non-built is done with
|
||||
/// self_type::move ().
|
||||
template <typename T>
|
||||
void
|
||||
swap (self_type& that) YY_NOEXCEPT
|
||||
{]b4_parse_assert_if([[
|
||||
]b4_assert[ (yytypeid_);
|
||||
]b4_assert[ (*yytypeid_ == *that.yytypeid_);]])[
|
||||
std::swap (as<T> (), that.as<T> ());
|
||||
}
|
||||
|
||||
/// Move the content of \a that to this.
|
||||
///
|
||||
/// Destroys \a that.
|
||||
template <typename T>
|
||||
void
|
||||
move (self_type& that)
|
||||
{
|
||||
# if 201103L <= YY_CPLUSPLUS
|
||||
emplace<T> (std::move (that.as<T> ()));
|
||||
# else
|
||||
emplace<T> ();
|
||||
swap<T> (that);
|
||||
# endif
|
||||
that.destroy<T> ();
|
||||
}
|
||||
|
||||
# if 201103L <= YY_CPLUSPLUS
|
||||
/// Move the content of \a that to this.
|
||||
template <typename T>
|
||||
void
|
||||
move (self_type&& that)
|
||||
{
|
||||
emplace<T> (std::move (that.as<T> ()));
|
||||
that.destroy<T> ();
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Copy the content of \a that to this.
|
||||
template <typename T>
|
||||
void
|
||||
copy (const self_type& that)
|
||||
{
|
||||
emplace<T> (that.as<T> ());
|
||||
}
|
||||
|
||||
/// Destroy the stored \a T.
|
||||
template <typename T>
|
||||
void
|
||||
destroy ()
|
||||
{
|
||||
as<T> ().~T ();]b4_parse_assert_if([
|
||||
yytypeid_ = YY_NULLPTR;])[
|
||||
}
|
||||
|
||||
private:
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
/// Non copyable.
|
||||
value_type (const self_type&);
|
||||
/// Non copyable.
|
||||
self_type& operator= (const self_type&);
|
||||
#endif
|
||||
|
||||
/// Accessor to raw memory as \a T.
|
||||
template <typename T>
|
||||
T*
|
||||
yyas_ () YY_NOEXCEPT
|
||||
{
|
||||
void *yyp = yyraw_;
|
||||
return static_cast<T*> (yyp);
|
||||
}
|
||||
|
||||
/// Const accessor to raw memory as \a T.
|
||||
template <typename T>
|
||||
const T*
|
||||
yyas_ () const YY_NOEXCEPT
|
||||
{
|
||||
const void *yyp = yyraw_;
|
||||
return static_cast<const T*> (yyp);
|
||||
}
|
||||
|
||||
/// An auxiliary type to compute the largest semantic type.
|
||||
union union_type
|
||||
{]b4_type_foreach([b4_char_sizeof])[ };
|
||||
|
||||
/// The size of the largest semantic type.
|
||||
enum { size = sizeof (union_type) };
|
||||
|
||||
/// A buffer to store semantic values.
|
||||
union
|
||||
{
|
||||
/// Strongest alignment constraints.
|
||||
long double yyalign_me_;
|
||||
/// A buffer large enough to store any of the semantic values.
|
||||
char yyraw_[size];
|
||||
};]b4_parse_assert_if([
|
||||
|
||||
/// Whether the content is built: if defined, the name of the stored type.
|
||||
const std::type_info *yytypeid_;])[
|
||||
};
|
||||
]])
|
||||
|
||||
|
||||
# How the semantic value is extracted when using variants.
|
||||
|
||||
# b4_symbol_value(VAL, SYMBOL-NUM, [TYPE])
|
||||
# ----------------------------------------
|
||||
# See README.
|
||||
m4_define([b4_symbol_value],
|
||||
[m4_ifval([$3],
|
||||
[$1.as< $3 > ()],
|
||||
[m4_ifval([$2],
|
||||
[b4_symbol_if([$2], [has_type],
|
||||
[$1.as < b4_symbol([$2], [type]) > ()],
|
||||
[$1])],
|
||||
[$1])])])
|
||||
|
||||
# b4_symbol_value_template(VAL, SYMBOL-NUM, [TYPE])
|
||||
# -------------------------------------------------
|
||||
# Same as b4_symbol_value, but used in a template method.
|
||||
m4_define([b4_symbol_value_template],
|
||||
[m4_ifval([$3],
|
||||
[$1.template as< $3 > ()],
|
||||
[m4_ifval([$2],
|
||||
[b4_symbol_if([$2], [has_type],
|
||||
[$1.template as < b4_symbol([$2], [type]) > ()],
|
||||
[$1])],
|
||||
[$1])])])
|
||||
|
||||
|
||||
|
||||
## ------------- ##
|
||||
## make_SYMBOL. ##
|
||||
## ------------- ##
|
||||
|
||||
|
||||
# _b4_includes_tokens(SYMBOL-NUM...)
|
||||
# ----------------------------------
|
||||
# Expands to non-empty iff one of the SYMBOL-NUM denotes
|
||||
# a token.
|
||||
m4_define([_b4_is_token],
|
||||
[b4_symbol_if([$1], [is_token], [1])])
|
||||
m4_define([_b4_includes_tokens],
|
||||
[m4_map([_b4_is_token], [$@])])
|
||||
|
||||
|
||||
# _b4_token_maker_define(SYMBOL-NUM)
|
||||
# ----------------------------------
|
||||
# Declare make_SYMBOL for SYMBOL-NUM. Use at class-level.
|
||||
m4_define([_b4_token_maker_define],
|
||||
[b4_token_visible_if([$1],
|
||||
[#if 201103L <= YY_CPLUSPLUS
|
||||
static
|
||||
symbol_type
|
||||
make_[]_b4_symbol([$1], [id]) (b4_join(
|
||||
b4_symbol_if([$1], [has_type],
|
||||
[b4_symbol([$1], [type]) v]),
|
||||
b4_locations_if([location_type l])))
|
||||
{
|
||||
return symbol_type (b4_join([token::b4_symbol([$1], [id])],
|
||||
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
||||
b4_locations_if([std::move (l)])));
|
||||
}
|
||||
#else
|
||||
static
|
||||
symbol_type
|
||||
make_[]_b4_symbol([$1], [id]) (b4_join(
|
||||
b4_symbol_if([$1], [has_type],
|
||||
[const b4_symbol([$1], [type])& v]),
|
||||
b4_locations_if([const location_type& l])))
|
||||
{
|
||||
return symbol_type (b4_join([token::b4_symbol([$1], [id])],
|
||||
b4_symbol_if([$1], [has_type], [v]),
|
||||
b4_locations_if([l])));
|
||||
}
|
||||
#endif
|
||||
])])
|
||||
|
||||
|
||||
# b4_token_kind(SYMBOL-NUM)
|
||||
# -------------------------
|
||||
# Some tokens don't have an ID.
|
||||
m4_define([b4_token_kind],
|
||||
[b4_symbol_if([$1], [has_id],
|
||||
[token::b4_symbol([$1], [id])],
|
||||
[b4_symbol([$1], [code])])])
|
||||
|
||||
|
||||
# _b4_tok_in(SYMBOL-NUM, ...)
|
||||
# ---------------------------
|
||||
# See b4_tok_in below. The SYMBOL-NUMs... are tokens only.
|
||||
#
|
||||
# We iterate over the tokens to group them by "range" of token numbers (not
|
||||
# symbols numbers!).
|
||||
#
|
||||
# b4_fst is the start of that range.
|
||||
# b4_prev is the previous value.
|
||||
# b4_val is the current value.
|
||||
# If b4_val is the successor of b4_prev in token numbers, update the latter,
|
||||
# otherwise emit the code for range b4_fst .. b4_prev.
|
||||
# $1 is also used as a terminator in the foreach, but it will not be printed.
|
||||
#
|
||||
m4_define([_b4_tok_in],
|
||||
[m4_pushdef([b4_prev], [$1])dnl
|
||||
m4_pushdef([b4_fst], [$1])dnl
|
||||
m4_pushdef([b4_sep], [])dnl
|
||||
m4_foreach([b4_val], m4_dquote(m4_shift($@, $1)),
|
||||
[m4_if(b4_symbol(b4_val, [code]), m4_eval(b4_symbol(b4_prev, [code]) + 1), [],
|
||||
[b4_sep[]m4_if(b4_fst, b4_prev,
|
||||
[tok == b4_token_kind(b4_fst)],
|
||||
[(b4_token_kind(b4_fst) <= tok && tok <= b4_token_kind(b4_prev))])[]dnl
|
||||
m4_define([b4_fst], b4_val)dnl
|
||||
m4_define([b4_sep], [
|
||||
|| ])])dnl
|
||||
m4_define([b4_prev], b4_val)])dnl
|
||||
m4_popdef([b4_sep])dnl
|
||||
m4_popdef([b4_fst])dnl
|
||||
m4_popdef([b4_prev])dnl
|
||||
])
|
||||
|
||||
|
||||
# _b4_filter_tokens(SYMBOL-NUM, ...)
|
||||
# ----------------------------------
|
||||
# Expand as the list of tokens amongst SYMBOL-NUM.
|
||||
m4_define([_b4_filter_tokens],
|
||||
[m4_pushdef([b4_sep])dnl
|
||||
m4_foreach([b4_val], [$@],
|
||||
[b4_symbol_if(b4_val, [is_token], [b4_sep[]b4_val[]m4_define([b4_sep], [,])])])dnl
|
||||
m4_popdef([b4_sep])dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_tok_in(SYMBOL-NUM, ...)
|
||||
# ---------------------------
|
||||
# A C++ conditional that checks that `tok` is a member of this list of symbol
|
||||
# numbers.
|
||||
m4_define([b4_tok_in],
|
||||
[_$0(_b4_filter_tokens($@))])
|
||||
|
||||
|
||||
|
||||
|
||||
# _b4_symbol_constructor_define(SYMBOL-NUM...)
|
||||
# --------------------------------------------
|
||||
# Define a symbol_type constructor common to all the SYMBOL-NUM (they
|
||||
# have the same type). Use at class-level.
|
||||
m4_define([_b4_symbol_constructor_define],
|
||||
[m4_ifval(_b4_includes_tokens($@),
|
||||
[[#if 201103L <= YY_CPLUSPLUS
|
||||
symbol_type (]b4_join(
|
||||
[int tok],
|
||||
b4_symbol_if([$1], [has_type],
|
||||
[b4_symbol([$1], [type]) v]),
|
||||
b4_locations_if([location_type l]))[)
|
||||
: super_type (]b4_join([token_kind_type (tok)],
|
||||
b4_symbol_if([$1], [has_type], [std::move (v)]),
|
||||
b4_locations_if([std::move (l)]))[)
|
||||
#else
|
||||
symbol_type (]b4_join(
|
||||
[int tok],
|
||||
b4_symbol_if([$1], [has_type],
|
||||
[const b4_symbol([$1], [type])& v]),
|
||||
b4_locations_if([const location_type& l]))[)
|
||||
: super_type (]b4_join([token_kind_type (tok)],
|
||||
b4_symbol_if([$1], [has_type], [v]),
|
||||
b4_locations_if([l]))[)
|
||||
#endif
|
||||
{]b4_parse_assert_if([[
|
||||
#if !defined _MSC_VER || defined __clang__
|
||||
]b4_assert[ (]b4_tok_in($@)[);
|
||||
#endif
|
||||
]])[}
|
||||
]])])
|
||||
|
||||
|
||||
# b4_basic_symbol_constructor_define(SYMBOL-NUM)
|
||||
# ----------------------------------------------
|
||||
# Generate a constructor for basic_symbol from given type.
|
||||
m4_define([b4_basic_symbol_constructor_define],
|
||||
[[#if 201103L <= YY_CPLUSPLUS
|
||||
basic_symbol (]b4_join(
|
||||
[typename Base::kind_type t],
|
||||
b4_symbol_if([$1], [has_type], [b4_symbol([$1], [type])&& v]),
|
||||
b4_locations_if([location_type&& l]))[)
|
||||
: Base (t)]b4_symbol_if([$1], [has_type], [
|
||||
, value (std::move (v))])[]b4_locations_if([
|
||||
, location (std::move (l))])[
|
||||
{}
|
||||
#else
|
||||
basic_symbol (]b4_join(
|
||||
[typename Base::kind_type t],
|
||||
b4_symbol_if([$1], [has_type], [const b4_symbol([$1], [type])& v]),
|
||||
b4_locations_if([const location_type& l]))[)
|
||||
: Base (t)]b4_symbol_if([$1], [has_type], [
|
||||
, value (v)])[]b4_locations_if([
|
||||
, location (l)])[
|
||||
{}
|
||||
#endif
|
||||
]])
|
||||
|
||||
|
||||
# b4_token_constructor_define
|
||||
# ---------------------------
|
||||
# Define the overloaded versions of make_FOO for all the token kinds.
|
||||
m4_define([b4_token_constructor_define],
|
||||
[ // Implementation of make_symbol for each token kind.
|
||||
b4_symbol_foreach([_b4_token_maker_define])])
|
||||
2209
Engine/bin/bison-flex/data/skeletons/yacc.c
Normal file
2209
Engine/bin/bison-flex/data/skeletons/yacc.c
Normal file
File diff suppressed because it is too large
Load diff
105
Engine/bin/bison-flex/data/xslt/bison.xsl
Normal file
105
Engine/bin/bison-flex/data/xslt/bison.xsl
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
bison.xsl - common templates for Bison XSLT.
|
||||
|
||||
Copyright (C) 2007-2015, 2018-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:bison="https://www.gnu.org/software/bison/">
|
||||
|
||||
<xsl:key
|
||||
name="bison:symbolByName"
|
||||
match="/bison-xml-report/grammar/nonterminals/nonterminal"
|
||||
use="@name"
|
||||
/>
|
||||
<xsl:key
|
||||
name="bison:symbolByName"
|
||||
match="/bison-xml-report/grammar/terminals/terminal"
|
||||
use="@name"
|
||||
/>
|
||||
<xsl:key
|
||||
name="bison:ruleByNumber"
|
||||
match="/bison-xml-report/grammar/rules/rule"
|
||||
use="@number"
|
||||
/>
|
||||
<xsl:key
|
||||
name="bison:ruleByLhs"
|
||||
match="/bison-xml-report/grammar/rules/rule[
|
||||
@usefulness != 'useless-in-grammar']"
|
||||
use="lhs"
|
||||
/>
|
||||
<xsl:key
|
||||
name="bison:ruleByRhs"
|
||||
match="/bison-xml-report/grammar/rules/rule[
|
||||
@usefulness != 'useless-in-grammar']"
|
||||
use="rhs/symbol"
|
||||
/>
|
||||
|
||||
<!-- For the specified state, output: #sr-conflicts,#rr-conflicts -->
|
||||
<xsl:template match="state" mode="bison:count-conflicts">
|
||||
<xsl:variable name="transitions" select="actions/transitions"/>
|
||||
<xsl:variable name="reductions" select="actions/reductions"/>
|
||||
<xsl:variable
|
||||
name="terminals"
|
||||
select="
|
||||
$transitions/transition[@type='shift']/@symbol
|
||||
| $reductions/reduction/@symbol
|
||||
"
|
||||
/>
|
||||
<xsl:variable name="conflict-data">
|
||||
<xsl:for-each select="$terminals">
|
||||
<xsl:variable name="name" select="."/>
|
||||
<xsl:if test="generate-id($terminals[. = $name][1]) = generate-id(.)">
|
||||
<xsl:variable
|
||||
name="shift-count"
|
||||
select="count($transitions/transition[@symbol=$name])"
|
||||
/>
|
||||
<xsl:variable
|
||||
name="reduce-count"
|
||||
select="count($reductions/reduction[@symbol=$name])"
|
||||
/>
|
||||
<xsl:if test="$shift-count > 0 and $reduce-count > 0">
|
||||
<xsl:text>s</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:if test="$reduce-count > 1">
|
||||
<xsl:text>r</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="string-length(translate($conflict-data, 'r', ''))"/>
|
||||
<xsl:text>,</xsl:text>
|
||||
<xsl:value-of select="string-length(translate($conflict-data, 's', ''))"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="space">
|
||||
<xsl:param name="repeat">0</xsl:param>
|
||||
<xsl:param name="fill" select="' '"/>
|
||||
<xsl:if test="number($repeat) >= 1">
|
||||
<xsl:call-template name="space">
|
||||
<xsl:with-param name="repeat" select="$repeat - 1"/>
|
||||
<xsl:with-param name="fill" select="$fill"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fill"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
401
Engine/bin/bison-flex/data/xslt/xml2dot.xsl
Normal file
401
Engine/bin/bison-flex/data/xslt/xml2dot.xsl
Normal file
|
|
@ -0,0 +1,401 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
xml2dot.xsl - transform Bison XML Report into DOT.
|
||||
|
||||
Copyright (C) 2007-2015, 2018-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Written by Wojciech Polak <polak@gnu.org>.
|
||||
-->
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:bison="https://www.gnu.org/software/bison/">
|
||||
|
||||
<xsl:import href="bison.xsl"/>
|
||||
<xsl:output method="text" encoding="UTF-8" indent="no"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:apply-templates select="bison-xml-report"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="bison-xml-report">
|
||||
<xsl:text>// Generated by GNU Bison </xsl:text>
|
||||
<xsl:value-of select="@version"/>
|
||||
<xsl:text>. </xsl:text>
|
||||
<xsl:text>// Report bugs to <</xsl:text>
|
||||
<xsl:value-of select="@bug-report"/>
|
||||
<xsl:text>>. </xsl:text>
|
||||
<xsl:text>// Home page: <</xsl:text>
|
||||
<xsl:value-of select="@url"/>
|
||||
<xsl:text>>. </xsl:text>
|
||||
<xsl:apply-templates select="automaton">
|
||||
<xsl:with-param name="filename" select="filename"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="automaton">
|
||||
<xsl:param name="filename"/>
|
||||
<xsl:text>digraph "</xsl:text>
|
||||
<xsl:call-template name="escape">
|
||||
<xsl:with-param name="subject" select="$filename"/>
|
||||
</xsl:call-template>
|
||||
<xsl:text>" {
|
||||
node [fontname = courier, shape = box, colorscheme = paired6]
|
||||
edge [fontname = courier]
|
||||
|
||||
</xsl:text>
|
||||
<xsl:apply-templates select="state"/>
|
||||
<xsl:text>} </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="automaton/state">
|
||||
<xsl:call-template name="output-node">
|
||||
<xsl:with-param name="number" select="@number"/>
|
||||
<xsl:with-param name="label">
|
||||
<xsl:apply-templates select="itemset/item"/>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<xsl:apply-templates select="actions/transitions"/>
|
||||
<xsl:apply-templates select="actions/reductions">
|
||||
<xsl:with-param name="staten">
|
||||
<xsl:value-of select="@number"/>
|
||||
</xsl:with-param>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="actions/reductions">
|
||||
<xsl:param name="staten"/>
|
||||
<xsl:for-each select='reduction'>
|
||||
<!-- These variables are needed because the current context can't be
|
||||
referred to directly in XPath expressions. -->
|
||||
<xsl:variable name="rul">
|
||||
<xsl:value-of select="@rule"/>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="ena">
|
||||
<xsl:value-of select="@enabled"/>
|
||||
</xsl:variable>
|
||||
<!-- The foreach's body is protected by this, so that we are actually
|
||||
going to iterate once per reduction rule, and not per lookahead. -->
|
||||
<xsl:if test='not(preceding-sibling::*[@rule=$rul and @enabled=$ena])'>
|
||||
<xsl:variable name="rule">
|
||||
<xsl:choose>
|
||||
<!-- The acceptation state is referred to as 'accept' in the XML, but
|
||||
just as '0' in the DOT. -->
|
||||
<xsl:when test="@rule='accept'">
|
||||
<xsl:text>0</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@rule"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<!-- The edge's beginning -->
|
||||
<xsl:call-template name="reduction-edge-start">
|
||||
<xsl:with-param name="state" select="$staten"/>
|
||||
<xsl:with-param name="rule" select="$rule"/>
|
||||
<xsl:with-param name="enabled" select="@enabled"/>
|
||||
</xsl:call-template>
|
||||
|
||||
<!-- The edge's tokens -->
|
||||
<!-- Don't show labels for the default action. In other cases, there will
|
||||
always be at least one token, so 'label="[]"' will not occur. -->
|
||||
<xsl:if test='$rule!=0 and not(../reduction[@enabled=$ena and @rule=$rule and @symbol="$default"])'>
|
||||
<xsl:text>label="[</xsl:text>
|
||||
<xsl:for-each select='../reduction[@enabled=$ena and @rule=$rule]'>
|
||||
<xsl:call-template name="escape">
|
||||
<xsl:with-param name="subject" select="@symbol"/>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="position() != last ()">
|
||||
<xsl:text>, </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
<xsl:text>]", </xsl:text>
|
||||
</xsl:if>
|
||||
|
||||
<!-- The edge's end -->
|
||||
<xsl:text>style=solid] </xsl:text>
|
||||
|
||||
<!-- The diamond representing the reduction -->
|
||||
<xsl:call-template name="reduction-node">
|
||||
<xsl:with-param name="state" select="$staten"/>
|
||||
<xsl:with-param name="rule" select="$rule"/>
|
||||
<xsl:with-param name="color">
|
||||
<xsl:choose>
|
||||
<xsl:when test='@enabled="true"'>
|
||||
<xsl:text>3</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>5</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="actions/transitions">
|
||||
<xsl:apply-templates select="transition"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="item">
|
||||
<xsl:param name="prev-rule-number"
|
||||
select="preceding-sibling::item[1]/@rule-number"/>
|
||||
<xsl:apply-templates select="key('bison:ruleByNumber', @rule-number)">
|
||||
<xsl:with-param name="dot" select="@dot"/>
|
||||
<xsl:with-param name="num" select="@rule-number"/>
|
||||
<xsl:with-param name="prev-lhs"
|
||||
select="key('bison:ruleByNumber', $prev-rule-number)/lhs[text()]"
|
||||
/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates select="lookaheads"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="rule">
|
||||
<xsl:param name="dot"/>
|
||||
<xsl:param name="num"/>
|
||||
<xsl:param name="prev-lhs"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$num < 10">
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="$num < 100">
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text></xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="$num"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$prev-lhs = lhs[text()]">
|
||||
<xsl:call-template name="lpad">
|
||||
<xsl:with-param name="str" select="'|'"/>
|
||||
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="lhs"/>
|
||||
<xsl:text>:</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="$dot = 0">
|
||||
<xsl:text> .</xsl:text>
|
||||
</xsl:if>
|
||||
|
||||
<!-- RHS -->
|
||||
<xsl:for-each select="rhs/symbol|rhs/empty">
|
||||
<xsl:apply-templates select="."/>
|
||||
<xsl:if test="$dot = position()">
|
||||
<xsl:text> .</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="symbol">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="empty">
|
||||
<xsl:text> %empty</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="lookaheads">
|
||||
<xsl:text> [</xsl:text>
|
||||
<xsl:apply-templates select="symbol"/>
|
||||
<xsl:text>]</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="lookaheads/symbol">
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:if test="position() != last()">
|
||||
<xsl:text>, </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="reduction-edge-start">
|
||||
<xsl:param name="state"/>
|
||||
<xsl:param name="rule"/>
|
||||
<xsl:param name="enabled"/>
|
||||
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="$state"/>
|
||||
<xsl:text> -> "</xsl:text>
|
||||
<xsl:value-of select="$state"/>
|
||||
<xsl:text>R</xsl:text>
|
||||
<xsl:value-of select="$rule"/>
|
||||
<xsl:if test='$enabled = "false"'>
|
||||
<xsl:text>d</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text>" [</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="reduction-node">
|
||||
<xsl:param name="state"/>
|
||||
<xsl:param name="rule"/>
|
||||
<xsl:param name="color"/>
|
||||
|
||||
<xsl:text> "</xsl:text>
|
||||
<xsl:value-of select="$state"/>
|
||||
<xsl:text>R</xsl:text>
|
||||
<xsl:value-of select="$rule"/>
|
||||
<xsl:if test="$color = 5">
|
||||
<xsl:text>d</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text>" [label="</xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$rule = 0">
|
||||
<xsl:text>Acc", fillcolor=1</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>R</xsl:text>
|
||||
<xsl:value-of select="$rule"/>
|
||||
<xsl:text>", fillcolor=</xsl:text>
|
||||
<xsl:value-of select="$color"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text>, shape=diamond, style=filled] </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="transition">
|
||||
<xsl:call-template name="output-edge">
|
||||
<xsl:with-param name="src" select="../../../@number"/>
|
||||
<xsl:with-param name="dst" select="@state"/>
|
||||
<xsl:with-param name="style">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@symbol = 'error'">
|
||||
<xsl:text>dotted</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type = 'shift'">
|
||||
<xsl:text>solid</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>dashed</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:with-param>
|
||||
<xsl:with-param name="label">
|
||||
<xsl:if test="not(@symbol = 'error')">
|
||||
<xsl:value-of select="@symbol"/>
|
||||
</xsl:if>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="output-node">
|
||||
<xsl:param name="number"/>
|
||||
<xsl:param name="label"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="$number"/>
|
||||
<xsl:text> [label="</xsl:text>
|
||||
<xsl:text>State </xsl:text>
|
||||
<xsl:value-of select="$number"/>
|
||||
<xsl:text>\n</xsl:text>
|
||||
<xsl:call-template name="escape">
|
||||
<xsl:with-param name="subject" select="$label"/>
|
||||
</xsl:call-template>
|
||||
<xsl:text>\l"] </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="output-edge">
|
||||
<xsl:param name="src"/>
|
||||
<xsl:param name="dst"/>
|
||||
<xsl:param name="style"/>
|
||||
<xsl:param name="label"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="$src"/>
|
||||
<xsl:text> -> </xsl:text>
|
||||
<xsl:value-of select="$dst"/>
|
||||
<xsl:text> [style=</xsl:text>
|
||||
<xsl:value-of select="$style"/>
|
||||
<xsl:if test="$label and $label != ''">
|
||||
<xsl:text> label="</xsl:text>
|
||||
<xsl:call-template name="escape">
|
||||
<xsl:with-param name="subject" select="$label"/>
|
||||
</xsl:call-template>
|
||||
<xsl:text>"</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text>] </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="escape">
|
||||
<xsl:param name="subject"/> <!-- required -->
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:with-param name="subject">
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:with-param name="subject">
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:with-param name="subject" select="$subject"/>
|
||||
<xsl:with-param name="search" select="'\'"/>
|
||||
<xsl:with-param name="replace" select="'\\'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
<xsl:with-param name="search" select="'"'"/>
|
||||
<xsl:with-param name="replace" select="'\"'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
<xsl:with-param name="search" select="' '"/>
|
||||
<xsl:with-param name="replace" select="'\l'"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="string-replace">
|
||||
<xsl:param name="subject"/>
|
||||
<xsl:param name="search"/>
|
||||
<xsl:param name="replace"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($subject, $search)">
|
||||
<xsl:variable name="before" select="substring-before($subject, $search)"/>
|
||||
<xsl:variable name="after" select="substring-after($subject, $search)"/>
|
||||
<xsl:value-of select="$before"/>
|
||||
<xsl:value-of select="$replace"/>
|
||||
<xsl:call-template name="string-replace">
|
||||
<xsl:with-param name="subject" select="$after"/>
|
||||
<xsl:with-param name="search" select="$search"/>
|
||||
<xsl:with-param name="replace" select="$replace"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$subject"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="lpad">
|
||||
<xsl:param name="str" select="''"/>
|
||||
<xsl:param name="pad" select="0"/>
|
||||
<xsl:variable name="diff" select="$pad - string-length($str)" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="$diff < 0">
|
||||
<xsl:value-of select="$str"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="space">
|
||||
<xsl:with-param name="repeat" select="$diff"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$str"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
572
Engine/bin/bison-flex/data/xslt/xml2text.xsl
Normal file
572
Engine/bin/bison-flex/data/xslt/xml2text.xsl
Normal file
|
|
@ -0,0 +1,572 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
xml2text.xsl - transform Bison XML Report into plain text.
|
||||
|
||||
Copyright (C) 2007-2015, 2018-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Written by Wojciech Polak <polak@gnu.org>.
|
||||
-->
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:bison="https://www.gnu.org/software/bison/">
|
||||
|
||||
<xsl:import href="bison.xsl"/>
|
||||
<xsl:output method="text" encoding="UTF-8" indent="no"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:apply-templates select="bison-xml-report"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="bison-xml-report">
|
||||
<xsl:apply-templates select="grammar" mode="reductions"/>
|
||||
<xsl:apply-templates select="grammar" mode="useless-in-parser"/>
|
||||
<xsl:apply-templates select="automaton" mode="conflicts"/>
|
||||
<xsl:apply-templates select="grammar"/>
|
||||
<xsl:apply-templates select="automaton"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="grammar" mode="reductions">
|
||||
<xsl:apply-templates select="nonterminals" mode="useless-in-grammar"/>
|
||||
<xsl:apply-templates select="terminals" mode="unused-in-grammar"/>
|
||||
<xsl:apply-templates select="rules" mode="useless-in-grammar"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="nonterminals" mode="useless-in-grammar">
|
||||
<xsl:if test="nonterminal[@usefulness='useless-in-grammar']">
|
||||
<xsl:text>Nonterminals useless in grammar </xsl:text>
|
||||
<xsl:for-each select="nonterminal[@usefulness='useless-in-grammar']">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="@name"/>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:for-each>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="terminals" mode="unused-in-grammar">
|
||||
<xsl:if test="terminal[@usefulness='unused-in-grammar']">
|
||||
<xsl:text>Terminals unused in grammar </xsl:text>
|
||||
<xsl:for-each select="terminal[@usefulness='unused-in-grammar']">
|
||||
<xsl:sort select="@symbol-number" data-type="number"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="@name"/>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:for-each>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="rules" mode="useless-in-grammar">
|
||||
<xsl:variable name="set" select="rule[@usefulness='useless-in-grammar']"/>
|
||||
<xsl:if test="$set">
|
||||
<xsl:text>Rules useless in grammar </xsl:text>
|
||||
<xsl:call-template name="style-rule-set">
|
||||
<xsl:with-param name="rule-set" select="$set"/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="grammar" mode="useless-in-parser">
|
||||
<xsl:variable
|
||||
name="set" select="rules/rule[@usefulness='useless-in-parser']"
|
||||
/>
|
||||
<xsl:if test="$set">
|
||||
<xsl:text>Rules useless in parser due to conflicts </xsl:text>
|
||||
<xsl:call-template name="style-rule-set">
|
||||
<xsl:with-param name="rule-set" select="$set"/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="grammar">
|
||||
<xsl:text>Grammar </xsl:text>
|
||||
<xsl:call-template name="style-rule-set">
|
||||
<xsl:with-param
|
||||
name="rule-set" select="rules/rule[@usefulness!='useless-in-grammar']"
|
||||
/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:apply-templates select="terminals"/>
|
||||
<xsl:apply-templates select="nonterminals"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="style-rule-set">
|
||||
<xsl:param name="rule-set"/>
|
||||
<xsl:for-each select="$rule-set">
|
||||
<xsl:apply-templates select=".">
|
||||
<xsl:with-param name="pad" select="'3'"/>
|
||||
<xsl:with-param name="prev-lhs">
|
||||
<xsl:if test="position()>1">
|
||||
<xsl:variable name="position" select="position()"/>
|
||||
<xsl:value-of select="$rule-set[$position - 1]/lhs"/>
|
||||
</xsl:if>
|
||||
</xsl:with-param>
|
||||
</xsl:apply-templates>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="grammar/terminals">
|
||||
<xsl:text>Terminals, with rules where they appear </xsl:text>
|
||||
<xsl:apply-templates select="terminal"/>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="grammar/nonterminals">
|
||||
<xsl:text>Nonterminals, with rules where they appear </xsl:text>
|
||||
<xsl:apply-templates select="nonterminal[@usefulness!='useless-in-grammar']"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="terminal">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="@name"/>
|
||||
<xsl:call-template name="line-wrap">
|
||||
<xsl:with-param name="first-line-length">
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length(@name) > 66">0</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="66 - string-length(@name)" />
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:with-param>
|
||||
<xsl:with-param name="line-length" select="66" />
|
||||
<xsl:with-param name="text">
|
||||
<xsl:if test="string-length(@type) != 0">
|
||||
<xsl:value-of select="concat(' <', @type, '>')"/>
|
||||
</xsl:if>
|
||||
<xsl:value-of select="concat(' (', @token-number, ')')"/>
|
||||
<xsl:for-each select="key('bison:ruleByRhs', @name)">
|
||||
<xsl:value-of select="concat(' ', @number)"/>
|
||||
</xsl:for-each>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="nonterminal">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="@name"/>
|
||||
<xsl:if test="string-length(@type) != 0">
|
||||
<xsl:value-of select="concat(' <', @type, '>')"/>
|
||||
</xsl:if>
|
||||
<xsl:value-of select="concat(' (', @symbol-number, ')')"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:variable name="output">
|
||||
<xsl:call-template name="line-wrap">
|
||||
<xsl:with-param name="line-length" select="66" />
|
||||
<xsl:with-param name="text">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test="key('bison:ruleByLhs', @name)">
|
||||
<xsl:text>on@left:</xsl:text>
|
||||
<xsl:for-each select="key('bison:ruleByLhs', @name)">
|
||||
<xsl:value-of select="concat(' ', @number)"/>
|
||||
</xsl:for-each>
|
||||
</xsl:if>
|
||||
<xsl:if test="key('bison:ruleByRhs', @name)">
|
||||
<xsl:if test="key('bison:ruleByLhs', @name)">
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text>on@right:</xsl:text>
|
||||
<xsl:for-each select="key('bison:ruleByRhs', @name)">
|
||||
<xsl:value-of select="concat(' ', @number)"/>
|
||||
</xsl:for-each>
|
||||
</xsl:if>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="translate($output, '@', ' ')" />
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="automaton" mode="conflicts">
|
||||
<xsl:variable name="conflict-report">
|
||||
<xsl:apply-templates select="state" mode="conflicts"/>
|
||||
</xsl:variable>
|
||||
<xsl:if test="string-length($conflict-report) != 0">
|
||||
<xsl:value-of select="$conflict-report"/>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="state" mode="conflicts">
|
||||
<xsl:variable name="conflict-counts">
|
||||
<xsl:apply-templates select="." mode="bison:count-conflicts" />
|
||||
</xsl:variable>
|
||||
<xsl:variable
|
||||
name="sr-count" select="substring-before($conflict-counts, ',')"
|
||||
/>
|
||||
<xsl:variable
|
||||
name="rr-count" select="substring-after($conflict-counts, ',')"
|
||||
/>
|
||||
<xsl:if test="$sr-count > 0 or $rr-count > 0">
|
||||
<xsl:value-of select="concat('State ', @number, ' conflicts:')"/>
|
||||
<xsl:if test="$sr-count > 0">
|
||||
<xsl:value-of select="concat(' ', $sr-count, ' shift/reduce')"/>
|
||||
<xsl:if test="$rr-count > 0">
|
||||
<xsl:value-of select="(',')"/>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:if test="$rr-count > 0">
|
||||
<xsl:value-of select="concat(' ', $rr-count, ' reduce/reduce')"/>
|
||||
</xsl:if>
|
||||
<xsl:value-of select="' '"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="automaton">
|
||||
<xsl:apply-templates select="state">
|
||||
<xsl:with-param name="pad" select="'3'"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="automaton/state">
|
||||
<xsl:param name="pad"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:text>State </xsl:text>
|
||||
<xsl:value-of select="@number"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:apply-templates select="itemset/item">
|
||||
<xsl:with-param name="pad" select="$pad"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates select="actions/transitions">
|
||||
<xsl:with-param name="type" select="'shift'"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates select="actions/errors"/>
|
||||
<xsl:apply-templates select="actions/reductions"/>
|
||||
<xsl:apply-templates select="actions/transitions">
|
||||
<xsl:with-param name="type" select="'goto'"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates select="solved-conflicts"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="actions/transitions">
|
||||
<xsl:param name="type"/>
|
||||
<xsl:if test="transition[@type = $type]">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:apply-templates select="transition[@type = $type]">
|
||||
<xsl:with-param name="pad">
|
||||
<xsl:call-template name="max-width-symbol">
|
||||
<xsl:with-param name="node" select="transition[@type = $type]"/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
</xsl:apply-templates>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="actions/errors">
|
||||
<xsl:if test="error">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:apply-templates select="error">
|
||||
<xsl:with-param name="pad">
|
||||
<xsl:call-template name="max-width-symbol">
|
||||
<xsl:with-param name="node" select="error"/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
</xsl:apply-templates>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="actions/reductions">
|
||||
<xsl:if test="reduction">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:apply-templates select="reduction">
|
||||
<xsl:with-param name="pad">
|
||||
<xsl:call-template name="max-width-symbol">
|
||||
<xsl:with-param name="node" select="reduction"/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
</xsl:apply-templates>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="item">
|
||||
<xsl:param name="pad"/>
|
||||
<xsl:param name="prev-rule-number"
|
||||
select="preceding-sibling::item[1]/@rule-number"/>
|
||||
<xsl:apply-templates
|
||||
select="key('bison:ruleByNumber', current()/@rule-number)"
|
||||
>
|
||||
<xsl:with-param name="itemset" select="'true'"/>
|
||||
<xsl:with-param name="pad" select="$pad"/>
|
||||
<xsl:with-param
|
||||
name="prev-lhs"
|
||||
select="key('bison:ruleByNumber', $prev-rule-number)/lhs[text()]"
|
||||
/>
|
||||
<xsl:with-param name="dot" select="@dot"/>
|
||||
<xsl:with-param name="lookaheads">
|
||||
<xsl:apply-templates select="lookaheads"/>
|
||||
</xsl:with-param>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="rule">
|
||||
<xsl:param name="itemset"/>
|
||||
<xsl:param name="pad"/>
|
||||
<xsl:param name="prev-lhs"/>
|
||||
<xsl:param name="dot"/>
|
||||
<xsl:param name="lookaheads"/>
|
||||
|
||||
<xsl:if test="$itemset != 'true' and not($prev-lhs = lhs[text()])">
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:call-template name="lpad">
|
||||
<xsl:with-param name="str" select="string(@number)"/>
|
||||
<xsl:with-param name="pad" select="number($pad)"/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> </xsl:text>
|
||||
|
||||
<!-- LHS -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]">
|
||||
<xsl:call-template name="lpad">
|
||||
<xsl:with-param name="str" select="'|'"/>
|
||||
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]">
|
||||
<xsl:call-template name="lpad">
|
||||
<xsl:with-param name="str" select="'|'"/>
|
||||
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="lhs"/>
|
||||
<xsl:text>:</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<!-- RHS -->
|
||||
<xsl:for-each select="rhs/*">
|
||||
<xsl:if test="position() = $dot + 1">
|
||||
<xsl:text> •</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="."/>
|
||||
<xsl:if test="position() = last() and position() = $dot">
|
||||
<xsl:text> •</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
<xsl:if test="$lookaheads">
|
||||
<xsl:value-of select="$lookaheads"/>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="symbol">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="empty">
|
||||
<xsl:text> %empty</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="lookaheads">
|
||||
<xsl:text> [</xsl:text>
|
||||
<xsl:apply-templates select="symbol"/>
|
||||
<xsl:text>]</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="lookaheads/symbol">
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:if test="position() != last()">
|
||||
<xsl:text>, </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="transition">
|
||||
<xsl:param name="pad"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:call-template name="rpad">
|
||||
<xsl:with-param name="str" select="string(@symbol)"/>
|
||||
<xsl:with-param name="pad" select="number($pad) + 2"/>
|
||||
</xsl:call-template>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@type = 'shift'">
|
||||
<xsl:text>shift, and go to state </xsl:text>
|
||||
<xsl:value-of select="@state"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type = 'goto'">
|
||||
<xsl:text>go to state </xsl:text>
|
||||
<xsl:value-of select="@state"/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="error">
|
||||
<xsl:param name="pad"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:call-template name="rpad">
|
||||
<xsl:with-param name="str" select="string(@symbol)"/>
|
||||
<xsl:with-param name="pad" select="number($pad) + 2"/>
|
||||
</xsl:call-template>
|
||||
<xsl:text>error</xsl:text>
|
||||
<xsl:text> (</xsl:text>
|
||||
<xsl:value-of select="text()"/>
|
||||
<xsl:text>)</xsl:text>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="reduction">
|
||||
<xsl:param name="pad"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:call-template name="rpad">
|
||||
<xsl:with-param name="str" select="string(@symbol)"/>
|
||||
<xsl:with-param name="pad" select="number($pad) + 2"/>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="@enabled = 'false'">
|
||||
<xsl:text>[</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@rule = 'accept'">
|
||||
<xsl:text>accept</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text>reduce using rule </xsl:text>
|
||||
<xsl:value-of select="@rule"/>
|
||||
<xsl:text> (</xsl:text>
|
||||
<xsl:value-of
|
||||
select="key('bison:ruleByNumber', current()/@rule)/lhs[text()]"/>
|
||||
<xsl:text>)</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="@enabled = 'false'">
|
||||
<xsl:text>]</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="solved-conflicts">
|
||||
<xsl:if test="resolution">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:apply-templates select="resolution"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="resolution">
|
||||
<xsl:text> Conflict between rule </xsl:text>
|
||||
<xsl:value-of select="@rule"/>
|
||||
<xsl:text> and token </xsl:text>
|
||||
<xsl:value-of select="@symbol"/>
|
||||
<xsl:text> resolved as </xsl:text>
|
||||
<xsl:if test="@type = 'error'">
|
||||
<xsl:text>an </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:value-of select="@type"/>
|
||||
<xsl:text> (</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text>). </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="max-width-symbol">
|
||||
<xsl:param name="node"/>
|
||||
<xsl:variable name="longest">
|
||||
<xsl:for-each select="$node">
|
||||
<xsl:sort data-type="number" select="string-length(@symbol)"
|
||||
order="descending"/>
|
||||
<xsl:if test="position() = 1">
|
||||
<xsl:value-of select="string-length(@symbol)"/>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="$longest"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="lpad">
|
||||
<xsl:param name="str" select="''"/>
|
||||
<xsl:param name="pad" select="0"/>
|
||||
<xsl:variable name="diff" select="$pad - string-length($str)" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="$diff < 0">
|
||||
<xsl:value-of select="$str"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="space">
|
||||
<xsl:with-param name="repeat" select="$diff"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$str"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="rpad">
|
||||
<xsl:param name="str" select="''"/>
|
||||
<xsl:param name="pad" select="0"/>
|
||||
<xsl:variable name="diff" select="$pad - string-length($str)"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$diff < 0">
|
||||
<xsl:value-of select="$str"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$str"/>
|
||||
<xsl:call-template name="space">
|
||||
<xsl:with-param name="repeat" select="$diff"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="line-wrap">
|
||||
<xsl:param name="line-length"/> <!-- required -->
|
||||
<xsl:param name="first-line-length" select="$line-length"/>
|
||||
<xsl:param name="text"/> <!-- required -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="normalize-space($text) = ''" />
|
||||
<xsl:when test="string-length($text) <= $first-line-length">
|
||||
<xsl:value-of select="concat($text, ' ')" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:variable name="break-pos">
|
||||
<xsl:call-template name="ws-search">
|
||||
<xsl:with-param name="text" select="$text" />
|
||||
<xsl:with-param name="start" select="$first-line-length+1" />
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="substring($text, 1, $break-pos - 1)" />
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:call-template name="line-wrap">
|
||||
<xsl:with-param name="line-length" select="$line-length" />
|
||||
<xsl:with-param
|
||||
name="text" select="concat(' ', substring($text, $break-pos+1))"
|
||||
/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="ws-search">
|
||||
<xsl:param name="text"/> <!-- required -->
|
||||
<xsl:param name="start"/> <!-- required -->
|
||||
<xsl:variable name="search-text" select="substring($text, $start)" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="not(contains($search-text, ' '))">
|
||||
<xsl:value-of select="string-length($text)+1" />
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of
|
||||
select="$start + string-length(substring-before($search-text, ' '))"
|
||||
/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
765
Engine/bin/bison-flex/data/xslt/xml2xhtml.xsl
Normal file
765
Engine/bin/bison-flex/data/xslt/xml2xhtml.xsl
Normal file
|
|
@ -0,0 +1,765 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
xml2html.xsl - transform Bison XML Report into XHTML.
|
||||
|
||||
Copyright (C) 2007-2015, 2018-2021 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of Bison, the GNU Compiler Compiler.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Written by Wojciech Polak <polak@gnu.org>.
|
||||
-->
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:bison="https://www.gnu.org/software/bison/">
|
||||
|
||||
<xsl:import href="bison.xsl"/>
|
||||
|
||||
<xsl:output method="xml" encoding="UTF-8"
|
||||
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
|
||||
indent="yes"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
||||
<title>
|
||||
<xsl:value-of select="bison-xml-report/filename"/>
|
||||
<xsl:text> - GNU Bison XML Automaton Report</xsl:text>
|
||||
</title>
|
||||
<style type="text/css"><![CDATA[
|
||||
body {
|
||||
font-family: "Nimbus Sans L", Arial, sans-serif;
|
||||
font-size: 9pt;
|
||||
}
|
||||
a:link {
|
||||
color: #1f00ff;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:visited {
|
||||
color: #1f00ff;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
color: red;
|
||||
}
|
||||
#menu a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.i {
|
||||
font-style: italic;
|
||||
}
|
||||
.pre {
|
||||
font-family: monospace;
|
||||
white-space: pre;
|
||||
}
|
||||
ol.decimal {
|
||||
list-style-type: decimal;
|
||||
}
|
||||
ol.lower-alpha {
|
||||
list-style-type: lower-alpha;
|
||||
}
|
||||
.dot {
|
||||
color: #cc0000;
|
||||
}
|
||||
#footer {
|
||||
margin-top: 3.5em;
|
||||
font-size: 7pt;
|
||||
}
|
||||
]]></style>
|
||||
</head>
|
||||
<body>
|
||||
<xsl:apply-templates select="bison-xml-report"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<div id="footer"><hr />This document was generated using
|
||||
<a href="https://www.gnu.org/software/bison/" title="GNU Bison">
|
||||
GNU Bison <xsl:value-of select="/bison-xml-report/@version"/></a>
|
||||
XML Automaton Report.<br />
|
||||
<!-- default copying notice -->
|
||||
Verbatim copying and distribution of this entire page is
|
||||
permitted in any medium, provided this notice is preserved.</div>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="bison-xml-report">
|
||||
<h1>GNU Bison XML Automaton Report</h1>
|
||||
<p>
|
||||
input grammar: <span class="i"><xsl:value-of select="filename"/></span>
|
||||
</p>
|
||||
|
||||
<xsl:text> </xsl:text>
|
||||
<h3>Table of Contents</h3>
|
||||
<ul id="menu">
|
||||
<li>
|
||||
<a href="#reductions">Reductions</a>
|
||||
<ul class="lower-alpha">
|
||||
<li><a href="#nonterminals_useless_in_grammar">Nonterminals useless in grammar</a></li>
|
||||
<li><a href="#terminals_unused_in_grammar">Terminals unused in grammar</a></li>
|
||||
<li><a href="#rules_useless_in_grammar">Rules useless in grammar</a></li>
|
||||
<xsl:if test="grammar/rules/rule[@usefulness='useless-in-parser']">
|
||||
<li><a href="#rules_useless_in_parser">Rules useless in parser due to conflicts</a></li>
|
||||
</xsl:if>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#conflicts">Conflicts</a></li>
|
||||
<li>
|
||||
<a href="#grammar">Grammar</a>
|
||||
<ul class="lower-alpha">
|
||||
<li><a href="#grammar">Itemset</a></li>
|
||||
<li><a href="#terminals">Terminal symbols</a></li>
|
||||
<li><a href="#nonterminals">Nonterminal symbols</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#automaton">Automaton</a></li>
|
||||
</ul>
|
||||
<xsl:apply-templates select="grammar" mode="reductions"/>
|
||||
<xsl:apply-templates select="grammar" mode="useless-in-parser"/>
|
||||
<xsl:apply-templates select="automaton" mode="conflicts"/>
|
||||
<xsl:apply-templates select="grammar"/>
|
||||
<xsl:apply-templates select="automaton"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="grammar" mode="reductions">
|
||||
<h2>
|
||||
<a name="reductions"/>
|
||||
<xsl:text> Reductions</xsl:text>
|
||||
</h2>
|
||||
<xsl:apply-templates select="nonterminals" mode="useless-in-grammar"/>
|
||||
<xsl:apply-templates select="terminals" mode="unused-in-grammar"/>
|
||||
<xsl:apply-templates select="rules" mode="useless-in-grammar"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="nonterminals" mode="useless-in-grammar">
|
||||
<h3>
|
||||
<a name="nonterminals_useless_in_grammar"/>
|
||||
<xsl:text> Nonterminals useless in grammar</xsl:text>
|
||||
</h3>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test="nonterminal[@usefulness='useless-in-grammar']">
|
||||
<p class="pre">
|
||||
<xsl:for-each select="nonterminal[@usefulness='useless-in-grammar']">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="@name"/>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:for-each>
|
||||
<xsl:text> </xsl:text>
|
||||
</p>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="terminals" mode="unused-in-grammar">
|
||||
<h3>
|
||||
<a name="terminals_unused_in_grammar"/>
|
||||
<xsl:text> Terminals unused in grammar</xsl:text>
|
||||
</h3>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test="terminal[@usefulness='unused-in-grammar']">
|
||||
<p class="pre">
|
||||
<xsl:for-each select="terminal[@usefulness='unused-in-grammar']">
|
||||
<xsl:sort select="@symbol-number" data-type="number"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="@name"/>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:for-each>
|
||||
<xsl:text> </xsl:text>
|
||||
</p>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="rules" mode="useless-in-grammar">
|
||||
<h3>
|
||||
<a name="rules_useless_in_grammar"/>
|
||||
<xsl:text> Rules useless in grammar</xsl:text>
|
||||
</h3>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:variable name="set" select="rule[@usefulness='useless-in-grammar']"/>
|
||||
<xsl:if test="$set">
|
||||
<p class="pre">
|
||||
<xsl:call-template name="style-rule-set">
|
||||
<xsl:with-param name="rule-set" select="$set"/>
|
||||
</xsl:call-template>
|
||||
<xsl:text> </xsl:text>
|
||||
</p>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="grammar" mode="useless-in-parser">
|
||||
<xsl:variable
|
||||
name="set" select="rules/rule[@usefulness='useless-in-parser']"
|
||||
/>
|
||||
<xsl:if test="$set">
|
||||
<h2>
|
||||
<a name="rules_useless_in_parser"/>
|
||||
<xsl:text> Rules useless in parser due to conflicts</xsl:text>
|
||||
</h2>
|
||||
<xsl:text> </xsl:text>
|
||||
<p class="pre">
|
||||
<xsl:call-template name="style-rule-set">
|
||||
<xsl:with-param name="rule-set" select="$set"/>
|
||||
</xsl:call-template>
|
||||
</p>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="grammar">
|
||||
<h2>
|
||||
<a name="grammar"/>
|
||||
<xsl:text> Grammar</xsl:text>
|
||||
</h2>
|
||||
<xsl:text> </xsl:text>
|
||||
<p class="pre">
|
||||
<xsl:call-template name="style-rule-set">
|
||||
<xsl:with-param name="anchor" select="'true'" />
|
||||
<xsl:with-param
|
||||
name="rule-set" select="rules/rule[@usefulness!='useless-in-grammar']"
|
||||
/>
|
||||
</xsl:call-template>
|
||||
</p>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:apply-templates select="terminals"/>
|
||||
<xsl:apply-templates select="nonterminals"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="style-rule-set">
|
||||
<xsl:param name="anchor"/>
|
||||
<xsl:param name="rule-set"/>
|
||||
<xsl:for-each select="$rule-set">
|
||||
<xsl:apply-templates select=".">
|
||||
<xsl:with-param name="anchor" select="$anchor"/>
|
||||
<xsl:with-param name="pad" select="'3'"/>
|
||||
<xsl:with-param name="prev-lhs">
|
||||
<xsl:if test="position()>1">
|
||||
<xsl:variable name="position" select="position()"/>
|
||||
<xsl:value-of select="$rule-set[$position - 1]/lhs"/>
|
||||
</xsl:if>
|
||||
</xsl:with-param>
|
||||
</xsl:apply-templates>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="automaton" mode="conflicts">
|
||||
<h2>
|
||||
<a name="conflicts"/>
|
||||
<xsl:text> Conflicts</xsl:text>
|
||||
</h2>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:variable name="conflict-report">
|
||||
<xsl:apply-templates select="state" mode="conflicts"/>
|
||||
</xsl:variable>
|
||||
<xsl:if test="string-length($conflict-report) != 0">
|
||||
<p class="pre">
|
||||
<xsl:copy-of select="$conflict-report"/>
|
||||
<xsl:text> </xsl:text>
|
||||
</p>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="state" mode="conflicts">
|
||||
<xsl:variable name="conflict-counts">
|
||||
<xsl:apply-templates select="." mode="bison:count-conflicts" />
|
||||
</xsl:variable>
|
||||
<xsl:variable
|
||||
name="sr-count" select="substring-before($conflict-counts, ',')"
|
||||
/>
|
||||
<xsl:variable
|
||||
name="rr-count" select="substring-after($conflict-counts, ',')"
|
||||
/>
|
||||
<xsl:if test="$sr-count > 0 or $rr-count > 0">
|
||||
<a>
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="concat('#state_', @number)"/>
|
||||
</xsl:attribute>
|
||||
<xsl:value-of select="concat('State ', @number)"/>
|
||||
</a>
|
||||
<xsl:text> conflicts:</xsl:text>
|
||||
<xsl:if test="$sr-count > 0">
|
||||
<xsl:value-of select="concat(' ', $sr-count, ' shift/reduce')"/>
|
||||
<xsl:if test="$rr-count > 0">
|
||||
<xsl:value-of select="(',')"/>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
<xsl:if test="$rr-count > 0">
|
||||
<xsl:value-of select="concat(' ', $rr-count, ' reduce/reduce')"/>
|
||||
</xsl:if>
|
||||
<xsl:value-of select="' '"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="grammar/terminals">
|
||||
<h3>
|
||||
<a name="terminals"/>
|
||||
<xsl:text> Terminals, with rules where they appear</xsl:text>
|
||||
</h3>
|
||||
<xsl:text> </xsl:text>
|
||||
<ul>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:apply-templates select="terminal"/>
|
||||
</ul>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="grammar/nonterminals">
|
||||
<h3>
|
||||
<a name="nonterminals"/>
|
||||
<xsl:text> Nonterminals, with rules where they appear</xsl:text>
|
||||
</h3>
|
||||
<xsl:text> </xsl:text>
|
||||
<ul>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:apply-templates
|
||||
select="nonterminal[@usefulness!='useless-in-grammar']"
|
||||
/>
|
||||
</ul>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="terminal">
|
||||
<xsl:text> </xsl:text>
|
||||
<li>
|
||||
<b><xsl:value-of select="@name"/></b>
|
||||
<xsl:if test="string-length(@type) != 0">
|
||||
<xsl:value-of select="concat(' <', @type, '>')"/>
|
||||
</xsl:if>
|
||||
<xsl:value-of select="concat(' (', @token-number, ')')"/>
|
||||
<xsl:for-each select="key('bison:ruleByRhs', @name)">
|
||||
<xsl:apply-templates select="." mode="number-link"/>
|
||||
</xsl:for-each>
|
||||
</li>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="nonterminal">
|
||||
<xsl:text> </xsl:text>
|
||||
<li>
|
||||
<b><xsl:value-of select="@name"/></b>
|
||||
<xsl:if test="string-length(@type) != 0">
|
||||
<xsl:value-of select="concat(' <', @type, '>')"/>
|
||||
</xsl:if>
|
||||
<xsl:value-of select="concat(' (', @symbol-number, ')')"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<ul>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test="key('bison:ruleByLhs', @name)">
|
||||
<xsl:text> </xsl:text>
|
||||
<li>
|
||||
<xsl:text>on left:</xsl:text>
|
||||
<xsl:for-each select="key('bison:ruleByLhs', @name)">
|
||||
<xsl:apply-templates select="." mode="number-link"/>
|
||||
</xsl:for-each>
|
||||
</li>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:if test="key('bison:ruleByRhs', @name)">
|
||||
<xsl:text> </xsl:text>
|
||||
<li>
|
||||
<xsl:text>on right:</xsl:text>
|
||||
<xsl:for-each select="key('bison:ruleByRhs', @name)">
|
||||
<xsl:apply-templates select="." mode="number-link"/>
|
||||
</xsl:for-each>
|
||||
</li>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text> </xsl:text>
|
||||
</ul>
|
||||
<xsl:text> </xsl:text>
|
||||
</li>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="rule" mode="number-link">
|
||||
<xsl:text> </xsl:text>
|
||||
<a>
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="concat('#rule_', @number)"/>
|
||||
</xsl:attribute>
|
||||
<xsl:value-of select="@number"/>
|
||||
</a>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="automaton">
|
||||
<h2>
|
||||
<a name="automaton"/>
|
||||
<xsl:text> Automaton</xsl:text>
|
||||
</h2>
|
||||
<xsl:apply-templates select="state">
|
||||
<xsl:with-param name="pad" select="'3'"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="automaton/state">
|
||||
<xsl:param name="pad"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<h3>
|
||||
<a>
|
||||
<xsl:attribute name="name">
|
||||
<xsl:value-of select="concat('state_', @number)"/>
|
||||
</xsl:attribute>
|
||||
</a>
|
||||
<xsl:text>State </xsl:text>
|
||||
<xsl:value-of select="@number"/>
|
||||
</h3>
|
||||
<xsl:text> </xsl:text>
|
||||
<p class="pre">
|
||||
<xsl:apply-templates select="itemset/item">
|
||||
<xsl:with-param name="pad" select="$pad"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates select="actions/transitions">
|
||||
<xsl:with-param name="type" select="'shift'"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates select="actions/errors"/>
|
||||
<xsl:apply-templates select="actions/reductions"/>
|
||||
<xsl:apply-templates select="actions/transitions">
|
||||
<xsl:with-param name="type" select="'goto'"/>
|
||||
</xsl:apply-templates>
|
||||
<xsl:apply-templates select="solved-conflicts"/>
|
||||
</p>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="actions/transitions">
|
||||
<xsl:param name="type"/>
|
||||
<xsl:if test="transition[@type = $type]">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:apply-templates select="transition[@type = $type]">
|
||||
<xsl:with-param name="pad">
|
||||
<xsl:call-template name="max-width-symbol">
|
||||
<xsl:with-param name="node" select="transition[@type = $type]"/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
</xsl:apply-templates>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="actions/errors">
|
||||
<xsl:if test="error">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:apply-templates select="error">
|
||||
<xsl:with-param name="pad">
|
||||
<xsl:call-template name="max-width-symbol">
|
||||
<xsl:with-param name="node" select="error"/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
</xsl:apply-templates>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="actions/reductions">
|
||||
<xsl:if test="reduction">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:apply-templates select="reduction">
|
||||
<xsl:with-param name="pad">
|
||||
<xsl:call-template name="max-width-symbol">
|
||||
<xsl:with-param name="node" select="reduction"/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
</xsl:apply-templates>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="item">
|
||||
<xsl:param name="pad"/>
|
||||
<xsl:param name="prev-rule-number"
|
||||
select="preceding-sibling::item[1]/@rule-number"/>
|
||||
<xsl:apply-templates
|
||||
select="key('bison:ruleByNumber', current()/@rule-number)"
|
||||
>
|
||||
<xsl:with-param name="itemset" select="'true'"/>
|
||||
<xsl:with-param name="pad" select="$pad"/>
|
||||
<xsl:with-param name="prev-lhs"
|
||||
select="key('bison:ruleByNumber', $prev-rule-number)/lhs[text()]"
|
||||
/>
|
||||
<xsl:with-param name="dot" select="@dot"/>
|
||||
<xsl:with-param name="lookaheads">
|
||||
<xsl:apply-templates select="lookaheads"/>
|
||||
</xsl:with-param>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<!--
|
||||
anchor = 'true': define as an <a> anchor.
|
||||
itemset = 'true': show the items.
|
||||
-->
|
||||
<xsl:template match="rule">
|
||||
<xsl:param name="anchor"/>
|
||||
<xsl:param name="itemset"/>
|
||||
<xsl:param name="pad"/>
|
||||
<xsl:param name="prev-lhs"/>
|
||||
<xsl:param name="dot"/>
|
||||
<xsl:param name="lookaheads"/>
|
||||
|
||||
<xsl:if test="$itemset != 'true' and not($prev-lhs = lhs[text()])">
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text> </xsl:text>
|
||||
|
||||
<xsl:choose>
|
||||
<xsl:when test="$anchor = 'true'">
|
||||
<a>
|
||||
<xsl:attribute name="name">
|
||||
<xsl:value-of select="concat('rule_', @number)"/>
|
||||
</xsl:attribute>
|
||||
<xsl:call-template name="lpad">
|
||||
<xsl:with-param name="str" select="string(@number)"/>
|
||||
<xsl:with-param name="pad" select="number($pad)"/>
|
||||
</xsl:call-template>
|
||||
</a>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<a>
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="concat('#rule_', @number)"/>
|
||||
</xsl:attribute>
|
||||
<xsl:call-template name="lpad">
|
||||
<xsl:with-param name="str" select="string(@number)"/>
|
||||
<xsl:with-param name="pad" select="number($pad)"/>
|
||||
</xsl:call-template>
|
||||
</a>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text> </xsl:text>
|
||||
|
||||
<!-- LHS -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="$prev-lhs = lhs[text()]">
|
||||
<xsl:call-template name="lpad">
|
||||
<xsl:with-param name="str" select="'|'"/>
|
||||
<xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 2"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<span class="i">
|
||||
<xsl:value-of select="lhs"/>
|
||||
</span>
|
||||
<xsl:text> →</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
<!-- RHS -->
|
||||
<xsl:for-each select="rhs/*">
|
||||
<xsl:if test="position() = $dot + 1">
|
||||
<xsl:text> </xsl:text>
|
||||
<span class="dot">•</span>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="."/>
|
||||
<xsl:if test="position() = last() and position() = $dot">
|
||||
<xsl:text> </xsl:text>
|
||||
<span class="dot">•</span>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
<xsl:if test="$lookaheads">
|
||||
<xsl:value-of select="$lookaheads"/>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="symbol">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="name(key('bison:symbolByName', .)) = 'nonterminal'">
|
||||
<span class="i"><xsl:value-of select="."/></span>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<b><xsl:value-of select="."/></b>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="empty">
|
||||
<xsl:text> %empty</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="lookaheads">
|
||||
<xsl:text> [</xsl:text>
|
||||
<xsl:apply-templates select="symbol"/>
|
||||
<xsl:text>]</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="lookaheads/symbol">
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:if test="position() != last()">
|
||||
<xsl:text>, </xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="transition">
|
||||
<xsl:param name="pad"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:call-template name="rpad">
|
||||
<xsl:with-param name="str" select="string(@symbol)"/>
|
||||
<xsl:with-param name="pad" select="number($pad) + 2"/>
|
||||
</xsl:call-template>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@type = 'shift'">
|
||||
<a>
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="concat('#state_', @state)"/>
|
||||
</xsl:attribute>
|
||||
<xsl:value-of select="concat('shift, and go to state ', @state)"/>
|
||||
</a>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type = 'goto'">
|
||||
<a>
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="concat('#state_', @state)"/>
|
||||
</xsl:attribute>
|
||||
<xsl:value-of select="concat('go to state ', @state)"/>
|
||||
</a>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="error">
|
||||
<xsl:param name="pad"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:call-template name="rpad">
|
||||
<xsl:with-param name="str" select="string(@symbol)"/>
|
||||
<xsl:with-param name="pad" select="number($pad) + 2"/>
|
||||
</xsl:call-template>
|
||||
<xsl:text>error</xsl:text>
|
||||
<xsl:text> (</xsl:text>
|
||||
<xsl:value-of select="text()"/>
|
||||
<xsl:text>)</xsl:text>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="reduction">
|
||||
<xsl:param name="pad"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:call-template name="rpad">
|
||||
<xsl:with-param name="str" select="string(@symbol)"/>
|
||||
<xsl:with-param name="pad" select="number($pad) + 2"/>
|
||||
</xsl:call-template>
|
||||
<xsl:if test="@enabled = 'false'">
|
||||
<xsl:text>[</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@rule = 'accept'">
|
||||
<xsl:text>accept</xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<a>
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="concat('#rule_', @rule)"/>
|
||||
</xsl:attribute>
|
||||
<xsl:value-of select="concat('reduce using rule ', @rule)"/>
|
||||
</a>
|
||||
<xsl:text> (</xsl:text>
|
||||
<xsl:value-of
|
||||
select="key('bison:ruleByNumber', current()/@rule)/lhs[text()]"
|
||||
/>
|
||||
<xsl:text>)</xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="@enabled = 'false'">
|
||||
<xsl:text>]</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="solved-conflicts">
|
||||
<xsl:if test="resolution">
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:apply-templates select="resolution"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="resolution">
|
||||
<xsl:text> Conflict between </xsl:text>
|
||||
<a>
|
||||
<xsl:attribute name="href">
|
||||
<xsl:value-of select="concat('#rule_', @rule)"/>
|
||||
</xsl:attribute>
|
||||
<xsl:value-of select="concat('rule ',@rule)"/>
|
||||
</a>
|
||||
<xsl:text> and token </xsl:text>
|
||||
<xsl:value-of select="@symbol"/>
|
||||
<xsl:text> resolved as </xsl:text>
|
||||
<xsl:if test="@type = 'error'">
|
||||
<xsl:text>an </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:value-of select="@type"/>
|
||||
<xsl:text> (</xsl:text>
|
||||
<xsl:value-of select="."/>
|
||||
<xsl:text>). </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="max-width-symbol">
|
||||
<xsl:param name="node"/>
|
||||
<xsl:variable name="longest">
|
||||
<xsl:for-each select="$node">
|
||||
<xsl:sort data-type="number" select="string-length(@symbol)"
|
||||
order="descending"/>
|
||||
<xsl:if test="position() = 1">
|
||||
<xsl:value-of select="string-length(@symbol)"/>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:variable>
|
||||
<xsl:value-of select="$longest"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="lpad">
|
||||
<xsl:param name="str" select="''"/>
|
||||
<xsl:param name="pad" select="0"/>
|
||||
<xsl:variable name="diff" select="$pad - string-length($str)" />
|
||||
<xsl:choose>
|
||||
<xsl:when test="$diff < 0">
|
||||
<xsl:value-of select="$str"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="space">
|
||||
<xsl:with-param name="repeat" select="$diff"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$str"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="rpad">
|
||||
<xsl:param name="str" select="''"/>
|
||||
<xsl:param name="pad" select="0"/>
|
||||
<xsl:variable name="diff" select="$pad - string-length($str)"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$diff < 0">
|
||||
<xsl:value-of select="$str"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$str"/>
|
||||
<xsl:call-template name="space">
|
||||
<xsl:with-param name="repeat" select="$diff"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="space">
|
||||
<xsl:param name="repeat">0</xsl:param>
|
||||
<xsl:param name="fill" select="' '"/>
|
||||
<xsl:if test="number($repeat) >= 1">
|
||||
<xsl:call-template name="space">
|
||||
<xsl:with-param name="repeat" select="$repeat - 1"/>
|
||||
<xsl:with-param name="fill" select="$fill"/>
|
||||
</xsl:call-template>
|
||||
<xsl:value-of select="$fill"/>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
Loading…
Add table
Add a link
Reference in a new issue