Compare commits

...

24 Commits

Author SHA1 Message Date
Anatol Belski
ad95ee0c7b Prepare 2.2.0beta3 2019-02-11 22:23:32 -08:00
Anatol Belski
55cdd86d3a Add missing bison files 2019-02-11 22:22:07 -08:00
Anatol Belski
1045633875 Back to dev 2019-02-11 22:10:05 -08:00
Anatol Belski
c6a2644a57 Prepare 2.2.0beta2 2019-02-11 22:09:08 -08:00
Anatol Belski
9ffa736cbc Update bison to 3.3.2 2019-02-11 21:59:18 -08:00
Anatol Belski
79fbcfee08 Upgrade bundled PHP to 7.3.2 2019-02-11 09:51:30 -08:00
Anatol Belski
f84b056d1c Make the major number optional and care about 8 2019-02-04 23:31:01 -08:00
Anatol Belski
0ab9b8ddc6 Add error check 2019-02-04 20:00:05 -08:00
Anatol Belski
794ef96470 Add 8.0 configs for PGO 2019-02-04 15:33:26 -08:00
Anatol Belski
cecf3df7f3 Back to dev 2019-01-12 22:05:55 +01:00
Anatol Belski
1e6ee7afaa Prepare 2.2.0beta1 2019-01-12 22:04:56 +01:00
Anatol Belski
05af1a3b06 Upgrade bundled PHP to 7.3.1 2019-01-12 18:41:21 +01:00
Anatol Belski
c748916f5c Back to dev
Also raise the version to 2.2.0 as some essential tool upgrades are to expect.
2019-01-12 16:17:01 +01:00
Anatol Belski
bebb84afd7 Prepare 2.1.10 2019-01-12 16:08:52 +01:00
Anatol Belski
841065efd4 One more version update 2019-01-08 17:57:31 +01:00
Anatol Belski
c726890170 Update versions in README 2019-01-08 17:55:26 +01:00
Anatol Belski
b2e52e36d8 Back to dev 2018-12-26 13:51:10 +01:00
Anatol Belski
b8713d8543 Prepare 2.1.10beta1 2018-12-26 13:49:56 +01:00
Anatol Belski
025290f6d3 Upgrade to re2c 1.1.1 2018-12-26 13:31:49 +01:00
Anatol Belski
1ed89bbba2 Upgrade to bison 3.2.4 2018-12-26 13:30:28 +01:00
Anatol Belski
1d4f4966af Convert eol 2018-09-29 21:01:31 +02:00
Anatol Belski
a5b1137938 Back to dev 2018-09-19 21:20:37 +02:00
Anatol Belski
908f5eeea7 Prepare 2.1.9 2018-09-19 21:19:41 +02:00
Anatol Belski
a7cc2823bf Back to dev 2018-09-12 12:04:30 +02:00
53 changed files with 11047 additions and 1583 deletions

View File

@@ -33,7 +33,7 @@ All the tools included are either scripts or 32-bit binaries. They are therefore
## Other tools
- `bison` 3.0.5, `re2c` 1.0.3, `lemon`
- `bison` 3.2.4, `re2c` 1.1.1, `lemon`
- `awk`, `gawk`, `sed`, `grep`
- `diff`, `diff3`, `patch`
- `md5sum`, `sha1sum`, `sha224sum`, `sha256sum`, `sha384sum`, `sha512sum`
@@ -62,7 +62,7 @@ It is not required to hold the source in the PHP SDK directory. It could be usef
- `git clone https://github.com/Microsoft/php-sdk-binary-tools.git c:\php-sdk`
- `cd c:\php-sdk`
- `git checkout php-sdk-2.0.12` or later
- `git checkout php-sdk-2.1.9` or later
- invoke `phpsdk-vc15-x64.bat`
- `phpsdk_buildtree phpmaster`
- `git clone https://github.com/php/php-src.git && cd php-src`, or fetch a zipball

View File

@@ -1 +1 @@
2.1.9beta1
2.2.0beta3

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/php/libcrypto-1_1.dll Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/php/libssl-1_1.dll Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,72 +1,72 @@
/**
* Run the passed command line hidden, suitable for a scheduled task.
* Author: Anatol Belski <ab@php.net>
* License: BSD 2-Clause
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#define CMD_PRE "cmd.exe /c "
#define CMD_PRE_LEN (sizeof(CMD_PRE)-1)
#ifdef DEBUG
int
main(int argc, char **argv)
#else
int
APIENTRY WinMain(HINSTANCE inst, HINSTANCE prev_inst, LPTSTR in_cmd, int show)
#endif
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
DWORD exit_code;
char *cmd = NULL;
size_t cmd_len = 0, arg_len = 0;
char *arg = strchr(GetCommandLine(), ' ');
if (!arg) {
return 3;
}
#ifdef DEBUG
printf("passed cmd: '%s'\n", arg);
#endif
arg_len = strlen(arg);
cmd_len = CMD_PRE_LEN + arg_len + 1;
cmd = malloc(cmd_len * sizeof(char));
memmove(cmd, CMD_PRE, CMD_PRE_LEN);
memmove(cmd + CMD_PRE_LEN, arg, arg_len);
cmd[cmd_len-1] = '\0';
#ifdef DEBUG
printf("constructed cmd: '%s'\n", cmd);
#endif
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
ZeroMemory( &pi, sizeof(pi) );
if (CreateProcess(NULL, cmd, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) {
CloseHandle( pi.hThread );
} else {
free(cmd);
printf( "Error: CreatePracess 0x%08lx \n", GetLastError() );
return 3;
}
WaitForSingleObject( pi.hProcess, INFINITE );
GetExitCodeProcess(pi.hProcess, &exit_code);
CloseHandle( pi.hProcess );
free(cmd);
return exit_code;
}
/**
* Run the passed command line hidden, suitable for a scheduled task.
* Author: Anatol Belski <ab@php.net>
* License: BSD 2-Clause
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#define CMD_PRE "cmd.exe /c "
#define CMD_PRE_LEN (sizeof(CMD_PRE)-1)
#ifdef DEBUG
int
main(int argc, char **argv)
#else
int
APIENTRY WinMain(HINSTANCE inst, HINSTANCE prev_inst, LPTSTR in_cmd, int show)
#endif
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
DWORD exit_code;
char *cmd = NULL;
size_t cmd_len = 0, arg_len = 0;
char *arg = strchr(GetCommandLine(), ' ');
if (!arg) {
return 3;
}
#ifdef DEBUG
printf("passed cmd: '%s'\n", arg);
#endif
arg_len = strlen(arg);
cmd_len = CMD_PRE_LEN + arg_len + 1;
cmd = malloc(cmd_len * sizeof(char));
memmove(cmd, CMD_PRE, CMD_PRE_LEN);
memmove(cmd + CMD_PRE_LEN, arg, arg_len);
cmd[cmd_len-1] = '\0';
#ifdef DEBUG
printf("constructed cmd: '%s'\n", cmd);
#endif
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
ZeroMemory( &pi, sizeof(pi) );
if (CreateProcess(NULL, cmd, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) {
CloseHandle( pi.hThread );
} else {
free(cmd);
printf( "Error: CreatePracess 0x%08lx \n", GetLastError() );
return 3;
}
WaitForSingleObject( pi.hProcess, INFINITE );
GetExitCodeProcess(pi.hProcess, &exit_code);
CloseHandle( pi.hProcess );
free(cmd);
return exit_code;
}

View File

@@ -41,7 +41,7 @@ class PGO
$dll = array_merge($dll, glob($this->php->getExtRootDir() . DIRECTORY_SEPARATOR . "php*.dll"));
/* find out next index */
$tpl = glob($this->php->getRootDir() . DIRECTORY_SEPARATOR . "php7{ts,}.dll", GLOB_BRACE)[0];
$tpl = glob($this->php->getRootDir() . DIRECTORY_SEPARATOR . "php{7,8,}{ts,}.dll", GLOB_BRACE)[0];
if (!$tpl) {
throw new Exception("Couldn't find php7[ts].dll in the PHP root dir.");
}

View File

@@ -66,6 +66,9 @@ class Lock
} else {
$this->fd = fopen($this->fn, "wb");
}
if (false === $this->fd) {
throw new Exception("Failed to open lock under '$this->fn'");
}
$this->locked = flock($this->fd, $flags, $this->wouldBlock);
return $this->locked;
}/*}}}*/

Binary file not shown.

Binary file not shown.

View File

@@ -1,7 +1,7 @@
# bison-i18n.m4 serial 2
dnl Copyright (C) 2005-2006, 2009-2015, 2018 Free Software Foundation,
dnl Inc.
dnl Copyright (C) 2005-2006, 2009-2015, 2018-2019 Free Software
dnl Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,

View File

@@ -1,10 +1,9 @@
-*- outline -*-
This directory contains data needed by Bison.
* Skeletons
Bison skeletons: the general shapes of the different parser kinds,
that are specialized for specific grammars by the bison program.
# 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:
@@ -24,19 +23,18 @@ Currently, the supported skeletons are:
- 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.
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.
## 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.
## 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.
@@ -50,9 +48,132 @@ into various formats.
- xml2xhtml.xsl
Conversion into XHTML.
# Implementation note 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.
## 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_symbols_definitions()` in `src/output.c`.
The macro `b4_symbol(NUM, FIELD)` gives access to the following FIELDS:
- `has_id`: 0 or 1.
Whether the symbol has an id.
- `id`: string
If has_id, the id (prefixed by api.token.prefix if defined), otherwise
defined as empty. Guaranteed to be usable as a C identifier.
- `tag`: string.
A representation of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
- `user_number`: integer
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.
- `number`: integer
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`
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).
- `has_printer`: 0, 1
- `printer`: string
- `printer_file`: string
- `printer_line`: integer
If the symbol has a printer, everything about it.
- `has_destructor`, `destructor`, `destructor_file`, `destructor_line`
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.
-----
Copyright (C) 2002, 2008-2015, 2018 Free Software Foundation, Inc.
Local Variables:
mode: markdown
fill-column: 76
ispell-dictionary: "american"
End:
Copyright (C) 2002, 2008-2015, 2018-2019 Free Software Foundation, Inc.
This file is part of GNU Bison.

View File

@@ -0,0 +1,60 @@
Some usage notes for the D Parser:
- it is a port of the Java parser, so interface is very similar.
- the lexer class needs to implement the interface 'Lexer' (similar to
java). It typically (depending on options) looks like this:
public interface Lexer
{
/**
* Method to retrieve the beginning position of the last scanned token.
* @return the position at which the last scanned token starts. */
@property YYPosition startPos ();
/**
* Method to retrieve the ending position of the last scanned token.
* @return the first position beyond the last scanned token. */
@property YYPosition endPos ();
/**
* Method to retrieve the semantic value of the last scanned token.
* @return the semantic value of the last scanned token. */
@property YYSemanticType semanticVal ();
/**
* Entry point for the scanner. Returns the token identifier corresponding
* to the next token and prepares to return the semantic value
* and beginning/ending positions of the token.
* @return the token identifier corresponding to the next token. */
YYTokenType yylex ();
/**
* Entry point for error reporting. Emits an error
* referring to the given location in a user-defined way.
*
* @param loc The location of the element to which the
* error message is related
* @param s The string for the error message. */
void yyerror (YYLocation loc, string s);
}
- semantic types are handled by D usions (same as for C/C++ parsers)
- the following (non-standard) %defines are supported:
%define package "<package_name>"
%define api.parser.class "my_class_name>"
%define position_type "my_position_type"
%define location_type "my_location_type"
- the following declarations basically work like in C/C++:
%locations
%error-verbose
%parse-param
%initial-action
%code
%union
- %destructor is not yet supported

View File

@@ -2,7 +2,8 @@
# Language-independent M4 Macros for Bison.
# Copyright (C) 2002, 2004-2015, 2018 Free Software Foundation, Inc.
# Copyright (C) 2002, 2004-2015, 2018-2019 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
@@ -22,12 +23,17 @@
## Identification. ##
## ---------------- ##
# b4_generated_by
# ---------------
m4_define([b4_generated_by],
[b4_comment([A Bison parser, made by GNU Bison b4_version.])
])
# b4_copyright(TITLE, [YEARS])
# ----------------------------
# If YEARS are not defined, use b4_copyright_years.
m4_define([b4_copyright],
[b4_comment([A Bison parser, made by GNU Bison b4_version.])
[b4_generated_by
b4_comment([$1
]m4_dquote(m4_text_wrap([Copyright (C)
@@ -58,26 +64,49 @@ Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison.])])
version 2.2 of Bison.])
])
# b4_disclaimer
# -------------
# Issue a warning about private implementation details.
m4_define([b4_disclaimer],
[b4_comment([Undocumented macros, especially those whose name start with YY_,
are private implementation details. Do not rely on them.])
])
# b4_required_version_if(VERSION, IF_NEWER, IF_OLDER)
# ---------------------------------------------------
# If the version %require'd by the user is VERSION (or newer) expand
# IF_NEWER, otherwise IF_OLDER. VERSION should be an integer, e.g.,
# 302 for 3.2.
m4_define([b4_required_version_if],
[m4_if(m4_eval($1 <= b4_required_version),
[1], [$2], [$3])])
## -------- ##
## Output. ##
## -------- ##
# b4_output_begin(FILE)
# ---------------------
# b4_output_begin(FILE1, FILE2)
# -----------------------------
# Enable output, i.e., send to diversion 0, expand after "#", and
# generate the tag to output into FILE. Must be followed by EOL.
# FILE is FILE1 concatenated to FILE2. FILE2 can be empty, or be
# absolute: do the right thing.
m4_define([b4_output_begin],
[m4_changecom()
m4_divert_push(0)dnl
@output(m4_unquote([$1])@)@dnl
@output(m4_unquote([$1])@,m4_unquote([$2])@)@dnl
])
# b4_output_end()
# ---------------
# b4_output_end
# -------------
# Output nothing, restore # as comment character (no expansions after #).
m4_define([b4_output_end],
[m4_divert_pop(0)
@@ -235,8 +264,8 @@ m4_define([b4_subtract],
# -------------------
# Join with comma, skipping empty arguments.
# b4_join calls itself recursively until it sees the first non-empty
# argument, then calls _b4_join which prepends each non-empty argument
# with a comma.
# argument, then calls _b4_join (i.e., `_$0`) which prepends each
# non-empty argument with a comma.
m4_define([b4_join],
[m4_if([$#$1],
[1], [],
@@ -346,66 +375,48 @@ b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
# b4_glr_cc_if([IF-TRUE], [IF-FALSE])
# -----------------------------------
m4_define([b4_glr_cc_if],
[m4_if(b4_skeleton, ["glr.cc"], $@)])
## --------- ##
## Symbols. ##
## --------- ##
# 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
# src/output.c:prepare_symbols_definitions().
# For a description of the Symbol handling, see README.
#
# The various FIELDS are:
#
# - has_id: 0 or 1.
# Whether the symbol has an id.
# - id: string
# If has_id, the id. Guaranteed to be usable as a C identifier.
# Prefixed by api.token.prefix if defined.
# - tag: string.
# A representat of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
# - user_number: integer
# The assigned (external) number as used by yylex.
# - is_token: 0 or 1
# Whether this is a terminal symbol.
# - number: integer
# The internalized number (used after yytranslate).
# - 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
# 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).
# - has_printer: 0, 1
# - printer: string
# - printer_file: string
# - printer_line: integer
# If the symbol has a printer, everything about it.
# - has_destructor, destructor, destructor_file, destructor_line
# Likewise.
#
# The following macros provide access to these values.
# The following macros provide access to symbol related values.
# b4_symbol_(NUM, FIELD)
# ----------------------
# __b4_symbol(NUM, FIELD)
# -----------------------
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
# undefined.
m4_define([b4_symbol_],
m4_define([__b4_symbol],
[m4_indir([b4_symbol($1, $2)])])
# _b4_symbol(NUM, FIELD)
# ----------------------
# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if
# undefined.
m4_define([_b4_symbol],
[m4_ifdef([b4_symbol($1, number)],
[__b4_symbol(m4_indir([b4_symbol($1, number)]), $2)],
[__b4_symbol([$1], [$2])])])
# b4_symbol(NUM, FIELD)
# ---------------------
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if
# undefined. If FIELD = id, prepend the token prefix.
m4_define([b4_symbol],
[m4_case([$2],
[id], [m4_do([b4_percent_define_get([api.token.prefix])],
[b4_symbol_([$1], [id])])],
[b4_symbol_($@)])])
[_b4_symbol([$1], [id])])],
[_b4_symbol($@)])])
# b4_symbol_if(NUM, FIELD, IF-TRUE, IF-FALSE)
@@ -440,11 +451,11 @@ m4_define([b4_symbol_action_location],
m4_define([b4_symbol_action],
[b4_symbol_if([$1], [has_$2],
[b4_dollar_pushdef([(*yyvaluep)],
b4_symbol_if([$1], [has_type],
[m4_dquote(b4_symbol([$1], [type]))]),
[$1],
[],
[(*yylocationp)])dnl
b4_symbol_case_([$1])[]dnl
b4_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"])
_b4_symbol_case([$1])[]dnl
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
b4_symbol([$1], [$2])
b4_syncline([@oline@], [@ofile@])
break;
@@ -469,7 +480,7 @@ m4_define([b4_symbol_actions],
m4_ifval(m4_defn([b4_actions_]),
[switch (m4_default([$2], [yytype]))
{
m4_defn([b4_actions_])
m4_defn([b4_actions_])[]dnl
default:
break;
}dnl
@@ -478,10 +489,12 @@ m4_ifval(m4_defn([b4_actions_]),
m4_popdef([b4_actions_])dnl
])
# b4_symbol_case_(SYMBOL-NUM)
# _b4_symbol_case(SYMBOL-NUM)
# ---------------------------
# Issue a "case NUM" for SYMBOL-NUM.
m4_define([b4_symbol_case_],
# Issue a "case NUM" for SYMBOL-NUM. Ends with its EOL to make it
# easier to use with m4_map, but then, use []dnl to suppress the last
# one.
m4_define([_b4_symbol_case],
[case b4_symbol([$1], [number]): b4_symbol_tag_comment([$1])])
])
@@ -536,16 +549,16 @@ m4_define([b4_token_format],
## Types. ##
## ------- ##
# b4_type_action_(NUMS)
# _b4_type_action(NUMS)
# ---------------------
# Run actions for the symbol NUMS that all have the same type-name.
# Skip NUMS that have no type-name.
#
# To specify the action to run, define b4_dollar_dollar(NUMBER,
# To specify the action to run, define b4_dollar_dollar(SYMBOL-NUM,
# TAG, TYPE).
m4_define([b4_type_action_],
m4_define([_b4_type_action],
[b4_symbol_if([$1], [has_type],
[m4_map([ b4_symbol_case_], [$@])[]dnl
[m4_map([ _b4_symbol_case], [$@])[]dnl
b4_dollar_dollar([b4_symbol([$1], [number])],
[b4_symbol([$1], [tag])],
[b4_symbol([$1], [type])]);
@@ -601,13 +614,15 @@ m4_define([b4_user_code],
b4_syncline([@oline@], [@ofile@])])
# b4_define_user_code(MACRO)
# --------------------------
# From b4_MACRO, build b4_user_MACRO that includes the synclines.
# b4_define_user_code(MACRO, COMMENT)
# -----------------------------------
# From b4_MACRO, if defined, build b4_user_MACRO that includes the synclines.
m4_define([b4_define_user_code],
[m4_define([b4_user_$1],
[b4_user_code([b4_$1])])])
[m4_ifdef([b4_$1],
[m4_ifval([$2],
[b4_comment([$2])
])b4_user_code([b4_$1])])])])
# b4_user_actions
# b4_user_initial_action
@@ -617,9 +632,9 @@ m4_define([b4_define_user_code],
# ----------------------
# Macros that issue user code, ending with synclines.
b4_define_user_code([actions])
b4_define_user_code([initial_action])
b4_define_user_code([post_prologue])
b4_define_user_code([pre_prologue])
b4_define_user_code([initial_action], [User initialization code.])
b4_define_user_code([post_prologue], [Second part of user prologue.])
b4_define_user_code([pre_prologue], [First part of user prologue.])
b4_define_user_code([union_members])
@@ -701,7 +716,7 @@ m4_define([b4_percent_define_use],
# b4_percent_define_get([[foo]])
m4_define([b4_percent_define_get],
[b4_percent_define_use([$1])dnl
b4_percent_define_ifdef_([$1],
_b4_percent_define_ifdef([$1],
[m4_indir([b4_percent_define(]$1[)])],
[$2])])
@@ -710,7 +725,7 @@ b4_percent_define_ifdef_([$1],
# Mimic muscle_percent_define_get_loc in ../src/muscle-tab.h exactly. That is,
# if the %define variable VARIABLE is undefined, complain fatally since that's
# a Bison or skeleton error. Otherwise, return its definition location in a
# form approriate for the first two arguments of b4_warn_at, b4_complain_at, or
# form appropriate for the first two arguments of b4_warn_at, b4_complain_at, or
# b4_fatal_at. Don't record this as a Bison usage of VARIABLE as there's no
# reason to suspect that the user-supplied value has yet influenced the output.
#
@@ -755,15 +770,15 @@ m4_define([b4_percent_define_get_syncline],
[m4_indir([b4_percent_define_syncline(]$1[)])],
[b4_fatal([[$0: undefined %%define variable '%s']], [$1])])])
# b4_percent_define_ifdef_(VARIABLE, IF-TRUE, [IF-FALSE])
# _b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE])
# ------------------------------------------------------
# If the %define variable VARIABLE is defined, expand IF-TRUE, else expand
# IF-FALSE. Don't record usage of VARIABLE.
#
# For example:
#
# b4_percent_define_ifdef_([[foo]], [[it's defined]], [[it's undefined]])
m4_define([b4_percent_define_ifdef_],
# _b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
m4_define([_b4_percent_define_ifdef],
[m4_ifdef([b4_percent_define(]$1[)],
[$2],
[$3])])
@@ -779,11 +794,44 @@ m4_define([b4_percent_define_ifdef_],
#
# b4_percent_define_ifdef([[foo]], [[it's defined]], [[it's undefined]])
m4_define([b4_percent_define_ifdef],
[b4_percent_define_ifdef_([$1],
[_b4_percent_define_ifdef([$1],
[b4_percent_define_use([$1])$2],
[$3])])
# b4_percent_define_check_file_complain(VARIABLE)
# -----------------------------------------------
# Warn about %define variable VARIABLE having an incorrect
# value.
m4_define([b4_percent_define_check_file_complain],
[b4_complain_at(b4_percent_define_get_loc([$1]),
[[%%define variable '%s' requires 'none' or '"..."' values]],
[$1])])
# b4_percent_define_check_file(MACRO, VARIABLE, DEFAULT)
# ------------------------------------------------------
# If the %define variable VARIABLE:
# - is undefined, then if DEFAULT is non-empty, define MACRO to DEFAULT
# - is a string, define MACRO to its value
# - is the keyword 'none', do nothing
# - otherwise, warn about the incorrect value.
m4_define([b4_percent_define_check_file],
[b4_percent_define_ifdef([$2],
[m4_case(b4_percent_define_get_kind([$2]),
[string],
[m4_define([$1], b4_percent_define_get([$2]))],
[keyword],
[m4_if(b4_percent_define_get([$2]), [none], [],
[b4_percent_define_check_file_complain([$2])])],
[b4_percent_define_check_file_complain([$2])])
],
[m4_ifval([$3],
[m4_define([$1], [$3])])])
])
## --------- ##
## Options. ##
## --------- ##
@@ -824,7 +872,7 @@ m4_define([b4_percent_define_flag_if],
#
# b4_percent_define_default([[foo]], [[default value]])
m4_define([b4_percent_define_default],
[b4_percent_define_ifdef_([$1], [],
[_b4_percent_define_ifdef([$1], [],
[m4_define([b4_percent_define(]$1[)], [$2])dnl
m4_define([b4_percent_define_kind(]$1[)],
[m4_default([$3], [keyword])])dnl
@@ -839,26 +887,26 @@ m4_define([b4_percent_define_default],
# Define b4_NAME_if that executes its $1 or $2 depending whether
# VARIABLE was %defined. The characters '.' and `-' in VARIABLE are mapped
# to '_'.
m4_define([b4_percent_define_if_define_],
m4_define([_b4_percent_define_if_define],
[m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]),
[b4_percent_define_flag_if(m4_default([$2], [$1]),
[$3], [$4])])])
m4_define([b4_percent_define_if_define],
[b4_percent_define_default([m4_default([$2], [$1])], [[false]])
b4_percent_define_if_define_([$1], [$2], $[1], $[2])])
_b4_percent_define_if_define([$1], [$2], $[1], $[2])])
# b4_percent_define_check_kind(VARIABLE, KIND, [DIAGNOSTIC = complain])
# ---------------------------------------------------------------------
m4_define([b4_percent_define_check_kind],
[b4_percent_define_ifdef_([$1],
[_b4_percent_define_ifdef([$1],
[m4_if(b4_percent_define_get_kind([$1]), [$2], [],
[b4_error([m4_default([$3], [complain])],
b4_percent_define_get_loc([$1]),
[m4_case([$2],
[code], [[%%define variable '%s' requires '{...}' values]],
[code], [[%%define variable '%s' requires '{...}' values]],
[keyword], [[%%define variable '%s' requires keyword values]],
[string], [[%%define variable '%s' requires '"..."' values]])],
[string], [[%%define variable '%s' requires '"..."' values]])],
[$1])])])dnl
])
@@ -884,7 +932,7 @@ m4_define([b4_percent_define_check_values],
[_b4_percent_define_check_values(b4_sublist)])])
m4_define([_b4_percent_define_check_values],
[b4_percent_define_ifdef_([$1],
[_b4_percent_define_ifdef([$1],
[b4_percent_define_check_kind(]$1[, [keyword], [deprecated])dnl
m4_pushdef([b4_good_value], [0])dnl
m4_if($#, 1, [],
@@ -946,7 +994,7 @@ m4_define([b4_percent_code_ifdef],
# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
# b4_token_ctor_if([IF-YYLEX-RETURNS-A-TOKEN], [IF-NOT])
# ----------------------------------------------
# ----------------------------------------------------------
b4_percent_define_if_define([token_ctor], [api.token.constructor])
b4_percent_define_if_define([locations]) # Whether locations are tracked.
b4_percent_define_if_define([parse.assert])
@@ -1011,8 +1059,6 @@ b4_check_user_names_wrap([[code]], [[qualifier]])
## ---------------- ##
# m4_define_default([b4_lex_param], []) dnl breaks other skeletons
m4_define_default([b4_pre_prologue], [])
m4_define_default([b4_post_prologue], [])
m4_define_default([b4_epilogue], [])
m4_define_default([b4_parse_param], [])

View File

@@ -2,8 +2,8 @@
# C++ skeleton dispatching for Bison.
# Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation,
# Inc.
# Copyright (C) 2006-2007, 2009-2015, 2018-2019 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
@@ -18,10 +18,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
b4_glr_if( [m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.cc]])])
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.cc]])])
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_pkgdatadir/[lalr1.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)

View File

@@ -2,7 +2,7 @@
# C++ skeleton for Bison
# Copyright (C) 2002-2018 Free Software Foundation, Inc.
# Copyright (C) 2002-2019 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
@@ -22,13 +22,22 @@ 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++])])
m4_include(b4_pkgdatadir/[c.m4])
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_comment([$1], [$2// ], [$2// ])])
# b4_inline(hh|cc)
# ----------------
@@ -40,18 +49,54 @@ m4_define([b4_inline],
]],
[m4_fatal([$0: invalid argument: $1])])])
## -------- ##
## Checks. ##
## -------- ##
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
b4_percent_define_check_kind([parser_class_name], [code], [deprecated])
# 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([[parser_class_name]], [[parser]])
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.
@@ -88,7 +133,7 @@ m4_if(m4_bregexp(b4_namespace_ref, [^[ ]*$]), [-1], [],
[[namespace reference is empty]])])
# Instead of assuming the C++ compiler will do it, Bison should reject any
# invalid b4_namepsace_ref that would be converted to a valid
# 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.
@@ -171,7 +216,18 @@ m4_define([b4_public_types_declare],
/// 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);]b4_locations_if([
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;])[
};
@@ -192,11 +248,18 @@ m4_define([b4_public_types_declare],
/// Internal symbol number for tokens (subsumed by symbol_number_type).
typedef ]b4_int_type_for([b4_translate])[ token_number_type;
]])
/// A complete symbol.
# 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 type
/// via type_get().
/// via type_get ().
///
/// Provide access to semantic value]b4_locations_if([ and location])[.
template <typename Base>
@@ -206,30 +269,57 @@ m4_define([b4_public_types_declare],
typedef Base super_type;
/// Default constructor.
basic_symbol ();
basic_symbol ()
: value ()]b4_locations_if([
, location ()])[
{}
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
basic_symbol (basic_symbol&& that);
#endif
/// Copy constructor.
basic_symbol (const basic_symbol& other);
]b4_variant_if([[
basic_symbol (const basic_symbol& that);]b4_variant_if([[
/// Constructor for valueless symbols, and symbols from each type.
]b4_type_foreach([b4_basic_symbol_constructor_declare])], [[
]b4_type_foreach([b4_basic_symbol_constructor_define])], [[
/// Constructor for valueless symbols.
basic_symbol (typename Base::kind_type t]b4_locations_if([,
const location_type& l])[);]])[
YY_MOVE_REF (location_type) l])[);
/// Constructor for symbols with semantic value.
basic_symbol (typename Base::kind_type t,
const semantic_type& v]b4_locations_if([,
const location_type& l])[);
YY_RVREF (semantic_type) v]b4_locations_if([,
YY_RVREF (location_type) l])[);
]])[
/// Destroy the symbol.
~basic_symbol ();
~basic_symbol ()
{
clear ();
}
/// Destroy contents, and record that is empty.
void clear ();
void clear ()
{]b4_variant_if([[
// User destructor.
symbol_number_type yytype = this->type_get ();
basic_symbol<Base>& yysym = *this;
(void) yysym;
switch (yytype)
{
]b4_symbol_foreach([b4_symbol_destructor])dnl
[ default:
break;
}
// Type destructor.
]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[
Base::clear ();
}
/// Whether empty.
bool empty () const;
bool empty () const YY_NOEXCEPT;
/// Destructive move, \a s is emptied into this.
void move (basic_symbol& s);
@@ -241,8 +331,10 @@ m4_define([b4_public_types_declare],
location_type location;])[
private:
#if YY_CPLUSPLUS < 201103L
/// Assignment operator.
basic_symbol& operator= (const basic_symbol& other);
basic_symbol& operator= (const basic_symbol& that);
#endif
};
/// Type access provider for token (enum) based symbols.
@@ -251,8 +343,13 @@ m4_define([b4_public_types_declare],
/// Default constructor.
by_type ();
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_type (by_type&& that);
#endif
/// Copy constructor.
by_type (const by_type& other);
by_type (const by_type& that);
/// The symbol type as needed by the constructor.
typedef token_type kind_type;
@@ -268,10 +365,10 @@ m4_define([b4_public_types_declare],
/// The (internal) type number (corresponding to \a type).
/// \a empty when empty.
symbol_number_type type_get () const;
symbol_number_type type_get () const YY_NOEXCEPT;
/// The token.
token_type token () const;
token_type token () const YY_NOEXCEPT;
/// The symbol type.
/// \a empty_symbol when empty.
@@ -280,140 +377,130 @@ m4_define([b4_public_types_declare],
};
/// "External" symbols: returned by the scanner.
typedef basic_symbol<by_type> symbol_type;
struct symbol_type : basic_symbol<by_type>
{]b4_variant_if([[
/// Superclass.
typedef basic_symbol<by_type> super_type;
]b4_symbol_constructor_declare])
/// Empty symbol.
symbol_type () {}
/// Constructor for valueless symbols, and symbols from each type.
]b4_type_foreach([_b4_token_constructor_define])dnl
])[};
]])
# b4_public_types_define(hh|cc)
# -----------------------------
# Provide the implementation needed by the public types.
m4_define([b4_public_types_define],
[ b4_inline([$1])b4_parser_class_name[::syntax_error::syntax_error (]b4_locations_if([const location_type& l, ])[const std::string& m)
: std::runtime_error (m)]b4_locations_if([
, location (l)])[
{}
// basic_symbol.
[[ // basic_symbol.
#if 201103L <= YY_CPLUSPLUS
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol ()
: value ()
{}
]b4_parser_class[::basic_symbol<Base>::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->type_get ()], [value], [move],
[std::move (that.value)])
])[}
#endif
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
: Base (other)
, value ()]b4_locations_if([
, location (other.location)])[
{
]b4_variant_if([b4_symbol_variant([other.type_get ()], [value], [copy],
[other.value])],
[value = other.value;])[
}
]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->type_get ()], [value], [copy],
[YY_MOVE (that.value)])
])[}
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
[typename Base::kind_type t],
[const semantic_type& v],
b4_locations_if([const location_type& l]))[)
: Base (t)
, value (]b4_variant_if([], [v])[)]b4_locations_if([
, location (l)])[
{]b4_variant_if([[
(void) v;
]b4_symbol_variant([this->type_get ()], [value], [copy], [v])])[}
]b4_variant_if([[
// Implementation of basic_symbol constructor for each type.
]b4_type_foreach([b4_basic_symbol_constructor_define])], [[
]b4_variant_if([], [[
/// Constructor for valueless symbols.
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join(
[typename Base::kind_type t],
b4_locations_if([const location_type& l]))[)
b4_locations_if([YY_MOVE_REF (location_type) l]))[)
: Base (t)
, value ()]b4_locations_if([
, location (l)])[
{}]])[
{}
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol ()
{
clear ();
}
template <typename Base>
void
]b4_parser_class_name[::basic_symbol<Base>::clear ()
]b4_parser_class[::basic_symbol<Base>::basic_symbol (]b4_join(
[typename Base::kind_type t],
[YY_RVREF (semantic_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([[
// User destructor.
symbol_number_type yytype = this->type_get ();
basic_symbol<Base>& yysym = *this;
(void) yysym;
switch (yytype)
{
]b4_symbol_foreach([b4_symbol_destructor])dnl
[ default:
break;
}
// Type destructor.
]b4_symbol_variant([[yytype]], [[value]], [[template destroy]])])[
Base::clear ();
}
(void) v;
]b4_symbol_variant([this->type_get ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
template <typename Base>
bool
]b4_parser_class_name[::basic_symbol<Base>::empty () const
]b4_parser_class[::basic_symbol<Base>::empty () const YY_NOEXCEPT
{
return Base::type_get () == empty_symbol;
}
template <typename Base>
void
]b4_parser_class_name[::basic_symbol<Base>::move (basic_symbol& s)
]b4_parser_class[::basic_symbol<Base>::move (basic_symbol& s)
{
super_type::move (s);
]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [move],
[s.value])],
[value = s.value;])[]b4_locations_if([
location = s.location;])[
[YY_MOVE (s.value)])],
[value = YY_MOVE (s.value);])[]b4_locations_if([
location = YY_MOVE (s.location);])[
}
// by_type.
]b4_inline([$1])b4_parser_class_name[::by_type::by_type ()
]b4_inline([$1])b4_parser_class[::by_type::by_type ()
: type (empty_symbol)
{}
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (const by_type& other)
: type (other.type)
#if 201103L <= YY_CPLUSPLUS
]b4_inline([$1])b4_parser_class[::by_type::by_type (by_type&& that)
: type (that.type)
{
that.clear ();
}
#endif
]b4_inline([$1])b4_parser_class[::by_type::by_type (const by_type& that)
: type (that.type)
{}
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (token_type t)
]b4_inline([$1])b4_parser_class[::by_type::by_type (token_type t)
: type (yytranslate_ (t))
{}
]b4_inline([$1])[void
]b4_parser_class_name[::by_type::clear ()
]b4_parser_class[::by_type::clear ()
{
type = empty_symbol;
}
]b4_inline([$1])[void
]b4_parser_class_name[::by_type::move (by_type& that)
]b4_parser_class[::by_type::move (by_type& that)
{
type = that.type;
that.clear ();
}
]b4_inline([$1])[int
]b4_parser_class_name[::by_type::type_get () const
]b4_parser_class[::by_type::type_get () const YY_NOEXCEPT
{
return type;
}
]b4_token_ctor_if([[
]b4_inline([$1])b4_parser_class_name[::token_type
]b4_parser_class_name[::by_type::token () const
]b4_inline([$1])b4_parser_class[::token_type
]b4_parser_class[::by_type::token () const YY_NOEXCEPT
{
// YYTOKNUM[NUM] -- (External) token number corresponding to the
// (internal) symbol number NUM (which must be that of a token). */
@@ -423,19 +510,17 @@ m4_define([b4_public_types_define],
{
]b4_toknum[
};
return static_cast<token_type> (yytoken_number_[type]);
return token_type (yytoken_number_[type]);
}
]])[]dnl
b4_symbol_constructor_define])
])
# b4_symbol_constructor_declare
# b4_symbol_constructor_define
# -----------------------------
# Declare/define symbol constructors for all the value types.
# b4_token_constructor_define
# ----------------------------
# Define symbol constructors for all the value types.
# Use at class-level. Redefined in variant.hh.
m4_define([b4_symbol_constructor_declare], [])
m4_define([b4_symbol_constructor_define], [])
m4_define([b4_token_constructor_define], [])
# b4_yytranslate_define(cc|hh)
@@ -443,16 +528,17 @@ m4_define([b4_symbol_constructor_define], [])
# Define yytranslate_. Sometimes used in the header file ($1=hh),
# sometimes in the cc file.
m4_define([b4_yytranslate_define],
[[ // Symbol number corresponding to token number t.
]b4_inline([$1])b4_parser_class_name[::token_number_type
]b4_parser_class_name[::yytranslate_ (]b4_token_ctor_if([token_type],
[ b4_inline([$1])b4_parser_class[::token_number_type
]b4_parser_class[::yytranslate_ (]b4_token_ctor_if([token_type],
[int])[ t)
{
// YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to
// TOKEN-NUM as returned by yylex.
static
const token_number_type
translate_table[] =
{
]b4_translate[
]b4_translate[
};
const unsigned user_token_number_max_ = ]b4_user_token_number_max[;
const token_number_type undef_token_ = ]b4_undef_token_number[;
@@ -469,15 +555,13 @@ m4_define([b4_yytranslate_define],
# b4_lhs_value([TYPE])
# --------------------
# Expansion of $<TYPE>$.
m4_define([b4_lhs_value],
[b4_symbol_value([yyval], [$1])])
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
# b4_rhs_value(RULE-LENGTH, POS, [TYPE])
# --------------------------------------
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS.
# FIXME: Dead code.
m4_define([b4_rhs_value],
[b4_symbol_value([yysemantic_stack_@{($1) - ($2)@}], [$3])])
@@ -489,9 +573,9 @@ m4_define([b4_lhs_location],
[(yyloc)])
# b4_rhs_location(RULE-LENGTH, NUM)
# b4_rhs_location(RULE-LENGTH, POS)
# ---------------------------------
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
# on RHS.
m4_define([b4_rhs_location],
[(yylocation_stack_@{($1) - ($2)@})])
@@ -564,7 +648,7 @@ m4_define([b4_yylloc_default_define],
{ \
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
} \
while (/*CONSTCOND*/ false)
while (false)
# endif
]])

View File

@@ -2,7 +2,7 @@
# Common code for C-like languages (C, C++, Java, etc.)
# Copyright (C) 2012-2015, 2018 Free Software Foundation, Inc.
# Copyright (C) 2012-2015, 2018-2019 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
@@ -17,14 +17,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# b4_comment_(TEXT, OPEN, CONTINUE, END)
# _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]).
#
# Prefix all the output lines with PREFIX.
m4_define([b4_comment_],
m4_define([_b4_comment],
[$2[]m4_bpatsubst(m4_expand([[$1]]), [
\(.\)], [
$3\1])$4])
@@ -34,30 +34,31 @@ $3\1])$4])
# --------------------------
# Put TEXT in comment. Prefix all the output lines with PREFIX.
m4_define([b4_comment],
[b4_comment_([$1], [$2/* ], [$2 ], [ */])])
[_b4_comment([$1], [$2/* ], [$2 ], [ */])])
# b4_dollar_dollar_(VALUE, FIELD, DEFAULT-FIELD)
# ----------------------------------------------
# _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)" is VALUE is a
# otherwise just VALUE. Be sure to pass "(VALUE)" if VALUE is a
# pointer.
m4_define([b4_dollar_dollar_],
m4_define([_b4_dollar_dollar],
[b4_symbol_value([$1],
m4_if([$2], [[]],
[[$3]], [[$2]]))])
[$2],
m4_if([$3], [[]],
[[$4]], [[$3]]))])
# b4_dollar_pushdef(VALUE-POINTER, DEFAULT-FIELD, LOCATION)
# b4_dollar_pushdef(VALUE-POINTER, SYMBOL-NUM, [TYPE_TAG], LOCATION)
# b4_dollar_popdef
# ---------------------------------------------------------
# Define b4_dollar_dollar for VALUE and DEFAULT-FIELD,
# ------------------------------------------------------------------
# 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], m4_dquote($][1), [$2])])dnl
m4_pushdef([b4_at_dollar], [$3])dnl
[_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

View File

@@ -2,8 +2,8 @@
# C skeleton dispatching for Bison.
# Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation,
# Inc.
# Copyright (C) 2006-2007, 2009-2015, 2018-2019 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
@@ -18,10 +18,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
b4_glr_if( [m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.c]])])
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.c]])])
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_pkgdatadir/[yacc.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)

View File

@@ -2,7 +2,8 @@
# C M4 Macros for Bison.
# Copyright (C) 2002, 2004-2015, 2018 Free Software Foundation, Inc.
# Copyright (C) 2002, 2004-2015, 2018-2019 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
@@ -17,7 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_include(b4_pkgdatadir/[c-like.m4])
m4_include(b4_skeletonsdir/[c-like.m4])
# b4_tocpp(STRING)
# ----------------
@@ -172,10 +173,10 @@ m4_define([b4_int_type],
[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char],
b4_ints_in($@, [-128], [127]), [1], [signed char],
b4_ints_in($@, [0], [65535]), [1], [unsigned short int],
b4_ints_in($@, [-32768], [32767]), [1], [short int],
b4_ints_in($@, [0], [65535]), [1], [unsigned short],
b4_ints_in($@, [-32768], [32767]), [1], [short],
m4_eval([0 <= $1]), [1], [unsigned int],
m4_eval([0 <= $1]), [1], [unsigned],
[int])])
@@ -204,11 +205,12 @@ m4_define([b4_table_value_equals],
## Compiler issues. ##
## ----------------- ##
# b4_attribute_define
# -------------------
# Provide portable compiler "attributes".
# b4_attribute_define([noreturn])
# -------------------------------
# Provide portable compiler "attributes". If "noreturn" is passed, define
# _Noreturn.
m4_define([b4_attribute_define],
[#ifndef YY_ATTRIBUTE
[[#ifndef YY_ATTRIBUTE
# if (defined __GNUC__ \
&& (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
|| defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
@@ -226,23 +228,30 @@ m4_define([b4_attribute_define],
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif
#if !defined _Noreturn \
&& (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
# if defined _MSC_VER && 1200 <= _MSC_VER
# define _Noreturn __declspec (noreturn)
# else
# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */
#if ! defined _Noreturn
# if defined __cplusplus && 201103L <= __cplusplus
# define _Noreturn [[noreturn]]
# elif !(defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)
# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
|| 0x5110 <= __SUNPRO_C)
# define _Noreturn __attribute__ ((__noreturn__))
# elif defined _MSC_VER && 1200 <= _MSC_VER
# define _Noreturn __declspec (noreturn)
# else
# define _Noreturn
# endif
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
]])[/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
@@ -260,24 +269,26 @@ m4_define([b4_attribute_define],
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
])
## ---------##
## Values. ##
## ---------##
]])
# b4_null_define
# --------------
# Portability issues: define a YY_NULLPTR appropriate for the current
# language (C, C++98, or C++11).
#
# In C++ pre C++11 it is standard practice to use 0 (not NULL) for the
# null pointer. In C, prefer ((void*)0) to avoid having to include stdlib.h.
m4_define([b4_null_define],
[# ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# if defined __cplusplus
# if 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# else
# define YY_NULLPTR 0
# endif
# else
# define YY_NULLPTR 0
# define YY_NULLPTR ((void*)0)
# endif
# endif[]dnl
])
@@ -288,6 +299,12 @@ m4_define([b4_null_define],
# Return a null pointer constant.
m4_define([b4_null], [YY_NULLPTR])
## ---------##
## Values. ##
## ---------##
# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
# -------------------------------------------------------------
# Define "yy<TABLE-NAME>" whose contents is CONTENT.
@@ -357,15 +374,17 @@ m4_define([b4_token_enums_defines],
## ----------------- ##
# b4_symbol_value(VAL, [TYPE])
# ----------------------------
# Given a semantic value VAL ($$, $1 etc.), extract its value of type
# TYPE if TYPE is given, otherwise just return VAL. The result can be
# used safetly, it is put in parens to avoid nasty precedence issues.
# TYPE is *not* put in braces, provide some if needed.
# b4_symbol_value(VAL, [SYMBOL-NUM], [TYPE-TAG])
# ----------------------------------------------
# See README.
m4_define([b4_symbol_value],
[($1[]m4_ifval([$2], [.$2]))])
[m4_ifval([$3],
[($1.$3)],
[m4_ifval([$2],
[b4_symbol_if([$2], [has_type],
[($1.b4_symbol([$2], [type]))],
[$1])],
[$1])])])
## ---------------------- ##
@@ -459,7 +478,8 @@ b4_syncline([@oline@], [@ofile@])
# ------------------------------------
m4_define([b4_predicate_case],
[ case $1:
if (! ($2)) YYERROR;
if (! (
$2)) YYERROR;
b4_syncline([@oline@], [@ofile@])
break;])
@@ -497,54 +517,54 @@ m4_ifset([b4_parse_param], [, b4_parse_param]))[
# Define the "yy_symbol_print" function.
m4_define_default([b4_yy_symbol_print_define],
[[
/*----------------------------------------.
| Print this symbol's value on YYOUTPUT. |
`----------------------------------------*/
/*-----------------------------------.
| Print this symbol's value on YYO. |
`-----------------------------------*/
]b4_function_define([yy_symbol_value_print],
[static void],
[[FILE *yyoutput], [yyoutput]],
[[FILE *yyo], [yyo]],
[[int yytype], [yytype]],
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
m4_ifset([b4_parse_param], [, b4_parse_param]))[
{
FILE *yyo = yyoutput;
]b4_parse_param_use([yyo], [yylocationp])dnl
FILE *yyoutput = yyo;
]b4_parse_param_use([yyoutput], [yylocationp])dnl
[ if (!yyvaluep)
return;]
dnl glr.c does not feature yytoknum.
m4_if(b4_skeleton, ["yacc.c"],
[[# ifdef YYPRINT
if (yytype < YYNTOKENS)
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
# endif
]])dnl
b4_symbol_actions([printer])[
}
/*--------------------------------.
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
/*---------------------------.
| Print this symbol on YYO. |
`---------------------------*/
]b4_function_define([yy_symbol_print],
[static void],
[[FILE *yyoutput], [yyoutput]],
[[FILE *yyo], [yyo]],
[[int yytype], [yytype]],
[[YYSTYPE const * const yyvaluep], [yyvaluep]][]dnl
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
m4_ifset([b4_parse_param], [, b4_parse_param]))[
{
YYFPRINTF (yyoutput, "%s %s (",
YYFPRINTF (yyo, "%s %s (",
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
]b4_locations_if([ YY_LOCATION_PRINT (yyoutput, *yylocationp);
YYFPRINTF (yyoutput, ": ");
]b4_locations_if([ YY_LOCATION_PRINT (yyo, *yylocationp);
YYFPRINTF (yyo, ": ");
])dnl
[ yy_symbol_value_print (yyoutput, yytype, yyvaluep]dnl
[ yy_symbol_value_print (yyo, yytype, yyvaluep]dnl
b4_locations_if([, yylocationp])[]b4_user_args[);
YYFPRINTF (yyoutput, ")");
YYFPRINTF (yyo, ")");
}]dnl
])
@@ -587,14 +607,17 @@ m4_define([b4_type_define_tag],
])
# b4_symbol_value_union(VAL, [TYPE])
# ----------------------------------
# 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([$2],
[(*($2*)(&$1))],
[$1])])
])
[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
@@ -806,11 +829,11 @@ m4_define([b4_yy_location_print_define],
YY_ATTRIBUTE_UNUSED
]b4_function_define([yy_location_print_],
[static unsigned],
[static int],
[[FILE *yyo], [yyo]],
[[YYLTYPE const * const yylocp], [yylocp]])[
{
unsigned res = 0;
int res = 0;
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
if (0 <= yylocp->first_line)
{

View File

@@ -0,0 +1,26 @@
-*- Autoconf -*-
# D skeleton dispatching for Bison.
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
b4_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)

View File

@@ -0,0 +1,320 @@
-*- Autoconf -*-
# D language support for Bison
# Copyright (C) 2018-2019 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# b4_comment(TEXT)
# ----------------
m4_define([b4_comment], [/* m4_bpatsubst([$1], [
], [
]) */])
# b4_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]])
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_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_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_locations_if(TRUE, FALSE)
# ----------------------------
m4_define([b4_locations_if],
[m4_if(b4_locations_flag, 1, [$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";
/** 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
])
## ------------------------- ##
## Assigning token numbers. ##
## ------------------------- ##
# 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(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
# -----------------------------------------------------
# Output the definition of the tokens as enums.
m4_define([b4_token_enums],
[/* Tokens. */
public enum YYTokenType {
/** Token returned by the scanner to signal the end of its input. */
EOF = 0,
b4_symbol_foreach([b4_token_enum])
}
])
# b4-case(ID, CODE)
# -----------------
m4_define([b4_case], [ case $1:
$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[]YYParser])])
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]))
## ----------------- ##
## 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 ([$1], [$2])])
# b4_lex_param
# b4_parse_param
# --------------
# If defined, b4_lex_param arrives double quoted, but below we prefer
# it to be single quoted. Same for b4_parse_param.
# TODO: should be in bison.m4
m4_define_default([b4_lex_param], [[]]))
m4_define([b4_lex_param], b4_lex_param))
m4_define([b4_parse_param], b4_parse_param))
# b4_lex_param_decl
# -------------------
# Extra formal arguments of the constructor.
m4_define([b4_lex_param_decl],
[m4_ifset([b4_lex_param],
[b4_remove_comma([$1],
b4_param_decls(b4_lex_param))],
[$1])])
m4_define([b4_param_decls],
[m4_map([b4_param_decl], [$@])])
m4_define([b4_param_decl], [, $1])
m4_define([b4_remove_comma], [m4_ifval(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;])

View File

@@ -2,7 +2,7 @@
# GLR skeleton for Bison
# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
# Copyright (C) 2002-2015, 2018-2019 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
@@ -21,7 +21,8 @@
# If we are loaded by glr.cc, do not override c++.m4 definitions by
# those of c.m4.
m4_if(b4_skeleton, ["glr.c"],
[m4_include(b4_pkgdatadir/[c.m4])])
[m4_include(b4_skeletonsdir/[c.m4])])
## ---------------- ##
## Default values. ##
@@ -96,6 +97,7 @@ m4_define([b4_pure_formals],
# b4_locuser_formals(LOC = yylocp)
# --------------------------------
# User formal arguments, possibly preceded by location argument.
m4_define([b4_locuser_formals],
[b4_locations_if([, YYLTYPE *m4_default([$1], [yylocp])])[]b4_user_formals])
@@ -112,27 +114,25 @@ m4_define([b4_locuser_args],
## ----------------- ##
# b4_lhs_value([TYPE])
# --------------------
# Expansion of $<TYPE>$.
# b4_lhs_value(SYMBOL-NUM, [TYPE])
# --------------------------------
# See README.
m4_define([b4_lhs_value],
[b4_symbol_value([(*yyvalp)], [$1])])
[b4_symbol_value([(*yyvalp)], [$1], [$2])])
# b4_rhs_data(RULE-LENGTH, NUM)
# b4_rhs_data(RULE-LENGTH, POS)
# -----------------------------
# Expand to the semantic stack place that contains value and location
# of symbol number NUM in a rule of length RULE-LENGTH.
# See README.
m4_define([b4_rhs_data],
[((yyGLRStackItem const *)yyvsp)@{YYFILL (b4_subtract([$2], [$1]))@}.yystate])
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
# --------------------------------------
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS.
# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
# --------------------------------------------------
# Expansion of $$ or $<TYPE>$, for symbol SYMBOL-NUM.
m4_define([b4_rhs_value],
[b4_symbol_value([b4_rhs_data([$1], [$2]).yysemantics.yysval], [$3])])
[b4_symbol_value([b4_rhs_data([$1], [$2]).yysemantics.yysval], [$3], [$4])])
@@ -194,16 +194,15 @@ m4_if(b4_skeleton, ["glr.c"],
# ----------------- #
# glr.cc produces its own header.
m4_if(b4_skeleton, ["glr.c"],
b4_glr_cc_if([],
[b4_defines_if(
[b4_output_begin([b4_spec_defines_file])
b4_copyright([Skeleton interface for Bison GLR parsers in C],
[2002-2015, 2018])[
[2002-2015, 2018-2019])[
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations[
]b4_cpp_guard_close([b4_spec_defines_file])[
]b4_output_end()
]b4_output_end
])])
@@ -213,13 +212,13 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C],
b4_output_begin([b4_parser_file_name])
b4_copyright([Skeleton implementation for Bison GLR parsers in C],
[2002-2015, 2018])[
[2002-2015, 2018-2019])[
/* C GLR parser skeleton written by Paul Hilfinger. */
]b4_identification
]b4_disclaimer[
]b4_identification[
b4_percent_code_get([[top]])[
]b4_percent_code_get([[top]])[
]m4_if(b4_api_prefix, [yy], [],
[[/* Substitute the type names. */
#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
@@ -229,14 +228,12 @@ b4_percent_code_get([[top]])[
#define yyparse ]b4_prefix[parse
#define yylex ]b4_prefix[lex
#define yyerror ]b4_prefix[error
#define yydebug ]b4_prefix[debug
]]b4_pure_if([], [[
#define yydebug ]b4_prefix[debug]]b4_pure_if([], [[
#define yylval ]b4_prefix[lval
#define yychar ]b4_prefix[char
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
#define yylloc ]b4_prefix[lloc]])]))[
/* First part of user declarations. */
]b4_user_pre_prologue[
]b4_null_define[
@@ -259,9 +256,8 @@ b4_percent_code_get([[top]])[
static YYSTYPE yyval_default;]b4_locations_if([[
static YYLTYPE yyloc_default][]b4_yyloc_default;])[
/* Copy the second part of user declarations. */
]b4_user_post_prologue
b4_percent_code_get[]dnl
]b4_user_post_prologue[
]b4_percent_code_get[]dnl
[#include <stdio.h>
#include <stdlib.h>
@@ -292,22 +288,29 @@ b4_percent_code_get[]dnl
#define YYSIZEMAX ((size_t) -1)
#ifdef __cplusplus
typedef bool yybool;
typedef bool yybool;
# define yytrue true
# define yyfalse false
#else
typedef unsigned char yybool;
/* When we move to stdbool, get rid of the various casts to yybool. */
typedef unsigned char yybool;
# define yytrue 1
# define yyfalse 0
#endif
#define yytrue 1
#define yyfalse 0
#ifndef YYSETJMP
# include <setjmp.h>
# define YYJMP_BUF jmp_buf
# define YYSETJMP(Env) setjmp (Env)
/* Pacify clang. */
# define YYLONGJMP(Env, Val) (longjmp (Env, Val), YYASSERT (0))
/* Pacify Clang and ICC. */
# define YYLONGJMP(Env, Val) \
do { \
longjmp (Env, Val); \
YYASSERT (0); \
} while (yyfalse)
#endif
]b4_attribute_define[
]b4_attribute_define([noreturn])[
#ifndef YYASSERT
# define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
@@ -324,7 +327,7 @@ b4_percent_code_get[]dnl
#define YYNNTS ]b4_nterms_number[
/* YYNRULES -- Number of rules. */
#define YYNRULES ]b4_rules_number[
/* YYNRULES -- Number of states. */
/* YYNSTATES -- Number of states. */
#define YYNSTATES ]b4_states_number[
/* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
#define YYMAXRHS ]b4_r2_max[
@@ -332,14 +335,22 @@ b4_percent_code_get[]dnl
accessed by $0, $-1, etc., in any rule. */
#define YYMAXLEFT ]b4_max_left_semantic_context[
/* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */
/* YYMAXUTOK -- Last valid token number (for yychar). */
#define YYMAXUTOK ]b4_user_token_number_max[]b4_glr_cc_if([[
/* YYFAULTYTOK -- Token number (for yychar) that denotes a
syntax_error thrown from the scanner. */
#define YYFAULTYTOK (YYMAXUTOK + 1)]])[
/* YYUNDEFTOK -- Symbol number (for yytoken) that denotes an unknown
token. */
#define YYUNDEFTOK ]b4_undef_token_number[
#define YYMAXUTOK ]b4_user_token_number_max[
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, with out-of-bounds checking. */
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
as returned by yylex. */
static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
{
]b4_translate[
@@ -398,9 +409,9 @@ static const ]b4_int_type_for([b4_conflict_list_heads])[ yyconflp[] =
/* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
0, pointed into by YYCONFLP. */
]dnl Do not use b4_int_type_for here, since there are places where
dnl pointers onto yyconfl are taken, whose type is "short int *".
dnl pointers onto yyconfl are taken, whose type is "short*".
dnl We probably ought to introduce a type for confl.
[static const short int yyconfl[] =
[static const short yyconfl[] =
{
]b4_conflicting_rules[
};
@@ -579,7 +590,10 @@ yytnamerr (char *yyres, const char *yystr)
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
/* Fall through. */
else
goto append;
append:
default:
if (yyres)
yyres[yyn] = *yyp;
@@ -597,7 +611,7 @@ yytnamerr (char *yyres, const char *yystr)
if (! yyres)
return strlen (yystr);
return yystpcpy (yyres, yystr) - yyres;
return (size_t) (yystpcpy (yyres, yystr) - yyres);
}
# endif
@@ -613,7 +627,7 @@ typedef int yyRuleNum;
typedef int yySymbol;
/** Item references, as in LALR(1) machine */
typedef short int yyItemNum;
typedef short yyItemNum;
typedef struct yyGLRState yyGLRState;
typedef struct yyGLRStateSet yyGLRStateSet;
@@ -635,7 +649,7 @@ struct yyGLRState {
size_t yyposn;
union {
/** First in a chain of alternative reductions producing the
* non-terminal corresponding to this state, threaded through
* nonterminal corresponding to this state, threaded through
* yynext. */
yySemanticOption* yyfirstVal;
/** Semantic value for this state. */
@@ -702,7 +716,7 @@ struct yyGLRStack {
static void yyexpandGLRStack (yyGLRStack* yystackp);
#endif
static _Noreturn void
_Noreturn static void
yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
{
if (yymsg != YY_NULLPTR)
@@ -710,7 +724,7 @@ yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
YYLONGJMP (yystackp->yyexception_buffer, 1);
}
static _Noreturn void
_Noreturn static void
yyMemoryExhausted (yyGLRStack* yystackp)
{
YYLONGJMP (yystackp->yyexception_buffer, 2);
@@ -754,6 +768,50 @@ yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
}
}
]m4_define([b4_yygetToken_call],
[[yygetToken (&yychar][]b4_pure_if([, yystackp])[]b4_user_args[)]])[
/** If yychar is empty, fetch the next token. */
static inline yySymbol
yygetToken (int *yycharp][]b4_pure_if([, yyGLRStack* yystackp])[]b4_user_formals[)
{
yySymbol yytoken;
]b4_parse_param_use()dnl
[ if (*yycharp == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));]b4_glr_cc_if([[
#if YY_EXCEPTIONS
try
{
#endif // YY_EXCEPTIONS
*yycharp = ]b4_lex[;
#if YY_EXCEPTIONS
}
catch (const ]b4_namespace_ref[::]b4_parser_class[::syntax_error& yyexc)
{
YYDPRINTF ((stderr, "Caught exception: %s\n", yyexc.what()));]b4_locations_if([
yylloc = yyexc.location;])[
yyerror (]b4_lyyerror_args[yyexc.what ());
// Map errors caught in the scanner to the undefined token
// (YYUNDEFTOK), so that error handling is started.
// However, record this with this special value of yychar.
*yycharp = YYFAULTYTOK;
}
#endif // YY_EXCEPTIONS]], [[
*yycharp = ]b4_lex[;]])[
}
if (*yycharp <= YYEOF)
{
*yycharp = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yytoken = YYTRANSLATE (*yycharp);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
return yytoken;
}
/* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in
* YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
* For convenience, always return YYLOW1. */
@@ -776,11 +834,11 @@ yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
* (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
* yyerr for YYERROR, yyabort for YYABORT. */
static YYRESULTTAG
yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
yyGLRStack* yystackp,
YYSTYPE* yyvalp]b4_locuser_formals[)
{
yybool yynormal YY_ATTRIBUTE_UNUSED = (yystackp->yysplitPoint == YY_NULLPTR);
yybool yynormal YY_ATTRIBUTE_UNUSED = (yybool) (yystackp->yysplitPoint == YY_NULLPTR);
int yylow;
]b4_parse_param_use([yyvalp], [yylocp])dnl
[ YYUSE (yyrhslen);
@@ -797,7 +855,7 @@ yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
# undef yyclearin
# define yyclearin (yychar = YYEMPTY)
# undef YYFILL
# define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
# define YYFILL(N) yyfill (yyvsp, &yylow, (N), yynormal)
# undef YYBACKUP
# define YYBACKUP(Token, Value) \
return yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")), \
@@ -811,12 +869,27 @@ yyuserAction (yyRuleNum yyn, size_t yyrhslen, yyGLRStackItem* yyvsp,
/* Default location. */
YYLLOC_DEFAULT ((*yylocp), (yyvsp - yyrhslen), yyrhslen);
yystackp->yyerror_range[1].yystate.yyloc = *yylocp;
]])[
]])[]b4_glr_cc_if([[
#if YY_EXCEPTIONS
typedef ]b4_namespace_ref[::]b4_parser_class[::syntax_error syntax_error;
try
{
#endif // YY_EXCEPTIONS]])[
switch (yyn)
{
]b4_user_actions[
]b4_user_actions[
default: break;
}]b4_glr_cc_if([[
#if YY_EXCEPTIONS
}
catch (const syntax_error& yyexc)
{
YYDPRINTF ((stderr, "Caught exception: %s\n", yyexc.what()));]b4_locations_if([
*yylocp = yyexc.location;])[
yyerror (]b4_yyerror_args[yyexc.what ());
YYERROR;
}
#endif // YY_EXCEPTIONS]])[
return yyok;
# undef yyerrok
@@ -900,7 +973,7 @@ yylhsNonterm (yyRuleNum yyrule)
static inline yybool
yyisDefaultedState (yyStateNum yystate)
{
return yypact_value_is_default (yypact[yystate]);
return (yybool) yypact_value_is_default (yypact[yystate]);
}
/** The default reduction for YYSTATE, assuming it has one. */
@@ -913,7 +986,7 @@ yydefaultAction (yyStateNum yystate)
#define yytable_value_is_error(Yytable_value) \
]b4_table_value_equals([[table]], [[Yytable_value]], [b4_table_ninf])[
/** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
/** The action to take in YYSTATE on seeing YYTOKEN.
* Result R means
* R < 0: Reduce on rule -R.
* R = 0: Error.
@@ -921,26 +994,25 @@ yydefaultAction (yyStateNum yystate)
* Set *YYCONFLICTS to a pointer into yyconfl to a 0-terminated list
* of conflicting reductions.
*/
static inline void
yygetLRActions (yyStateNum yystate, int yytoken,
int* yyaction, const short int** yyconflicts)
static inline int
yygetLRActions (yyStateNum yystate, yySymbol yytoken, const short** yyconflicts)
{
int yyindex = yypact[yystate] + yytoken;
if (yypact_value_is_default (yypact[yystate])
if (yyisDefaultedState (yystate)
|| yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
{
*yyaction = -yydefact[yystate];
*yyconflicts = yyconfl;
return -yydefact[yystate];
}
else if (! yytable_value_is_error (yytable[yyindex]))
{
*yyaction = yytable[yyindex];
*yyconflicts = yyconfl + yyconflp[yyindex];
return yytable[yyindex];
}
else
{
*yyaction = 0;
*yyconflicts = yyconfl + yyconflp[yyindex];
return 0;
}
}
@@ -961,13 +1033,13 @@ yyLRgotoState (yyStateNum yystate, yySymbol yysym)
static inline yybool
yyisShiftAction (int yyaction)
{
return 0 < yyaction;
return (yybool) (0 < yyaction);
}
static inline yybool
yyisErrorAction (int yyaction)
{
return yyaction == 0;
return (yybool) (yyaction == 0);
}
/* GLRStates */
@@ -1077,7 +1149,7 @@ yyexpandGLRStack (yyGLRStack* yystackp)
yyGLRStackItem* yyp0, *yyp1;
size_t yynewSize;
size_t yyn;
size_t yysize = yystackp->yynextFree - yystackp->yyitems;
size_t yysize = (size_t) (yystackp->yynextFree - yystackp->yyitems);
if (YYMAXDEPTH - YYHEADROOM < yysize)
yyMemoryExhausted (yystackp);
yynewSize = 2*yysize;
@@ -1196,7 +1268,7 @@ yyremoveDeletes (yyGLRStack* yystackp)
if (yyj != yyi)
{
YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n",
(unsigned long int) yyi, (unsigned long int) yyj));
(unsigned long) yyi, (unsigned long) yyj));
}
yyj += 1;
}
@@ -1250,25 +1322,25 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
# define YY_REDUCE_PRINT(Args)
#else
# define YY_REDUCE_PRINT(Args) \
do { \
if (yydebug) \
yy_reduce_print Args; \
} while (0)
do { \
if (yydebug) \
yy_reduce_print Args; \
} while (0)
/*----------------------------------------------------------------------.
| Report that stack #YYK of *YYSTACKP is going to be reduced by YYRULE. |
`----------------------------------------------------------------------*/
static inline void
yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk,
yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, size_t yyk,
yyRuleNum yyrule]b4_user_formals[)
{
int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
int yylow = 1;])[
int yyi;
YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n",
(unsigned long int) yyk, yyrule - 1,
(unsigned long int) yyrline[yyrule]);
(unsigned long) yyk, yyrule - 1,
(unsigned long) yyrline[yyrule]);
if (! yynormal)
yyfillin (yyvsp, 1, -yynrhs);
/* The symbols being reduced. */
@@ -1277,8 +1349,8 @@ yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk,
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
yystos[yyvsp[yyi - yynrhs + 1].yystate.yylrState],
&yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval
]b4_locations_if([, &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
&yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval]b4_locations_if([,
&]b4_rhs_location(yynrhs, yyi + 1))[]dnl
b4_user_args[);
if (!yyvsp[yyi - yynrhs + 1].yystate.yyresolved)
YYFPRINTF (stderr, " (unresolved)");
@@ -1305,9 +1377,9 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
yyGLRStackItem* yyrhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
YYASSERT (yyk == 0);
yystackp->yynextFree -= yynrhs;
yystackp->yyspaceLeft += yynrhs;
yystackp->yyspaceLeft += (size_t) yynrhs;
yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
YY_REDUCE_PRINT ((1, yyrhs, yyk, yyrule]b4_user_args[));
YY_REDUCE_PRINT ((yytrue, yyrhs, yyk, yyrule]b4_user_args[));
return yyuserAction (yyrule, yynrhs, yyrhs, yystackp,
yyvalp]b4_locuser_args[);
}
@@ -1328,7 +1400,7 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
}
yyupdateSplit (yystackp, yys);
yystackp->yytops.yystates[yyk] = yys;
YY_REDUCE_PRINT ((0, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyk, yyrule]b4_user_args[));
YY_REDUCE_PRINT ((yyfalse, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1, yyk, yyrule]b4_user_args[));
return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
yystackp, yyvalp]b4_locuser_args[);
}
@@ -1360,7 +1432,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULLPTR)
{
YYDPRINTF ((stderr, "Parse on stack %lu rejected by rule #%d.\n",
(unsigned long int) yyk, yyrule - 1));
(unsigned long) yyk, yyrule - 1));
}
if (yyflag != yyok)
return yyflag;
@@ -1388,7 +1460,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
YYDPRINTF ((stderr,
"Reduced stack %lu by rule #%d; action deferred. "
"Now in state %d.\n",
(unsigned long int) yyk, yyrule - 1, yynewLRState));
(unsigned long) yyk, yyrule - 1, yynewLRState));
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULLPTR)
{
@@ -1401,8 +1473,8 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
yyaddDeferredAction (yystackp, yyk, yyp, yys0, yyrule);
yymarkStackDeleted (yystackp, yyk);
YYDPRINTF ((stderr, "Merging stack %lu into stack %lu.\n",
(unsigned long int) yyk,
(unsigned long int) yyi));
(unsigned long) yyk,
(unsigned long) yyi));
return yyok;
}
yyp = yyp->yypred;
@@ -1424,11 +1496,9 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
}
if (yystackp->yytops.yysize >= yystackp->yytops.yycapacity)
{
yyGLRState** yynewStates;
yyGLRState** yynewStates = YY_NULLPTR;
yybool* yynewLookaheadNeeds;
yynewStates = YY_NULLPTR;
if (yystackp->yytops.yycapacity
> (YYSIZEMAX / (2 * sizeof yynewStates[0])))
yyMemoryExhausted (yystackp);
@@ -1648,8 +1718,8 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
else
YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
yyx->yyrule - 1, (unsigned long int) (yys->yyposn + 1),
(unsigned long int) yyx->yystate->yyposn);
yyx->yyrule - 1, (unsigned long) (yys->yyposn + 1),
(unsigned long) yyx->yystate->yyposn);
for (yyi = 1; yyi <= yynrhs; yyi += 1)
{
if (yystates[yyi]->yyresolved)
@@ -1660,8 +1730,8 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
else
YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
yytokenName (yystos[yystates[yyi]->yylrState]),
(unsigned long int) (yystates[yyi-1]->yyposn + 1),
(unsigned long int) yystates[yyi]->yyposn);
(unsigned long) (yystates[yyi-1]->yyposn + 1),
(unsigned long) yystates[yyi]->yyposn);
}
else
yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);
@@ -1693,7 +1763,7 @@ yyreportAmbiguity (yySemanticOption* yyx0,
* ending at YYS1. Has no effect on previously resolved states.
* The first semantic option of a state is always chosen. */
static void
yyresolveLocations (yyGLRState* yys1, int yyn1,
yyresolveLocations (yyGLRState *yys1, int yyn1,
yyGLRStack *yystackp]b4_user_formals[)
{
if (0 < yyn1)
@@ -1704,9 +1774,9 @@ yyresolveLocations (yyGLRState* yys1, int yyn1,
yyGLRStackItem yyrhsloc[1 + YYMAXRHS];
int yynrhs;
yySemanticOption *yyoption = yys1->yysemantics.yyfirstVal;
YYASSERT (yyoption != YY_NULLPTR);
YYASSERT (yyoption);
yynrhs = yyrhsLength (yyoption->yyrule);
if (yynrhs > 0)
if (0 < yynrhs)
{
yyGLRState *yys;
int yyn;
@@ -1729,18 +1799,7 @@ yyresolveLocations (yyGLRState* yys1, int yyn1,
yyGLRState *yyprevious = yyoption->yystate;
yyrhsloc[0].yystate.yyloc = yyprevious->yyloc;
}
{
int yychar_current = yychar;
YYSTYPE yylval_current = yylval;
YYLTYPE yylloc_current = yylloc;
yychar = yyoption->yyrawchar;
yylval = yyoption->yyval;
yylloc = yyoption->yyloc;
YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs);
yychar = yychar_current;
yylval = yylval_current;
yylloc = yylloc_current;
}
YYLLOC_DEFAULT ((yys1->yyloc), yyrhsloc, yynrhs);
}
}
}]])[
@@ -1867,9 +1926,9 @@ yycompressStack (yyGLRStack* yystackp)
yyr = yyp, yyp = yyq, yyq = yyp->yypred)
yyp->yypred = yyr;
yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems;
yystackp->yyspaceLeft += (size_t) (yystackp->yynextFree - yystackp->yyitems);
yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1;
yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems;
yystackp->yyspaceLeft -= (size_t) (yystackp->yynextFree - yystackp->yyitems);
yystackp->yysplitPoint = YY_NULLPTR;
yystackp->yylastDeleted = YY_NULLPTR;
@@ -1892,7 +1951,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
{
yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
YYDPRINTF ((stderr, "Stack %lu Entering state %d\n",
(unsigned long int) yyk, yystate));
(unsigned long) yyk, yystate));
YYASSERT (yystate != YYFINAL);
@@ -1903,7 +1962,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
if (yyrule == 0)
{
YYDPRINTF ((stderr, "Stack %lu dies.\n",
(unsigned long int) yyk));
(unsigned long) yyk));
yymarkStackDeleted (yystackp, yyk);
return yyok;
}
@@ -1913,7 +1972,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
YYDPRINTF ((stderr,
"Stack %lu dies "
"(predicate failure or explicit user error).\n",
(unsigned long int) yyk));
(unsigned long) yyk));
yymarkStackDeleted (yystackp, yyk);
return yyok;
}
@@ -1924,35 +1983,19 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
{
yySymbol yytoken;
int yyaction;
const short int* yyconflicts;
const short* yyconflicts;
yystackp->yytops.yylookaheadNeeds[yyk] = yytrue;
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = ]b4_lex[;
}
if (yychar <= YYEOF)
{
yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
yytoken = ]b4_yygetToken_call[;
yyaction = yygetLRActions (yystate, yytoken, &yyconflicts);
while (*yyconflicts != 0)
{
YYRESULTTAG yyflag;
size_t yynewStack = yysplitStack (yystackp, yyk);
YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n",
(unsigned long int) yynewStack,
(unsigned long int) yyk));
(unsigned long) yynewStack,
(unsigned long) yyk));
yyflag = yyglrReduce (yystackp, yynewStack,
*yyconflicts,
yyimmediate[*yyconflicts]]b4_user_args[);
@@ -1962,7 +2005,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
else if (yyflag == yyerr)
{
YYDPRINTF ((stderr, "Stack %lu dies.\n",
(unsigned long int) yynewStack));
(unsigned long) yynewStack));
yymarkStackDeleted (yystackp, yynewStack);
}
else
@@ -1975,7 +2018,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
else if (yyisErrorAction (yyaction))
{
YYDPRINTF ((stderr, "Stack %lu dies.\n",
(unsigned long int) yyk));
(unsigned long) yyk));
yymarkStackDeleted (yystackp, yyk);
break;
}
@@ -1988,7 +2031,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
YYDPRINTF ((stderr,
"Stack %lu dies "
"(predicate failure or explicit user error).\n",
(unsigned long int) yyk));
(unsigned long) yyk));
yymarkStackDeleted (yystackp, yyk);
break;
}
@@ -2073,7 +2116,8 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
yyarg[yycount++] = yytokenName (yyx);
{
size_t yysz = yysize + yytnamerr (YY_NULLPTR, yytokenName (yyx));
yysize_overflow |= yysz < yysize;
if (yysz < yysize)
yysize_overflow = yytrue;
yysize = yysz;
}
}
@@ -2098,7 +2142,8 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
{
size_t yysz = yysize + strlen (yyformat);
yysize_overflow |= yysz < yysize;
if (yysz < yysize)
yysize_overflow = yytrue;
yysize = yysz;
}
@@ -2141,15 +2186,13 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
static void
yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
{
size_t yyk;
int yyj;
if (yystackp->yyerrState == 3)
/* We just shifted the error token and (perhaps) took some
reductions. Skip tokens until we can proceed. */
while (yytrue)
{
yySymbol yytoken;
int yyj;
if (yychar == YYEOF)
yyFail (yystackp][]b4_lpure_args[, YY_NULLPTR);
if (yychar != YYEMPTY)
@@ -2164,19 +2207,9 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
yytoken = YYTRANSLATE (yychar);
yydestruct ("Error: discarding",
yytoken, &yylval]b4_locuser_args([&yylloc])[);
yychar = YYEMPTY;
}
YYDPRINTF ((stderr, "Reading a token: "));
yychar = ]b4_lex[;
if (yychar <= YYEOF)
{
yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
yytoken = ]b4_yygetToken_call[;
yyj = yypact[yystackp->yytops.yystates[0]->yylrState];
if (yypact_value_is_default (yyj))
return;
@@ -2191,22 +2224,25 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
}
/* Reduce to one stack. */
for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1)
if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
break;
if (yyk >= yystackp->yytops.yysize)
yyFail (yystackp][]b4_lpure_args[, YY_NULLPTR);
for (yyk += 1; yyk < yystackp->yytops.yysize; yyk += 1)
yymarkStackDeleted (yystackp, yyk);
yyremoveDeletes (yystackp);
yycompressStack (yystackp);
{
size_t yyk;
for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1)
if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
break;
if (yyk >= yystackp->yytops.yysize)
yyFail (yystackp][]b4_lpure_args[, YY_NULLPTR);
for (yyk += 1; yyk < yystackp->yytops.yysize; yyk += 1)
yymarkStackDeleted (yystackp, yyk);
yyremoveDeletes (yystackp);
yycompressStack (yystackp);
}
/* Now pop stack until we find a state that shifts the error token. */
yystackp->yyerrState = 3;
while (yystackp->yytops.yystates[0] != YY_NULLPTR)
{
yyGLRState *yys = yystackp->yytops.yystates[0];
yyj = yypact[yys->yylrState];
int yyj = yypact[yys->yylrState];
if (! yypact_value_is_default (yyj))
{
yyj += YYTERROR;
@@ -2270,8 +2306,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
yylval = yyval_default;]b4_locations_if([
yylloc = yyloc_default;])[
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yylval], [], [yylloc])dnl
/* User initialization code. */
b4_dollar_pushdef([yylval], [], [], [yylloc])dnl
b4_user_initial_action
b4_dollar_popdef])[]dnl
[
@@ -2295,17 +2330,13 @@ b4_dollar_popdef])[]dnl
/* Standard mode */
while (yytrue)
{
yyRuleNum yyrule;
int yyaction;
const short int* yyconflicts;
yyStateNum yystate = yystack.yytops.yystates[0]->yylrState;
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
if (yystate == YYFINAL)
goto yyacceptlab;
if (yyisDefaultedState (yystate))
{
yyrule = yydefaultAction (yystate);
yyRuleNum yyrule = yydefaultAction (yystate);
if (yyrule == 0)
{]b4_locations_if([[
yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
@@ -2316,25 +2347,9 @@ b4_dollar_popdef])[]dnl
}
else
{
yySymbol yytoken;
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = ]b4_lex[;
}
if (yychar <= YYEOF)
{
yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
yySymbol yytoken = ]b4_yygetToken_call;[
const short* yyconflicts;
int yyaction = yygetLRActions (yystate, yytoken, &yyconflicts);
if (*yyconflicts != 0)
break;
if (yyisShiftAction (yyaction))
@@ -2348,8 +2363,11 @@ b4_dollar_popdef])[]dnl
}
else if (yyisErrorAction (yyaction))
{]b4_locations_if([[
yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
yyreportSyntaxError (&yystack]b4_user_args[);
yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[]b4_glr_cc_if([[
/* Don't issue an error message again for exceptions
thrown from the scanner. */
if (yychar != YYFAULTYTOK)
]])[ yyreportSyntaxError (&yystack]b4_user_args[);
goto yyuser_error;
}
else
@@ -2363,7 +2381,7 @@ b4_dollar_popdef])[]dnl
size_t yys;
for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
yystackp->yytops.yylookaheadNeeds[yys] = yychar != YYEMPTY;
yystackp->yytops.yylookaheadNeeds[yys] = (yybool) (yychar != YYEMPTY);
/* yyprocessOneStack returns one of three things:
@@ -2409,18 +2427,17 @@ b4_dollar_popdef])[]dnl
yyposn += 1;
for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
{
int yyaction;
const short int* yyconflicts;
yyStateNum yystate = yystack.yytops.yystates[yys]->yylrState;
yygetLRActions (yystate, yytoken_to_shift, &yyaction,
const short* yyconflicts;
int yyaction = yygetLRActions (yystate, yytoken_to_shift,
&yyconflicts);
/* Note that yyconflicts were handled by yyprocessOneStack. */
YYDPRINTF ((stderr, "On stack %lu, ", (unsigned long int) yys));
YYDPRINTF ((stderr, "On stack %lu, ", (unsigned long) yys));
YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, &yylval, &yylloc);
yyglrShift (&yystack, yys, yyaction, yyposn,
&yylval]b4_locations_if([, &yylloc])[);
YYDPRINTF ((stderr, "Stack %lu now in state #%d\n",
(unsigned long int) yys,
(unsigned long) yys,
yystack.yytops.yystates[yys]->yylrState));
}
@@ -2503,7 +2520,7 @@ yy_yypstack (yyGLRState* yys)
YYFPRINTF (stderr, " -> ");
}
YYFPRINTF (stderr, "%d@@%lu", yys->yylrState,
(unsigned long int) yys->yyposn);
(unsigned long) yys->yyposn);
}
static void
@@ -2534,18 +2551,18 @@ yypdumpstack (yyGLRStack* yystackp)
for (yyp = yystackp->yyitems; yyp < yystackp->yynextFree; yyp += 1)
{
YYFPRINTF (stderr, "%3lu. ",
(unsigned long int) (yyp - yystackp->yyitems));
(unsigned long) (yyp - yystackp->yyitems));
if (*(yybool *) yyp)
{
YYASSERT (yyp->yystate.yyisState);
YYASSERT (yyp->yyoption.yyisState);
YYFPRINTF (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
yyp->yystate.yyresolved, yyp->yystate.yylrState,
(unsigned long int) yyp->yystate.yyposn,
(long int) YYINDEX (yyp->yystate.yypred));
(unsigned long) yyp->yystate.yyposn,
(long) YYINDEX (yyp->yystate.yypred));
if (! yyp->yystate.yyresolved)
YYFPRINTF (stderr, ", firstVal: %ld",
(long int) YYINDEX (yyp->yystate
(long) YYINDEX (yyp->yystate
.yysemantics.yyfirstVal));
}
else
@@ -2554,15 +2571,15 @@ yypdumpstack (yyGLRStack* yystackp)
YYASSERT (!yyp->yyoption.yyisState);
YYFPRINTF (stderr, "Option. rule: %d, state: %ld, next: %ld",
yyp->yyoption.yyrule - 1,
(long int) YYINDEX (yyp->yyoption.yystate),
(long int) YYINDEX (yyp->yyoption.yynext));
(long) YYINDEX (yyp->yyoption.yystate),
(long) YYINDEX (yyp->yyoption.yynext));
}
YYFPRINTF (stderr, "\n");
}
YYFPRINTF (stderr, "Tops:");
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
YYFPRINTF (stderr, "%lu: %ld; ", (unsigned long int) yyi,
(long int) YYINDEX (yystackp->yytops.yystates[yyi]));
YYFPRINTF (stderr, "%lu: %ld; ", (unsigned long) yyi,
(long) YYINDEX (yystackp->yytops.yystates[yyi]));
YYFPRINTF (stderr, "\n");
}
#endif
@@ -2584,4 +2601,4 @@ m4_if(b4_prefix, [yy], [],
#define yylloc ]b4_prefix[lloc]])])[
]b4_epilogue[]dnl
b4_output_end()
b4_output_end

View File

@@ -1,6 +1,6 @@
# C++ GLR skeleton for Bison
# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
# Copyright (C) 2002-2015, 2018-2019 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
@@ -44,13 +44,13 @@
# filename member).
# We require a pure interface.
m4_define([b4_pure_flag], [1])
m4_define([b4_pure_flag], [1])
m4_include(b4_pkgdatadir/[c++.m4])
b4_bison_locations_if([m4_include(b4_pkgdatadir/[location.cc])])
m4_include(b4_skeletonsdir/[c++.m4])
b4_bison_locations_if([m4_include(b4_skeletonsdir/[location.cc])])
m4_define([b4_parser_class_name],
[b4_percent_define_get([[parser_class_name]])])
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]))
@@ -60,10 +60,10 @@ m4_define([b4_parse_param_orig], m4_defn([b4_parse_param]))
# New ones.
m4_ifset([b4_parse_param],
[m4_define([b4_parse_param_wrap],
[[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]],]
[[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_name[& yyparser], [[yyparser]]]])
[[b4_namespace_ref::b4_parser_class[& yyparser], [[yyparser]]]])
])
@@ -81,10 +81,10 @@ m4_define([b4_yy_symbol_print_define],
[static void],
[[FILE *], []],
[[int yytype], [yytype]],
[[const ]b4_namespace_ref::b4_parser_class_name[::semantic_type *yyvaluep],
[[const ]b4_namespace_ref::b4_parser_class[::semantic_type *yyvaluep],
[yyvaluep]][]dnl
b4_locations_if([,
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
[yylocationp]]]),
b4_parse_param)[
{
@@ -98,18 +98,15 @@ b4_locations_if([,
[yylloc.initialize ();]m4_ifdef([b4_initial_action], [
m4_defn([b4_initial_action])]))])[
# Hijack the post prologue to insert early definition of YYLLOC_DEFAULT
# and declaration of yyerror.
# Hijack the post prologue to declare yyerror.
]m4_append([b4_post_prologue],
[b4_syncline([@oline@], [@ofile@])[
]b4_yylloc_default_define[
#define YYRHSLOC(Rhs, K) ((Rhs)[K].yystate.yyloc)
]b4_function_declare([yyerror],
[static void],b4_locations_if([
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
[yylocationp]],])
b4_parse_param,
[[const char* msg], [msg]])])
[[const char* msg], [msg]])])[
#undef yynerrs
@@ -122,8 +119,7 @@ m4_if(b4_prefix, [yy], [],
#define yyparse ]b4_prefix[parse
#define yylex ]b4_prefix[lex
#define yyerror ]b4_prefix[error
#define yydebug ]b4_prefix[debug
]]b4_pure_if([], [[
#define yydebug ]b4_prefix[debug]]b4_pure_if([], [[
#define yylval ]b4_prefix[lval
#define yychar ]b4_prefix[char
#define yynerrs ]b4_prefix[nerrs]b4_locations_if([[
@@ -140,7 +136,7 @@ m4_append([b4_epilogue],
]b4_function_define([yyerror],
[static void],b4_locations_if([
[[const ]b4_namespace_ref::b4_parser_class_name[::location_type *yylocationp],
[[const ]b4_namespace_ref::b4_parser_class[::location_type *yylocationp],
[yylocationp]],])
b4_parse_param,
[[const char* msg], [msg]])[
@@ -154,20 +150,27 @@ m4_append([b4_epilogue],
]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_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
]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_name::~b4_parser_class_name[ ()
]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_name[::parse ()
]b4_parser_class[::parse ()
{
return ::yyparse (*this]b4_user_args[);
}
@@ -178,21 +181,21 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
`--------------------*/
void
]b4_parser_class_name[::yy_symbol_value_print_ (int yytype,
]b4_parser_class[::yy_symbol_value_print_ (int yytype,
const semantic_type* yyvaluep]b4_locations_if([[,
const location_type* yylocationp]])[)
{]b4_locations_if([[
YYUSE (yylocationp);]])[
YYUSE (yyvaluep);
std::ostream& yyoutput = debug_stream ();
std::ostream& yyo = yyoutput;
YYUSE (yyo);
std::ostream& yyo = debug_stream ();
std::ostream& yyoutput = yyo;
YYUSE (yyoutput);
]b4_symbol_actions([printer])[
}
void
]b4_parser_class_name[::yy_symbol_print_ (int yytype,
]b4_parser_class[::yy_symbol_print_ (int yytype,
const semantic_type* yyvaluep]b4_locations_if([[,
const location_type* yylocationp]])[)
{
@@ -204,26 +207,26 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
}
std::ostream&
]b4_parser_class_name[::debug_stream () const
]b4_parser_class[::debug_stream () const
{
return *yycdebug_;
}
void
]b4_parser_class_name[::set_debug_stream (std::ostream& o)
]b4_parser_class[::set_debug_stream (std::ostream& o)
{
yycdebug_ = &o;
}
]b4_parser_class_name[::debug_level_type
]b4_parser_class_name[::debug_level () const
]b4_parser_class[::debug_level_type
]b4_parser_class[::debug_level () const
{
return yydebug;
}
void
]b4_parser_class_name[::set_debug_level (debug_level_type l)
]b4_parser_class[::set_debug_level (debug_level_type l)
{
// Actually, it is yydebug which is really used.
yydebug = l;
@@ -234,40 +237,61 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
b4_namespace_close
])
# b4_shared_declarations
# ----------------------
# Declaration that might either go into the header (if --defines)
# or open coded in the parser body.
# b4_shared_declarations(hh|cc)
# -----------------------------
# Declaration that might either go into the header (if --defines, $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>
#include <iostream>]b4_defines_if([
b4_bison_locations_if([[#include "location.hh"]])])[
]b4_cxx_portability[
]m4_ifdef([b4_location_include],
[[# include ]b4_location_include])[
]b4_variant_if([b4_variant_includes])[
]b4_attribute_define[
]b4_null_define[
// 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_defines_if([],
[b4_bison_locations_if([b4_position_define
b4_location_define])])[
]b4_bison_locations_if([m4_ifndef([b4_location_file],
[b4_location_define])])[
/// A Bison parser.
class ]b4_parser_class_name[
class ]b4_parser_class[
{
public:
]b4_public_types_declare[
/// Build a parser object.
]b4_parser_class_name[ (]b4_parse_param_decl[);
virtual ~]b4_parser_class_name[ ();
]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.
@@ -279,8 +303,8 @@ b4_location_define])])[
debug_level_type debug_level () const;
/// Set the current debugging level.
void set_debug_level (debug_level_type l);
#endif
public:
/// Report a syntax error.]b4_locations_if([[
/// \param loc where the syntax error is found.]])[
/// \param msg a description of the syntax error.
@@ -315,10 +339,10 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
[b4_token_defines])
[
#ifndef ]b4_api_PREFIX[STYPE
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class_name[::semantic_type
# define ]b4_api_PREFIX[STYPE ]b4_namespace_ref[::]b4_parser_class[::semantic_type
#endif
#ifndef ]b4_api_PREFIX[LTYPE
# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class_name[::location_type
# define ]b4_api_PREFIX[LTYPE ]b4_namespace_ref[::]b4_parser_class[::location_type
#endif
]b4_namespace_close[
@@ -329,17 +353,17 @@ b4_percent_define_flag_if([[global_tokens_and_yystype]],
b4_defines_if(
[b4_output_begin([b4_spec_defines_file])
b4_copyright([Skeleton interface for Bison GLR parsers in C++],
[2002-2015, 2018])[
[2002-2015, 2018-2019])[
// C++ GLR parser skeleton written by Akim Demaille.
]b4_disclaimer[
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations[
]b4_cpp_guard_close([b4_spec_defines_file])[
]b4_output_end()])
]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_pkgdatadir/[glr.c])
m4_include(b4_skeletonsdir/[glr.c])
m4_popdef([b4_parse_param])

View File

@@ -2,7 +2,8 @@
# Java skeleton dispatching for Bison.
# Copyright (C) 2007, 2009-2015, 2018 Free Software Foundation, Inc.
# Copyright (C) 2007, 2009-2015, 2018-2019 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
@@ -20,7 +21,7 @@
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_pkgdatadir/[lalr1.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)

View File

@@ -2,7 +2,7 @@
# Java language support for Bison
# Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
# Copyright (C) 2007-2015, 2018-2019 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
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_include(b4_pkgdatadir/[c-like.m4])
m4_include(b4_skeletonsdir/[c-like.m4])
# b4_list2(LIST1, LIST2)
@@ -42,32 +42,24 @@ m4_define([b4_percent_define_get3],
m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
# b4_public_if(TRUE, FALSE)
# -------------------------
b4_percent_define_default([[public]], [[false]])
m4_define([b4_public_if],
[b4_percent_define_flag_if([public], [$1], [$2])])
# b4_abstract_if(TRUE, FALSE)
# b4_parser_class_declaration
# ---------------------------
b4_percent_define_default([[abstract]], [[false]])
m4_define([b4_abstract_if],
[b4_percent_define_flag_if([abstract], [$1], [$2])])
# 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]])
# b4_final_if(TRUE, FALSE)
# ---------------------------
b4_percent_define_default([[final]], [[false]])
m4_define([b4_final_if],
[b4_percent_define_flag_if([final], [$1], [$2])])
# b4_strictfp_if(TRUE, FALSE)
# ---------------------------
b4_percent_define_default([[strictfp]], [[false]])
m4_define([b4_strictfp_if],
[b4_percent_define_flag_if([strictfp], [$1], [$2])])
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)
@@ -180,7 +172,7 @@ b4_percent_define_check_kind([[extends]], [code], [deprecated])
b4_percent_define_check_kind([[implements]], [code], [deprecated])
b4_percent_define_check_kind([[init_throws]], [code], [deprecated])
b4_percent_define_check_kind([[lex_throws]], [code], [deprecated])
b4_percent_define_check_kind([[parser_class_name]], [code], [deprecated])
b4_percent_define_check_kind([[api.parser.class]], [code], [deprecated])
b4_percent_define_check_kind([[throws]], [code], [deprecated])
@@ -195,8 +187,8 @@ b4_percent_define_default([[api.value.type]], [[Object]])
# %name-prefix
m4_define_default([b4_prefix], [[YY]])
b4_percent_define_default([[parser_class_name]], [b4_prefix[]Parser])
m4_define([b4_parser_class_name], [b4_percent_define_get([[parser_class_name]])])
b4_percent_define_default([[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]])])
@@ -219,21 +211,40 @@ m4_define([b4_position_type], [b4_percent_define_get([[api.position.type]])])
## ----------------- ##
# b4_lhs_value([TYPE])
# --------------------
# Expansion of $<TYPE>$.
# 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_value(RULE-LENGTH, NUM, [TYPE])
# --------------------------------------
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS.
# 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],
[(m4_ifval($3, [($3)])[](yystack.valueAt ($1-($2))))])
[b4_symbol_value([b4_rhs_data([$1], [$2])], [$3], [$4])])
# b4_lhs_location()
# -----------------
@@ -242,12 +253,12 @@ m4_define([b4_lhs_location],
[(yyloc)])
# b4_rhs_location(RULE-LENGTH, NUM)
# b4_rhs_location(RULE-LENGTH, POS)
# ---------------------------------
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
# on RHS.
m4_define([b4_rhs_location],
[yystack.locationAt ($1-($2))])
[yystack.locationAt (b4_subtract($@))])
# b4_lex_param

View File

@@ -1,6 +1,6 @@
# C++ skeleton for Bison
# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
# Copyright (C) 2002-2015, 2018-2019 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
@@ -15,11 +15,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_include(b4_pkgdatadir/[c++.m4])
m4_include(b4_skeletonsdir/[c++.m4])
# api.value.type=variant is valid.
m4_define([b4_value_type_setup_variant])
# b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
# --------------------------------------------------------------
# Declare "parser::yy<TABLE-NAME>_" whose contents is CONTENT.
@@ -34,65 +35,68 @@ m4_define([b4_integral_parser_table_declare],
# Define "parser::yy<TABLE-NAME>_" whose contents is CONTENT.
m4_define([b4_integral_parser_table_define],
[ const b4_int_type_for([$2])
b4_parser_class_name::yy$1_[[]] =
b4_parser_class::yy$1_[[]] =
{
$2
};dnl
])
# b4_symbol_value_template(VAL, [TYPE])
# -------------------------------------
# b4_symbol_value_template(VAL, SYMBOL-NUM, [TYPE])
# -------------------------------------------------
# Same as b4_symbol_value, but used in a template method. It makes
# a difference when using variants. Note that b4_value_type_setup_union
# overrides b4_symbol_value, so we must override it again.
m4_copy([b4_symbol_value], [b4_symbol_value_template])
m4_append([b4_value_type_setup_union],
[m4_copy_force([b4_symbol_value_union], [b4_symbol_value_template])])
[m4_copy_force([b4_symbol_value_union], [b4_symbol_value_template])])
# b4_lhs_value([TYPE])
# --------------------
# Expansion of $<TYPE>$.
# b4_lhs_value(SYMBOL-NUM, [TYPE])
# --------------------------------
# See README.
m4_define([b4_lhs_value],
[b4_symbol_value([yylhs.value], [$1])])
[b4_symbol_value([yylhs.value], [$1], [$2])])
# b4_lhs_location()
# -----------------
# Expansion of @$.
m4_define([b4_lhs_location],
[yylhs.location])
[yylhs.location])
# b4_rhs_data(RULE-LENGTH, NUM)
# b4_rhs_data(RULE-LENGTH, POS)
# -----------------------------
# Return the data corresponding to the symbol #NUM, where the current
# rule has RULE-LENGTH symbols on RHS.
# See README.
m4_define([b4_rhs_data],
[yystack_@{b4_subtract($@)@}])
[yystack_@{b4_subtract($@)@}])
# b4_rhs_state(RULE-LENGTH, NUM)
# b4_rhs_state(RULE-LENGTH, POS)
# ------------------------------
# The state corresponding to the symbol #NUM, where the current
# The state corresponding to the symbol #POS, where the current
# rule has RULE-LENGTH symbols on RHS.
m4_define([b4_rhs_state],
[b4_rhs_data([$1], [$2]).state])
[b4_rhs_data([$1], [$2]).state])
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
# --------------------------------------
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS.
# b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
# --------------------------------------------------
# See README.
m4_define([_b4_rhs_value],
[b4_symbol_value([b4_rhs_data([$1], [$2]).value], [$3], [$4])])
m4_define([b4_rhs_value],
[b4_symbol_value([b4_rhs_data([$1], [$2]).value], [$3])])
[b4_percent_define_ifdef([api.value.automove],
[YY_MOVE (_b4_rhs_value($@))],
[_b4_rhs_value($@)])])
# b4_rhs_location(RULE-LENGTH, NUM)
# b4_rhs_location(RULE-LENGTH, POS)
# ---------------------------------
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
# on RHS.
m4_define([b4_rhs_location],
[b4_rhs_data([$1], [$2]).location])
[b4_rhs_data([$1], [$2]).location])
# b4_symbol_action(SYMBOL-NUM, KIND)
@@ -103,11 +107,11 @@ m4_define([b4_symbol_action],
[b4_symbol_if([$1], [has_$2],
[m4_pushdef([b4_symbol_value], m4_defn([b4_symbol_value_template]))[]dnl
b4_dollar_pushdef([yysym.value],
b4_symbol_if([$1], [has_type],
[m4_dquote(b4_symbol([$1], [type]))]),
[yysym.location])dnl
b4_symbol_case_([$1])
b4_syncline([b4_symbol([$1], [$2_line])], ["b4_symbol([$1], [$2_file])"])
[$1],
[],
[yysym.location])dnl
_b4_symbol_case([$1])[]dnl
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
b4_symbol([$1], [$2])
b4_syncline([@oline@], [@ofile@])
break;
@@ -131,21 +135,22 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))])])
m4_pushdef([b4_copyright_years],
[2002-2015, 2018])
[2002-2015, 2018-2019])
m4_define([b4_parser_class_name],
[b4_percent_define_get([[parser_class_name]])])
m4_define([b4_parser_class],
[b4_percent_define_get([[api.parser.class]])])
b4_bison_locations_if([# Backward compatibility.
m4_define([b4_location_constructors])
m4_include(b4_pkgdatadir/[location.cc])])
m4_include(b4_pkgdatadir/[stack.hh])
b4_variant_if([m4_include(b4_pkgdatadir/[variant.hh])])
m4_include(b4_skeletonsdir/[location.cc])])
m4_include(b4_skeletonsdir/[stack.hh])
b4_variant_if([m4_include(b4_skeletonsdir/[variant.hh])])
# b4_shared_declarations(hh|cc)
# -----------------------------
# Declaration that might either go into the header (if --defines, $1 = hh)
# or open coded in the parser body.
# or in the implementation file.
m4_define([b4_shared_declarations],
[b4_percent_code_get([[requires]])[
]b4_parse_assert_if([# include <cassert>])[
@@ -153,31 +158,36 @@ m4_define([b4_shared_declarations],
# include <iostream>
# include <stdexcept>
# include <string>
# include <vector>]b4_defines_if([[
# include "stack.hh"
]b4_bison_locations_if([[# include "location.hh"]])])[
# include <vector>
]b4_cxx_portability[
]m4_ifdef([b4_location_include],
[[# include ]b4_location_include])[
]b4_variant_if([b4_variant_includes])[
]b4_attribute_define[
]b4_null_define[
]b4_YYDEBUG_define[
]b4_namespace_open[
]b4_defines_if([],
[b4_stack_define
b4_bison_locations_if([b4_position_define
b4_location_define])])[
]b4_variant_if([b4_variant_define])[
]b4_bison_locations_if([m4_ifndef([b4_location_file],
[b4_location_define])])[
/// A Bison parser.
class ]b4_parser_class_name[
class ]b4_parser_class[
{
public:
]b4_public_types_declare[
]b4_symbol_type_define[
/// Build a parser object.
]b4_parser_class_name[ (]b4_parse_param_decl[);
virtual ~]b4_parser_class_name[ ();
]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.
@@ -205,10 +215,12 @@ b4_location_define])])[
/// Report a syntax error.
void error (const syntax_error& err);
]b4_token_constructor_define[
private:
/// This class is not copyable.
]b4_parser_class_name[ (const ]b4_parser_class_name[&);
]b4_parser_class_name[& operator= (const ]b4_parser_class_name[&);
]b4_parser_class[ (const ]b4_parser_class[&);
]b4_parser_class[& operator= (const ]b4_parser_class[&);
/// State numbers.
typedef int state_type;
@@ -255,8 +267,9 @@ b4_location_define])])[
/// Print the state stack on the debug stream.
virtual void yystack_print_ ();
// Debugging.
/// Debugging level.
int yydebug_;
/// Debug stream.
std::ostream* yycdebug_;
/// \brief Display a symbol type, value and location.
@@ -278,26 +291,26 @@ b4_location_define])])[
struct by_state
{
/// Default constructor.
by_state ();
by_state () YY_NOEXCEPT;
/// The symbol type as needed by the constructor.
typedef state_type kind_type;
/// Constructor.
by_state (kind_type s);
by_state (kind_type s) YY_NOEXCEPT;
/// Copy constructor.
by_state (const by_state& other);
by_state (const by_state& that) YY_NOEXCEPT;
/// Record that this symbol is empty.
void clear ();
void clear () YY_NOEXCEPT;
/// Steal the symbol type from \a that.
void move (by_state& that);
/// The (internal) type number (corresponding to \a state).
/// \a empty_symbol when empty.
symbol_number_type type_get () const;
symbol_number_type type_get () const YY_NOEXCEPT;
/// The state number used to denote an empty symbol.
enum { empty_state = -1 };
@@ -314,14 +327,19 @@ b4_location_define])])[
typedef basic_symbol<by_state> super_type;
/// Construct an empty symbol.
stack_symbol_type ();
/// Copy construct.
stack_symbol_type (const stack_symbol_type& that);
/// Move or copy construction.
stack_symbol_type (YY_RVREF (stack_symbol_type) that);
/// Steal the contents from \a sym to build this.
stack_symbol_type (state_type s, symbol_type& sym);
/// Assignment, needed by push_back.
stack_symbol_type& operator= (const stack_symbol_type& that);
stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym);
#if YY_CPLUSPLUS < 201103L
/// Assignment, needed by push_back by some old implementations.
/// Moves the contents of that.
stack_symbol_type& operator= (stack_symbol_type& that);
#endif
};
]b4_stack_define[
/// Stack type.
typedef stack<stack_symbol_type> stack_type;
@@ -331,20 +349,20 @@ b4_location_define])])[
/// Push a new state on the stack.
/// \param m a debug message to display
/// if null, no trace is output.
/// \param s the symbol
/// \param sym the symbol
/// \warning the contents of \a s.value is stolen.
void yypush_ (const char* m, stack_symbol_type& s);
void yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym);
/// Push a new look ahead token on the state on the stack.
/// \param m a debug message to display
/// if null, no trace is output.
/// \param s the state
/// \param sym the symbol (for its value and location).
/// \warning the contents of \a s.value is stolen.
void yypush_ (const char* m, state_type s, symbol_type& sym);
/// \warning the contents of \a sym.value is stolen.
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
/// Pop \a n symbols the three stacks.
void yypop_ (unsigned n = 1);
/// Pop \a n symbols from the stack.
void yypop_ (int n = 1);
/// Constants.
enum
@@ -370,12 +388,16 @@ b4_location_define])])[
#ifndef ]b4_api_PREFIX[STYPE
// Redirection for backward compatibility.
# define ]b4_api_PREFIX[STYPE b4_namespace_ref::b4_parser_class_name::semantic_type
# define ]b4_api_PREFIX[STYPE b4_namespace_ref::b4_parser_class::semantic_type
#endif
])[
]b4_percent_code_get([[provides]])[
]])
## -------------- ##
## Output files. ##
## -------------- ##
b4_defines_if(
[b4_output_begin([b4_spec_defines_file])
b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
@@ -387,30 +409,28 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
// C++ LALR(1) parser skeleton written by Akim Demaille.
]b4_disclaimer[
]b4_cpp_guard_open([b4_spec_defines_file])[
]b4_shared_declarations(hh)[
]b4_cpp_guard_close([b4_spec_defines_file])
b4_output_end()
b4_output_end
])
b4_output_begin([b4_parser_file_name])
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])
b4_percent_code_get([[top]])[]dnl
b4_output_begin([b4_parser_file_name])[
]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])[
]b4_disclaimer[
]b4_percent_code_get([[top]])[]dnl
m4_if(b4_prefix, [yy], [],
[
// Take the name prefix into account.
#define yylex b4_prefix[]lex])[
[#]define yylex b4_prefix[]lex])[
// First part of user declarations.
]b4_user_pre_prologue[
]b4_null_define[
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
[b4_shared_declarations([cc])])[
// User implementation prologue.
]b4_user_post_prologue[
]b4_percent_code_get[
@@ -426,6 +446,15 @@ m4_if(b4_prefix, [yy], [],
# endif
#endif
// 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_locations_if([dnl
[#define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
]b4_yylloc_default_define])[
@@ -486,11 +515,11 @@ m4_if(b4_prefix, [yy], [],
apostrophe, a comma, or backslash (other than backslash-backslash).
YYSTR is taken from yytname. */
std::string
]b4_parser_class_name[::yytnamerr_ (const char *yystr)
]b4_parser_class[::yytnamerr_ (const char *yystr)
{
if (*yystr == '"')
{
std::string yyr = "";
std::string yyr;
char const *yyp = yystr;
for (;;)
@@ -503,7 +532,10 @@ m4_if(b4_prefix, [yy], [],
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
// Fall through.
else
goto append;
append:
default:
yyr += *yyp;
break;
@@ -519,7 +551,7 @@ m4_if(b4_prefix, [yy], [],
]])[
/// Build a parser object.
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
]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], [ ], [ :])[yydebug_ (false),
@@ -527,9 +559,11 @@ m4_if(b4_prefix, [yy], [],
#endif]b4_parse_param_cons[
{}
]b4_parser_class_name::~b4_parser_class_name[ ()
]b4_parser_class::~b4_parser_class[ ()
{}
]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
{}
/*---------------.
| Symbol types. |
@@ -538,33 +572,33 @@ m4_if(b4_prefix, [yy], [],
]b4_token_ctor_if([], [b4_public_types_define([cc])])[
// by_state.
]b4_parser_class_name[::by_state::by_state ()
]b4_parser_class[::by_state::by_state () YY_NOEXCEPT
: state (empty_state)
{}
]b4_parser_class_name[::by_state::by_state (const by_state& other)
: state (other.state)
]b4_parser_class[::by_state::by_state (const by_state& that) YY_NOEXCEPT
: state (that.state)
{}
void
]b4_parser_class_name[::by_state::clear ()
]b4_parser_class[::by_state::clear () YY_NOEXCEPT
{
state = empty_state;
}
void
]b4_parser_class_name[::by_state::move (by_state& that)
]b4_parser_class[::by_state::move (by_state& that)
{
state = that.state;
that.clear ();
}
]b4_parser_class_name[::by_state::by_state (state_type s)
]b4_parser_class[::by_state::by_state (state_type s) YY_NOEXCEPT
: state (s)
{}
]b4_parser_class_name[::symbol_number_type
]b4_parser_class_name[::by_state::type_get () const
]b4_parser_class[::symbol_number_type
]b4_parser_class[::by_state::type_get () const YY_NOEXCEPT
{
if (state == empty_state)
return empty_symbol;
@@ -572,42 +606,47 @@ m4_if(b4_prefix, [yy], [],
return yystos_[state];
}
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type ()
]b4_parser_class[::stack_symbol_type::stack_symbol_type ()
{}
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that)
: super_type (that.state]b4_locations_if([, that.location])[)
{
]b4_variant_if([b4_symbol_variant([that.type_get ()],
[value], [copy], [that.value])],
[[value = that.value;]])[
]b4_parser_class[::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that)
: super_type (YY_MOVE (that.state)]b4_variant_if([], [, YY_MOVE (that.value)])b4_locations_if([, YY_MOVE (that.location)])[)
{]b4_variant_if([
b4_symbol_variant([that.type_get ()],
[value], [YY_MOVE_OR_COPY], [YY_MOVE (that.value)])])[
#if 201103L <= YY_CPLUSPLUS
// that is emptied.
that.state = empty_state;
#endif
}
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that)
: super_type (s]b4_locations_if([, that.location])[)
{
]b4_variant_if([b4_symbol_variant([that.type_get ()],
[value], [move], [that.value])],
[[value = that.value;]])[
]b4_parser_class[::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that)
: super_type (s]b4_variant_if([], [, YY_MOVE (that.value)])[]b4_locations_if([, YY_MOVE (that.location)])[)
{]b4_variant_if([
b4_symbol_variant([that.type_get ()],
[value], [move], [YY_MOVE (that.value)])])[
// that is emptied.
that.type = empty_symbol;
}
]b4_parser_class_name[::stack_symbol_type&
]b4_parser_class_name[::stack_symbol_type::operator= (const stack_symbol_type& that)
#if YY_CPLUSPLUS < 201103L
]b4_parser_class[::stack_symbol_type&
]b4_parser_class[::stack_symbol_type::operator= (stack_symbol_type& that)
{
state = that.state;
]b4_variant_if([b4_symbol_variant([that.type_get ()],
[value], [copy], [that.value])],
[value], [move], [that.value])],
[[value = that.value;]])[]b4_locations_if([
location = that.location;])[
// that is emptied.
that.state = empty_state;
return *this;
}
#endif
template <typename Base>
void
]b4_parser_class_name[::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
]b4_parser_class[::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
{
if (yymsg)
YY_SYMBOL_PRINT (yymsg, yysym);]b4_variant_if([], [
@@ -619,16 +658,18 @@ m4_if(b4_prefix, [yy], [],
#if ]b4_api_PREFIX[DEBUG
template <typename Base>
void
]b4_parser_class_name[::yy_print_ (std::ostream& yyo,
]b4_parser_class[::yy_print_ (std::ostream& yyo,
const basic_symbol<Base>& yysym) const
{
std::ostream& yyoutput = yyo;
YYUSE (yyoutput);
symbol_number_type yytype = yysym.type_get ();
#if defined __GNUC__ && ! defined __clang__ && ! defined __ICC && __GNUC__ * 100 + __GNUC_MINOR__ <= 408
// Avoid a (spurious) G++ 4.8 warning about "array subscript is
// below array bounds".
if (yysym.empty ())
std::abort ();
#endif
yyo << (yytype < yyntokens_ ? "token" : "nterm")
<< ' ' << yytname_[yytype] << " ("]b4_locations_if([
<< yysym.location << ": "])[;
@@ -638,55 +679,59 @@ m4_if(b4_prefix, [yy], [],
#endif
void
]b4_parser_class_name[::yypush_ (const char* m, state_type s, symbol_type& sym)
{
stack_symbol_type t (s, sym);
yypush_ (m, t);
}
void
]b4_parser_class_name[::yypush_ (const char* m, stack_symbol_type& s)
]b4_parser_class[::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym)
{
if (m)
YY_SYMBOL_PRINT (m, s);
yystack_.push (s);
YY_SYMBOL_PRINT (m, sym);
yystack_.push (YY_MOVE (sym));
}
void
]b4_parser_class_name[::yypop_ (unsigned n)
]b4_parser_class[::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym)
{
#if 201103L <= YY_CPLUSPLUS
yypush_ (m, stack_symbol_type (s, std::move (sym)));
#else
stack_symbol_type ss (s, sym);
yypush_ (m, ss);
#endif
}
void
]b4_parser_class[::yypop_ (int n)
{
yystack_.pop (n);
}
#if ]b4_api_PREFIX[DEBUG
std::ostream&
]b4_parser_class_name[::debug_stream () const
]b4_parser_class[::debug_stream () const
{
return *yycdebug_;
}
void
]b4_parser_class_name[::set_debug_stream (std::ostream& o)
]b4_parser_class[::set_debug_stream (std::ostream& o)
{
yycdebug_ = &o;
}
]b4_parser_class_name[::debug_level_type
]b4_parser_class_name[::debug_level () const
]b4_parser_class[::debug_level_type
]b4_parser_class[::debug_level () const
{
return yydebug_;
}
void
]b4_parser_class_name[::set_debug_level (debug_level_type l)
]b4_parser_class[::set_debug_level (debug_level_type l)
{
yydebug_ = l;
}
#endif // ]b4_api_PREFIX[DEBUG
]b4_parser_class_name[::state_type
]b4_parser_class_name[::yy_lr_goto_state_ (state_type yystate, int yysym)
]b4_parser_class[::state_type
]b4_parser_class[::yy_lr_goto_state_ (state_type yystate, int yysym)
{
int yyr = yypgoto_[yysym - yyntokens_] + yystate;
if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
@@ -696,19 +741,25 @@ m4_if(b4_prefix, [yy], [],
}
bool
]b4_parser_class_name[::yy_pact_value_is_default_ (int yyvalue)
]b4_parser_class[::yy_pact_value_is_default_ (int yyvalue)
{
return yyvalue == yypact_ninf_;
}
bool
]b4_parser_class_name[::yy_table_value_is_error_ (int yyvalue)
]b4_parser_class[::yy_table_value_is_error_ (int yyvalue)
{
return yyvalue == yytable_ninf_;
}
int
]b4_parser_class_name[::parse ()
]b4_parser_class[::operator() ()
{
return parse ();
}
int
]b4_parser_class[::parse ()
{
// State.
int yyn;
@@ -728,15 +779,14 @@ m4_if(b4_prefix, [yy], [],
/// The return value of parse ().
int yyresult;
// FIXME: This shoud be completely indented. It is not yet to
// avoid gratuitous conflicts when merging into the master branch.
#if YY_EXCEPTIONS
try
#endif // YY_EXCEPTIONS
{
YYCDEBUG << "Starting parse\n";
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yyla.value], [], [yyla.location])dnl
// User initialization code.
b4_dollar_pushdef([yyla.value], [], [], [yyla.location])dnl
b4_user_initial_action
b4_dollar_popdef])[]dnl
@@ -745,21 +795,25 @@ b4_dollar_popdef])[]dnl
location values to have been already stored, initialize these
stacks with a primary value. */
yystack_.clear ();
yypush_ (YY_NULLPTR, 0, yyla);
yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));
// A new symbol was pushed on the stack.
/*-----------------------------------------------.
| yynewstate -- push a new symbol on the stack. |
`-----------------------------------------------*/
yynewstate:
YYCDEBUG << "Entering state " << yystack_[0].state << '\n';
// Accept?
if (yystack_[0].state == yyfinal_)
goto yyacceptlab;
YYACCEPT;
goto yybackup;
// Backup.
yybackup:
/*-----------.
| yybackup. |
`-----------*/
yybackup:
// Try to take a decision without lookahead.
yyn = yypact_[yystack_[0].state];
if (yy_pact_value_is_default_ (yyn))
@@ -769,17 +823,22 @@ b4_dollar_popdef])[]dnl
if (yyla.empty ())
{
YYCDEBUG << "Reading a token: ";
#if YY_EXCEPTIONS
try
#endif // YY_EXCEPTIONS
{]b4_token_ctor_if([[
symbol_type yylookahead (]b4_lex[);
yyla.move (yylookahead);]], [[
yyla.type = yytranslate_ (]b4_lex[);]])[
}
#if YY_EXCEPTIONS
catch (const syntax_error& yyexc)
{
YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
error (yyexc);
goto yyerrlab1;
}
#endif // YY_EXCEPTIONS
}
YY_SYMBOL_PRINT ("Next token is", yyla);
@@ -804,9 +863,10 @@ b4_dollar_popdef])[]dnl
--yyerrstatus_;
// Shift the lookahead token.
yypush_ ("Shifting", yyn, yyla);
yypush_ ("Shifting", yyn, YY_MOVE (yyla));
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
@@ -816,8 +876,9 @@ b4_dollar_popdef])[]dnl
goto yyerrlab;
goto yyreduce;
/*-----------------------------.
| yyreduce -- Do a reduction. |
| yyreduce -- do a reduction. |
`-----------------------------*/
yyreduce:
yylen = yyr2_[yyn];
@@ -827,7 +888,7 @@ b4_dollar_popdef])[]dnl
/* Variants are always initialized to an empty instance of the
correct type. The default '$$ = $1' action is NOT applied
when using variants. */
b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [build])], [
b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [emplace])], [
/* If YYLEN is nonzero, implement the default value of the
action: '$$ = $1'. Otherwise, use the top of the stack.
@@ -842,14 +903,16 @@ b4_dollar_popdef])[]dnl
[
// Default location.
{
slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
YYLLOC_DEFAULT (yylhs.location, slice, yylen);
stack_type::slice range (yystack_, yylen);
YYLLOC_DEFAULT (yylhs.location, range, yylen);
yyerror_range[1].location = yylhs.location;
}]])[
// Perform the reduction.
YY_REDUCE_PRINT (yyn);
#if YY_EXCEPTIONS
try
#endif // YY_EXCEPTIONS
{
switch (yyn)
{
@@ -858,21 +921,25 @@ b4_dollar_popdef])[]dnl
break;
}
}
#if YY_EXCEPTIONS
catch (const syntax_error& yyexc)
{
YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
error (yyexc);
YYERROR;
}
#endif // YY_EXCEPTIONS
YY_SYMBOL_PRINT ("-> $$ =", yylhs);
yypop_ (yylen);
yylen = 0;
YY_STACK_PRINT ();
// Shift the result of the reduction.
yypush_ (YY_NULLPTR, yylhs);
yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
}
goto yynewstate;
/*--------------------------------------.
| yyerrlab -- here on detecting error. |
`--------------------------------------*/
@@ -910,18 +977,18 @@ b4_dollar_popdef])[]dnl
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
/* Pacify compilers like GCC when the user code never invokes
YYERROR and the label yyerrorlab therefore never appears in user
code. */
/* Pacify compilers when the user code never invokes YYERROR and
the label yyerrorlab therefore never appears in user code. */
if (false)
goto yyerrorlab;
YYERROR;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
yypop_ (yylen);
yylen = 0;
goto yyerrlab1;
/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
@@ -958,20 +1025,30 @@ b4_dollar_popdef])[]dnl
// Shift the error token.
error_token.state = yyn;
yypush_ ("Shifting", error_token);
yypush_ ("Shifting", YY_MOVE (error_token));
}
goto yynewstate;
// Accept.
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here. |
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
goto yyreturn;
// Abort.
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
yyresult = 1;
goto yyreturn;
/*-----------------------------------------------------.
| yyreturn -- parsing is finished, return the result. |
`-----------------------------------------------------*/
yyreturn:
if (!yyla.empty ())
yy_destroy_ ("Cleanup: discarding lookahead", yyla);
@@ -987,11 +1064,12 @@ b4_dollar_popdef])[]dnl
return yyresult;
}
#if YY_EXCEPTIONS
catch (...)
{
YYCDEBUG << "Exception caught: cleaning lookahead and stack\n";
// Do not try to display the values of the reclaimed symbols,
// as their printer might throw an exception.
// as their printers might throw an exception.
if (!yyla.empty ())
yy_destroy_ (YY_NULLPTR, yyla);
@@ -1002,10 +1080,11 @@ b4_dollar_popdef])[]dnl
}
throw;
}
#endif // YY_EXCEPTIONS
}
void
]b4_parser_class_name[::error (const syntax_error& yyexc)
]b4_parser_class[::error (const syntax_error& yyexc)
{
error (]b4_join(b4_locations_if([yyexc.location]),
[[yyexc.what ()]])[);
@@ -1013,7 +1092,7 @@ b4_dollar_popdef])[]dnl
// Generate an error message.
std::string
]b4_parser_class_name[::yysyntax_error_ (]dnl
]b4_parser_class[::yysyntax_error_ (]dnl
b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
[state_type, const symbol_type&])[) const
{]b4_error_verbose_if([[
@@ -1112,9 +1191,9 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
}
const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class_name::yypact_ninf_ = b4_pact_ninf[;
const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class::yypact_ninf_ = b4_pact_ninf[;
const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class_name::yytable_ninf_ = b4_table_ninf[;
const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class::yytable_ninf_ = b4_table_ninf[;
]b4_parser_tables_define[
@@ -1122,7 +1201,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
// YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
// First, the terminals, then, starting at \a yyntokens_, nonterminals.
const char*
const ]b4_parser_class_name[::yytname_[] =
const ]b4_parser_class[::yytname_[] =
{
]b4_tname[
};
@@ -1132,7 +1211,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
// Print the state stack on the debug stream.
void
]b4_parser_class_name[::yystack_print_ ()
]b4_parser_class[::yystack_print_ ()
{
*yycdebug_ << "Stack now";
for (stack_type::const_iterator
@@ -1145,7 +1224,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
// Report on the debug stream that the rule \a yyrule is going to be reduced.
void
]b4_parser_class_name[::yy_reduce_print_ (int yyrule)
]b4_parser_class[::yy_reduce_print_ (int yyrule)
{
unsigned yylno = yyrline_[yyrule];
int yynrhs = yyr2_[yyrule];
@@ -1162,7 +1241,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
]b4_token_ctor_if([], [b4_yytranslate_define([cc])])[
]b4_namespace_close[
]b4_epilogue[]dnl
b4_output_end()
b4_output_end
m4_popdef([b4_copyright_years])dnl

View File

@@ -0,0 +1,897 @@
# Java skeleton for Bison -*- autoconf -*-
# Copyright (C) 2007-2011, 2019 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_include(b4_skeletonsdir/[d.m4])
m4_divert_push(0)dnl
@output(b4_parser_file_name@)@
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in D],
[2007-2012, 2019])
b4_percent_define_ifdef([package], [module b4_percent_define_get([package]);
])[
version(D_Version2) {
} else {
static assert(false, "need compiler for D Version 2");
}
]b4_user_pre_prologue[
]b4_user_post_prologue[
]b4_percent_code_get([[imports]])[
import std.format;
/**
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
*
* @@author LALR (1) parser skeleton written by Paolo Bonzini.
* Port to D language was done by Oliver Mangold.
*/
/**
* Communication interface between the scanner and the Bison-generated
* parser <tt>]b4_parser_class[</tt>.
*/
public interface Lexer
{
]b4_locations_if([[/**
* Method to retrieve the beginning position of the last scanned token.
* @@return the position at which the last scanned token starts. */
@@property ]b4_position_type[ startPos ();
/**
* Method to retrieve the ending position of the last scanned token.
* @@return the first position beyond the last scanned token. */
@@property ]b4_position_type[ endPos ();]])[
/**
* Method to retrieve the semantic value of the last scanned token.
* @@return the semantic value of the last scanned token. */
@@property ]b4_yystype[ semanticVal ();
/**
* Entry point for the scanner. Returns the token identifier corresponding
* to the next token and prepares to return the semantic value
* ]b4_locations_if([and beginning/ending positions ])[of the token.
* @@return the token identifier corresponding to the next token. */
YYTokenType yylex ();
/**
* Entry point for error reporting. Emits an error
* ]b4_locations_if([referring to the given location ])[in a user-defined way.
*
* ]b4_locations_if([[@@param loc The location of the element to which the
* error message is related]])[
* @@param s The string for the error message. */
void yyerror (]b4_locations_if([b4_location_type[ loc, ]])[string s);
}
private final struct YYStackElement{
int state;
]b4_yystype[ value;
]b4_locations_if(b4_location_type[[] location;])[
}
private final struct YYStack {
private YYStackElement[] stack = [];
public final @@property ulong height()
{
return stack.length;
}
public final void push (int state, ]b4_yystype[ value]dnl
b4_locations_if([, ref ]b4_location_type[ loc])[)
{
stack ~= YYStackElement(state, value]b4_locations_if([, loc])[);
}
public final void pop ()
{
pop (1);
}
public final void pop (int num)
{
stack.length -= num;
}
public final int stateAt (int i)
{
return stack[$-i-1].state;
}
]b4_locations_if([[public final ref ]b4_location_type[ locationAt (int i)
{
return stack[$-i-1].location;
}
]])[public final ref ]b4_yystype[ valueAt (int i)
{
return stack[$-i-1].value;
}
// Print the state stack on the debug stream.
public final void print (File stream)
{
stream.write ("Stack now");
for (int i = 0; i < stack.length; i++)
stream.write (" %d", stack[i].state);
stream.writeln ();
}
}
]b4_locations_if(b4_position_type_if([[[
static assert(__traits(compiles,
(new ]b4_position_type[[1])[0]=(new ]b4_position_type[[1])[0]),
"struct/class ]b4_position_type[ must be default-constructible "
"and assignable");
static assert(__traits(compiles, (new string[1])[0]=(new ]b4_position_type[).toString()),
"error: struct/class ]b4_position_type[ must have toString method");
]]], [[
/**
* A struct denoting a point in the input.*/
public struct ]b4_position_type[ {
/** The column index within the line of input. */
public int column = 1;
/** The line number within an input file. */
public int line = 1;
/** The name of the input file. */
public string filename = "(unspecified file)";
/**
* Return a string representation of the position. */
public string toString() const {
return format("%s:%d.%d", filename, line, column);
}
}
]])b4_location_type_if([[[
static assert(__traits(compiles, (new ]b4_location_type[((new ]b4_position_type[[1])[0]))) &&
__traits(compiles, (new ]b4_location_type[((new ]b4_position_type[[1])[0], (new ]b4_position_type[[1])[0]))),
"error: struct/class ]b4_location_type[ must have "
"default constructor and constructors this(]b4_position_type[) and this(]b4_position_type[, ]b4_position_type[).");
static assert(__traits(compiles, (new ]b4_location_type[[1])[0].begin=(new ]b4_location_type[[1])[0].begin) &&
__traits(compiles, (new ]b4_location_type[[1])[0].begin=(new ]b4_location_type[[1])[0].end) &&
__traits(compiles, (new ]b4_location_type[[1])[0].end=(new ]b4_location_type[[1])[0].begin) &&
__traits(compiles, (new ]b4_location_type[[1])[0].end=(new ]b4_location_type[[1])[0].end),
"error: struct/class ]b4_location_type[ must have assignment-compatible "
"members/properties 'begin' and 'end'.");
static assert(__traits(compiles, (new string[1])[0]=(new ]b4_location_type[[1])[0].toString()),
"error: struct/class ]b4_location_type[ must have toString method.");
private immutable bool yy_location_is_class = !__traits(compiles, *(new ]b4_location_type[((new ]b4_position_type[[1])[0])));]]], [[
/**
* A class defining a pair of positions. Positions, defined by the
* <code>]b4_position_type[</code> class, denote a point in the input.
* Locations represent a part of the input through the beginning
* and ending positions. */
public class ]b4_location_type[
{
/** The first, inclusive, position in the range. */
public ]b4_position_type[ begin;
/** The first position beyond the range. */
public ]b4_position_type[ end;
/**
* Create a <code>]b4_location_type[</code> denoting an empty range located at
* a given point.
* @@param loc The position at which the range is anchored. */
public this (]b4_position_type[ loc) {
this.begin = this.end = loc;
}
/**
* Create a <code>]b4_location_type[</code> from the endpoints of the range.
* @@param begin The first position included in the range.
* @@param end The first position beyond the range. */
public this (]b4_position_type[ begin, ]b4_position_type[ end)
{
this.begin = begin;
this.end = end;
}
/**
* Return a representation of the location. For this to be correct,
* <code>]b4_position_type[</code> should override the <code>toString</code>
* method. */
public const string toString () const {
if (begin==end)
return begin.toString ();
else
return begin.toString () ~ "-" ~ end.toString ();
}
}
private immutable bool yy_location_is_class = true;
]]))m4_ifdef([b4_user_union_members], [private union YYSemanticType
{
b4_user_union_members
};],
[m4_if(b4_tag_seen_flag, 0,
[[private alias int YYSemanticType;]])])[
]b4_token_enums(b4_tokens)[
]b4_parser_class_declaration[
{
]b4_identification[
/** True if verbose error messages are enabled. */
public bool errorVerbose = ]b4_flag_value([error_verbose]);
b4_locations_if([[
private final ]b4_location_type[ yylloc_from_stack (ref YYStack rhs, int n)
{
static if (yy_location_is_class) {
if (n > 0)
return new ]b4_location_type[ (rhs.locationAt (n-1).begin, rhs.locationAt (0).end);
else
return new ]b4_location_type[ (rhs.locationAt (0).end);
} else {
if (n > 0)
return ]b4_location_type[ (rhs.locationAt (n-1).begin, rhs.locationAt (0).end);
else
return ]b4_location_type[ (rhs.locationAt (0).end);
}
}]])[
]b4_lexer_if([[private class YYLexer implements Lexer {
]b4_percent_code_get([[lexer]])[
}
]])[/** The object doing lexical analysis for us. */
private Lexer yylexer;
]
b4_parse_param_vars
b4_lexer_if([[
/**
* Instantiates the Bison-generated parser.
*/
public this] (b4_parse_param_decl([b4_lex_param_decl])[) {
this.yylexer = new YYLexer(]b4_lex_param_call[);
this.yyDebugStream = stderr;
]b4_parse_param_cons[
}
]])
/**
* Instantiates the Bison-generated parser.
* @@param yylexer The scanner that will supply tokens to the parser.
*/
b4_lexer_if([[protected]], [[public]]) [this (]b4_parse_param_decl([[Lexer yylexer]])[) {
this.yylexer = yylexer;
this.yyDebugStream = stderr;
]b4_parse_param_cons[
}
private File yyDebugStream;
/**
* Return the <tt>File</tt> on which the debugging output is
* printed.
*/
public File getDebugStream () { return yyDebugStream; }
/**
* Set the <tt>std.File</tt> on which the debug output is printed.
* @@param s The stream that is used for debugging output.
*/
public final void setDebugStream(File s) { yyDebugStream = s; }
private int yydebug = 0;
/**
* Answer the verbosity of the debugging output; 0 means that all kinds of
* output from the parser are suppressed.
*/
public final int getDebugLevel() { return yydebug; }
/**
* Set the verbosity of the debugging output; 0 means that all kinds of
* output from the parser are suppressed.
* @@param level The verbosity level for debugging output.
*/
public final void setDebugLevel(int level) { yydebug = level; }
private final int yylex () {
return yylexer.yylex ();
}
protected final void yyerror (]b4_locations_if(ref [b4_location_type[ loc, ]])[string s) {
yylexer.yyerror (]b4_locations_if([loc, ])[s);
}]
[protected final void yycdebug (string s) {
if (yydebug > 0)
yyDebugStream.writeln (s);
}
/**
* Returned by a Bison action in order to stop the parsing process and
* return success (<tt>true</tt>). */
public static immutable int YYACCEPT = 0;
/**
* Returned by a Bison action in order to stop the parsing process and
* return failure (<tt>false</tt>). */
public static immutable int YYABORT = 1;
/**
* Returned by a Bison action in order to start error recovery without
* printing an error message. */
public static immutable int YYERROR = 2;
// Internal return codes that are not supported for user semantic
// actions.
private static immutable int YYERRLAB = 3;
private static immutable int YYNEWSTATE = 4;
private static immutable int YYDEFAULT = 5;
private static immutable int YYREDUCE = 6;
private static immutable int YYERRLAB1 = 7;
private static immutable int YYRETURN = 8;
]b4_locations_if([
private static immutable YYSemanticType yy_semantic_null = cast(YYSemanticType)null;])[
private int yyerrstatus_ = 0;
/**
* Return whether error recovery is being done. In this state, the parser
* reads token until it reaches a known state, and then restarts normal
* operation. */
public final bool recovering ()
{
return yyerrstatus_ == 0;
}
private int yyaction (int yyn, ref YYStack yystack, int yylen)
{
]b4_yystype[ yyval;
]b4_locations_if([b4_location_type[ yyloc = yylloc_from_stack (yystack, yylen);]])[
/* If YYLEN is nonzero, implement the default value of the action:
`$$ = $1'. Otherwise, use the top of the stack.
Otherwise, the following line sets YYVAL to garbage.
This behavior is undocumented and Bison
users should not rely upon it. */
if (yylen > 0)
yyval = yystack.valueAt (yylen - 1);
else
yyval = yystack.valueAt (0);
yy_reduce_print (yyn, yystack);
switch (yyn)
{
]b4_user_actions[
default: break;
}
yy_symbol_print ("-> $$ =", yyr1_[yyn], yyval]b4_locations_if([, yyloc])[);
yystack.pop (yylen);
yylen = 0;
/* Shift the result of the reduction. */
yyn = yyr1_[yyn];
int yystate = yypgoto_[yyn - yyntokens_] + yystack.stateAt (0);
if (0 <= yystate && yystate <= yylast_
&& yycheck_[yystate] == yystack.stateAt (0))
yystate = yytable_[yystate];
else
yystate = yydefgoto_[yyn - yyntokens_];
yystack.push (yystate, yyval]b4_locations_if([, yyloc])[);
return YYNEWSTATE;
}
/* 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 final string yytnamerr_ (string yystr)
{
if (yystr[0] == '"')
{
string yyr;
strip_quotes: for (int i = 1; i < yystr.length; i++)
switch (yystr[i])
{
case '\'':
case ',':
break strip_quotes;
case '\\':
if (yystr[++i] != '\\')
break strip_quotes;
goto default;
default:
yyr ~= yystr[i];
break;
case '"':
return yyr;
}
}
else if (yystr=="$end")
return "end of input";
return yystr;
}
/*--------------------------------.
| Print this symbol on YYOUTPUT. |
`--------------------------------*/
private final void yy_symbol_print (string s, int yytype,
ref ]b4_yystype[ yyvaluep]dnl
b4_locations_if([, ref ]b4_location_type[ yylocationp])[)
{
if (yydebug > 0) {
string message = s ~ (yytype < yyntokens_ ? " token " : " nterm ")
~ yytname_[yytype] ~ " ("]b4_locations_if([
~ yylocationp.toString() ~ ": "])[;
static if (__traits(compiles, message~=yyvaluep.toString ()))
message ~= yyvaluep.toString ();
else
message ~= format ("%s", &yyvaluep);
message ~= ")";
yycdebug (message);
}
}
/**
* Parse input from the scanner that was specified at object construction
* time. Return whether the end of the input was reached successfully.
*
* @@return <tt>true</tt> if the parsing succeeds. Note that this does not
* imply that there were no syntax errors.
*/
public bool parse ()
{
/// Lookahead and lookahead in internal form.
int yychar = yyempty_;
int yytoken = 0;
/* State. */
int yyn = 0;
int yylen = 0;
int yystate = 0;
YYStack yystack;
/* Error handling. */
int yynerrs_ = 0;
]b4_locations_if([/// The location where the error started.
]b4_location_type[ yyerrloc = null;
/// ]b4_location_type[ of the lookahead.
]b4_location_type[ yylloc;
/// @@$.
]b4_location_type[ yyloc;])[
/// Semantic value of the lookahead.
]b4_yystype[ yylval;
int yyresult;
yycdebug ("Starting parse\n");
yyerrstatus_ = 0;
]m4_ifdef([b4_initial_action], [
m4_pushdef([b4_at_dollar], [yylloc])dnl
m4_pushdef([b4_dollar_dollar], [yylval])dnl
/* User initialization code. */
b4_user_initial_action
m4_popdef([b4_dollar_dollar])dnl
m4_popdef([b4_at_dollar])])dnl
[ /* Initialize the stack. */
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
int label = YYNEWSTATE;
for (;;)
final switch (label)
{
/* New state. Unlike in the C/C++ skeletons, the state is already
pushed when we come here. */
case YYNEWSTATE:
yycdebug (format("Entering state %d\n", yystate));
if (yydebug > 0)
yystack.print (yyDebugStream);
/* Accept? */
if (yystate == yyfinal_)
return true;
/* Take a decision. First try without lookahead. */
yyn = yypact_[yystate];
if (yy_pact_value_is_default_ (yyn))
{
label = YYDEFAULT;
break;
}
/* Read a lookahead token. */
if (yychar == yyempty_)
{
yycdebug ("Reading a token: ");
yychar = yylex ();]
b4_locations_if([[
static if (yy_location_is_class) {
yylloc = new ]b4_location_type[(yylexer.startPos, yylexer.endPos);
} else {
yylloc = ]b4_location_type[(yylexer.startPos, yylexer.endPos);
}]])
yylval = yylexer.semanticVal;[
}
/* Convert token to internal form. */
if (yychar <= YYTokenType.EOF)
{
yychar = yytoken = YYTokenType.EOF;
yycdebug ("Now at end of input.\n");
}
else
{
yytoken = yytranslate_ (yychar);
yy_symbol_print ("Next token is",
yytoken, yylval]b4_locations_if([, yylloc])[);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
detect an error, take that action. */
yyn += yytoken;
if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
label = YYDEFAULT;
/* <= 0 means reduce or error. */
else if ((yyn = yytable_[yyn]) <= 0)
{
if (yy_table_value_is_error_ (yyn))
label = YYERRLAB;
else
{
yyn = -yyn;
label = YYREDUCE;
}
}
else
{
/* Shift the lookahead token. */
yy_symbol_print ("Shifting", yytoken,
yylval]b4_locations_if([, yylloc])[);
/* Discard the token being shifted. */
yychar = yyempty_;
/* Count tokens shifted since error; after three, turn off error
* status. */
if (yyerrstatus_ > 0)
--yyerrstatus_;
yystate = yyn;
yystack.push (yystate, yylval]b4_locations_if([, yylloc])[);
label = YYNEWSTATE;
}
break;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
case YYDEFAULT:
yyn = yydefact_[yystate];
if (yyn == 0)
label = YYERRLAB;
else
label = YYREDUCE;
break;
/*-----------------------------.
| yyreduce -- Do a reduction. |
`-----------------------------*/
case YYREDUCE:
yylen = yyr2_[yyn];
label = yyaction (yyn, yystack, yylen);
yystate = yystack.stateAt (0);
break;
/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
case YYERRLAB:
/* If not already recovering from an error, report this error. */
if (yyerrstatus_ == 0)
{
++yynerrs_;
if (yychar == yyempty_)
yytoken = yyempty_;
yyerror (]b4_locations_if([yylloc, ])[yysyntax_error (yystate, yytoken));
}
]b4_locations_if([yyerrloc = yylloc;])[
if (yyerrstatus_ == 3)
{
/* If just tried and failed to reuse lookahead token after an
* error, discard it. */
if (yychar <= YYTokenType.EOF)
{
/* Return failure if at end of input. */
if (yychar == YYTokenType.EOF)
return false;
}
else
yychar = yyempty_;
}
/* Else will try to reuse lookahead token after shifting the error
* token. */
label = YYERRLAB1;
break;
/*-------------------------------------------------.
| errorlab -- error raised explicitly by YYERROR. |
`-------------------------------------------------*/
case YYERROR:
]b4_locations_if([yyerrloc = yystack.locationAt (yylen - 1);])[
/* Do not reclaim the symbols of the rule which action triggered
this YYERROR. */
yystack.pop (yylen);
yylen = 0;
yystate = yystack.stateAt (0);
label = YYERRLAB1;
break;
/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
case YYERRLAB1:
yyerrstatus_ = 3; /* Each real token shifted decrements this.xb */
for (;;)
{
yyn = yypact_[yystate];
if (!yy_pact_value_is_default_ (yyn))
{
yyn += yyterror_;
if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
{
yyn = yytable_[yyn];
if (0 < yyn)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (yystack.height == 1)
return false;
]b4_locations_if([yyerrloc = yystack.locationAt (0);])[
yystack.pop ();
yystate = yystack.stateAt (0);
if (yydebug > 0)
yystack.print (yyDebugStream);
}
]b4_locations_if([
/* Muck with the stack to setup for yylloc. */
yystack.push (0, yy_semantic_null, yylloc);
yystack.push (0, yy_semantic_null, yyerrloc);
yyloc = yylloc_from_stack (yystack, 2);
yystack.pop (2);])[
/* Shift the error token. */
yy_symbol_print ("Shifting", yystos_[yyn],
yylval]b4_locations_if([, yyloc])[);
yystate = yyn;
yystack.push (yyn, yylval]b4_locations_if([, yyloc])[);
label = YYNEWSTATE;
break;
/* Accept. */
case YYACCEPT:
return true;
/* Abort. */
case YYABORT:
return false;
}
}
// Generate an error message.
private final string yysyntax_error (int yystate, int tok)
{
if (errorVerbose)
{
/* There are many possibilities here to consider:
- Assume YYFAIL is not used. It's too flawed to consider.
See
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
for details. YYERROR is fine as it does not invoke this
function.
- If this state is a consistent state with a default action,
then the only way this function was invoked is if the
default action is an error action. In that case, don't
check for expected tokens because there are none.
- The only way there can be no lookahead present (in tok) is
if this state is a consistent state with a default action.
Thus, detecting the absence of a lookahead is sufficient to
determine that there is no unexpected or expected token to
report. In that case, just report a simple "syntax error".
- Don't assume there isn't a lookahead just because this
state is a consistent state with a default action. There
might have been a previous inconsistent state, consistent
state with a non-default action, or user semantic action
that manipulated yychar. (However, yychar is currently out
of scope during semantic actions.)
- Of course, the expected token list depends on states to
have correct lookahead information, and it depends on the
parser not to perform extra reductions after fetching a
lookahead from the scanner and before detecting a syntax
error. Thus, state merging (from LALR or IELR) and default
reductions corrupt the expected token list. However, the
list is correct for canonical LR with one exception: it
will still contain any token that will not be accepted due
to an error action in a later state.
*/
if (tok != yyempty_)
{
// FIXME: This method of building the message is not compatible
// with internationalization.
string res = "syntax error, unexpected ";
res ~= yytnamerr_ (yytname_[tok]);
int yyn = yypact_[yystate];
if (!yy_pact_value_is_default_ (yyn))
{
/* Start YYX at -YYN if negative to avoid negative
indexes in YYCHECK. In other words, skip the first
-YYN actions for this state because they are default
actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = yylast_ - yyn + 1;
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
int count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
++count;
if (count < 5)
{
count = 0;
for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_
&& !yy_table_value_is_error_ (yytable_[x + yyn]))
{
res ~= count++ == 0 ? ", expecting " : " or ";
res ~= yytnamerr_ (yytname_[x]);
}
}
}
return res;
}
}
return "syntax error";
}
/**
* Whether the given <code>yypact_</code> value indicates a defaulted state.
* @@param yyvalue the value to check
*/
private static bool yy_pact_value_is_default_ (int yyvalue)
{
return yyvalue == yypact_ninf_;
}
/**
* Whether the given <code>yytable_</code> value indicates a syntax error.
* @@param yyvalue the value to check
*/
private static bool yy_table_value_is_error_ (int yyvalue)
{
return yyvalue == yytable_ninf_;
}
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
private static immutable ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[;
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If YYTABLE_NINF_, syntax error. */
private static immutable ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[;
]b4_parser_tables_define[
/* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
to YYLEX-NUM. */
private static immutable ]b4_int_type_for([b4_toknum])[[]
yytoken_number_ =
@{
]b4_toknum[
@};
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at \a yyntokens_, nonterminals. */
private static immutable string[] yytname_ =
@{
]b4_tname[
@};
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
private static immutable ]b4_int_type_for([b4_rline])[[] yyrline_ =
@{
]b4_rline[
@};
// Report on the debug stream that the rule yyrule is going to be reduced.
private final void yy_reduce_print (int yyrule, ref YYStack yystack)
{
if (yydebug == 0)
return;
int yylno = yyrline_[yyrule];
int yynrhs = yyr2_[yyrule];
/* Print the symbols being reduced, and their result. */
yycdebug (format("Reducing stack by rule %d (line %d), ",
yyrule - 1, yylno));
/* The symbols being reduced. */
for (int yyi = 0; yyi < yynrhs; yyi++)
yy_symbol_print (format(" $%d =", yyi + 1),
yystos_[yystack.stateAt(yynrhs - (yyi + 1))],
]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
b4_rhs_location(yynrhs, yyi + 1)])[);
}
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
private static immutable ]b4_int_type_for([b4_translate])[[] yytranslate_table_ =
@{
]b4_translate[
@};
private static ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
{
if (t >= 0 && t <= yyuser_token_number_max_)
return yytranslate_table_[t];
else
return yyundef_token_;
}
private static immutable int yylast_ = ]b4_last[;
private static immutable int yynnts_ = ]b4_nterms_number[;
private static immutable int yyempty_ = -2;
private static immutable int yyfinal_ = ]b4_final_state_number[;
private static immutable int yyterror_ = 1;
private static immutable int yyerrcode_ = 256;
private static immutable int yyntokens_ = ]b4_tokens_number[;
private static immutable int yyuser_token_number_max_ = ]b4_user_token_number_max[;
private static immutable int yyundef_token_ = ]b4_undef_token_number[;
]/* User implementation code. */
b4_percent_code_get[]dnl
}
b4_epilogue
m4_divert_pop(0)dnl

View File

@@ -1,6 +1,6 @@
# Java skeleton for Bison -*- autoconf -*-
# Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
# Copyright (C) 2007-2015, 2018-2019 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
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_include(b4_pkgdatadir/[java.m4])
m4_include(b4_skeletonsdir/[java.m4])
b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java],
[b4_skeleton])])
@@ -82,28 +82,20 @@ m4_define([b4_define_state],[[
]b4_yystype[ yylval = null;
]])
b4_output_begin([b4_parser_file_name])
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
[2007-2015, 2018])
b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);
])[/* First part of user declarations. */
]b4_user_pre_prologue
b4_user_post_prologue
b4_percent_code_get([[imports]])
b4_output_begin([b4_parser_file_name])[
]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
[2007-2015, 2018])[
]b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);[
]])[
]b4_user_pre_prologue[
]b4_user_post_prologue[
]b4_percent_code_get([[imports]])
[/**
* A Bison parser, automatically generated from <tt>]m4_bpatsubst(b4_file_name, [^"\(.*\)"$], [\1])[</tt>.
*
* @@author LALR (1) parser skeleton written by Paolo Bonzini.
*/
]b4_percent_define_get3([annotations], [], [ ])dnl
b4_public_if([public ])dnl
b4_abstract_if([abstract ])dnl
b4_final_if([final ])dnl
b4_strictfp_if([strictfp ])dnl
[class ]b4_parser_class_name[]dnl
b4_percent_define_get3([extends], [ extends ])dnl
b4_percent_define_get3([implements], [ implements ])[
]b4_parser_class_declaration[
{
]b4_identification[
]b4_error_verbose_if([[
@@ -188,7 +180,7 @@ b4_locations_if([[
/**
* Communication interface between the scanner and the Bison-generated
* parser <tt>]b4_parser_class_name[</tt>.
* parser <tt>]b4_parser_class[</tt>.
*/
public interface Lexer {
/** Token returned by the scanner to signal the end of its input. */
@@ -248,7 +240,7 @@ b4_lexer_if([[
/**
* Instantiates the Bison-generated parser.
*/
public ]b4_parser_class_name (b4_parse_param_decl([b4_lex_param_decl])[) ]b4_maybe_throws([b4_init_throws])[
public ]b4_parser_class (b4_parse_param_decl([b4_lex_param_decl])[) ]b4_maybe_throws([b4_init_throws])[
{
]b4_percent_code_get([[init]])[
this.yylexer = new YYLexer(]b4_lex_param_call[);
@@ -260,7 +252,7 @@ b4_lexer_if([[
* Instantiates the Bison-generated parser.
* @@param yylexer The scanner that will supply tokens to the parser.
*/
b4_lexer_if([[protected]], [[public]]) b4_parser_class_name[ (]b4_parse_param_decl([[Lexer yylexer]])[) ]b4_maybe_throws([b4_init_throws])[
b4_lexer_if([[protected]], [[public]]) b4_parser_class[ (]b4_parse_param_decl([[Lexer yylexer]])[) ]b4_maybe_throws([b4_init_throws])[
{
]b4_percent_code_get([[init]])[
this.yylexer = yylexer;
@@ -390,8 +382,7 @@ b4_lexer_if([[
}
// Print the state stack on the debug stream.
public void print (java.io.PrintStream out)
{
public void print (java.io.PrintStream out) {
out.print ("Stack now");
for (int i = 0; i <= height; i++)
@@ -585,8 +576,7 @@ b4_define_state])[
/* Initialize the stack. */
yystack.push (yystate, yylval ]b4_locations_if([, yylloc])[);
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yylval], [], [yylloc])dnl
/* User initialization code. */
b4_dollar_pushdef([yylval], [], [], [yylloc])dnl
b4_user_initial_action
b4_dollar_popdef[]dnl
])[
@@ -596,8 +586,7 @@ b4_dollar_popdef[]dnl
{
push_parse_initialize ();
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yylval], [], [yylloc])dnl
/* User initialization code. */
b4_dollar_pushdef([yylval], [], [], [yylloc])dnl
b4_user_initial_action
b4_dollar_popdef[]dnl
])[
@@ -1036,11 +1025,12 @@ b4_both_if([[
for (int yyi = 0; yyi < yynrhs; yyi++)
yy_symbol_print (" $" + (yyi + 1) + " =",
yystos_[yystack.stateAt(yynrhs - (yyi + 1))],
]b4_rhs_value(yynrhs, yyi + 1)b4_locations_if([,
]b4_rhs_data(yynrhs, yyi + 1)b4_locations_if([,
b4_rhs_location(yynrhs, yyi + 1)])[);
}
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, with out-of-bounds checking. */
]b4_integral_parser_table_define([translate_table], [b4_translate])[
private static final ]b4_int_type_for([b4_translate])[ yytranslate_ (int t)
@@ -1068,4 +1058,4 @@ b4_percent_code_get[]dnl
}
b4_epilogue[]dnl
b4_output_end()
b4_output_end

View File

@@ -1,6 +1,6 @@
# C++ skeleton for Bison
# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
# Copyright (C) 2002-2015, 2018-2019 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
@@ -16,13 +16,50 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef([b4_copyright_years],
[2002-2015, 2018])
[2002-2015, 2018-2019])
# b4_position_define
# b4_position_file
# ----------------
# Name of the file containing the position class, if we want this file.
b4_defines_if([b4_required_version_if([302], [],
[m4_define([b4_position_file], [position.hh])])])])
# 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_defines_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_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_location_define
# ------------------
# Define class position.
m4_define([b4_position_define],
[[ /// Abstract a position.
# Define the position and location classes.
m4_define([b4_location_define],
[[ /// A point in a source file.
class position
{
public:]m4_ifdef([b4_location_constructors], [[
@@ -73,12 +110,11 @@ m4_define([b4_position_define],
unsigned column;
private:
/// Compute max(min, lhs+rhs) (provided min <= lhs).
static unsigned add_ (unsigned lhs, int rhs, unsigned min)
/// Compute max (min, lhs+rhs).
static unsigned add_ (unsigned lhs, int rhs, int min)
{
return (0 < rhs || -static_cast<unsigned>(rhs) < lhs
? rhs + lhs
: min);
return static_cast<unsigned> (std::max (min,
static_cast<int> (lhs) + rhs));
}
};
@@ -134,20 +170,15 @@ m4_define([b4_position_define],
** \param pos a reference to the position to redirect
*/
template <typename YYChar>
inline std::basic_ostream<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;
}
]])
# b4_location_define
# ------------------
m4_define([b4_location_define],
[[ /// Abstract a location.
/// Two points in a source file.
class location
{
public:
@@ -271,7 +302,7 @@ m4_define([b4_location_define],
** Avoid duplicate information.
*/
template <typename YYChar>
inline std::basic_ostream<YYChar>&
std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
{
unsigned end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
@@ -289,16 +320,31 @@ m4_define([b4_location_define],
]])
b4_defines_if([
b4_output_begin([b4_dir_prefix[]position.hh])
b4_copyright([Positions for Bison parsers in C++])[
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_dir_prefix[position.hh
** Define the ]b4_namespace_ref[::position class.
** \file ]b4_location_path[
** Define the ]b4_namespace_ref[::location class.
*/
]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[
]b4_cpp_guard_open([b4_location_path])[
# include <algorithm> // std::max
# include <iostream>
@@ -306,31 +352,12 @@ b4_copyright([Positions for Bison parsers in C++])[
]b4_null_define[
]b4_namespace_open[
]b4_position_define[
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]position.hh])
b4_output_end()
b4_output_begin([b4_dir_prefix[]location.hh])
b4_copyright([Locations for Bison parsers in C++])[
/**
** \file ]b4_dir_prefix[location.hh
** Define the ]b4_namespace_ref[::location class.
*/
]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[
# include "position.hh"
]b4_namespace_open[
]b4_location_define[
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
b4_output_end()
])
]b4_cpp_guard_close([b4_location_path])[
]b4_output_end[
]])
m4_popdef([b4_copyright_years])

View File

@@ -0,0 +1,163 @@
# C++ skeleton for Bison
# Copyright (C) 2002-2015, 2018-2019 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# b4_stack_file
# -------------
# Name of the file containing the stack class, if we want this file.
b4_defines_if([b4_required_version_if([302], [],
[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::reverse_iterator iterator;
typedef typename S::const_reverse_iterator const_iterator;
typedef typename S::size_type size_type;
stack (size_type n = 200)
: seq_ (n)
{}
/// Random access.
///
/// Index 0 returns the topmost element.
T&
operator[] (size_type i)
{
return seq_[size () - 1 - i];
}
/// Random access.
///
/// Index 0 returns the topmost element.
T&
operator[] (int i)
{
return operator[] (size_type (i));
}
/// Random access.
///
/// Index 0 returns the topmost element.
const T&
operator[] (size_type i) const
{
return seq_[size () - 1 - i];
}
/// Random access.
///
/// Index 0 returns the topmost element.
const T&
operator[] (int i) const
{
return operator[] (size_type (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 (int 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.
size_type
size () const YY_NOEXCEPT
{
return seq_.size ();
}
/// Iterator on top of the stack (going downwards).
const_iterator
begin () const YY_NOEXCEPT
{
return seq_.rbegin ();
}
/// Bottom of the stack.
const_iterator
end () const YY_NOEXCEPT
{
return seq_.rend ();
}
/// Present a slice of the top of a stack.
class slice
{
public:
slice (const stack& stack, int range)
: stack_ (stack)
, range_ (range)
{}
const T&
operator[] (int i) const
{
return stack_[range_ - i];
}
private:
const stack& stack_;
int range_;
};
private:
stack (const stack&);
stack& operator= (const stack&);
/// 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[
]])

View File

@@ -0,0 +1,453 @@
# C++ skeleton for Bison
# Copyright (C) 2002-2015, 2018-2019 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
## --------- ##
## variant. ##
## --------- ##
# 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 YYASSERT
# include <cassert>
# define YYASSERT assert
#endif
]])
## -------------------------- ##
## Adjustments for variants. ##
## -------------------------- ##
# b4_value_type_declare
# ---------------------
# Define semantic_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 semantic_type
{
public:
/// Type of *this.
typedef semantic_type self_type;
/// Empty construction.
semantic_type () YY_NOEXCEPT
: yybuffer_ ()]b4_parse_assert_if([
, yytypeid_ (YY_NULLPTR)])[
{}
/// Construct and fill.
template <typename T>
semantic_type (YY_RVREF (T) t)]b4_parse_assert_if([
: yytypeid_ (&typeid (T))])[
{
YYASSERT (sizeof (T) <= size);
new (yyas_<T> ()) T (YY_MOVE (t));
}
/// Destruction, allowed only if empty.
~semantic_type () YY_NOEXCEPT
{]b4_parse_assert_if([
YYASSERT (!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([
YYASSERT (!yytypeid_);
YYASSERT (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([
YYASSERT (!yytypeid_);
YYASSERT (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([
YYASSERT (!yytypeid_);
YYASSERT (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([
YYASSERT (yytypeid_);
YYASSERT (*yytypeid_ == typeid (T));
YYASSERT (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([
YYASSERT (yytypeid_);
YYASSERT (*yytypeid_ == typeid (T));
YYASSERT (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([
YYASSERT (yytypeid_);
YYASSERT (*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:
/// Prohibit blind copies.
self_type& operator= (const self_type&);
semantic_type (const self_type&);
/// Accessor to raw memory as \a T.
template <typename T>
T*
yyas_ () YY_NOEXCEPT
{
void *yyp = yybuffer_.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 = yybuffer_.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];
} yybuffer_;]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
])])
m4_define([_b4_type_clause],
[b4_symbol_if([$1], [is_token],
[b4_symbol_if([$1], [has_id],
[tok == token::b4_symbol([$1], [id])],
[tok == b4_symbol([$1], [user_number])])])])
# _b4_token_constructor_define(SYMBOL-NUM...)
# -------------------------------------------
# Define a unique make_symbol for all the SYMBOL-NUM (they
# have the same type). Use at class-level.
m4_define([_b4_token_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_type (tok)],
b4_symbol_if([$1], [has_type], [std::move (v)]),
b4_locations_if([std::move (l)]))[)
{
YYASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
}
#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_type (tok)],
b4_symbol_if([$1], [has_type], [v]),
b4_locations_if([l]))[)
{
YYASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
}
#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_symbol for all the value types.
m4_define([b4_token_constructor_define],
[ // Implementation of make_symbol for each symbol type.
b4_symbol_foreach([_b4_token_maker_define])])

View File

@@ -1,11 +1,11 @@
-*- C -*-
# Yacc compatible skeleton for Bison
# Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software
# Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software
# Foundation, Inc.
m4_pushdef([b4_copyright_years],
[1984, 1989-1990, 2000-2015, 2018])
[1984, 1989-1990, 2000-2015, 2018-2019])
# 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
@@ -51,7 +51,7 @@ m4_define([b4_lac_flag],
[m4_if(b4_percent_define_get([[parse.lac]]),
[none], [[0]], [[1]])])
m4_include(b4_pkgdatadir/[c.m4])
m4_include(b4_skeletonsdir/[c.m4])
## ---------------- ##
## Default values. ##
@@ -118,7 +118,7 @@ m4_define([b4_int_type],
b4_ints_in($@, [0], [65535]), [1], [yytype_uint16],
b4_ints_in($@, [-32768], [32767]), [1], [yytype_int16],
m4_eval([0 <= $1]), [1], [unsigned int],
m4_eval([0 <= $1]), [1], [unsigned],
[int])])
@@ -128,19 +128,18 @@ m4_define([b4_int_type],
## ----------------- ##
# b4_lhs_value([TYPE])
# --------------------
# Expansion of $<TYPE>$.
# b4_lhs_value(SYMBOL-NUM, [TYPE])
# --------------------------------
# See README.
m4_define([b4_lhs_value],
[b4_symbol_value(yyval, [$1])])
[b4_symbol_value(yyval, [$1], [$2])])
# b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
# --------------------------------------
# Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
# symbols on RHS.
# b4_rhs_value(RULE-LENGTH, POS, [SYMBOL-NUM], [TYPE])
# ----------------------------------------------------
# See README.
m4_define([b4_rhs_value],
[b4_symbol_value([yyvsp@{b4_subtract([$2], [$1])@}], [$3])])
[b4_symbol_value([yyvsp@{b4_subtract([$2], [$1])@}], [$3], [$4])])
## ----------- ##
@@ -154,12 +153,12 @@ m4_define([b4_lhs_location],
[(yyloc)])
# b4_rhs_location(RULE-LENGTH, NUM)
# b4_rhs_location(RULE-LENGTH, POS)
# ---------------------------------
# Expansion of @NUM, where the current rule has RULE-LENGTH symbols
# Expansion of @POS, where the current rule has RULE-LENGTH symbols
# on RHS.
m4_define([b4_rhs_location],
[(yylsp@{b4_subtract([$2], [$1])@})])
[(yylsp@{b4_subtract([$2], [$1])@})])
## -------------- ##
@@ -237,11 +236,11 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
YYSIZE_T yyes_capacity;]])])
# b4_declare_yyparse_push_
# _b4_declare_yyparse_push
# ------------------------
# Declaration of yyparse (and dependencies) when using the push parser
# (including in pull mode).
m4_define([b4_declare_yyparse_push_],
m4_define([_b4_declare_yyparse_push],
[[#ifndef YYPUSH_MORE_DEFINED
# define YYPUSH_MORE_DEFINED
enum { YYPUSH_MORE = 4 };
@@ -265,18 +264,18 @@ b4_function_declare([b4_prefix[pstate_delete]], [[void]],
[[b4_prefix[pstate *ps]], [[ps]]])dnl
])
# b4_declare_yyparse_
# _b4_declare_yyparse
# -------------------
# When not the push parser.
m4_define([b4_declare_yyparse_],
m4_define([_b4_declare_yyparse],
[b4_function_declare(b4_prefix[parse], [int], b4_parse_param)])
# b4_declare_yyparse
# ------------------
m4_define([b4_declare_yyparse],
[b4_push_if([b4_declare_yyparse_push_],
[b4_declare_yyparse_])[]dnl
[b4_push_if([_b4_declare_yyparse_push],
[_b4_declare_yyparse])[]dnl
])
@@ -299,9 +298,8 @@ m4_define([b4_shared_declarations],
## Output files. ##
## -------------- ##
b4_output_begin([b4_parser_file_name])
b4_copyright([Bison implementation for Yacc-like parsers in C])[
b4_output_begin([b4_parser_file_name])[
]b4_copyright([Bison implementation for Yacc-like parsers in C])[
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
@@ -312,8 +310,9 @@ b4_copyright([Bison implementation for Yacc-like parsers in C])[
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
]b4_identification
b4_percent_code_get([[top]])[]dnl
]b4_disclaimer[
]b4_identification[
]b4_percent_code_get([[top]])[]dnl
m4_if(b4_api_prefix, [yy], [],
[[/* Substitute the type names. */
#define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
@@ -335,9 +334,7 @@ m4_if(b4_api_prefix, [yy], [],
#define yychar ]b4_prefix[char]b4_locations_if([[
#define yylloc ]b4_prefix[lloc]])]))[
/* Copy the first part of user declarations. */
]b4_user_pre_prologue[
]b4_null_define[
/* Enabling verbose error messages. */
@@ -354,9 +351,8 @@ m4_if(b4_api_prefix, [yy], [],
]])dnl
b4_shared_declarations[
/* Copy the second part of user declarations. */
]b4_user_post_prologue
b4_percent_code_get[]dnl
]b4_user_post_prologue[
]b4_percent_code_get[]dnl
[#ifdef short
# undef short
@@ -377,13 +373,13 @@ typedef signed char yytype_int8;
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short int yytype_uint16;
typedef unsigned short yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short int yytype_int16;
typedef short yytype_int16;
#endif
#ifndef YYSIZE_T
@@ -395,7 +391,7 @@ typedef short int yytype_int16;
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned int
# define YYSIZE_T unsigned
# endif
#endif
@@ -565,16 +561,16 @@ union yyalloc
/* YYNSTATES -- Number of states. */
#define YYNSTATES ]b4_states_number[
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK ]b4_undef_token_number[
#define YYMAXUTOK ]b4_user_token_number_max[
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, with out-of-bounds checking. */
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, without out-of-bounds checking. */
as returned by yylex. */
static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
{
]b4_translate[
@@ -627,23 +623,23 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY) \
{ \
yychar = (Token); \
yylval = (Value); \
YYPOPSTACK (yylen); \
yystate = *yyssp; \]b4_lac_if([[
YY_LAC_DISCARD ("YYBACKUP"); \]])[
goto yybackup; \
} \
else \
{ \
yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
YYERROR; \
} \
while (0)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY) \
{ \
yychar = (Token); \
yylval = (Value); \
YYPOPSTACK (yylen); \
yystate = *yyssp; \]b4_lac_if([[
YY_LAC_DISCARD ("YYBACKUP"); \]])[
goto yybackup; \
} \
else \
{ \
yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
YYERROR; \
} \
while (0)
/* Error token number */
#define YYTERROR 1
@@ -719,7 +715,7 @@ do { \
])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [,
b4_parse_param]))[
{
unsigned long int yylno = yyrline[yyrule];
unsigned long yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
@@ -791,7 +787,7 @@ yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd,
yytype_int16 **yytop, yytype_int16 *yytop_empty)
{
YYSIZE_T yysize_old =
*yytop == yytop_empty ? 0 : *yytop - *yybottom + 1;
(YYSIZE_T) (*yytop == yytop_empty ? 0 : *yytop - *yybottom + 1);
YYSIZE_T yysize_new = yysize_old + yyadd;
if (*yycapacity < yysize_new)
{
@@ -827,7 +823,7 @@ yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd,
*yycapacity = yyalloc;]m4_if(b4_percent_define_get([[parse.lac.memory-trace]]),
[full], [[
YYDPRINTF ((stderr, "%srealloc to %lu%s", yydebug_prefix,
(unsigned long int) yyalloc, yydebug_suffix));]])[
(unsigned long) yyalloc, yydebug_suffix));]])[
}
return 0;
}
@@ -957,7 +953,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
YYDPRINTF ((stderr, " R%d", yyrule - 1));
if (yyesp != yyes_prev)
{
YYSIZE_T yysize = yyesp - *yyes + 1;
YYSIZE_T yysize = (YYSIZE_T) (yyesp - *yyes + 1);
if (yylen < yysize)
{
yyesp -= yylen;
@@ -973,15 +969,14 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
yyesp = yyes_prev -= yylen;
}
{
int yystate;
yytype_int16 yystate;
{
int yylhs = yyr1[yyrule] - YYNTOKENS;
yystate = yypgoto[yylhs] + *yyesp;
if (yystate < 0 || YYLAST < yystate
|| yycheck[yystate] != *yyesp)
yystate = yydefgoto[yylhs];
else
yystate = yytable[yystate];
const int yylhs = yyr1[yyrule] - YYNTOKENS;
const int yyi = yypgoto[yylhs] + *yyesp;
yystate = ((yytype_int16)
(0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyesp
? yytable[yyi]
: yydefgoto[yylhs]));
}
if (yyesp == yyes_prev)
{
@@ -1001,7 +996,7 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes,
}
*++yyesp = yystate;
}
YYDPRINTF ((stderr, " G%d", yystate));
YYDPRINTF ((stderr, " G%d", (int) yystate));
}
}
}]])[
@@ -1071,7 +1066,10 @@ yytnamerr (char *yyres, const char *yystr)
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
/* Fall through. */
else
goto append;
append:
default:
if (yyres)
yyres[yyn] = *yyp;
@@ -1089,7 +1087,7 @@ yytnamerr (char *yyres, const char *yystr)
if (! yyres)
return yystrlen (yystr);
return yystpcpy (yyres, yystr) - yyres;
return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
}
# endif
@@ -1188,10 +1186,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yyarg[yycount++] = yytname[yyx];
{
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
if (! (yysize <= yysize1
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
yysize = yysize1;
else
return 2;
yysize = yysize1;
}
}
}]b4_lac_if([[
@@ -1219,9 +1217,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
{
YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
yysize = yysize1;
else
return 2;
yysize = yysize1;
}
if (*yymsg_alloc < yysize)
@@ -1279,13 +1278,10 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
]b4_function_define([[yypull_parse]], [[int]],
[[[yypstate *yyps]], [[yyps]]]m4_ifset([b4_parse_param], [,
b4_parse_param]))[
{
int yystatus;
yypstate *yyps_local;]b4_pure_if([[
int yychar;
YYSTYPE yylval;]b4_locations_if([[
{]b4_pure_if([b4_locations_if([[
static YYLTYPE yyloc_default][]b4_yyloc_default[;
YYLTYPE yylloc = yyloc_default;]])])[
yypstate *yyps_local;
if (yyps)
yyps_local = yyps;
else
@@ -1299,8 +1295,10 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
return 2;
}
}
do {
yychar = ]b4_lex[;
int yystatus;
do {]b4_pure_if([[
YYSTYPE yylval;
int ]])[yychar = ]b4_lex[;
yystatus =
yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])[);
} while (yystatus == YYPUSH_MORE);
@@ -1326,16 +1324,19 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
]b4_function_define([[yypstate_delete]], [[void]],
[[[yypstate *yyps]], [[yyps]]])[
{
if (yyps)
{
#ifndef yyoverflow
/* If the stack was reallocated but the parse did not complete, then the
stack still needs to be freed. */
if (!yyps->yynew && yyps->yyss != yyps->yyssa)
YYSTACK_FREE (yyps->yyss);
/* If the stack was reallocated but the parse did not complete, then the
stack still needs to be freed. */
if (!yyps->yynew && yyps->yyss != yyps->yyssa)
YYSTACK_FREE (yyps->yyss);
#endif]b4_lac_if([[
if (!yyps->yynew && yyps->yyes != yyps->yyesa)
YYSTACK_FREE (yyps->yyes);]])[
free (yyps);]b4_pure_if([], [[
yypstate_allocated = 0;]])[
if (!yyps->yynew && yyps->yyes != yyps->yyesa)
YYSTACK_FREE (yyps->yyes);]])[
free (yyps);]b4_pure_if([], [[
yypstate_allocated = 0;]])[
}
}
]b4_pure_if([[
#define ]b4_prefix[nerrs yyps->]b4_prefix[nerrs]])[
@@ -1428,9 +1429,8 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [],
b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [], [],
[b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])])dnl
/* User initialization code. */
b4_user_initial_action
b4_dollar_popdef[]dnl
m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval;
@@ -1439,23 +1439,31 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo
]])dnl
[ goto yysetstate;
/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. |
| yynewstate -- push a new state, which is found in yystate. |
`------------------------------------------------------------*/
yynewstate:
yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
yysetstate:
*yyssp = yystate;
/*--------------------------------------------------------------------.
| yynewstate -- set current state (the top of the stack) to yystate. |
`--------------------------------------------------------------------*/
yysetstate:
*yyssp = (yytype_int16) yystate;
if (yyss + yystacksize - 1 <= yyssp)
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
goto yyexhaustedlab;
#else
{
/* Get the current used size of the three stacks, in elements. */
YYSIZE_T yysize = yyssp - yyss + 1;
YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
#ifdef yyoverflow
# if defined yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
@@ -1473,15 +1481,11 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo
&yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([
&yyls1, yysize * sizeof (*yylsp),])[
&yystacksize);
]b4_locations_if([
yyls = yyls1;])[
yyss = yyss1;
yyvs = yyvs1;
yyvs = yyvs1;]b4_locations_if([
yyls = yyls1;])[
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
goto yyexhaustedlab;
# else
# else /* defined YYSTACK_RELOCATE */
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
@@ -1498,23 +1502,23 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
YYSTACK_RELOCATE (yyls_alloc, yyls);])[
# undef YYSTACK_RELOCATE
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;]b4_locations_if([
yylsp = yyls + yysize - 1;])[
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
(unsigned long) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
@@ -1523,11 +1527,11 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo
goto yybackup;
/*-----------.
| yybackup. |
`-----------*/
yybackup:
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
@@ -1625,7 +1629,7 @@ yydefault:
/*-----------------------------.
| yyreduce -- Do a reduction. |
| yyreduce -- do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
@@ -1650,7 +1654,7 @@ yyreduce:
int yychar_backup = yychar;
switch (yyn)
{
]b4_user_actions[
]b4_user_actions[
default: break;
}
if (yychar_backup != yychar)
@@ -1684,14 +1688,13 @@ yyreduce:
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTOKENS];
{
const int yylhs = yyr1[yyn] - YYNTOKENS;
const int yyi = yypgoto[yylhs] + *yyssp;
yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
? yytable[yyi]
: yydefgoto[yylhs]);
}
goto yynewstate;
@@ -1777,12 +1780,10 @@ yyerrlab:
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
/* Pacify compilers like GCC when the user code never invokes
YYERROR and the label yyerrorlab therefore never appears in user
code. */
if (/*CONSTCOND*/ 0)
goto yyerrorlab;
/* Pacify compilers when the user code never invokes YYERROR and the
label yyerrorlab therefore never appears in user code. */
if (0)
YYERROR;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
@@ -1853,6 +1854,7 @@ yyacceptlab:
yyresult = 0;
goto yyreturn;
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
@@ -1860,6 +1862,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
#if ]b4_lac_if([[1]], [[!defined yyoverflow || YYERROR_VERBOSE]])[
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
@@ -1870,6 +1873,10 @@ yyexhaustedlab:
/* Fall through. */
#endif
/*-----------------------------------------------------.
| yyreturn -- parsing is finished, return the result. |
`-----------------------------------------------------*/
yyreturn:
if (yychar != YYEMPTY)
{
@@ -1897,6 +1904,10 @@ yyreturn:
YYSTACK_FREE (yyes);]])b4_push_if([[
yyps->yynew = 1;
/*-----------------------------------------.
| yypushreturn -- ask for the next token. |
`-----------------------------------------*/
yypushreturn:]])[
#if YYERROR_VERBOSE
if (yymsg != yymsgbuf)
@@ -1905,12 +1916,12 @@ yypushreturn:]])[
return yyresult;
}
]b4_epilogue[]dnl
b4_output_end()
b4_output_end
b4_defines_if(
[b4_output_begin([b4_spec_defines_file])[
b4_defines_if([[
]b4_output_begin([b4_spec_defines_file])[
]b4_copyright([Bison interface for Yacc-like parsers in C])[
]b4_disclaimer[
]b4_shared_declarations[
]b4_output_end()
])# b4_defines_if
]b4_output_end[
]])# b4_defines_if

View File

@@ -1,152 +0,0 @@
# C++ skeleton for Bison
# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
m4_pushdef([b4_copyright_years],
[2002-2015, 2018])
# b4_stack_define
# ---------------
m4_define([b4_stack_define],
[[ /// A stack with random access from its top.
template <class T, class S = std::vector<T> >
class stack
{
public:
// Hide our reversed order.
typedef typename S::reverse_iterator iterator;
typedef typename S::const_reverse_iterator const_iterator;
stack ()
: seq_ ()
{
seq_.reserve (200);
}
stack (unsigned n)
: seq_ (n)
{}
/// Random access.
///
/// Index 0 returns the topmost element.
T&
operator[] (unsigned i)
{
return seq_[seq_.size () - 1 - i];
}
/// Random access.
///
/// Index 0 returns the topmost element.
const T&
operator[] (unsigned i) const
{
return seq_[seq_.size () - 1 - i];
}
/// Steal the contents of \a t.
///
/// Close to move-semantics.
void
push (T& t)
{
seq_.push_back (T());
operator[](0).move (t);
}
void
pop (unsigned n = 1)
{
for (; n; --n)
seq_.pop_back ();
}
void
clear ()
{
seq_.clear ();
}
typename S::size_type
size () const
{
return seq_.size ();
}
const_iterator
begin () const
{
return seq_.rbegin ();
}
const_iterator
end () const
{
return seq_.rend ();
}
private:
stack (const stack&);
stack& operator= (const stack&);
/// The wrapped container.
S seq_;
};
/// Present a slice of the top of a stack.
template <class T, class S = stack<T> >
class slice
{
public:
slice (const S& stack, unsigned range)
: stack_ (stack)
, range_ (range)
{}
const T&
operator [] (unsigned i) const
{
return stack_[range_ - i];
}
private:
const S& stack_;
unsigned range_;
};
]])
b4_defines_if(
[b4_output_begin([b4_dir_prefix[]stack.hh])
b4_copyright([Stack handling for Bison parsers in C++])[
/**
** \file ]b4_dir_prefix[stack.hh
** Define the ]b4_namespace_ref[::stack class.
*/
]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[
# include <vector>
]b4_namespace_open[
]b4_stack_define[
]b4_namespace_close[
]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
b4_output_end()
])
m4_popdef([b4_copyright_years])

View File

@@ -1,360 +0,0 @@
# C++ skeleton for Bison
# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
## --------- ##
## variant. ##
## --------- ##
# 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 YYASSERT
# include <cassert>
# define YYASSERT assert
#endif
]])
# b4_variant_define
# -----------------
# Define "variant".
m4_define([b4_variant_define],
[[ /// A char[S] 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 state.
template <size_t S>
struct variant
{
/// Type of *this.
typedef variant<S> self_type;
/// Empty construction.
variant ()]b4_parse_assert_if([
: yytypeid_ (YY_NULLPTR)])[
{}
/// Construct and fill.
template <typename T>
variant (const T& t)]b4_parse_assert_if([
: yytypeid_ (&typeid (T))])[
{
YYASSERT (sizeof (T) <= S);
new (yyas_<T> ()) T (t);
}
/// Destruction, allowed only if empty.
~variant ()
{]b4_parse_assert_if([
YYASSERT (!yytypeid_);
])[}
/// Instantiate an empty \a T in here.
template <typename T>
T&
build ()
{]b4_parse_assert_if([
YYASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= S);
yytypeid_ = & typeid (T);])[
return *new (yyas_<T> ()) T;
}
/// Instantiate a \a T in here from \a t.
template <typename T>
T&
build (const T& t)
{]b4_parse_assert_if([
YYASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= S);
yytypeid_ = & typeid (T);])[
return *new (yyas_<T> ()) T (t);
}
/// Accessor to a built \a T.
template <typename T>
T&
as ()
{]b4_parse_assert_if([
YYASSERT (*yytypeid_ == typeid (T));
YYASSERT (sizeof (T) <= S);])[
return *yyas_<T> ();
}
/// Const accessor to a built \a T (for %printer).
template <typename T>
const T&
as () const
{]b4_parse_assert_if([
YYASSERT (*yytypeid_ == typeid (T));
YYASSERT (sizeof (T) <= S);])[
return *yyas_<T> ();
}
/// Swap the content with \a other, 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 responsability.
/// Swapping between built and (possibly) non-built is done with
/// variant::move ().
template <typename T>
void
swap (self_type& other)
{]b4_parse_assert_if([
YYASSERT (yytypeid_);
YYASSERT (*yytypeid_ == *other.yytypeid_);])[
std::swap (as<T> (), other.as<T> ());
}
/// Move the content of \a other to this.
///
/// Destroys \a other.
template <typename T>
void
move (self_type& other)
{
build<T> ();
swap<T> (other);
other.destroy<T> ();
}
/// Copy the content of \a other to this.
template <typename T>
void
copy (const self_type& other)
{
build<T> (other.as<T> ());
}
/// Destroy the stored \a T.
template <typename T>
void
destroy ()
{
as<T> ().~T ();]b4_parse_assert_if([
yytypeid_ = YY_NULLPTR;])[
}
private:
/// Prohibit blind copies.
self_type& operator=(const self_type&);
variant (const self_type&);
/// Accessor to raw memory as \a T.
template <typename T>
T*
yyas_ ()
{
void *yyp = yybuffer_.yyraw;
return static_cast<T*> (yyp);
}
/// Const accessor to raw memory as \a T.
template <typename T>
const T*
yyas_ () const
{
const void *yyp = yybuffer_.yyraw;
return static_cast<const T*> (yyp);
}
union
{
/// Strongest alignment constraints.
long double yyalign_me;
/// A buffer large enough to store any of the semantic values.
char yyraw[S];
} yybuffer_;]b4_parse_assert_if([
/// Whether the content is built: if defined, the name of the stored type.
const std::type_info *yytypeid_;])[
};
]])
## -------------------------- ##
## Adjustments for variants. ##
## -------------------------- ##
# b4_value_type_declare
# ---------------------
# Declare semantic_type.
m4_define([b4_value_type_declare],
[[ /// An auxiliary type to compute the largest semantic type.
union union_type
{]b4_type_foreach([b4_char_sizeof])[};
/// Symbol semantic values.
typedef variant<sizeof(union_type)> semantic_type;][]dnl
])
# How the semantic value is extracted when using variants.
# b4_symbol_value(VAL, [TYPE])
# ----------------------------
m4_define([b4_symbol_value],
[m4_ifval([$2],
[$1.as< $2 > ()],
[$1])])
# b4_symbol_value_template(VAL, [TYPE])
# -------------------------------------
# Same as b4_symbol_value, but used in a template method.
m4_define([b4_symbol_value_template],
[m4_ifval([$2],
[$1.template as< $2 > ()],
[$1])])
## ------------- ##
## make_SYMBOL. ##
## ------------- ##
# b4_symbol_constructor_declare_(SYMBOL-NUMBER)
# ---------------------------------------------
# Declare the overloaded version of make_symbol for the (common) type of
# these SYMBOL-NUMBERS. Use at class-level.
m4_define([b4_symbol_constructor_declare_],
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
[ static inline
symbol_type
make_[]b4_symbol_([$1], [id]) (dnl
b4_join(b4_symbol_if([$1], [has_type],
[const b4_symbol([$1], [type])& v]),
b4_locations_if([const location_type& l])));
])])])
# b4_symbol_constructor_declare
# -----------------------------
# Declare symbol constructors for all the value types.
# Use at class-level.
m4_define([b4_symbol_constructor_declare],
[ // Symbol constructors declarations.
b4_symbol_foreach([b4_symbol_constructor_declare_])])
# b4_symbol_constructor_define_(SYMBOL-NUMBER)
# --------------------------------------------
# Define symbol constructor for this SYMBOL-NUMBER.
m4_define([b4_symbol_constructor_define_],
[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
[ b4_parser_class_name::symbol_type
b4_parser_class_name::make_[]b4_symbol_([$1], [id]) (dnl
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])));
}
])])])
# b4_basic_symbol_constructor_declare
# -----------------------------------
# Generate a constructor declaration for basic_symbol from given type.
m4_define([b4_basic_symbol_constructor_declare],
[[
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]))[);
]])
# b4_basic_symbol_constructor_define
# ----------------------------------
# Generate a constructor implementation for basic_symbol from given type.
m4_define([b4_basic_symbol_constructor_define],
[[
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::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)
, value (]b4_symbol_if([$1], [has_type], [v])[)]b4_locations_if([
, location (l)])[
{}
]])
# b4_symbol_constructor_define
# ----------------------------
# Define the overloaded versions of make_symbol for all the value types.
m4_define([b4_symbol_constructor_define],
[ // Implementation of make_symbol for each symbol type.
b4_symbol_foreach([b4_symbol_constructor_define_])])

View File

@@ -3,7 +3,7 @@
<!--
bison.xsl - common templates for Bison XSLT.
Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.

View File

@@ -3,7 +3,7 @@
<!--
xml2dot.xsl - transform Bison XML Report into DOT.
Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -83,7 +83,7 @@
<xsl:param name="staten"/>
<xsl:for-each select='reduction'>
<!-- These variables are needed because the current context can't be
refered to directly in XPath expressions. -->
referred to directly in XPath expressions. -->
<xsl:variable name="rul">
<xsl:value-of select="@rule"/>
</xsl:variable>
@@ -95,7 +95,7 @@
<xsl:if test='not(preceding-sibling::*[@rule=$rul and @enabled=$ena])'>
<xsl:variable name="rule">
<xsl:choose>
<!-- The acceptation state is refered to as 'accept' in the XML, but
<!-- 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>

View File

@@ -3,7 +3,7 @@
<!--
xml2text.xsl - transform Bison XML Report into plain text.
Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.

View File

@@ -3,7 +3,7 @@
<!--
xml2html.xsl - transform Bison XML Report into XHTML.
Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
Copyright (C) 2007-2015, 2018-2019 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -38,6 +38,7 @@
<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>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff