Compare commits

...

26 Commits

Author SHA1 Message Date
Christoph M. Becker
e28c5e9b96 Prepare 2.2.0beta5 2019-04-18 16:24:57 +02:00
Christoph M. Becker
b359404509 Fix #58: Missing msys-crypto-1.1.dll
After discussion with @weltling, this time we only fix what is
definitely known to be broken, i.e. wget relying on OpenSSL 1.1 (which
does not work yet in msys2), the OpenSSL DLLs which have been x86
binaries, and finally we remove the gcc_s DLL which was also a x86
binary.
2019-04-16 23:38:44 +02:00
Christoph M. Becker
912853c55f Revert "Fix #58: Missing msys-crypto-1.1.dll"
This reverts commit 806f743f3c.
2019-04-16 23:31:05 +02:00
Christoph M. Becker
806f743f3c Fix #58: Missing msys-crypto-1.1.dll
While we're at it, we also bring all packages up to date.

Since wget 1.20.1-1 - 1.20.3-1 has issues with SSL, we're downgrading
to the latest working version, i.e. wget 1.19.5-1.
2019-04-16 19:35:37 +02:00
Christoph M. Becker
d13ff857f0 Back to dev 2019-04-08 12:44:33 +02:00
Christoph M. Becker
217ab7b4ca Prepare 2.2.0beta4 2019-04-08 12:42:25 +02:00
Anatol Belski
f740aface6 Remove unmatching sentence 2019-04-04 16:18:54 +02:00
Anatol Belski
f160e68fbc Update readme 2019-04-04 16:17:39 +02:00
Christoph M. Becker
9e3fcfdd77 Update phpsdk_rebase_msys2.cmd for x64 2019-04-04 15:06:29 +02:00
Christoph M. Becker
51d2eaa463 Upgrade msys2 to 64-bit
We update all existing packages right away.
2019-04-04 14:38:49 +02:00
Christoph M. Becker
15cc20920a Be more strict when looking for the desired VS (#56)
* Be more strict when looking for the desired VS

On systems where VS 2017 and VS 2019 are available, the starter script
may choose VS 2019 if vc15 is requested.  The documentation on vswhere
isn't particularly clear regarding the -version parameter, but it
states that a version range is expected.  Therefore we change the
shell setup script accordingly.

* Remove break constructs

These had been introduced to cater to multiple found VS installations,
to only use the first one.  Since the ranges are supposed to find only
a single installation, and since apparently the order of multiple
findings is not guaranteed, we remove the break constructs for better
readability of the source code.
2019-04-03 16:03:42 +02:00
Christoph M. Becker
df2eb74fee Fix phpsdk_deps
Rename `PHP_SDK_VC` to `PHP_SDK_VS` according to commit 76ede8f900.
2019-04-03 01:32:20 +02:00
Christoph M. Becker
f59fd45ee5 Don't repeat yourself
`Config::getCurrentStabilityName()` already retrieves the current
stability name, so there is no need to explicitly set it.
2019-03-31 14:37:17 +02:00
Christoph M. Becker
43107058f8 Work around old-style constructors in PGO training case
class.php of the pgo01org training case still uses PHP 4 style
constructors, which trigger deprecation notices and as such may
negatively affect the optimization.  Until this will be fixed upstream,
we're employing the workaround to modify the file during the PGO
initialization step.
2019-03-31 14:36:55 +02:00
Anatol Belski
b53316585a Fix var name 2019-03-31 13:19:05 +02:00
Anatol Belski
8b957129bd Fix loops 2019-03-31 13:05:27 +02:00
Anatol Belski
76ede8f900 Renames VC => VS
Rename starter scripts for 16
2019-03-31 12:51:55 +02:00
Anatol Belski
60cfe587d5 Show exact VC++ version 2019-03-11 16:30:07 +01:00
Anatol Belski
e6b4a0d34d Involve JIT in PGO training for master 2019-03-10 18:33:42 +01:00
Anatol Belski
dac0e43fec Add VS2019 command prompt starters 2019-02-24 20:08:23 +01:00
Anatol Belski
1d69f089ca Improve error handling on erroneous branch data 2019-02-21 19:33:12 +01:00
Anatol Belski
99112657d2 Update vswhere 2019-02-21 17:14:21 +01:00
Anatol Belski
7eaeba9e73 Back to dev 2019-02-11 22:24:57 -08:00
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
117 changed files with 4122 additions and 4307 deletions

View File

@@ -12,15 +12,13 @@ The PHP SDK 2.0+ is compatible with PHP 7.0 and above. The compatibility with [o
# Requirements
- `Visual C++ 2015` or `Visual C++ 2017` must be installed prior SDK usage (be sure to install both the C++ and the Windows SDK components)
- A 64-bit build host
- `Visual C++ 2015` or `Visual C++ 2017` must be installed prior SDK usage (be sure to install the C++ dev, .NET dev and the Windows SDK components)
- if `Cygwin`, `MingW` or any other cross solution is installed, please read notes in the pitfalls section
- if a 64-bit build is intended, a 64-bit system is required. Cross compilation of 64-bit on 32-bit system is not supported at the moment
- The PHP SDK was successfully tested on Windows 7 or later, earlier versions might work but are not recommended
# Tools
All the tools included are either scripts or 32-bit binaries. They are therefore runable on any of x86 or x64 supported Windows system.
## SDK
- starter scripts, named phpsdk-<crt>-<arch>.bat

View File

@@ -1 +1 @@
2.2.0beta2
2.2.0beta5

View File

@@ -10,11 +10,11 @@ rem otherwise - retain the old behavior, create structs for all the known build
cmd /c "exit /b 0"
if "%PHP_SDK_ARCH%" NEQ "" (
if "%PHP_SDK_VC%" NEQ "" (
MD %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%\deps\bin
MD %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%\deps\lib
MD %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%\deps\include
cd %_%\%PHP_SDK_VC%\%PHP_SDK_ARCH%
if "%PHP_SDK_VS%" NEQ "" (
MD %_%\%PHP_SDK_VS%\%PHP_SDK_ARCH%\deps\bin
MD %_%\%PHP_SDK_VS%\%PHP_SDK_ARCH%\deps\lib
MD %_%\%PHP_SDK_VS%\%PHP_SDK_ARCH%\deps\include
cd %_%\%PHP_SDK_VS%\%PHP_SDK_ARCH%
goto exit
)
goto create_all

View File

@@ -126,19 +126,11 @@ try {
usage(3);
}
/* The current CRT needs to match the config one. */
$active_crt = getenv("PHP_SDK_VC");
$active_crt = getenv("PHP_SDK_VS");
if (Config::getCurrentCrtName() != $active_crt && !$force) {
throw new Exception("Active CRT '$active_crt' differs from the branch CRT '" . Config::getCurrentCrtName() . "'.");
}
if (NULL === Config::getCurrentStabilityName()) {
if ("master" == Config::getCurrentBranchName()) {
Config::setCurrentStabilityName("staging");
} else {
Config::setCurrentStabilityName("stable");
}
}
$branch_data = Config::getCurrentBranchData();
echo "\nConfiguration: " . Config::getCurrentBranchName() . "-$branch_data[crt]-$branch_data[arch]-$branch_data[stability]\n\n";

View File

@@ -24,7 +24,7 @@ if "%PHP_SDK_ARCH%"=="x64" (
echo Build architecture: 32-bit
)
echo Visual C++: %PHP_SDK_VC_NUM%
echo Visual C++: %PHP_SDK_VC_TOOLSET_VER%
echo PHP-SDK path: %PHP_SDK_ROOT_PATH%

View File

@@ -1,14 +1,14 @@
@echo off
if "%PHP_SDK_PHP_CMD%"=="" (
call %~dp0phpsdk_setvars.bat
if "!PHP_SDK_PHP_CMD!"=="" (
echo PHP SDK is not setup
exit /b 3
)
)
cmd /c %PHP_SDK_PHP_CMD% %PHP_SDK_BIN_PATH%\phpsdk_pgo.php %*
exit /b %errorlevel%
@echo off
if "%PHP_SDK_PHP_CMD%"=="" (
call %~dp0phpsdk_setvars.bat
if "!PHP_SDK_PHP_CMD!"=="" (
echo PHP SDK is not setup
exit /b 3
)
)
cmd /c %PHP_SDK_PHP_CMD% %PHP_SDK_BIN_PATH%\phpsdk_pgo.php %*
exit /b %errorlevel%

View File

@@ -2,7 +2,7 @@
setlocal enableextensions enabledelayedexpansion
set PHPSDK_MSYS2_BASE_ADDR=0x70000000
set PHPSDK_MSYS2_BASE_ADDR=0x100400000
set PHPSDK_MSYS2_BASE_DYNAMIC=0
:getopt
@@ -33,7 +33,7 @@ GOTO EXIT
:help
echo phpsdk_rebase_msys2 ^<address^>
echo Rebase MSYS2 DLLs to the given address. If ommited, default is 0x70000000.
echo Rebase MSYS2 DLLs to the given address. If ommited, default is 0x100400000.
:EXIT
exit /b %errorlevel%

View File

@@ -15,31 +15,33 @@ if "%2"=="" goto :help
cmd /c "exit /b 0"
set PHP_SDK_VC=%1
if /i not "%PHP_SDK_VC:~0,2%"=="vc" (
set PHP_SDK_VS=%1
if /i not "%PHP_SDK_VS:~0,2%"=="vc" (
if /i not "%PHP_SDK_VS:~0,2%"=="vs" (
:malformed_vc_string
echo Malformed CRT string "%1"
set PHP_SDK_VC=
goto out_error
echo Malformed CRT string "%1"
set PHP_SDK_VS=
goto out_error
)
)
if ""=="%PHP_SDK_VC:~2%" (
if ""=="%PHP_SDK_VS:~2%" (
goto malformed_vc_string
)
set /a TMP_CHK=%PHP_SDK_VC:~2%
set /a TMP_CHK=%PHP_SDK_VS:~2%
if 14 gtr %TMP_CHK% (
if "0"=="%TMP_CHK%" (
if not "0"=="%PHP_SDK_VC:~2%" (
if not "0"=="%PHP_SDK_VS:~2%" (
set TMP_CHK=
goto malformed_vc_string
)
)
echo At least vc14 is required
set PHP_SDK_VC=
set PHP_SDK_VS=
set TMP_CHK=
goto out_error
)
set PHP_SDK_VC_NUM=%TMP_CHK%
set PHP_SDK_VS_NUM=%TMP_CHK%
set TMP_CHK=
if /i not "%2"=="x64" (
@@ -66,28 +68,37 @@ if not errorlevel 1 (
set TMPKEY=
rem get vc base dir
if 15 gtr %PHP_SDK_VC_NUM% (
if 15 gtr %PHP_SDK_VS_NUM% (
if /i "%PHP_SDK_OS_ARCH%"=="x64" (
set TMPKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
set TMPKEY=HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\%PHP_SDK_VS:~2%.0\Setup\VC
) else (
set TMPKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VC:~2%.0\Setup\VC
set TMPKEY=HKLM\SOFTWARE\Microsoft\VisualStudio\%PHP_SDK_VS:~2%.0\Setup\VC
)
reg query !TMPKEY! /v ProductDir >nul 2>&1
if errorlevel 1 (
echo Couldn't determine VC%PHP_SDK_VC:~2% directory
echo Couldn't determine VC%PHP_SDK_VS:~2% directory
goto out_error;
)
for /f "tokens=2*" %%a in ('reg query !TMPKEY! /v ProductDir') do set PHP_SDK_VC_DIR=%%b
) else (
rem vc15 support only for now, could parse out and pass on later
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version %PHP_SDK_VC_NUM% -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do set PHP_SDK_VC_DIR=%%b\VC
rem build the version range, e.g. "[15,16)"
set /a PHP_SDK_VS_RANGE=PHP_SDK_VS_NUM + 1
set PHP_SDK_VS_RANGE="[%PHP_SDK_VS_NUM%,!PHP_SDK_VS_RANGE%!)"
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do (
set PHP_SDK_VC_DIR=%%b\VC
)
if not exist "!PHP_SDK_VC_DIR!" (
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version %PHP_SDK_VC_NUM% -products Microsoft.VisualStudio.Product.BuildTools -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do set PHP_SDK_VC_DIR=%%b\VC
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -products Microsoft.VisualStudio.Product.BuildTools -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do (
set PHP_SDK_VC_DIR=%%b\VC
)
if not exist "!PHP_SDK_VC_DIR!" (
rem check for a preview release
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version %PHP_SDK_VC_NUM% -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do set PHP_SDK_VC_DIR=%%b\VC
for /f "tokens=1* delims=: " %%a in ('%~dp0\vswhere -nologo -version !PHP_SDK_VS_RANGE! -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text') do (
set PHP_SDK_VC_DIR=%%b\VC
)
if not exist "!PHP_SDK_VC_DIR!" (
echo Could not determine '%PHP_SDK_VC%' directory
echo Could not determine '%PHP_SDK_VS%' directory
goto out_error;
)
)
@@ -95,8 +106,9 @@ if 15 gtr %PHP_SDK_VC_NUM% (
set VSCMD_ARG_no_logo=nologo
)
set TMPKEY=
set PHP_SDK_VS_RANGE=
if 15 gtr %PHP_SDK_VC_NUM% (
if 15 gtr %PHP_SDK_VS_NUM% (
rem get sdk dir
rem if 10.0 is available, it's ok
if /i "%PHP_SDK_OS_ARCH%"=="x64" (
@@ -131,20 +143,20 @@ if 15 gtr %PHP_SDK_VC_NUM% (
)
if /i "%PHP_SDK_ARCH%"=="x64" (
if 15 gtr %PHP_SDK_VC_NUM% (
set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" amd64
if 15 gtr %PHP_SDK_VS_NUM% (
set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" amd64
) else (
set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" amd64
set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" amd64
)
) else (
if 15 gtr %PHP_SDK_VC_NUM% (
set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" x86
if 15 gtr %PHP_SDK_VS_NUM% (
set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" x86
) else (
set PHP_SDK_VC_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" x86
set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" x86
)
)
rem echo Visual Studio path %PHP_SDK_VC_DIR%
rem echo Visual Studio VC path %PHP_SDK_VC_DIR%
rem echo Windows SDK path %PHP_SDK_WIN_SDK_DIR%

View File

@@ -17,5 +17,12 @@ set PHP_SDK_PHP_CMD=%PHP_SDK_BIN_PATH%\php\do_php.bat
set PATH=%PHP_SDK_BIN_PATH%;%PHP_SDK_MSYS2_PATH%;%PATH%
for /f "tokens=1* delims=: " %%a in ('link /?') do (
set PHP_SDK_VC_TOOLSET_VER=%%b
goto break0
)
:break0
set PHP_SDK_VC_TOOLSET_VER=%PHP_SDK_VC_TOOLSET_VER:~-13%
exit /b %errorlevel%

Binary file not shown.

View File

@@ -138,7 +138,8 @@ class Config
$tmp = $fetcher->getByUri(self::$depsBaseUri . "/series/");
if (false !== $tmp) {
$data = array();
if (preg_match_all(",/packages-(.+)-(vc\d+)-(x86|x64)-(stable|staging)\.txt,U", $tmp, $m, PREG_SET_ORDER)) {
if (preg_match_all(",/packages-(.+)-(vc\d+)-(x86|x64)-(stable|staging)\.txt,U", $tmp, $m, PREG_SET_ORDER)
|| preg_match_all(",/packages-(.+)-(vs\d+)-(x86|x64)-(stable|staging)\.txt,U", $tmp, $m, PREG_SET_ORDER)) {
foreach ($m as $b) {
if (!isset($data[$b[1]])) {
$data[$b[1]] = array();
@@ -293,10 +294,13 @@ class Config
}
}
if (!@$ret["stability"]) {
if (!isset($ret["arch"]) || !$ret["arch"]) {
throw new Exception("Failed to find config with arch '" . self::getCurrentArchName() . "'");
}
if (!isset($ret["stability"]) || !$ret["stability"]) {
throw new Exception("Failed to find config with stability '" . self::getCurrentStabilityName() . "'");
}
if (!@$ret["crt"]) {
if (!isset($ret["crt"]) || !$ret["crt"]) {
throw new Exception("Failed to find config with arch '" . self::getCurrentArchName() . "'");
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,4 @@
# bits2str --- turn a byte into readable ones and zeros
# bits2str --- turn an integer into readable ones and zeros
function bits2str(bits, data, mask)
{

View File

@@ -38,7 +38,7 @@ function _gr_init( oldfs, oldrs, olddol0, grcat,
n = split($4, a, "[ \t]*,[ \t]*")
for (i = 1; i <= n; i++)
if (a[i] in _gr_groupsbyuser)
_gr_groupsbyuser[a[i]] = gr_groupsbyuser[a[i]] " " $1
_gr_groupsbyuser[a[i]] = _gr_groupsbyuser[a[i]] " " $1
else
_gr_groupsbyuser[a[i]] = $1

View File

@@ -1,4 +1,26 @@
# inplace --- load and invoke the inplace extension.
#
# Copyright (C) 2013, 2017 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
#
# GAWK 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.
#
# GAWK 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
# Andrew J. Schorr, aschorr@telemetry-investments.com
# January 2013
@load "inplace"
@@ -15,7 +37,7 @@
# actions in an ENDFILE rule will be redirected as expected.
BEGIN {
inplace = 1 # enabled by default
inplace = 1 # enabled by default
}
BEGINFILE {

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
@@ -263,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], [],
@@ -374,60 +375,42 @@ 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)
# -----------------------
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
# undefined.
m4_define([__b4_symbol],
[m4_indir([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.
m4_define([_b4_symbol],
[m4_indir([b4_symbol($1, $2)])])
[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],
@@ -468,8 +451,8 @@ 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])])
@@ -497,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
@@ -508,7 +491,9 @@ m4_popdef([b4_actions_])dnl
# _b4_symbol_case(SYMBOL-NUM)
# ---------------------------
# Issue a "case NUM" for SYMBOL-NUM.
# 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])])
])
@@ -569,7 +554,7 @@ m4_define([b4_token_format],
# 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],
[b4_symbol_if([$1], [has_type],

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,10 +22,10 @@ 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([parser_class_name], [code], [deprecated])
b4_percent_define_check_kind([api.parser.class], [code], [deprecated])
## ----- ##
@@ -72,6 +72,22 @@ m4_define([b4_cxx_portability],
# 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
])
@@ -80,7 +96,7 @@ m4_define([b4_cxx_portability],
## 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.
@@ -200,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;])[
};
@@ -224,11 +251,11 @@ m4_define([b4_public_types_declare],
]])
# b4_symbol_type_declare
# ----------------------
# b4_symbol_type_define
# ---------------------
# Define symbol_type, the external type for symbols used for symbol
# constructors.
m4_define([b4_symbol_type_declare],
m4_define([b4_symbol_type_define],
[[ /// A complete symbol.
///
/// Expects its Base type to provide access to the symbol type
@@ -242,7 +269,10 @@ m4_define([b4_symbol_type_declare],
typedef Base super_type;
/// Default constructor.
basic_symbol ();
basic_symbol ()
: value ()]b4_locations_if([
, location ()])[
{}
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
@@ -250,11 +280,10 @@ m4_define([b4_symbol_type_declare],
#endif
/// Copy constructor.
basic_symbol (const basic_symbol& that);
basic_symbol (const basic_symbol& that);]b4_variant_if([[
]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([,
YY_MOVE_REF (location_type) l])[);
@@ -262,16 +291,35 @@ m4_define([b4_symbol_type_declare],
/// Constructor for symbols with semantic value.
basic_symbol (typename Base::kind_type t,
YY_RVREF (semantic_type) v]b4_locations_if([,
YY_RVREF (location_type) l])[);]])[
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);
@@ -317,10 +365,10 @@ m4_define([b4_symbol_type_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.
@@ -329,7 +377,17 @@ m4_define([b4_symbol_type_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;
/// Empty symbol.
symbol_type () {}
/// Constructor for valueless symbols, and symbols from each type.
]b4_type_foreach([_b4_token_constructor_define])dnl
])[};
]])
@@ -337,46 +395,33 @@ m4_define([b4_symbol_type_declare],
# -----------------------------
# 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.
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol ()
: value ()]b4_locations_if([
, location ()])[
{}
[[ // basic_symbol.
#if 201103L <= YY_CPLUSPLUS
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (basic_symbol&& that)
]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)])])[
}
[std::move (that.value)])
])[}
#endif
template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& that)
]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],
[that.value])])[
}
[YY_MOVE (that.value)])
])[}
]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([YY_MOVE_REF (location_type) l]))[)
: Base (t)
@@ -385,7 +430,7 @@ m4_define([b4_public_types_define],
{}
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],
[YY_RVREF (semantic_type) v],
b4_locations_if([YY_RVREF (location_type) l]))[)
@@ -396,42 +441,16 @@ m4_define([b4_public_types_define],
(void) v;
]b4_symbol_variant([this->type_get ()], [value], [YY_MOVE_OR_COPY], [YY_MOVE (v)])])[}]])[
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_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 ();
}
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],
@@ -441,47 +460,47 @@ m4_define([b4_public_types_define],
}
// 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)
{}
#if 201103L <= YY_CPLUSPLUS
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (by_type&& that)
]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_name[::by_type::by_type (const by_type& that)
]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). */
@@ -491,20 +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)
@@ -512,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[;
@@ -538,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])])
@@ -558,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)@})])
@@ -633,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
@@ -39,25 +39,26 @@ m4_define([b4_comment],
# _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],
[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)
# ----------------
@@ -373,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 safely, 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])])])
## ---------------------- ##
@@ -604,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

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,11 +194,11 @@ 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])[
@@ -212,7 +212,7 @@ 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_disclaimer[
@@ -228,8 +228,7 @@ b4_copyright([Skeleton implementation for Bison GLR parsers in C],
#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([[
@@ -328,7 +327,7 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
#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[
@@ -336,14 +335,22 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
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) (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[
@@ -583,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;
@@ -639,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. */
@@ -758,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. */
@@ -815,12 +869,27 @@ yyuserAction (yyRuleNum yyn, int 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[
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
@@ -917,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.
@@ -925,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** yyconflicts)
static inline int
yygetLRActions (yyStateNum yystate, yySymbol yytoken, const short** yyconflicts)
{
int yyindex = yypact[yystate] + yytoken;
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;
}
}
@@ -1254,10 +1322,10 @@ 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. |
@@ -1918,24 +1986,8 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
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)
{
@@ -2134,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)
@@ -2157,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;
@@ -2184,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;
@@ -2263,7 +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
b4_dollar_pushdef([yylval], [], [], [yylloc])dnl
b4_user_initial_action
b4_dollar_popdef])[]dnl
[
@@ -2287,17 +2330,13 @@ b4_dollar_popdef])[]dnl
/* Standard mode */
while (yytrue)
{
yyRuleNum yyrule;
int yyaction;
const short* 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;]])[
@@ -2308,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))
@@ -2340,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
@@ -2401,10 +2427,9 @@ b4_dollar_popdef])[]dnl
yyposn += 1;
for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
{
int yyaction;
const short* 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) yys));

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
@@ -46,11 +46,11 @@
# We require a pure interface.
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,26 +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_name[::operator() ()
]b4_parser_class[::operator() ()
{
return parse ();
}
int
]b4_parser_class_name[::parse ()
]b4_parser_class[::parse ()
{
return ::yyparse (*this]b4_user_args[);
}
@@ -184,7 +181,7 @@ 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([[
@@ -198,7 +195,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
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]])[)
{
@@ -210,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;
@@ -252,26 +249,39 @@ b4_percent_code_get([[requires]])[
#include <stdexcept>
#include <string>
]m4_ifdef([b4_location_file],
]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_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.
@@ -281,6 +291,7 @@ b4_percent_code_get([[requires]])[
/// \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.
@@ -292,8 +303,8 @@ b4_percent_code_get([[requires]])[
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.
@@ -328,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[
@@ -342,7 +353,7 @@ 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[
@@ -354,5 +365,5 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
# 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,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/[c++.m4])
m4_include(b4_skeletonsdir/[c++.m4])
# api.value.type=variant is valid.
m4_define([b4_value_type_setup_variant])
@@ -35,57 +35,55 @@ 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])])
[b4_symbol_value([b4_rhs_data([$1], [$2]).value], [$3], [$4])])
m4_define([b4_rhs_value],
[b4_percent_define_ifdef([api.value.automove],
@@ -93,12 +91,12 @@ m4_define([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)
@@ -109,10 +107,10 @@ 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])
[$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@])
@@ -137,16 +135,16 @@ 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)
@@ -174,21 +172,18 @@ m4_define([b4_shared_declarations],
]b4_namespace_open[
]b4_stack_define[
]b4_bison_locations_if([m4_ifndef([b4_location_file],
[b4_location_define])])[
]b4_variant_if([b4_variant_define])[
/// A Bison parser.
class ]b4_parser_class_name[
class ]b4_parser_class[
{
public:
]b4_public_types_declare[
]b4_symbol_type_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.
@@ -220,12 +215,12 @@ m4_define([b4_shared_declarations],
/// Report a syntax error.
void error (const syntax_error& err);
]b4_symbol_constructor_declare[
]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;
@@ -296,26 +291,26 @@ m4_define([b4_shared_declarations],
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 };
@@ -343,6 +338,8 @@ m4_define([b4_shared_declarations],
#endif
};
]b4_stack_define[
/// Stack type.
typedef stack<stack_symbol_type> stack_type;
@@ -391,7 +388,7 @@ m4_define([b4_shared_declarations],
#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]])[
@@ -518,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 (;;)
@@ -535,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;
@@ -551,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),
@@ -559,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. |
@@ -570,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;
@@ -604,10 +606,10 @@ 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 (YY_RVREF (stack_symbol_type) that)
]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 ()],
@@ -618,7 +620,7 @@ m4_if(b4_prefix, [yy], [],
#endif
}
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that)
]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 ()],
@@ -628,8 +630,8 @@ m4_if(b4_prefix, [yy], [],
}
#if YY_CPLUSPLUS < 201103L
]b4_parser_class_name[::stack_symbol_type&
]b4_parser_class_name[::stack_symbol_type::operator= (stack_symbol_type& that)
]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 ()],
@@ -644,7 +646,7 @@ m4_if(b4_prefix, [yy], [],
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([], [
@@ -656,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 << ": "])[;
@@ -675,7 +679,7 @@ m4_if(b4_prefix, [yy], [],
#endif
void
]b4_parser_class_name[::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym)
]b4_parser_class[::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym)
{
if (m)
YY_SYMBOL_PRINT (m, sym);
@@ -683,7 +687,7 @@ m4_if(b4_prefix, [yy], [],
}
void
]b4_parser_class_name[::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym)
]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)));
@@ -694,40 +698,40 @@ m4_if(b4_prefix, [yy], [],
}
void
]b4_parser_class_name[::yypop_ (int n)
]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)
@@ -737,25 +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[::operator() ()
]b4_parser_class[::operator() ()
{
return parse ();
}
int
]b4_parser_class_name[::parse ()
]b4_parser_class[::parse ()
{
// State.
int yyn;
@@ -782,7 +786,7 @@ m4_if(b4_prefix, [yy], [],
YYCDEBUG << "Starting parse\n";
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yyla.value], [], [yyla.location])dnl
b4_dollar_pushdef([yyla.value], [], [], [yyla.location])dnl
b4_user_initial_action
b4_dollar_popdef])[]dnl
@@ -793,17 +797,22 @@ b4_dollar_popdef])[]dnl
yystack_.clear ();
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:
// Try to take a decision without lookahead.
yyn = yypact_[yystack_[0].state];
@@ -825,6 +834,7 @@ b4_dollar_popdef])[]dnl
#if YY_EXCEPTIONS
catch (const syntax_error& yyexc)
{
YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
error (yyexc);
goto yyerrlab1;
}
@@ -856,6 +866,7 @@ b4_dollar_popdef])[]dnl
yypush_ ("Shifting", yyn, YY_MOVE (yyla));
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
@@ -865,8 +876,9 @@ b4_dollar_popdef])[]dnl
goto yyerrlab;
goto yyreduce;
/*-----------------------------.
| yyreduce -- Do a reduction. |
| yyreduce -- do a reduction. |
`-----------------------------*/
yyreduce:
yylen = yyr2_[yyn];
@@ -891,8 +903,8 @@ 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;
}]])[
@@ -912,6 +924,7 @@ b4_dollar_popdef])[]dnl
#if YY_EXCEPTIONS
catch (const syntax_error& yyexc)
{
YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
error (yyexc);
YYERROR;
}
@@ -926,6 +939,7 @@ b4_dollar_popdef])[]dnl
}
goto yynewstate;
/*--------------------------------------.
| yyerrlab -- here on detecting error. |
`--------------------------------------*/
@@ -963,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. |
`-------------------------------------------------------------*/
@@ -1015,16 +1029,26 @@ b4_dollar_popdef])[]dnl
}
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);
@@ -1060,7 +1084,7 @@ b4_dollar_popdef])[]dnl
}
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 ()]])[);
@@ -1068,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([[
@@ -1167,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[
@@ -1177,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[
};
@@ -1187,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
@@ -1200,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];

Some files were not shown because too many files have changed in this diff Show More