From 3acb9f2d596343d787ca265b39dc02bfa33ac941 Mon Sep 17 00:00:00 2001 From: Churkin Aleksey Date: Tue, 25 Aug 2026 14:37:40 +0300 Subject: [PATCH 1/3] gen1-to-gen2: remove the C++ v1 -> gen2 converter It carries a fork of the v1 bison grammar and re-parses the file after every rewrite, which is why that fork has to accept mixed gen1+gen2 input. A converter that reads the tree daslang itself parses needs neither, and lands two commits later under the same name. Everything the binary reached goes with it: the vendored grammar, the `gen1_to_gen2` target and its install, `daslang --run-fmt` (its only in-binary caller), the CodeQL exclusion for the generated parser, the packaging rows that shipped the exe, and the release-phase checks that ran it. The formatter proper is `utils/das-fmt/dasfmt.das` and is untouched - the two have never been the same tool. Co-Authored-By: Claude Opus 5 (1M context) --- .gitattributes | 2 - .github/workflows/codeql.yml | 1 - .github/workflows/extended_checks.yml | 4 +- CMakeLists.txt | 27 +- ci/check_shipped_skills.py | 2 +- ci/packaging/README.md | 2 +- ci/packaging/deb_build.sh | 2 +- ci/packaging/homebrew-daslang.rb.template | 1 - ci/packaging/scoop-daslang.json.template | 1 - ci/packaging/wheel_build.py | 2 +- ci/smoke_test_bundle.sh | 3 +- install/CLAUDE.md | 2 +- install/README.md | 2 +- utils/CMakeLists.txt | 11 +- utils/daslang/main.cpp | 38 - utils/gen1-to-gen2/Readme.md | 46 - utils/gen1-to-gen2/ds_parser.cpp | 13475 ------------------ utils/gen1-to-gen2/ds_parser.hpp | 396 - utils/gen1-to-gen2/ds_parser.ypp | 4627 ------ utils/gen1-to-gen2/fmt.cpp | 318 - utils/gen1-to-gen2/fmt.h | 28 - utils/gen1-to-gen2/formatter.cpp | 213 - utils/gen1-to-gen2/formatter.h | 131 - utils/gen1-to-gen2/helpers.cpp | 247 - utils/gen1-to-gen2/helpers.h | 68 - utils/gen1-to-gen2/main.cpp | 325 - utils/internal/test-release/utils_phase.das | 3 - 27 files changed, 11 insertions(+), 19966 deletions(-) delete mode 100644 utils/gen1-to-gen2/Readme.md delete mode 100644 utils/gen1-to-gen2/ds_parser.cpp delete mode 100644 utils/gen1-to-gen2/ds_parser.hpp delete mode 100644 utils/gen1-to-gen2/ds_parser.ypp delete mode 100644 utils/gen1-to-gen2/fmt.cpp delete mode 100644 utils/gen1-to-gen2/fmt.h delete mode 100644 utils/gen1-to-gen2/formatter.cpp delete mode 100644 utils/gen1-to-gen2/formatter.h delete mode 100644 utils/gen1-to-gen2/helpers.cpp delete mode 100644 utils/gen1-to-gen2/helpers.h delete mode 100644 utils/gen1-to-gen2/main.cpp diff --git a/.gitattributes b/.gitattributes index 89af009e06..86c9895579 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,8 +1,6 @@ # All files generated by standalone contexts are ignored in git statistic src/das/**/*.cpp binary src/das/**/*.h binary -utils/gen1-to-gen2/ds_parser.cpp binary -utils/gen1-to-gen2/ds_parser.output binary daslib/_aot_generated/*.cpp binary # Shell scripts must keep LF endings even when checked out under autocrlf=true. diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index d29cbae625..f0df555278 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -81,7 +81,6 @@ jobs: -**/stb_*.h -modules/dasSQLITE/sqlite/** -modules/dasMinfft/minfft/** - -utils/gen1-to-gen2/ds_parser.cpp input: sarif-results/cpp.sarif output: sarif-results/cpp.sarif diff --git a/.github/workflows/extended_checks.yml b/.github/workflows/extended_checks.yml index d77739113a..5dec1b0dc7 100644 --- a/.github/workflows/extended_checks.yml +++ b/.github/workflows/extended_checks.yml @@ -222,7 +222,7 @@ jobs: # No sccache launcher: this lane is nightly-only and runs uncached. cmake --no-warn-unused-cli -B./build -G "${{ matrix.cmake_generator }}" -DCMAKE_BUILD_TYPE:STRING=Release \ $ACTIVE_MODULES -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" - cmake --build ./build --config Release --target daslang gen1_to_gen2 daslang_static --parallel + cmake --build ./build --config Release --target daslang daslang_static --parallel ;; linux) echo "BIN=./bin" >> $GITHUB_ENV @@ -306,7 +306,7 @@ jobs: # ON via ci/release_modules.txt in this workflow. run: | set -eux - # The main extended_checks build only targets daslang/gen1_to_gen2/daslang_static. + # The main extended_checks build only targets daslang/daslang_static. # Sequence loads dasGlfw + dasLiveHost + dasHV + dasAudio + dasPUGIXML + # dasStbImage at runtime; build their dynamic-module targets first. # No `cmake --install` -- the source tree already IS a usable daslang diff --git a/CMakeLists.txt b/CMakeLists.txt index 70c2834cf2..96fd3353ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -874,7 +874,6 @@ FLEX(src/parser/ds_lexer.lpp) FLEX(src/parser/ds2_lexer.lpp) BISON(src/parser/ds_parser.ypp) BISON(src/parser/ds2_parser.ypp) -BISON(utils/gen1-to-gen2/ds_parser.ypp) SET(PARSER_GENERATED_SRC # 1st parser @@ -1170,14 +1169,6 @@ src/simulate/fs_file_info.cpp ) -SET(GEN1_TO_GEN2_SRC - ${PROJECT_SOURCE_DIR}/utils/gen1-to-gen2/fmt.cpp - ${PROJECT_SOURCE_DIR}/utils/gen1-to-gen2/formatter.cpp - ${PROJECT_SOURCE_DIR}/utils/gen1-to-gen2/helpers.cpp - ${PROJECT_SOURCE_DIR}/utils/gen1-to-gen2/ds_parser.cpp - CACHE INTERNAL "GEN1_TO_GEN2_SRC" -) - # MSVC first so clang-cl (CXX_COMPILER_ID==Clang but MSVC driver) takes /EHsc, not -fexceptions if(MSVC) set_source_files_properties(src/builtin/module_builtin_ast_serialize.cpp PROPERTIES @@ -1189,11 +1180,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") ) endif() -# flex/bison output (the gen1_to_gen2 converter's own copy) is not ours to clean -IF(MSVC) - set_source_files_properties(${PROJECT_SOURCE_DIR}/utils/gen1-to-gen2/ds_parser.cpp PROPERTIES COMPILE_FLAGS "/W0") -ELSE() - set_source_files_properties(${PROJECT_SOURCE_DIR}/utils/gen1-to-gen2/ds_parser.cpp PROPERTIES COMPILE_FLAGS "-w") +IF(NOT MSVC) # fmt's vendored format-inl.h noreturn helper: GCC needs -Wno-error, clang -Wno-invalid-noreturn IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set_source_files_properties(src/misc/format.cpp PROPERTIES COMPILE_FLAGS "-Wno-error") @@ -1300,7 +1287,6 @@ SET(LIBDASCRIPT_COMPILER_SRC ${SIMULATE_FUSION_SRC} ${PARSER_GENERATED_SRC} ${PARSER_SRC} - ${GEN1_TO_GEN2_SRC} src/ast/ast_parse.cpp src/ast/ast_optimize.cpp src/ast/ast_const_folding.cpp @@ -1598,17 +1584,6 @@ if (NOT ${DAS_TOOLS_DISABLED}) FILES_MATCHING PATTERN "*.das" ) - add_executable(gen1_to_gen2 ${PROJECT_SOURCE_DIR}/utils/gen1-to-gen2/main.cpp) - TARGET_LINK_LIBRARIES(gen1_to_gen2 libDaScriptDyn ${SRC_LIBRARIES}) - ADD_DEPENDENCIES(gen1_to_gen2 libDaScriptDyn ${DAS_DYN_MODULES_LIBS}) - target_include_directories(gen1_to_gen2 PRIVATE ${NEED_MODULES_PATH}) - - SETUP_CPP11(gen1_to_gen2) - DAS_APPLY_STRICT_WARNINGS(gen1_to_gen2) - SETUP_LTO(gen1_to_gen2) - SETUP_BIN_RPATH(gen1_to_gen2) - install(TARGETS gen1_to_gen2 RUNTIME DESTINATION ${DAS_INSTALL_BINDIR}) - #IF(APPLE) # add_executable(daslangOsx MACOSX_BUNDLE ${DAS_DASCRIPT_MAIN_SRC}) # TARGET_LINK_LIBRARIES(daslangOsx libDaScript libDaScriptTest Threads::Threads ${DAS_MODULES_LIBS}) diff --git a/ci/check_shipped_skills.py b/ci/check_shipped_skills.py index 220fe495f4..1b73b2d79d 100644 --- a/ci/check_shipped_skills.py +++ b/ci/check_shipped_skills.py @@ -51,7 +51,7 @@ # `daslang.exe` and every module DLL", which is fine; `daslang.exe utils/aot/main.das` # is not. The discriminator is the next token: a flag, or a real file with an extension. EXE_CMD = re.compile( - r"(?_amd64.deb` (binaries land in `/opt/daslang`, - `daslang`/`daslang-live`/`gen1_to_gen2` symlinked into `/usr/bin`). A hosted apt + `daslang`/`daslang-live` symlinked into `/usr/bin`). A hosted apt repo is a later tier. 6. **pip** (automatic): `wheel_build.py` repacks each bundle into a platform wheel (`daslang--py3-none-{win_amd64,manylinux_2_NN_x86_64,manylinux_2_NN_aarch64,macosx_NN_0_arm64}.whl`) diff --git a/ci/packaging/deb_build.sh b/ci/packaging/deb_build.sh index a2b476f5cf..9156128669 100644 --- a/ci/packaging/deb_build.sh +++ b/ci/packaging/deb_build.sh @@ -22,7 +22,7 @@ mkdir -p "$PKG/opt/daslang" "$PKG/usr/bin" "$PKG/DEBIAN" cp -a "$BUNDLE"/. "$PKG/opt/daslang/" # the user-facing binaries; everything else is reached relative to /opt/daslang -for exe in daslang daslang-live gen1_to_gen2; do +for exe in daslang daslang-live; do if [ -x "$PKG/opt/daslang/bin/$exe" ]; then ln -s "/opt/daslang/bin/$exe" "$PKG/usr/bin/$exe" fi diff --git a/ci/packaging/homebrew-daslang.rb.template b/ci/packaging/homebrew-daslang.rb.template index d1a930b699..39b6ef61ee 100644 --- a/ci/packaging/homebrew-daslang.rb.template +++ b/ci/packaging/homebrew-daslang.rb.template @@ -33,7 +33,6 @@ class Daslang < Formula libexec.install Dir["#{root}/*"] bin.install_symlink libexec/"bin/daslang" bin.install_symlink libexec/"bin/daslang-live" - bin.install_symlink libexec/"bin/gen1_to_gen2" end test do diff --git a/ci/packaging/scoop-daslang.json.template b/ci/packaging/scoop-daslang.json.template index 7f4166e44d..5a5e8197e4 100644 --- a/ci/packaging/scoop-daslang.json.template +++ b/ci/packaging/scoop-daslang.json.template @@ -9,7 +9,6 @@ "bin": [ "bin\\daslang.exe", "bin\\daslang-live.exe", - "bin\\gen1_to_gen2.exe", "bin\\lint.exe", "bin\\daspkg.exe", "bin\\dascov.exe", diff --git a/ci/packaging/wheel_build.py b/ci/packaging/wheel_build.py index 91b7f32864..c107ab60e7 100644 --- a/ci/packaging/wheel_build.py +++ b/ci/packaging/wheel_build.py @@ -26,7 +26,7 @@ SUMMARY = "High-performance statically-typed scripting language for games and real-time applications" # console_scripts shim per shipped executable; the scoop bucket exposes the same set -TOOLS = ["daslang", "daslang-live", "gen1_to_gen2", "lint", "daspkg", "dascov", +TOOLS = ["daslang", "daslang-live", "lint", "daspkg", "dascov", "detect-dupe", "benchctl", "dastest", "das-fmt"] EXCLUDE_TOP = ("include", "examples", "doc", "logs") diff --git a/ci/smoke_test_bundle.sh b/ci/smoke_test_bundle.sh index af1b1c68c0..0032af803e 100644 --- a/ci/smoke_test_bundle.sh +++ b/ci/smoke_test_bundle.sh @@ -33,7 +33,7 @@ CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # Two exe naming conventions exist: # * CPP_SUFFIX — for binaries built via cmake `add_executable` (daslang, -# daslang-live, gen1_to_gen2): platform-natural suffix (.exe on Windows, +# daslang-live): platform-natural suffix (.exe on Windows, # none on Linux/macOS). # * DASEXE_SUFFIX — for binaries built via `daslang -exe`: ALWAYS `.exe` on # every platform (utils/CMakeLists.txt: "daslang -exe appends `.exe` to the @@ -106,7 +106,6 @@ COMPILE_TESTS=( # and a bundle whose rpath points back at the build tree is present-but-dead on every # user's box. SHIPPED_EXE_TESTS=( - "gen1_to_gen2|cpp" "daslang-live|cpp" "benchctl|dasexe" "dascov|dasexe" diff --git a/install/CLAUDE.md b/install/CLAUDE.md index 51cd42b38b..1e45bbee5c 100644 --- a/install/CLAUDE.md +++ b/install/CLAUDE.md @@ -190,7 +190,7 @@ For path/filename ops use `fio` helpers (`base_name`/`dir_name`/`path_join`/...) ## SDK Directory Layout -- `bin/` - compiler and tool binaries: `daslang`, `daslang-live`, `gen1_to_gen2`, plus prebuilt tool exes (`lint.exe`, `das-fmt.exe`, `daspkg.exe`, `dascov.exe`, `detect-dupe.exe`, `benchctl.exe`, `dastest.exe` - the `.exe` suffix on every platform) and shared-module / tree-sitter libraries on Windows. Each tool also keeps its source form - `bin/daslang utils//main.das`, except das-fmt (`utils/das-fmt/dasfmt.das`) and dastest (`dastest/dastest.das`). **Name trap:** `bin/gen1_to_gen2` is the gen1->gen2 syntax *converter*, not a formatter; the formatter is `das-fmt` (MCP `format_file`, `bin/das-fmt.exe`, or `bin/daslang utils/das-fmt/dasfmt.das`) +- `bin/` - compiler and tool binaries: `daslang`, `daslang-live`, plus prebuilt tool exes (`lint.exe`, `das-fmt.exe`, `daspkg.exe`, `dascov.exe`, `detect-dupe.exe`, `benchctl.exe`, `dastest.exe` - the `.exe` suffix on every platform) and shared-module / tree-sitter libraries on Windows. Each tool also keeps its source form - `bin/daslang utils//main.das`, except das-fmt (`utils/das-fmt/dasfmt.das`) and dastest (`dastest/dastest.das`). - `lib/`, `include/daScript/` - libraries and C++ headers for embedding - `daslib/` - standard library modules (.das) - `modules/` - optional plugin modules (dasHV, dasGlfw, dasPUGIXML, dasSQLITE, dasAudio, dasLLVM, dasLLAMA, ...) diff --git a/install/README.md b/install/README.md index e994311008..8ff305e497 100644 --- a/install/README.md +++ b/install/README.md @@ -30,7 +30,7 @@ | Directory | Contents | |--------------|-------------------------------------------------------| -| `bin/` | Compiler and tool binaries (`daslang`, `daslang-live`, `gen1_to_gen2`) | +| `bin/` | Compiler and tool binaries (`daslang`, `daslang-live`) | | `lib/` | Static and shared libraries for embedding | | `include/` | C++ headers for integration | | `daslib/` | Standard library modules (`.das` files) | diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 8cb98140b0..fb2e9423b6 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -174,19 +174,10 @@ FOREACH(_das ${DAS_UTILS_TO_TEST}) LIST(APPEND _run_utils_tests COMMAND ${CMAKE_COMMAND} -E echo "Running tests ${_das}" COMMAND daslang ${PROJECT_SOURCE_DIR}/dastest/dastest.das -- --test ${PROJECT_SOURCE_DIR}/utils/${_das} - DEPENDS gen1_to_gen2 tree_sitter_daslang + DEPENDS tree_sitter_daslang ) ENDFOREACH() -# gen1_to_gen2 (utils/gen1-to-gen2, the gen1->gen2 syntax converter) carries its own -# --tests self-check suite. It's a C++ target (not a daslang -exe util), so invoke -# the binary directly rather than through dastest. Previously uncovered by CI, which -# let the make-literal verify-compile tests rot unnoticed. (issue #3094) -LIST(APPEND _run_utils_tests - COMMAND ${CMAKE_COMMAND} -E echo "Running tests gen1_to_gen2 --tests" - COMMAND $ --tests - DEPENDS gen1_to_gen2 -) ADD_CUSTOM_TARGET(run_utils_tests ${_run_utils_tests} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} diff --git a/utils/daslang/main.cpp b/utils/daslang/main.cpp index 5fd3fd4ede..aac4c512d1 100644 --- a/utils/daslang/main.cpp +++ b/utils/daslang/main.cpp @@ -5,7 +5,6 @@ #include "daScript/daScriptModule.h" #include "daScript/misc/das_common.h" #include "daScript/simulate/fs_file_info.h" -#include "../gen1-to-gen2/fmt.h" #include "daScript/ast/ast_aot_cpp.h" #include "daScript/ast/ast_serializer.h" #include "daScript/misc/crash_handler.h" @@ -648,7 +647,6 @@ void print_help() { << " -project_root root directory of the project (used for dyn modules)\n" << " -load_module directly load a single dynamic-module folder (the one containing .das_module); repeatable. Bypasses the project_root/modules/ scan and shadows same-basename entries from dasroot/project_root.\n" << " --disable-module never load/register the named dynamic module (case-insensitive folder match); repeatable. Keeps a native-only module (e.g. dashv) out of a wasm cross-compile so a guarded `require ?name` resolves as absent.\n" - << " -run-fmt <-i/-d> <-v2/-v1> {--semicolon} run formatter\n" << " -log output program code\n" << " -pause pause after errors and pause again before exiting program\n" << " -dry-run compile and simulate script without execution\n" @@ -748,7 +746,6 @@ int MAIN_FUNC_NAME ( int argc, char * argv[] ) { string project_root; vector load_modules; vector disabled_modules; - optional formatter; for ( int i=1; i < argc; ++i ) { if ( argv[i][0]=='-' ) { string cmd(argv[i]+1); @@ -883,38 +880,6 @@ int MAIN_FUNC_NAME ( int argc, char * argv[] ) { } disabled_modules.push_back(argv[i + 1]); i++; - } else if ( cmd=="run-fmt" ) { - formatter.emplace(); - if ( i+2 > argc ) { - printf("formatter requires 2 arguments\n"); - print_help(); - return -1; - } - const string mode = string(argv[i+1]); - if (mode == "-i" || mode == "--inplace") { - formatter->insert(format::FormatOpt::Inplace); - } else if (string(argv[i+1]) == "-d" || string(argv[i+1]) == "--dry") { - } else { - print_help(); - return -1; - } - i += 1; - const string to_v2 = string(argv[i+1]); - if (to_v2 == "-v2") { - formatter->insert(format::FormatOpt::V2Syntax); - } else if (to_v2 == "-v1") { - } else { - print_help(); - return -1; - } - i++; - - if (i + 1 < argc) { - if (string(argv[i + 1]) == "--semicolon") { - formatter->insert(format::FormatOpt::SemicolonEOL); - ++i; - } - } } else if ( cmd=="args" ) { break; } else if ( cmd=="pause" ) { @@ -1036,9 +1001,6 @@ int MAIN_FUNC_NAME ( int argc, char * argv[] ) { #endif Module::Initialize(); - if (formatter) { - return format::run(formatter.value(), files); - } // compile and run int exitCode = 0; if (!aotResult.empty() && files.size() > 1) { diff --git a/utils/gen1-to-gen2/Readme.md b/utils/gen1-to-gen2/Readme.md deleted file mode 100644 index 462399cb24..0000000000 --- a/utils/gen1-to-gen2/Readme.md +++ /dev/null @@ -1,46 +0,0 @@ -# Utility to convert syntax from v1 to v2 -## Key differences -First, you may want to check this [article about initialization](https://borisbat.github.io/dascf-blog/2024/07/23/data-initialization/). It describes most initialization expressions in both the old and new syntax. -However, some corner cases are missing, such as: -``` -// old -var a = new [[Foo#()]] -// will be converted to new -var a = new struct() -``` - -## How it works -Formatter tools generally operate at either token-level or the AST-level. -AST-level looks much easier to maintain, so I decided to use it. - -There's a copy of bison grammar corresponding to the v1 syntax. For required non-terminals I edited action on match. - -We maintain the `last_printed` position and once a rule that -should be replaced is matched -- Everything from `last_printed` up to this rule -is written directly to the `output` -- This rule is modified, and the position is updated. - -## Usage: -``` -./bin/gen1_to_gen2 file1.das file2.das -i -v2 -``` -There are two command line arguments (excluding input files): - -- The first determines whether the conversion should be done in-place (`-i`) -or printed to stdout(`-d`). - * If converter fails in first case it will do nothing. - * In second case it will print a partially converted file to stdout, which will not compile, -but can be fixed manually -- The second option is `-v1` or `-v2`, specifying whether to convert to gen1.5 syntax or to gen2 syntax. -This option is not required; by default files will be converted to gen1.5 - -I used this command to transform all `.das` files syntax in current folder in-place: -``` -find . -name "*.das" | tr '\n' ' ' | xargs ./bin/gen1_to_gen2 -i -``` -Afterward, I suggest running it again on failed files individually: -``` -./bin/gen1_to_gen2 -d -``` -This will at least partially format then, allowing you to manually edit the remaining parts. diff --git a/utils/gen1-to-gen2/ds_parser.cpp b/utils/gen1-to-gen2/ds_parser.cpp deleted file mode 100644 index 33f2c94a15..0000000000 --- a/utils/gen1-to-gen2/ds_parser.cpp +++ /dev/null @@ -1,13475 +0,0 @@ -/* A Bison parser, made by GNU Bison 3.8.2. */ - -/* Bison implementation for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, - Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, - especially those whose name start with YY_ or yy_. They are - private implementation details that can be changed or removed. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output, and Bison version. */ -#define YYBISON 30802 - -/* Bison version string. */ -#define YYBISON_VERSION "3.8.2" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 2 - -/* Push parsers. */ -#define YYPUSH 0 - -/* Pull parsers. */ -#define YYPULL 1 - -/* Substitute the type names. */ -#define YYSTYPE DAS_YYSTYPE -#define YYLTYPE DAS_YYLTYPE -/* Substitute the variable and function names. */ -#define yyparse das_yyparse -#define yylex das_yylex -#define yyerror das_yyerror -#define yydebug das_yydebug -#define yynerrs das_yynerrs - -/* First part of user prologue. */ - - #define das_yyparse fmt_yyparse // We can't change flex prefix, since we have only one lexer file, seems like to define is the best way - - #include "daScript/misc/platform.h" - #include "daScript/simulate/debug_info.h" - #include "daScript/ast/compilation_errors.h" - - #ifdef _MSC_VER - #pragma warning(disable:4262) - #pragma warning(disable:4127) - #pragma warning(disable:4702) - #endif - - using namespace das; - - union DAS_YYSTYPE; - struct DAS_YYLTYPE; - - #define YY_NO_UNISTD_H - #include "../src/parser/lex.yy.h" - - void das_yyerror ( DAS_YYLTYPE * lloc, yyscan_t scanner, const string & error ); - void das_yyfatalerror ( DAS_YYLTYPE * lloc, yyscan_t scanner, const string & error, CompilationError cerr ); - int yylex ( DAS_YYSTYPE *lvalp, DAS_YYLTYPE *llocp, yyscan_t scanner ); - void yybegin ( const char * str ); - - void das_yybegin_reader ( yyscan_t yyscanner ); - void das_yyend_reader ( yyscan_t yyscanner ); - void das_accept_sequence ( yyscan_t yyscanner, const char * seq, size_t seqLen, int lineNo, FileInfo * info ); - - namespace das { class Module; } - void das_collect_keywords ( das::Module * mod, yyscan_t yyscanner ); - void das_strfmt ( yyscan_t yyscanner ); - - #undef yyextra - #define yyextra (*((das::DasParserState **)(scanner))) - - -# ifndef YY_CAST -# ifdef __cplusplus -# define YY_CAST(Type, Val) static_cast (Val) -# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) -# else -# define YY_CAST(Type, Val) ((Type) (Val)) -# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) -# endif -# endif -# ifndef YY_NULLPTR -# if defined __cplusplus -# if 201103L <= __cplusplus -# define YY_NULLPTR nullptr -# else -# define YY_NULLPTR 0 -# endif -# else -# define YY_NULLPTR ((void*)0) -# endif -# endif - -#include "ds_parser.hpp" -/* Symbol kind. */ -enum yysymbol_kind_t -{ - YYSYMBOL_YYEMPTY = -2, - YYSYMBOL_YYEOF = 0, /* "end of file" */ - YYSYMBOL_YYerror = 1, /* error */ - YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ - YYSYMBOL_LEXER_ERROR = 3, /* "lexer error" */ - YYSYMBOL_DAS_CAPTURE = 4, /* "capture" */ - YYSYMBOL_DAS_STRUCT = 5, /* "struct" */ - YYSYMBOL_DAS_CLASS = 6, /* "class" */ - YYSYMBOL_DAS_LET = 7, /* "let" */ - YYSYMBOL_DAS_DEF = 8, /* "def" */ - YYSYMBOL_DAS_WHILE = 9, /* "while" */ - YYSYMBOL_DAS_IF = 10, /* "if" */ - YYSYMBOL_DAS_STATIC_IF = 11, /* "static_if" */ - YYSYMBOL_DAS_ELSE = 12, /* "else" */ - YYSYMBOL_DAS_FOR = 13, /* "for" */ - YYSYMBOL_DAS_CATCH = 14, /* "recover" */ - YYSYMBOL_DAS_TRUE = 15, /* "true" */ - YYSYMBOL_DAS_FALSE = 16, /* "false" */ - YYSYMBOL_DAS_NEWT = 17, /* "new" */ - YYSYMBOL_DAS_TYPEINFO = 18, /* "typeinfo" */ - YYSYMBOL_DAS_TYPE = 19, /* "type" */ - YYSYMBOL_DAS_IN = 20, /* "in" */ - YYSYMBOL_DAS_IS = 21, /* "is" */ - YYSYMBOL_DAS_AS = 22, /* "as" */ - YYSYMBOL_DAS_ELIF = 23, /* "elif" */ - YYSYMBOL_DAS_STATIC_ELIF = 24, /* "static_elif" */ - YYSYMBOL_DAS_ARRAY = 25, /* "array" */ - YYSYMBOL_DAS_RETURN = 26, /* "return" */ - YYSYMBOL_DAS_NULL = 27, /* "null" */ - YYSYMBOL_DAS_BREAK = 28, /* "break" */ - YYSYMBOL_DAS_TRY = 29, /* "try" */ - YYSYMBOL_DAS_OPTIONS = 30, /* "options" */ - YYSYMBOL_DAS_TABLE = 31, /* "table" */ - YYSYMBOL_DAS_EXPECT = 32, /* "expect" */ - YYSYMBOL_DAS_CONST = 33, /* "const" */ - YYSYMBOL_DAS_REQUIRE = 34, /* "require" */ - YYSYMBOL_DAS_OPERATOR = 35, /* "operator" */ - YYSYMBOL_DAS_ENUM = 36, /* "enum" */ - YYSYMBOL_DAS_FINALLY = 37, /* "finally" */ - YYSYMBOL_DAS_DELETE = 38, /* "delete" */ - YYSYMBOL_DAS_DEREF = 39, /* "deref" */ - YYSYMBOL_DAS_TYPEDEF = 40, /* "typedef" */ - YYSYMBOL_DAS_TYPEDECL = 41, /* "typedecl" */ - YYSYMBOL_DAS_WITH = 42, /* "with" */ - YYSYMBOL_DAS_AKA = 43, /* "aka" */ - YYSYMBOL_DAS_ASSUME = 44, /* "assume" */ - YYSYMBOL_DAS_CAST = 45, /* "cast" */ - YYSYMBOL_DAS_OVERRIDE = 46, /* "override" */ - YYSYMBOL_DAS_ABSTRACT = 47, /* "abstract" */ - YYSYMBOL_DAS_UPCAST = 48, /* "upcast" */ - YYSYMBOL_DAS_ITERATOR = 49, /* "iterator" */ - YYSYMBOL_DAS_VAR = 50, /* "var" */ - YYSYMBOL_DAS_ADDR = 51, /* "addr" */ - YYSYMBOL_DAS_CONTINUE = 52, /* "continue" */ - YYSYMBOL_DAS_WHERE = 53, /* "where" */ - YYSYMBOL_DAS_PASS = 54, /* "pass" */ - YYSYMBOL_DAS_REINTERPRET = 55, /* "reinterpret" */ - YYSYMBOL_DAS_MODULE = 56, /* "module" */ - YYSYMBOL_DAS_PUBLIC = 57, /* "public" */ - YYSYMBOL_DAS_LABEL = 58, /* "label" */ - YYSYMBOL_DAS_GOTO = 59, /* "goto" */ - YYSYMBOL_DAS_IMPLICIT = 60, /* "implicit" */ - YYSYMBOL_DAS_EXPLICIT = 61, /* "explicit" */ - YYSYMBOL_DAS_SHARED = 62, /* "shared" */ - YYSYMBOL_DAS_PRIVATE = 63, /* "private" */ - YYSYMBOL_DAS_SMART_PTR = 64, /* "smart_ptr" */ - YYSYMBOL_DAS_UNSAFE = 65, /* "unsafe" */ - YYSYMBOL_DAS_INSCOPE = 66, /* "inscope" */ - YYSYMBOL_DAS_STATIC = 67, /* "static" */ - YYSYMBOL_DAS_FIXED_ARRAY = 68, /* "fixed_array" */ - YYSYMBOL_DAS_DEFAULT = 69, /* "default" */ - YYSYMBOL_DAS_UNINITIALIZED = 70, /* "uninitialized" */ - YYSYMBOL_DAS_TBOOL = 71, /* "bool" */ - YYSYMBOL_DAS_TVOID = 72, /* "void" */ - YYSYMBOL_DAS_TSTRING = 73, /* "string" */ - YYSYMBOL_DAS_TAUTO = 74, /* "auto" */ - YYSYMBOL_DAS_TINT = 75, /* "int" */ - YYSYMBOL_DAS_TINT2 = 76, /* "int2" */ - YYSYMBOL_DAS_TINT3 = 77, /* "int3" */ - YYSYMBOL_DAS_TINT4 = 78, /* "int4" */ - YYSYMBOL_DAS_TUINT = 79, /* "uint" */ - YYSYMBOL_DAS_TBITFIELD = 80, /* "bitfield" */ - YYSYMBOL_DAS_TUINT2 = 81, /* "uint2" */ - YYSYMBOL_DAS_TUINT3 = 82, /* "uint3" */ - YYSYMBOL_DAS_TUINT4 = 83, /* "uint4" */ - YYSYMBOL_DAS_TFLOAT = 84, /* "float" */ - YYSYMBOL_DAS_TFLOAT2 = 85, /* "float2" */ - YYSYMBOL_DAS_TFLOAT3 = 86, /* "float3" */ - YYSYMBOL_DAS_TFLOAT4 = 87, /* "float4" */ - YYSYMBOL_DAS_TRANGE = 88, /* "range" */ - YYSYMBOL_DAS_TURANGE = 89, /* "urange" */ - YYSYMBOL_DAS_TRANGE64 = 90, /* "range64" */ - YYSYMBOL_DAS_TURANGE64 = 91, /* "urange64" */ - YYSYMBOL_DAS_TBLOCK = 92, /* "block" */ - YYSYMBOL_DAS_TINT64 = 93, /* "int64" */ - YYSYMBOL_DAS_TUINT64 = 94, /* "uint64" */ - YYSYMBOL_DAS_TDOUBLE = 95, /* "double" */ - YYSYMBOL_DAS_TFUNCTION = 96, /* "function" */ - YYSYMBOL_DAS_TLAMBDA = 97, /* "lambda" */ - YYSYMBOL_DAS_TINT8 = 98, /* "int8" */ - YYSYMBOL_DAS_TUINT8 = 99, /* "uint8" */ - YYSYMBOL_DAS_TINT16 = 100, /* "int16" */ - YYSYMBOL_DAS_TUINT16 = 101, /* "uint16" */ - YYSYMBOL_DAS_TFLOAT16 = 102, /* "float16" */ - YYSYMBOL_DAS_THALF2 = 103, /* "half2" */ - YYSYMBOL_DAS_THALF3 = 104, /* "half3" */ - YYSYMBOL_DAS_THALF4 = 105, /* "half4" */ - YYSYMBOL_DAS_THALF8 = 106, /* "half8" */ - YYSYMBOL_DAS_TSHORT2 = 107, /* "short2" */ - YYSYMBOL_DAS_TSHORT3 = 108, /* "short3" */ - YYSYMBOL_DAS_TSHORT4 = 109, /* "short4" */ - YYSYMBOL_DAS_TSHORT8 = 110, /* "short8" */ - YYSYMBOL_DAS_TUSHORT2 = 111, /* "ushort2" */ - YYSYMBOL_DAS_TUSHORT3 = 112, /* "ushort3" */ - YYSYMBOL_DAS_TUSHORT4 = 113, /* "ushort4" */ - YYSYMBOL_DAS_TUSHORT8 = 114, /* "ushort8" */ - YYSYMBOL_DAS_TBYTE2 = 115, /* "byte2" */ - YYSYMBOL_DAS_TBYTE3 = 116, /* "byte3" */ - YYSYMBOL_DAS_TBYTE4 = 117, /* "byte4" */ - YYSYMBOL_DAS_TBYTE8 = 118, /* "byte8" */ - YYSYMBOL_DAS_TBYTE16 = 119, /* "byte16" */ - YYSYMBOL_DAS_TUBYTE2 = 120, /* "ubyte2" */ - YYSYMBOL_DAS_TUBYTE3 = 121, /* "ubyte3" */ - YYSYMBOL_DAS_TUBYTE4 = 122, /* "ubyte4" */ - YYSYMBOL_DAS_TUBYTE8 = 123, /* "ubyte8" */ - YYSYMBOL_DAS_TUBYTE16 = 124, /* "ubyte16" */ - YYSYMBOL_DAS_TTUPLE = 125, /* "tuple" */ - YYSYMBOL_DAS_TVARIANT = 126, /* "variant" */ - YYSYMBOL_DAS_GENERATOR = 127, /* "generator" */ - YYSYMBOL_DAS_YIELD = 128, /* "yield" */ - YYSYMBOL_DAS_SEALED = 129, /* "sealed" */ - YYSYMBOL_DAS_TEMPLATE = 130, /* "template" */ - YYSYMBOL_ADDEQU = 131, /* "+=" */ - YYSYMBOL_SUBEQU = 132, /* "-=" */ - YYSYMBOL_DIVEQU = 133, /* "/=" */ - YYSYMBOL_MULEQU = 134, /* "*=" */ - YYSYMBOL_MODEQU = 135, /* "%=" */ - YYSYMBOL_ANDEQU = 136, /* "&=" */ - YYSYMBOL_OREQU = 137, /* "|=" */ - YYSYMBOL_XOREQU = 138, /* "^=" */ - YYSYMBOL_SHL = 139, /* "<<" */ - YYSYMBOL_SHR = 140, /* ">>" */ - YYSYMBOL_ADDADD = 141, /* "++" */ - YYSYMBOL_SUBSUB = 142, /* "--" */ - YYSYMBOL_LEEQU = 143, /* "<=" */ - YYSYMBOL_SHLEQU = 144, /* "<<=" */ - YYSYMBOL_SHREQU = 145, /* ">>=" */ - YYSYMBOL_GREQU = 146, /* ">=" */ - YYSYMBOL_EQUEQU = 147, /* "==" */ - YYSYMBOL_NOTEQU = 148, /* "!=" */ - YYSYMBOL_RARROW = 149, /* "->" */ - YYSYMBOL_LARROW = 150, /* "<-" */ - YYSYMBOL_QQ = 151, /* "??" */ - YYSYMBOL_QDOT = 152, /* "?." */ - YYSYMBOL_QBRA = 153, /* "?[" */ - YYSYMBOL_LPIPE = 154, /* "<|" */ - YYSYMBOL_LBPIPE = 155, /* " <|" */ - YYSYMBOL_LLPIPE = 156, /* "$ <|" */ - YYSYMBOL_LAPIPE = 157, /* "@ <|" */ - YYSYMBOL_LFPIPE = 158, /* "@@ <|" */ - YYSYMBOL_RPIPE = 159, /* "|>" */ - YYSYMBOL_CLONEEQU = 160, /* ":=" */ - YYSYMBOL_ROTL = 161, /* "<<<" */ - YYSYMBOL_ROTR = 162, /* ">>>" */ - YYSYMBOL_ROTLEQU = 163, /* "<<<=" */ - YYSYMBOL_ROTREQU = 164, /* ">>>=" */ - YYSYMBOL_MAPTO = 165, /* "=>" */ - YYSYMBOL_COLCOL = 166, /* "::" */ - YYSYMBOL_ANDAND = 167, /* "&&" */ - YYSYMBOL_OROR = 168, /* "||" */ - YYSYMBOL_XORXOR = 169, /* "^^" */ - YYSYMBOL_ANDANDEQU = 170, /* "&&=" */ - YYSYMBOL_OROREQU = 171, /* "||=" */ - YYSYMBOL_XORXOREQU = 172, /* "^^=" */ - YYSYMBOL_DOTDOT = 173, /* ".." */ - YYSYMBOL_MTAG_E = 174, /* "$$" */ - YYSYMBOL_MTAG_I = 175, /* "$i" */ - YYSYMBOL_MTAG_V = 176, /* "$v" */ - YYSYMBOL_MTAG_B = 177, /* "$b" */ - YYSYMBOL_MTAG_A = 178, /* "$a" */ - YYSYMBOL_MTAG_T = 179, /* "$t" */ - YYSYMBOL_MTAG_C = 180, /* "$c" */ - YYSYMBOL_MTAG_F = 181, /* "$f" */ - YYSYMBOL_MTAG_DOTDOTDOT = 182, /* "..." */ - YYSYMBOL_BRABRAB = 183, /* "[[" */ - YYSYMBOL_BRACBRB = 184, /* "[{" */ - YYSYMBOL_CBRCBRB = 185, /* "{{" */ - YYSYMBOL_OPEN_BRACE = 186, /* "new scope" */ - YYSYMBOL_CLOSE_BRACE = 187, /* "close scope" */ - YYSYMBOL_SEMICOLON = 188, /* SEMICOLON */ - YYSYMBOL_INTEGER = 189, /* "integer constant" */ - YYSYMBOL_LONG_INTEGER = 190, /* "long integer constant" */ - YYSYMBOL_UNSIGNED_INTEGER = 191, /* "unsigned integer constant" */ - YYSYMBOL_UNSIGNED_LONG_INTEGER = 192, /* "unsigned long integer constant" */ - YYSYMBOL_UNSIGNED_INT8 = 193, /* "unsigned int8 constant" */ - YYSYMBOL_DAS_FLOAT = 194, /* "floating point constant" */ - YYSYMBOL_DAS_FLOAT16_CONST = 195, /* "float16 constant" */ - YYSYMBOL_DOUBLE = 196, /* "double constant" */ - YYSYMBOL_NAME = 197, /* "name" */ - YYSYMBOL_KEYWORD = 198, /* "keyword" */ - YYSYMBOL_TYPE_FUNCTION = 199, /* "type function" */ - YYSYMBOL_BEGIN_STRING = 200, /* "start of the string" */ - YYSYMBOL_STRING_CHARACTER = 201, /* STRING_CHARACTER */ - YYSYMBOL_STRING_CHARACTER_ESC = 202, /* STRING_CHARACTER_ESC */ - YYSYMBOL_END_STRING = 203, /* "end of the string" */ - YYSYMBOL_BEGIN_STRING_EXPR = 204, /* "{" */ - YYSYMBOL_END_STRING_EXPR = 205, /* "}" */ - YYSYMBOL_END_OF_READ = 206, /* "end of failed eader macro" */ - YYSYMBOL_207_begin_of_code_block_ = 207, /* "begin of code block" */ - YYSYMBOL_208_end_of_code_block_ = 208, /* "end of code block" */ - YYSYMBOL_209_end_of_expression_ = 209, /* "end of expression" */ - YYSYMBOL_SEMICOLON_CUR_CUR = 210, /* ";}}" */ - YYSYMBOL_SEMICOLON_CUR_SQR = 211, /* ";}]" */ - YYSYMBOL_SEMICOLON_SQR_SQR = 212, /* ";]]" */ - YYSYMBOL_COMMA_SQR_SQR = 213, /* ",]]" */ - YYSYMBOL_COMMA_CUR_SQR = 214, /* ",}]" */ - YYSYMBOL_END_OF_EXPR = 215, /* END_OF_EXPR */ - YYSYMBOL_EMPTY = 216, /* EMPTY */ - YYSYMBOL_217_ = 217, /* ',' */ - YYSYMBOL_218_ = 218, /* '=' */ - YYSYMBOL_219_ = 219, /* '?' */ - YYSYMBOL_220_ = 220, /* ':' */ - YYSYMBOL_221_ = 221, /* '|' */ - YYSYMBOL_222_ = 222, /* '^' */ - YYSYMBOL_223_ = 223, /* '&' */ - YYSYMBOL_224_ = 224, /* '<' */ - YYSYMBOL_225_ = 225, /* '>' */ - YYSYMBOL_226_ = 226, /* '-' */ - YYSYMBOL_227_ = 227, /* '+' */ - YYSYMBOL_228_ = 228, /* '*' */ - YYSYMBOL_229_ = 229, /* '/' */ - YYSYMBOL_230_ = 230, /* '%' */ - YYSYMBOL_UNARY_MINUS = 231, /* UNARY_MINUS */ - YYSYMBOL_UNARY_PLUS = 232, /* UNARY_PLUS */ - YYSYMBOL_233_ = 233, /* '~' */ - YYSYMBOL_234_ = 234, /* '!' */ - YYSYMBOL_PRE_INC = 235, /* PRE_INC */ - YYSYMBOL_PRE_DEC = 236, /* PRE_DEC */ - YYSYMBOL_POST_INC = 237, /* POST_INC */ - YYSYMBOL_POST_DEC = 238, /* POST_DEC */ - YYSYMBOL_DEREF = 239, /* DEREF */ - YYSYMBOL_240_ = 240, /* '.' */ - YYSYMBOL_241_ = 241, /* '[' */ - YYSYMBOL_242_ = 242, /* ']' */ - YYSYMBOL_243_ = 243, /* '(' */ - YYSYMBOL_244_ = 244, /* ')' */ - YYSYMBOL_245_ = 245, /* '$' */ - YYSYMBOL_246_ = 246, /* '@' */ - YYSYMBOL_247_ = 247, /* '#' */ - YYSYMBOL_YYACCEPT = 248, /* $accept */ - YYSYMBOL_program = 249, /* program */ - YYSYMBOL_semicolon = 250, /* semicolon */ - YYSYMBOL_top_level_reader_macro = 251, /* top_level_reader_macro */ - YYSYMBOL_optional_public_or_private_module = 252, /* optional_public_or_private_module */ - YYSYMBOL_module_name = 253, /* module_name */ - YYSYMBOL_optional_not_required = 254, /* optional_not_required */ - YYSYMBOL_module_declaration = 255, /* module_declaration */ - YYSYMBOL_character_sequence = 256, /* character_sequence */ - YYSYMBOL_string_constant = 257, /* string_constant */ - YYSYMBOL_format_string = 258, /* format_string */ - YYSYMBOL_optional_format_string = 259, /* optional_format_string */ - YYSYMBOL_260_1 = 260, /* $@1 */ - YYSYMBOL_string_builder_body = 261, /* string_builder_body */ - YYSYMBOL_string_builder = 262, /* string_builder */ - YYSYMBOL_reader_character_sequence = 263, /* reader_character_sequence */ - YYSYMBOL_expr_reader = 264, /* expr_reader */ - YYSYMBOL_265_2 = 265, /* $@2 */ - YYSYMBOL_options_declaration = 266, /* options_declaration */ - YYSYMBOL_require_declaration = 267, /* require_declaration */ - YYSYMBOL_keyword_or_name = 268, /* keyword_or_name */ - YYSYMBOL_require_module_name = 269, /* require_module_name */ - YYSYMBOL_require_module = 270, /* require_module */ - YYSYMBOL_is_public_module = 271, /* is_public_module */ - YYSYMBOL_expect_declaration = 272, /* expect_declaration */ - YYSYMBOL_expect_list = 273, /* expect_list */ - YYSYMBOL_expect_error = 274, /* expect_error */ - YYSYMBOL_expression_label = 275, /* expression_label */ - YYSYMBOL_expression_goto = 276, /* expression_goto */ - YYSYMBOL_elif_or_static_elif = 277, /* elif_or_static_elif */ - YYSYMBOL_expression_else = 278, /* expression_else */ - YYSYMBOL_if_or_static_if = 279, /* if_or_static_if */ - YYSYMBOL_expression_else_one_liner = 280, /* expression_else_one_liner */ - YYSYMBOL_281_3 = 281, /* $@3 */ - YYSYMBOL_expression_if_one_liner = 282, /* expression_if_one_liner */ - YYSYMBOL_expression_if_then_else = 283, /* expression_if_then_else */ - YYSYMBOL_284_4 = 284, /* $@4 */ - YYSYMBOL_expression_for_loop = 285, /* expression_for_loop */ - YYSYMBOL_286_5 = 286, /* $@5 */ - YYSYMBOL_287_6 = 287, /* $@6 */ - YYSYMBOL_expression_unsafe = 288, /* expression_unsafe */ - YYSYMBOL_expression_while_loop = 289, /* expression_while_loop */ - YYSYMBOL_expression_with = 290, /* expression_with */ - YYSYMBOL_expression_with_alias = 291, /* expression_with_alias */ - YYSYMBOL_292_7 = 292, /* $@7 */ - YYSYMBOL_293_8 = 293, /* $@8 */ - YYSYMBOL_annotation_argument_value = 294, /* annotation_argument_value */ - YYSYMBOL_annotation_argument_value_list = 295, /* annotation_argument_value_list */ - YYSYMBOL_annotation_argument_name = 296, /* annotation_argument_name */ - YYSYMBOL_annotation_argument = 297, /* annotation_argument */ - YYSYMBOL_annotation_argument_list = 298, /* annotation_argument_list */ - YYSYMBOL_metadata_argument_list = 299, /* metadata_argument_list */ - YYSYMBOL_annotation_declaration_name = 300, /* annotation_declaration_name */ - YYSYMBOL_annotation_declaration_basic = 301, /* annotation_declaration_basic */ - YYSYMBOL_annotation_declaration = 302, /* annotation_declaration */ - YYSYMBOL_annotation_list = 303, /* annotation_list */ - YYSYMBOL_optional_annotation_list = 304, /* optional_annotation_list */ - YYSYMBOL_optional_function_argument_list = 305, /* optional_function_argument_list */ - YYSYMBOL_optional_function_type = 306, /* optional_function_type */ - YYSYMBOL_function_name = 307, /* function_name */ - YYSYMBOL_optional_template = 308, /* optional_template */ - YYSYMBOL_global_function_declaration = 309, /* global_function_declaration */ - YYSYMBOL_optional_public_or_private_function = 310, /* optional_public_or_private_function */ - YYSYMBOL_function_declaration_header = 311, /* function_declaration_header */ - YYSYMBOL_function_declaration = 312, /* function_declaration */ - YYSYMBOL_313_9 = 313, /* $@9 */ - YYSYMBOL_open_block = 314, /* open_block */ - YYSYMBOL_close_block = 315, /* close_block */ - YYSYMBOL_expression_block = 316, /* expression_block */ - YYSYMBOL_expr_call_pipe = 317, /* expr_call_pipe */ - YYSYMBOL_expression_any = 318, /* expression_any */ - YYSYMBOL_expressions = 319, /* expressions */ - YYSYMBOL_expr_keyword = 320, /* expr_keyword */ - YYSYMBOL_optional_expr_list = 321, /* optional_expr_list */ - YYSYMBOL_optional_expr_list_in_braces = 322, /* optional_expr_list_in_braces */ - YYSYMBOL_optional_expr_map_tuple_list = 323, /* optional_expr_map_tuple_list */ - YYSYMBOL_type_declaration_no_options_list = 324, /* type_declaration_no_options_list */ - YYSYMBOL_expression_keyword = 325, /* expression_keyword */ - YYSYMBOL_326_10 = 326, /* $@10 */ - YYSYMBOL_327_11 = 327, /* $@11 */ - YYSYMBOL_328_12 = 328, /* $@12 */ - YYSYMBOL_329_13 = 329, /* $@13 */ - YYSYMBOL_expr_pipe = 330, /* expr_pipe */ - YYSYMBOL_name_in_namespace = 331, /* name_in_namespace */ - YYSYMBOL_expression_delete = 332, /* expression_delete */ - YYSYMBOL_new_type_declaration = 333, /* new_type_declaration */ - YYSYMBOL_334_14 = 334, /* $@14 */ - YYSYMBOL_335_15 = 335, /* $@15 */ - YYSYMBOL_expr_new = 336, /* expr_new */ - YYSYMBOL_expression_break = 337, /* expression_break */ - YYSYMBOL_expression_continue = 338, /* expression_continue */ - YYSYMBOL_expression_return_no_pipe = 339, /* expression_return_no_pipe */ - YYSYMBOL_expression_return = 340, /* expression_return */ - YYSYMBOL_expression_yield_no_pipe = 341, /* expression_yield_no_pipe */ - YYSYMBOL_expression_yield = 342, /* expression_yield */ - YYSYMBOL_expression_try_catch = 343, /* expression_try_catch */ - YYSYMBOL_kwd_let_var_or_nothing = 344, /* kwd_let_var_or_nothing */ - YYSYMBOL_kwd_let = 345, /* kwd_let */ - YYSYMBOL_optional_in_scope = 346, /* optional_in_scope */ - YYSYMBOL_tuple_expansion = 347, /* tuple_expansion */ - YYSYMBOL_tuple_expansion_variable_declaration = 348, /* tuple_expansion_variable_declaration */ - YYSYMBOL_expression_let = 349, /* expression_let */ - YYSYMBOL_expr_cast = 350, /* expr_cast */ - YYSYMBOL_351_16 = 351, /* $@16 */ - YYSYMBOL_352_17 = 352, /* $@17 */ - YYSYMBOL_353_18 = 353, /* $@18 */ - YYSYMBOL_354_19 = 354, /* $@19 */ - YYSYMBOL_355_20 = 355, /* $@20 */ - YYSYMBOL_356_21 = 356, /* $@21 */ - YYSYMBOL_expr_type_decl = 357, /* expr_type_decl */ - YYSYMBOL_358_22 = 358, /* $@22 */ - YYSYMBOL_359_23 = 359, /* $@23 */ - YYSYMBOL_expr_type_info = 360, /* expr_type_info */ - YYSYMBOL_expr_list = 361, /* expr_list */ - YYSYMBOL_block_or_simple_block = 362, /* block_or_simple_block */ - YYSYMBOL_block_or_lambda = 363, /* block_or_lambda */ - YYSYMBOL_capture_entry = 364, /* capture_entry */ - YYSYMBOL_capture_list = 365, /* capture_list */ - YYSYMBOL_optional_capture_list = 366, /* optional_capture_list */ - YYSYMBOL_expr_block = 367, /* expr_block */ - YYSYMBOL_expr_full_block = 368, /* expr_full_block */ - YYSYMBOL_expr_full_block_assumed_piped = 369, /* expr_full_block_assumed_piped */ - YYSYMBOL_370_24 = 370, /* $@24 */ - YYSYMBOL_expr_numeric_const = 371, /* expr_numeric_const */ - YYSYMBOL_expr_assign = 372, /* expr_assign */ - YYSYMBOL_expr_assign_pipe_right = 373, /* expr_assign_pipe_right */ - YYSYMBOL_expr_assign_pipe = 374, /* expr_assign_pipe */ - YYSYMBOL_expr_named_call = 375, /* expr_named_call */ - YYSYMBOL_expr_method_call = 376, /* expr_method_call */ - YYSYMBOL_func_addr_name = 377, /* func_addr_name */ - YYSYMBOL_func_addr_expr = 378, /* func_addr_expr */ - YYSYMBOL_379_25 = 379, /* $@25 */ - YYSYMBOL_380_26 = 380, /* $@26 */ - YYSYMBOL_381_27 = 381, /* $@27 */ - YYSYMBOL_382_28 = 382, /* $@28 */ - YYSYMBOL_expr_field = 383, /* expr_field */ - YYSYMBOL_384_29 = 384, /* $@29 */ - YYSYMBOL_385_30 = 385, /* $@30 */ - YYSYMBOL_expr_call = 386, /* expr_call */ - YYSYMBOL_expr2 = 387, /* expr2 */ - YYSYMBOL_388_31 = 388, /* $@31 */ - YYSYMBOL_389_32 = 389, /* $@32 */ - YYSYMBOL_390_33 = 390, /* $@33 */ - YYSYMBOL_391_34 = 391, /* $@34 */ - YYSYMBOL_392_35 = 392, /* $@35 */ - YYSYMBOL_393_36 = 393, /* $@36 */ - YYSYMBOL_expr = 394, /* expr */ - YYSYMBOL_expr_mtag = 395, /* expr_mtag */ - YYSYMBOL_optional_field_annotation = 396, /* optional_field_annotation */ - YYSYMBOL_optional_override = 397, /* optional_override */ - YYSYMBOL_optional_constant = 398, /* optional_constant */ - YYSYMBOL_optional_public_or_private_member_variable = 399, /* optional_public_or_private_member_variable */ - YYSYMBOL_optional_static_member_variable = 400, /* optional_static_member_variable */ - YYSYMBOL_structure_variable_declaration = 401, /* structure_variable_declaration */ - YYSYMBOL_opt_sem = 402, /* opt_sem */ - YYSYMBOL_struct_variable_declaration_list = 403, /* struct_variable_declaration_list */ - YYSYMBOL_404_37 = 404, /* $@37 */ - YYSYMBOL_405_38 = 405, /* $@38 */ - YYSYMBOL_406_39 = 406, /* $@39 */ - YYSYMBOL_407_40 = 407, /* $@40 */ - YYSYMBOL_function_argument_declaration_no_type = 408, /* function_argument_declaration_no_type */ - YYSYMBOL_function_argument_declaration_type = 409, /* function_argument_declaration_type */ - YYSYMBOL_function_argument_list = 410, /* function_argument_list */ - YYSYMBOL_tuple_type = 411, /* tuple_type */ - YYSYMBOL_tuple_type_list = 412, /* tuple_type_list */ - YYSYMBOL_tuple_alias_type_list = 413, /* tuple_alias_type_list */ - YYSYMBOL_variant_type = 414, /* variant_type */ - YYSYMBOL_variant_type_list = 415, /* variant_type_list */ - YYSYMBOL_variant_alias_type_list = 416, /* variant_alias_type_list */ - YYSYMBOL_copy_or_move = 417, /* copy_or_move */ - YYSYMBOL_variable_declaration_no_type = 418, /* variable_declaration_no_type */ - YYSYMBOL_variable_declaration_type = 419, /* variable_declaration_type */ - YYSYMBOL_variable_declaration = 420, /* variable_declaration */ - YYSYMBOL_copy_or_move_or_clone = 421, /* copy_or_move_or_clone */ - YYSYMBOL_optional_ref = 422, /* optional_ref */ - YYSYMBOL_let_variable_name_with_pos_list = 423, /* let_variable_name_with_pos_list */ - YYSYMBOL_let_variable_declaration = 424, /* let_variable_declaration */ - YYSYMBOL_global_variable_declaration_list = 425, /* global_variable_declaration_list */ - YYSYMBOL_426_41 = 426, /* $@41 */ - YYSYMBOL_optional_shared = 427, /* optional_shared */ - YYSYMBOL_optional_public_or_private_variable = 428, /* optional_public_or_private_variable */ - YYSYMBOL_global_let = 429, /* global_let */ - YYSYMBOL_430_42 = 430, /* $@42 */ - YYSYMBOL_enum_list = 431, /* enum_list */ - YYSYMBOL_optional_public_or_private_alias = 432, /* optional_public_or_private_alias */ - YYSYMBOL_single_alias = 433, /* single_alias */ - YYSYMBOL_434_43 = 434, /* $@43 */ - YYSYMBOL_alias_list = 435, /* alias_list */ - YYSYMBOL_alias_declaration = 436, /* alias_declaration */ - YYSYMBOL_437_44 = 437, /* $@44 */ - YYSYMBOL_optional_public_or_private_enum = 438, /* optional_public_or_private_enum */ - YYSYMBOL_enum_name = 439, /* enum_name */ - YYSYMBOL_enum_declaration = 440, /* enum_declaration */ - YYSYMBOL_optional_structure_parent = 441, /* optional_structure_parent */ - YYSYMBOL_optional_sealed = 442, /* optional_sealed */ - YYSYMBOL_structure_name = 443, /* structure_name */ - YYSYMBOL_class_or_struct = 444, /* class_or_struct */ - YYSYMBOL_optional_public_or_private_structure = 445, /* optional_public_or_private_structure */ - YYSYMBOL_optional_struct_variable_declaration_list = 446, /* optional_struct_variable_declaration_list */ - YYSYMBOL_structure_declaration = 447, /* structure_declaration */ - YYSYMBOL_448_45 = 448, /* $@45 */ - YYSYMBOL_449_46 = 449, /* $@46 */ - YYSYMBOL_variable_name_with_pos_list = 450, /* variable_name_with_pos_list */ - YYSYMBOL_basic_type_declaration = 451, /* basic_type_declaration */ - YYSYMBOL_enum_basic_type_declaration = 452, /* enum_basic_type_declaration */ - YYSYMBOL_structure_type_declaration = 453, /* structure_type_declaration */ - YYSYMBOL_auto_type_declaration = 454, /* auto_type_declaration */ - YYSYMBOL_bitfield_bits = 455, /* bitfield_bits */ - YYSYMBOL_commas = 456, /* commas */ - YYSYMBOL_bitfield_alias_bits = 457, /* bitfield_alias_bits */ - YYSYMBOL_bitfield_basic_type_declaration = 458, /* bitfield_basic_type_declaration */ - YYSYMBOL_bitfield_type_declaration = 459, /* bitfield_type_declaration */ - YYSYMBOL_460_47 = 460, /* $@47 */ - YYSYMBOL_461_48 = 461, /* $@48 */ - YYSYMBOL_c_or_s = 462, /* c_or_s */ - YYSYMBOL_table_type_pair = 463, /* table_type_pair */ - YYSYMBOL_dim_list = 464, /* dim_list */ - YYSYMBOL_type_declaration_no_options = 465, /* type_declaration_no_options */ - YYSYMBOL_466_49 = 466, /* $@49 */ - YYSYMBOL_467_50 = 467, /* $@50 */ - YYSYMBOL_468_51 = 468, /* $@51 */ - YYSYMBOL_469_52 = 469, /* $@52 */ - YYSYMBOL_470_53 = 470, /* $@53 */ - YYSYMBOL_471_54 = 471, /* $@54 */ - YYSYMBOL_472_55 = 472, /* $@55 */ - YYSYMBOL_473_56 = 473, /* $@56 */ - YYSYMBOL_474_57 = 474, /* $@57 */ - YYSYMBOL_475_58 = 475, /* $@58 */ - YYSYMBOL_476_59 = 476, /* $@59 */ - YYSYMBOL_477_60 = 477, /* $@60 */ - YYSYMBOL_478_61 = 478, /* $@61 */ - YYSYMBOL_479_62 = 479, /* $@62 */ - YYSYMBOL_480_63 = 480, /* $@63 */ - YYSYMBOL_481_64 = 481, /* $@64 */ - YYSYMBOL_482_65 = 482, /* $@65 */ - YYSYMBOL_483_66 = 483, /* $@66 */ - YYSYMBOL_484_67 = 484, /* $@67 */ - YYSYMBOL_485_68 = 485, /* $@68 */ - YYSYMBOL_486_69 = 486, /* $@69 */ - YYSYMBOL_487_70 = 487, /* $@70 */ - YYSYMBOL_488_71 = 488, /* $@71 */ - YYSYMBOL_489_72 = 489, /* $@72 */ - YYSYMBOL_490_73 = 490, /* $@73 */ - YYSYMBOL_491_74 = 491, /* $@74 */ - YYSYMBOL_492_75 = 492, /* $@75 */ - YYSYMBOL_type_declaration = 493, /* type_declaration */ - YYSYMBOL_tuple_alias_declaration = 494, /* tuple_alias_declaration */ - YYSYMBOL_495_76 = 495, /* $@76 */ - YYSYMBOL_496_77 = 496, /* $@77 */ - YYSYMBOL_497_78 = 497, /* $@78 */ - YYSYMBOL_498_79 = 498, /* $@79 */ - YYSYMBOL_variant_alias_declaration = 499, /* variant_alias_declaration */ - YYSYMBOL_500_80 = 500, /* $@80 */ - YYSYMBOL_501_81 = 501, /* $@81 */ - YYSYMBOL_502_82 = 502, /* $@82 */ - YYSYMBOL_503_83 = 503, /* $@83 */ - YYSYMBOL_bitfield_alias_declaration = 504, /* bitfield_alias_declaration */ - YYSYMBOL_505_84 = 505, /* $@84 */ - YYSYMBOL_506_85 = 506, /* $@85 */ - YYSYMBOL_make_decl = 507, /* make_decl */ - YYSYMBOL_make_struct_fields = 508, /* make_struct_fields */ - YYSYMBOL_make_variant_dim = 509, /* make_variant_dim */ - YYSYMBOL_make_struct_single = 510, /* make_struct_single */ - YYSYMBOL_make_struct_dim = 511, /* make_struct_dim */ - YYSYMBOL_make_struct_dim_list = 512, /* make_struct_dim_list */ - YYSYMBOL_make_struct_dim_decl = 513, /* make_struct_dim_decl */ - YYSYMBOL_optional_make_struct_dim_decl = 514, /* optional_make_struct_dim_decl */ - YYSYMBOL_optional_block = 515, /* optional_block */ - YYSYMBOL_optional_trailing_semicolon_cur_cur = 516, /* optional_trailing_semicolon_cur_cur */ - YYSYMBOL_optional_trailing_semicolon_cur_sqr = 517, /* optional_trailing_semicolon_cur_sqr */ - YYSYMBOL_optional_trailing_semicolon_sqr_sqr = 518, /* optional_trailing_semicolon_sqr_sqr */ - YYSYMBOL_optional_trailing_delim_sqr_sqr = 519, /* optional_trailing_delim_sqr_sqr */ - YYSYMBOL_optional_trailing_delim_cur_sqr = 520, /* optional_trailing_delim_cur_sqr */ - YYSYMBOL_use_initializer = 521, /* use_initializer */ - YYSYMBOL_make_struct_decl = 522, /* make_struct_decl */ - YYSYMBOL_523_86 = 523, /* $@86 */ - YYSYMBOL_524_87 = 524, /* $@87 */ - YYSYMBOL_525_88 = 525, /* $@88 */ - YYSYMBOL_526_89 = 526, /* $@89 */ - YYSYMBOL_527_90 = 527, /* $@90 */ - YYSYMBOL_528_91 = 528, /* $@91 */ - YYSYMBOL_529_92 = 529, /* $@92 */ - YYSYMBOL_530_93 = 530, /* $@93 */ - YYSYMBOL_make_tuple = 531, /* make_tuple */ - YYSYMBOL_make_map_tuple = 532, /* make_map_tuple */ - YYSYMBOL_make_tuple_call = 533, /* make_tuple_call */ - YYSYMBOL_534_94 = 534, /* $@94 */ - YYSYMBOL_535_95 = 535, /* $@95 */ - YYSYMBOL_make_dim = 536, /* make_dim */ - YYSYMBOL_make_dim_decl = 537, /* make_dim_decl */ - YYSYMBOL_538_96 = 538, /* $@96 */ - YYSYMBOL_539_97 = 539, /* $@97 */ - YYSYMBOL_540_98 = 540, /* $@98 */ - YYSYMBOL_541_99 = 541, /* $@99 */ - YYSYMBOL_542_100 = 542, /* $@100 */ - YYSYMBOL_543_101 = 543, /* $@101 */ - YYSYMBOL_544_102 = 544, /* $@102 */ - YYSYMBOL_545_103 = 545, /* $@103 */ - YYSYMBOL_546_104 = 546, /* $@104 */ - YYSYMBOL_547_105 = 547, /* $@105 */ - YYSYMBOL_make_table = 548, /* make_table */ - YYSYMBOL_expr_map_tuple_list = 549, /* expr_map_tuple_list */ - YYSYMBOL_make_table_decl = 550, /* make_table_decl */ - YYSYMBOL_array_comprehension_where = 551, /* array_comprehension_where */ - YYSYMBOL_optional_comma = 552, /* optional_comma */ - YYSYMBOL_array_comprehension = 553 /* array_comprehension */ -}; -typedef enum yysymbol_kind_t yysymbol_kind_t; - - - - -#ifdef short -# undef short -#endif - -/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure - and (if available) are included - so that the code can choose integer types of a good width. */ - -#ifndef __PTRDIFF_MAX__ -# include /* INFRINGES ON USER NAME SPACE */ -# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_STDINT_H -# endif -#endif - -/* Narrow types that promote to a signed type and that can represent a - signed or unsigned integer of at least N bits. In tables they can - save space and decrease cache pressure. Promoting to a signed type - helps avoid bugs in integer arithmetic. */ - -#ifdef __INT_LEAST8_MAX__ -typedef __INT_LEAST8_TYPE__ yytype_int8; -#elif defined YY_STDINT_H -typedef int_least8_t yytype_int8; -#else -typedef signed char yytype_int8; -#endif - -#ifdef __INT_LEAST16_MAX__ -typedef __INT_LEAST16_TYPE__ yytype_int16; -#elif defined YY_STDINT_H -typedef int_least16_t yytype_int16; -#else -typedef short yytype_int16; -#endif - -/* Work around bug in HP-UX 11.23, which defines these macros - incorrectly for preprocessor constants. This workaround can likely - be removed in 2023, as HPE has promised support for HP-UX 11.23 - (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of - . */ -#ifdef __hpux -# undef UINT_LEAST8_MAX -# undef UINT_LEAST16_MAX -# define UINT_LEAST8_MAX 255 -# define UINT_LEAST16_MAX 65535 -#endif - -#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ -typedef __UINT_LEAST8_TYPE__ yytype_uint8; -#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ - && UINT_LEAST8_MAX <= INT_MAX) -typedef uint_least8_t yytype_uint8; -#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX -typedef unsigned char yytype_uint8; -#else -typedef short yytype_uint8; -#endif - -#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ -typedef __UINT_LEAST16_TYPE__ yytype_uint16; -#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ - && UINT_LEAST16_MAX <= INT_MAX) -typedef uint_least16_t yytype_uint16; -#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX -typedef unsigned short yytype_uint16; -#else -typedef int yytype_uint16; -#endif - -#ifndef YYPTRDIFF_T -# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ -# define YYPTRDIFF_T __PTRDIFF_TYPE__ -# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ -# elif defined PTRDIFF_MAX -# ifndef ptrdiff_t -# include /* INFRINGES ON USER NAME SPACE */ -# endif -# define YYPTRDIFF_T ptrdiff_t -# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX -# else -# define YYPTRDIFF_T long -# define YYPTRDIFF_MAXIMUM LONG_MAX -# endif -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned -# endif -#endif - -#define YYSIZE_MAXIMUM \ - YY_CAST (YYPTRDIFF_T, \ - (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ - ? YYPTRDIFF_MAXIMUM \ - : YY_CAST (YYSIZE_T, -1))) - -#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) - - -/* Stored state numbers (used for stacks). */ -typedef yytype_int16 yy_state_t; - -/* State numbers in computations. */ -typedef int yy_state_fast_t; - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(Msgid) dgettext ("bison-runtime", Msgid) -# endif -# endif -# ifndef YY_ -# define YY_(Msgid) Msgid -# endif -#endif - - -#ifndef YY_ATTRIBUTE_PURE -# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) -# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) -# else -# define YY_ATTRIBUTE_PURE -# endif -#endif - -#ifndef YY_ATTRIBUTE_UNUSED -# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) -# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) -# else -# define YY_ATTRIBUTE_UNUSED -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YY_USE(E) ((void) (E)) -#else -# define YY_USE(E) /* empty */ -#endif - -/* Suppress an incorrect diagnostic about yylval being uninitialized. */ -#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ -# if __GNUC__ * 100 + __GNUC_MINOR__ < 407 -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") -# else -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ - _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# endif -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ - _Pragma ("GCC diagnostic pop") -#else -# define YY_INITIAL_VALUE(Value) Value -#endif -#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_END -#endif -#ifndef YY_INITIAL_VALUE -# define YY_INITIAL_VALUE(Value) /* Nothing. */ -#endif - -#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ -# define YY_IGNORE_USELESS_CAST_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") -# define YY_IGNORE_USELESS_CAST_END \ - _Pragma ("GCC diagnostic pop") -#endif -#ifndef YY_IGNORE_USELESS_CAST_BEGIN -# define YY_IGNORE_USELESS_CAST_BEGIN -# define YY_IGNORE_USELESS_CAST_END -#endif - - -#define YY_ASSERT(E) ((void) (0 && (E))) - -#if 1 - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS -# include /* INFRINGES ON USER NAME SPACE */ - /* Use EXIT_SUCCESS as a witness for stdlib.h. */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's 'empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined EXIT_SUCCESS \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* 1 */ - -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined DAS_YYLTYPE_IS_TRIVIAL && DAS_YYLTYPE_IS_TRIVIAL \ - && defined DAS_YYSTYPE_IS_TRIVIAL && DAS_YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yy_state_t yyss_alloc; - YYSTYPE yyvs_alloc; - YYLTYPE yyls_alloc; -}; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \ - + YYSIZEOF (YYLTYPE)) \ - + 2 * YYSTACK_GAP_MAXIMUM) - -# define YYCOPY_NEEDED 1 - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYPTRDIFF_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / YYSIZEOF (*yyptr); \ - } \ - while (0) - -#endif - -#if defined YYCOPY_NEEDED && YYCOPY_NEEDED -/* Copy COUNT objects from SRC to DST. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) -# else -# define YYCOPY(Dst, Src, Count) \ - do \ - { \ - YYPTRDIFF_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (Dst)[yyi] = (Src)[yyi]; \ - } \ - while (0) -# endif -# endif -#endif /* !YYCOPY_NEEDED */ - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 2 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 15621 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 248 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 306 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 1015 -/* YYNSTATES -- Number of states. */ -#define YYNSTATES 1875 - -/* YYMAXUTOK -- Last valid token kind. */ -#define YYMAXUTOK 475 - - -/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, with out-of-bounds checking. */ -#define YYTRANSLATE(YYX) \ - (0 <= (YYX) && (YYX) <= YYMAXUTOK \ - ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ - : YYSYMBOL_YYUNDEF) - -/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex. */ -static const yytype_uint8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 234, 2, 247, 245, 230, 223, 2, - 243, 244, 228, 227, 217, 226, 240, 229, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 220, 209, - 224, 218, 225, 219, 246, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 241, 2, 242, 222, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 207, 221, 208, 233, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, - 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, - 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, - 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, - 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, - 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, - 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, - 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, - 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, - 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, - 205, 206, 210, 211, 212, 213, 214, 215, 216, 231, - 232, 235, 236, 237, 238, 239 -}; - -#if DAS_YYDEBUG -/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_int16 yyrline[] = -{ - 0, 610, 610, 611, 616, 617, 618, 619, 620, 621, - 622, 623, 624, 625, 626, 627, 628, 632, 635, 638, - 644, 645, 646, 650, 651, 655, 656, 660, 679, 680, - 681, 682, 686, 687, 691, 692, 696, 697, 697, 701, - 706, 715, 730, 746, 751, 759, 759, 800, 830, 834, - 835, 836, 840, 843, 847, 851, 855, 859, 865, 874, - 877, 883, 884, 888, 892, 893, 897, 900, 906, 912, - 915, 921, 922, 926, 927, 928, 938, 951, 952, 956, - 957, 957, 963, 964, 965, 966, 967, 971, 981, 991, - 991, 999, 999, 1003, 1003, 1012, 1020, 1032, 1042, 1042, - 1046, 1046, 1052, 1053, 1054, 1055, 1056, 1057, 1061, 1066, - 1074, 1075, 1076, 1080, 1081, 1082, 1083, 1084, 1085, 1086, - 1087, 1088, 1094, 1097, 1103, 1106, 1109, 1115, 1116, 1117, - 1118, 1122, 1135, 1153, 1156, 1164, 1175, 1186, 1197, 1200, - 1207, 1211, 1218, 1219, 1223, 1224, 1225, 1229, 1232, 1236, - 1243, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, - 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, - 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, - 1276, 1277, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 1285, - 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, - 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, - 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, - 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, - 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, - 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, - 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, - 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, - 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, - 1376, 1377, 1381, 1382, 1386, 1405, 1406, 1407, 1411, 1417, - 1417, 1434, 1435, 1438, 1439, 1442, 1449, 1473, 1491, 1500, - 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, - 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, - 1526, 1527, 1531, 1536, 1542, 1548, 1560, 1561, 1565, 1566, - 1570, 1571, 1575, 1579, 1586, 1586, 1586, 1592, 1592, 1592, - 1601, 1635, 1643, 1650, 1657, 1663, 1664, 1675, 1679, 1682, - 1690, 1690, 1690, 1693, 1699, 1702, 1706, 1710, 1717, 1724, - 1730, 1734, 1738, 1741, 1744, 1752, 1755, 1758, 1766, 1769, - 1777, 1780, 1783, 1791, 1803, 1804, 1805, 1809, 1810, 1814, - 1815, 1819, 1824, 1832, 1843, 1849, 1864, 1876, 1879, 1885, - 1885, 1885, 1888, 1888, 1888, 1893, 1893, 1893, 1901, 1901, - 1901, 1907, 1921, 1937, 1955, 1965, 1976, 1991, 1994, 2000, - 2001, 2008, 2019, 2020, 2021, 2025, 2026, 2027, 2028, 2029, - 2033, 2038, 2046, 2047, 2060, 2064, 2074, 2081, 2088, 2088, - 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2108, 2109, - 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119, - 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2130, 2140, 2149, - 2158, 2163, 2164, 2165, 2166, 2167, 2168, 2169, 2170, 2171, - 2172, 2173, 2174, 2175, 2176, 2177, 2178, 2179, 2184, 2190, - 2201, 2206, 2216, 2220, 2227, 2230, 2230, 2230, 2235, 2235, - 2235, 2248, 2252, 2256, 2261, 2268, 2276, 2281, 2288, 2288, - 2288, 2295, 2299, 2309, 2318, 2327, 2331, 2334, 2340, 2341, - 2342, 2343, 2344, 2345, 2346, 2347, 2348, 2349, 2350, 2351, - 2352, 2353, 2354, 2355, 2356, 2357, 2358, 2359, 2360, 2361, - 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2375, 2376, 2377, - 2378, 2379, 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2393, - 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2416, 2417, 2418, - 2419, 2420, 2423, 2426, 2427, 2427, 2427, 2430, 2435, 2439, - 2443, 2443, 2443, 2448, 2451, 2455, 2455, 2455, 2460, 2463, - 2464, 2465, 2466, 2467, 2468, 2469, 2470, 2471, 2473, 2477, - 2485, 2490, 2494, 2503, 2504, 2505, 2506, 2507, 2508, 2509, - 2513, 2517, 2521, 2525, 2529, 2533, 2537, 2541, 2545, 2552, - 2553, 2562, 2566, 2567, 2568, 2572, 2573, 2577, 2578, 2579, - 2583, 2584, 2588, 2599, 2600, 2601, 2602, 2607, 2610, 2610, - 2614, 2614, 2633, 2632, 2648, 2647, 2661, 2670, 2682, 2691, - 2701, 2702, 2703, 2704, 2705, 2709, 2712, 2721, 2722, 2726, - 2729, 2732, 2747, 2756, 2757, 2761, 2764, 2767, 2780, 2781, - 2785, 2791, 2797, 2806, 2809, 2816, 2819, 2825, 2826, 2827, - 2831, 2832, 2836, 2843, 2848, 2857, 2863, 2874, 2877, 2882, - 2887, 2895, 2905, 2916, 2919, 2919, 2939, 2940, 2944, 2945, - 2946, 2950, 2957, 2957, 2976, 2979, 2995, 3015, 3016, 3017, - 3022, 3022, 3052, 3055, 3062, 3072, 3072, 3076, 3077, 3078, - 3082, 3092, 3112, 3135, 3136, 3140, 3141, 3145, 3151, 3152, - 3153, 3154, 3158, 3159, 3160, 3164, 3167, 3178, 3183, 3178, - 3203, 3210, 3215, 3224, 3230, 3241, 3242, 3243, 3244, 3245, - 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254, 3255, - 3256, 3257, 3258, 3259, 3260, 3261, 3262, 3263, 3264, 3265, - 3266, 3267, 3268, 3269, 3270, 3271, 3272, 3273, 3274, 3275, - 3276, 3277, 3278, 3279, 3280, 3281, 3282, 3283, 3284, 3285, - 3286, 3287, 3288, 3289, 3290, 3294, 3295, 3296, 3297, 3298, - 3299, 3300, 3301, 3305, 3316, 3320, 3327, 3339, 3346, 3352, - 3362, 3363, 3368, 3373, 3387, 3397, 3407, 3417, 3427, 3440, - 3441, 3442, 3443, 3444, 3448, 3452, 3452, 3452, 3466, 3467, - 3471, 3475, 3482, 3485, 3491, 3492, 3493, 3494, 3495, 3505, - 3508, 3508, 3508, 3512, 3517, 3524, 3524, 3531, 3535, 3539, - 3544, 3549, 3554, 3559, 3563, 3567, 3572, 3576, 3580, 3585, - 3585, 3585, 3591, 3598, 3598, 3598, 3603, 3603, 3603, 3609, - 3609, 3609, 3614, 3619, 3619, 3619, 3624, 3624, 3624, 3633, - 3638, 3638, 3638, 3643, 3643, 3643, 3652, 3657, 3657, 3657, - 3662, 3662, 3662, 3671, 3671, 3671, 3677, 3677, 3677, 3686, - 3689, 3700, 3716, 3716, 3721, 3730, 3716, 3759, 3759, 3764, - 3774, 3759, 3803, 3803, 3803, 3856, 3857, 3858, 3859, 3860, - 3864, 3871, 3878, 3884, 3890, 3897, 3904, 3910, 3919, 3922, - 3928, 3936, 3941, 3948, 3953, 3960, 3965, 3971, 3972, 3976, - 3977, 3982, 3983, 3987, 3988, 3992, 3993, 3997, 3998, 3999, - 4003, 4004, 4005, 4009, 4010, 4014, 4047, 4086, 4105, 4125, - 4145, 4166, 4166, 4166, 4174, 4174, 4174, 4181, 4181, 4181, - 4192, 4192, 4192, 4203, 4207, 4213, 4229, 4235, 4241, 4247, - 4247, 4247, 4261, 4266, 4273, 4293, 4321, 4345, 4345, 4345, - 4355, 4355, 4355, 4369, 4369, 4369, 4383, 4392, 4392, 4392, - 4412, 4419, 4419, 4419, 4429, 4434, 4441, 4444, 4450, 4470, - 4492, 4500, 4520, 4545, 4546, 4550, 4551, 4556, 4566, 4569, - 4572, 4575, 4583, 4592, 4604, 4614 -}; -#endif - -/** Accessing symbol of state STATE. */ -#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) - -#if 1 -/* The user-facing name of the symbol whose (internal) number is - YYSYMBOL. No bounds checking. */ -static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; - -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "\"end of file\"", "error", "\"invalid token\"", "\"lexer error\"", - "\"capture\"", "\"struct\"", "\"class\"", "\"let\"", "\"def\"", - "\"while\"", "\"if\"", "\"static_if\"", "\"else\"", "\"for\"", - "\"recover\"", "\"true\"", "\"false\"", "\"new\"", "\"typeinfo\"", - "\"type\"", "\"in\"", "\"is\"", "\"as\"", "\"elif\"", "\"static_elif\"", - "\"array\"", "\"return\"", "\"null\"", "\"break\"", "\"try\"", - "\"options\"", "\"table\"", "\"expect\"", "\"const\"", "\"require\"", - "\"operator\"", "\"enum\"", "\"finally\"", "\"delete\"", "\"deref\"", - "\"typedef\"", "\"typedecl\"", "\"with\"", "\"aka\"", "\"assume\"", - "\"cast\"", "\"override\"", "\"abstract\"", "\"upcast\"", "\"iterator\"", - "\"var\"", "\"addr\"", "\"continue\"", "\"where\"", "\"pass\"", - "\"reinterpret\"", "\"module\"", "\"public\"", "\"label\"", "\"goto\"", - "\"implicit\"", "\"explicit\"", "\"shared\"", "\"private\"", - "\"smart_ptr\"", "\"unsafe\"", "\"inscope\"", "\"static\"", - "\"fixed_array\"", "\"default\"", "\"uninitialized\"", "\"bool\"", - "\"void\"", "\"string\"", "\"auto\"", "\"int\"", "\"int2\"", "\"int3\"", - "\"int4\"", "\"uint\"", "\"bitfield\"", "\"uint2\"", "\"uint3\"", - "\"uint4\"", "\"float\"", "\"float2\"", "\"float3\"", "\"float4\"", - "\"range\"", "\"urange\"", "\"range64\"", "\"urange64\"", "\"block\"", - "\"int64\"", "\"uint64\"", "\"double\"", "\"function\"", "\"lambda\"", - "\"int8\"", "\"uint8\"", "\"int16\"", "\"uint16\"", "\"float16\"", - "\"half2\"", "\"half3\"", "\"half4\"", "\"half8\"", "\"short2\"", - "\"short3\"", "\"short4\"", "\"short8\"", "\"ushort2\"", "\"ushort3\"", - "\"ushort4\"", "\"ushort8\"", "\"byte2\"", "\"byte3\"", "\"byte4\"", - "\"byte8\"", "\"byte16\"", "\"ubyte2\"", "\"ubyte3\"", "\"ubyte4\"", - "\"ubyte8\"", "\"ubyte16\"", "\"tuple\"", "\"variant\"", "\"generator\"", - "\"yield\"", "\"sealed\"", "\"template\"", "\"+=\"", "\"-=\"", "\"/=\"", - "\"*=\"", "\"%=\"", "\"&=\"", "\"|=\"", "\"^=\"", "\"<<\"", "\">>\"", - "\"++\"", "\"--\"", "\"<=\"", "\"<<=\"", "\">>=\"", "\">=\"", "\"==\"", - "\"!=\"", "\"->\"", "\"<-\"", "\"??\"", "\"?.\"", "\"?[\"", "\"<|\"", - "\" <|\"", "\"$ <|\"", "\"@ <|\"", "\"@@ <|\"", "\"|>\"", "\":=\"", - "\"<<<\"", "\">>>\"", "\"<<<=\"", "\">>>=\"", "\"=>\"", "\"::\"", - "\"&&\"", "\"||\"", "\"^^\"", "\"&&=\"", "\"||=\"", "\"^^=\"", "\"..\"", - "\"$$\"", "\"$i\"", "\"$v\"", "\"$b\"", "\"$a\"", "\"$t\"", "\"$c\"", - "\"$f\"", "\"...\"", "\"[[\"", "\"[{\"", "\"{{\"", "\"new scope\"", - "\"close scope\"", "SEMICOLON", "\"integer constant\"", - "\"long integer constant\"", "\"unsigned integer constant\"", - "\"unsigned long integer constant\"", "\"unsigned int8 constant\"", - "\"floating point constant\"", "\"float16 constant\"", - "\"double constant\"", "\"name\"", "\"keyword\"", "\"type function\"", - "\"start of the string\"", "STRING_CHARACTER", "STRING_CHARACTER_ESC", - "\"end of the string\"", "\"{\"", "\"}\"", - "\"end of failed eader macro\"", "\"begin of code block\"", - "\"end of code block\"", "\"end of expression\"", "\";}}\"", "\";}]\"", - "\";]]\"", "\",]]\"", "\",}]\"", "END_OF_EXPR", "EMPTY", "','", "'='", - "'?'", "':'", "'|'", "'^'", "'&'", "'<'", "'>'", "'-'", "'+'", "'*'", - "'/'", "'%'", "UNARY_MINUS", "UNARY_PLUS", "'~'", "'!'", "PRE_INC", - "PRE_DEC", "POST_INC", "POST_DEC", "DEREF", "'.'", "'['", "']'", "'('", - "')'", "'$'", "'@'", "'#'", "$accept", "program", "semicolon", - "top_level_reader_macro", "optional_public_or_private_module", - "module_name", "optional_not_required", "module_declaration", - "character_sequence", "string_constant", "format_string", - "optional_format_string", "$@1", "string_builder_body", "string_builder", - "reader_character_sequence", "expr_reader", "$@2", "options_declaration", - "require_declaration", "keyword_or_name", "require_module_name", - "require_module", "is_public_module", "expect_declaration", - "expect_list", "expect_error", "expression_label", "expression_goto", - "elif_or_static_elif", "expression_else", "if_or_static_if", - "expression_else_one_liner", "$@3", "expression_if_one_liner", - "expression_if_then_else", "$@4", "expression_for_loop", "$@5", "$@6", - "expression_unsafe", "expression_while_loop", "expression_with", - "expression_with_alias", "$@7", "$@8", "annotation_argument_value", - "annotation_argument_value_list", "annotation_argument_name", - "annotation_argument", "annotation_argument_list", - "metadata_argument_list", "annotation_declaration_name", - "annotation_declaration_basic", "annotation_declaration", - "annotation_list", "optional_annotation_list", - "optional_function_argument_list", "optional_function_type", - "function_name", "optional_template", "global_function_declaration", - "optional_public_or_private_function", "function_declaration_header", - "function_declaration", "$@9", "open_block", "close_block", - "expression_block", "expr_call_pipe", "expression_any", "expressions", - "expr_keyword", "optional_expr_list", "optional_expr_list_in_braces", - "optional_expr_map_tuple_list", "type_declaration_no_options_list", - "expression_keyword", "$@10", "$@11", "$@12", "$@13", "expr_pipe", - "name_in_namespace", "expression_delete", "new_type_declaration", "$@14", - "$@15", "expr_new", "expression_break", "expression_continue", - "expression_return_no_pipe", "expression_return", - "expression_yield_no_pipe", "expression_yield", "expression_try_catch", - "kwd_let_var_or_nothing", "kwd_let", "optional_in_scope", - "tuple_expansion", "tuple_expansion_variable_declaration", - "expression_let", "expr_cast", "$@16", "$@17", "$@18", "$@19", "$@20", - "$@21", "expr_type_decl", "$@22", "$@23", "expr_type_info", "expr_list", - "block_or_simple_block", "block_or_lambda", "capture_entry", - "capture_list", "optional_capture_list", "expr_block", "expr_full_block", - "expr_full_block_assumed_piped", "$@24", "expr_numeric_const", - "expr_assign", "expr_assign_pipe_right", "expr_assign_pipe", - "expr_named_call", "expr_method_call", "func_addr_name", - "func_addr_expr", "$@25", "$@26", "$@27", "$@28", "expr_field", "$@29", - "$@30", "expr_call", "expr2", "$@31", "$@32", "$@33", "$@34", "$@35", - "$@36", "expr", "expr_mtag", "optional_field_annotation", - "optional_override", "optional_constant", - "optional_public_or_private_member_variable", - "optional_static_member_variable", "structure_variable_declaration", - "opt_sem", "struct_variable_declaration_list", "$@37", "$@38", "$@39", - "$@40", "function_argument_declaration_no_type", - "function_argument_declaration_type", "function_argument_list", - "tuple_type", "tuple_type_list", "tuple_alias_type_list", "variant_type", - "variant_type_list", "variant_alias_type_list", "copy_or_move", - "variable_declaration_no_type", "variable_declaration_type", - "variable_declaration", "copy_or_move_or_clone", "optional_ref", - "let_variable_name_with_pos_list", "let_variable_declaration", - "global_variable_declaration_list", "$@41", "optional_shared", - "optional_public_or_private_variable", "global_let", "$@42", "enum_list", - "optional_public_or_private_alias", "single_alias", "$@43", "alias_list", - "alias_declaration", "$@44", "optional_public_or_private_enum", - "enum_name", "enum_declaration", "optional_structure_parent", - "optional_sealed", "structure_name", "class_or_struct", - "optional_public_or_private_structure", - "optional_struct_variable_declaration_list", "structure_declaration", - "$@45", "$@46", "variable_name_with_pos_list", "basic_type_declaration", - "enum_basic_type_declaration", "structure_type_declaration", - "auto_type_declaration", "bitfield_bits", "commas", - "bitfield_alias_bits", "bitfield_basic_type_declaration", - "bitfield_type_declaration", "$@47", "$@48", "c_or_s", "table_type_pair", - "dim_list", "type_declaration_no_options", "$@49", "$@50", "$@51", - "$@52", "$@53", "$@54", "$@55", "$@56", "$@57", "$@58", "$@59", "$@60", - "$@61", "$@62", "$@63", "$@64", "$@65", "$@66", "$@67", "$@68", "$@69", - "$@70", "$@71", "$@72", "$@73", "$@74", "$@75", "type_declaration", - "tuple_alias_declaration", "$@76", "$@77", "$@78", "$@79", - "variant_alias_declaration", "$@80", "$@81", "$@82", "$@83", - "bitfield_alias_declaration", "$@84", "$@85", "make_decl", - "make_struct_fields", "make_variant_dim", "make_struct_single", - "make_struct_dim", "make_struct_dim_list", "make_struct_dim_decl", - "optional_make_struct_dim_decl", "optional_block", - "optional_trailing_semicolon_cur_cur", - "optional_trailing_semicolon_cur_sqr", - "optional_trailing_semicolon_sqr_sqr", "optional_trailing_delim_sqr_sqr", - "optional_trailing_delim_cur_sqr", "use_initializer", "make_struct_decl", - "$@86", "$@87", "$@88", "$@89", "$@90", "$@91", "$@92", "$@93", - "make_tuple", "make_map_tuple", "make_tuple_call", "$@94", "$@95", - "make_dim", "make_dim_decl", "$@96", "$@97", "$@98", "$@99", "$@100", - "$@101", "$@102", "$@103", "$@104", "$@105", "make_table", - "expr_map_tuple_list", "make_table_decl", "array_comprehension_where", - "optional_comma", "array_comprehension", YY_NULLPTR -}; - -static const char * -yysymbol_name (yysymbol_kind_t yysymbol) -{ - return yytname[yysymbol]; -} -#endif - -#define YYPACT_NINF (-1604) - -#define yypact_value_is_default(Yyn) \ - ((Yyn) == YYPACT_NINF) - -#define YYTABLE_NINF (-881) - -#define yytable_value_is_error(Yyn) \ - ((Yyn) == YYTABLE_NINF) - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -static const yytype_int16 yypact[] = -{ - -1604, 132, -1604, -1604, 84, -93, 453, 173, -1604, -51, - 67, 67, 67, -1604, -1604, -64, 179, -1604, -1604, -1604, - 576, -1604, -1604, -1604, 573, -1604, 109, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, 56, -1604, -28, - 59, 52, -1604, 171, -1604, -1604, -1604, 387, 346, -1604, - 35, -1604, -1604, -1604, 67, 67, -1604, -1604, 109, -1604, - -1604, -1604, -1604, -1604, 365, 308, -1604, -1604, -1604, -1604, - 179, 179, 179, 360, -1604, 797, 201, -1604, -1604, 513, - 518, 527, 328, 506, -1604, 693, 73, 84, 520, -93, - 453, 453, 575, 453, 600, -1604, 918, 918, -1604, 636, - 593, 138, 576, 862, 646, 692, 715, -1604, 743, 678, - -1604, -1604, -27, 84, 179, 179, 179, 179, -1604, -1604, - -1604, -1604, 910, -1604, -1604, 753, -1604, -1604, -1604, -1604, - -1604, 173, -1604, -1604, -1604, -1604, -1604, 919, 49, 696, - -1604, -1604, -1604, -1604, 575, 575, 575, 921, -1604, -1604, - -1604, -1604, 795, -1604, -1604, -1604, -1604, 593, -1604, -1604, - -1604, 758, -1604, -1604, -1604, -1604, -1604, 784, -1604, 116, - -1604, 72, 828, 797, -1604, -1604, -1604, -1604, -1604, 1, - 875, -1604, -102, -1604, -1604, -1604, 925, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, 194, 808, -1604, 793, -1604, -1604, - 948, -1604, 800, 173, 173, -1604, -1604, 15424, 909, -1604, - -1604, 825, -1604, 597, 84, 84, -60, 152, -1604, -1604, - -1604, 49, -1604, -1604, 12228, -1604, 830, 173, -1604, -1604, - 14494, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, 1005, - 1008, -1604, 782, 173, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, 173, 643, 841, 173, -1604, -102, 240, -1604, - 84, -1604, 823, 1031, 809, -1604, -1604, 858, 859, 868, - 850, 871, 876, -1604, -1604, -1604, 860, -1604, -1604, -1604, - -1604, -1604, 652, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, 880, -1604, -1604, -1604, 882, 883, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, 885, 894, 886, - -64, -1604, -1604, -1604, -1604, -1604, 798, 878, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, 922, 937, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, 941, 897, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, 1125, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, 952, 911, -1604, -1604, 210, -37, - -1604, -1604, -1604, 549, -1604, -64, -1604, -1604, -1604, 152, - 915, -1604, 11104, 954, 961, 12228, -1604, -25, -1604, -1604, - -1604, 11104, -1604, -1604, 962, 936, -70, -29, 149, -1604, - -1604, 11104, 154, -1604, -1604, -1604, 21, -1604, -1604, -1604, - 12, 6692, -1604, 920, 11876, 699, 12053, 563, -1604, -1604, - -1604, -1604, 965, 656, 1502, 923, -1604, 104, 955, 501, - 924, 12228, 12228, -1604, 3201, 643, 11104, -1604, -1604, 47, - 593, -1604, 946, 947, -1604, -1604, 928, -92, 949, 42, - -1604, 574, 929, 950, 951, 933, 953, 938, 618, 956, - -1604, 625, 958, 959, 11104, 11104, 942, 943, 957, 963, - 964, 968, -1604, 11526, 11701, 6926, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, 969, 972, -1604, 1152, 11104, 11104, - 11104, 11104, 11104, 6228, 11104, -1604, 971, -1604, -1604, 7160, - -1604, 111, -1604, -1604, -1604, -1604, 960, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, 2397, -1604, 975, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, 1136, 990, -1604, -1604, -1604, 4828, - 12228, 12228, 12228, 2623, 12228, 12228, 978, 967, 12228, 782, - 12228, 782, 12228, 782, 12403, 1001, 2785, -1604, 11104, -1604, - -1604, -1604, -1604, -1604, 973, -1604, -1604, 13969, 11104, -1604, - 798, 261, -1604, -43, -1604, -1604, 216, -1604, 878, 597, - 982, 216, -1604, 597, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - 11104, -1604, -1604, 639, -88, -88, -88, -1604, 878, 878, - -1604, 11104, -1604, -1604, 976, 4132, -1604, 173, 7392, -1604, - 11104, 1007, -1604, 576, 1016, 7624, 144, 999, 4364, 281, - 281, 281, -1604, 7856, -1604, 576, 576, 11104, 1214, -1604, - -1604, -1604, -1604, -1604, -1604, 1188, -1604, -1604, -1604, -42, - -1604, 576, 576, 576, 576, -1604, 576, -1604, -1604, 1161, - -1604, 306, -1604, 14686, 675, -1604, 593, -1604, 179, 1220, - -1604, -102, -1604, -1604, -1604, -1604, 987, -1604, -1604, -64, - 626, -1604, 1011, 1012, 1014, -1604, 11104, 12228, 11104, 11104, - -1604, -1604, 11104, -1604, 11104, -1604, 11104, -1604, -1604, 11104, - -1604, 12228, 624, 624, 11104, 11104, 11104, 11104, 11104, 11104, - 639, 3433, 639, 3666, 639, 1074, -1604, 707, -1604, -1604, - 845, 997, 624, 624, 7, 624, 624, 180, 1228, 1000, - 1026, 14686, 1026, 310, 639, 597, -1604, 1027, -1604, 5060, - 57, 15087, 15142, 11104, 11104, -1604, -1604, 11104, 11104, 11104, - 11104, 1048, 11104, 676, 11104, 11104, 11104, 11104, 11104, 11104, - 11104, 11104, 11104, 8088, 11104, 11104, 11104, 11104, 11104, 11104, - 11104, 11104, 11104, 11104, 15323, 11104, -1604, 8320, 1050, -1604, - 4828, -1604, 1093, 11523, 623, 754, 1032, 411, -1604, 810, - 813, -1604, -1604, 1061, 816, -37, 837, -37, 843, -37, - -1604, 332, -1604, 472, -1604, 12228, 1044, -1604, -1604, 14076, - -1604, -1604, 11104, 1045, 12228, -1604, -1604, 12228, -1604, -1604, - 2892, 1021, 1225, -1604, -1604, 245, -1604, -1604, -1604, 173, - 639, 1028, 4828, -1604, 1052, 2053, 11698, 1256, 11104, -1604, - 1075, 173, 1055, -1604, 1054, 1086, -1604, -1604, 12228, 4828, - -1604, 11523, 1030, -1604, 960, -1604, -1604, -1604, 173, -1604, - -1604, 173, -1604, 173, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -90, 281, -1604, 5292, 5292, 5292, 5292, 5292, - 5292, 5292, 5292, 5292, 5292, 5292, 11104, 5292, 5292, 5292, - 5292, 5292, 5292, -1604, -1604, 1080, 287, 917, 1212, 576, - 12228, 12228, 12228, 6460, 8552, 1083, 11104, 12228, -1604, -1604, - -1604, 12228, 1026, 1914, 1046, 12391, 12228, 12228, 12514, 12228, - 12549, 12228, 1026, 12228, 12403, 1026, 1001, 342, 12656, 12691, - 12798, 12833, 12940, 12975, 20, 281, 1049, 15, 3899, 5526, - 8784, 1128, 1077, 14, 442, 1078, 263, 28, 9016, 14, - 672, 33, 11104, 1088, -1604, 11104, -1604, 12228, 12228, -1604, - 11104, 142, 639, 639, 39, 193, -1604, 11104, -1604, 1053, - 1057, 1058, 174, -1604, -1604, 43, -1604, 11104, -1604, -54, - 5760, -1604, 203, 1081, 1059, 1062, -12, 782, 1082, 1064, - -1604, -1604, 1085, 1068, -1604, -1604, 77, 77, 1230, 1230, - 2447, 2447, 1090, 488, 1094, -1604, 14111, 212, 212, 975, - 77, 77, 2106, 14916, 1173, 14782, 15269, 14647, 2354, 1610, - 1355, 1230, 1230, 230, 230, 488, 488, 488, 704, 11104, - 1095, 1098, 730, 11104, 1301, 1100, 14218, -1604, 311, -1604, - -1604, 11873, 11104, 11104, 11104, 11104, 11104, 11104, 11104, 11104, - 11104, 11104, 11104, 11104, 11104, 11104, 11104, 11104, 11104, -1604, - -1604, -1604, -1604, 12228, -1604, -1604, -1604, 499, -1604, 1092, - -1604, 1103, -1604, 1104, -1604, 12403, -1604, 1001, 510, 878, - -1604, 1118, -1604, 114, -1604, 878, 878, -1604, 11104, 1121, - -1604, 1139, -1604, 12228, -1604, 11104, -1604, 46, 639, -1604, - 1052, 11104, 173, -1604, 1145, -1604, -1604, -1604, -1604, 1063, - -1604, 11523, -1604, 57, -1604, 98, 11104, -1604, 960, 1147, - 1147, -1604, -1604, -1604, 281, 281, 281, -1604, -1604, -42, - -1604, -42, -1604, -42, -1604, -42, -1604, -42, -1604, -42, - -1604, -42, -1604, -42, -1604, -42, -1604, -42, -1604, -42, - -1604, -1604, -42, -1604, -42, -1604, -42, -1604, -42, -1604, - -42, -1604, -42, 1146, 576, -1604, -1604, 300, -1604, 51, - 593, 1401, 1650, 854, 733, 336, 1122, 1123, 1168, 1124, - 323, 1130, 855, 12228, 12403, 1001, 1769, 1131, 1135, 12228, - -1604, -1604, 1939, 2158, -1604, 2175, -1604, 2410, 1143, 2636, - 538, 1144, 544, 57, -1604, -1604, -1604, -1604, -1604, 1137, - 11104, -1604, 11104, 11104, 11104, 5994, 13969, 3, 11104, 751, - 733, 442, -1604, -1604, 1148, -1604, 11104, -1604, 1151, 11104, - -1604, 11104, 733, 822, 1162, -1604, -1604, 11104, -1604, -1604, - -1604, 545, 612, 1185, 48, 60, 11104, 639, 63, 14686, - -1604, 11104, 11104, 12228, 782, 11104, -1604, 198, -1604, 1164, - 322, 11336, -1604, 751, -1604, -1604, -12, 1209, 1213, 1166, - 1215, 1218, -1604, 355, -37, -1604, 11104, -1604, 11104, 9248, - 11104, -1604, 1187, 1174, -1604, -1604, 11104, 1177, -1604, 14253, - 11104, 9480, 1178, -1604, 14360, -1604, 9712, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - 878, -1604, -1604, 1219, -1604, 1226, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, 1179, 12228, -1604, -1604, - 1045, 13082, -1604, 1381, 189, -1604, 11104, 74, -1604, 12228, - 11104, 57, 782, 173, -1604, -1604, 468, 11104, -1604, 1416, - 3201, 57, -1604, 402, 381, -1604, -1604, -1604, 12228, 593, - 1396, 51, -1604, -1604, 917, -1604, -1604, -1604, -1604, 1186, - -1604, -1604, -1604, 653, -1604, 1190, 1234, -1604, -1604, 2646, - 665, 683, -1604, -1604, 11104, 2676, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, 1192, 9944, 682, 13117, -1604, - -1604, 14, 442, -1604, 1194, 248, 1077, -1604, -1604, -1604, - -1604, 1078, 734, 14, 1197, -1604, -1604, -1604, -1604, 735, - -1604, -1604, -1604, 1235, 11104, 11104, 738, 80, 11104, 13224, - 13259, 2847, -37, 745, -1604, 1199, 5760, 389, -1604, -1604, - 1248, -1604, -1604, -12, 1205, 333, 12228, 13366, 12228, 13401, - -1604, 394, 13508, -1604, 11104, 14820, 11104, -1604, 13543, 5760, - -1604, 405, 11104, -1604, -1604, -1604, 414, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, 878, -1604, 1253, 11104, 406, 11104, - 350, 576, 844, -37, -1604, -1604, 173, -1604, 576, -1604, - 782, 1254, 1210, -86, 350, -1604, -1604, -1604, 1396, 639, - 1211, 1221, -1604, -1604, 11104, 1266, 11104, 1240, -1604, -1604, - -1604, -1604, 1223, 1224, 1231, 11104, 11104, 11104, 1232, 1383, - 1233, 1236, 10176, -1604, 473, 11104, 255, 442, -1604, 11104, - 11104, 11104, 11104, 822, -1604, 11104, 11104, 1179, -1604, -1604, - 524, 531, 11104, 11104, 752, -1604, -1604, -1604, 1244, 11104, - -1604, 417, -1604, 1229, -1604, -1604, 10408, -1604, -1604, 2924, - -1604, 856, -1604, -1604, -1604, 12228, 13650, 13685, -1604, 498, - -1604, 13792, -1604, -1604, -1604, -1604, 535, -1604, -1604, -1604, - 333, 133, 4596, -1604, -37, -1604, 277, 12228, -25, 593, - 15424, -1604, -1604, -1604, -1604, 1383, 1383, 1237, 1252, 1241, - 1243, 1245, 1246, 1247, 11104, -1604, 11104, -1604, -1604, -1604, - 11104, -1604, -1604, 1383, 1383, -1604, 13827, -1604, 14537, 11104, - 11104, -1604, 13934, -1604, -1604, 14537, -1604, 576, -1604, -1604, - 1277, 1275, 1278, 14537, 557, 11104, 537, -1604, 576, 1249, - -1604, 11104, -1604, -1604, -1604, 863, -1604, -1604, 1255, -1604, - 173, -1604, 468, -1604, 10640, 10872, -1604, -1604, -1604, -1604, - -1604, -1604, 173, 12228, -25, 1037, 11104, -1604, 576, 15424, - -34, -34, -1604, 11104, -1604, 11104, 1383, 1383, 733, 1261, - 1274, 1026, -34, 733, -1604, 1438, 1258, -1604, -1604, 290, - 1302, 597, -1604, 11104, 11104, 1279, 1310, 14537, -1604, 537, - 597, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, 11104, - 11104, -1604, -1604, 1037, 11104, 11104, 576, 593, 173, 733, - 1077, 1305, -1604, 1280, 1281, 1283, 1285, -34, -34, 1077, - 1286, -1604, -1604, 1288, 1289, 1290, 11104, 1293, 11104, 11104, - 1294, 597, 576, 14537, -1604, 11104, 1295, -1604, -1604, -1604, - -1604, 11104, 576, 576, -1604, -1604, 593, 578, 1296, -1604, - -1604, -1604, -1604, -1604, 1298, 1299, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, 1330, 1303, 14537, -1604, - 576, -1604, -1604, -1604, -1604, 733, -1604, -1604, -1604, -1604, - 1307, -1604, 579, -1604, -1604 -}; - -/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE does not specify something else to do. Zero - means the default is an error. */ -static const yytype_int16 yydefact[] = -{ - 2, 142, 1, 377, 0, 0, 0, 705, 378, 0, - 697, 697, 697, 17, 18, 0, 0, 16, 15, 3, - 0, 10, 9, 8, 0, 7, 686, 6, 11, 5, - 4, 13, 12, 14, 111, 112, 110, 120, 122, 47, - 66, 63, 64, 0, 49, 50, 51, 0, 0, 52, - 61, 48, 292, 291, 697, 697, 24, 23, 686, 699, - 698, 902, 892, 897, 0, 345, 45, 128, 129, 130, - 0, 0, 0, 131, 133, 140, 0, 127, 19, 719, - 718, 282, 707, 722, 687, 688, 0, 0, 0, 0, - 0, 0, 53, 0, 0, 62, 0, 0, 59, 0, - 626, 697, 0, 20, 0, 0, 0, 347, 0, 0, - 139, 134, 0, 0, 0, 0, 0, 0, 143, 721, - 720, 283, 285, 709, 708, 0, 724, 723, 727, 690, - 689, 692, 118, 119, 116, 117, 114, 0, 0, 0, - 113, 123, 67, 65, 55, 56, 54, 61, 58, 57, - 700, 623, 624, 702, 294, 293, 704, 626, 706, 21, - 22, 25, 903, 893, 898, 346, 43, 46, 138, 0, - 135, 136, 137, 141, 287, 286, 289, 284, 710, 0, - 715, 683, 609, 28, 29, 33, 0, 106, 107, 104, - 105, 103, 102, 108, 0, 0, 60, 0, 625, 703, - 0, 27, 809, 0, 0, 44, 132, 0, 0, 694, - 716, 0, 728, 684, 0, 0, 611, 0, 30, 31, - 32, 0, 121, 115, 0, 26, 0, 0, 894, 899, - 0, 234, 235, 236, 237, 238, 239, 240, 241, 242, - 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, - 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, - 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, - 273, 274, 275, 276, 277, 278, 279, 280, 281, 0, - 0, 150, 144, 0, 785, 788, 791, 792, 786, 789, - 787, 790, 0, 0, 713, 725, 691, 609, 0, 124, - 0, 126, 0, 672, 670, 693, 109, 0, 0, 0, - 0, 0, 0, 735, 778, 736, 794, 737, 741, 742, - 743, 744, 784, 748, 749, 750, 751, 752, 753, 754, - 779, 780, 781, 782, 862, 740, 747, 783, 869, 876, - 738, 745, 739, 746, 755, 756, 757, 758, 759, 760, - 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, - 771, 772, 773, 774, 775, 776, 777, 0, 0, 0, - 0, 793, 824, 827, 825, 826, 889, 701, 812, 813, - 810, 811, 802, 649, 655, 228, 229, 226, 153, 154, - 156, 155, 157, 158, 159, 160, 186, 187, 184, 185, - 177, 188, 189, 178, 175, 176, 227, 210, 0, 225, - 190, 191, 192, 193, 164, 165, 166, 161, 162, 163, - 174, 0, 180, 181, 179, 172, 173, 168, 167, 169, - 170, 171, 152, 151, 209, 0, 182, 183, 609, 147, - 322, 290, 694, 626, 711, 0, 717, 627, 729, 0, - 0, 125, 0, 0, 0, 0, 671, 0, 830, 853, - 856, 0, 859, 849, 0, 0, 863, 870, 877, 883, - 886, 0, 328, 839, 844, 838, 0, 852, 848, 841, - 0, 0, 843, 828, 0, 0, 895, 900, 230, 231, - 224, 208, 232, 211, 194, 0, 145, 376, 640, 641, - 0, 0, 0, 288, 0, 0, 0, 695, 714, 630, - 626, 610, 0, 0, 554, 555, 0, 0, 0, 0, - 549, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 784, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 598, 0, 0, 0, 430, 432, 431, 433, - 434, 435, 436, 437, 0, 0, 39, 291, 0, 0, - 0, 0, 0, 326, 0, 412, 413, 552, 551, 330, - 591, 508, 582, 581, 580, 579, 142, 585, 550, 584, - 583, 557, 509, 558, 0, 510, 0, 553, 905, 909, - 906, 907, 908, 674, 675, 0, 668, 669, 667, 0, - 0, 0, 0, 0, 0, 0, 0, 815, 0, 144, - 0, 144, 0, 144, 0, 0, 0, 835, 326, 834, - 846, 847, 840, 842, 0, 845, 829, 0, 0, 891, - 890, 805, 904, 345, 818, 819, 0, 650, 645, 0, - 0, 0, 656, 0, 233, 213, 214, 216, 215, 217, - 218, 219, 220, 212, 221, 222, 223, 197, 198, 200, - 199, 201, 202, 203, 204, 195, 196, 205, 206, 207, - 0, 374, 375, 0, 609, 609, 609, 146, 149, 148, - 324, 0, 77, 78, 91, 362, 360, 0, 0, 100, - 0, 0, 361, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 300, 0, 301, 0, 0, 0, 0, 317, - 312, 309, 308, 310, 311, 295, 344, 323, 303, 591, - 302, 0, 85, 86, 83, 315, 84, 316, 318, 380, - 307, 0, 304, 592, 438, 712, 626, 628, 0, 0, - 726, 609, 685, 951, 954, 350, 354, 353, 359, 0, - 0, 398, 0, 0, 0, 987, 0, 0, 330, 0, - 389, 392, 0, 395, 0, 991, 0, 960, 969, 0, - 957, 0, 537, 538, 0, 0, 0, 0, 0, 0, - 0, 929, 0, 0, 0, 967, 994, 0, 334, 337, - 0, 0, 514, 513, 547, 512, 511, 0, 0, 0, - 1005, 407, 1005, 414, 0, 0, 996, 1005, 589, 0, - 422, 0, 0, 0, 0, 539, 540, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 498, 0, 673, 0, 0, 677, - 0, 682, 0, 681, 0, 0, 0, 820, 833, 0, - 0, 795, 814, 0, 0, 147, 0, 147, 0, 147, - 647, 0, 653, 0, 796, 0, 1005, 837, 822, 0, - 803, 800, 0, 804, 0, 651, 896, 0, 657, 901, - 0, 0, 730, 637, 638, 660, 642, 643, 644, 0, - 0, 0, 0, 366, 363, 592, 438, 0, 0, 348, - 0, 0, 0, 321, 0, 0, 70, 95, 0, 0, - 371, 368, 413, 425, 142, 343, 341, 342, 0, 319, - 320, 0, 89, 0, 428, 298, 306, 313, 314, 365, - 370, 379, 0, 0, 305, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 297, 696, 0, 0, 617, 620, 0, - 0, 0, 0, 943, 0, 0, 0, 0, 977, 980, - 983, 0, 1005, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1005, 0, 0, 1005, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 345, 0, 0, - 0, 963, 921, 929, 0, 972, 0, 0, 0, 929, - 0, 0, 0, 0, 932, 0, 999, 0, 0, 42, - 0, 40, 0, 0, 0, 0, 974, 1006, 327, 0, - 0, 0, 485, 482, 484, 0, 998, 1006, 331, 0, - 326, 501, 0, 1005, 0, 0, 0, 144, 0, 0, - 568, 567, 0, 0, 569, 573, 515, 516, 528, 529, - 526, 527, 0, 563, 0, 545, 0, 586, 587, 588, - 517, 518, 533, 534, 535, 536, 0, 0, 531, 532, - 530, 524, 525, 520, 519, 521, 522, 523, 0, 0, - 0, 491, 0, 0, 0, 0, 0, 506, 0, 676, - 679, 438, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 680, - 831, 854, 857, 0, 860, 850, 797, 0, 864, 0, - 871, 0, 878, 0, 884, 0, 887, 0, 0, 332, - 1006, 0, 823, 808, 801, 646, 652, 639, 0, 0, - 659, 0, 658, 0, 661, 0, 96, 0, 0, 367, - 364, 0, 0, 349, 0, 97, 98, 68, 69, 0, - 372, 369, 414, 422, 325, 73, 0, 322, 142, 0, - 0, 388, 387, 340, 0, 0, 0, 460, 469, 448, - 470, 449, 472, 451, 471, 450, 473, 452, 463, 442, - 464, 443, 465, 444, 474, 453, 475, 454, 462, 440, - 441, 476, 455, 477, 456, 466, 445, 467, 446, 468, - 447, 461, 439, 0, 143, 618, 619, 620, 621, 612, - 626, 0, 0, 0, 944, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1000, 559, 0, 0, 560, 0, 590, 0, 0, 0, - 0, 0, 0, 422, 593, 594, 595, 596, 597, 0, - 0, 930, 0, 0, 0, 0, 407, 929, 0, 0, - 0, 0, 938, 939, 0, 946, 0, 936, 0, 0, - 975, 0, 0, 0, 0, 934, 976, 0, 966, 931, - 995, 0, 0, 36, 0, 0, 0, 0, 0, 408, - 556, 0, 0, 0, 144, 0, 997, 0, 502, 0, - 0, 0, 505, 1006, 920, 503, 0, 0, 0, 0, - 0, 0, 420, 0, 147, 564, 0, 570, 0, 0, - 0, 543, 0, 0, 574, 578, 0, 0, 546, 0, - 0, 0, 0, 492, 0, 499, 0, 541, 507, 678, - 448, 449, 451, 450, 452, 442, 443, 444, 453, 454, - 440, 455, 456, 445, 446, 447, 439, 832, 855, 858, - 821, 861, 851, 0, 816, 0, 865, 867, 872, 874, - 879, 881, 885, 648, 888, 654, 328, 0, 329, 806, - 807, 0, 732, 733, 663, 662, 0, 0, 373, 0, - 0, 422, 144, 0, 71, 72, 73, 0, 88, 79, - 0, 422, 381, 0, 0, 459, 457, 458, 0, 626, - 615, 612, 613, 614, 617, 631, 952, 955, 351, 0, - 356, 357, 355, 0, 401, 0, 0, 404, 399, 0, - 0, 0, 988, 986, 330, 0, 390, 393, 396, 992, - 990, 961, 970, 968, 958, 0, 0, 0, 0, 911, - 910, 929, 0, 964, 0, 0, 922, 945, 937, 965, - 935, 973, 0, 929, 0, 941, 942, 949, 933, 0, - 335, 338, 37, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 147, 0, 504, 0, 326, 0, 417, 418, - 0, 416, 415, 0, 0, 0, 0, 0, 0, 0, - 480, 0, 0, 575, 0, 548, 0, 544, 0, 326, - 493, 0, 0, 542, 500, 496, 0, 799, 817, 798, - 868, 875, 882, 836, 333, 731, 0, 0, 0, 0, - 0, 0, 0, 147, 74, 87, 0, 80, 0, 296, - 144, 0, 0, 670, 0, 636, 616, 632, 615, 0, - 0, 0, 352, 358, 0, 0, 0, 0, 400, 978, - 981, 984, 0, 0, 0, 0, 0, 0, 0, 943, - 0, 0, 0, 599, 0, 0, 0, 0, 947, 0, - 0, 0, 0, 0, 940, 0, 0, 328, 34, 41, - 0, 0, 0, 0, 0, 483, 608, 486, 0, 0, - 478, 0, 424, 0, 421, 423, 0, 409, 427, 0, - 607, 0, 605, 481, 602, 0, 0, 0, 601, 0, - 494, 0, 497, 734, 664, 92, 0, 101, 99, 299, - 0, 73, 0, 90, 147, 382, 670, 0, 0, 626, - 0, 634, 666, 665, 622, 943, 943, 0, 0, 0, - 0, 0, 0, 0, 326, 1001, 330, 391, 394, 397, - 0, 944, 962, 943, 943, 561, 0, 600, 1003, 0, - 0, 948, 0, 913, 912, 1003, 950, 1003, 336, 339, - 38, 0, 0, 1003, 0, 0, 0, 489, 1003, 0, - 419, 0, 410, 565, 571, 0, 606, 604, 0, 603, - 0, 426, 73, 75, 362, 0, 81, 85, 86, 83, - 84, 82, 0, 0, 0, 0, 0, 629, 0, 0, - 928, 928, 402, 0, 405, 0, 943, 943, 918, 0, - 0, 1005, 928, 918, 562, 0, 0, 915, 914, 0, - 0, 0, 35, 0, 0, 0, 0, 1003, 487, 0, - 0, 479, 411, 566, 572, 576, 495, 94, 76, 0, - 0, 368, 429, 0, 0, 0, 0, 626, 0, 0, - 925, 1005, 927, 0, 0, 0, 0, 928, 928, 919, - 0, 989, 1002, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1003, 1003, 1007, 0, 0, 490, 1014, 577, - 369, 0, 0, 0, 386, 633, 626, 0, 1006, 926, - 953, 956, 403, 406, 0, 0, 985, 993, 971, 959, - 1004, 1012, 917, 916, 1013, 1015, 0, 0, 1003, 1011, - 0, 385, 384, 635, 923, 0, 979, 982, 1010, 1008, - 0, 383, 0, 1009, 924 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = -{ - -1604, -1604, -1, -1604, -1604, -1604, -1604, -1604, 750, 1458, - -1604, -1604, -1604, -1604, -1604, -1604, 1546, -1604, -1604, -1604, - 610, 500, -1604, 1403, -1604, -1604, 1462, -1604, -1604, -1604, - -1390, -1604, -1604, -1604, -108, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, 1334, -1604, -1604, -46, - -44, -1604, -1604, -1604, 629, 818, -500, -588, -832, -1604, - -1604, -1604, -1604, -1597, -1604, -1604, -5, -209, -275, -493, - -1604, 370, -1604, -612, -1356, -751, -161, -284, -1604, -1604, - -1604, -1604, -567, 0, -1604, -1604, -1604, -1604, -1604, -104, - -99, -98, -1604, -97, -1604, -1604, -1604, 1565, -1604, 378, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -403, -91, 812, 53, 234, -1137, -671, - -1604, -706, -1604, -1604, -494, 399, -1604, -1604, -1604, -1603, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, 1126, - -1604, -1604, -1604, -1604, -1604, -1604, 1406, -1604, -168, 131, - -4, 145, 338, -1604, -154, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, 456, -459, -955, -1604, -475, -954, -1604, -864, - -2, 11, -1604, -590, -1487, -1604, -421, -1604, -1604, 1528, - -1604, -1604, -1604, 1149, 1132, 285, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -722, 455, -1604, 1076, -1604, -1604, 440, -1604, - 1272, -1604, -1604, -1604, -409, -1604, -1604, -435, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -173, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, 1087, - -757, -165, -930, -765, -1604, -1604, -1220, -975, -1604, -1604, - -1604, -1257, -14, -1180, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, 302, -544, -1604, -1604, -1604, 819, -1604, - -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, -1604, - -1604, -1604, -1604, -1381, -785, -1604 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = -{ - 0, 1, 635, 18, 161, 58, 201, 19, 186, 192, - 1710, 1503, 1618, 790, 567, 167, 568, 109, 21, 22, - 49, 50, 51, 98, 23, 41, 42, 705, 706, 1427, - 1428, 707, 1568, 1662, 708, 709, 1186, 710, 900, 901, - 711, 712, 713, 714, 1420, 910, 193, 194, 37, 38, - 39, 216, 73, 74, 75, 76, 24, 439, 503, 282, - 122, 25, 176, 283, 177, 207, 569, 156, 923, 1197, - 717, 504, 718, 799, 619, 805, 1148, 570, 1027, 1616, - 1028, 1617, 720, 571, 721, 746, 972, 1582, 572, 722, - 723, 724, 725, 726, 727, 728, 673, 729, 942, 1433, - 1191, 730, 573, 986, 1595, 987, 1596, 989, 1597, 574, - 977, 1588, 575, 800, 1638, 576, 1342, 1343, 1057, 925, - 577, 963, 1188, 578, 852, 1198, 732, 579, 580, 1044, - 581, 1323, 1716, 1324, 1779, 582, 1104, 1544, 583, 733, - 1526, 1783, 1528, 1784, 1645, 1829, 785, 585, 497, 1444, - 1577, 1237, 1239, 969, 153, 509, 965, 741, 1670, 1749, - 498, 499, 500, 870, 871, 486, 872, 873, 487, 1284, - 893, 894, 1674, 599, 457, 304, 305, 213, 297, 85, - 131, 27, 182, 293, 99, 100, 197, 101, 28, 55, - 125, 179, 29, 446, 211, 212, 83, 128, 448, 30, - 180, 295, 895, 586, 292, 373, 374, 1137, 883, 485, - 227, 375, 863, 1548, 1145, 856, 483, 376, 600, 1387, - 875, 605, 1392, 601, 1388, 602, 1389, 604, 1391, 608, - 1396, 609, 1550, 610, 1398, 611, 1551, 612, 1400, 613, - 1552, 614, 1402, 615, 1404, 638, 31, 105, 203, 383, - 639, 32, 106, 204, 384, 643, 33, 104, 202, 587, - 1800, 1810, 1054, 1013, 1801, 1802, 1803, 1014, 1026, 1306, - 1300, 1295, 1497, 1247, 588, 970, 1580, 971, 1581, 996, - 1601, 993, 1599, 1015, 806, 589, 994, 1600, 1016, 590, - 1253, 1681, 1254, 1682, 1255, 1683, 981, 1592, 991, 1598, - 787, 807, 591, 1766, 1038, 592 -}; - -/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule whose - number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_int16 yytable[] = -{ - 17, 786, 54, 199, 296, 850, 876, 984, 441, 739, - 731, 716, 641, 935, 217, 66, 77, 1039, 1019, 78, - 595, 865, 1048, 867, 1012, 869, 1012, 636, 510, 926, - 927, 1165, 851, 1139, 1487, 1141, 1565, 1143, 1291, 1270, - 1280, 141, 1272, 1246, 1303, 622, 1422, 752, 1301, 630, - 1553, 377, 1053, 1307, 620, -142, 1005, 94, 1004, 1316, - 1017, 1055, 1021, 1325, 187, 188, 1416, 1005, 1504, 169, - 77, 77, 77, 1748, 64, 1034, 810, 637, 642, -866, - 1505, 214, 1045, 1508, 444, 302, 1668, 737, 132, 133, - 495, 1151, 95, 1189, 1559, 214, 40, 1442, 811, 812, - 1623, 158, 64, 34, 35, 65, 716, 303, 781, 783, - 1423, 671, 501, 1778, 77, 77, 77, 77, 903, 1329, - -873, 1424, 1425, 108, 59, 596, 181, 1006, 13, 449, - 60, 920, 2, 65, 1667, 597, 1475, 456, 1337, 3, - 114, 115, 116, 1327, 215, 1423, 56, 1006, 1338, 14, - -866, 749, 1798, 1190, 672, -866, 1424, 1425, 215, 823, - 824, 802, 4, 1327, 5, 1160, 6, 753, 754, 299, - 298, 84, 7, -866, 209, 1283, 1827, 884, 1167, 1744, - 1443, 108, 8, 502, 1006, 1339, 300, 52, 9, 87, - 1328, -873, 716, 598, 57, 59, -873, 1257, 228, 229, - 1327, 60, 13, 565, 922, 716, 1340, 1268, 53, 1799, - 1271, 1341, 10, 67, -873, 301, 1053, 168, 815, 816, - 719, 208, 382, 14, 371, 1608, 821, 885, 822, 823, - 824, 825, 888, 1162, 154, 623, 826, 1161, 189, 114, - 1056, 116, 68, 190, 621, 1161, 191, 844, 845, 137, - 1161, 811, 812, 624, 451, 155, 1161, 11, 12, 625, - 1161, 1709, 134, 1161, 96, 1161, 755, 135, 1334, 89, - 136, 1733, 1193, 137, 86, 97, 632, 1161, 440, 88, - 1161, 36, 904, 1110, 1562, 756, 1426, 442, 738, 507, - 447, 1161, 1053, 1330, 1570, 715, 735, 1161, -880, 1460, - 740, 1461, 1409, 839, 840, 841, 842, 843, 808, 69, - 1314, 1315, 1482, 1318, 1449, 719, 138, 844, 845, 139, - 13, 1732, 983, -488, 1770, 154, 1771, 302, 678, 679, - 52, 881, 1775, 87, 1281, 1169, 997, 1780, 70, 1160, - 102, 14, 1788, 218, 219, 64, 155, 1440, 1160, 303, - 1701, 53, 1180, 982, 809, 891, 742, 716, 1283, 52, - 206, 821, 15, 992, 823, 824, 995, 1238, 891, -880, - 472, 815, 816, 16, -880, 473, 65, 892, 617, 821, - 53, 822, 823, 824, 825, 123, 157, 764, 495, 826, - 892, 124, -880, 214, -488, 1160, 1826, 618, 1160, -488, - 90, 719, 474, 475, 13, 1160, 1052, 1162, 1610, 716, - 484, 221, 907, 71, 719, 1699, 1162, -488, 117, 1692, - 1331, 917, 72, 1033, 1183, 14, 716, 854, 855, 857, - 886, 859, 860, 634, 889, 864, 1317, 866, 222, 868, - 1160, 1856, 1857, 118, 1108, 508, 1417, 1332, 1133, 880, - 1818, 13, 844, 845, 496, 371, 215, 87, 841, 842, - 843, 943, 1161, 1162, 1147, 1163, 1162, 52, 1164, 1344, - 844, 845, 14, 1162, 108, 1297, 64, 1870, 881, 882, - 1423, 1310, 450, 1179, 371, 1040, 371, 1053, 53, 476, - 1041, 1424, 1425, 477, 13, 1750, 1751, 1743, 1636, 1170, - 456, 371, 371, 1326, 117, 1298, 1607, 65, 1162, 811, - 812, 13, 1525, 1762, 1763, 14, 371, 750, 1613, 52, - 13, 1192, 1481, 1435, 1436, 1437, 565, 922, 1171, 1234, - 1012, 1804, 14, 1486, 1042, 1241, 1242, 1493, 13, 1289, - 53, 14, 1814, 371, 371, 1012, 1256, 92, 1455, 634, - 1557, 1262, 1263, 1171, 1265, 1368, 1267, 1144, 1269, 14, - 43, 478, 107, 126, 1515, 479, 719, 1273, 480, 127, - 1245, 484, 1523, 968, 1259, 93, 1807, 1808, 79, 80, - 1450, 81, 964, 481, 44, 45, 46, 1844, 1845, 482, - 144, 145, 52, 146, 849, 1507, 1046, 1524, 1571, 13, - 371, 371, 371, 113, 371, 371, 1523, 802, 371, 82, - 371, 1171, 371, 53, 371, 802, 91, 47, 719, 1571, - 14, 1611, 1171, 1171, 1166, 1573, 43, 48, 634, 815, - 816, 1171, 484, 1632, 1289, 719, 1175, 821, 1643, 822, - 823, 824, 825, 119, 1572, 811, 812, 826, 120, 1650, - 44, 45, 46, 1184, 1292, 1293, 1185, 121, 1652, 1719, - 13, 719, 719, 719, 719, 719, 719, 719, 719, 719, - 719, 719, 1405, 719, 719, 719, 719, 719, 719, 372, - 1628, 14, 440, 47, 1294, -82, 1403, 13, 1431, 634, - 1171, 440, 913, 48, 440, 440, 440, 1146, 13, 110, - 111, 112, 1149, 64, 929, 930, 148, 149, 14, 142, - 675, 1155, 1040, 1593, 1156, 1289, 1393, 1697, 676, 14, - 936, 937, 938, 939, 1394, 940, 13, 634, 844, 845, - 944, 1660, 13, 13, 65, 1406, 1512, 151, 77, 1407, - 1728, 1171, 1700, 170, 171, 172, 173, 14, 1171, 974, - 129, 13, 1171, 14, 14, 634, 130, 371, 152, 1631, - 640, 634, 634, 1472, 13, 815, 816, 506, 1711, 1474, - 1500, 371, 14, 821, 1171, 1712, 823, 824, 825, 1730, - 634, 151, 1649, 826, 154, 14, 1025, 645, 646, 647, - 648, 649, 650, 651, 652, 1289, 1289, 147, 757, 1243, - 13, 1776, 152, 1043, 1252, 155, 945, 946, 947, 948, - 949, 950, 951, 952, 891, 97, 653, 758, 1459, 953, - 954, 14, 1864, 1874, 1465, 955, 654, 655, 656, 634, - 154, 473, 1742, 150, 1563, 956, 892, 1501, 957, 958, - 443, 13, 765, 162, 484, 959, 960, 961, 1130, 768, - 975, 155, 1129, 13, 1149, 1149, 1659, 1074, 474, 475, - 13, 766, 14, 1147, 844, 845, 1311, 1312, 769, 976, - 634, 13, 226, 1075, 14, 371, -809, 1477, 1584, 166, - 1304, 14, 634, 1305, 371, 1357, 154, 371, 1511, 163, - 1590, 1605, 14, 962, 440, 13, 631, 1418, 1492, 1171, - 634, 1358, 1407, 1407, 1499, 1819, 440, 155, 1591, 378, - 372, 1362, 164, 1506, 1006, 1023, 14, 1024, 371, 159, - 565, 922, 1513, 440, 379, 160, 440, 1363, 1187, 380, - 1327, 381, 1484, 512, 513, 1760, 731, 716, 440, 372, - 165, 372, 195, 1612, 1615, 476, 1531, 1622, 1485, 477, - 178, 1171, 1171, 519, 1629, 1171, 372, 372, 1541, 521, - 1390, 1715, 1171, 1546, 114, 115, 116, 174, 1240, 1171, - 371, 371, 371, 175, 1235, 484, 1813, 371, 95, 1131, - 1236, 371, 1664, 198, 284, 205, 371, 371, 285, 371, - 1414, 371, 200, 371, 371, 114, 528, 529, 372, 372, - 440, 1809, 286, 287, 210, 223, 1809, 288, 289, 290, - 291, 224, 1290, 1558, 225, 1299, 1839, 478, 1290, 1299, - 226, 479, 294, 473, 480, 438, 454, 371, 371, 455, - 1494, 484, 456, 1495, 484, 1134, 1496, 484, 1135, 481, - 436, 1138, 1837, 437, 1585, 482, 183, 184, 1029, 1030, - 474, 475, 1147, 531, 532, 372, 372, 372, 484, 372, - 372, 445, 1140, 372, 484, 372, 452, 372, 1142, 372, - 473, 1707, 1759, 1604, 453, 484, 484, 484, 1746, 1448, - 1458, 1724, 458, 459, 484, 1718, 1445, 1602, 1785, 565, - 922, 1639, 460, 461, 64, 462, 473, 474, 475, 484, - 463, 1620, 1621, 464, 466, 1624, 467, 468, 1872, 469, - 1369, 543, 544, 545, 52, 44, 45, 46, 470, 488, - 183, 184, 185, 474, 475, 65, 218, 219, 220, 471, - 896, 897, 898, 371, 489, 557, 1395, 476, 490, 491, - 596, 477, 61, 62, 63, 371, 719, 492, 1564, 493, - 597, 593, 745, 494, 1794, 1795, 1656, 511, 594, 606, - 607, 628, 644, 371, 674, 791, 670, 440, 677, 563, - 743, 744, 759, 751, 760, 761, 762, 763, 13, 848, - 767, 764, 770, 771, 476, 774, 775, 596, 477, 440, - 440, 440, 862, 788, 811, 812, 789, 597, 640, 14, - 776, 16, 887, 1831, 912, 914, 777, 778, 598, 478, - 476, 779, 372, 479, 477, 877, 480, 803, 847, -93, - 1714, 1569, 861, 918, 932, 933, 372, 941, 967, 1822, - 973, 481, 1745, 1439, 1554, 978, 979, 482, 980, 1022, - 1032, 1035, 1036, 1037, 1047, 1072, 1560, 1109, 943, 1456, - 1637, 811, 812, 371, 371, 598, 478, 1132, 1136, 371, - 479, 1150, 1154, 480, 1158, 1574, 1061, 1065, 1159, 1171, - 1172, 1168, 1174, 1176, 1177, 1178, 1182, 1233, 481, 1238, - 1250, 1079, 478, 1655, 482, 1575, 479, 1761, 1421, 480, - 1260, 1661, 1282, 1288, 1289, 1296, 1309, 1320, 1333, 1105, - 1321, 1322, 1365, 1335, 481, 1336, 1345, 1346, 1793, 1347, - 482, 1348, 813, 814, 815, 816, 817, 1397, 1412, 818, - 819, 820, 821, 371, 822, 823, 824, 825, 1399, 1401, - 372, 904, 826, 1349, 827, 828, 1413, 1350, 1360, 372, - 829, 1361, 372, 1366, 1432, 1200, 1202, 1204, 1206, 1208, - 1210, 1212, 1214, 1216, 1218, 1641, 1221, 1223, 1225, 1227, - 1229, 1231, 1408, 1419, 1438, 1453, 1451, 1452, 1454, 813, - 814, 815, 816, 372, 1457, 1463, 811, 812, 1464, 821, - 1476, 822, 823, 824, 825, 1637, 1170, 1470, 1473, 826, - 1488, 827, 828, 1490, 834, 835, 836, 837, 838, 839, - 840, 841, 842, 843, 1498, 1502, 1518, 371, 1514, 1520, - 1519, 1533, 1521, 844, 845, 1522, 1547, 1534, 440, 371, - 1536, 1542, 618, 1549, 1556, 372, 372, 372, 1567, 1576, - 1583, 1587, 372, 1586, 473, 1602, 372, 1609, 371, 1614, - 1619, 372, 372, 1630, 372, 1633, 372, 1635, 372, 372, - 1653, 1665, 1666, 1691, 1675, 1787, 839, 840, 841, 842, - 843, 474, 475, 1678, 1676, 1680, 1684, 1792, 1685, 1717, - 844, 845, 1725, 1720, 1686, 1690, 1693, 1753, 1772, 1694, - 1290, 1752, 372, 372, 1773, 1754, 1755, 1774, 1756, 1757, - 1758, 1816, 1290, 1781, 813, 814, 815, 816, 817, 1786, - 1817, 818, 819, 820, 821, 1811, 822, 823, 824, 825, - 1820, 924, 924, 924, 826, 1747, 827, 828, 1812, 1825, - 440, 1824, 1838, 1836, 1840, 1841, 371, 1842, 371, 1843, - 1846, 934, 1847, 1848, 1849, 1851, 1854, 1859, 1868, 1865, - 1031, 1355, 1866, 1867, 140, 1869, 934, 20, 476, 1873, - 196, 143, 477, 440, 1736, 306, 966, 1430, 1737, 1657, - 1658, 440, 1821, 1738, 1739, 1740, 26, 1663, 1434, 1731, - 1517, 1828, 1578, 1669, 1671, 1441, 1634, 1672, 584, 837, - 838, 839, 840, 841, 842, 843, 103, 603, 372, 1579, - 1673, 505, 747, 1410, 465, 844, 845, 616, 1815, 1706, - 372, 1491, 1020, 748, 0, 0, 0, 627, 0, 0, - 0, 0, 1855, 0, 0, 0, 0, 0, 372, 0, - 478, 0, 0, 0, 479, 0, 1446, 480, 0, 0, - 0, 811, 812, 657, 658, 659, 660, 661, 662, 663, - 664, 0, 481, 1835, 0, 371, 0, 0, 482, 0, - 0, 0, 665, 0, 0, 440, 0, 0, 0, 0, - 772, 773, 666, 0, 0, 934, 0, 371, 0, 0, - 0, 0, 667, 668, 669, 0, 0, 0, 0, 0, - 0, 0, 1863, 473, 792, 793, 794, 795, 796, 801, - 801, 0, 0, 0, 0, 0, 0, 1765, 0, 0, - 0, 0, 0, 0, 1765, 0, 1765, 0, 372, 372, - 474, 475, 1765, 0, 372, 0, 1043, 1765, 934, 0, - 0, 0, 0, 0, 0, 440, 0, 0, 0, 0, - 0, 0, 0, 934, 0, 0, 0, 440, 0, 0, - 0, 0, 0, 371, 801, 0, 0, 1797, 0, 813, - 814, 815, 816, 817, 879, 924, 818, 819, 820, 821, - 0, 822, 823, 824, 825, 0, 0, 0, 0, 826, - 0, 827, 828, 0, 0, 0, 1765, 0, 372, 1043, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 440, 0, 1834, 890, 476, 0, 0, - 0, 477, 473, 0, 0, 0, 0, 0, 0, 0, - 0, 905, 0, 0, 0, 0, 0, 924, 0, 0, - 0, 1765, 1765, 0, 0, 0, 0, 0, 0, 474, - 475, 1861, 1862, 836, 837, 838, 839, 840, 841, 842, - 843, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 844, 845, 0, 0, 0, 0, 0, 1765, 0, 1871, - 0, 0, 372, 0, 0, 0, 0, 0, 0, 478, - 0, 0, 0, 479, 372, 1447, 480, 0, 0, 0, - 0, 0, 801, 0, 0, 985, 0, 0, 988, 0, - 990, 481, 801, 372, 0, 801, 0, 482, 0, 0, - 998, 999, 1000, 1001, 1002, 1003, 0, 0, 0, 0, - 734, 0, 736, 0, 0, 0, 476, 0, 0, 0, - 477, 0, 0, 934, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 801, 0, 0, 0, 1066, - 1067, 0, 0, 1068, 1069, 1070, 1071, 473, 1073, 0, - 1076, 1077, 1078, 1080, 1081, 1082, 1083, 1084, 1085, 1087, - 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, - 0, 1106, 473, 801, 474, 475, 0, 0, 0, 0, - 0, 372, 0, 372, 0, 0, 0, 0, 478, 0, - 0, 0, 479, 934, 1462, 480, 0, 0, 0, 474, - 475, 0, 0, 0, 0, 853, 924, 924, 924, 0, - 481, 934, 0, 934, 0, 934, 482, 934, 0, 934, - 0, 934, 0, 934, 0, 934, 0, 934, 905, 934, - 0, 934, 0, 0, 934, 0, 934, 0, 934, 0, - 934, 0, 934, 0, 934, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 476, 0, -407, 0, 477, 0, 0, 0, 0, - 0, 0, 0, 0, 811, 812, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 476, 899, 0, 0, - 477, 906, 0, 0, 909, 0, 911, 0, 0, 801, - 372, 916, 13, 0, 921, 0, 0, 0, 0, 928, - 0, 0, 0, 931, 0, 0, 0, 0, 0, 0, - 0, 0, 372, 14, 0, 0, 0, 811, 812, 0, - 0, 634, 0, 478, 792, 1286, 801, 479, 0, 1258, - 480, 0, 0, 0, 801, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 481, 0, 0, 478, 0, - 0, 482, 479, 1319, 1466, 480, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 801, 0, 0, 0, - 481, 0, 0, 0, 0, 0, 482, 1011, 0, 1011, - 0, 473, 813, 814, 815, 816, 817, 0, 372, 818, - 819, 820, 821, 0, 822, 823, 824, 825, 473, 0, - 0, 0, 826, 0, 827, 828, 0, 0, 474, 475, - 829, 830, 831, 0, 0, 1359, 832, 0, 0, 1364, - 0, 0, 0, 0, 0, 474, 475, 0, 0, 0, - 0, -407, 0, 0, 0, 813, 814, 815, 816, 817, - 0, 0, 818, 819, 820, 821, 1111, 822, 823, 824, - 825, 0, -407, 0, 0, 826, 0, 827, 828, 0, - -407, 0, 833, 0, 834, 835, 836, 837, 838, 839, - 840, 841, 842, 843, 1411, 0, 0, 0, 1153, 0, - 0, 0, 0, 844, 845, 0, 0, 1319, 0, 0, - 0, 0, 0, 0, 0, 476, 0, 0, 906, 477, - 0, 0, 0, 0, 1173, 0, 0, 0, 0, 0, - 0, 0, 476, 0, 0, 1181, 477, 834, 835, 836, - 837, 838, 839, 840, 841, 842, 843, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 844, 845, 0, 0, - 0, 1199, 1201, 1203, 1205, 1207, 1209, 1211, 1213, 1215, - 1217, 1219, 1220, 1222, 1224, 1226, 1228, 1230, 1232, 0, - 0, 0, 0, 0, 934, 811, 812, 478, 0, 0, - 1249, 479, 1251, 1467, 480, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 478, 0, 0, 0, 479, 481, - 1468, 480, 0, 0, 0, 482, 801, 0, 1478, 0, - 0, 801, 0, 0, 0, 0, 481, 0, 811, 812, - 0, 0, 482, 0, 0, 0, 0, 801, 1308, 0, - 0, 0, 0, 801, 0, 0, 1313, 0, 0, 0, - 0, 0, 801, 473, 0, 0, 0, 1509, 1510, 0, - 0, 801, 0, 0, 0, 0, 0, 1319, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 811, 812, - 474, 475, 1527, 0, 1529, 801, 1532, 0, 0, 0, - 0, 0, 1535, 0, 0, 0, 1538, 801, 0, 0, - 0, 0, 801, 813, 814, 815, 816, 817, 0, 0, - 818, 819, 820, 821, 0, 822, 823, 824, 825, 0, - 0, 0, 0, 826, 0, 827, 828, 0, 1370, 1371, - 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, - 1382, 1383, 1384, 1385, 1386, 0, 813, 814, 815, 816, - 817, 0, 801, 818, 819, 820, 821, 0, 822, 823, - 824, 825, 0, 0, 0, 0, 826, 476, 827, 828, - 0, 477, 0, 0, 829, 830, 831, 0, 0, 0, - 832, 1415, 0, 0, 0, 0, 835, 836, 837, 838, - 839, 840, 841, 842, 843, 0, 813, 814, 815, 816, - 817, 0, 1429, 818, 844, 845, 821, 0, 822, 823, - 824, 825, 801, 0, 0, 0, 826, 0, 827, 828, - 0, 0, 0, 0, 0, 0, 833, 0, 834, 835, - 836, 837, 838, 839, 840, 841, 842, 843, 0, 478, - 801, 801, 0, 479, 801, 1469, 480, 844, 845, 0, - 0, 846, 801, 0, 811, 812, 0, 0, 0, 0, - 0, 481, 0, 0, 0, 0, 0, 482, 0, 0, - 1646, 0, 1647, 0, 0, 801, 0, 0, 1651, 473, - 0, 837, 838, 839, 840, 841, 842, 843, 0, 473, - 0, 0, 0, 0, 0, 801, 0, 844, 845, 1479, - 1480, 0, 0, 0, 1483, 0, 474, 475, 0, 0, - 0, 0, 1489, 0, 0, 1011, 474, 475, 0, 473, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1696, 0, - 0, 1698, 0, 0, 0, 1702, 474, 475, 1705, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1713, 801, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 813, 814, 815, 816, 817, 0, 0, 818, - 819, 820, 821, 0, 822, 823, 824, 825, 0, 0, - 0, 0, 826, 476, 827, 828, 0, 477, 0, 0, - 829, 830, 831, 476, 0, 0, 832, 477, 0, 0, - 0, 0, 0, 0, 0, 0, 811, 812, 0, 0, - 801, 0, 0, 0, 0, 0, 801, 0, 0, 0, - 0, 0, 0, 476, 0, 0, 1561, 477, 0, 0, - 0, 0, 0, 1566, 0, 0, 734, 0, 0, 0, - 0, 1777, 833, 0, 834, 835, 836, 837, 838, 839, - 840, 841, 842, 843, 0, 478, 0, 0, 0, 479, - 801, 1471, 480, 844, 845, 478, 0, 858, 0, 479, - 0, 1589, 480, 0, 0, 0, 0, 481, 0, 0, - 473, 0, 0, 482, 0, 0, 0, 481, 0, 0, - 0, 0, 0, 482, 0, 478, 0, 0, 0, 479, - 1823, 1594, 480, 0, 0, 0, 0, 474, 475, 0, - 0, 0, 0, 811, 812, 801, 0, 481, 0, 0, - 0, 0, 0, 482, 813, 814, 815, 816, 817, 0, - 0, 818, 819, 820, 821, 0, 822, 823, 824, 825, - 0, 0, 0, 0, 826, 0, 827, 828, 0, 0, - 0, 1858, 829, 830, 831, 0, 0, 473, 832, 0, - 0, 0, 0, 1654, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 474, 475, 0, 0, 0, 0, - 1677, 0, 1679, 0, 476, 0, 0, 0, 477, 0, - 0, 1687, 1688, 1689, 833, 0, 834, 835, 836, 837, - 838, 839, 840, 841, 842, 843, 1703, 1704, 0, 0, - 0, 0, 1708, 0, 0, 844, 845, 0, 0, 874, - 0, 813, 814, 815, 816, 817, 0, 0, 818, 819, - 820, 821, 1722, 822, 823, 824, 825, 0, 0, 0, - 0, 826, 0, 827, 828, 0, 0, 0, 0, 829, - 830, 831, 0, 0, 0, 832, 478, 0, 1741, 0, - 479, 476, 1627, 480, 0, 477, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 481, 0, - 0, 0, 0, 0, 482, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1767, 1768, 0, 0, 0, - 0, 833, 0, 834, 835, 836, 837, 838, 839, 840, - 841, 842, 843, 0, 0, 0, 0, 1782, 0, 0, - 0, 0, 844, 845, 0, 0, 1157, 0, 0, 0, - 0, 1791, 0, 478, 0, 0, 0, 479, 0, 1723, - 480, 0, 1796, 0, 0, 0, 0, 0, 0, 1805, - 0, 1806, 0, 0, 0, 481, 0, 0, 0, 0, - 0, 482, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1830, 0, 0, 0, - 1832, 1833, 680, 0, 0, 0, 512, 513, 3, 0, - 681, 682, 683, 0, 684, 0, 514, 515, 516, 517, - 518, 0, 1850, 0, 1852, 1853, 519, 685, 520, 686, - 687, 0, 521, 0, 0, 0, 0, 1860, 0, 688, - 522, 689, 0, 690, 0, 691, 523, 0, 0, 524, - 0, 8, 525, 692, 0, 693, 526, 0, 0, 694, - 695, 0, 0, 0, 0, 0, 696, 0, 0, 528, - 529, 0, 313, 314, 315, 0, 317, 318, 319, 320, - 321, 530, 323, 324, 325, 326, 327, 328, 329, 330, - 331, 332, 333, 0, 335, 336, 337, 0, 0, 340, - 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, - 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, - 361, 362, 363, 364, 365, 366, 531, 532, 697, 698, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 534, 535, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 699, 700, 701, - 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, - 0, 0, 0, 0, 0, 536, 537, 538, 539, 540, - 0, 541, 0, 542, 543, 544, 545, 52, 154, 702, - 546, 547, 548, 549, 550, 551, 552, 553, 65, 703, - 555, 556, 0, 0, 0, 0, 0, 0, 557, 155, - 704, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 558, 559, 560, - 0, 15, 0, 0, 561, 562, 0, 0, 512, 513, - 0, 0, 563, 0, 564, 0, 565, 566, 514, 515, - 516, 517, 518, 0, 0, 0, 0, 0, 519, 0, - 520, 0, 0, 0, 521, 0, 473, 0, 0, 0, - 0, 0, 522, 0, 0, 0, 0, 0, 523, 0, - 0, 524, 0, 0, 525, 0, 1005, 0, 526, 0, - 0, 0, 0, 474, 475, 0, 0, 0, 527, 0, - 0, 528, 529, 0, 313, 314, 315, 0, 317, 318, - 319, 320, 321, 530, 323, 324, 325, 326, 327, 328, - 329, 330, 331, 332, 333, 0, 335, 336, 337, 0, - 0, 340, 341, 342, 343, 344, 345, 346, 347, 348, - 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, - 359, 360, 361, 362, 363, 364, 365, 366, 531, 532, - 533, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 534, 535, 0, 0, 0, 0, - 476, 0, 0, 0, 477, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, - 0, 0, 0, 0, 0, 0, 0, 536, 537, 538, - 539, 540, 0, 541, 1006, 542, 543, 544, 545, 52, - 0, 0, 546, 547, 548, 549, 550, 551, 552, 553, - 1007, 554, 555, 556, 0, 0, 0, 0, 0, 0, - 557, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 478, 0, 0, 0, 479, 0, 0, 1008, - 559, 560, 0, 15, 0, 0, 561, 562, 0, 0, - 0, 512, 513, 0, 1009, 0, 1010, 0, 565, 566, - 482, 514, 515, 516, 517, 518, 0, 0, 0, 0, - 0, 519, 0, 520, 0, 0, 0, 521, 0, 473, - 0, 0, 0, 0, 0, 522, 0, 0, 0, 0, - 0, 523, 0, 0, 524, 0, 0, 525, 0, 0, - 0, 526, 0, 0, 0, 0, 474, 475, 0, 0, - 0, 527, 0, 0, 528, 529, 0, 313, 314, 315, - 0, 317, 318, 319, 320, 321, 530, 323, 324, 325, - 326, 327, 328, 329, 330, 331, 332, 333, 0, 335, - 336, 337, 0, 0, 340, 341, 342, 343, 344, 345, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, - 366, 531, 532, 533, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 534, 535, 0, - 0, 0, 0, 476, 0, 0, 0, 477, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, - 536, 537, 538, 539, 540, 0, 541, 1006, 542, 543, - 544, 545, 52, 0, 0, 546, 547, 548, 549, 550, - 551, 552, 553, 1007, 554, 555, 556, 0, 0, 0, - 0, 0, 0, 557, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 478, 0, 0, 0, 479, - 0, 0, 1008, 559, 560, 0, 15, 0, 0, 561, - 562, 0, 0, 0, 512, 513, 0, 1009, 0, 1018, - 0, 565, 566, 482, 514, 515, 516, 517, 518, 0, - 0, 0, 0, 0, 519, 0, 520, 0, 0, 0, - 521, 0, 622, 0, 0, 0, 0, 0, 522, 0, - 0, 0, 0, 0, 523, 0, 0, 524, 0, 0, - 525, 0, 0, 0, 526, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 527, 0, 0, 528, 529, 0, - 313, 314, 315, 0, 317, 318, 319, 320, 321, 530, - 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, - 333, 0, 335, 336, 337, 0, 0, 340, 341, 342, - 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, - 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, - 363, 364, 365, 366, 531, 532, 533, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 534, 535, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, - 0, 0, 0, 536, 537, 538, 539, 540, 0, 541, - 0, 542, 543, 544, 545, 52, 0, 0, 546, 547, - 548, 549, 550, 551, 552, 553, 65, 554, 555, 556, - 0, 0, 0, 0, 0, 0, 557, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 623, 0, 0, 558, 559, 560, 0, 15, - 0, 0, 561, 562, 0, 0, 0, 512, 513, 0, - 1285, 0, 564, 0, 565, 566, 625, 514, 515, 516, - 517, 518, 0, 0, 0, 0, 0, 519, 0, 520, - 0, 0, 0, 521, 0, 0, 0, 0, 0, 0, - 0, 522, 0, 0, 0, 0, 0, 523, 0, 0, - 524, 0, 0, 525, 0, 0, 0, 526, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 527, 0, 0, - 528, 529, 0, 313, 314, 315, 0, 317, 318, 319, - 320, 321, 530, 323, 324, 325, 326, 327, 328, 329, - 330, 331, 332, 333, 0, 335, 336, 337, 0, 0, - 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, - 360, 361, 362, 363, 364, 365, 366, 531, 532, 697, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 534, 535, 0, 0, 0, 0, 0, - 0, 0, 902, 0, 0, 0, 0, 0, 699, 700, - 701, 0, 0, 0, 0, 0, 0, 0, 64, 0, - 0, 0, 0, 0, 0, 0, 536, 537, 538, 539, - 540, 0, 541, 0, 542, 543, 544, 545, 52, 0, - 0, 546, 547, 548, 549, 550, 551, 552, 553, 65, - 554, 555, 556, 0, 0, 0, 0, 0, 0, 557, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 558, 559, - 560, 0, 15, 0, 0, 561, 562, 0, 0, 512, - 513, 0, 0, 563, 0, 564, 0, 565, 566, 514, - 515, 516, 517, 518, 0, 0, 0, 0, 0, 519, - 0, 520, 0, 0, 0, 521, 0, 0, 0, 0, - 0, 0, 0, 522, 0, 0, 0, 0, 0, 523, - 0, 0, 524, 0, 0, 525, 0, 0, 0, 526, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 527, - 0, 0, 528, 529, 0, 313, 314, 315, 0, 317, - 318, 319, 320, 321, 530, 323, 324, 325, 326, 327, - 328, 329, 330, 331, 332, 333, 0, 335, 336, 337, - 0, 0, 340, 341, 342, 343, 344, 345, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, - 358, 359, 360, 361, 362, 363, 364, 365, 366, 531, - 532, 697, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 534, 535, 0, 0, 0, - 0, 0, 0, 0, 919, 0, 0, 0, 0, 0, - 699, 700, 701, 0, 0, 0, 0, 0, 0, 0, - 64, 0, 0, 0, 0, 0, 0, 0, 536, 537, - 538, 539, 540, 0, 541, 0, 542, 543, 544, 545, - 52, 0, 0, 546, 547, 548, 549, 550, 551, 552, - 553, 65, 554, 555, 556, 0, 0, 0, 0, 0, - 0, 557, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 558, 559, 560, 0, 15, 0, 0, 561, 562, 0, - 0, 512, 513, 0, 0, 563, 0, 564, 0, 565, - 566, 514, 515, 516, 517, 518, 0, 0, 0, 0, - 0, 519, 1734, 520, 686, 0, 0, 521, 0, 0, - 0, 0, 0, 0, 0, 522, 0, 0, 0, 0, - 0, 523, 0, 0, 524, 0, 0, 525, 692, 0, - 0, 526, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 527, 0, 0, 528, 529, 0, 313, 314, 315, - 0, 317, 318, 319, 320, 321, 530, 323, 324, 325, - 326, 327, 328, 329, 330, 331, 332, 333, 0, 335, - 336, 337, 0, 0, 340, 341, 342, 343, 344, 345, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, - 366, 531, 532, 533, 1735, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 534, 535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, - 536, 537, 538, 539, 540, 0, 541, 0, 542, 543, - 544, 545, 52, 0, 0, 546, 547, 548, 549, 550, - 551, 552, 553, 65, 554, 555, 556, 0, 0, 0, - 0, 0, 0, 557, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 558, 559, 560, 0, 15, 0, 0, 561, - 562, 0, 0, 512, 513, 0, 0, 563, 0, 564, - 0, 565, 566, 514, 515, 516, 517, 518, 0, 0, - 0, 0, 0, 519, 0, 520, 0, 0, 0, 521, - 0, 0, 0, 0, 0, 0, 0, 522, 0, 0, - 0, 0, 0, 523, 0, 0, 524, 0, 0, 525, - 0, 0, 0, 526, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 527, 0, 0, 528, 529, 0, 313, - 314, 315, 0, 317, 318, 319, 320, 321, 530, 323, - 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, - 0, 335, 336, 337, 0, 0, 340, 341, 342, 343, - 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, - 364, 365, 366, 531, 532, 697, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 534, - 535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 699, 700, 701, 0, 0, 0, - 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, - 0, 0, 536, 537, 538, 539, 540, 0, 541, 0, - 542, 543, 544, 545, 52, 0, 0, 546, 547, 548, - 549, 550, 551, 552, 553, 65, 554, 555, 556, 0, - 0, 0, 0, 0, 0, 557, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 558, 559, 560, 0, 15, 0, - 0, 561, 562, 0, 0, 512, 513, 0, 0, 563, - 0, 564, 0, 565, 566, 514, 515, 516, 517, 518, - 0, 0, 0, 0, 0, 519, 0, 520, 0, 0, - 0, 521, 0, 0, 0, 0, 0, 0, 0, 522, - 0, 0, 0, 0, 0, 523, 0, 0, 524, 0, - 0, 525, 0, 0, 0, 526, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 527, 0, 0, 528, 529, - 1049, 313, 314, 315, 0, 317, 318, 319, 320, 321, - 530, 323, 324, 325, 326, 327, 328, 329, 330, 331, - 332, 333, 0, 335, 336, 337, 0, 0, 340, 341, - 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, - 362, 363, 364, 365, 366, 531, 532, 533, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 534, 535, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, - 0, 0, 0, 0, 536, 537, 538, 539, 540, 0, - 541, 1006, 542, 543, 544, 545, 52, 0, 0, 546, - 547, 548, 549, 550, 551, 552, 553, 1007, 554, 555, - 556, 0, 0, 0, 0, 0, 0, 557, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 558, 559, 560, 0, - 15, 0, 0, 561, 562, 0, 0, 512, 513, 0, - 0, 1050, 0, 564, 1051, 565, 566, 514, 515, 516, - 517, 518, 0, 0, 0, 0, 0, 519, 0, 520, - 0, 0, 0, 521, 0, 0, 0, 0, 0, 0, - 0, 522, 0, 0, 0, 0, 0, 523, 0, 0, - 524, 0, 0, 525, 0, 0, 0, 526, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 527, 0, 0, - 528, 529, 0, 313, 314, 315, 0, 317, 318, 319, - 320, 321, 530, 323, 324, 325, 326, 327, 328, 329, - 330, 331, 332, 333, 0, 335, 336, 337, 0, 0, - 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, - 360, 361, 362, 363, 364, 365, 366, 531, 532, 697, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 534, 535, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1194, 1195, - 1196, 0, 0, 0, 0, 0, 0, 0, 64, 0, - 0, 0, 0, 0, 0, 0, 536, 537, 538, 539, - 540, 0, 541, 0, 542, 543, 544, 545, 52, 0, - 0, 546, 547, 548, 549, 550, 551, 552, 553, 65, - 554, 555, 556, 0, 0, 0, 0, 0, 0, 557, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 558, 559, - 560, 0, 15, 0, 0, 561, 562, 0, 0, 0, - 0, 512, 513, 563, 0, 564, 0, 565, 566, 797, - 0, 514, 515, 516, 517, 518, 0, 0, 0, 0, - 0, 519, 0, 520, 0, 0, 0, 521, 0, 0, - 0, 0, 0, 0, 0, 522, 0, 0, 0, 0, - 0, 523, 0, 0, 524, 798, 0, 525, 0, 0, - 0, 526, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 527, 0, 0, 528, 529, 0, 313, 314, 315, - 0, 317, 318, 319, 320, 321, 530, 323, 324, 325, - 326, 327, 328, 329, 330, 331, 332, 333, 0, 335, - 336, 337, 0, 0, 340, 341, 342, 343, 344, 345, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, - 366, 531, 532, 533, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 534, 535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, - 536, 537, 538, 539, 540, 0, 541, 0, 542, 543, - 544, 545, 52, 0, 0, 546, 547, 548, 549, 550, - 551, 552, 553, 65, 554, 555, 556, 0, 0, 0, - 0, 0, 0, 557, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 558, 559, 560, 0, 15, 0, 0, 561, - 562, 0, 0, 0, 0, 512, 513, 563, 626, 564, - 0, 565, 566, 797, 0, 514, 515, 516, 517, 518, - 0, 0, 0, 0, 0, 519, 0, 520, 0, 0, - 0, 521, 0, 0, 0, 0, 0, 0, 0, 522, - 0, 0, 0, 0, 0, 523, 0, 0, 524, 798, - 0, 525, 0, 0, 0, 526, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 527, 0, 0, 528, 529, - 0, 313, 314, 315, 0, 317, 318, 319, 320, 321, - 530, 323, 324, 325, 326, 327, 328, 329, 330, 331, - 332, 333, 0, 335, 336, 337, 0, 0, 340, 341, - 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, - 362, 363, 364, 365, 366, 531, 532, 533, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 534, 535, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, - 0, 0, 0, 0, 536, 537, 538, 539, 540, 0, - 541, 1006, 542, 543, 544, 545, 52, 0, 0, 546, - 547, 548, 549, 550, 551, 552, 553, 1007, 554, 555, - 556, 0, 0, 0, 0, 0, 0, 557, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 558, 559, 560, 0, - 15, 0, 0, 561, 562, 0, 0, 0, 0, 512, - 513, 563, 0, 564, 0, 565, 566, 797, 0, 514, - 515, 516, 517, 518, 0, 0, 0, 0, 0, 519, - 0, 520, 0, 0, 0, 521, 0, 0, 0, 0, - 0, 0, 0, 522, 0, 0, 0, 0, 0, 523, - 0, 0, 524, 798, 0, 525, 0, 0, 0, 526, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 527, - 0, 0, 528, 529, 0, 313, 314, 315, 0, 317, - 318, 319, 320, 321, 530, 323, 324, 325, 326, 327, - 328, 329, 330, 331, 332, 333, 0, 335, 336, 337, - 0, 0, 340, 341, 342, 343, 344, 345, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, - 358, 359, 360, 361, 362, 363, 364, 365, 366, 531, - 532, 533, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 534, 535, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 64, 0, 0, 0, 0, 0, 0, 0, 536, 537, - 538, 539, 540, 0, 541, 0, 542, 543, 544, 545, - 52, 0, 0, 546, 547, 548, 549, 550, 551, 552, - 553, 65, 554, 555, 556, 0, 0, 0, 0, 0, - 0, 557, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 558, 559, 560, 0, 15, 0, 0, 561, 562, 0, - 0, 0, 0, 512, 513, 563, 877, 564, 0, 565, - 566, 797, 0, 514, 515, 516, 517, 518, 0, 0, - 0, 0, 0, 519, 0, 520, 0, 0, 0, 521, - 0, 0, 0, 0, 0, 0, 0, 522, 0, 0, - 0, 0, 0, 523, 0, 0, 524, 798, 0, 525, - 0, 0, 0, 526, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 527, 0, 0, 528, 529, 0, 313, - 314, 315, 0, 317, 318, 319, 320, 321, 530, 323, - 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, - 0, 335, 336, 337, 0, 0, 340, 341, 342, 343, - 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, - 364, 365, 366, 531, 532, 533, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 534, - 535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, - 0, 0, 536, 537, 538, 539, 540, 0, 541, 0, - 542, 543, 544, 545, 52, 0, 0, 546, 547, 548, - 549, 550, 551, 552, 553, 65, 554, 555, 556, 0, - 0, 0, 0, 0, 0, 557, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 558, 559, 560, 0, 15, 0, - 0, 561, 562, 0, 0, 512, 513, 0, 0, 563, - 0, 564, 0, 565, 566, 514, 515, 516, 517, 518, - 0, 0, 0, 0, 0, 519, 0, 520, 0, 0, - 0, 521, 0, 0, 0, 0, 0, 0, 0, 522, - 0, 0, 0, 0, 0, 523, 0, 0, 524, 0, - 0, 525, 0, 0, 0, 526, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 527, 0, 0, 528, 529, - 1244, 313, 314, 315, 0, 317, 318, 319, 320, 321, - 530, 323, 324, 325, 326, 327, 328, 329, 330, 331, - 332, 333, 0, 335, 336, 337, 0, 0, 340, 341, - 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, - 362, 363, 364, 365, 366, 531, 532, 533, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 534, 535, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, - 0, 0, 0, 0, 536, 537, 538, 539, 540, 0, - 541, 1006, 542, 543, 544, 545, 52, 0, 0, 546, - 547, 548, 549, 550, 551, 552, 553, 1007, 554, 555, - 556, 0, 0, 0, 0, 0, 0, 557, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 558, 559, 560, 0, - 15, 0, 0, 561, 562, 0, 0, 512, 513, 0, - 0, 563, 0, 564, 0, 565, 566, 514, 515, 516, - 517, 518, 0, 0, 0, 0, 0, 519, 0, 520, - 0, 0, 0, 521, 0, 0, 0, 0, 0, 0, - 0, 522, 0, 0, 0, 0, 0, 523, 0, 0, - 524, 0, 0, 525, 0, 0, 0, 526, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 527, 0, 0, - 528, 529, 0, 313, 314, 315, 0, 317, 318, 319, - 320, 321, 530, 323, 324, 325, 326, 327, 328, 329, - 330, 331, 332, 333, 0, 335, 336, 337, 0, 0, - 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, - 360, 361, 362, 363, 364, 365, 366, 531, 532, 533, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 534, 535, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, - 0, 0, 0, 0, 0, 0, 536, 537, 538, 539, - 540, 0, 541, 0, 542, 543, 544, 545, 52, 0, - 0, 546, 547, 548, 549, 550, 551, 552, 553, 65, - 554, 555, 556, 0, 0, 0, 0, 0, 0, 557, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 558, 559, - 560, 0, 15, 0, 0, 561, 562, 0, 0, 0, - 0, 512, 513, 563, 626, 564, 0, 565, 566, 784, - 0, 514, 515, 516, 517, 518, 0, 0, 0, 0, - 0, 519, 0, 520, 0, 0, 0, 521, 0, 0, - 0, 0, 0, 0, 0, 522, 0, 0, 0, 0, - 0, 523, 0, 0, 524, 0, 0, 525, 0, 0, - 0, 526, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 527, 0, 0, 528, 529, 0, 313, 314, 315, - 0, 317, 318, 319, 320, 321, 530, 323, 324, 325, - 326, 327, 328, 329, 330, 331, 332, 333, 0, 335, - 336, 337, 0, 0, 340, 341, 342, 343, 344, 345, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, - 366, 531, 532, 533, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 534, 535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, - 536, 537, 538, 539, 540, 0, 541, 0, 542, 543, - 544, 545, 52, 0, 0, 546, 547, 548, 549, 550, - 551, 552, 553, 65, 554, 555, 556, 0, 0, 0, - 0, 0, 0, 557, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 558, 559, 560, 0, 15, 0, 0, 561, - 562, 0, 0, 0, 0, 512, 513, 563, 0, 564, - 0, 565, 566, 804, 0, 514, 515, 516, 517, 518, - 0, 0, 0, 0, 0, 519, 0, 520, 0, 0, - 0, 521, 0, 0, 0, 0, 0, 0, 0, 522, - 0, 0, 0, 0, 0, 523, 0, 0, 524, 0, - 0, 525, 0, 0, 0, 526, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 527, 0, 0, 528, 529, - 0, 313, 314, 315, 0, 317, 318, 319, 320, 321, - 530, 323, 324, 325, 326, 327, 328, 329, 330, 331, - 332, 333, 0, 335, 336, 337, 0, 0, 340, 341, - 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, - 362, 363, 364, 365, 366, 531, 532, 533, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 534, 535, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, - 0, 0, 0, 0, 536, 537, 538, 539, 540, 0, - 541, 0, 542, 543, 544, 545, 52, 0, 0, 546, - 547, 548, 549, 550, 551, 552, 553, 65, 554, 555, - 556, 0, 0, 0, 0, 0, 0, 557, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 558, 559, 560, 0, - 15, 0, 0, 561, 562, 0, 0, 512, 513, 0, - 0, 563, 0, 564, 0, 565, 566, 514, 515, 516, - 517, 518, 0, 0, 0, 0, 0, 519, 0, 520, - 0, 0, 0, 521, 0, 0, 0, 0, 0, 0, - 0, 522, 0, 0, 0, 0, 0, 523, 0, 0, - 524, 0, 0, 525, 0, 0, 0, 526, 0, 0, - 0, 0, 0, 908, 0, 0, 0, 527, 0, 0, - 528, 529, 0, 313, 314, 315, 0, 317, 318, 319, - 320, 321, 530, 323, 324, 325, 326, 327, 328, 329, - 330, 331, 332, 333, 0, 335, 336, 337, 0, 0, - 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, - 360, 361, 362, 363, 364, 365, 366, 531, 532, 533, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 534, 535, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, - 0, 0, 0, 0, 0, 0, 536, 537, 538, 539, - 540, 0, 541, 0, 542, 543, 544, 545, 52, 0, - 0, 546, 547, 548, 549, 550, 551, 552, 553, 65, - 554, 555, 556, 0, 0, 0, 0, 0, 0, 557, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 558, 559, - 560, 0, 15, 0, 0, 561, 562, 0, 0, 512, - 513, 0, 0, 563, 0, 564, 0, 565, 566, 514, - 515, 516, 517, 518, 0, 0, 0, 0, 0, 519, - 0, 520, 0, 0, 0, 521, 0, 0, 0, 0, - 0, 0, 0, 522, 0, 0, 0, 0, 0, 523, - 0, 0, 524, 0, 0, 525, 0, 0, 0, 526, - 0, 0, 915, 0, 0, 0, 0, 0, 0, 527, - 0, 0, 528, 529, 0, 313, 314, 315, 0, 317, - 318, 319, 320, 321, 530, 323, 324, 325, 326, 327, - 328, 329, 330, 331, 332, 333, 0, 335, 336, 337, - 0, 0, 340, 341, 342, 343, 344, 345, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, - 358, 359, 360, 361, 362, 363, 364, 365, 366, 531, - 532, 533, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 534, 535, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 64, 0, 0, 0, 0, 0, 0, 0, 536, 537, - 538, 539, 540, 0, 541, 0, 542, 543, 544, 545, - 52, 0, 0, 546, 547, 548, 549, 550, 551, 552, - 553, 65, 554, 555, 556, 0, 0, 0, 0, 0, - 0, 557, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 558, 559, 560, 0, 15, 0, 0, 561, 562, 0, - 0, 512, 513, 0, 0, 563, 0, 564, 0, 565, - 566, 514, 515, 516, 517, 518, 0, 0, 0, 0, - 0, 519, 0, 520, 0, 0, 0, 521, 0, 0, - 0, 0, 0, 0, 0, 522, 0, 0, 0, 0, - 0, 523, 0, 0, 524, 0, 0, 525, 0, 0, - 0, 526, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 527, 0, 0, 528, 529, 0, 313, 314, 315, - 0, 317, 318, 319, 320, 321, 530, 323, 324, 325, - 326, 327, 328, 329, 330, 331, 332, 333, 0, 335, - 336, 337, 0, 0, 340, 341, 342, 343, 344, 345, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, - 366, 531, 532, 533, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 534, 535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, - 536, 537, 538, 539, 540, 0, 541, 0, 542, 543, - 544, 545, 52, 0, 0, 546, 547, 548, 549, 550, - 551, 552, 553, 65, 554, 555, 556, 0, 0, 0, - 0, 0, 0, 557, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 788, 0, 558, 559, 560, 0, 15, 0, 0, 561, - 562, 0, 0, 512, 513, 0, 0, 563, 0, 564, - 0, 565, 566, 514, 515, 516, 517, 518, 0, 0, - 1086, 0, 0, 519, 0, 520, 0, 0, 0, 521, - 0, 0, 0, 0, 0, 0, 0, 522, 0, 0, - 0, 0, 0, 523, 0, 0, 524, 0, 0, 525, - 0, 0, 0, 526, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 527, 0, 0, 528, 529, 0, 313, - 314, 315, 0, 317, 318, 319, 320, 321, 530, 323, - 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, - 0, 335, 336, 337, 0, 0, 340, 341, 342, 343, - 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, - 364, 365, 366, 531, 532, 533, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 534, - 535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, - 0, 0, 536, 537, 538, 539, 540, 0, 541, 0, - 542, 543, 544, 545, 52, 0, 0, 546, 547, 548, - 549, 550, 551, 552, 553, 65, 554, 555, 556, 0, - 0, 0, 0, 0, 0, 557, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 558, 559, 560, 0, 15, 0, - 0, 561, 562, 0, 0, 512, 513, 0, 0, 563, - 0, 564, 0, 565, 566, 514, 515, 516, 517, 518, - 0, 0, 0, 0, 0, 519, 0, 520, 0, 0, - 0, 521, 0, 0, 0, 0, 0, 0, 0, 522, - 0, 0, 0, 0, 0, 523, 0, 0, 524, 0, - 0, 525, 0, 0, 0, 526, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 527, 0, 0, 528, 529, - 0, 313, 314, 315, 0, 317, 318, 319, 320, 321, - 530, 323, 324, 325, 326, 327, 328, 329, 330, 331, - 332, 333, 0, 335, 336, 337, 0, 0, 340, 341, - 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, - 362, 363, 364, 365, 366, 531, 532, 533, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 534, 535, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, - 0, 0, 0, 0, 536, 537, 538, 539, 540, 0, - 541, 0, 542, 543, 544, 545, 52, 0, 0, 546, - 547, 548, 549, 550, 551, 552, 553, 65, 554, 555, - 556, 0, 0, 0, 0, 0, 0, 557, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 558, 559, 560, 0, - 15, 0, 0, 561, 562, 0, 0, 512, 513, 0, - 0, 563, 0, 564, 1107, 565, 566, 514, 515, 516, - 517, 518, 0, 0, 0, 0, 0, 519, 0, 520, - 0, 0, 0, 521, 0, 0, 0, 0, 0, 0, - 0, 522, 0, 0, 0, 0, 0, 523, 0, 0, - 524, 0, 0, 525, 0, 0, 0, 526, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 527, 0, 0, - 528, 529, 0, 313, 314, 315, 0, 317, 318, 319, - 320, 321, 530, 323, 324, 325, 326, 327, 328, 329, - 330, 331, 332, 333, 0, 335, 336, 337, 0, 0, - 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, - 360, 361, 362, 363, 364, 365, 366, 531, 532, 533, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 534, 535, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, - 0, 0, 0, 0, 0, 0, 536, 537, 538, 539, - 540, 0, 541, 0, 542, 543, 544, 545, 52, 0, - 0, 546, 547, 548, 549, 550, 551, 552, 553, 65, - 554, 555, 556, 0, 0, 0, 0, 0, 0, 557, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1248, 0, 558, 559, - 560, 0, 15, 0, 0, 561, 562, 0, 0, 512, - 513, 0, 0, 563, 0, 564, 0, 565, 566, 514, - 515, 516, 517, 518, 0, 0, 0, 0, 0, 519, - 0, 520, 0, 0, 0, 521, 0, 0, 0, 0, - 0, 0, 0, 522, 0, 0, 0, 0, 0, 523, - 0, 0, 524, 0, 0, 525, 0, 0, 0, 526, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 527, - 0, 0, 528, 529, 0, 313, 314, 315, 0, 317, - 318, 319, 320, 321, 530, 323, 324, 325, 326, 327, - 328, 329, 330, 331, 332, 333, 0, 335, 336, 337, - 0, 0, 340, 341, 342, 343, 344, 345, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, - 358, 359, 360, 361, 362, 363, 364, 365, 366, 531, - 532, 533, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 534, 535, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 64, 0, 0, 0, 0, 0, 0, 0, 536, 537, - 538, 539, 540, 0, 541, 0, 542, 543, 544, 545, - 52, 0, 0, 546, 547, 548, 549, 550, 551, 552, - 553, 65, 554, 555, 556, 0, 0, 0, 0, 0, - 0, 557, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 558, 559, 560, 0, 15, 0, 0, 561, 562, 0, - 0, 512, 513, 0, 0, 563, 0, 564, 1287, 565, - 566, 514, 515, 516, 517, 518, 0, 0, 0, 0, - 0, 519, 0, 520, 0, 0, 0, 521, 0, 0, - 0, 0, 0, 0, 0, 522, 0, 0, 0, 0, - 0, 523, 0, 0, 524, 0, 0, 525, 0, 0, - 0, 526, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 527, 0, 0, 528, 529, 0, 313, 314, 315, - 0, 317, 318, 319, 320, 321, 530, 323, 324, 325, - 326, 327, 328, 329, 330, 331, 332, 333, 0, 335, - 336, 337, 0, 0, 340, 341, 342, 343, 344, 345, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, - 366, 531, 532, 533, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 534, 535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, - 536, 537, 538, 539, 540, 0, 541, 0, 542, 543, - 544, 545, 52, 0, 0, 546, 547, 548, 549, 550, - 551, 552, 553, 65, 554, 555, 556, 0, 0, 0, - 0, 0, 0, 557, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 558, 559, 560, 0, 15, 0, 0, 561, - 562, 0, 0, 512, 513, 0, 0, 563, 0, 564, - 1302, 565, 566, 514, 515, 516, 517, 518, 0, 0, - 0, 0, 0, 519, 0, 520, 0, 0, 0, 521, - 0, 0, 0, 0, 0, 0, 0, 522, 0, 0, - 0, 0, 0, 523, 0, 0, 524, 0, 0, 525, - 0, 0, 0, 526, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 527, 0, 0, 528, 529, 0, 313, - 314, 315, 0, 317, 318, 319, 320, 321, 530, 323, - 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, - 0, 335, 336, 337, 0, 0, 340, 341, 342, 343, - 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, - 364, 365, 366, 531, 532, 533, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 534, - 535, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, - 0, 0, 536, 537, 538, 539, 540, 0, 541, 0, - 542, 543, 544, 545, 52, 0, 0, 546, 547, 548, - 549, 550, 551, 552, 553, 65, 554, 555, 556, 0, - 0, 0, 0, 0, 0, 557, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 558, 559, 560, 0, 15, 0, - 0, 561, 562, 0, 0, 512, 513, 0, 0, 563, - 0, 564, 1530, 565, 566, 514, 515, 516, 517, 518, - 0, 0, 0, 0, 0, 519, 0, 520, 0, 0, - 0, 521, 0, 0, 0, 0, 0, 0, 0, 522, - 0, 0, 0, 0, 0, 523, 0, 0, 524, 0, - 0, 525, 0, 0, 0, 526, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 527, 0, 0, 528, 529, - 0, 313, 314, 315, 0, 317, 318, 319, 320, 321, - 530, 323, 324, 325, 326, 327, 328, 329, 330, 331, - 332, 333, 0, 335, 336, 337, 0, 0, 340, 341, - 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, - 362, 363, 364, 365, 366, 531, 532, 533, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 534, 535, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, - 0, 0, 0, 0, 536, 537, 538, 539, 540, 0, - 541, 0, 542, 543, 544, 545, 52, 0, 0, 546, - 547, 548, 549, 550, 551, 552, 553, 65, 554, 555, - 556, 0, 0, 0, 0, 0, 0, 557, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 558, 559, 560, 0, - 15, 0, 0, 561, 562, 0, 0, 512, 513, 0, - 0, 1539, 0, 564, 1540, 565, 566, 514, 515, 516, - 517, 518, 0, 0, 0, 0, 0, 519, 0, 520, - 0, 0, 0, 521, 0, 0, 0, 0, 0, 0, - 0, 522, 0, 0, 0, 0, 0, 523, 0, 0, - 524, 0, 0, 525, 0, 0, 0, 526, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 527, 0, 0, - 528, 529, 0, 313, 314, 315, 0, 317, 318, 319, - 320, 321, 530, 323, 324, 325, 326, 327, 328, 329, - 330, 331, 332, 333, 0, 335, 336, 337, 0, 0, - 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, - 360, 361, 362, 363, 364, 365, 366, 531, 532, 533, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 534, 535, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, - 0, 0, 0, 0, 0, 0, 536, 537, 538, 539, - 540, 0, 541, 0, 542, 543, 544, 545, 52, 0, - 0, 546, 547, 548, 549, 550, 551, 552, 553, 65, - 554, 555, 556, 0, 0, 0, 0, 0, 0, 557, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 558, 559, - 560, 0, 15, 0, 0, 561, 562, 0, 0, 512, - 513, 0, 0, 563, 0, 564, 1545, 565, 566, 514, - 515, 516, 517, 518, 0, 0, 0, 0, 0, 519, - 0, 520, 0, 0, 0, 521, 0, 0, 0, 0, - 0, 0, 0, 522, 0, 0, 0, 0, 0, 523, - 0, 0, 524, 0, 0, 525, 0, 0, 0, 526, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 527, - 0, 0, 528, 529, 0, 313, 314, 315, 0, 317, - 318, 319, 320, 321, 530, 323, 324, 325, 326, 327, - 328, 329, 330, 331, 332, 333, 0, 335, 336, 337, - 0, 0, 340, 341, 342, 343, 344, 345, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, - 358, 359, 360, 361, 362, 363, 364, 365, 366, 531, - 532, 533, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 534, 535, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 64, 0, 0, 0, 0, 0, 0, 0, 536, 537, - 538, 539, 540, 0, 541, 0, 542, 543, 544, 545, - 52, 0, 0, 546, 547, 548, 549, 550, 551, 552, - 553, 65, 554, 555, 556, 0, 0, 0, 0, 0, - 0, 557, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 558, 559, 560, 0, 15, 0, 0, 561, 562, 0, - 0, 512, 513, 0, 0, 563, 0, 564, 1603, 565, - 566, 514, 515, 516, 517, 518, 0, 0, 0, 0, - 0, 519, 0, 520, 0, 0, 0, 521, 0, 0, - 0, 0, 0, 0, 0, 522, 0, 0, 0, 0, - 0, 523, 0, 0, 524, 0, 0, 525, 0, 0, - 0, 526, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 527, 0, 0, 528, 529, 0, 313, 314, 315, - 0, 317, 318, 319, 320, 321, 530, 323, 324, 325, - 326, 327, 328, 329, 330, 331, 332, 333, 0, 335, - 336, 337, 0, 0, 340, 341, 342, 343, 344, 345, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, - 366, 531, 532, 533, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 534, 535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, - 536, 537, 538, 539, 540, 0, 541, 0, 542, 543, - 544, 545, 52, 0, 0, 546, 547, 548, 549, 550, - 551, 552, 553, 65, 554, 555, 556, 0, 0, 0, - 0, 0, 0, 557, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 558, 559, 560, 0, 15, 0, 0, 561, - 562, 0, 0, 512, 513, 0, 0, 563, 0, 564, - 1695, 565, 566, 514, 515, 516, 517, 518, 0, 0, - 0, 0, 0, 519, 0, 520, 0, 0, 0, 521, - 0, 0, 0, 0, 0, 0, 0, 522, 0, 0, - 0, 0, 0, 523, 0, 0, 524, 0, 0, 525, - 0, 0, 0, 526, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 527, 0, 0, 528, 529, 0, 313, - 314, 315, 0, 317, 318, 319, 320, 321, 530, 323, - 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, - 0, 335, 336, 337, 0, 0, 340, 341, 342, 343, - 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, - 364, 365, 366, 531, 532, 533, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 534, - 535, 0, 0, 0, 0, 0, 0, 0, 1721, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, - 0, 0, 536, 537, 538, 539, 540, 0, 541, 0, - 542, 543, 544, 545, 52, 0, 0, 546, 547, 548, - 549, 550, 551, 552, 553, 65, 554, 555, 556, 0, - 0, 0, 0, 0, 0, 557, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 558, 559, 560, 0, 15, 0, - 0, 561, 562, 0, 0, 512, 513, 0, 0, 563, - 0, 564, 0, 565, 566, 514, 515, 516, 517, 518, - 0, 0, 0, 0, 0, 519, 0, 520, 0, 0, - 0, 521, 0, 0, 0, 0, 0, 0, 0, 522, - 0, 0, 0, 0, 0, 523, 0, 0, 524, 0, - 0, 525, 0, 0, 0, 526, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 527, 0, 0, 528, 529, - 0, 313, 314, 315, 0, 317, 318, 319, 320, 321, - 530, 323, 324, 325, 326, 327, 328, 329, 330, 331, - 332, 333, 0, 335, 336, 337, 0, 0, 340, 341, - 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, - 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, - 362, 363, 364, 365, 366, 531, 532, 533, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 534, 535, 0, 0, 0, 0, 0, 0, 0, - 1789, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, - 0, 0, 0, 0, 536, 537, 538, 539, 540, 0, - 541, 0, 542, 543, 544, 545, 52, 0, 0, 546, - 547, 548, 549, 550, 551, 552, 553, 65, 554, 555, - 556, 0, 0, 0, 0, 0, 0, 557, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 558, 559, 560, 0, - 15, 0, 0, 561, 562, 0, 0, 512, 513, 0, - 0, 563, 0, 564, 0, 565, 566, 514, 515, 516, - 517, 518, 0, 0, 0, 0, 0, 519, 0, 520, - 0, 0, 0, 521, 0, 0, 0, 0, 0, 0, - 0, 522, 0, 0, 0, 0, 0, 523, 0, 0, - 524, 0, 0, 525, 0, 0, 0, 526, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 527, 0, 0, - 528, 529, 0, 313, 314, 315, 0, 317, 318, 319, - 320, 321, 530, 323, 324, 325, 326, 327, 328, 329, - 330, 331, 332, 333, 0, 335, 336, 337, 0, 0, - 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, - 360, 361, 362, 363, 364, 365, 366, 531, 532, 533, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 534, 535, 0, 0, 0, 0, 0, - 0, 0, 1790, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, - 0, 0, 0, 0, 0, 0, 536, 537, 538, 539, - 540, 0, 541, 0, 542, 543, 544, 545, 52, 0, - 0, 546, 547, 548, 549, 550, 551, 552, 553, 65, - 554, 555, 556, 0, 0, 0, 0, 0, 0, 557, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 558, 559, - 560, 0, 15, 0, 0, 561, 562, 0, 0, 512, - 513, 0, 0, 563, 0, 564, 0, 565, 566, 514, - 515, 516, 517, 518, 0, 0, 0, 0, 0, 519, - 0, 520, 0, 0, 0, 521, 0, 0, 0, 0, - 0, 0, 0, 522, 0, 0, 0, 0, 0, 523, - 0, 0, 524, 0, 0, 525, 0, 0, 0, 526, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 527, - 0, 0, 528, 529, 0, 313, 314, 315, 0, 317, - 318, 319, 320, 321, 530, 323, 324, 325, 326, 327, - 328, 329, 330, 331, 332, 333, 0, 335, 336, 337, - 0, 0, 340, 341, 342, 343, 344, 345, 346, 347, - 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, - 358, 359, 360, 361, 362, 363, 364, 365, 366, 531, - 532, 533, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 534, 535, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 64, 0, 0, 0, 0, 0, 0, 0, 536, 537, - 538, 539, 540, 0, 541, 0, 542, 543, 544, 545, - 52, 0, 0, 546, 547, 548, 549, 550, 551, 552, - 553, 65, 554, 555, 556, 0, 0, 0, 0, 0, - 0, 557, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 558, 559, 560, 0, 15, 0, 0, 561, 562, 0, - 0, 512, 513, 0, 0, 563, 0, 564, 0, 565, - 566, 514, 515, 516, 517, 518, 0, 0, 0, 0, - 0, 519, 0, 520, 0, 0, 0, 521, 0, 0, - 0, 0, 0, 0, 0, 522, 0, 0, 0, 0, - 0, 523, 0, 0, 524, 0, 0, 525, 0, 0, - 0, 526, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 527, 0, 0, 528, 529, 0, 313, 314, 315, - 0, 317, 318, 319, 320, 321, 530, 323, 324, 325, - 326, 327, 328, 329, 330, 331, 332, 333, 0, 335, - 336, 337, 0, 0, 340, 341, 342, 343, 344, 345, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, - 366, 531, 532, 533, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 534, 535, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, - 536, 537, 538, 539, 540, 0, 541, 0, 542, 543, - 544, 545, 52, 0, 0, 546, 547, 548, 549, 550, - 551, 552, 553, 65, 554, 555, 556, 0, 0, 780, - 0, 0, 0, 557, 0, 307, 0, 0, 0, 0, - 0, 308, 0, 0, 0, 0, 0, 309, 0, 0, - 0, 0, 558, 559, 560, 0, 15, 310, 0, 561, - 562, 0, 0, 0, 0, 311, 0, 1516, 0, 564, - 0, 565, 566, 0, 0, 0, 0, 0, 0, 0, - 312, 0, 0, 0, 0, 0, 0, 313, 314, 315, - 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, - 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, - 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, - 366, 367, 368, 0, 1112, 1113, 1114, 1115, 1116, 1117, - 1118, 1119, 0, 0, 0, 0, 0, 1120, 1121, 0, - 0, 0, 0, 1122, 0, 0, 0, 0, -438, 0, - 0, 0, 0, 956, 0, 0, 1123, 1124, 0, 0, - 0, 0, 64, 1125, 1126, 1127, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 369, 0, 0, 0, 0, - 0, 0, 0, 0, 782, 0, 0, 0, 0, 0, - 307, 0, 0, 65, 0, 0, 308, 0, 0, 0, - 0, 0, 309, 0, 0, 0, 0, 0, 0, 0, - 0, 1128, 310, 0, 0, 0, 0, 0, 0, 0, - 311, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 312, 0, 0, 565, 922, - 0, 370, 313, 314, 315, 316, 317, 318, 319, 320, - 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, - 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, - 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, - 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, - 361, 362, 363, 364, 365, 366, 367, 368, 0, 1112, - 1113, 1114, 1115, 1116, 1117, 1118, 1119, 0, 0, 0, - 0, 0, 1120, 1121, 0, 0, 0, 0, 1122, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 956, 0, - 0, 1123, 1124, 0, 0, 0, 0, 64, 1125, 1126, - 1127, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 369, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 307, 0, 0, 65, 0, - 0, 308, 0, 0, 0, 0, 0, 309, 0, 0, - 0, 0, 0, 0, 0, 0, 1128, 310, 0, 0, - 0, 0, 0, 0, 0, 311, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 312, 0, 0, 565, 922, 0, 370, 313, 314, 315, - 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, - 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, - 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, - 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, - 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, - 366, 367, 368, 0, 1112, 1113, 1114, 1115, 1116, 1117, - 1118, 1119, 0, 0, 0, 0, 0, 1120, 1121, 0, - 0, 0, 0, 1122, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 956, 0, 0, 1123, 1124, 0, 0, - 0, 0, 64, 1125, 1126, 1127, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 369, 0, 0, 0, 0, - 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 307, 65, 0, 0, 0, 0, 308, 0, - 0, 0, 14, 0, 309, 0, 0, 0, 0, 0, - 0, 1128, 0, 0, 310, 0, 0, 0, 0, 0, - 0, 0, 311, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 312, 565, 922, - 0, 370, 0, 629, 313, 314, 315, 316, 317, 318, - 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, - 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, - 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, - 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, - 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 369, 0, 0, 0, 0, 0, 0, 0, - 0, 13, 0, 0, 0, 0, 0, 307, 0, 0, - 633, 0, 0, 308, 0, 0, 0, 0, 0, 309, - 0, 0, 14, 0, 0, 0, 0, 0, 0, 310, - 634, 0, 0, 0, 0, 0, 0, 311, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 312, 0, 0, 0, 0, 0, 370, 313, - 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, - 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, - 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, - 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, - 364, 365, 366, 367, 368, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 369, 0, 0, - 0, 0, 811, 812, 0, 0, 0, 0, 0, 0, - 0, 0, 307, 0, 0, 65, 0, 0, 308, 0, - 0, 0, 0, 0, 309, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 310, 0, 0, 0, 0, 0, - 0, 0, 311, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 312, 0, 0, - 0, 0, 0, 370, 313, 314, 315, 316, 317, 318, - 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, - 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, - 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, - 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, - 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, - 813, 814, 815, 816, 817, 811, 812, 818, 819, 820, - 821, 0, 822, 823, 824, 825, 0, 0, 0, 0, - 826, 0, 827, 828, 0, 0, 0, 0, 829, 830, - 831, 0, 0, 0, 832, 0, 0, 0, 0, 64, - 811, 812, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 369, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 633, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 833, 0, 834, 835, 836, 837, 838, 839, 840, 841, - 842, 843, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 844, 845, 0, 0, 1261, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 370, 0, - 0, 0, 0, 813, 814, 815, 816, 817, 0, 0, - 818, 819, 820, 821, 0, 822, 823, 824, 825, 0, - 0, 0, 0, 826, 0, 827, 828, 811, 812, 0, - 0, 829, 830, 831, 0, 0, 0, 832, 813, 814, - 815, 816, 817, 0, 0, 818, 819, 820, 821, 0, - 822, 823, 824, 825, 0, 0, 0, 0, 826, 0, - 827, 828, 811, 812, 0, 0, 829, 830, 831, 0, - 0, 0, 832, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 833, 0, 834, 835, 836, 837, 838, - 839, 840, 841, 842, 843, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 844, 845, 0, 0, 1264, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 833, 0, - 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 844, - 845, 0, 0, 1266, 0, 813, 814, 815, 816, 817, - 0, 0, 818, 819, 820, 821, 0, 822, 823, 824, - 825, 0, 0, 0, 0, 826, 0, 827, 828, 811, - 812, 0, 0, 829, 830, 831, 0, 0, 0, 832, - 813, 814, 815, 816, 817, 0, 0, 818, 819, 820, - 821, 0, 822, 823, 824, 825, 0, 0, 0, 0, - 826, 0, 827, 828, 811, 812, 0, 0, 829, 830, - 831, 0, 0, 0, 832, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 833, 0, 834, 835, 836, - 837, 838, 839, 840, 841, 842, 843, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 844, 845, 0, 0, - 1274, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 833, 0, 834, 835, 836, 837, 838, 839, 840, 841, - 842, 843, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 844, 845, 0, 0, 1275, 0, 813, 814, 815, - 816, 817, 0, 0, 818, 819, 820, 821, 0, 822, - 823, 824, 825, 0, 0, 0, 0, 826, 0, 827, - 828, 811, 812, 0, 0, 829, 830, 831, 0, 0, - 0, 832, 813, 814, 815, 816, 817, 0, 0, 818, - 819, 820, 821, 0, 822, 823, 824, 825, 0, 0, - 0, 0, 826, 0, 827, 828, 811, 812, 0, 0, - 829, 830, 831, 0, 0, 0, 832, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 833, 0, 834, - 835, 836, 837, 838, 839, 840, 841, 842, 843, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 844, 845, - 0, 0, 1276, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 833, 0, 834, 835, 836, 837, 838, 839, - 840, 841, 842, 843, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 844, 845, 0, 0, 1277, 0, 813, - 814, 815, 816, 817, 0, 0, 818, 819, 820, 821, - 0, 822, 823, 824, 825, 0, 0, 0, 0, 826, - 0, 827, 828, 811, 812, 0, 0, 829, 830, 831, - 0, 0, 0, 832, 813, 814, 815, 816, 817, 0, - 0, 818, 819, 820, 821, 0, 822, 823, 824, 825, - 0, 0, 0, 0, 826, 0, 827, 828, 811, 812, - 0, 0, 829, 830, 831, 0, 0, 0, 832, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 833, - 0, 834, 835, 836, 837, 838, 839, 840, 841, 842, - 843, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 844, 845, 0, 0, 1278, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 833, 0, 834, 835, 836, 837, - 838, 839, 840, 841, 842, 843, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 844, 845, 0, 0, 1279, - 0, 813, 814, 815, 816, 817, 0, 0, 818, 819, - 820, 821, 0, 822, 823, 824, 825, 0, 0, 0, - 0, 826, 0, 827, 828, 811, 812, 0, 0, 829, - 830, 831, 0, 0, 0, 832, 813, 814, 815, 816, - 817, 0, 0, 818, 819, 820, 821, 0, 822, 823, - 824, 825, 0, 0, 0, 0, 826, 0, 827, 828, - 811, 812, 0, 0, 829, 830, 831, 0, 0, 0, - 832, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 833, 0, 834, 835, 836, 837, 838, 839, 840, - 841, 842, 843, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 844, 845, 0, 0, 1555, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 833, 0, 834, 835, - 836, 837, 838, 839, 840, 841, 842, 843, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 844, 845, 0, - 0, 1606, 0, 813, 814, 815, 816, 817, 0, 0, - 818, 819, 820, 821, 0, 822, 823, 824, 825, 0, - 0, 0, 0, 826, 0, 827, 828, 811, 812, 0, - 0, 829, 830, 831, 0, 0, 0, 832, 813, 814, - 815, 816, 817, 0, 0, 818, 819, 820, 821, 0, - 822, 823, 824, 825, 0, 0, 0, 0, 826, 0, - 827, 828, 811, 812, 0, 0, 829, 830, 831, 0, - 0, 0, 832, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 833, 0, 834, 835, 836, 837, 838, - 839, 840, 841, 842, 843, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 844, 845, 0, 0, 1625, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 833, 0, - 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 844, - 845, 0, 0, 1626, 0, 813, 814, 815, 816, 817, - 0, 0, 818, 819, 820, 821, 0, 822, 823, 824, - 825, 0, 0, 0, 0, 826, 0, 827, 828, 811, - 812, 0, 0, 829, 830, 831, 0, 0, 0, 832, - 813, 814, 815, 816, 817, 0, 0, 818, 819, 820, - 821, 0, 822, 823, 824, 825, 0, 0, 0, 0, - 826, 0, 827, 828, 811, 812, 0, 0, 829, 830, - 831, 0, 0, 0, 832, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 833, 0, 834, 835, 836, - 837, 838, 839, 840, 841, 842, 843, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 844, 845, 0, 0, - 1640, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 833, 0, 834, 835, 836, 837, 838, 839, 840, 841, - 842, 843, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 844, 845, 0, 0, 1642, 0, 813, 814, 815, - 816, 817, 0, 0, 818, 819, 820, 821, 0, 822, - 823, 824, 825, 0, 0, 0, 0, 826, 0, 827, - 828, 811, 812, 0, 0, 829, 830, 831, 0, 0, - 0, 832, 813, 814, 815, 816, 817, 0, 0, 818, - 819, 820, 821, 0, 822, 823, 824, 825, 0, 0, - 0, 0, 826, 0, 827, 828, 811, 812, 0, 0, - 829, 830, 831, 0, 0, 0, 832, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 833, 0, 834, - 835, 836, 837, 838, 839, 840, 841, 842, 843, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 844, 845, - 0, 0, 1644, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 833, 0, 834, 835, 836, 837, 838, 839, - 840, 841, 842, 843, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 844, 845, 0, 0, 1648, 0, 813, - 814, 815, 816, 817, 0, 0, 818, 819, 820, 821, - 0, 822, 823, 824, 825, 0, 0, 0, 0, 826, - 0, 827, 828, 811, 812, 0, 0, 829, 830, 831, - 0, 0, 0, 832, 813, 814, 815, 816, 817, 0, - 0, 818, 819, 820, 821, 0, 822, 823, 824, 825, - 0, 0, 0, 0, 826, 0, 827, 828, 811, 812, - 0, 0, 829, 830, 831, 0, 0, 0, 832, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 833, - 0, 834, 835, 836, 837, 838, 839, 840, 841, 842, - 843, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 844, 845, 0, 0, 1726, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 833, 0, 834, 835, 836, 837, - 838, 839, 840, 841, 842, 843, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 844, 845, 0, 0, 1727, - 0, 813, 814, 815, 816, 817, 0, 0, 818, 819, - 820, 821, 0, 822, 823, 824, 825, 0, 0, 0, - 0, 826, 0, 827, 828, 811, 812, 0, 0, 829, - 830, 831, 0, 0, 0, 832, 813, 814, 815, 816, - 817, 0, 0, 818, 819, 820, 821, 0, 822, 823, - 824, 825, 0, 0, 0, 0, 826, 0, 827, 828, - 811, 812, 0, 0, 829, 830, 831, 0, 0, 0, - 832, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 833, 0, 834, 835, 836, 837, 838, 839, 840, - 841, 842, 843, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 844, 845, 0, 0, 1729, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 833, 0, 834, 835, - 836, 837, 838, 839, 840, 841, 842, 843, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 844, 845, 0, - 0, 1764, 0, 813, 814, 815, 816, 817, 0, 0, - 818, 819, 820, 821, 0, 822, 823, 824, 825, 0, - 0, 0, 0, 826, 0, 827, 828, 811, 812, 0, - 0, 829, 830, 831, 0, 0, 0, 832, 813, 814, - 815, 816, 817, 0, 0, 818, 819, 820, 821, 0, - 822, 823, 824, 825, 0, 0, 0, 0, 826, 0, - 827, 828, 811, 812, 0, 0, 829, 830, 831, 0, - 0, 0, 832, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 833, 0, 834, 835, 836, 837, 838, - 839, 840, 841, 842, 843, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 844, 845, 0, 0, 1769, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 833, 0, - 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 844, - 845, 878, 0, 0, 0, 813, 814, 815, 816, 817, - 0, 0, 818, 819, 820, 821, 0, 822, 823, 824, - 825, 0, 0, 0, 0, 826, 0, 827, 828, 811, - 812, 0, 0, 829, 830, 831, 0, 0, 0, 832, - 813, 814, 815, 816, 817, 0, 0, 818, 819, 820, - 821, 0, 822, 823, 824, 825, 0, 0, 0, 0, - 826, 0, 827, 828, 811, 812, 0, 0, 829, 830, - 831, 0, 0, 0, 832, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 833, 0, 834, 835, 836, - 837, 838, 839, 840, 841, 842, 843, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 844, 845, 1152, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 833, 0, 834, 835, 836, 837, 838, 839, 840, 841, - 842, 843, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 844, 845, 1351, 0, 0, 0, 813, 814, 815, - 816, 817, 0, 0, 818, 819, 820, 821, 0, 822, - 823, 824, 825, 0, 0, 0, 0, 826, 0, 827, - 828, 811, 812, 0, 0, 829, 830, 831, 0, 0, - 0, 832, 813, 814, 815, 816, 817, 0, 0, 818, - 819, 820, 821, 0, 822, 823, 824, 825, 0, 0, - 0, 0, 826, 0, 827, 828, 0, 0, 0, 0, - 829, 830, 831, 0, 0, 0, 832, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 833, 0, 834, - 835, 836, 837, 838, 839, 840, 841, 842, 843, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 844, 845, - 1367, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 833, 0, 834, 835, 836, 837, 838, 839, - 840, 841, 842, 843, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 844, 845, 1537, 0, 0, 0, 813, - 814, 815, 816, 817, 0, 0, 818, 819, 820, 821, - 0, 822, 823, 824, 825, 385, 386, 0, 0, 826, - 0, 827, 828, 0, 0, 0, 0, 829, 830, 831, - 0, 0, 387, 832, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 811, 812, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 833, - 0, 834, 835, 836, 837, 838, 839, 840, 841, 842, - 843, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 844, 845, 1543, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 388, 389, 390, 391, 392, - 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, - 403, 404, 405, 0, 0, 406, 407, 408, 0, 0, - 0, 0, 0, 0, 409, 410, 411, 412, 413, 0, - 0, 414, 415, 416, 417, 418, 419, 420, 811, 812, - 0, 0, 0, 0, 0, 0, 813, 814, 815, 816, - 817, 0, 0, 818, 819, 820, 821, 0, 822, 823, - 824, 825, 0, 0, 0, 0, 826, 0, 827, 828, - 0, 0, 0, 0, 829, 830, 831, 811, 812, 0, - 832, 0, 0, 421, 0, 422, 423, 424, 425, 426, - 427, 428, 429, 430, 431, 13, 0, 432, 433, 0, - 0, 0, 0, 0, 434, 435, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 833, 0, 834, 835, - 836, 837, 838, 839, 840, 841, 842, 843, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 844, 845, 0, - 0, 0, 0, 0, 0, 0, 813, 814, 815, 816, - 817, 0, 0, 818, 819, 820, 821, 0, 822, 823, - 824, 825, 0, 811, 812, 0, 826, 0, 827, 828, - 0, 0, 0, 0, 829, 830, 831, 0, 0, 0, - 832, 0, 0, 0, 0, 813, 814, 815, 816, 817, - 0, 0, 818, 819, 820, 821, 0, 822, 823, 824, - 825, 811, 812, 0, 0, 826, 0, 827, 828, 0, - 0, 0, 0, 829, 830, 831, 0, 0, 0, 832, - 0, 0, 0, 0, 0, 0, 833, 1356, 834, 835, - 836, 837, 838, 839, 840, 841, 842, 843, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 844, 845, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 833, 0, 834, 835, 836, - 837, 838, 839, 840, 841, 842, 843, 0, 0, 0, - 0, 813, 814, 815, 816, 817, 844, 845, 818, 819, - 820, 821, 0, 822, 823, 824, 825, 811, 812, 0, - 0, 826, 0, 827, 828, 0, 0, 0, 0, 829, - 830, 831, 0, 0, 0, -881, 0, 0, 0, 813, - 814, 815, 816, 817, 0, 0, 818, 819, 820, 821, - 0, 822, 823, 824, 825, 0, 0, 0, 0, 826, - 0, 827, 828, 0, 0, 0, 0, 829, 830, 831, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 833, 0, 834, 835, 836, 837, 838, 839, 840, - 841, 842, 843, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 844, 845, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 833, - 0, 834, 835, 836, 837, 838, 839, 840, 841, 842, - 843, 0, 0, 0, 0, 813, 814, 815, 816, 817, - 844, 845, 818, 819, 820, 821, 0, 822, 823, 824, - 825, 0, 0, 0, 0, 826, 0, 827, 828, 0, - 0, 0, 0, 829, 0, 831, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1058, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 834, 835, 836, - 837, 838, 839, 840, 841, 842, 843, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 844, 845, 313, 314, - 315, 1062, 317, 318, 319, 320, 321, 530, 323, 324, - 325, 326, 327, 328, 329, 330, 331, 332, 333, 0, - 335, 336, 337, 0, 0, 340, 341, 342, 343, 344, - 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, - 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, - 365, 366, 0, 313, 314, 315, 0, 317, 318, 319, - 320, 321, 530, 323, 324, 325, 326, 327, 328, 329, - 330, 331, 332, 333, 0, 335, 336, 337, 0, 0, - 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, - 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, - 360, 361, 362, 363, 364, 365, 366, 0, 1059, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1060, 0, 0, 0, 1352, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1063, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1064, - 313, 314, 315, 0, 317, 318, 319, 320, 321, 530, - 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, - 333, 0, 335, 336, 337, 0, 0, 340, 341, 342, - 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, - 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, - 363, 364, 365, 366, 313, 314, 315, 0, 317, 318, - 319, 320, 321, 530, 323, 324, 325, 326, 327, 328, - 329, 330, 331, 332, 333, 0, 335, 336, 337, 0, - 0, 340, 341, 342, 343, 344, 345, 346, 347, 348, - 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, - 359, 360, 361, 362, 363, 364, 365, 366, 0, 0, - 1353, 0, 0, 0, 0, 0, 0, 0, 0, 230, - 0, 0, 0, 0, 0, 0, 1354, 0, 0, 0, - 0, 0, 0, 0, 0, 1098, 1099, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 231, 0, 232, 0, 233, - 234, 235, 236, 237, 1100, 238, 239, 240, 241, 242, - 243, 244, 245, 246, 247, 248, 0, 249, 250, 251, - 1101, 0, 252, 253, 254, 255, 256, 257, 258, 259, - 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, - 270, 271, 272, 273, 274, 275, 276, 277, 278, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1102, 1103, 279, 280, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 281 -}; - -static const yytype_int16 yycheck[] = -{ - 1, 545, 7, 157, 213, 595, 618, 758, 283, 509, - 504, 504, 487, 719, 182, 15, 16, 802, 783, 20, - 455, 609, 807, 611, 781, 613, 783, 486, 449, 700, - 701, 895, 599, 865, 1291, 867, 1426, 869, 1013, 994, - 20, 87, 996, 973, 1019, 33, 1183, 5, 20, 484, - 1406, 224, 809, 20, 33, 8, 53, 22, 780, 20, - 782, 4, 784, 20, 15, 16, 20, 53, 20, 113, - 70, 71, 72, 1670, 166, 797, 576, 486, 487, 149, - 20, 183, 804, 20, 293, 175, 1573, 40, 15, 16, - 178, 876, 57, 183, 20, 183, 189, 46, 21, 22, - 20, 102, 166, 19, 20, 197, 599, 197, 543, 544, - 12, 7, 149, 1716, 114, 115, 116, 117, 685, 1049, - 149, 23, 24, 166, 57, 150, 131, 181, 188, 297, - 63, 698, 0, 197, 220, 160, 1273, 223, 150, 7, - 167, 168, 169, 197, 246, 12, 197, 181, 160, 209, - 220, 243, 1749, 243, 50, 225, 23, 24, 246, 152, - 153, 564, 30, 197, 32, 150, 34, 125, 126, 215, - 214, 62, 40, 243, 179, 160, 1779, 220, 900, 1666, - 129, 166, 50, 220, 181, 197, 246, 186, 56, 217, - 244, 220, 685, 218, 245, 57, 225, 982, 203, 204, - 197, 63, 188, 245, 246, 698, 218, 992, 207, 243, - 995, 223, 80, 34, 243, 216, 973, 244, 141, 142, - 504, 220, 227, 209, 224, 1482, 149, 636, 151, 152, - 153, 154, 641, 218, 187, 223, 159, 217, 189, 167, - 183, 169, 63, 194, 223, 217, 197, 240, 241, 200, - 217, 21, 22, 241, 300, 208, 217, 125, 126, 247, - 217, 1617, 189, 217, 229, 217, 224, 194, 1053, 217, - 197, 1661, 943, 200, 218, 240, 485, 217, 283, 220, - 217, 197, 685, 850, 1421, 243, 188, 292, 241, 443, - 295, 217, 1049, 1050, 1431, 504, 505, 217, 149, 1254, - 509, 1255, 188, 226, 227, 228, 229, 230, 197, 130, - 1032, 1033, 1287, 1035, 1244, 599, 243, 240, 241, 246, - 188, 188, 757, 149, 1705, 187, 1707, 175, 501, 502, - 186, 217, 1713, 217, 1005, 902, 771, 1718, 159, 150, - 55, 209, 1732, 201, 202, 166, 208, 47, 150, 197, - 1607, 207, 919, 756, 243, 175, 510, 850, 160, 186, - 244, 149, 230, 766, 152, 153, 769, 67, 175, 220, - 370, 141, 142, 241, 225, 33, 197, 197, 224, 149, - 207, 151, 152, 153, 154, 57, 101, 243, 178, 159, - 197, 63, 243, 183, 220, 150, 1777, 243, 150, 225, - 229, 685, 60, 61, 188, 150, 809, 218, 160, 902, - 221, 217, 687, 234, 698, 160, 218, 243, 217, 1599, - 217, 696, 243, 243, 924, 209, 919, 600, 601, 602, - 639, 604, 605, 217, 643, 608, 243, 610, 244, 612, - 150, 1822, 1823, 242, 847, 445, 1168, 244, 857, 188, - 160, 188, 240, 241, 244, 455, 246, 217, 228, 229, - 230, 155, 217, 218, 873, 220, 218, 186, 223, 1057, - 240, 241, 209, 218, 166, 212, 166, 1858, 217, 218, - 12, 1025, 242, 918, 484, 175, 486, 1244, 207, 147, - 180, 23, 24, 151, 188, 1675, 1676, 220, 165, 902, - 223, 501, 502, 1047, 217, 242, 1481, 197, 218, 21, - 22, 188, 1344, 1693, 1694, 209, 516, 517, 1493, 186, - 188, 942, 1287, 1194, 1195, 1196, 245, 246, 217, 242, - 1287, 1751, 209, 1290, 224, 970, 971, 1302, 188, 217, - 207, 209, 1762, 543, 544, 1302, 981, 47, 225, 217, - 1414, 986, 987, 217, 989, 244, 991, 225, 993, 209, - 173, 219, 197, 57, 242, 223, 850, 225, 226, 63, - 973, 221, 217, 741, 983, 229, 1756, 1757, 5, 6, - 244, 8, 736, 241, 197, 198, 199, 1807, 1808, 247, - 90, 91, 186, 93, 595, 1317, 805, 242, 217, 188, - 600, 601, 602, 243, 604, 605, 217, 1010, 608, 36, - 610, 217, 612, 207, 614, 1018, 229, 230, 902, 217, - 209, 1485, 217, 217, 899, 244, 173, 240, 217, 141, - 142, 217, 221, 244, 217, 919, 911, 149, 244, 151, - 152, 153, 154, 130, 242, 21, 22, 159, 130, 244, - 197, 198, 199, 928, 212, 213, 931, 130, 244, 242, - 188, 945, 946, 947, 948, 949, 950, 951, 952, 953, - 954, 955, 1147, 957, 958, 959, 960, 961, 962, 224, - 1512, 209, 687, 230, 242, 10, 1145, 188, 1188, 217, - 217, 696, 693, 240, 699, 700, 701, 225, 188, 70, - 71, 72, 875, 166, 705, 706, 96, 97, 209, 189, - 209, 884, 175, 1464, 887, 217, 217, 244, 217, 209, - 721, 722, 723, 724, 225, 726, 188, 217, 240, 241, - 731, 1563, 188, 188, 197, 225, 1324, 188, 738, 1148, - 242, 217, 1606, 114, 115, 116, 117, 209, 217, 749, - 57, 188, 217, 209, 209, 217, 63, 757, 209, 1516, - 197, 217, 217, 225, 188, 141, 142, 218, 244, 225, - 225, 771, 209, 149, 217, 244, 152, 153, 154, 244, - 217, 188, 1539, 159, 187, 209, 787, 131, 132, 133, - 134, 135, 136, 137, 138, 217, 217, 197, 224, 972, - 188, 244, 209, 803, 977, 208, 131, 132, 133, 134, - 135, 136, 137, 138, 175, 240, 160, 243, 1253, 144, - 145, 209, 244, 244, 1259, 150, 170, 171, 172, 217, - 187, 33, 1664, 197, 1422, 160, 197, 225, 163, 164, - 197, 188, 224, 197, 221, 170, 171, 172, 225, 224, - 224, 208, 853, 188, 1027, 1028, 1562, 181, 60, 61, - 188, 243, 209, 1272, 240, 241, 1027, 1028, 243, 243, - 217, 188, 220, 197, 209, 875, 224, 1280, 225, 201, - 208, 209, 217, 211, 884, 181, 187, 887, 1323, 197, - 225, 209, 209, 218, 899, 188, 197, 1172, 1301, 217, - 217, 197, 1311, 1312, 1307, 1769, 911, 208, 225, 79, - 455, 181, 197, 1316, 181, 208, 209, 210, 918, 57, - 245, 246, 1325, 928, 94, 63, 931, 197, 933, 99, - 197, 101, 181, 5, 6, 1686, 1430, 1430, 943, 484, - 197, 486, 246, 209, 209, 147, 1349, 209, 197, 151, - 197, 217, 217, 25, 209, 217, 501, 502, 1361, 31, - 1133, 209, 217, 1366, 167, 168, 169, 57, 969, 217, - 970, 971, 972, 63, 57, 221, 1761, 977, 57, 225, - 63, 981, 1570, 188, 75, 201, 986, 987, 79, 989, - 1163, 991, 234, 993, 994, 167, 68, 69, 543, 544, - 1005, 1758, 93, 94, 129, 197, 1763, 98, 99, 100, - 101, 218, 1013, 1416, 66, 1016, 1801, 219, 1019, 1020, - 220, 223, 197, 33, 226, 243, 217, 1027, 1028, 220, - 208, 221, 223, 211, 221, 225, 214, 221, 225, 241, - 35, 225, 1799, 35, 1453, 247, 201, 202, 203, 204, - 60, 61, 1461, 125, 126, 600, 601, 602, 221, 604, - 605, 220, 225, 608, 221, 610, 243, 612, 225, 614, - 33, 1615, 1684, 1476, 43, 221, 221, 221, 1668, 225, - 225, 225, 224, 224, 221, 1629, 1240, 243, 225, 245, - 246, 1526, 224, 243, 166, 224, 33, 60, 61, 221, - 224, 1504, 1505, 243, 224, 1508, 224, 224, 1865, 224, - 1111, 183, 184, 185, 186, 197, 198, 199, 224, 197, - 201, 202, 203, 60, 61, 197, 201, 202, 203, 243, - 674, 675, 676, 1133, 197, 207, 1137, 147, 197, 242, - 150, 151, 10, 11, 12, 1145, 1430, 22, 1423, 197, - 160, 197, 224, 242, 1744, 1745, 1559, 242, 197, 197, - 224, 241, 197, 1163, 209, 13, 243, 1172, 244, 241, - 224, 224, 243, 224, 224, 224, 243, 224, 188, 43, - 224, 243, 224, 224, 147, 243, 243, 150, 151, 1194, - 1195, 1196, 225, 224, 21, 22, 224, 160, 197, 209, - 243, 241, 220, 1793, 197, 189, 243, 243, 218, 219, - 147, 243, 757, 223, 151, 242, 226, 246, 243, 243, - 1623, 1430, 244, 224, 10, 37, 771, 66, 8, 1773, - 243, 241, 1667, 1234, 1407, 224, 224, 247, 224, 165, - 243, 13, 242, 217, 217, 197, 1419, 197, 155, 1250, - 1525, 21, 22, 1253, 1254, 218, 219, 225, 197, 1259, - 223, 217, 217, 226, 243, 1438, 811, 812, 43, 217, - 14, 243, 197, 218, 220, 189, 246, 197, 241, 67, - 197, 826, 219, 1558, 247, 1439, 223, 1690, 225, 226, - 244, 1566, 243, 165, 217, 217, 208, 244, 217, 844, - 243, 243, 1, 244, 241, 243, 224, 243, 1743, 224, - 247, 243, 139, 140, 141, 142, 143, 225, 197, 146, - 147, 148, 149, 1323, 151, 152, 153, 154, 225, 225, - 875, 1734, 159, 243, 161, 162, 197, 243, 243, 884, - 167, 243, 887, 243, 197, 946, 947, 948, 949, 950, - 951, 952, 953, 954, 955, 1528, 957, 958, 959, 960, - 961, 962, 244, 218, 218, 197, 244, 244, 244, 139, - 140, 141, 142, 918, 244, 244, 21, 22, 243, 149, - 243, 151, 152, 153, 154, 1660, 1789, 244, 244, 159, - 242, 161, 162, 242, 221, 222, 223, 224, 225, 226, - 227, 228, 229, 230, 242, 220, 197, 1407, 244, 243, - 197, 224, 197, 240, 241, 197, 197, 243, 1423, 1419, - 243, 243, 243, 197, 43, 970, 971, 972, 12, 33, - 244, 197, 977, 243, 33, 243, 981, 243, 1438, 242, - 205, 986, 987, 244, 989, 197, 991, 242, 993, 994, - 197, 197, 242, 70, 243, 1730, 226, 227, 228, 229, - 230, 60, 61, 197, 243, 225, 243, 1742, 244, 225, - 240, 241, 1645, 244, 243, 243, 243, 225, 201, 243, - 1481, 244, 1027, 1028, 209, 244, 243, 209, 243, 243, - 243, 53, 1493, 244, 139, 140, 141, 142, 143, 244, - 242, 146, 147, 148, 149, 244, 151, 152, 153, 154, - 208, 699, 700, 701, 159, 1669, 161, 162, 244, 209, - 1525, 242, 217, 1798, 244, 244, 1526, 244, 1528, 244, - 244, 719, 244, 244, 244, 242, 242, 242, 208, 243, - 790, 1086, 244, 244, 86, 242, 734, 1, 147, 242, - 147, 89, 151, 1558, 1662, 221, 738, 1187, 1662, 1560, - 1561, 1566, 1771, 1662, 1662, 1662, 1, 1568, 1190, 1660, - 1336, 1780, 1441, 1574, 1578, 1237, 1523, 1579, 452, 224, - 225, 226, 227, 228, 229, 230, 58, 461, 1133, 1444, - 1579, 442, 516, 1153, 322, 240, 241, 471, 1763, 1613, - 1145, 1299, 783, 516, -1, -1, -1, 481, -1, -1, - -1, -1, 1821, -1, -1, -1, -1, -1, 1163, -1, - 219, -1, -1, -1, 223, -1, 225, 226, -1, -1, - -1, 21, 22, 131, 132, 133, 134, 135, 136, 137, - 138, -1, 241, 1797, -1, 1645, -1, -1, 247, -1, - -1, -1, 150, -1, -1, 1660, -1, -1, -1, -1, - 534, 535, 160, -1, -1, 853, -1, 1667, -1, -1, - -1, -1, 170, 171, 172, -1, -1, -1, -1, -1, - -1, -1, 1836, 33, 558, 559, 560, 561, 562, 563, - 564, -1, -1, -1, -1, -1, -1, 1698, -1, -1, - -1, -1, -1, -1, 1705, -1, 1707, -1, 1253, 1254, - 60, 61, 1713, -1, 1259, -1, 1716, 1718, 906, -1, - -1, -1, -1, -1, -1, 1730, -1, -1, -1, -1, - -1, -1, -1, 921, -1, -1, -1, 1742, -1, -1, - -1, -1, -1, 1743, 618, -1, -1, 1748, -1, 139, - 140, 141, 142, 143, 628, 943, 146, 147, 148, 149, - -1, 151, 152, 153, 154, -1, -1, -1, -1, 159, - -1, 161, 162, -1, -1, -1, 1777, -1, 1323, 1779, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 1798, -1, 1796, 670, 147, -1, -1, - -1, 151, 33, -1, -1, -1, -1, -1, -1, -1, - -1, 685, -1, -1, -1, -1, -1, 1005, -1, -1, - -1, 1822, 1823, -1, -1, -1, -1, -1, -1, 60, - 61, 1832, 1833, 223, 224, 225, 226, 227, 228, 229, - 230, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 240, 241, -1, -1, -1, -1, -1, 1858, -1, 1860, - -1, -1, 1407, -1, -1, -1, -1, -1, -1, 219, - -1, -1, -1, 223, 1419, 225, 226, -1, -1, -1, - -1, -1, 756, -1, -1, 759, -1, -1, 762, -1, - 764, 241, 766, 1438, -1, 769, -1, 247, -1, -1, - 774, 775, 776, 777, 778, 779, -1, -1, -1, -1, - 504, -1, 506, -1, -1, -1, 147, -1, -1, -1, - 151, -1, -1, 1111, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 809, -1, -1, -1, 813, - 814, -1, -1, 817, 818, 819, 820, 33, 822, -1, - 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, - 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, - -1, 845, 33, 847, 60, 61, -1, -1, -1, -1, - -1, 1526, -1, 1528, -1, -1, -1, -1, 219, -1, - -1, -1, 223, 1181, 225, 226, -1, -1, -1, 60, - 61, -1, -1, -1, -1, 599, 1194, 1195, 1196, -1, - 241, 1199, -1, 1201, -1, 1203, 247, 1205, -1, 1207, - -1, 1209, -1, 1211, -1, 1213, -1, 1215, 902, 1217, - -1, 1219, -1, -1, 1222, -1, 1224, -1, 1226, -1, - 1228, -1, 1230, -1, 1232, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 147, -1, 10, -1, 151, -1, -1, -1, -1, - -1, -1, -1, -1, 21, 22, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 147, 681, -1, -1, - 151, 685, -1, -1, 688, -1, 690, -1, -1, 973, - 1645, 695, 188, -1, 698, -1, -1, -1, -1, 703, - -1, -1, -1, 707, -1, -1, -1, -1, -1, -1, - -1, -1, 1667, 209, -1, -1, -1, 21, 22, -1, - -1, 217, -1, 219, 1008, 1009, 1010, 223, -1, 225, - 226, -1, -1, -1, 1018, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 241, -1, -1, 219, -1, - -1, 247, 223, 1037, 225, 226, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 1050, -1, -1, -1, - 241, -1, -1, -1, -1, -1, 247, 781, -1, 783, - -1, 33, 139, 140, 141, 142, 143, -1, 1743, 146, - 147, 148, 149, -1, 151, 152, 153, 154, 33, -1, - -1, -1, 159, -1, 161, 162, -1, -1, 60, 61, - 167, 168, 169, -1, -1, 1099, 173, -1, -1, 1103, - -1, -1, -1, -1, -1, 60, 61, -1, -1, -1, - -1, 188, -1, -1, -1, 139, 140, 141, 142, 143, - -1, -1, 146, 147, 148, 149, 850, 151, 152, 153, - 154, -1, 209, -1, -1, 159, -1, 161, 162, -1, - 217, -1, 219, -1, 221, 222, 223, 224, 225, 226, - 227, 228, 229, 230, 1158, -1, -1, -1, 882, -1, - -1, -1, -1, 240, 241, -1, -1, 1171, -1, -1, - -1, -1, -1, -1, -1, 147, -1, -1, 902, 151, - -1, -1, -1, -1, 908, -1, -1, -1, -1, -1, - -1, -1, 147, -1, -1, 919, 151, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 240, 241, -1, -1, - -1, 945, 946, 947, 948, 949, 950, 951, 952, 953, - 954, 955, 956, 957, 958, 959, 960, 961, 962, -1, - -1, -1, -1, -1, 1562, 21, 22, 219, -1, -1, - 974, 223, 976, 225, 226, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 219, -1, -1, -1, 223, 241, - 225, 226, -1, -1, -1, 247, 1280, -1, 1282, -1, - -1, 1285, -1, -1, -1, -1, 241, -1, 21, 22, - -1, -1, 247, -1, -1, -1, -1, 1301, 1022, -1, - -1, -1, -1, 1307, -1, -1, 1030, -1, -1, -1, - -1, -1, 1316, 33, -1, -1, -1, 1321, 1322, -1, - -1, 1325, -1, -1, -1, -1, -1, 1331, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 21, 22, - 60, 61, 1346, -1, 1348, 1349, 1350, -1, -1, -1, - -1, -1, 1356, -1, -1, -1, 1360, 1361, -1, -1, - -1, -1, 1366, 139, 140, 141, 142, 143, -1, -1, - 146, 147, 148, 149, -1, 151, 152, 153, 154, -1, - -1, -1, -1, 159, -1, 161, 162, -1, 1112, 1113, - 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, - 1124, 1125, 1126, 1127, 1128, -1, 139, 140, 141, 142, - 143, -1, 1416, 146, 147, 148, 149, -1, 151, 152, - 153, 154, -1, -1, -1, -1, 159, 147, 161, 162, - -1, 151, -1, -1, 167, 168, 169, -1, -1, -1, - 173, 1165, -1, -1, -1, -1, 222, 223, 224, 225, - 226, 227, 228, 229, 230, -1, 139, 140, 141, 142, - 143, -1, 1186, 146, 240, 241, 149, -1, 151, 152, - 153, 154, 1476, -1, -1, -1, 159, -1, 161, 162, - -1, -1, -1, -1, -1, -1, 219, -1, 221, 222, - 223, 224, 225, 226, 227, 228, 229, 230, -1, 219, - 1504, 1505, -1, 223, 1508, 225, 226, 240, 241, -1, - -1, 244, 1516, -1, 21, 22, -1, -1, -1, -1, - -1, 241, -1, -1, -1, -1, -1, 247, -1, -1, - 1534, -1, 1536, -1, -1, 1539, -1, -1, 1542, 33, - -1, 224, 225, 226, 227, 228, 229, 230, -1, 33, - -1, -1, -1, -1, -1, 1559, -1, 240, 241, 1283, - 1284, -1, -1, -1, 1288, -1, 60, 61, -1, -1, - -1, -1, 1296, -1, -1, 1299, 60, 61, -1, 33, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 1602, -1, - -1, 1605, -1, -1, -1, 1609, 60, 61, 1612, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 1622, 1623, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 139, 140, 141, 142, 143, -1, -1, 146, - 147, 148, 149, -1, 151, 152, 153, 154, -1, -1, - -1, -1, 159, 147, 161, 162, -1, 151, -1, -1, - 167, 168, 169, 147, -1, -1, 173, 151, -1, -1, - -1, -1, -1, -1, -1, -1, 21, 22, -1, -1, - 1684, -1, -1, -1, -1, -1, 1690, -1, -1, -1, - -1, -1, -1, 147, -1, -1, 1420, 151, -1, -1, - -1, -1, -1, 1427, -1, -1, 1430, -1, -1, -1, - -1, 1715, 219, -1, 221, 222, 223, 224, 225, 226, - 227, 228, 229, 230, -1, 219, -1, -1, -1, 223, - 1734, 225, 226, 240, 241, 219, -1, 244, -1, 223, - -1, 225, 226, -1, -1, -1, -1, 241, -1, -1, - 33, -1, -1, 247, -1, -1, -1, 241, -1, -1, - -1, -1, -1, 247, -1, 219, -1, -1, -1, 223, - 1774, 225, 226, -1, -1, -1, -1, 60, 61, -1, - -1, -1, -1, 21, 22, 1789, -1, 241, -1, -1, - -1, -1, -1, 247, 139, 140, 141, 142, 143, -1, - -1, 146, 147, 148, 149, -1, 151, 152, 153, 154, - -1, -1, -1, -1, 159, -1, 161, 162, -1, -1, - -1, 1825, 167, 168, 169, -1, -1, 33, 173, -1, - -1, -1, -1, 1557, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 60, 61, -1, -1, -1, -1, - 1584, -1, 1586, -1, 147, -1, -1, -1, 151, -1, - -1, 1595, 1596, 1597, 219, -1, 221, 222, 223, 224, - 225, 226, 227, 228, 229, 230, 1610, 1611, -1, -1, - -1, -1, 1616, -1, -1, 240, 241, -1, -1, 244, - -1, 139, 140, 141, 142, 143, -1, -1, 146, 147, - 148, 149, 1636, 151, 152, 153, 154, -1, -1, -1, - -1, 159, -1, 161, 162, -1, -1, -1, -1, 167, - 168, 169, -1, -1, -1, 173, 219, -1, 1662, -1, - 223, 147, 225, 226, -1, 151, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 241, -1, - -1, -1, -1, -1, 247, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 1699, 1700, -1, -1, -1, - -1, 219, -1, 221, 222, 223, 224, 225, 226, 227, - 228, 229, 230, -1, -1, -1, -1, 1721, -1, -1, - -1, -1, 240, 241, -1, -1, 244, -1, -1, -1, - -1, 1735, -1, 219, -1, -1, -1, 223, -1, 225, - 226, -1, 1746, -1, -1, -1, -1, -1, -1, 1753, - -1, 1755, -1, -1, -1, 241, -1, -1, -1, -1, - -1, 247, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 1790, -1, -1, -1, - 1794, 1795, 1, -1, -1, -1, 5, 6, 7, -1, - 9, 10, 11, -1, 13, -1, 15, 16, 17, 18, - 19, -1, 1816, -1, 1818, 1819, 25, 26, 27, 28, - 29, -1, 31, -1, -1, -1, -1, 1831, -1, 38, - 39, 40, -1, 42, -1, 44, 45, -1, -1, 48, - -1, 50, 51, 52, -1, 54, 55, -1, -1, 58, - 59, -1, -1, -1, -1, -1, 65, -1, -1, 68, - 69, -1, 71, 72, 73, -1, 75, 76, 77, 78, - 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, - 89, 90, 91, -1, 93, 94, 95, -1, -1, 98, - 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, - 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, - 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 141, 142, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 156, 157, 158, - -1, -1, -1, -1, -1, -1, -1, 166, -1, -1, - -1, -1, -1, -1, -1, 174, 175, 176, 177, 178, - -1, 180, -1, 182, 183, 184, 185, 186, 187, 188, - 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, - 199, 200, -1, -1, -1, -1, -1, -1, 207, 208, - 209, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 226, 227, 228, - -1, 230, -1, -1, 233, 234, -1, -1, 5, 6, - -1, -1, 241, -1, 243, -1, 245, 246, 15, 16, - 17, 18, 19, -1, -1, -1, -1, -1, 25, -1, - 27, -1, -1, -1, 31, -1, 33, -1, -1, -1, - -1, -1, 39, -1, -1, -1, -1, -1, 45, -1, - -1, 48, -1, -1, 51, -1, 53, -1, 55, -1, - -1, -1, -1, 60, 61, -1, -1, -1, 65, -1, - -1, 68, 69, -1, 71, 72, 73, -1, 75, 76, - 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - 87, 88, 89, 90, 91, -1, 93, 94, 95, -1, - -1, 98, 99, 100, 101, 102, 103, 104, 105, 106, - 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, - 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, - 127, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 141, 142, -1, -1, -1, -1, - 147, -1, -1, -1, 151, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 166, - -1, -1, -1, -1, -1, -1, -1, 174, 175, 176, - 177, 178, -1, 180, 181, 182, 183, 184, 185, 186, - -1, -1, 189, 190, 191, 192, 193, 194, 195, 196, - 197, 198, 199, 200, -1, -1, -1, -1, -1, -1, - 207, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 219, -1, -1, -1, 223, -1, -1, 226, - 227, 228, -1, 230, -1, -1, 233, 234, -1, -1, - -1, 5, 6, -1, 241, -1, 243, -1, 245, 246, - 247, 15, 16, 17, 18, 19, -1, -1, -1, -1, - -1, 25, -1, 27, -1, -1, -1, 31, -1, 33, - -1, -1, -1, -1, -1, 39, -1, -1, -1, -1, - -1, 45, -1, -1, 48, -1, -1, 51, -1, -1, - -1, 55, -1, -1, -1, -1, 60, 61, -1, -1, - -1, 65, -1, -1, 68, 69, -1, 71, 72, 73, - -1, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, -1, 93, - 94, 95, -1, -1, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, - 124, 125, 126, 127, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 141, 142, -1, - -1, -1, -1, 147, -1, -1, -1, 151, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 166, -1, -1, -1, -1, -1, -1, -1, - 174, 175, 176, 177, 178, -1, 180, 181, 182, 183, - 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, - 194, 195, 196, 197, 198, 199, 200, -1, -1, -1, - -1, -1, -1, 207, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 219, -1, -1, -1, 223, - -1, -1, 226, 227, 228, -1, 230, -1, -1, 233, - 234, -1, -1, -1, 5, 6, -1, 241, -1, 243, - -1, 245, 246, 247, 15, 16, 17, 18, 19, -1, - -1, -1, -1, -1, 25, -1, 27, -1, -1, -1, - 31, -1, 33, -1, -1, -1, -1, -1, 39, -1, - -1, -1, -1, -1, 45, -1, -1, 48, -1, -1, - 51, -1, -1, -1, 55, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 65, -1, -1, 68, 69, -1, - 71, 72, 73, -1, 75, 76, 77, 78, 79, 80, - 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, - 91, -1, 93, 94, 95, -1, -1, 98, 99, 100, - 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, - 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, - 121, 122, 123, 124, 125, 126, 127, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 141, 142, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 166, -1, -1, -1, -1, - -1, -1, -1, 174, 175, 176, 177, 178, -1, 180, - -1, 182, 183, 184, 185, 186, -1, -1, 189, 190, - 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, - -1, -1, -1, -1, -1, -1, 207, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 223, -1, -1, 226, 227, 228, -1, 230, - -1, -1, 233, 234, -1, -1, -1, 5, 6, -1, - 241, -1, 243, -1, 245, 246, 247, 15, 16, 17, - 18, 19, -1, -1, -1, -1, -1, 25, -1, 27, - -1, -1, -1, 31, -1, -1, -1, -1, -1, -1, - -1, 39, -1, -1, -1, -1, -1, 45, -1, -1, - 48, -1, -1, 51, -1, -1, -1, 55, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, - 68, 69, -1, 71, 72, 73, -1, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, -1, 93, 94, 95, -1, -1, - 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 141, 142, -1, -1, -1, -1, -1, - -1, -1, 150, -1, -1, -1, -1, -1, 156, 157, - 158, -1, -1, -1, -1, -1, -1, -1, 166, -1, - -1, -1, -1, -1, -1, -1, 174, 175, 176, 177, - 178, -1, 180, -1, 182, 183, 184, 185, 186, -1, - -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, - 198, 199, 200, -1, -1, -1, -1, -1, -1, 207, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 226, 227, - 228, -1, 230, -1, -1, 233, 234, -1, -1, 5, - 6, -1, -1, 241, -1, 243, -1, 245, 246, 15, - 16, 17, 18, 19, -1, -1, -1, -1, -1, 25, - -1, 27, -1, -1, -1, 31, -1, -1, -1, -1, - -1, -1, -1, 39, -1, -1, -1, -1, -1, 45, - -1, -1, 48, -1, -1, 51, -1, -1, -1, 55, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, - -1, -1, 68, 69, -1, 71, 72, 73, -1, 75, - 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, - 86, 87, 88, 89, 90, 91, -1, 93, 94, 95, - -1, -1, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, - 126, 127, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 141, 142, -1, -1, -1, - -1, -1, -1, -1, 150, -1, -1, -1, -1, -1, - 156, 157, 158, -1, -1, -1, -1, -1, -1, -1, - 166, -1, -1, -1, -1, -1, -1, -1, 174, 175, - 176, 177, 178, -1, 180, -1, 182, 183, 184, 185, - 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, - 196, 197, 198, 199, 200, -1, -1, -1, -1, -1, - -1, 207, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 226, 227, 228, -1, 230, -1, -1, 233, 234, -1, - -1, 5, 6, -1, -1, 241, -1, 243, -1, 245, - 246, 15, 16, 17, 18, 19, -1, -1, -1, -1, - -1, 25, 26, 27, 28, -1, -1, 31, -1, -1, - -1, -1, -1, -1, -1, 39, -1, -1, -1, -1, - -1, 45, -1, -1, 48, -1, -1, 51, 52, -1, - -1, 55, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 65, -1, -1, 68, 69, -1, 71, 72, 73, - -1, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, -1, 93, - 94, 95, -1, -1, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, - 124, 125, 126, 127, 128, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 141, 142, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 166, -1, -1, -1, -1, -1, -1, -1, - 174, 175, 176, 177, 178, -1, 180, -1, 182, 183, - 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, - 194, 195, 196, 197, 198, 199, 200, -1, -1, -1, - -1, -1, -1, 207, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 226, 227, 228, -1, 230, -1, -1, 233, - 234, -1, -1, 5, 6, -1, -1, 241, -1, 243, - -1, 245, 246, 15, 16, 17, 18, 19, -1, -1, - -1, -1, -1, 25, -1, 27, -1, -1, -1, 31, - -1, -1, -1, -1, -1, -1, -1, 39, -1, -1, - -1, -1, -1, 45, -1, -1, 48, -1, -1, 51, - -1, -1, -1, 55, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 65, -1, -1, 68, 69, -1, 71, - 72, 73, -1, 75, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - -1, 93, 94, 95, -1, -1, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 123, 124, 125, 126, 127, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 141, - 142, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 156, 157, 158, -1, -1, -1, - -1, -1, -1, -1, 166, -1, -1, -1, -1, -1, - -1, -1, 174, 175, 176, 177, 178, -1, 180, -1, - 182, 183, 184, 185, 186, -1, -1, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 200, -1, - -1, -1, -1, -1, -1, 207, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 226, 227, 228, -1, 230, -1, - -1, 233, 234, -1, -1, 5, 6, -1, -1, 241, - -1, 243, -1, 245, 246, 15, 16, 17, 18, 19, - -1, -1, -1, -1, -1, 25, -1, 27, -1, -1, - -1, 31, -1, -1, -1, -1, -1, -1, -1, 39, - -1, -1, -1, -1, -1, 45, -1, -1, 48, -1, - -1, 51, -1, -1, -1, 55, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 65, -1, -1, 68, 69, - 70, 71, 72, 73, -1, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, -1, 93, 94, 95, -1, -1, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 141, 142, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 166, -1, -1, -1, - -1, -1, -1, -1, 174, 175, 176, 177, 178, -1, - 180, 181, 182, 183, 184, 185, 186, -1, -1, 189, - 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - 200, -1, -1, -1, -1, -1, -1, 207, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 226, 227, 228, -1, - 230, -1, -1, 233, 234, -1, -1, 5, 6, -1, - -1, 241, -1, 243, 244, 245, 246, 15, 16, 17, - 18, 19, -1, -1, -1, -1, -1, 25, -1, 27, - -1, -1, -1, 31, -1, -1, -1, -1, -1, -1, - -1, 39, -1, -1, -1, -1, -1, 45, -1, -1, - 48, -1, -1, 51, -1, -1, -1, 55, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, - 68, 69, -1, 71, 72, 73, -1, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, -1, 93, 94, 95, -1, -1, - 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 141, 142, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 156, 157, - 158, -1, -1, -1, -1, -1, -1, -1, 166, -1, - -1, -1, -1, -1, -1, -1, 174, 175, 176, 177, - 178, -1, 180, -1, 182, 183, 184, 185, 186, -1, - -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, - 198, 199, 200, -1, -1, -1, -1, -1, -1, 207, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 226, 227, - 228, -1, 230, -1, -1, 233, 234, -1, -1, -1, - -1, 5, 6, 241, -1, 243, -1, 245, 246, 13, - -1, 15, 16, 17, 18, 19, -1, -1, -1, -1, - -1, 25, -1, 27, -1, -1, -1, 31, -1, -1, - -1, -1, -1, -1, -1, 39, -1, -1, -1, -1, - -1, 45, -1, -1, 48, 49, -1, 51, -1, -1, - -1, 55, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 65, -1, -1, 68, 69, -1, 71, 72, 73, - -1, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, -1, 93, - 94, 95, -1, -1, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, - 124, 125, 126, 127, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 141, 142, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 166, -1, -1, -1, -1, -1, -1, -1, - 174, 175, 176, 177, 178, -1, 180, -1, 182, 183, - 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, - 194, 195, 196, 197, 198, 199, 200, -1, -1, -1, - -1, -1, -1, 207, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 226, 227, 228, -1, 230, -1, -1, 233, - 234, -1, -1, -1, -1, 5, 6, 241, 242, 243, - -1, 245, 246, 13, -1, 15, 16, 17, 18, 19, - -1, -1, -1, -1, -1, 25, -1, 27, -1, -1, - -1, 31, -1, -1, -1, -1, -1, -1, -1, 39, - -1, -1, -1, -1, -1, 45, -1, -1, 48, 49, - -1, 51, -1, -1, -1, 55, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 65, -1, -1, 68, 69, - -1, 71, 72, 73, -1, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, -1, 93, 94, 95, -1, -1, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 141, 142, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 166, -1, -1, -1, - -1, -1, -1, -1, 174, 175, 176, 177, 178, -1, - 180, 181, 182, 183, 184, 185, 186, -1, -1, 189, - 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - 200, -1, -1, -1, -1, -1, -1, 207, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 226, 227, 228, -1, - 230, -1, -1, 233, 234, -1, -1, -1, -1, 5, - 6, 241, -1, 243, -1, 245, 246, 13, -1, 15, - 16, 17, 18, 19, -1, -1, -1, -1, -1, 25, - -1, 27, -1, -1, -1, 31, -1, -1, -1, -1, - -1, -1, -1, 39, -1, -1, -1, -1, -1, 45, - -1, -1, 48, 49, -1, 51, -1, -1, -1, 55, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, - -1, -1, 68, 69, -1, 71, 72, 73, -1, 75, - 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, - 86, 87, 88, 89, 90, 91, -1, 93, 94, 95, - -1, -1, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, - 126, 127, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 141, 142, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 166, -1, -1, -1, -1, -1, -1, -1, 174, 175, - 176, 177, 178, -1, 180, -1, 182, 183, 184, 185, - 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, - 196, 197, 198, 199, 200, -1, -1, -1, -1, -1, - -1, 207, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 226, 227, 228, -1, 230, -1, -1, 233, 234, -1, - -1, -1, -1, 5, 6, 241, 242, 243, -1, 245, - 246, 13, -1, 15, 16, 17, 18, 19, -1, -1, - -1, -1, -1, 25, -1, 27, -1, -1, -1, 31, - -1, -1, -1, -1, -1, -1, -1, 39, -1, -1, - -1, -1, -1, 45, -1, -1, 48, 49, -1, 51, - -1, -1, -1, 55, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 65, -1, -1, 68, 69, -1, 71, - 72, 73, -1, 75, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - -1, 93, 94, 95, -1, -1, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 123, 124, 125, 126, 127, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 141, - 142, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 166, -1, -1, -1, -1, -1, - -1, -1, 174, 175, 176, 177, 178, -1, 180, -1, - 182, 183, 184, 185, 186, -1, -1, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 200, -1, - -1, -1, -1, -1, -1, 207, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 226, 227, 228, -1, 230, -1, - -1, 233, 234, -1, -1, 5, 6, -1, -1, 241, - -1, 243, -1, 245, 246, 15, 16, 17, 18, 19, - -1, -1, -1, -1, -1, 25, -1, 27, -1, -1, - -1, 31, -1, -1, -1, -1, -1, -1, -1, 39, - -1, -1, -1, -1, -1, 45, -1, -1, 48, -1, - -1, 51, -1, -1, -1, 55, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 65, -1, -1, 68, 69, - 70, 71, 72, 73, -1, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, -1, 93, 94, 95, -1, -1, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 141, 142, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 166, -1, -1, -1, - -1, -1, -1, -1, 174, 175, 176, 177, 178, -1, - 180, 181, 182, 183, 184, 185, 186, -1, -1, 189, - 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - 200, -1, -1, -1, -1, -1, -1, 207, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 226, 227, 228, -1, - 230, -1, -1, 233, 234, -1, -1, 5, 6, -1, - -1, 241, -1, 243, -1, 245, 246, 15, 16, 17, - 18, 19, -1, -1, -1, -1, -1, 25, -1, 27, - -1, -1, -1, 31, -1, -1, -1, -1, -1, -1, - -1, 39, -1, -1, -1, -1, -1, 45, -1, -1, - 48, -1, -1, 51, -1, -1, -1, 55, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, - 68, 69, -1, 71, 72, 73, -1, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, -1, 93, 94, 95, -1, -1, - 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 141, 142, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 166, -1, - -1, -1, -1, -1, -1, -1, 174, 175, 176, 177, - 178, -1, 180, -1, 182, 183, 184, 185, 186, -1, - -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, - 198, 199, 200, -1, -1, -1, -1, -1, -1, 207, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 226, 227, - 228, -1, 230, -1, -1, 233, 234, -1, -1, -1, - -1, 5, 6, 241, 242, 243, -1, 245, 246, 13, - -1, 15, 16, 17, 18, 19, -1, -1, -1, -1, - -1, 25, -1, 27, -1, -1, -1, 31, -1, -1, - -1, -1, -1, -1, -1, 39, -1, -1, -1, -1, - -1, 45, -1, -1, 48, -1, -1, 51, -1, -1, - -1, 55, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 65, -1, -1, 68, 69, -1, 71, 72, 73, - -1, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, -1, 93, - 94, 95, -1, -1, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, - 124, 125, 126, 127, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 141, 142, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 166, -1, -1, -1, -1, -1, -1, -1, - 174, 175, 176, 177, 178, -1, 180, -1, 182, 183, - 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, - 194, 195, 196, 197, 198, 199, 200, -1, -1, -1, - -1, -1, -1, 207, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 226, 227, 228, -1, 230, -1, -1, 233, - 234, -1, -1, -1, -1, 5, 6, 241, -1, 243, - -1, 245, 246, 13, -1, 15, 16, 17, 18, 19, - -1, -1, -1, -1, -1, 25, -1, 27, -1, -1, - -1, 31, -1, -1, -1, -1, -1, -1, -1, 39, - -1, -1, -1, -1, -1, 45, -1, -1, 48, -1, - -1, 51, -1, -1, -1, 55, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 65, -1, -1, 68, 69, - -1, 71, 72, 73, -1, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, -1, 93, 94, 95, -1, -1, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 141, 142, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 166, -1, -1, -1, - -1, -1, -1, -1, 174, 175, 176, 177, 178, -1, - 180, -1, 182, 183, 184, 185, 186, -1, -1, 189, - 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - 200, -1, -1, -1, -1, -1, -1, 207, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 226, 227, 228, -1, - 230, -1, -1, 233, 234, -1, -1, 5, 6, -1, - -1, 241, -1, 243, -1, 245, 246, 15, 16, 17, - 18, 19, -1, -1, -1, -1, -1, 25, -1, 27, - -1, -1, -1, 31, -1, -1, -1, -1, -1, -1, - -1, 39, -1, -1, -1, -1, -1, 45, -1, -1, - 48, -1, -1, 51, -1, -1, -1, 55, -1, -1, - -1, -1, -1, 61, -1, -1, -1, 65, -1, -1, - 68, 69, -1, 71, 72, 73, -1, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, -1, 93, 94, 95, -1, -1, - 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 141, 142, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 166, -1, - -1, -1, -1, -1, -1, -1, 174, 175, 176, 177, - 178, -1, 180, -1, 182, 183, 184, 185, 186, -1, - -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, - 198, 199, 200, -1, -1, -1, -1, -1, -1, 207, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 226, 227, - 228, -1, 230, -1, -1, 233, 234, -1, -1, 5, - 6, -1, -1, 241, -1, 243, -1, 245, 246, 15, - 16, 17, 18, 19, -1, -1, -1, -1, -1, 25, - -1, 27, -1, -1, -1, 31, -1, -1, -1, -1, - -1, -1, -1, 39, -1, -1, -1, -1, -1, 45, - -1, -1, 48, -1, -1, 51, -1, -1, -1, 55, - -1, -1, 58, -1, -1, -1, -1, -1, -1, 65, - -1, -1, 68, 69, -1, 71, 72, 73, -1, 75, - 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, - 86, 87, 88, 89, 90, 91, -1, 93, 94, 95, - -1, -1, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, - 126, 127, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 141, 142, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 166, -1, -1, -1, -1, -1, -1, -1, 174, 175, - 176, 177, 178, -1, 180, -1, 182, 183, 184, 185, - 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, - 196, 197, 198, 199, 200, -1, -1, -1, -1, -1, - -1, 207, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 226, 227, 228, -1, 230, -1, -1, 233, 234, -1, - -1, 5, 6, -1, -1, 241, -1, 243, -1, 245, - 246, 15, 16, 17, 18, 19, -1, -1, -1, -1, - -1, 25, -1, 27, -1, -1, -1, 31, -1, -1, - -1, -1, -1, -1, -1, 39, -1, -1, -1, -1, - -1, 45, -1, -1, 48, -1, -1, 51, -1, -1, - -1, 55, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 65, -1, -1, 68, 69, -1, 71, 72, 73, - -1, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, -1, 93, - 94, 95, -1, -1, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, - 124, 125, 126, 127, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 141, 142, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 166, -1, -1, -1, -1, -1, -1, -1, - 174, 175, 176, 177, 178, -1, 180, -1, 182, 183, - 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, - 194, 195, 196, 197, 198, 199, 200, -1, -1, -1, - -1, -1, -1, 207, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 224, -1, 226, 227, 228, -1, 230, -1, -1, 233, - 234, -1, -1, 5, 6, -1, -1, 241, -1, 243, - -1, 245, 246, 15, 16, 17, 18, 19, -1, -1, - 22, -1, -1, 25, -1, 27, -1, -1, -1, 31, - -1, -1, -1, -1, -1, -1, -1, 39, -1, -1, - -1, -1, -1, 45, -1, -1, 48, -1, -1, 51, - -1, -1, -1, 55, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 65, -1, -1, 68, 69, -1, 71, - 72, 73, -1, 75, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - -1, 93, 94, 95, -1, -1, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 123, 124, 125, 126, 127, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 141, - 142, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 166, -1, -1, -1, -1, -1, - -1, -1, 174, 175, 176, 177, 178, -1, 180, -1, - 182, 183, 184, 185, 186, -1, -1, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 200, -1, - -1, -1, -1, -1, -1, 207, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 226, 227, 228, -1, 230, -1, - -1, 233, 234, -1, -1, 5, 6, -1, -1, 241, - -1, 243, -1, 245, 246, 15, 16, 17, 18, 19, - -1, -1, -1, -1, -1, 25, -1, 27, -1, -1, - -1, 31, -1, -1, -1, -1, -1, -1, -1, 39, - -1, -1, -1, -1, -1, 45, -1, -1, 48, -1, - -1, 51, -1, -1, -1, 55, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 65, -1, -1, 68, 69, - -1, 71, 72, 73, -1, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, -1, 93, 94, 95, -1, -1, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 141, 142, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 166, -1, -1, -1, - -1, -1, -1, -1, 174, 175, 176, 177, 178, -1, - 180, -1, 182, 183, 184, 185, 186, -1, -1, 189, - 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - 200, -1, -1, -1, -1, -1, -1, 207, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 226, 227, 228, -1, - 230, -1, -1, 233, 234, -1, -1, 5, 6, -1, - -1, 241, -1, 243, 244, 245, 246, 15, 16, 17, - 18, 19, -1, -1, -1, -1, -1, 25, -1, 27, - -1, -1, -1, 31, -1, -1, -1, -1, -1, -1, - -1, 39, -1, -1, -1, -1, -1, 45, -1, -1, - 48, -1, -1, 51, -1, -1, -1, 55, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, - 68, 69, -1, 71, 72, 73, -1, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, -1, 93, 94, 95, -1, -1, - 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 141, 142, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 166, -1, - -1, -1, -1, -1, -1, -1, 174, 175, 176, 177, - 178, -1, 180, -1, 182, 183, 184, 185, 186, -1, - -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, - 198, 199, 200, -1, -1, -1, -1, -1, -1, 207, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 224, -1, 226, 227, - 228, -1, 230, -1, -1, 233, 234, -1, -1, 5, - 6, -1, -1, 241, -1, 243, -1, 245, 246, 15, - 16, 17, 18, 19, -1, -1, -1, -1, -1, 25, - -1, 27, -1, -1, -1, 31, -1, -1, -1, -1, - -1, -1, -1, 39, -1, -1, -1, -1, -1, 45, - -1, -1, 48, -1, -1, 51, -1, -1, -1, 55, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, - -1, -1, 68, 69, -1, 71, 72, 73, -1, 75, - 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, - 86, 87, 88, 89, 90, 91, -1, 93, 94, 95, - -1, -1, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, - 126, 127, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 141, 142, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 166, -1, -1, -1, -1, -1, -1, -1, 174, 175, - 176, 177, 178, -1, 180, -1, 182, 183, 184, 185, - 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, - 196, 197, 198, 199, 200, -1, -1, -1, -1, -1, - -1, 207, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 226, 227, 228, -1, 230, -1, -1, 233, 234, -1, - -1, 5, 6, -1, -1, 241, -1, 243, 244, 245, - 246, 15, 16, 17, 18, 19, -1, -1, -1, -1, - -1, 25, -1, 27, -1, -1, -1, 31, -1, -1, - -1, -1, -1, -1, -1, 39, -1, -1, -1, -1, - -1, 45, -1, -1, 48, -1, -1, 51, -1, -1, - -1, 55, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 65, -1, -1, 68, 69, -1, 71, 72, 73, - -1, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, -1, 93, - 94, 95, -1, -1, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, - 124, 125, 126, 127, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 141, 142, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 166, -1, -1, -1, -1, -1, -1, -1, - 174, 175, 176, 177, 178, -1, 180, -1, 182, 183, - 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, - 194, 195, 196, 197, 198, 199, 200, -1, -1, -1, - -1, -1, -1, 207, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 226, 227, 228, -1, 230, -1, -1, 233, - 234, -1, -1, 5, 6, -1, -1, 241, -1, 243, - 244, 245, 246, 15, 16, 17, 18, 19, -1, -1, - -1, -1, -1, 25, -1, 27, -1, -1, -1, 31, - -1, -1, -1, -1, -1, -1, -1, 39, -1, -1, - -1, -1, -1, 45, -1, -1, 48, -1, -1, 51, - -1, -1, -1, 55, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 65, -1, -1, 68, 69, -1, 71, - 72, 73, -1, 75, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - -1, 93, 94, 95, -1, -1, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 123, 124, 125, 126, 127, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 141, - 142, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 166, -1, -1, -1, -1, -1, - -1, -1, 174, 175, 176, 177, 178, -1, 180, -1, - 182, 183, 184, 185, 186, -1, -1, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 200, -1, - -1, -1, -1, -1, -1, 207, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 226, 227, 228, -1, 230, -1, - -1, 233, 234, -1, -1, 5, 6, -1, -1, 241, - -1, 243, 244, 245, 246, 15, 16, 17, 18, 19, - -1, -1, -1, -1, -1, 25, -1, 27, -1, -1, - -1, 31, -1, -1, -1, -1, -1, -1, -1, 39, - -1, -1, -1, -1, -1, 45, -1, -1, 48, -1, - -1, 51, -1, -1, -1, 55, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 65, -1, -1, 68, 69, - -1, 71, 72, 73, -1, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, -1, 93, 94, 95, -1, -1, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 141, 142, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 166, -1, -1, -1, - -1, -1, -1, -1, 174, 175, 176, 177, 178, -1, - 180, -1, 182, 183, 184, 185, 186, -1, -1, 189, - 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - 200, -1, -1, -1, -1, -1, -1, 207, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 226, 227, 228, -1, - 230, -1, -1, 233, 234, -1, -1, 5, 6, -1, - -1, 241, -1, 243, 244, 245, 246, 15, 16, 17, - 18, 19, -1, -1, -1, -1, -1, 25, -1, 27, - -1, -1, -1, 31, -1, -1, -1, -1, -1, -1, - -1, 39, -1, -1, -1, -1, -1, 45, -1, -1, - 48, -1, -1, 51, -1, -1, -1, 55, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, - 68, 69, -1, 71, 72, 73, -1, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, -1, 93, 94, 95, -1, -1, - 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 141, 142, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 166, -1, - -1, -1, -1, -1, -1, -1, 174, 175, 176, 177, - 178, -1, 180, -1, 182, 183, 184, 185, 186, -1, - -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, - 198, 199, 200, -1, -1, -1, -1, -1, -1, 207, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 226, 227, - 228, -1, 230, -1, -1, 233, 234, -1, -1, 5, - 6, -1, -1, 241, -1, 243, 244, 245, 246, 15, - 16, 17, 18, 19, -1, -1, -1, -1, -1, 25, - -1, 27, -1, -1, -1, 31, -1, -1, -1, -1, - -1, -1, -1, 39, -1, -1, -1, -1, -1, 45, - -1, -1, 48, -1, -1, 51, -1, -1, -1, 55, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, - -1, -1, 68, 69, -1, 71, 72, 73, -1, 75, - 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, - 86, 87, 88, 89, 90, 91, -1, 93, 94, 95, - -1, -1, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, - 126, 127, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 141, 142, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 166, -1, -1, -1, -1, -1, -1, -1, 174, 175, - 176, 177, 178, -1, 180, -1, 182, 183, 184, 185, - 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, - 196, 197, 198, 199, 200, -1, -1, -1, -1, -1, - -1, 207, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 226, 227, 228, -1, 230, -1, -1, 233, 234, -1, - -1, 5, 6, -1, -1, 241, -1, 243, 244, 245, - 246, 15, 16, 17, 18, 19, -1, -1, -1, -1, - -1, 25, -1, 27, -1, -1, -1, 31, -1, -1, - -1, -1, -1, -1, -1, 39, -1, -1, -1, -1, - -1, 45, -1, -1, 48, -1, -1, 51, -1, -1, - -1, 55, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 65, -1, -1, 68, 69, -1, 71, 72, 73, - -1, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, -1, 93, - 94, 95, -1, -1, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, - 124, 125, 126, 127, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 141, 142, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 166, -1, -1, -1, -1, -1, -1, -1, - 174, 175, 176, 177, 178, -1, 180, -1, 182, 183, - 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, - 194, 195, 196, 197, 198, 199, 200, -1, -1, -1, - -1, -1, -1, 207, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 226, 227, 228, -1, 230, -1, -1, 233, - 234, -1, -1, 5, 6, -1, -1, 241, -1, 243, - 244, 245, 246, 15, 16, 17, 18, 19, -1, -1, - -1, -1, -1, 25, -1, 27, -1, -1, -1, 31, - -1, -1, -1, -1, -1, -1, -1, 39, -1, -1, - -1, -1, -1, 45, -1, -1, 48, -1, -1, 51, - -1, -1, -1, 55, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 65, -1, -1, 68, 69, -1, 71, - 72, 73, -1, 75, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - -1, 93, 94, 95, -1, -1, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 123, 124, 125, 126, 127, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 141, - 142, -1, -1, -1, -1, -1, -1, -1, 150, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 166, -1, -1, -1, -1, -1, - -1, -1, 174, 175, 176, 177, 178, -1, 180, -1, - 182, 183, 184, 185, 186, -1, -1, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 200, -1, - -1, -1, -1, -1, -1, 207, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 226, 227, 228, -1, 230, -1, - -1, 233, 234, -1, -1, 5, 6, -1, -1, 241, - -1, 243, -1, 245, 246, 15, 16, 17, 18, 19, - -1, -1, -1, -1, -1, 25, -1, 27, -1, -1, - -1, 31, -1, -1, -1, -1, -1, -1, -1, 39, - -1, -1, -1, -1, -1, 45, -1, -1, 48, -1, - -1, 51, -1, -1, -1, 55, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 65, -1, -1, 68, 69, - -1, 71, 72, 73, -1, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - 90, 91, -1, 93, 94, 95, -1, -1, 98, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 141, 142, -1, -1, -1, -1, -1, -1, -1, - 150, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 166, -1, -1, -1, - -1, -1, -1, -1, 174, 175, 176, 177, 178, -1, - 180, -1, 182, 183, 184, 185, 186, -1, -1, 189, - 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - 200, -1, -1, -1, -1, -1, -1, 207, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 226, 227, 228, -1, - 230, -1, -1, 233, 234, -1, -1, 5, 6, -1, - -1, 241, -1, 243, -1, 245, 246, 15, 16, 17, - 18, 19, -1, -1, -1, -1, -1, 25, -1, 27, - -1, -1, -1, 31, -1, -1, -1, -1, -1, -1, - -1, 39, -1, -1, -1, -1, -1, 45, -1, -1, - 48, -1, -1, 51, -1, -1, -1, 55, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 65, -1, -1, - 68, 69, -1, 71, 72, 73, -1, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, -1, 93, 94, 95, -1, -1, - 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 141, 142, -1, -1, -1, -1, -1, - -1, -1, 150, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 166, -1, - -1, -1, -1, -1, -1, -1, 174, 175, 176, 177, - 178, -1, 180, -1, 182, 183, 184, 185, 186, -1, - -1, 189, 190, 191, 192, 193, 194, 195, 196, 197, - 198, 199, 200, -1, -1, -1, -1, -1, -1, 207, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 226, 227, - 228, -1, 230, -1, -1, 233, 234, -1, -1, 5, - 6, -1, -1, 241, -1, 243, -1, 245, 246, 15, - 16, 17, 18, 19, -1, -1, -1, -1, -1, 25, - -1, 27, -1, -1, -1, 31, -1, -1, -1, -1, - -1, -1, -1, 39, -1, -1, -1, -1, -1, 45, - -1, -1, 48, -1, -1, 51, -1, -1, -1, 55, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, - -1, -1, 68, 69, -1, 71, 72, 73, -1, 75, - 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, - 86, 87, 88, 89, 90, 91, -1, 93, 94, 95, - -1, -1, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, - 126, 127, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 141, 142, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 166, -1, -1, -1, -1, -1, -1, -1, 174, 175, - 176, 177, 178, -1, 180, -1, 182, 183, 184, 185, - 186, -1, -1, 189, 190, 191, 192, 193, 194, 195, - 196, 197, 198, 199, 200, -1, -1, -1, -1, -1, - -1, 207, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 226, 227, 228, -1, 230, -1, -1, 233, 234, -1, - -1, 5, 6, -1, -1, 241, -1, 243, -1, 245, - 246, 15, 16, 17, 18, 19, -1, -1, -1, -1, - -1, 25, -1, 27, -1, -1, -1, 31, -1, -1, - -1, -1, -1, -1, -1, 39, -1, -1, -1, -1, - -1, 45, -1, -1, 48, -1, -1, 51, -1, -1, - -1, 55, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 65, -1, -1, 68, 69, -1, 71, 72, 73, - -1, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, -1, 93, - 94, 95, -1, -1, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, - 124, 125, 126, 127, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 141, 142, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 166, -1, -1, -1, -1, -1, -1, -1, - 174, 175, 176, 177, 178, -1, 180, -1, 182, 183, - 184, 185, 186, -1, -1, 189, 190, 191, 192, 193, - 194, 195, 196, 197, 198, 199, 200, -1, -1, 13, - -1, -1, -1, 207, -1, 19, -1, -1, -1, -1, - -1, 25, -1, -1, -1, -1, -1, 31, -1, -1, - -1, -1, 226, 227, 228, -1, 230, 41, -1, 233, - 234, -1, -1, -1, -1, 49, -1, 241, -1, 243, - -1, 245, 246, -1, -1, -1, -1, -1, -1, -1, - 64, -1, -1, -1, -1, -1, -1, 71, 72, 73, - 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, - 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, - 124, 125, 126, -1, 131, 132, 133, 134, 135, 136, - 137, 138, -1, -1, -1, -1, -1, 144, 145, -1, - -1, -1, -1, 150, -1, -1, -1, -1, 155, -1, - -1, -1, -1, 160, -1, -1, 163, 164, -1, -1, - -1, -1, 166, 170, 171, 172, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 179, -1, -1, -1, -1, - -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, - 19, -1, -1, 197, -1, -1, 25, -1, -1, -1, - -1, -1, 31, -1, -1, -1, -1, -1, -1, -1, - -1, 218, 41, -1, -1, -1, -1, -1, -1, -1, - 49, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 64, -1, -1, 245, 246, - -1, 245, 71, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, - 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, - 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, - 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, - 119, 120, 121, 122, 123, 124, 125, 126, -1, 131, - 132, 133, 134, 135, 136, 137, 138, -1, -1, -1, - -1, -1, 144, 145, -1, -1, -1, -1, 150, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 160, -1, - -1, 163, 164, -1, -1, -1, -1, 166, 170, 171, - 172, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 179, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 19, -1, -1, 197, -1, - -1, 25, -1, -1, -1, -1, -1, 31, -1, -1, - -1, -1, -1, -1, -1, -1, 218, 41, -1, -1, - -1, -1, -1, -1, -1, 49, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 64, -1, -1, 245, 246, -1, 245, 71, 72, 73, - 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, - 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, - 124, 125, 126, -1, 131, 132, 133, 134, 135, 136, - 137, 138, -1, -1, -1, -1, -1, 144, 145, -1, - -1, -1, -1, 150, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 160, -1, -1, 163, 164, -1, -1, - -1, -1, 166, 170, 171, 172, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 179, -1, -1, -1, -1, - -1, 188, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 19, 197, -1, -1, -1, -1, 25, -1, - -1, -1, 209, -1, 31, -1, -1, -1, -1, -1, - -1, 218, -1, -1, 41, -1, -1, -1, -1, -1, - -1, -1, 49, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 64, 245, 246, - -1, 245, -1, 247, 71, 72, 73, 74, 75, 76, - 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, - 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, - 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, - 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 166, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 179, -1, -1, -1, -1, -1, -1, -1, - -1, 188, -1, -1, -1, -1, -1, 19, -1, -1, - 197, -1, -1, 25, -1, -1, -1, -1, -1, 31, - -1, -1, 209, -1, -1, -1, -1, -1, -1, 41, - 217, -1, -1, -1, -1, -1, -1, 49, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 64, -1, -1, -1, -1, -1, 245, 71, - 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 123, 124, 125, 126, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 166, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 179, -1, -1, - -1, -1, 21, 22, -1, -1, -1, -1, -1, -1, - -1, -1, 19, -1, -1, 197, -1, -1, 25, -1, - -1, -1, -1, -1, 31, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 41, -1, -1, -1, -1, -1, - -1, -1, 49, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 64, -1, -1, - -1, -1, -1, 245, 71, 72, 73, 74, 75, 76, - 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, - 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, - 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, - 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, - 139, 140, 141, 142, 143, 21, 22, 146, 147, 148, - 149, -1, 151, 152, 153, 154, -1, -1, -1, -1, - 159, -1, 161, 162, -1, -1, -1, -1, 167, 168, - 169, -1, -1, -1, 173, -1, -1, -1, -1, 166, - 21, 22, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 179, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 197, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 219, -1, 221, 222, 223, 224, 225, 226, 227, 228, - 229, 230, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 240, 241, -1, -1, 244, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 245, -1, - -1, -1, -1, 139, 140, 141, 142, 143, -1, -1, - 146, 147, 148, 149, -1, 151, 152, 153, 154, -1, - -1, -1, -1, 159, -1, 161, 162, 21, 22, -1, - -1, 167, 168, 169, -1, -1, -1, 173, 139, 140, - 141, 142, 143, -1, -1, 146, 147, 148, 149, -1, - 151, 152, 153, 154, -1, -1, -1, -1, 159, -1, - 161, 162, 21, 22, -1, -1, 167, 168, 169, -1, - -1, -1, 173, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 219, -1, 221, 222, 223, 224, 225, - 226, 227, 228, 229, 230, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 240, 241, -1, -1, 244, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 219, -1, - 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 240, - 241, -1, -1, 244, -1, 139, 140, 141, 142, 143, - -1, -1, 146, 147, 148, 149, -1, 151, 152, 153, - 154, -1, -1, -1, -1, 159, -1, 161, 162, 21, - 22, -1, -1, 167, 168, 169, -1, -1, -1, 173, - 139, 140, 141, 142, 143, -1, -1, 146, 147, 148, - 149, -1, 151, 152, 153, 154, -1, -1, -1, -1, - 159, -1, 161, 162, 21, 22, -1, -1, 167, 168, - 169, -1, -1, -1, 173, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 219, -1, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 240, 241, -1, -1, - 244, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 219, -1, 221, 222, 223, 224, 225, 226, 227, 228, - 229, 230, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 240, 241, -1, -1, 244, -1, 139, 140, 141, - 142, 143, -1, -1, 146, 147, 148, 149, -1, 151, - 152, 153, 154, -1, -1, -1, -1, 159, -1, 161, - 162, 21, 22, -1, -1, 167, 168, 169, -1, -1, - -1, 173, 139, 140, 141, 142, 143, -1, -1, 146, - 147, 148, 149, -1, 151, 152, 153, 154, -1, -1, - -1, -1, 159, -1, 161, 162, 21, 22, -1, -1, - 167, 168, 169, -1, -1, -1, 173, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 219, -1, 221, - 222, 223, 224, 225, 226, 227, 228, 229, 230, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 240, 241, - -1, -1, 244, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 219, -1, 221, 222, 223, 224, 225, 226, - 227, 228, 229, 230, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 240, 241, -1, -1, 244, -1, 139, - 140, 141, 142, 143, -1, -1, 146, 147, 148, 149, - -1, 151, 152, 153, 154, -1, -1, -1, -1, 159, - -1, 161, 162, 21, 22, -1, -1, 167, 168, 169, - -1, -1, -1, 173, 139, 140, 141, 142, 143, -1, - -1, 146, 147, 148, 149, -1, 151, 152, 153, 154, - -1, -1, -1, -1, 159, -1, 161, 162, 21, 22, - -1, -1, 167, 168, 169, -1, -1, -1, 173, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 219, - -1, 221, 222, 223, 224, 225, 226, 227, 228, 229, - 230, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 240, 241, -1, -1, 244, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 219, -1, 221, 222, 223, 224, - 225, 226, 227, 228, 229, 230, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 240, 241, -1, -1, 244, - -1, 139, 140, 141, 142, 143, -1, -1, 146, 147, - 148, 149, -1, 151, 152, 153, 154, -1, -1, -1, - -1, 159, -1, 161, 162, 21, 22, -1, -1, 167, - 168, 169, -1, -1, -1, 173, 139, 140, 141, 142, - 143, -1, -1, 146, 147, 148, 149, -1, 151, 152, - 153, 154, -1, -1, -1, -1, 159, -1, 161, 162, - 21, 22, -1, -1, 167, 168, 169, -1, -1, -1, - 173, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 219, -1, 221, 222, 223, 224, 225, 226, 227, - 228, 229, 230, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 240, 241, -1, -1, 244, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 219, -1, 221, 222, - 223, 224, 225, 226, 227, 228, 229, 230, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 240, 241, -1, - -1, 244, -1, 139, 140, 141, 142, 143, -1, -1, - 146, 147, 148, 149, -1, 151, 152, 153, 154, -1, - -1, -1, -1, 159, -1, 161, 162, 21, 22, -1, - -1, 167, 168, 169, -1, -1, -1, 173, 139, 140, - 141, 142, 143, -1, -1, 146, 147, 148, 149, -1, - 151, 152, 153, 154, -1, -1, -1, -1, 159, -1, - 161, 162, 21, 22, -1, -1, 167, 168, 169, -1, - -1, -1, 173, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 219, -1, 221, 222, 223, 224, 225, - 226, 227, 228, 229, 230, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 240, 241, -1, -1, 244, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 219, -1, - 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 240, - 241, -1, -1, 244, -1, 139, 140, 141, 142, 143, - -1, -1, 146, 147, 148, 149, -1, 151, 152, 153, - 154, -1, -1, -1, -1, 159, -1, 161, 162, 21, - 22, -1, -1, 167, 168, 169, -1, -1, -1, 173, - 139, 140, 141, 142, 143, -1, -1, 146, 147, 148, - 149, -1, 151, 152, 153, 154, -1, -1, -1, -1, - 159, -1, 161, 162, 21, 22, -1, -1, 167, 168, - 169, -1, -1, -1, 173, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 219, -1, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 240, 241, -1, -1, - 244, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 219, -1, 221, 222, 223, 224, 225, 226, 227, 228, - 229, 230, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 240, 241, -1, -1, 244, -1, 139, 140, 141, - 142, 143, -1, -1, 146, 147, 148, 149, -1, 151, - 152, 153, 154, -1, -1, -1, -1, 159, -1, 161, - 162, 21, 22, -1, -1, 167, 168, 169, -1, -1, - -1, 173, 139, 140, 141, 142, 143, -1, -1, 146, - 147, 148, 149, -1, 151, 152, 153, 154, -1, -1, - -1, -1, 159, -1, 161, 162, 21, 22, -1, -1, - 167, 168, 169, -1, -1, -1, 173, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 219, -1, 221, - 222, 223, 224, 225, 226, 227, 228, 229, 230, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 240, 241, - -1, -1, 244, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 219, -1, 221, 222, 223, 224, 225, 226, - 227, 228, 229, 230, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 240, 241, -1, -1, 244, -1, 139, - 140, 141, 142, 143, -1, -1, 146, 147, 148, 149, - -1, 151, 152, 153, 154, -1, -1, -1, -1, 159, - -1, 161, 162, 21, 22, -1, -1, 167, 168, 169, - -1, -1, -1, 173, 139, 140, 141, 142, 143, -1, - -1, 146, 147, 148, 149, -1, 151, 152, 153, 154, - -1, -1, -1, -1, 159, -1, 161, 162, 21, 22, - -1, -1, 167, 168, 169, -1, -1, -1, 173, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 219, - -1, 221, 222, 223, 224, 225, 226, 227, 228, 229, - 230, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 240, 241, -1, -1, 244, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 219, -1, 221, 222, 223, 224, - 225, 226, 227, 228, 229, 230, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 240, 241, -1, -1, 244, - -1, 139, 140, 141, 142, 143, -1, -1, 146, 147, - 148, 149, -1, 151, 152, 153, 154, -1, -1, -1, - -1, 159, -1, 161, 162, 21, 22, -1, -1, 167, - 168, 169, -1, -1, -1, 173, 139, 140, 141, 142, - 143, -1, -1, 146, 147, 148, 149, -1, 151, 152, - 153, 154, -1, -1, -1, -1, 159, -1, 161, 162, - 21, 22, -1, -1, 167, 168, 169, -1, -1, -1, - 173, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 219, -1, 221, 222, 223, 224, 225, 226, 227, - 228, 229, 230, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 240, 241, -1, -1, 244, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 219, -1, 221, 222, - 223, 224, 225, 226, 227, 228, 229, 230, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 240, 241, -1, - -1, 244, -1, 139, 140, 141, 142, 143, -1, -1, - 146, 147, 148, 149, -1, 151, 152, 153, 154, -1, - -1, -1, -1, 159, -1, 161, 162, 21, 22, -1, - -1, 167, 168, 169, -1, -1, -1, 173, 139, 140, - 141, 142, 143, -1, -1, 146, 147, 148, 149, -1, - 151, 152, 153, 154, -1, -1, -1, -1, 159, -1, - 161, 162, 21, 22, -1, -1, 167, 168, 169, -1, - -1, -1, 173, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 219, -1, 221, 222, 223, 224, 225, - 226, 227, 228, 229, 230, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 240, 241, -1, -1, 244, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 219, -1, - 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 240, - 241, 242, -1, -1, -1, 139, 140, 141, 142, 143, - -1, -1, 146, 147, 148, 149, -1, 151, 152, 153, - 154, -1, -1, -1, -1, 159, -1, 161, 162, 21, - 22, -1, -1, 167, 168, 169, -1, -1, -1, 173, - 139, 140, 141, 142, 143, -1, -1, 146, 147, 148, - 149, -1, 151, 152, 153, 154, -1, -1, -1, -1, - 159, -1, 161, 162, 21, 22, -1, -1, 167, 168, - 169, -1, -1, -1, 173, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 219, -1, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 240, 241, 242, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 219, -1, 221, 222, 223, 224, 225, 226, 227, 228, - 229, 230, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 240, 241, 242, -1, -1, -1, 139, 140, 141, - 142, 143, -1, -1, 146, 147, 148, 149, -1, 151, - 152, 153, 154, -1, -1, -1, -1, 159, -1, 161, - 162, 21, 22, -1, -1, 167, 168, 169, -1, -1, - -1, 173, 139, 140, 141, 142, 143, -1, -1, 146, - 147, 148, 149, -1, 151, 152, 153, 154, -1, -1, - -1, -1, 159, -1, 161, 162, -1, -1, -1, -1, - 167, 168, 169, -1, -1, -1, 173, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 219, -1, 221, - 222, 223, 224, 225, 226, 227, 228, 229, 230, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 240, 241, - 242, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 219, -1, 221, 222, 223, 224, 225, 226, - 227, 228, 229, 230, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 240, 241, 242, -1, -1, -1, 139, - 140, 141, 142, 143, -1, -1, 146, 147, 148, 149, - -1, 151, 152, 153, 154, 21, 22, -1, -1, 159, - -1, 161, 162, -1, -1, -1, -1, 167, 168, 169, - -1, -1, 38, 173, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 21, 22, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 219, - -1, 221, 222, 223, 224, 225, 226, 227, 228, 229, - 230, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 240, 241, 242, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, - 146, 147, 148, -1, -1, 151, 152, 153, -1, -1, - -1, -1, -1, -1, 160, 161, 162, 163, 164, -1, - -1, 167, 168, 169, 170, 171, 172, 173, 21, 22, - -1, -1, -1, -1, -1, -1, 139, 140, 141, 142, - 143, -1, -1, 146, 147, 148, 149, -1, 151, 152, - 153, 154, -1, -1, -1, -1, 159, -1, 161, 162, - -1, -1, -1, -1, 167, 168, 169, 21, 22, -1, - 173, -1, -1, 219, -1, 221, 222, 223, 224, 225, - 226, 227, 228, 229, 230, 188, -1, 233, 234, -1, - -1, -1, -1, -1, 240, 241, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 209, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 219, -1, 221, 222, - 223, 224, 225, 226, 227, 228, 229, 230, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 240, 241, -1, - -1, -1, -1, -1, -1, -1, 139, 140, 141, 142, - 143, -1, -1, 146, 147, 148, 149, -1, 151, 152, - 153, 154, -1, 21, 22, -1, 159, -1, 161, 162, - -1, -1, -1, -1, 167, 168, 169, -1, -1, -1, - 173, -1, -1, -1, -1, 139, 140, 141, 142, 143, - -1, -1, 146, 147, 148, 149, -1, 151, 152, 153, - 154, 21, 22, -1, -1, 159, -1, 161, 162, -1, - -1, -1, -1, 167, 168, 169, -1, -1, -1, 173, - -1, -1, -1, -1, -1, -1, 219, 220, 221, 222, - 223, 224, 225, 226, 227, 228, 229, 230, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 240, 241, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 219, -1, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, -1, -1, -1, - -1, 139, 140, 141, 142, 143, 240, 241, 146, 147, - 148, 149, -1, 151, 152, 153, 154, 21, 22, -1, - -1, 159, -1, 161, 162, -1, -1, -1, -1, 167, - 168, 169, -1, -1, -1, 173, -1, -1, -1, 139, - 140, 141, 142, 143, -1, -1, 146, 147, 148, 149, - -1, 151, 152, 153, 154, -1, -1, -1, -1, 159, - -1, 161, 162, -1, -1, -1, -1, 167, 168, 169, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 219, -1, 221, 222, 223, 224, 225, 226, 227, - 228, 229, 230, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 240, 241, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 219, - -1, 221, 222, 223, 224, 225, 226, 227, 228, 229, - 230, -1, -1, -1, -1, 139, 140, 141, 142, 143, - 240, 241, 146, 147, 148, 149, -1, 151, 152, 153, - 154, -1, -1, -1, -1, 159, -1, 161, 162, -1, - -1, -1, -1, 167, -1, 169, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 240, 241, 71, 72, - 73, 19, 75, 76, 77, 78, 79, 80, 81, 82, - 83, 84, 85, 86, 87, 88, 89, 90, 91, -1, - 93, 94, 95, -1, -1, 98, 99, 100, 101, 102, - 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, - 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, - 123, 124, -1, 71, 72, 73, -1, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, -1, 93, 94, 95, -1, -1, - 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 122, 123, 124, -1, 181, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 197, -1, -1, -1, 19, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 181, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 197, - 71, 72, 73, -1, 75, 76, 77, 78, 79, 80, - 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, - 91, -1, 93, 94, 95, -1, -1, 98, 99, 100, - 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, - 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, - 121, 122, 123, 124, 71, 72, 73, -1, 75, 76, - 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - 87, 88, 89, 90, 91, -1, 93, 94, 95, -1, - -1, 98, 99, 100, 101, 102, 103, 104, 105, 106, - 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, - 117, 118, 119, 120, 121, 122, 123, 124, -1, -1, - 181, -1, -1, -1, -1, -1, -1, -1, -1, 35, - -1, -1, -1, -1, -1, -1, 197, -1, -1, -1, - -1, -1, -1, -1, -1, 152, 153, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 71, -1, 73, -1, 75, - 76, 77, 78, 79, 181, 81, 82, 83, 84, 85, - 86, 87, 88, 89, 90, 91, -1, 93, 94, 95, - 197, -1, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, 121, 122, 123, 124, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 240, 241, 141, 142, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 197 -}; - -/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of - state STATE-NUM. */ -static const yytype_int16 yystos[] = -{ - 0, 249, 0, 7, 30, 32, 34, 40, 50, 56, - 80, 125, 126, 188, 209, 230, 241, 250, 251, 255, - 264, 266, 267, 272, 304, 309, 345, 429, 436, 440, - 447, 494, 499, 504, 19, 20, 197, 296, 297, 298, - 189, 273, 274, 173, 197, 198, 199, 230, 240, 268, - 269, 270, 186, 207, 314, 437, 197, 245, 253, 57, - 63, 432, 432, 432, 166, 197, 331, 34, 63, 130, - 159, 234, 243, 300, 301, 302, 303, 331, 250, 5, - 6, 8, 36, 444, 62, 427, 218, 217, 220, 217, - 229, 229, 269, 229, 22, 57, 229, 240, 271, 432, - 433, 435, 433, 427, 505, 495, 500, 197, 166, 265, - 302, 302, 302, 243, 167, 168, 169, 217, 242, 130, - 130, 130, 308, 57, 63, 438, 57, 63, 445, 57, - 63, 428, 15, 16, 189, 194, 197, 200, 243, 246, - 257, 297, 189, 274, 269, 269, 269, 197, 268, 268, - 197, 188, 209, 402, 187, 208, 315, 433, 250, 57, - 63, 252, 197, 197, 197, 197, 201, 263, 244, 298, - 302, 302, 302, 302, 57, 63, 310, 312, 197, 439, - 448, 314, 430, 201, 202, 203, 256, 15, 16, 189, - 194, 197, 257, 294, 295, 246, 271, 434, 188, 402, - 234, 254, 506, 496, 501, 201, 244, 313, 220, 314, - 129, 442, 443, 425, 183, 246, 299, 396, 201, 202, - 203, 217, 244, 197, 218, 66, 220, 458, 314, 314, - 35, 71, 73, 75, 76, 77, 78, 79, 81, 82, - 83, 84, 85, 86, 87, 88, 89, 90, 91, 93, - 94, 95, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, 121, 122, 123, 124, 141, - 142, 197, 307, 311, 75, 79, 93, 94, 98, 99, - 100, 101, 452, 431, 197, 449, 315, 426, 298, 297, - 246, 250, 175, 197, 423, 424, 294, 19, 25, 31, - 41, 49, 64, 71, 72, 73, 74, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, - 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 122, 123, 124, 125, 126, 179, - 245, 331, 451, 453, 454, 459, 465, 493, 79, 94, - 99, 101, 314, 497, 502, 21, 22, 38, 131, 132, - 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, - 143, 144, 145, 146, 147, 148, 151, 152, 153, 160, - 161, 162, 163, 164, 167, 168, 169, 170, 171, 172, - 173, 219, 221, 222, 223, 224, 225, 226, 227, 228, - 229, 230, 233, 234, 240, 241, 35, 35, 243, 305, - 314, 316, 314, 197, 315, 220, 441, 314, 446, 396, - 242, 297, 243, 43, 217, 220, 223, 422, 224, 224, - 224, 243, 224, 224, 243, 458, 224, 224, 224, 224, - 224, 243, 331, 33, 60, 61, 147, 151, 219, 223, - 226, 241, 247, 464, 221, 457, 413, 416, 197, 197, - 197, 242, 22, 197, 242, 178, 244, 396, 408, 409, - 410, 149, 220, 306, 319, 431, 218, 402, 331, 403, - 424, 242, 5, 6, 15, 16, 17, 18, 19, 25, - 27, 31, 39, 45, 48, 51, 55, 65, 68, 69, - 80, 125, 126, 127, 141, 142, 174, 175, 176, 177, - 178, 180, 182, 183, 184, 185, 189, 190, 191, 192, - 193, 194, 195, 196, 198, 199, 200, 207, 226, 227, - 228, 233, 234, 241, 243, 245, 246, 262, 264, 314, - 325, 331, 336, 350, 357, 360, 363, 368, 371, 375, - 376, 378, 383, 386, 387, 395, 451, 507, 522, 533, - 537, 550, 553, 197, 197, 465, 150, 160, 218, 421, - 466, 471, 473, 387, 475, 469, 197, 224, 477, 479, - 481, 483, 485, 487, 489, 491, 387, 224, 243, 322, - 33, 223, 33, 223, 241, 247, 242, 387, 241, 247, - 465, 197, 315, 197, 217, 250, 411, 462, 493, 498, - 197, 414, 462, 503, 197, 131, 132, 133, 134, 135, - 136, 137, 138, 160, 170, 171, 172, 131, 132, 133, - 134, 135, 136, 137, 138, 150, 160, 170, 171, 172, - 243, 7, 50, 344, 209, 209, 217, 244, 493, 493, - 1, 9, 10, 11, 13, 26, 28, 29, 38, 40, - 42, 44, 52, 54, 58, 59, 65, 127, 128, 156, - 157, 158, 188, 198, 209, 275, 276, 279, 282, 283, - 285, 288, 289, 290, 291, 315, 317, 318, 320, 325, - 330, 332, 337, 338, 339, 340, 341, 342, 343, 345, - 349, 372, 374, 387, 394, 315, 394, 40, 241, 304, - 315, 405, 402, 224, 224, 224, 333, 453, 507, 243, - 331, 224, 5, 125, 126, 224, 243, 224, 243, 243, - 224, 224, 243, 224, 243, 224, 243, 224, 224, 243, - 224, 224, 387, 387, 243, 243, 243, 243, 243, 243, - 13, 465, 13, 465, 13, 394, 532, 548, 224, 224, - 261, 13, 387, 387, 387, 387, 387, 13, 49, 321, - 361, 387, 361, 246, 13, 323, 532, 549, 197, 243, - 304, 21, 22, 139, 140, 141, 142, 143, 146, 147, - 148, 149, 151, 152, 153, 154, 159, 161, 162, 167, - 168, 169, 173, 219, 221, 222, 223, 224, 225, 226, - 227, 228, 229, 230, 240, 241, 244, 243, 43, 250, - 421, 330, 372, 394, 493, 493, 463, 493, 244, 493, - 493, 244, 225, 460, 493, 305, 493, 305, 493, 305, - 411, 412, 414, 415, 244, 468, 321, 242, 242, 387, - 188, 217, 218, 456, 220, 462, 315, 220, 462, 315, - 387, 175, 197, 418, 419, 450, 410, 410, 410, 394, - 286, 287, 150, 330, 361, 387, 394, 316, 61, 394, - 293, 394, 197, 250, 189, 58, 394, 316, 224, 150, - 330, 394, 246, 316, 363, 367, 367, 367, 394, 250, - 250, 394, 10, 37, 363, 369, 250, 250, 250, 250, - 250, 66, 346, 155, 250, 131, 132, 133, 134, 135, - 136, 137, 138, 144, 145, 150, 160, 163, 164, 170, - 171, 172, 218, 369, 402, 404, 303, 8, 396, 401, - 523, 525, 334, 243, 331, 224, 243, 358, 224, 224, - 224, 544, 361, 465, 323, 387, 351, 353, 387, 355, - 387, 546, 361, 529, 534, 361, 527, 465, 387, 387, - 387, 387, 387, 387, 450, 53, 181, 197, 226, 241, - 243, 394, 508, 511, 515, 531, 536, 450, 243, 511, - 536, 450, 165, 208, 210, 250, 516, 326, 328, 203, - 204, 256, 243, 243, 450, 13, 242, 217, 552, 552, - 175, 180, 224, 331, 377, 450, 315, 217, 552, 70, - 241, 244, 361, 508, 510, 4, 183, 366, 19, 181, - 197, 451, 19, 181, 197, 451, 387, 387, 387, 387, - 387, 387, 197, 387, 181, 197, 387, 387, 387, 451, - 387, 387, 387, 387, 387, 387, 22, 387, 387, 387, - 387, 387, 387, 387, 387, 387, 387, 387, 152, 153, - 181, 197, 240, 241, 384, 451, 387, 244, 361, 197, - 330, 394, 131, 132, 133, 134, 135, 136, 137, 138, - 144, 145, 150, 163, 164, 170, 171, 172, 218, 250, - 225, 225, 225, 462, 225, 225, 197, 455, 225, 306, - 225, 306, 225, 306, 225, 462, 225, 462, 324, 493, - 217, 552, 242, 394, 217, 493, 493, 244, 243, 43, - 150, 217, 218, 220, 223, 417, 316, 450, 243, 330, - 361, 217, 14, 394, 197, 316, 218, 220, 189, 465, - 330, 394, 246, 304, 316, 316, 284, 314, 370, 183, - 243, 348, 424, 367, 156, 157, 158, 317, 373, 394, - 373, 394, 373, 394, 373, 394, 373, 394, 373, 394, - 373, 394, 373, 394, 373, 394, 373, 394, 373, 394, - 394, 373, 394, 373, 394, 373, 394, 373, 394, 373, - 394, 373, 394, 197, 242, 57, 63, 399, 67, 400, - 250, 465, 465, 493, 70, 361, 510, 521, 224, 394, - 197, 394, 493, 538, 540, 542, 465, 552, 225, 462, - 244, 244, 465, 465, 244, 465, 244, 465, 552, 465, - 412, 552, 415, 225, 244, 244, 244, 244, 244, 244, - 20, 367, 243, 160, 417, 241, 387, 244, 165, 217, - 250, 515, 212, 213, 242, 519, 217, 212, 242, 250, - 518, 20, 244, 515, 208, 211, 517, 20, 394, 208, - 532, 324, 324, 394, 450, 450, 20, 243, 450, 387, - 244, 243, 243, 379, 381, 20, 532, 197, 244, 510, - 508, 217, 244, 217, 552, 244, 243, 150, 160, 197, - 218, 223, 364, 365, 305, 224, 243, 224, 243, 243, - 243, 242, 19, 181, 197, 451, 220, 181, 197, 387, - 243, 243, 181, 197, 387, 1, 243, 242, 244, 250, - 394, 394, 394, 394, 394, 394, 394, 394, 394, 394, - 394, 394, 394, 394, 394, 394, 394, 467, 472, 474, - 493, 476, 470, 217, 225, 250, 478, 225, 482, 225, - 486, 225, 490, 411, 492, 414, 225, 462, 244, 188, - 456, 387, 197, 197, 493, 394, 20, 450, 316, 218, - 292, 225, 366, 12, 23, 24, 188, 277, 278, 394, - 319, 304, 197, 347, 347, 367, 367, 367, 218, 250, - 47, 400, 46, 129, 397, 402, 225, 225, 225, 510, - 244, 244, 244, 197, 244, 225, 250, 244, 225, 465, - 412, 415, 225, 244, 243, 465, 225, 225, 225, 225, - 244, 225, 225, 244, 225, 366, 243, 361, 387, 394, - 394, 511, 515, 394, 181, 197, 508, 519, 242, 394, - 242, 531, 361, 511, 208, 211, 214, 520, 242, 361, - 225, 225, 220, 259, 20, 20, 361, 450, 20, 387, - 387, 465, 305, 361, 244, 242, 241, 365, 197, 197, - 243, 197, 197, 217, 242, 306, 388, 387, 390, 387, - 244, 361, 387, 224, 243, 387, 243, 242, 387, 241, - 244, 361, 243, 242, 385, 244, 361, 197, 461, 197, - 480, 484, 488, 322, 493, 244, 43, 417, 361, 20, - 493, 394, 366, 305, 316, 278, 394, 12, 280, 315, - 366, 217, 242, 244, 493, 402, 33, 398, 397, 399, - 524, 526, 335, 244, 225, 462, 243, 197, 359, 225, - 225, 225, 545, 323, 225, 352, 354, 356, 547, 530, - 535, 528, 243, 244, 361, 209, 244, 515, 519, 243, - 160, 417, 209, 515, 242, 209, 327, 329, 260, 205, - 361, 361, 209, 20, 361, 244, 244, 225, 306, 209, - 244, 508, 244, 197, 364, 242, 165, 316, 362, 465, - 244, 493, 244, 244, 244, 392, 387, 387, 244, 508, - 244, 387, 244, 197, 394, 316, 361, 250, 250, 369, - 306, 316, 281, 250, 305, 197, 242, 220, 422, 250, - 406, 398, 418, 419, 420, 243, 243, 394, 197, 394, - 225, 539, 541, 543, 243, 244, 243, 394, 394, 394, - 243, 70, 521, 243, 243, 244, 387, 244, 387, 160, - 417, 519, 387, 394, 394, 387, 520, 532, 394, 322, - 258, 244, 244, 387, 361, 209, 380, 225, 532, 242, - 244, 150, 394, 225, 225, 493, 244, 244, 242, 244, - 244, 362, 188, 278, 26, 128, 282, 337, 338, 339, - 341, 394, 306, 220, 422, 465, 421, 402, 311, 407, - 521, 521, 244, 225, 244, 243, 243, 243, 243, 321, - 323, 361, 521, 521, 244, 250, 551, 394, 394, 244, - 551, 551, 201, 209, 209, 551, 244, 387, 377, 382, - 551, 244, 394, 389, 391, 225, 244, 316, 278, 150, - 150, 394, 316, 465, 421, 421, 394, 250, 311, 243, - 508, 512, 513, 514, 514, 394, 394, 521, 521, 508, - 509, 244, 244, 552, 514, 509, 53, 242, 160, 417, - 208, 315, 532, 387, 242, 209, 551, 377, 315, 393, - 394, 421, 394, 394, 250, 402, 316, 508, 217, 552, - 244, 244, 244, 244, 514, 514, 244, 244, 244, 244, - 394, 242, 394, 394, 242, 315, 551, 551, 387, 242, - 394, 250, 250, 402, 244, 243, 244, 244, 208, 242, - 551, 250, 508, 242, 244 -}; - -/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ -static const yytype_int16 yyr1[] = -{ - 0, 248, 249, 249, 249, 249, 249, 249, 249, 249, - 249, 249, 249, 249, 249, 249, 249, 250, 250, 251, - 252, 252, 252, 253, 253, 254, 254, 255, 256, 256, - 256, 256, 257, 257, 258, 258, 259, 260, 259, 261, - 261, 261, 262, 263, 263, 265, 264, 266, 267, 268, - 268, 268, 269, 269, 269, 269, 269, 269, 269, 270, - 270, 271, 271, 272, 273, 273, 274, 274, 275, 276, - 276, 277, 277, 278, 278, 278, 278, 279, 279, 280, - 281, 280, 282, 282, 282, 282, 282, 283, 283, 284, - 283, 286, 285, 287, 285, 288, 289, 290, 292, 291, - 293, 291, 294, 294, 294, 294, 294, 294, 295, 295, - 296, 296, 296, 297, 297, 297, 297, 297, 297, 297, - 297, 297, 298, 298, 299, 299, 299, 300, 300, 300, - 300, 301, 301, 302, 302, 302, 302, 302, 302, 302, - 303, 303, 304, 304, 305, 305, 305, 306, 306, 306, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 307, 307, 308, 308, 309, 310, 310, 310, 311, 313, - 312, 314, 314, 315, 315, 316, 316, 317, 317, 317, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, - 318, 318, 319, 319, 319, 320, 321, 321, 322, 322, - 323, 323, 324, 324, 326, 327, 325, 328, 329, 325, - 330, 330, 330, 330, 330, 331, 331, 331, 332, 332, - 334, 335, 333, 333, 336, 336, 336, 336, 336, 336, - 337, 338, 339, 339, 339, 340, 340, 340, 341, 341, - 342, 342, 342, 343, 344, 344, 344, 345, 345, 346, - 346, 347, 347, 348, 348, 348, 348, 349, 349, 351, - 352, 350, 353, 354, 350, 355, 356, 350, 358, 359, - 357, 360, 360, 360, 360, 360, 360, 361, 361, 362, - 362, 362, 363, 363, 363, 364, 364, 364, 364, 364, - 365, 365, 366, 366, 366, 367, 367, 368, 370, 369, - 371, 371, 371, 371, 371, 371, 371, 371, 372, 372, - 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, - 372, 372, 372, 372, 372, 372, 372, 373, 373, 373, - 373, 374, 374, 374, 374, 374, 374, 374, 374, 374, - 374, 374, 374, 374, 374, 374, 374, 374, 375, 375, - 376, 376, 377, 377, 378, 379, 380, 378, 381, 382, - 378, 383, 383, 383, 383, 383, 383, 383, 384, 385, - 383, 386, 386, 386, 386, 386, 386, 386, 387, 387, - 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, - 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, - 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, - 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, - 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, - 387, 387, 387, 387, 388, 389, 387, 387, 387, 387, - 390, 391, 387, 387, 387, 392, 393, 387, 387, 387, - 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, - 387, 387, 394, 395, 395, 395, 395, 395, 395, 395, - 395, 395, 395, 395, 395, 395, 395, 395, 395, 396, - 396, 396, 397, 397, 397, 398, 398, 399, 399, 399, - 400, 400, 401, 402, 402, 402, 402, 403, 404, 403, - 405, 403, 406, 403, 407, 403, 403, 408, 409, 409, - 410, 410, 410, 410, 410, 411, 411, 412, 412, 413, - 413, 413, 414, 415, 415, 416, 416, 416, 417, 417, - 418, 418, 418, 419, 419, 420, 420, 421, 421, 421, - 422, 422, 423, 423, 423, 423, 423, 424, 424, 424, - 424, 424, 424, 425, 426, 425, 427, 427, 428, 428, - 428, 429, 430, 429, 431, 431, 431, 432, 432, 432, - 434, 433, 435, 435, 436, 437, 436, 438, 438, 438, - 439, 440, 440, 441, 441, 442, 442, 443, 444, 444, - 444, 444, 445, 445, 445, 446, 446, 448, 449, 447, - 450, 450, 450, 450, 450, 451, 451, 451, 451, 451, - 451, 451, 451, 451, 451, 451, 451, 451, 451, 451, - 451, 451, 451, 451, 451, 451, 451, 451, 451, 451, - 451, 451, 451, 451, 451, 451, 451, 451, 451, 451, - 451, 451, 451, 451, 451, 451, 451, 451, 451, 451, - 451, 451, 451, 451, 451, 452, 452, 452, 452, 452, - 452, 452, 452, 453, 454, 454, 454, 455, 455, 455, - 456, 456, 457, 457, 457, 457, 457, 457, 457, 458, - 458, 458, 458, 458, 459, 460, 461, 459, 462, 462, - 463, 463, 464, 464, 465, 465, 465, 465, 465, 465, - 466, 467, 465, 465, 465, 468, 465, 465, 465, 465, - 465, 465, 465, 465, 465, 465, 465, 465, 465, 469, - 470, 465, 465, 471, 472, 465, 473, 474, 465, 475, - 476, 465, 465, 477, 478, 465, 479, 480, 465, 465, - 481, 482, 465, 483, 484, 465, 465, 485, 486, 465, - 487, 488, 465, 489, 490, 465, 491, 492, 465, 493, - 493, 493, 495, 496, 497, 498, 494, 500, 501, 502, - 503, 499, 505, 506, 504, 507, 507, 507, 507, 507, - 508, 508, 508, 508, 508, 508, 508, 508, 509, 509, - 510, 511, 511, 512, 512, 513, 513, 514, 514, 515, - 515, 516, 516, 517, 517, 518, 518, 519, 519, 519, - 520, 520, 520, 521, 521, 522, 522, 522, 522, 522, - 522, 523, 524, 522, 525, 526, 522, 527, 528, 522, - 529, 530, 522, 531, 531, 531, 532, 532, 533, 534, - 535, 533, 536, 536, 537, 537, 537, 538, 539, 537, - 540, 541, 537, 542, 543, 537, 537, 544, 545, 537, - 537, 546, 547, 537, 548, 548, 549, 549, 550, 550, - 550, 550, 550, 551, 551, 552, 552, 553, 553, 553, - 553, 553, 553, 553, 553, 553 -}; - -/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ -static const yytype_int8 yyr2[] = -{ - 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, - 0, 1, 1, 1, 1, 0, 2, 5, 1, 1, - 2, 2, 3, 2, 0, 2, 0, 0, 3, 0, - 2, 5, 3, 1, 2, 0, 4, 2, 2, 1, - 1, 1, 1, 2, 3, 3, 3, 3, 3, 2, - 4, 0, 1, 2, 1, 3, 1, 3, 3, 3, - 2, 1, 1, 0, 2, 4, 5, 1, 1, 0, - 0, 3, 1, 1, 1, 1, 1, 5, 4, 0, - 6, 0, 6, 0, 8, 2, 3, 3, 0, 6, - 0, 6, 1, 1, 1, 1, 1, 1, 1, 3, - 1, 1, 1, 3, 3, 5, 3, 3, 3, 3, - 1, 5, 1, 3, 2, 3, 2, 1, 1, 1, - 1, 1, 4, 1, 2, 3, 3, 3, 3, 2, - 1, 3, 0, 3, 0, 2, 3, 0, 2, 2, - 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 3, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, - 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 3, 2, 2, 2, 2, 2, - 3, 3, 3, 4, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 0, 1, 4, 0, 1, 1, 3, 0, - 4, 1, 1, 1, 1, 3, 7, 2, 2, 6, - 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, - 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, - 2, 2, 0, 2, 2, 3, 0, 2, 0, 4, - 0, 2, 1, 3, 0, 0, 7, 0, 0, 7, - 3, 2, 2, 2, 1, 1, 3, 2, 2, 3, - 0, 0, 5, 1, 2, 5, 5, 5, 6, 2, - 1, 1, 1, 2, 3, 2, 2, 3, 2, 3, - 2, 2, 3, 4, 1, 1, 0, 1, 1, 1, - 0, 1, 3, 9, 8, 8, 7, 3, 3, 0, - 0, 7, 0, 0, 7, 0, 0, 7, 0, 0, - 6, 5, 8, 10, 5, 8, 10, 1, 3, 1, - 2, 3, 1, 1, 2, 2, 2, 2, 2, 4, - 1, 3, 0, 4, 4, 1, 6, 6, 0, 7, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, - 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 6, 8, - 5, 6, 1, 4, 3, 0, 0, 8, 0, 0, - 9, 3, 4, 5, 6, 8, 5, 6, 0, 0, - 5, 3, 4, 4, 5, 4, 3, 4, 1, 1, - 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, - 2, 4, 5, 4, 5, 3, 4, 2, 5, 1, - 1, 1, 1, 1, 1, 1, 4, 1, 1, 4, - 4, 7, 8, 3, 0, 0, 8, 3, 3, 3, - 0, 0, 8, 3, 4, 0, 0, 9, 4, 1, - 1, 1, 1, 1, 1, 1, 3, 3, 3, 2, - 4, 1, 1, 4, 4, 4, 4, 4, 1, 6, - 7, 6, 6, 7, 7, 6, 7, 6, 6, 0, - 4, 1, 0, 1, 1, 0, 1, 0, 1, 1, - 0, 1, 5, 1, 1, 2, 0, 0, 0, 8, - 0, 5, 0, 10, 0, 11, 6, 3, 3, 4, - 1, 1, 3, 3, 3, 1, 3, 1, 3, 0, - 2, 3, 3, 1, 3, 0, 2, 3, 1, 1, - 1, 2, 3, 3, 5, 1, 1, 1, 1, 1, - 0, 1, 1, 4, 3, 3, 5, 4, 6, 5, - 5, 4, 4, 0, 0, 5, 0, 1, 0, 1, - 1, 6, 0, 6, 0, 3, 5, 0, 1, 1, - 0, 5, 2, 3, 4, 0, 4, 0, 1, 1, - 1, 7, 9, 0, 2, 0, 1, 3, 1, 1, - 2, 2, 0, 1, 1, 0, 3, 0, 0, 7, - 1, 4, 3, 3, 5, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 4, 4, 1, 3, 3, - 1, 2, 0, 3, 3, 2, 5, 5, 4, 0, - 2, 2, 2, 2, 4, 0, 0, 7, 1, 1, - 1, 3, 3, 4, 1, 1, 1, 1, 2, 3, - 0, 0, 6, 4, 3, 0, 7, 4, 2, 2, - 3, 2, 3, 2, 2, 3, 3, 3, 2, 0, - 0, 6, 2, 0, 0, 6, 0, 0, 6, 0, - 0, 6, 1, 0, 0, 6, 0, 0, 7, 1, - 0, 0, 6, 0, 0, 7, 1, 0, 0, 6, - 0, 0, 7, 0, 0, 6, 0, 0, 6, 1, - 3, 3, 0, 0, 0, 0, 10, 0, 0, 0, - 0, 10, 0, 0, 9, 1, 1, 1, 1, 1, - 3, 3, 5, 5, 6, 6, 8, 8, 0, 1, - 2, 1, 3, 3, 5, 1, 2, 1, 0, 0, - 2, 2, 1, 2, 1, 2, 1, 2, 1, 1, - 2, 1, 1, 0, 1, 5, 4, 6, 7, 5, - 7, 0, 0, 10, 0, 0, 10, 0, 0, 10, - 0, 0, 7, 1, 3, 3, 3, 1, 5, 0, - 0, 10, 1, 3, 3, 4, 4, 0, 0, 11, - 0, 0, 11, 0, 0, 10, 5, 0, 0, 9, - 5, 0, 0, 10, 1, 3, 1, 3, 3, 3, - 4, 7, 9, 0, 3, 0, 1, 9, 11, 12, - 11, 10, 10, 10, 9, 10 -}; - - -enum { YYENOMEM = -2 }; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = DAS_YYEMPTY) - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab -#define YYNOMEM goto yyexhaustedlab - - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ - do \ - if (yychar == DAS_YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (&yylloc, scanner, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ - while (0) - -/* Backward compatibility with an undocumented macro. - Use DAS_YYerror or DAS_YYUNDEF. */ -#define YYERRCODE DAS_YYUNDEF - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (N) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (0) -#endif - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) - - -/* Enable debugging if requested. */ -#if DAS_YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) - - -/* YYLOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -# ifndef YYLOCATION_PRINT - -# if defined YY_LOCATION_PRINT - - /* Temporary convenience wrapper in case some people defined the - undocumented and private YY_LOCATION_PRINT macros. */ -# define YYLOCATION_PRINT(File, Loc) YY_LOCATION_PRINT(File, *(Loc)) - -# elif defined DAS_YYLTYPE_IS_TRIVIAL && DAS_YYLTYPE_IS_TRIVIAL - -/* Print *YYLOCP on YYO. Private, do not rely on its existence. */ - -YY_ATTRIBUTE_UNUSED -static int -yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) -{ - int res = 0; - int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0; - if (0 <= yylocp->first_line) - { - res += YYFPRINTF (yyo, "%d", yylocp->first_line); - if (0 <= yylocp->first_column) - res += YYFPRINTF (yyo, ".%d", yylocp->first_column); - } - if (0 <= yylocp->last_line) - { - if (yylocp->first_line < yylocp->last_line) - { - res += YYFPRINTF (yyo, "-%d", yylocp->last_line); - if (0 <= end_col) - res += YYFPRINTF (yyo, ".%d", end_col); - } - else if (0 <= end_col && yylocp->first_column < end_col) - res += YYFPRINTF (yyo, "-%d", end_col); - } - return res; -} - -# define YYLOCATION_PRINT yy_location_print_ - - /* Temporary convenience wrapper in case some people defined the - undocumented and private YY_LOCATION_PRINT macros. */ -# define YY_LOCATION_PRINT(File, Loc) YYLOCATION_PRINT(File, &(Loc)) - -# else - -# define YYLOCATION_PRINT(File, Loc) ((void) 0) - /* Temporary convenience wrapper in case some people defined the - undocumented and private YY_LOCATION_PRINT macros. */ -# define YY_LOCATION_PRINT YYLOCATION_PRINT - -# endif -# endif /* !defined YYLOCATION_PRINT */ - - -# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Kind, Value, Location, scanner); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) - - -/*-----------------------------------. -| Print this symbol's value on YYO. | -`-----------------------------------*/ - -static void -yy_symbol_value_print (FILE *yyo, - yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, yyscan_t scanner) -{ - FILE *yyoutput = yyo; - YY_USE (yyoutput); - YY_USE (yylocationp); - YY_USE (scanner); - if (!yyvaluep) - return; - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - YY_USE (yykind); - YY_IGNORE_MAYBE_UNINITIALIZED_END -} - - -/*---------------------------. -| Print this symbol on YYO. | -`---------------------------*/ - -static void -yy_symbol_print (FILE *yyo, - yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, yyscan_t scanner) -{ - YYFPRINTF (yyo, "%s %s (", - yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); - - YYLOCATION_PRINT (yyo, yylocationp); - YYFPRINTF (yyo, ": "); - yy_symbol_value_print (yyo, yykind, yyvaluep, yylocationp, scanner); - YYFPRINTF (yyo, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -static void -yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) -{ - YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (0) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -static void -yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, - int yyrule, yyscan_t scanner) -{ - int yylno = yyrline[yyrule]; - int yynrhs = yyr2[yyrule]; - int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, - YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), - &yyvsp[(yyi + 1) - (yynrhs)], - &(yylsp[(yyi + 1) - (yynrhs)]), scanner); - YYFPRINTF (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyssp, yyvsp, yylsp, Rule, scanner); \ -} while (0) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !DAS_YYDEBUG */ -# define YYDPRINTF(Args) ((void) 0) -# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !DAS_YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - -/* Context of a parse error. */ -typedef struct -{ - yy_state_t *yyssp; - yysymbol_kind_t yytoken; - YYLTYPE *yylloc; -} yypcontext_t; - -/* Put in YYARG at most YYARGN of the expected tokens given the - current YYCTX, and return the number of tokens stored in YYARG. If - YYARG is null, return the number of expected tokens (guaranteed to - be less than YYNTOKENS). Return YYENOMEM on memory exhaustion. - Return 0 if there are more than YYARGN expected tokens, yet fill - YYARG up to YYARGN. */ -static int -yypcontext_expected_tokens (const yypcontext_t *yyctx, - yysymbol_kind_t yyarg[], int yyargn) -{ - /* Actual size of YYARG. */ - int yycount = 0; - int yyn = yypact[+*yyctx->yyssp]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYSYMBOL_YYerror - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (!yyarg) - ++yycount; - else if (yycount == yyargn) - return 0; - else - yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx); - } - } - if (yyarg && yycount == 0 && 0 < yyargn) - yyarg[0] = YYSYMBOL_YYEMPTY; - return yycount; -} - - - - -#ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S))) -# else -/* Return the length of YYSTR. */ -static YYPTRDIFF_T -yystrlen (const char *yystr) -{ - YYPTRDIFF_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -#endif - -#ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -yystpcpy (char *yydest, const char *yysrc) -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -#endif - -#ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYPTRDIFF_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYPTRDIFF_T yyn = 0; - char const *yyp = yystr; - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - else - goto append; - - append: - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (yyres) - return yystpcpy (yyres, yystr) - yyres; - else - return yystrlen (yystr); -} -#endif - - -static int -yy_syntax_error_arguments (const yypcontext_t *yyctx, - yysymbol_kind_t yyarg[], int yyargn) -{ - /* Actual size of YYARG. */ - int yycount = 0; - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yyctx->yytoken != YYSYMBOL_YYEMPTY) - { - int yyn; - if (yyarg) - yyarg[yycount] = yyctx->yytoken; - ++yycount; - yyn = yypcontext_expected_tokens (yyctx, - yyarg ? yyarg + 1 : yyarg, yyargn - 1); - if (yyn == YYENOMEM) - return YYENOMEM; - else - yycount += yyn; - } - return yycount; -} - -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return -1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return YYENOMEM if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, - const yypcontext_t *yyctx) -{ - enum { YYARGS_MAX = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat: reported tokens (one for the "unexpected", - one per "expected"). */ - yysymbol_kind_t yyarg[YYARGS_MAX]; - /* Cumulated lengths of YYARG. */ - YYPTRDIFF_T yysize = 0; - - /* Actual size of YYARG. */ - int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX); - if (yycount == YYENOMEM) - return YYENOMEM; - - switch (yycount) - { -#define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - default: /* Avoid compiler warnings. */ - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -#undef YYCASE_ - } - - /* Compute error message size. Don't count the "%s"s, but reserve - room for the terminator. */ - yysize = yystrlen (yyformat) - 2 * yycount + 1; - { - int yyi; - for (yyi = 0; yyi < yycount; ++yyi) - { - YYPTRDIFF_T yysize1 - = yysize + yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]]); - if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) - yysize = yysize1; - else - return YYENOMEM; - } - } - - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return -1; - } - - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]); - yyformat += 2; - } - else - { - ++yyp; - ++yyformat; - } - } - return 0; -} - - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -static void -yydestruct (const char *yymsg, - yysymbol_kind_t yykind, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, yyscan_t scanner) -{ - YY_USE (yyvaluep); - YY_USE (yylocationp); - YY_USE (scanner); - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); - - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - switch (yykind) - { - case YYSYMBOL_NAME: /* "name" */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_KEYWORD: /* "keyword" */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_TYPE_FUNCTION: /* "type function" */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_module_name: /* module_name */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_character_sequence: /* character_sequence */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_string_constant: /* string_constant */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_format_string: /* format_string */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_optional_format_string: /* optional_format_string */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_string_builder_body: /* string_builder_body */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_string_builder: /* string_builder */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_reader: /* expr_reader */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_keyword_or_name: /* keyword_or_name */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_require_module_name: /* require_module_name */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_expression_label: /* expression_label */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_goto: /* expression_goto */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_else: /* expression_else */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_else_one_liner: /* expression_else_one_liner */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_if_one_liner: /* expression_if_one_liner */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_if_then_else: /* expression_if_then_else */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_for_loop: /* expression_for_loop */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_unsafe: /* expression_unsafe */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_while_loop: /* expression_while_loop */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_with: /* expression_with */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_with_alias: /* expression_with_alias */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_annotation_argument_value: /* annotation_argument_value */ - { delete ((*yyvaluep).aa); } - break; - - case YYSYMBOL_annotation_argument_value_list: /* annotation_argument_value_list */ - { delete ((*yyvaluep).aaList); } - break; - - case YYSYMBOL_annotation_argument_name: /* annotation_argument_name */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_annotation_argument: /* annotation_argument */ - { delete ((*yyvaluep).aa); } - break; - - case YYSYMBOL_annotation_argument_list: /* annotation_argument_list */ - { delete ((*yyvaluep).aaList); } - break; - - case YYSYMBOL_metadata_argument_list: /* metadata_argument_list */ - { delete ((*yyvaluep).aaList); } - break; - - case YYSYMBOL_annotation_declaration_name: /* annotation_declaration_name */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_annotation_declaration_basic: /* annotation_declaration_basic */ - { /* gc owns AnnotationDeclaration */ } - break; - - case YYSYMBOL_annotation_declaration: /* annotation_declaration */ - { /* gc owns AnnotationDeclaration */ } - break; - - case YYSYMBOL_annotation_list: /* annotation_list */ - { delete ((*yyvaluep).faList); } - break; - - case YYSYMBOL_optional_annotation_list: /* optional_annotation_list */ - { delete ((*yyvaluep).faList); } - break; - - case YYSYMBOL_optional_function_argument_list: /* optional_function_argument_list */ - { deleteVariableDeclarationList(((*yyvaluep).pVarDeclList)); } - break; - - case YYSYMBOL_optional_function_type: /* optional_function_type */ - { delete ((*yyvaluep).pTypeDecl); } - break; - - case YYSYMBOL_function_name: /* function_name */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_function_declaration_header: /* function_declaration_header */ - { ((*yyvaluep).pFuncDecl)->delRef(); } - break; - - case YYSYMBOL_function_declaration: /* function_declaration */ - { ((*yyvaluep).pFuncDecl)->delRef(); } - break; - - case YYSYMBOL_expression_block: /* expression_block */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_call_pipe: /* expr_call_pipe */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_any: /* expression_any */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expressions: /* expressions */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_keyword: /* expr_keyword */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_optional_expr_list: /* optional_expr_list */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_optional_expr_list_in_braces: /* optional_expr_list_in_braces */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_optional_expr_map_tuple_list: /* optional_expr_map_tuple_list */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_type_declaration_no_options_list: /* type_declaration_no_options_list */ - { deleteTypeDeclarationList(((*yyvaluep).pTypeDeclList)); } - break; - - case YYSYMBOL_expression_keyword: /* expression_keyword */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_pipe: /* expr_pipe */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_name_in_namespace: /* name_in_namespace */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_expression_delete: /* expression_delete */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_new_type_declaration: /* new_type_declaration */ - { delete ((*yyvaluep).pTypeDecl); } - break; - - case YYSYMBOL_expr_new: /* expr_new */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_break: /* expression_break */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_continue: /* expression_continue */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_return_no_pipe: /* expression_return_no_pipe */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_return: /* expression_return */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_yield_no_pipe: /* expression_yield_no_pipe */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_yield: /* expression_yield */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expression_try_catch: /* expression_try_catch */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_tuple_expansion: /* tuple_expansion */ - { delete ((*yyvaluep).pNameList); } - break; - - case YYSYMBOL_tuple_expansion_variable_declaration: /* tuple_expansion_variable_declaration */ - { delete ((*yyvaluep).pVarDecl); } - break; - - case YYSYMBOL_expression_let: /* expression_let */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_cast: /* expr_cast */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_type_decl: /* expr_type_decl */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_type_info: /* expr_type_info */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_list: /* expr_list */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_block_or_simple_block: /* block_or_simple_block */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_capture_entry: /* capture_entry */ - { delete ((*yyvaluep).pCapt); } - break; - - case YYSYMBOL_capture_list: /* capture_list */ - { delete ((*yyvaluep).pCaptList); } - break; - - case YYSYMBOL_optional_capture_list: /* optional_capture_list */ - { delete ((*yyvaluep).pCaptList); } - break; - - case YYSYMBOL_expr_block: /* expr_block */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_full_block: /* expr_full_block */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_full_block_assumed_piped: /* expr_full_block_assumed_piped */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_numeric_const: /* expr_numeric_const */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_assign: /* expr_assign */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_assign_pipe_right: /* expr_assign_pipe_right */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_assign_pipe: /* expr_assign_pipe */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_named_call: /* expr_named_call */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_method_call: /* expr_method_call */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_func_addr_name: /* func_addr_name */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_func_addr_expr: /* func_addr_expr */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_field: /* expr_field */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_call: /* expr_call */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr2: /* expr2 */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr: /* expr */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_mtag: /* expr_mtag */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_optional_field_annotation: /* optional_field_annotation */ - { delete ((*yyvaluep).aaList); } - break; - - case YYSYMBOL_structure_variable_declaration: /* structure_variable_declaration */ - { delete ((*yyvaluep).pVarDecl); } - break; - - case YYSYMBOL_struct_variable_declaration_list: /* struct_variable_declaration_list */ - { deleteVariableDeclarationList(((*yyvaluep).pVarDeclList)); } - break; - - case YYSYMBOL_function_argument_declaration_no_type: /* function_argument_declaration_no_type */ - { delete ((*yyvaluep).pVarDecl); } - break; - - case YYSYMBOL_function_argument_declaration_type: /* function_argument_declaration_type */ - { delete ((*yyvaluep).pVarDecl); } - break; - - case YYSYMBOL_function_argument_list: /* function_argument_list */ - { deleteVariableDeclarationList(((*yyvaluep).pVarDeclList)); } - break; - - case YYSYMBOL_tuple_type: /* tuple_type */ - { delete ((*yyvaluep).pVarDecl); } - break; - - case YYSYMBOL_tuple_type_list: /* tuple_type_list */ - { deleteVariableDeclarationList(((*yyvaluep).pVarDeclList)); } - break; - - case YYSYMBOL_tuple_alias_type_list: /* tuple_alias_type_list */ - { deleteVariableDeclarationList(((*yyvaluep).pVarDeclList)); } - break; - - case YYSYMBOL_variant_type: /* variant_type */ - { delete ((*yyvaluep).pVarDecl); } - break; - - case YYSYMBOL_variant_type_list: /* variant_type_list */ - { deleteVariableDeclarationList(((*yyvaluep).pVarDeclList)); } - break; - - case YYSYMBOL_variant_alias_type_list: /* variant_alias_type_list */ - { deleteVariableDeclarationList(((*yyvaluep).pVarDeclList)); } - break; - - case YYSYMBOL_variable_declaration_no_type: /* variable_declaration_no_type */ - { delete ((*yyvaluep).pVarDecl); } - break; - - case YYSYMBOL_variable_declaration_type: /* variable_declaration_type */ - { delete ((*yyvaluep).pVarDecl); } - break; - - case YYSYMBOL_variable_declaration: /* variable_declaration */ - { delete ((*yyvaluep).pVarDecl); } - break; - - case YYSYMBOL_let_variable_name_with_pos_list: /* let_variable_name_with_pos_list */ - { delete ((*yyvaluep).pNameWithPosList); } - break; - - case YYSYMBOL_let_variable_declaration: /* let_variable_declaration */ - { delete ((*yyvaluep).pVarDecl); } - break; - - case YYSYMBOL_global_variable_declaration_list: /* global_variable_declaration_list */ - { deleteVariableDeclarationList(((*yyvaluep).pVarDeclList)); } - break; - - case YYSYMBOL_enum_list: /* enum_list */ - { delete ((*yyvaluep).pEnumList); } - break; - - case YYSYMBOL_alias_list: /* alias_list */ - { delete ((*yyvaluep).positions); } - break; - - case YYSYMBOL_enum_name: /* enum_name */ - { /* $$->delRef(); // if enum rule returns, module already has the link */ } - break; - - case YYSYMBOL_optional_structure_parent: /* optional_structure_parent */ - { delete ((*yyvaluep).s); } - break; - - case YYSYMBOL_optional_struct_variable_declaration_list: /* optional_struct_variable_declaration_list */ - { deleteVariableDeclarationList(((*yyvaluep).pVarDeclList)); } - break; - - case YYSYMBOL_variable_name_with_pos_list: /* variable_name_with_pos_list */ - { delete ((*yyvaluep).pNameWithPosList); } - break; - - case YYSYMBOL_structure_type_declaration: /* structure_type_declaration */ - { delete ((*yyvaluep).pTypeDecl); } - break; - - case YYSYMBOL_auto_type_declaration: /* auto_type_declaration */ - { delete ((*yyvaluep).pTypeDecl); } - break; - - case YYSYMBOL_bitfield_bits: /* bitfield_bits */ - { delete ((*yyvaluep).pNameList); } - break; - - case YYSYMBOL_bitfield_alias_bits: /* bitfield_alias_bits */ - { deleteNameExprList(((*yyvaluep).pNameExprList)); } - break; - - case YYSYMBOL_bitfield_type_declaration: /* bitfield_type_declaration */ - { delete ((*yyvaluep).pTypeDecl); } - break; - - case YYSYMBOL_table_type_pair: /* table_type_pair */ - { delete ((*yyvaluep).aTypePair).firstType; delete ((*yyvaluep).aTypePair).secondType; } - break; - - case YYSYMBOL_dim_list: /* dim_list */ - { delete ((*yyvaluep).pTypeDecl); } - break; - - case YYSYMBOL_type_declaration_no_options: /* type_declaration_no_options */ - { delete ((*yyvaluep).pTypeDecl); } - break; - - case YYSYMBOL_type_declaration: /* type_declaration */ - { delete ((*yyvaluep).pTypeDecl); } - break; - - case YYSYMBOL_make_decl: /* make_decl */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_make_struct_fields: /* make_struct_fields */ - { /* gc owns MakeStruct */ } - break; - - case YYSYMBOL_make_variant_dim: /* make_variant_dim */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_make_struct_single: /* make_struct_single */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_make_struct_dim: /* make_struct_dim */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_make_struct_dim_list: /* make_struct_dim_list */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_make_struct_dim_decl: /* make_struct_dim_decl */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_optional_make_struct_dim_decl: /* optional_make_struct_dim_decl */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_optional_block: /* optional_block */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_make_struct_decl: /* make_struct_decl */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_make_tuple: /* make_tuple */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_make_map_tuple: /* make_map_tuple */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_make_tuple_call: /* make_tuple_call */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_make_dim: /* make_dim */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_make_dim_decl: /* make_dim_decl */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_make_table: /* make_table */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_expr_map_tuple_list: /* expr_map_tuple_list */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_make_table_decl: /* make_table_decl */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_array_comprehension_where: /* array_comprehension_where */ - { delete ((*yyvaluep).pExpression); } - break; - - case YYSYMBOL_array_comprehension: /* array_comprehension */ - { delete ((*yyvaluep).pExpression); } - break; - - default: - break; - } - YY_IGNORE_MAYBE_UNINITIALIZED_END -} - - - - - - -/*----------. -| yyparse. | -`----------*/ - -int -yyparse (yyscan_t scanner) -{ -/* Lookahead token kind. */ -int yychar; - - -/* The semantic value of the lookahead symbol. */ -/* Default value used for initialization, for pacifying older GCCs - or non-GCC compilers. */ -YY_INITIAL_VALUE (static YYSTYPE yyval_default;) -YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); - -/* Location data for the lookahead symbol. */ -static YYLTYPE yyloc_default -# if defined DAS_YYLTYPE_IS_TRIVIAL && DAS_YYLTYPE_IS_TRIVIAL - = { 1, 1, 1, 1 } -# endif -; -YYLTYPE yylloc = yyloc_default; - - /* Number of syntax errors so far. */ - int yynerrs = 0; - - yy_state_fast_t yystate = 0; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus = 0; - - /* Refer to the stacks through separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* Their size. */ - YYPTRDIFF_T yystacksize = YYINITDEPTH; - - /* The state stack: array, bottom, top. */ - yy_state_t yyssa[YYINITDEPTH]; - yy_state_t *yyss = yyssa; - yy_state_t *yyssp = yyss; - - /* The semantic value stack: array, bottom, top. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp = yyvs; - - /* The location stack: array, bottom, top. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp = yyls; - - int yyn; - /* The return value of yyparse. */ - int yyresult; - /* Lookahead symbol kind. */ - yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - YYLTYPE yyloc; - - /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[3]; - - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf; - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yychar = DAS_YYEMPTY; /* Cause a token to be read. */ - - yylsp[0] = yylloc; - goto yysetstate; - - -/*------------------------------------------------------------. -| yynewstate -- push a new state, which is found in yystate. | -`------------------------------------------------------------*/ -yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - - -/*--------------------------------------------------------------------. -| yysetstate -- set current state (the top of the stack) to yystate. | -`--------------------------------------------------------------------*/ -yysetstate: - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - YY_ASSERT (0 <= yystate && yystate < YYNSTATES); - YY_IGNORE_USELESS_CAST_BEGIN - *yyssp = YY_CAST (yy_state_t, yystate); - YY_IGNORE_USELESS_CAST_END - YY_STACK_PRINT (yyss, yyssp); - - if (yyss + yystacksize - 1 <= yyssp) -#if !defined yyoverflow && !defined YYSTACK_RELOCATE - YYNOMEM; -#else - { - /* Get the current used size of the three stacks, in elements. */ - YYPTRDIFF_T yysize = yyssp - yyss + 1; - -# if defined yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - yy_state_t *yyss1 = yyss; - YYSTYPE *yyvs1 = yyvs; - YYLTYPE *yyls1 = yyls; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * YYSIZEOF (*yyssp), - &yyvs1, yysize * YYSIZEOF (*yyvsp), - &yyls1, yysize * YYSIZEOF (*yylsp), - &yystacksize); - yyss = yyss1; - yyvs = yyvs1; - yyls = yyls1; - } -# else /* defined YYSTACK_RELOCATE */ - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - YYNOMEM; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yy_state_t *yyss1 = yyss; - union yyalloc *yyptr = - YY_CAST (union yyalloc *, - YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); - if (! yyptr) - YYNOMEM; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); - YYSTACK_RELOCATE (yyls_alloc, yyls); -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - yylsp = yyls + yysize - 1; - - YY_IGNORE_USELESS_CAST_BEGIN - YYDPRINTF ((stderr, "Stack size increased to %ld\n", - YY_CAST (long, yystacksize))); - YY_IGNORE_USELESS_CAST_END - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } -#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ - - - if (yystate == YYFINAL) - YYACCEPT; - - goto yybackup; - - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; - if (yypact_value_is_default (yyn)) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ - if (yychar == DAS_YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token\n")); - yychar = yylex (&yylval, &yylloc, scanner); - } - - if (yychar <= DAS_YYEOF) - { - yychar = DAS_YYEOF; - yytoken = YYSYMBOL_YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else if (yychar == DAS_YYerror) - { - /* The scanner already issued an error message, process directly - to error recovery. But do not keep the error token as - lookahead, it is too special and may lead us to an endless - loop in error recovery. */ - yychar = DAS_YYUNDEF; - yytoken = YYSYMBOL_YYerror; - yyerror_range[1] = yylloc; - goto yyerrlab1; - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yytable_value_is_error (yyn)) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the lookahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - yystate = yyn; - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - *++yyvsp = yylval; - YY_IGNORE_MAYBE_UNINITIALIZED_END - *++yylsp = yylloc; - - /* Discard the shifted token. */ - yychar = DAS_YYEMPTY; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - '$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - /* Default location. */ - YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); - yyerror_range[1] = yyloc; - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 3: /* program: program module_declaration */ - { - if ( yyextra->das_has_type_declarations ) { - das_yyerror(scanner,"module name has to be first declaration",tokAt(scanner,(yylsp[0])), CompilationError::syntax_error); - } - } - break; - - case 4: /* program: program structure_declaration */ - { yyextra->das_has_type_declarations = true; } - break; - - case 5: /* program: program enum_declaration */ - { yyextra->das_has_type_declarations = true; } - break; - - case 6: /* program: program global_let */ - { yyextra->das_has_type_declarations = true; } - break; - - case 7: /* program: program global_function_declaration */ - { yyextra->das_has_type_declarations = true; } - break; - - case 11: /* program: program alias_declaration */ - { yyextra->das_has_type_declarations = true; } - break; - - case 12: /* program: program variant_alias_declaration */ - { yyextra->das_has_type_declarations = true; } - break; - - case 13: /* program: program tuple_alias_declaration */ - { yyextra->das_has_type_declarations = true; } - break; - - case 14: /* program: program bitfield_alias_declaration */ - { yyextra->das_has_type_declarations = true; } - break; - - case 17: /* semicolon: SEMICOLON */ - { - format::try_semicolon_at_eol(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - } - break; - - case 18: /* semicolon: "end of expression" */ - {} - break; - - case 19: /* top_level_reader_macro: expr_reader semicolon */ - { - delete (yyvsp[-1].pExpression); // we do nothing, we don't even attemp to 'visit' - } - break; - - case 20: /* optional_public_or_private_module: %empty */ - { (yyval.b) = yyextra->g_Program->policies.default_module_public; } - break; - - case 21: /* optional_public_or_private_module: "public" */ - { (yyval.b) = true; } - break; - - case 22: /* optional_public_or_private_module: "private" */ - { (yyval.b) = false; } - break; - - case 23: /* module_name: '$' */ - { (yyval.s) = new string("$"); } - break; - - case 24: /* module_name: "name" */ - { (yyval.s) = (yyvsp[0].s); } - break; - - case 25: /* optional_not_required: %empty */ - { (yyval.b) = false; } - break; - - case 26: /* optional_not_required: '!' "inscope" */ - { (yyval.b) = true; } - break; - - case 27: /* module_declaration: "module" module_name optional_shared optional_public_or_private_module optional_not_required */ - { - yyextra->g_Program->thisModuleName = *(yyvsp[-3].s); - yyextra->g_Program->thisModule->isPublic = (yyvsp[-1].b); - yyextra->g_Program->thisModule->isModule = true; - yyextra->g_Program->thisModule->visibleEverywhere = (yyvsp[0].b); - if ( yyextra->g_Program->thisModule->name.empty() ) { - yyextra->g_Program->library.renameModule(yyextra->g_Program->thisModule.get(),*(yyvsp[-3].s)); - } else if ( yyextra->g_Program->thisModule->name != *(yyvsp[-3].s) ){ - das_yyerror(scanner,"this module already has a name " + yyextra->g_Program->thisModule->name,tokAt(scanner,(yylsp[-3])), - CompilationError::module_already_has_a_name); - } - if ( !yyextra->g_Program->policies.ignore_shared_modules ) { - yyextra->g_Program->promoteToBuiltin = (yyvsp[-2].b); - } - delete (yyvsp[-3].s); - } - break; - - case 28: /* character_sequence: STRING_CHARACTER */ - { (yyval.s) = new string(); *(yyval.s) += (yyvsp[0].ch); } - break; - - case 29: /* character_sequence: STRING_CHARACTER_ESC */ - { (yyval.s) = new string(); *(yyval.s) += "\\\\"; } - break; - - case 30: /* character_sequence: character_sequence STRING_CHARACTER */ - { (yyval.s) = (yyvsp[-1].s); *(yyvsp[-1].s) += (yyvsp[0].ch); } - break; - - case 31: /* character_sequence: character_sequence STRING_CHARACTER_ESC */ - { (yyval.s) = (yyvsp[-1].s); *(yyvsp[-1].s) += "\\\\"; } - break; - - case 32: /* string_constant: "start of the string" character_sequence "end of the string" */ - { (yyval.s) = (yyvsp[-1].s); } - break; - - case 33: /* string_constant: "start of the string" "end of the string" */ - { (yyval.s) = new string(); } - break; - - case 34: /* format_string: %empty */ - { (yyval.s) = new string(); } - break; - - case 35: /* format_string: format_string STRING_CHARACTER */ - { (yyval.s) = (yyvsp[-1].s); (yyvsp[-1].s)->push_back((yyvsp[0].ch)); } - break; - - case 36: /* optional_format_string: %empty */ - { (yyval.s) = new string(""); } - break; - - case 37: /* $@1: %empty */ - { das_strfmt(scanner); } - break; - - case 38: /* optional_format_string: ':' $@1 format_string */ - { (yyval.s) = (yyvsp[0].s); } - break; - - case 39: /* string_builder_body: %empty */ - { - (yyval.pExpression) = new ExprStringBuilder(); - (yyval.pExpression)->at = LineInfo(yyextra->g_FileAccessStack.back(), - yylloc.first_column,yylloc.first_line,yylloc.last_column,yylloc.last_line); - } - break; - - case 40: /* string_builder_body: string_builder_body character_sequence */ - { - bool err; - auto esconst = unescapeString(*(yyvsp[0].s),&err); - if ( err ) das_yyerror(scanner,"invalid escape sequence",tokAt(scanner,(yylsp[-1])), CompilationError::invalid_escape_sequence); - auto sc = new ExprConstString(tokAt(scanner,(yylsp[0])),esconst); - delete (yyvsp[0].s); - static_cast((yyvsp[-1].pExpression))->elements.push_back(sc); - (yyval.pExpression) = (yyvsp[-1].pExpression); - } - break; - - case 41: /* string_builder_body: string_builder_body "{" expr optional_format_string "}" */ - { - auto se = (yyvsp[-2].pExpression); - if ( !(yyvsp[-1].s)->empty() ) { - auto call_fmt = new ExprCall(tokAt(scanner,(yylsp[-1])), "_::fmt"); - call_fmt->arguments.push_back(new ExprConstString(tokAt(scanner,(yylsp[-1])),":" + *(yyvsp[-1].s))); - call_fmt->arguments.push_back(se); - se = call_fmt; - } - static_cast((yyvsp[-4].pExpression))->elements.push_back(se); - (yyval.pExpression) = (yyvsp[-4].pExpression); - delete (yyvsp[-1].s); - } - break; - - case 42: /* string_builder: "start of the string" string_builder_body "end of the string" */ - { - auto strb = static_cast((yyvsp[-1].pExpression)); - if ( strb->elements.size()==0 ) { - (yyval.pExpression) = new ExprConstString(tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])),""); - delete (yyvsp[-1].pExpression); - } else if ( strb->elements.size()==1 && strb->elements[0]->rtti_isStringConstant() ) { - auto sconst = static_cast(strb->elements[0]); - (yyval.pExpression) = new ExprConstString(tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])),sconst->text); - delete (yyvsp[-1].pExpression); - } else { - (yyval.pExpression) = (yyvsp[-1].pExpression); - } - } - break; - - case 43: /* reader_character_sequence: STRING_CHARACTER */ - { - if ( !yyextra->g_ReaderMacro->accept(yyextra->g_Program.get(), yyextra->g_Program->thisModule.get(), yyextra->g_ReaderExpr, (yyvsp[0].ch), tokAt(scanner,(yylsp[0]))) ) { - das_yyend_reader(scanner); - } - } - break; - - case 44: /* reader_character_sequence: reader_character_sequence STRING_CHARACTER */ - { - if ( !yyextra->g_ReaderMacro->accept(yyextra->g_Program.get(), yyextra->g_Program->thisModule.get(), yyextra->g_ReaderExpr, (yyvsp[0].ch), tokAt(scanner,(yylsp[0]))) ) { - das_yyend_reader(scanner); - } - } - break; - - case 45: /* $@2: %empty */ - { - auto macros = yyextra->g_Program->getReaderMacro(*(yyvsp[0].s)); - if ( macros.size()==0 ) { - das_yyerror(scanner,"reader macro " + *(yyvsp[0].s) + " not found",tokAt(scanner,(yylsp[0])), - CompilationError::unsupported_read_macro); - } else if ( macros.size()>1 ) { - string options; - for ( auto & x : macros ) { - options += "\t" + x->module->name + "::" + x->name + "\n"; - } - das_yyerror(scanner,"too many options for the reader macro " + *(yyvsp[0].s) + "\n" + options, tokAt(scanner,(yylsp[0])), - CompilationError::unsupported_read_macro); - } else if ( yychar != '~' ) { - das_yyerror(scanner,"expecting ~ after the reader macro", tokAt(scanner,(yylsp[0])), - CompilationError::syntax_error); - } else { - yyextra->g_ReaderMacro = macros.back(); - yyextra->g_ReaderExpr = new ExprReader(tokAt(scanner,(yylsp[-1])),yyextra->g_ReaderMacro); - yyclearin ; - das_yybegin_reader(scanner); - } - } - break; - - case 46: /* expr_reader: '%' name_in_namespace $@2 reader_character_sequence */ - { - yyextra->g_ReaderExpr->at = tokRangeAt(scanner,(yylsp[-3]),(yylsp[0])); - (yyval.pExpression) = yyextra->g_ReaderExpr; - int thisLine = 0; - FileInfo * info = nullptr; - if (!format::is_formatter_enabled()) { - if ( auto seqt = yyextra->g_ReaderMacro->suffix(yyextra->g_Program.get(), yyextra->g_Program->thisModule.get(), yyextra->g_ReaderExpr, thisLine, info, tokAt(scanner,(yylsp[0]))) ) { - das_accept_sequence(scanner,seqt,strlen(seqt),thisLine,info); - yylloc.first_column = (yylsp[0]).first_column; - yylloc.first_line = (yylsp[0]).first_line; - yylloc.last_column = (yylsp[0]).last_column; - yylloc.last_line = (yylsp[0]).last_line; - } - } - delete (yyvsp[-2].s); - yyextra->g_ReaderMacro = nullptr; - yyextra->g_ReaderExpr = nullptr; - } - break; - - case 47: /* options_declaration: "options" annotation_argument_list */ - { - for ( auto & opt : *(yyvsp[0].aaList) ) { - if ( opt.name=="indenting" && opt.type==Type::tInt ) { - if (opt.iValue != 0 && opt.iValue != 2 && opt.iValue != 4 && opt.iValue != 8) { //this is error - yyextra->das_tab_size = yyextra->das_def_tab_size; - } else { - yyextra->das_tab_size = opt.iValue ? opt.iValue : yyextra->das_def_tab_size;//0 is default - } - yyextra->g_FileAccessStack.back()->tabSize = yyextra->das_tab_size; - } else if ( opt.name=="gen2_make_syntax" && opt.type==Type::tBool ) { - yyextra->das_gen2_make_syntax = opt.bValue; - } - } - for ( auto & opt : *(yyvsp[0].aaList) ) { - if ( yyextra->g_Access->isOptionAllowed(opt.name, yyextra->g_Program->thisModule->fileName) ) { - if ( yyextra->g_Access->isOptionBlocked(opt.name, yyextra->g_Program->thisModule->fileName) ) { - // blocked: ok to write, silently ignored (not applied) - } else { - yyextra->g_Program->options.push_back(opt); - } - } else { - das_yyerror(scanner,"option " + opt.name + " is not allowed here", - tokAt(scanner,(yylsp[0])), CompilationError::invalid_option); - } - } - delete (yyvsp[0].aaList); - } - break; - - case 49: /* keyword_or_name: "name" */ - { (yyval.s) = (yyvsp[0].s); } - break; - - case 50: /* keyword_or_name: "keyword" */ - { (yyval.s) = (yyvsp[0].s); } - break; - - case 51: /* keyword_or_name: "type function" */ - { (yyval.s) = (yyvsp[0].s); } - break; - - case 52: /* require_module_name: keyword_or_name */ - { - (yyval.s) = (yyvsp[0].s); - } - break; - - case 53: /* require_module_name: '%' require_module_name */ - { - *(yyvsp[0].s) = "%" + *(yyvsp[0].s); - (yyval.s) = (yyvsp[0].s); - } - break; - - case 54: /* require_module_name: '.' '/' require_module_name */ - { - *(yyvsp[0].s) = "./" + *(yyvsp[0].s); - (yyval.s) = (yyvsp[0].s); - } - break; - - case 55: /* require_module_name: ".." '/' require_module_name */ - { - *(yyvsp[0].s) = "../" + *(yyvsp[0].s); - (yyval.s) = (yyvsp[0].s); - } - break; - - case 56: /* require_module_name: '%' '/' require_module_name */ - { - *(yyvsp[0].s) = "%/" + *(yyvsp[0].s); - (yyval.s) = (yyvsp[0].s); - } - break; - - case 57: /* require_module_name: require_module_name '.' keyword_or_name */ - { - *(yyvsp[-2].s) += "."; - *(yyvsp[-2].s) += *(yyvsp[0].s); - delete (yyvsp[0].s); - (yyval.s) = (yyvsp[-2].s); - } - break; - - case 58: /* require_module_name: require_module_name '/' keyword_or_name */ - { - *(yyvsp[-2].s) += "/"; - *(yyvsp[-2].s) += *(yyvsp[0].s); - delete (yyvsp[0].s); - (yyval.s) = (yyvsp[-2].s); - } - break; - - case 59: /* require_module: require_module_name is_public_module */ - { - ast_requireModule(scanner,(yyvsp[-1].s),nullptr,(yyvsp[0].b),tokAt(scanner,(yylsp[-1]))); - } - break; - - case 60: /* require_module: require_module_name "as" "name" is_public_module */ - { - ast_requireModule(scanner,(yyvsp[-3].s),(yyvsp[-1].s),(yyvsp[0].b),tokAt(scanner,(yylsp[-3]))); - } - break; - - case 61: /* is_public_module: %empty */ - { (yyval.b) = false; } - break; - - case 62: /* is_public_module: "public" */ - { (yyval.b) = true; } - break; - - case 66: /* expect_error: "integer constant" */ - { - yyextra->g_Program->expectErrors[CompilationError((yyvsp[0].i))] ++; - } - break; - - case 67: /* expect_error: "integer constant" ':' "integer constant" */ - { - yyextra->g_Program->expectErrors[CompilationError((yyvsp[-2].i))] += (yyvsp[0].i); - } - break; - - case 68: /* expression_label: "label" "integer constant" ':' */ - { - (yyval.pExpression) = new ExprLabel(tokAt(scanner,(yylsp[-2])),(yyvsp[-1].i)); - } - break; - - case 69: /* expression_goto: "goto" "label" "integer constant" */ - { - (yyval.pExpression) = new ExprGoto(tokAt(scanner,(yylsp[-2])),(yyvsp[0].i)); - } - break; - - case 70: /* expression_goto: "goto" expr */ - { - (yyval.pExpression) = new ExprGoto(tokAt(scanner,(yylsp[-1])),(yyvsp[0].pExpression)); - } - break; - - case 71: /* elif_or_static_elif: "elif" */ - { (yyval.b) = false; } - break; - - case 72: /* elif_or_static_elif: "static_elif" */ - { (yyval.b) = true; } - break; - - case 73: /* expression_else: %empty */ - { (yyval.pExpression) = nullptr; } - break; - - case 74: /* expression_else: "else" expression_block */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 75: /* expression_else: elif_or_static_elif expr expression_block expression_else */ - { - format::wrap_par_expr(tokAt(scanner,(yylsp[-2])), (yyvsp[-2].pExpression)->at); - if (!format::is_else_newline() && (yyvsp[0].pExpression) != nullptr) { - format::skip_spaces_or_print(tokAt(scanner,(yylsp[-3])), tokAt(scanner,(yylsp[-1])), tokAt(scanner,(yylsp[0])), yyextra->das_tab_size); - } - - auto eite = new ExprIfThenElse(tokAt(scanner,(yylsp[-3])),(yyvsp[-2].pExpression),(yyvsp[-1].pExpression),(yyvsp[0].pExpression)); - eite->isStatic = (yyvsp[-3].b); - (yyval.pExpression) = eite; - } - break; - - case 76: /* expression_else: elif_or_static_elif expr expression_block SEMICOLON expression_else */ - { - format::wrap_par_expr(tokAt(scanner,(yylsp[-3])), (yyvsp[-3].pExpression)->at); - if (!format::is_else_newline() && (yyvsp[0].pExpression) != nullptr) { - format::skip_spaces_or_print(tokAt(scanner,(yylsp[-4])), tokAt(scanner,(yylsp[-2])), tokAt(scanner,(yylsp[0])), yyextra->das_tab_size); - } - - auto eite = new ExprIfThenElse(tokAt(scanner,(yylsp[-4])),(yyvsp[-3].pExpression),(yyvsp[-2].pExpression),(yyvsp[0].pExpression)); - eite->isStatic = (yyvsp[-4].b); - (yyval.pExpression) = eite; - } - break; - - case 77: /* if_or_static_if: "if" */ - { (yyval.b) = false; } - break; - - case 78: /* if_or_static_if: "static_if" */ - { (yyval.b) = true; } - break; - - case 79: /* expression_else_one_liner: %empty */ - { (yyval.pExpression) = nullptr; } - break; - - case 80: /* $@3: %empty */ - { yyextra->das_need_oxford_comma = true; } - break; - - case 81: /* expression_else_one_liner: "else" $@3 expression_if_one_liner */ - { - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 82: /* expression_if_one_liner: expr */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 83: /* expression_if_one_liner: expression_return_no_pipe */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 84: /* expression_if_one_liner: expression_yield_no_pipe */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 85: /* expression_if_one_liner: expression_break */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 86: /* expression_if_one_liner: expression_continue */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 87: /* expression_if_then_else: if_or_static_if expr expression_block SEMICOLON expression_else */ - { - format::wrap_par_expr(tokAt(scanner,(yylsp[-3])), (yyvsp[-3].pExpression)->at); - if (!format::is_else_newline() && (yyvsp[0].pExpression) != nullptr) { - format::skip_spaces_or_print(tokAt(scanner,(yylsp[-4])), tokAt(scanner,(yylsp[-2])), tokAt(scanner,(yylsp[0])), yyextra->das_tab_size); - } - - auto eite = new ExprIfThenElse(tokAt(scanner,(yylsp[-4])),(yyvsp[-3].pExpression),(yyvsp[-2].pExpression),(yyvsp[0].pExpression)); - eite->isStatic = (yyvsp[-4].b); - (yyval.pExpression) = eite; - } - break; - - case 88: /* expression_if_then_else: if_or_static_if expr expression_block expression_else */ - { - format::wrap_par_expr(tokAt(scanner,(yylsp[-2])), (yyvsp[-2].pExpression)->at); - if (!format::is_else_newline() && (yyvsp[0].pExpression) != nullptr) { - format::skip_spaces_or_print(tokAt(scanner,(yylsp[-3])), tokAt(scanner,(yylsp[-1])), tokAt(scanner,(yylsp[0])), yyextra->das_tab_size); - } - - auto eite = new ExprIfThenElse(tokAt(scanner,(yylsp[-3])),(yyvsp[-2].pExpression),(yyvsp[-1].pExpression),(yyvsp[0].pExpression)); - eite->isStatic = (yyvsp[-3].b); - (yyval.pExpression) = eite; - } - break; - - case 89: /* $@4: %empty */ - { yyextra->das_need_oxford_comma = true; } - break; - - case 90: /* expression_if_then_else: expression_if_one_liner "if" $@4 expr expression_else_one_liner semicolon */ - { - format::wrap_par_expr(tokAt(scanner,(yylsp[-2])), (yyvsp[-2].pExpression)->at); - - (yyval.pExpression) = new ExprIfThenElse(tokAt(scanner,(yylsp[-4])),(yyvsp[-2].pExpression),ast_wrapInBlock((yyvsp[-5].pExpression)),(yyvsp[-1].pExpression) ? ast_wrapInBlock((yyvsp[-1].pExpression)) : nullptr); - } - break; - - case 91: /* $@5: %empty */ - { yyextra->das_need_oxford_comma=false; } - break; - - case 92: /* expression_for_loop: "for" $@5 variable_name_with_pos_list "in" expr_list expression_block */ - { - format::wrap_par_expr(tokRangeAt(scanner, (yylsp[-3]), (yylsp[-1])), tokRangeAt(scanner, (yylsp[-3]), (yylsp[-1]))); - (yyval.pExpression) = ast_forLoop(scanner,(yyvsp[-3].pNameWithPosList),(yyvsp[-1].pExpression),(yyvsp[0].pExpression),tokAt(scanner,(yylsp[-5])),tokAt(scanner,(yylsp[0]))); - } - break; - - case 93: /* $@6: %empty */ - { // Had to add to successfully convert to v2 syntax, just copied from ds2_parser - yyextra->das_keyword = true; - } - break; - - case 94: /* expression_for_loop: "for" $@6 '(' variable_name_with_pos_list "in" expr_list ')' expression_block */ - { - yyextra->das_keyword = false; - (yyval.pExpression) = ast_forLoop(scanner,(yyvsp[-4].pNameWithPosList),(yyvsp[-2].pExpression),(yyvsp[0].pExpression),tokAt(scanner,(yylsp[-7])),tokAt(scanner,(yylsp[0]))); - } - break; - - case 95: /* expression_unsafe: "unsafe" expression_block */ - { - auto pUnsafe = new ExprUnsafe(tokAt(scanner,(yylsp[-1]))); - pUnsafe->body = (yyvsp[0].pExpression); - (yyval.pExpression) = pUnsafe; - } - break; - - case 96: /* expression_while_loop: "while" expr expression_block */ - { - format::wrap_par_expr(tokAt(scanner,(yylsp[-1])), (yyvsp[-1].pExpression)->at); - - auto pWhile = new ExprWhile(tokAt(scanner,(yylsp[-2]))); - pWhile->cond = (yyvsp[-1].pExpression); - pWhile->body = (yyvsp[0].pExpression); - ((ExprBlock *)(yyvsp[0].pExpression))->inTheLoop = true; - (yyval.pExpression) = pWhile; - } - break; - - case 97: /* expression_with: "with" expr expression_block */ - { - format::wrap_par_expr(tokAt(scanner,(yylsp[-1])), (yyvsp[-1].pExpression)->at); - auto pWith = new ExprWith(tokAt(scanner,(yylsp[-2]))); - pWith->with = (yyvsp[-1].pExpression); - pWith->body = (yyvsp[0].pExpression); - (yyval.pExpression) = pWith; - } - break; - - case 98: /* $@7: %empty */ - { yyextra->das_need_oxford_comma=true; } - break; - - case 99: /* expression_with_alias: "assume" "name" '=' $@7 expr semicolon */ - { - (yyval.pExpression) = new ExprAssume(tokAt(scanner,(yylsp[-5])), *(yyvsp[-4].s), ExpressionPtr((yyvsp[-1].pExpression))); - delete (yyvsp[-4].s); - } - break; - - case 100: /* $@8: %empty */ - { yyextra->das_force_oxford_comma=true;} - break; - - case 101: /* expression_with_alias: "typedef" $@8 "name" '=' type_declaration semicolon */ - { - (yyval.pExpression) = new ExprAssume(tokAt(scanner,(yylsp[-5])), *(yyvsp[-3].s), TypeDeclPtr((yyvsp[-1].pTypeDecl))); - } - break; - - case 102: /* annotation_argument_value: string_constant */ - { (yyval.aa) = new AnnotationArgument("",*(yyvsp[0].s)); delete (yyvsp[0].s); } - break; - - case 103: /* annotation_argument_value: "name" */ - { (yyval.aa) = new AnnotationArgument("",*(yyvsp[0].s)); delete (yyvsp[0].s); } - break; - - case 104: /* annotation_argument_value: "integer constant" */ - { (yyval.aa) = new AnnotationArgument("",(yyvsp[0].i)); } - break; - - case 105: /* annotation_argument_value: "floating point constant" */ - { (yyval.aa) = new AnnotationArgument("",float((yyvsp[0].fd))); } - break; - - case 106: /* annotation_argument_value: "true" */ - { (yyval.aa) = new AnnotationArgument("",true); } - break; - - case 107: /* annotation_argument_value: "false" */ - { (yyval.aa) = new AnnotationArgument("",false); } - break; - - case 108: /* annotation_argument_value_list: annotation_argument_value */ - { - (yyval.aaList) = new AnnotationArgumentList(); - (yyval.aaList)->push_back(*(yyvsp[0].aa)); - delete (yyvsp[0].aa); - } - break; - - case 109: /* annotation_argument_value_list: annotation_argument_value_list ',' annotation_argument_value */ - { - (yyval.aaList) = (yyvsp[-2].aaList); - (yyval.aaList)->push_back(*(yyvsp[0].aa)); - delete (yyvsp[0].aa); - } - break; - - case 110: /* annotation_argument_name: "name" */ - { (yyval.s) = (yyvsp[0].s); } - break; - - case 111: /* annotation_argument_name: "type" */ - { (yyval.s) = new string("type"); } - break; - - case 112: /* annotation_argument_name: "in" */ - { (yyval.s) = new string("in"); } - break; - - case 113: /* annotation_argument: annotation_argument_name '=' string_constant */ - { (yyval.aa) = new AnnotationArgument(*(yyvsp[-2].s),*(yyvsp[0].s),tokRangeAt(scanner,(yylsp[-2]),(yylsp[0]))); delete (yyvsp[0].s); delete (yyvsp[-2].s); } - break; - - case 114: /* annotation_argument: annotation_argument_name '=' "name" */ - { (yyval.aa) = new AnnotationArgument(*(yyvsp[-2].s),*(yyvsp[0].s),tokRangeAt(scanner,(yylsp[-2]),(yylsp[0]))); delete (yyvsp[0].s); delete (yyvsp[-2].s); } - break; - - case 115: /* annotation_argument: annotation_argument_name '=' '@' '@' "name" */ - { (yyval.aa) = new AnnotationArgument(*(yyvsp[-4].s),*(yyvsp[0].s),tokAt(scanner,(yylsp[-4]))); delete (yyvsp[0].s); delete (yyvsp[-4].s); } - break; - - case 116: /* annotation_argument: annotation_argument_name '=' "integer constant" */ - { (yyval.aa) = new AnnotationArgument(*(yyvsp[-2].s),(yyvsp[0].i),tokRangeAt(scanner,(yylsp[-2]),(yylsp[0]))); delete (yyvsp[-2].s); } - break; - - case 117: /* annotation_argument: annotation_argument_name '=' "floating point constant" */ - { (yyval.aa) = new AnnotationArgument(*(yyvsp[-2].s),float((yyvsp[0].fd)),tokRangeAt(scanner,(yylsp[-2]),(yylsp[0]))); delete (yyvsp[-2].s); } - break; - - case 118: /* annotation_argument: annotation_argument_name '=' "true" */ - { (yyval.aa) = new AnnotationArgument(*(yyvsp[-2].s),true,tokRangeAt(scanner,(yylsp[-2]),(yylsp[0]))); delete (yyvsp[-2].s); } - break; - - case 119: /* annotation_argument: annotation_argument_name '=' "false" */ - { (yyval.aa) = new AnnotationArgument(*(yyvsp[-2].s),false,tokRangeAt(scanner,(yylsp[-2]),(yylsp[0]))); delete (yyvsp[-2].s); } - break; - - case 120: /* annotation_argument: annotation_argument_name */ - { (yyval.aa) = new AnnotationArgument(*(yyvsp[0].s),true,tokAt(scanner,(yylsp[0]))); delete (yyvsp[0].s); } - break; - - case 121: /* annotation_argument: annotation_argument_name '=' '(' annotation_argument_value_list ')' */ - { - { (yyval.aa) = new AnnotationArgument(*(yyvsp[-4].s),(yyvsp[-1].aaList),tokRangeAt(scanner,(yylsp[-4]),(yylsp[0]))); delete (yyvsp[-4].s); } - } - break; - - case 122: /* annotation_argument_list: annotation_argument */ - { - (yyval.aaList) = ast_annotationArgumentListEntry(scanner,new AnnotationArgumentList(),(yyvsp[0].aa)); - } - break; - - case 123: /* annotation_argument_list: annotation_argument_list ',' annotation_argument */ - { - (yyval.aaList) = ast_annotationArgumentListEntry(scanner,(yyvsp[-2].aaList),(yyvsp[0].aa)); - } - break; - - case 124: /* metadata_argument_list: '@' annotation_argument */ - { - (yyval.aaList) = ast_annotationArgumentListEntry(scanner,new AnnotationArgumentList(),(yyvsp[0].aa)); - } - break; - - case 125: /* metadata_argument_list: metadata_argument_list '@' annotation_argument */ - { - (yyval.aaList) = ast_annotationArgumentListEntry(scanner,(yyvsp[-2].aaList),(yyvsp[0].aa)); - } - break; - - case 126: /* metadata_argument_list: metadata_argument_list semicolon */ - { - (yyval.aaList) = (yyvsp[-1].aaList); - } - break; - - case 127: /* annotation_declaration_name: name_in_namespace */ - { (yyval.s) = (yyvsp[0].s); } - break; - - case 128: /* annotation_declaration_name: "require" */ - { (yyval.s) = new string("require"); } - break; - - case 129: /* annotation_declaration_name: "private" */ - { (yyval.s) = new string("private"); } - break; - - case 130: /* annotation_declaration_name: "template" */ - { (yyval.s) = new string("template"); } - break; - - case 131: /* annotation_declaration_basic: annotation_declaration_name */ - { - (yyval.fa) = new AnnotationDeclaration(); - (yyval.fa)->at = tokAt(scanner,(yylsp[0])); - if ( yyextra->g_Access->isAnnotationAllowed(*(yyvsp[0].s), yyextra->g_Program->thisModuleName) ) { - if ( auto ann = findAnnotation(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))) ) { - (yyval.fa)->annotation = ann; - } - } else { - das_yyerror(scanner,"annotation " + *(yyvsp[0].s) + " is not allowed here", - tokAt(scanner,(yylsp[0])), CompilationError::invalid_annotation); - } - delete (yyvsp[0].s); - } - break; - - case 132: /* annotation_declaration_basic: annotation_declaration_name '(' annotation_argument_list ')' */ - { - (yyval.fa) = new AnnotationDeclaration(); - (yyval.fa)->at = tokAt(scanner,(yylsp[-3])); - if ( yyextra->g_Access->isAnnotationAllowed(*(yyvsp[-3].s), yyextra->g_Program->thisModuleName) ) { - if ( auto ann = findAnnotation(scanner,*(yyvsp[-3].s),tokAt(scanner,(yylsp[-3]))) ) { - (yyval.fa)->annotation = ann; - } - } else { - das_yyerror(scanner,"annotation " + *(yyvsp[-3].s) + " is not allowed here", - tokAt(scanner,(yylsp[-3])), CompilationError::invalid_annotation); - } - swap ( (yyval.fa)->arguments, *(yyvsp[-1].aaList) ); - delete (yyvsp[-1].aaList); - delete (yyvsp[-3].s); - } - break; - - case 133: /* annotation_declaration: annotation_declaration_basic */ - { - (yyval.fa) = (yyvsp[0].fa); - } - break; - - case 134: /* annotation_declaration: '!' annotation_declaration */ - { - if ( !(yyvsp[0].fa)->annotation->rtti_isFunctionAnnotation() || !((FunctionAnnotation *)((yyvsp[0].fa)->annotation))->isSpecialized() ) { - das_yyerror(scanner,"can only run logical operations on contracts", tokAt(scanner, (yylsp[0])), - CompilationError::invalid_annotation); } - (yyval.fa) = new AnnotationDeclaration(); - (yyval.fa)->at = tokAt(scanner, (yylsp[-1])); - (yyval.fa)->annotation = newLogicAnnotation(LogicAnnotationOp::Not,(yyvsp[0].fa),nullptr); - } - break; - - case 135: /* annotation_declaration: annotation_declaration "&&" annotation_declaration */ - { - if ( !(yyvsp[-2].fa)->annotation->rtti_isFunctionAnnotation() || !((FunctionAnnotation *)((yyvsp[-2].fa)->annotation))->isSpecialized() ) { - das_yyerror(scanner,"can only run logical operations on contracts", tokAt(scanner, (yylsp[-2])), - CompilationError::invalid_annotation); } - if ( !(yyvsp[0].fa)->annotation->rtti_isFunctionAnnotation() || !((FunctionAnnotation *)((yyvsp[0].fa)->annotation))->isSpecialized() ) { - das_yyerror(scanner,"can only run logical operations on contracts", tokAt(scanner, (yylsp[0])), - CompilationError::invalid_annotation); } - (yyval.fa) = new AnnotationDeclaration(); - (yyval.fa)->at = tokAt(scanner, (yylsp[-1])); - (yyval.fa)->annotation = newLogicAnnotation(LogicAnnotationOp::And,(yyvsp[-2].fa),(yyvsp[0].fa)); - } - break; - - case 136: /* annotation_declaration: annotation_declaration "||" annotation_declaration */ - { - if ( !(yyvsp[-2].fa)->annotation || !(yyvsp[-2].fa)->annotation->rtti_isFunctionAnnotation() || !((FunctionAnnotation *)((yyvsp[-2].fa)->annotation))->isSpecialized() ) { - das_yyerror(scanner,"can only run logical operations on contracts", tokAt(scanner, (yylsp[-2])), - CompilationError::invalid_annotation); } - if ( !(yyvsp[0].fa)->annotation || !(yyvsp[0].fa)->annotation->rtti_isFunctionAnnotation() || !((FunctionAnnotation *)((yyvsp[0].fa)->annotation))->isSpecialized() ) { - das_yyerror(scanner,"can only run logical operations on contracts", tokAt(scanner, (yylsp[0])), - CompilationError::invalid_annotation); } - (yyval.fa) = new AnnotationDeclaration(); - (yyval.fa)->at = tokAt(scanner, (yylsp[-1])); - (yyval.fa)->annotation = newLogicAnnotation(LogicAnnotationOp::Or,(yyvsp[-2].fa),(yyvsp[0].fa)); - } - break; - - case 137: /* annotation_declaration: annotation_declaration "^^" annotation_declaration */ - { - if ( !(yyvsp[-2].fa)->annotation->rtti_isFunctionAnnotation() || !((FunctionAnnotation *)((yyvsp[-2].fa)->annotation))->isSpecialized() ) { - das_yyerror(scanner,"can only run logical operations on contracts", tokAt(scanner, (yylsp[-2])), - CompilationError::invalid_annotation); } - if ( !(yyvsp[0].fa)->annotation->rtti_isFunctionAnnotation() || !((FunctionAnnotation *)((yyvsp[0].fa)->annotation))->isSpecialized() ) { - das_yyerror(scanner,"can only run logical operations on contracts", tokAt(scanner, (yylsp[0])), - CompilationError::invalid_annotation); } - (yyval.fa) = new AnnotationDeclaration(); - (yyval.fa)->at = tokAt(scanner, (yylsp[-1])); - (yyval.fa)->annotation = newLogicAnnotation(LogicAnnotationOp::Xor,(yyvsp[-2].fa),(yyvsp[0].fa)); - } - break; - - case 138: /* annotation_declaration: '(' annotation_declaration ')' */ - { - (yyval.fa) = (yyvsp[-1].fa); - } - break; - - case 139: /* annotation_declaration: "|>" annotation_declaration */ - { - (yyval.fa) = (yyvsp[0].fa); - (yyvsp[0].fa)->inherited = true; - } - break; - - case 140: /* annotation_list: annotation_declaration */ - { - (yyval.faList) = new AnnotationList(); - (yyval.faList)->push_back(AnnotationDeclarationPtr((yyvsp[0].fa))); - } - break; - - case 141: /* annotation_list: annotation_list ',' annotation_declaration */ - { - (yyval.faList) = (yyvsp[-2].faList); - (yyval.faList)->push_back(AnnotationDeclarationPtr((yyvsp[0].fa))); - } - break; - - case 142: /* optional_annotation_list: %empty */ - { (yyval.faList) = nullptr; } - break; - - case 143: /* optional_annotation_list: '[' annotation_list ']' */ - { (yyval.faList) = (yyvsp[-1].faList); } - break; - - case 144: /* optional_function_argument_list: %empty */ - { (yyval.pVarDeclList) = nullptr; } - break; - - case 145: /* optional_function_argument_list: '(' ')' */ - { (yyval.pVarDeclList) = nullptr; } - break; - - case 146: /* optional_function_argument_list: '(' function_argument_list ')' */ - { (yyval.pVarDeclList) = (yyvsp[-1].pVarDeclList); } - break; - - case 147: /* optional_function_type: %empty */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::autoinfer); - } - break; - - case 148: /* optional_function_type: ':' type_declaration */ - { - (yyval.pTypeDecl) = (yyvsp[0].pTypeDecl); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[0])); - } - break; - - case 149: /* optional_function_type: "->" type_declaration */ - { - (yyval.pTypeDecl) = (yyvsp[0].pTypeDecl); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[0])); - } - break; - - case 150: /* function_name: "name" */ - { - das_checkName(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))); - (yyval.s) = (yyvsp[0].s); - } - break; - - case 151: /* function_name: "operator" '!' */ - { (yyval.s) = new string("!"); } - break; - - case 152: /* function_name: "operator" '~' */ - { (yyval.s) = new string("~"); } - break; - - case 153: /* function_name: "operator" "+=" */ - { (yyval.s) = new string("+="); } - break; - - case 154: /* function_name: "operator" "-=" */ - { (yyval.s) = new string("-="); } - break; - - case 155: /* function_name: "operator" "*=" */ - { (yyval.s) = new string("*="); } - break; - - case 156: /* function_name: "operator" "/=" */ - { (yyval.s) = new string("/="); } - break; - - case 157: /* function_name: "operator" "%=" */ - { (yyval.s) = new string("%="); } - break; - - case 158: /* function_name: "operator" "&=" */ - { (yyval.s) = new string("&="); } - break; - - case 159: /* function_name: "operator" "|=" */ - { (yyval.s) = new string("|="); } - break; - - case 160: /* function_name: "operator" "^=" */ - { (yyval.s) = new string("^="); } - break; - - case 161: /* function_name: "operator" "&&=" */ - { (yyval.s) = new string("&&="); } - break; - - case 162: /* function_name: "operator" "||=" */ - { (yyval.s) = new string("||="); } - break; - - case 163: /* function_name: "operator" "^^=" */ - { (yyval.s) = new string("^^="); } - break; - - case 164: /* function_name: "operator" "&&" */ - { (yyval.s) = new string("&&"); } - break; - - case 165: /* function_name: "operator" "||" */ - { (yyval.s) = new string("||"); } - break; - - case 166: /* function_name: "operator" "^^" */ - { (yyval.s) = new string("^^"); } - break; - - case 167: /* function_name: "operator" '+' */ - { (yyval.s) = new string("+"); } - break; - - case 168: /* function_name: "operator" '-' */ - { (yyval.s) = new string("-"); } - break; - - case 169: /* function_name: "operator" '*' */ - { (yyval.s) = new string("*"); } - break; - - case 170: /* function_name: "operator" '/' */ - { (yyval.s) = new string("/"); } - break; - - case 171: /* function_name: "operator" '%' */ - { (yyval.s) = new string("%"); } - break; - - case 172: /* function_name: "operator" '<' */ - { (yyval.s) = new string("<"); } - break; - - case 173: /* function_name: "operator" '>' */ - { (yyval.s) = new string(">"); } - break; - - case 174: /* function_name: "operator" ".." */ - { (yyval.s) = new string("interval"); } - break; - - case 175: /* function_name: "operator" "==" */ - { (yyval.s) = new string("=="); } - break; - - case 176: /* function_name: "operator" "!=" */ - { (yyval.s) = new string("!="); } - break; - - case 177: /* function_name: "operator" "<=" */ - { (yyval.s) = new string("<="); } - break; - - case 178: /* function_name: "operator" ">=" */ - { (yyval.s) = new string(">="); } - break; - - case 179: /* function_name: "operator" '&' */ - { (yyval.s) = new string("&"); } - break; - - case 180: /* function_name: "operator" '|' */ - { (yyval.s) = new string("|"); } - break; - - case 181: /* function_name: "operator" '^' */ - { (yyval.s) = new string("^"); } - break; - - case 182: /* function_name: "++" "operator" */ - { (yyval.s) = new string("++"); } - break; - - case 183: /* function_name: "--" "operator" */ - { (yyval.s) = new string("--"); } - break; - - case 184: /* function_name: "operator" "++" */ - { (yyval.s) = new string("+++"); } - break; - - case 185: /* function_name: "operator" "--" */ - { (yyval.s) = new string("---"); } - break; - - case 186: /* function_name: "operator" "<<" */ - { (yyval.s) = new string("<<"); } - break; - - case 187: /* function_name: "operator" ">>" */ - { (yyval.s) = new string(">>"); } - break; - - case 188: /* function_name: "operator" "<<=" */ - { (yyval.s) = new string("<<="); } - break; - - case 189: /* function_name: "operator" ">>=" */ - { (yyval.s) = new string(">>="); } - break; - - case 190: /* function_name: "operator" "<<<" */ - { (yyval.s) = new string("<<<"); } - break; - - case 191: /* function_name: "operator" ">>>" */ - { (yyval.s) = new string(">>>"); } - break; - - case 192: /* function_name: "operator" "<<<=" */ - { (yyval.s) = new string("<<<="); } - break; - - case 193: /* function_name: "operator" ">>>=" */ - { (yyval.s) = new string(">>>="); } - break; - - case 194: /* function_name: "operator" '[' ']' */ - { (yyval.s) = new string("[]"); } - break; - - case 195: /* function_name: "operator" '[' ']' "<-" */ - { (yyval.s) = new string("[]<-"); } - break; - - case 196: /* function_name: "operator" '[' ']' ":=" */ - { (yyval.s) = new string("[]:="); } - break; - - case 197: /* function_name: "operator" '[' ']' "+=" */ - { (yyval.s) = new string("[]+="); } - break; - - case 198: /* function_name: "operator" '[' ']' "-=" */ - { (yyval.s) = new string("[]-="); } - break; - - case 199: /* function_name: "operator" '[' ']' "*=" */ - { (yyval.s) = new string("[]*="); } - break; - - case 200: /* function_name: "operator" '[' ']' "/=" */ - { (yyval.s) = new string("[]/="); } - break; - - case 201: /* function_name: "operator" '[' ']' "%=" */ - { (yyval.s) = new string("[]%="); } - break; - - case 202: /* function_name: "operator" '[' ']' "&=" */ - { (yyval.s) = new string("[]&="); } - break; - - case 203: /* function_name: "operator" '[' ']' "|=" */ - { (yyval.s) = new string("[]|="); } - break; - - case 204: /* function_name: "operator" '[' ']' "^=" */ - { (yyval.s) = new string("[]^="); } - break; - - case 205: /* function_name: "operator" '[' ']' "&&=" */ - { (yyval.s) = new string("[]&&="); } - break; - - case 206: /* function_name: "operator" '[' ']' "||=" */ - { (yyval.s) = new string("[]||="); } - break; - - case 207: /* function_name: "operator" '[' ']' "^^=" */ - { (yyval.s) = new string("[]^^="); } - break; - - case 208: /* function_name: "operator" "?[" ']' */ - { (yyval.s) = new string("?[]"); } - break; - - case 209: /* function_name: "operator" '.' */ - { (yyval.s) = new string("."); } - break; - - case 210: /* function_name: "operator" "?." */ - { (yyval.s) = new string("?."); } - break; - - case 211: /* function_name: "operator" '.' "name" */ - { (yyval.s) = new string(".`"+*(yyvsp[0].s)); delete (yyvsp[0].s); } - break; - - case 212: /* function_name: "operator" '.' "name" ":=" */ - { (yyval.s) = new string(".`"+*(yyvsp[-1].s)+"`clone"); delete (yyvsp[-1].s); } - break; - - case 213: /* function_name: "operator" '.' "name" "+=" */ - { (yyval.s) = new string(".`"+*(yyvsp[-1].s)+"`+="); delete (yyvsp[-1].s); } - break; - - case 214: /* function_name: "operator" '.' "name" "-=" */ - { (yyval.s) = new string(".`"+*(yyvsp[-1].s)+"`-="); delete (yyvsp[-1].s); } - break; - - case 215: /* function_name: "operator" '.' "name" "*=" */ - { (yyval.s) = new string(".`"+*(yyvsp[-1].s)+"`*="); delete (yyvsp[-1].s); } - break; - - case 216: /* function_name: "operator" '.' "name" "/=" */ - { (yyval.s) = new string(".`"+*(yyvsp[-1].s)+"`/="); delete (yyvsp[-1].s); } - break; - - case 217: /* function_name: "operator" '.' "name" "%=" */ - { (yyval.s) = new string(".`"+*(yyvsp[-1].s)+"`%="); delete (yyvsp[-1].s); } - break; - - case 218: /* function_name: "operator" '.' "name" "&=" */ - { (yyval.s) = new string(".`"+*(yyvsp[-1].s)+"`&="); delete (yyvsp[-1].s); } - break; - - case 219: /* function_name: "operator" '.' "name" "|=" */ - { (yyval.s) = new string(".`"+*(yyvsp[-1].s)+"`|="); delete (yyvsp[-1].s); } - break; - - case 220: /* function_name: "operator" '.' "name" "^=" */ - { (yyval.s) = new string(".`"+*(yyvsp[-1].s)+"`^="); delete (yyvsp[-1].s); } - break; - - case 221: /* function_name: "operator" '.' "name" "&&=" */ - { (yyval.s) = new string(".`"+*(yyvsp[-1].s)+"`&&="); delete (yyvsp[-1].s); } - break; - - case 222: /* function_name: "operator" '.' "name" "||=" */ - { (yyval.s) = new string(".`"+*(yyvsp[-1].s)+"`||="); delete (yyvsp[-1].s); } - break; - - case 223: /* function_name: "operator" '.' "name" "^^=" */ - { (yyval.s) = new string(".`"+*(yyvsp[-1].s)+"`^^="); delete (yyvsp[-1].s); } - break; - - case 224: /* function_name: "operator" "?." "name" */ - { (yyval.s) = new string("?.`"+*(yyvsp[0].s)); delete (yyvsp[0].s);} - break; - - case 225: /* function_name: "operator" ":=" */ - { (yyval.s) = new string("clone"); } - break; - - case 226: /* function_name: "operator" "delete" */ - { (yyval.s) = new string("finalize"); } - break; - - case 227: /* function_name: "operator" "??" */ - { (yyval.s) = new string("??"); } - break; - - case 228: /* function_name: "operator" "is" */ - { (yyval.s) = new string("`is"); } - break; - - case 229: /* function_name: "operator" "as" */ - { (yyval.s) = new string("`as"); } - break; - - case 230: /* function_name: "operator" "is" "name" */ - { (yyval.s) = (yyvsp[0].s); *(yyvsp[0].s) = "`is`" + *(yyvsp[0].s); } - break; - - case 231: /* function_name: "operator" "as" "name" */ - { (yyval.s) = (yyvsp[0].s); *(yyvsp[0].s) = "`as`" + *(yyvsp[0].s); } - break; - - case 232: /* function_name: "operator" '?' "as" */ - { (yyval.s) = new string("?as"); } - break; - - case 233: /* function_name: "operator" '?' "as" "name" */ - { (yyval.s) = (yyvsp[0].s); *(yyvsp[0].s) = "?as`" + *(yyvsp[0].s); } - break; - - case 234: /* function_name: "bool" */ - { (yyval.s) = new string("bool"); } - break; - - case 235: /* function_name: "string" */ - { (yyval.s) = new string("string"); } - break; - - case 236: /* function_name: "int" */ - { (yyval.s) = new string("int"); } - break; - - case 237: /* function_name: "int2" */ - { (yyval.s) = new string("int2"); } - break; - - case 238: /* function_name: "int3" */ - { (yyval.s) = new string("int3"); } - break; - - case 239: /* function_name: "int4" */ - { (yyval.s) = new string("int4"); } - break; - - case 240: /* function_name: "uint" */ - { (yyval.s) = new string("uint"); } - break; - - case 241: /* function_name: "uint2" */ - { (yyval.s) = new string("uint2"); } - break; - - case 242: /* function_name: "uint3" */ - { (yyval.s) = new string("uint3"); } - break; - - case 243: /* function_name: "uint4" */ - { (yyval.s) = new string("uint4"); } - break; - - case 244: /* function_name: "float" */ - { (yyval.s) = new string("float"); } - break; - - case 245: /* function_name: "float2" */ - { (yyval.s) = new string("float2"); } - break; - - case 246: /* function_name: "float3" */ - { (yyval.s) = new string("float3"); } - break; - - case 247: /* function_name: "float4" */ - { (yyval.s) = new string("float4"); } - break; - - case 248: /* function_name: "range" */ - { (yyval.s) = new string("range"); } - break; - - case 249: /* function_name: "urange" */ - { (yyval.s) = new string("urange"); } - break; - - case 250: /* function_name: "range64" */ - { (yyval.s) = new string("range64"); } - break; - - case 251: /* function_name: "urange64" */ - { (yyval.s) = new string("urange64"); } - break; - - case 252: /* function_name: "int64" */ - { (yyval.s) = new string("int64"); } - break; - - case 253: /* function_name: "uint64" */ - { (yyval.s) = new string("uint64"); } - break; - - case 254: /* function_name: "double" */ - { (yyval.s) = new string("double"); } - break; - - case 255: /* function_name: "int8" */ - { (yyval.s) = new string("int8"); } - break; - - case 256: /* function_name: "uint8" */ - { (yyval.s) = new string("uint8"); } - break; - - case 257: /* function_name: "int16" */ - { (yyval.s) = new string("int16"); } - break; - - case 258: /* function_name: "uint16" */ - { (yyval.s) = new string("uint16"); } - break; - - case 259: /* function_name: "float16" */ - { (yyval.s) = new string("float16"); } - break; - - case 260: /* function_name: "half2" */ - { (yyval.s) = new string("half2"); } - break; - - case 261: /* function_name: "half3" */ - { (yyval.s) = new string("half3"); } - break; - - case 262: /* function_name: "half4" */ - { (yyval.s) = new string("half4"); } - break; - - case 263: /* function_name: "half8" */ - { (yyval.s) = new string("half8"); } - break; - - case 264: /* function_name: "short2" */ - { (yyval.s) = new string("short2"); } - break; - - case 265: /* function_name: "short3" */ - { (yyval.s) = new string("short3"); } - break; - - case 266: /* function_name: "short4" */ - { (yyval.s) = new string("short4"); } - break; - - case 267: /* function_name: "short8" */ - { (yyval.s) = new string("short8"); } - break; - - case 268: /* function_name: "ushort2" */ - { (yyval.s) = new string("ushort2"); } - break; - - case 269: /* function_name: "ushort3" */ - { (yyval.s) = new string("ushort3"); } - break; - - case 270: /* function_name: "ushort4" */ - { (yyval.s) = new string("ushort4"); } - break; - - case 271: /* function_name: "ushort8" */ - { (yyval.s) = new string("ushort8"); } - break; - - case 272: /* function_name: "byte2" */ - { (yyval.s) = new string("byte2"); } - break; - - case 273: /* function_name: "byte3" */ - { (yyval.s) = new string("byte3"); } - break; - - case 274: /* function_name: "byte4" */ - { (yyval.s) = new string("byte4"); } - break; - - case 275: /* function_name: "byte8" */ - { (yyval.s) = new string("byte8"); } - break; - - case 276: /* function_name: "byte16" */ - { (yyval.s) = new string("byte16"); } - break; - - case 277: /* function_name: "ubyte2" */ - { (yyval.s) = new string("ubyte2"); } - break; - - case 278: /* function_name: "ubyte3" */ - { (yyval.s) = new string("ubyte3"); } - break; - - case 279: /* function_name: "ubyte4" */ - { (yyval.s) = new string("ubyte4"); } - break; - - case 280: /* function_name: "ubyte8" */ - { (yyval.s) = new string("ubyte8"); } - break; - - case 281: /* function_name: "ubyte16" */ - { (yyval.s) = new string("ubyte16"); } - break; - - case 282: /* optional_template: %empty */ - { (yyval.b) = false; } - break; - - case 283: /* optional_template: "template" */ - { (yyval.b) = true; } - break; - - case 284: /* global_function_declaration: optional_annotation_list "def" optional_template function_declaration */ - { - (yyvsp[0].pFuncDecl)->atDecl = tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])); - (yyvsp[0].pFuncDecl)->isTemplate = (yyvsp[-1].b); - assignDefaultArguments((yyvsp[0].pFuncDecl)); - runFunctionAnnotations(scanner, yyextra, (yyvsp[0].pFuncDecl), (yyvsp[-3].faList), tokAt(scanner,(yylsp[-3]))); - if ( (yyvsp[0].pFuncDecl)->isGeneric() ) { - implAddGenericFunction(scanner,(yyvsp[0].pFuncDecl)); - } else { - if ( !yyextra->g_Program->addFunction((yyvsp[0].pFuncDecl)) ) { - das_yyerror(scanner,"function is already defined " + - (yyvsp[0].pFuncDecl)->getMangledName(),(yyvsp[0].pFuncDecl)->at, - CompilationError::function_already_declared); - } - } - (yyvsp[0].pFuncDecl)->delRef(); - } - break; - - case 285: /* optional_public_or_private_function: %empty */ - { (yyval.b) = yyextra->g_thisStructure ? !yyextra->g_thisStructure->privateStructure : yyextra->g_Program->thisModule->isPublic; } - break; - - case 286: /* optional_public_or_private_function: "private" */ - { (yyval.b) = false; } - break; - - case 287: /* optional_public_or_private_function: "public" */ - { (yyval.b) = true; } - break; - - case 288: /* function_declaration_header: function_name optional_function_argument_list optional_function_type */ - { - (yyval.pFuncDecl) = ast_functionDeclarationHeader(scanner,(yyvsp[-2].s),(yyvsp[-1].pVarDeclList),(yyvsp[0].pTypeDecl),tokAt(scanner,(yylsp[-2]))); - } - break; - - case 289: /* $@9: %empty */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[0])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeFunction(tak); - } - } - break; - - case 290: /* function_declaration: optional_public_or_private_function $@9 function_declaration_header expression_block */ - { - (yyvsp[-1].pFuncDecl)->body = (yyvsp[0].pExpression); - (yyvsp[-1].pFuncDecl)->privateFunction = !(yyvsp[-3].b); - (yyval.pFuncDecl) = (yyvsp[-1].pFuncDecl); - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[0])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterFunction((yyvsp[-1].pFuncDecl),tak); - } - } - break; - - case 291: /* open_block: "begin of code block" */ - { (yyval.ui) = 0xdeadbeef; } - break; - - case 292: /* open_block: "new scope" */ - { (yyval.ui) = (yyvsp[0].i); } - break; - - case 293: /* close_block: "end of code block" */ - { (yyval.ui) = 0xdeadbeef; } - break; - - case 294: /* close_block: "close scope" */ - { (yyval.ui) = (yyvsp[0].i); } - break; - - case 295: /* expression_block: open_block expressions close_block */ - { - auto prev_loc = format::Pos::from(tokAt(scanner,(yylsp[-2]))); - handle_brace(prev_loc, (yyvsp[-2].ui), format::get_substring(prev_loc, format::Pos::from_last(tokAt(scanner,(yylsp[-1])))), - yyextra->das_tab_size, format::Pos::from_last(tokAt(scanner,(yylsp[-1])))); - (yyval.pExpression) = (yyvsp[-1].pExpression); - (yyval.pExpression)->at = tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])); - } - break; - - case 296: /* expression_block: open_block expressions close_block "finally" open_block expressions close_block */ - { - auto prev_loc = format::Pos::from(tokAt(scanner,(yylsp[-6]))); - if (format::is_replace_braces() && (yyvsp[-6].ui) != 0xdeadbeef && format::prepare_rule(prev_loc)) { - handle_brace(prev_loc, (yyvsp[-6].ui), format::get_substring(prev_loc, format::Pos::from_last(tokAt(scanner,(yylsp[-5])))), - yyextra->das_tab_size, format::Pos::from_last(tokAt(scanner,(yylsp[-5])))); - auto prev_loc_f = format::Pos::from(tokAt(scanner,(yylsp[-2]))); - assert((yyvsp[-2].ui) != 0xdeadbeef); - { - const auto internal_f = format::get_substring(prev_loc_f, format::Pos::from_last(tokAt(scanner,(yylsp[-1])))); - format::get_writer() << " finally {" << internal_f << "\n" << string((yyvsp[-2].ui) * yyextra->das_tab_size, ' ') + "}"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[-1])))); - } - } - - auto pB = (ExprBlock *) (yyvsp[-5].pExpression); - auto pF = (ExprBlock *) (yyvsp[-1].pExpression); - swap ( pB->finalList, pF->list ); - (yyval.pExpression) = (yyvsp[-5].pExpression); - (yyval.pExpression)->at = tokRangeAt(scanner,(yylsp[-6]),(yylsp[0])); - delete (yyvsp[-1].pExpression); - } - break; - - case 297: /* expr_call_pipe: expr expr_full_block_assumed_piped */ - { - if ( (yyvsp[-1].pExpression)->rtti_isCallLikeExpr() ) { - auto start = format::Pos::from_last(tokAt(scanner, (yylsp[-1]))); - start.column -= 1; // drop ) - if (format::is_replace_braces() && format::prepare_rule(start)) { - if (!((ExprLooksLikeCall *)(yyvsp[-1].pExpression))->arguments.empty()) { - format::get_writer() << ", "; - } - format::get_writer() << format::get_substring(tokAt(scanner, (yylsp[0]))) << ");"; - format::finish_rule(format::Pos::from_last(tokAt(scanner, (yylsp[0])))); - } - ((ExprLooksLikeCall *)(yyvsp[-1].pExpression))->arguments.push_back((yyvsp[0].pExpression)); - (yyval.pExpression) = (yyvsp[-1].pExpression); - } else { - (yyval.pExpression) = (yyvsp[-1].pExpression); - delete (yyvsp[0].pExpression); - } - } - break; - - case 298: /* expr_call_pipe: expression_keyword expr_full_block_assumed_piped */ - { - if ( (yyvsp[-1].pExpression)->rtti_isCallLikeExpr() ) { - ((ExprLooksLikeCall *)(yyvsp[-1].pExpression))->arguments.push_back((yyvsp[0].pExpression)); - (yyval.pExpression) = (yyvsp[-1].pExpression); - } else { - (yyval.pExpression) = (yyvsp[-1].pExpression); - delete (yyvsp[0].pExpression); - } - } - break; - - case 299: /* expr_call_pipe: "generator" '<' type_declaration_no_options '>' optional_capture_list expr_full_block_assumed_piped */ - { - (yyval.pExpression) = ast_makeGenerator(scanner,(yyvsp[-3].pTypeDecl),(yyvsp[-1].pCaptList),(yyvsp[0].pExpression),tokAt(scanner,(yylsp[-5])),tokAt(scanner,(yylsp[-1]))); - } - break; - - case 300: /* expression_any: SEMICOLON */ - { (yyval.pExpression) = nullptr; } - break; - - case 301: /* expression_any: "end of expression" */ - { (yyval.pExpression) = nullptr; } - break; - - case 302: /* expression_any: expr_pipe */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 303: /* expression_any: expr_keyword */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 304: /* expression_any: expr_assign_pipe */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 305: /* expression_any: expr_assign semicolon */ - { (yyval.pExpression) = (yyvsp[-1].pExpression); } - break; - - case 306: /* expression_any: expression_delete semicolon */ - { (yyval.pExpression) = (yyvsp[-1].pExpression); } - break; - - case 307: /* expression_any: expression_let */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 308: /* expression_any: expression_while_loop */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 309: /* expression_any: expression_unsafe */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 310: /* expression_any: expression_with */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 311: /* expression_any: expression_with_alias */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 312: /* expression_any: expression_for_loop */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 313: /* expression_any: expression_break semicolon */ - { (yyval.pExpression) = (yyvsp[-1].pExpression); } - break; - - case 314: /* expression_any: expression_continue semicolon */ - { (yyval.pExpression) = (yyvsp[-1].pExpression); } - break; - - case 315: /* expression_any: expression_return */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 316: /* expression_any: expression_yield */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 317: /* expression_any: expression_if_then_else */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 318: /* expression_any: expression_try_catch */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 319: /* expression_any: expression_label semicolon */ - { (yyval.pExpression) = (yyvsp[-1].pExpression); } - break; - - case 320: /* expression_any: expression_goto semicolon */ - { (yyval.pExpression) = (yyvsp[-1].pExpression); } - break; - - case 321: /* expression_any: "pass" semicolon */ - { (yyval.pExpression) = nullptr; } - break; - - case 322: /* expressions: %empty */ - { - (yyval.pExpression) = new ExprBlock(); - (yyval.pExpression)->at = LineInfo(yyextra->g_FileAccessStack.back(), - yylloc.first_column,yylloc.first_line,yylloc.last_column,yylloc.last_line); - } - break; - - case 323: /* expressions: expressions expression_any */ - { - (yyval.pExpression) = (yyvsp[-1].pExpression); - if ( (yyvsp[0].pExpression) ) { - static_cast((yyvsp[-1].pExpression))->list.push_back((yyvsp[0].pExpression)); - } - } - break; - - case 324: /* expressions: expressions error */ - { - delete (yyvsp[-1].pExpression); (yyval.pExpression) = nullptr; YYABORT; - } - break; - - case 325: /* expr_keyword: "keyword" expr expression_block */ - { - format::wrap_par_expr(tokAt(scanner,(yylsp[-1])), (yyvsp[-1].pExpression)->at); // wrap match (expr) - auto pCall = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-2])),*(yyvsp[-2].s)); - pCall->arguments.push_back((yyvsp[-1].pExpression)); - auto resT = new TypeDecl(Type::autoinfer); - auto blk = ast_makeBlock(scanner,0,nullptr,nullptr,nullptr,resT,(yyvsp[0].pExpression),tokAt(scanner,(yylsp[0])),tokAt(scanner,(yylsp[0])),LineInfo()); - pCall->arguments.push_back(blk); - delete (yyvsp[-2].s); - (yyval.pExpression) = pCall; - } - break; - - case 326: /* optional_expr_list: %empty */ - { (yyval.pExpression) = nullptr; } - break; - - case 327: /* optional_expr_list: expr_list optional_comma */ - { (yyval.pExpression) = (yyvsp[-1].pExpression); } - break; - - case 328: /* optional_expr_list_in_braces: %empty */ - { (yyval.pExpression) = nullptr; } - break; - - case 329: /* optional_expr_list_in_braces: '(' optional_expr_list optional_comma ')' */ - { (yyval.pExpression) = (yyvsp[-2].pExpression); } - break; - - case 330: /* optional_expr_map_tuple_list: %empty */ - { (yyval.pExpression) = nullptr; } - break; - - case 331: /* optional_expr_map_tuple_list: expr_map_tuple_list optional_comma */ - { (yyval.pExpression) = (yyvsp[-1].pExpression); } - break; - - case 332: /* type_declaration_no_options_list: type_declaration */ - { - (yyval.pTypeDeclList) = new vector(); - (yyval.pTypeDeclList)->push_back(new ExprTypeDecl(tokAt(scanner,(yylsp[0])),(yyvsp[0].pTypeDecl))); - } - break; - - case 333: /* type_declaration_no_options_list: type_declaration_no_options_list c_or_s type_declaration */ - { - (yyval.pTypeDeclList) = (yyvsp[-2].pTypeDeclList); - (yyval.pTypeDeclList)->push_back(new ExprTypeDecl(tokAt(scanner,(yylsp[0])),(yyvsp[0].pTypeDecl))); - } - break; - - case 334: /* $@10: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 335: /* $@11: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 336: /* expression_keyword: "keyword" '<' $@10 type_declaration_no_options_list '>' $@11 expr */ - { - auto pCall = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-6])),tokAt(scanner,(yylsp[0])),*(yyvsp[-6].s)); - pCall->arguments = typesAndSequenceToList((yyvsp[-3].pTypeDeclList),(yyvsp[0].pExpression)); - delete (yyvsp[-6].s); - (yyval.pExpression) = pCall; - } - break; - - case 337: /* $@12: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 338: /* $@13: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 339: /* expression_keyword: "type function" '<' $@12 type_declaration_no_options_list '>' $@13 optional_expr_list_in_braces */ - { - auto pCall = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-6])),tokAt(scanner,(yylsp[0])),*(yyvsp[-6].s)); - pCall->arguments = typesAndSequenceToList((yyvsp[-3].pTypeDeclList),(yyvsp[0].pExpression)); - delete (yyvsp[-6].s); - (yyval.pExpression) = pCall; - } - break; - - case 340: /* expr_pipe: expr_assign " <|" expr_block */ - { - Expression * pipeCall = (yyvsp[-2].pExpression)->tail(); - if ( pipeCall->rtti_isCallLikeExpr() ) { - auto pCall = (ExprLooksLikeCall *) pipeCall; - pCall->arguments.push_back((yyvsp[0].pExpression)); - (yyval.pExpression) = (yyvsp[-2].pExpression); - } else if ( pipeCall->rtti_isVar() ) { - // a += b <| c - auto pVar = (ExprVar *) pipeCall; - auto pCall = yyextra->g_Program->makeCall(pVar->at,pVar->name); - pCall->arguments.push_back((yyvsp[0].pExpression)); - if ( !(yyvsp[-2].pExpression)->swap_tail(pVar,pCall) ) { - delete pVar; - (yyval.pExpression) = pCall; - } else { - (yyval.pExpression) = (yyvsp[-2].pExpression); - } - } else if ( pipeCall->rtti_isMakeStruct() ) { - auto pMS = (ExprMakeStruct *) pipeCall; - if ( pMS->block ) { - das_yyerror(scanner,"can't pipe into [[ make structure ]]. it already has where closure", - tokAt(scanner,(yylsp[-1])),CompilationError::cant_pipe); - delete (yyvsp[0].pExpression); - } else { - pMS->block = (yyvsp[0].pExpression); - } - (yyval.pExpression) = (yyvsp[-2].pExpression); - } else { - das_yyerror(scanner,"can only pipe into function call or [[ make structure ]]", - tokAt(scanner,(yylsp[-1])),CompilationError::cant_pipe); - delete (yyvsp[0].pExpression); - (yyval.pExpression) = (yyvsp[-2].pExpression); - } - } - break; - - case 341: /* expr_pipe: "@ <|" expr_block */ - { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, (yylsp[-1]))))) { - format::get_writer() << "@"; - format::finish_rule(format::Pos::from_last(tokAt(scanner, (yylsp[-1])))); - } - - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 342: /* expr_pipe: "@@ <|" expr_block */ - { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, (yylsp[-1]))))) { - format::get_writer() << "@@"; - format::finish_rule(format::Pos::from_last(tokAt(scanner, (yylsp[-1])))); - } - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 343: /* expr_pipe: "$ <|" expr_block */ - { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, (yylsp[-1]))))) { - format::get_writer() << "$"; - format::finish_rule(format::Pos::from_last(tokAt(scanner, (yylsp[-1])))); - } - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 344: /* expr_pipe: expr_call_pipe */ - { - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 345: /* name_in_namespace: "name" */ - { (yyval.s) = (yyvsp[0].s); } - break; - - case 346: /* name_in_namespace: "name" "::" "name" */ - { - auto ita = yyextra->das_module_alias.find(*(yyvsp[-2].s)); - if ( ita == yyextra->das_module_alias.end() ) { - *(yyvsp[-2].s) += "::"; - } else { - *(yyvsp[-2].s) = ita->second + "::"; - } - *(yyvsp[-2].s) += *(yyvsp[0].s); - delete (yyvsp[0].s); - (yyval.s) = (yyvsp[-2].s); - } - break; - - case 347: /* name_in_namespace: "::" "name" */ - { *(yyvsp[0].s) = "::" + *(yyvsp[0].s); (yyval.s) = (yyvsp[0].s); } - break; - - case 348: /* expression_delete: "delete" expr */ - { - (yyval.pExpression) = new ExprDelete(tokAt(scanner,(yylsp[-1])), (yyvsp[0].pExpression)); - } - break; - - case 349: /* expression_delete: "delete" "explicit" expr */ - { - auto delExpr = new ExprDelete(tokAt(scanner,(yylsp[-2])), (yyvsp[0].pExpression)); - delExpr->native = true; - (yyval.pExpression) = delExpr; - } - break; - - case 350: /* $@14: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 351: /* $@15: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 352: /* new_type_declaration: '<' $@14 type_declaration '>' $@15 */ - { - (yyval.pTypeDecl) = (yyvsp[-2].pTypeDecl); - } - break; - - case 353: /* new_type_declaration: structure_type_declaration */ - { - (yyval.pTypeDecl) = (yyvsp[0].pTypeDecl); - } - break; - - case 354: /* expr_new: "new" new_type_declaration */ - { - (yyval.pExpression) = new ExprNew(tokAt(scanner,(yylsp[-1])),(yyvsp[0].pTypeDecl),false); - } - break; - - case 355: /* expr_new: "new" new_type_declaration '(' use_initializer ')' */ - { - (yyval.pExpression) = new ExprNew(tokAt(scanner,(yylsp[-4])),(yyvsp[-3].pTypeDecl),true); - ((ExprNew *)(yyval.pExpression))->initializer = (yyvsp[-1].b); - } - break; - - case 356: /* expr_new: "new" new_type_declaration '(' expr_list ')' */ - { - auto pNew = new ExprNew(tokAt(scanner,(yylsp[-4])),(yyvsp[-3].pTypeDecl),true); - (yyval.pExpression) = parseFunctionArguments(pNew,(yyvsp[-1].pExpression)); - } - break; - - case 357: /* expr_new: "new" new_type_declaration '(' make_struct_single ')' */ - { - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->at = tokAt(scanner,(yylsp[-3])); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->makeType = (yyvsp[-3].pTypeDecl); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->useInitializer = true; // $init; - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->alwaysUseInitializer = true; - (yyval.pExpression) = new ExprAscend(tokAt(scanner,(yylsp[-4])),(yyvsp[-1].pExpression)); - } - break; - - case 358: /* expr_new: "new" new_type_declaration '(' "uninitialized" make_struct_single ')' */ - { - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->at = tokAt(scanner,(yylsp[-4])); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->makeType = (yyvsp[-4].pTypeDecl); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->useInitializer = false; // $init; - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->alwaysUseInitializer = true; - (yyval.pExpression) = new ExprAscend(tokAt(scanner,(yylsp[-5])),(yyvsp[-1].pExpression)); - } - break; - - case 359: /* expr_new: "new" make_decl */ - { - (yyval.pExpression) = new ExprAscend(tokAt(scanner,(yylsp[-1])),(yyvsp[0].pExpression)); - } - break; - - case 360: /* expression_break: "break" */ - { (yyval.pExpression) = new ExprBreak(tokAt(scanner,(yylsp[0]))); } - break; - - case 361: /* expression_continue: "continue" */ - { (yyval.pExpression) = new ExprContinue(tokAt(scanner,(yylsp[0]))); } - break; - - case 362: /* expression_return_no_pipe: "return" */ - { - (yyval.pExpression) = new ExprReturn(tokAt(scanner,(yylsp[0])),nullptr); - } - break; - - case 363: /* expression_return_no_pipe: "return" expr_list */ - { - (yyval.pExpression) = new ExprReturn(tokAt(scanner,(yylsp[-1])),sequenceToTuple((yyvsp[0].pExpression))); - } - break; - - case 364: /* expression_return_no_pipe: "return" "<-" expr_list */ - { - auto pRet = new ExprReturn(tokAt(scanner,(yylsp[-2])),sequenceToTuple((yyvsp[0].pExpression))); - pRet->moveSemantics = true; - (yyval.pExpression) = pRet; - } - break; - - case 365: /* expression_return: expression_return_no_pipe semicolon */ - { - (yyval.pExpression) = (yyvsp[-1].pExpression); - } - break; - - case 366: /* expression_return: "return" expr_pipe */ - { - (yyval.pExpression) = new ExprReturn(tokAt(scanner,(yylsp[-1])),(yyvsp[0].pExpression)); - } - break; - - case 367: /* expression_return: "return" "<-" expr_pipe */ - { - auto pRet = new ExprReturn(tokAt(scanner,(yylsp[-2])),(yyvsp[0].pExpression)); - pRet->moveSemantics = true; - (yyval.pExpression) = pRet; - } - break; - - case 368: /* expression_yield_no_pipe: "yield" expr */ - { - (yyval.pExpression) = new ExprYield(tokAt(scanner,(yylsp[-1])),(yyvsp[0].pExpression)); - } - break; - - case 369: /* expression_yield_no_pipe: "yield" "<-" expr */ - { - auto pRet = new ExprYield(tokAt(scanner,(yylsp[-2])),(yyvsp[0].pExpression)); - pRet->moveSemantics = true; - (yyval.pExpression) = pRet; - } - break; - - case 370: /* expression_yield: expression_yield_no_pipe semicolon */ - { - (yyval.pExpression) = (yyvsp[-1].pExpression); - } - break; - - case 371: /* expression_yield: "yield" expr_pipe */ - { - (yyval.pExpression) = new ExprYield(tokAt(scanner,(yylsp[-1])),(yyvsp[0].pExpression)); - } - break; - - case 372: /* expression_yield: "yield" "<-" expr_pipe */ - { - auto pRet = new ExprYield(tokAt(scanner,(yylsp[-2])),(yyvsp[0].pExpression)); - pRet->moveSemantics = true; - (yyval.pExpression) = pRet; - } - break; - - case 373: /* expression_try_catch: "try" expression_block "recover" expression_block */ - { - const auto end_block = format::Pos::from_last(tokAt(scanner, (yylsp[-2]))); - const auto start = format::Pos::from(tokAt(scanner, (yylsp[-3]))); - if (format::is_replace_braces()) { - format::skip_spaces_or_print(tokAt(scanner, (yylsp[-3])), tokAt(scanner, (yylsp[-2])), tokAt(scanner, (yylsp[-1])), yyextra->das_tab_size); - } - - (yyval.pExpression) = new ExprTryCatch(tokAt(scanner,(yylsp[-3])),(yyvsp[-2].pExpression),(yyvsp[0].pExpression)); - } - break; - - case 374: /* kwd_let_var_or_nothing: "let" */ - { (yyval.b) = true; } - break; - - case 375: /* kwd_let_var_or_nothing: "var" */ - { (yyval.b) = false; } - break; - - case 376: /* kwd_let_var_or_nothing: %empty */ - { (yyval.b) = true; } - break; - - case 377: /* kwd_let: "let" */ - { (yyval.b) = true; } - break; - - case 378: /* kwd_let: "var" */ - { (yyval.b) = false; } - break; - - case 379: /* optional_in_scope: "inscope" */ - { (yyval.b) = true; } - break; - - case 380: /* optional_in_scope: %empty */ - { (yyval.b) = false; } - break; - - case 381: /* tuple_expansion: "name" */ - { - (yyval.pNameList) = new vector(); - (yyval.pNameList)->push_back(*(yyvsp[0].s)); - delete (yyvsp[0].s); - } - break; - - case 382: /* tuple_expansion: tuple_expansion ',' "name" */ - { - (yyvsp[-2].pNameList)->push_back(*(yyvsp[0].s)); - delete (yyvsp[0].s); - (yyval.pNameList) = (yyvsp[-2].pNameList); - } - break; - - case 383: /* tuple_expansion_variable_declaration: "[[" tuple_expansion ']' ']' ':' type_declaration_no_options copy_or_move_or_clone expr semicolon */ - { - // std::cout << "case11" << std::endl; - format::replace_with(false, - format::Pos::from(tokAt(scanner,(yylsp[-8]))), - format::substring_between(tokAt(scanner, (yylsp[-8])), tokAt(scanner, (yylsp[-6]))), - format::Pos::from_last(tokAt(scanner,(yylsp[-5]))), "(", ")"); - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[-7].pNameList),tokAt(scanner,(yylsp[-7])),(yyvsp[-3].pTypeDecl),(yyvsp[-1].pExpression)); - (yyval.pVarDecl)->init_via_move = ((yyvsp[-2].i) & CorM_MOVE) !=0; - (yyval.pVarDecl)->init_via_clone = ((yyvsp[-2].i) & CorM_CLONE) !=0; - (yyval.pVarDecl)->isTupleExpansion = true; - } - break; - - case 384: /* tuple_expansion_variable_declaration: '(' tuple_expansion ')' ':' type_declaration_no_options copy_or_move_or_clone expr semicolon */ - { - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[-6].pNameList),tokAt(scanner,(yylsp[-6])),(yyvsp[-3].pTypeDecl),(yyvsp[-1].pExpression)); - (yyval.pVarDecl)->init_via_move = ((yyvsp[-2].i) & CorM_MOVE) !=0; - (yyval.pVarDecl)->init_via_clone = ((yyvsp[-2].i) & CorM_CLONE) !=0; - (yyval.pVarDecl)->isTupleExpansion = true; - } - break; - - case 385: /* tuple_expansion_variable_declaration: "[[" tuple_expansion ']' ']' optional_ref copy_or_move_or_clone expr semicolon */ - { - // std::cout << "case12" << std::endl; - format::replace_with(false, - format::Pos::from(tokAt(scanner,(yylsp[-7]))), - format::substring_between(tokAt(scanner, (yylsp[-7])), tokAt(scanner, (yylsp[-5]))), - format::Pos::from_last(tokAt(scanner,(yylsp[-4]))), "(", ")"); - - auto typeDecl = new TypeDecl(Type::autoinfer); - typeDecl->at = tokAt(scanner,(yylsp[-6])); - typeDecl->ref = (yyvsp[-3].b); - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[-6].pNameList),tokAt(scanner,(yylsp[-6])),typeDecl,(yyvsp[-1].pExpression)); - (yyval.pVarDecl)->init_via_move = ((yyvsp[-2].i) & CorM_MOVE) !=0; - (yyval.pVarDecl)->init_via_clone = ((yyvsp[-2].i) & CorM_CLONE) !=0; - (yyval.pVarDecl)->isTupleExpansion = true; - } - break; - - case 386: /* tuple_expansion_variable_declaration: '(' tuple_expansion ')' optional_ref copy_or_move_or_clone expr semicolon */ - { - auto typeDecl = new TypeDecl(Type::autoinfer); - typeDecl->at = tokAt(scanner,(yylsp[-5])); - typeDecl->ref = (yyvsp[-3].b); - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[-5].pNameList),tokAt(scanner,(yylsp[-5])),typeDecl,(yyvsp[-1].pExpression)); - (yyval.pVarDecl)->init_via_move = ((yyvsp[-2].i) & CorM_MOVE) !=0; - (yyval.pVarDecl)->init_via_clone = ((yyvsp[-2].i) & CorM_CLONE) !=0; - (yyval.pVarDecl)->isTupleExpansion = true; - } - break; - - case 387: /* expression_let: kwd_let optional_in_scope let_variable_declaration */ - { - (yyval.pExpression) = ast_Let(scanner,(yyvsp[-2].b),(yyvsp[-1].b),(yyvsp[0].pVarDecl),tokAt(scanner,(yylsp[-2])),tokAt(scanner,(yylsp[0]))); - } - break; - - case 388: /* expression_let: kwd_let optional_in_scope tuple_expansion_variable_declaration */ - { - (yyval.pExpression) = ast_Let(scanner,(yyvsp[-2].b),(yyvsp[-1].b),(yyvsp[0].pVarDecl),tokAt(scanner,(yylsp[-2])),tokAt(scanner,(yylsp[0]))); - } - break; - - case 389: /* $@16: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 390: /* $@17: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 391: /* expr_cast: "cast" '<' $@16 type_declaration_no_options '>' $@17 expr */ - { - (yyval.pExpression) = new ExprCast(tokAt(scanner,(yylsp[-6])),(yyvsp[0].pExpression),(yyvsp[-3].pTypeDecl)); - } - break; - - case 392: /* $@18: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 393: /* $@19: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 394: /* expr_cast: "upcast" '<' $@18 type_declaration_no_options '>' $@19 expr */ - { - auto pCast = new ExprCast(tokAt(scanner,(yylsp[-6])),(yyvsp[0].pExpression),(yyvsp[-3].pTypeDecl)); - pCast->upcast = true; - (yyval.pExpression) = pCast; - } - break; - - case 395: /* $@20: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 396: /* $@21: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 397: /* expr_cast: "reinterpret" '<' $@20 type_declaration_no_options '>' $@21 expr */ - { - auto pCast = new ExprCast(tokAt(scanner,(yylsp[-6])),(yyvsp[0].pExpression),(yyvsp[-3].pTypeDecl)); - pCast->reinterpret = true; - (yyval.pExpression) = pCast; - } - break; - - case 398: /* $@22: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 399: /* $@23: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 400: /* expr_type_decl: "type" '<' $@22 type_declaration '>' $@23 */ - { - (yyval.pExpression) = new ExprTypeDecl(tokAt(scanner,(yylsp[-5])),(yyvsp[-2].pTypeDecl)); - } - break; - - case 401: /* expr_type_info: "typeinfo" '(' name_in_namespace expr ')' */ - { - format::replace_with(false, - format::Pos::from(tokAt(scanner,(yylsp[-3]))), - format::get_substring(tokAt(scanner,(yylsp[-2]))), - format::Pos::from(tokAt(scanner,(yylsp[-1]))), " ", "("); - if ( (yyvsp[-1].pExpression)->rtti_isTypeDecl() ) { - auto ptd = (ExprTypeDecl *)(yyvsp[-1].pExpression); - (yyval.pExpression) = new ExprTypeInfo(tokAt(scanner,(yylsp[-4])),*(yyvsp[-2].s),ptd->typeexpr); - delete (yyvsp[-1].pExpression); - } else { - (yyval.pExpression) = new ExprTypeInfo(tokAt(scanner,(yylsp[-4])),*(yyvsp[-2].s),(yyvsp[-1].pExpression)); - } - delete (yyvsp[-2].s); - } - break; - - case 402: /* expr_type_info: "typeinfo" '(' name_in_namespace '<' "name" '>' expr ')' */ - { - format::replace_with(false, - format::Pos::from(tokAt(scanner,(yylsp[-6]))), - format::get_substring(tokRangeAt(scanner,(yylsp[-5]),(yylsp[-2]))), - format::Pos::from(tokAt(scanner,(yylsp[-1]))), " ", "("); - - if ( (yyvsp[-1].pExpression)->rtti_isTypeDecl() ) { - auto ptd = (ExprTypeDecl *)(yyvsp[-1].pExpression); - (yyval.pExpression) = new ExprTypeInfo(tokAt(scanner,(yylsp[-7])),*(yyvsp[-5].s),ptd->typeexpr,*(yyvsp[-3].s)); - delete (yyvsp[-1].pExpression); - } else { - (yyval.pExpression) = new ExprTypeInfo(tokAt(scanner,(yylsp[-7])),*(yyvsp[-5].s),(yyvsp[-1].pExpression),*(yyvsp[-3].s)); - } - delete (yyvsp[-5].s); - delete (yyvsp[-3].s); - } - break; - - case 403: /* expr_type_info: "typeinfo" '(' name_in_namespace '<' "name" c_or_s "name" '>' expr ')' */ - { - format::replace_with(false, - format::Pos::from(tokAt(scanner,(yylsp[-8]))), - format::get_substring(tokRangeAt(scanner,(yylsp[-7]),(yylsp[-2]))), - format::Pos::from(tokAt(scanner,(yylsp[-1]))), " ", "("); - - if ( (yyvsp[-1].pExpression)->rtti_isTypeDecl() ) { - auto ptd = (ExprTypeDecl *)(yyvsp[-1].pExpression); - (yyval.pExpression) = new ExprTypeInfo(tokAt(scanner,(yylsp[-9])),*(yyvsp[-7].s),ptd->typeexpr,*(yyvsp[-5].s),*(yyvsp[-3].s)); - delete (yyvsp[-1].pExpression); - } else { - (yyval.pExpression) = new ExprTypeInfo(tokAt(scanner,(yylsp[-9])),*(yyvsp[-7].s),(yyvsp[-1].pExpression),*(yyvsp[-5].s),*(yyvsp[-3].s)); - } - delete (yyvsp[-7].s); - delete (yyvsp[-5].s); - delete (yyvsp[-3].s); - } - break; - - case 404: /* expr_type_info: "typeinfo" name_in_namespace '(' expr ')' */ - { - if ( (yyvsp[-1].pExpression)->rtti_isTypeDecl() ) { - auto ptd = (ExprTypeDecl *)(yyvsp[-1].pExpression); - (yyval.pExpression) = new ExprTypeInfo(tokAt(scanner,(yylsp[-4])),*(yyvsp[-3].s),ptd->typeexpr); - delete (yyvsp[-1].pExpression); - } else { - (yyval.pExpression) = new ExprTypeInfo(tokAt(scanner,(yylsp[-4])),*(yyvsp[-3].s),(yyvsp[-1].pExpression)); - } - delete (yyvsp[-3].s); - } - break; - - case 405: /* expr_type_info: "typeinfo" name_in_namespace '<' "name" '>' '(' expr ')' */ - { - if ( (yyvsp[-1].pExpression)->rtti_isTypeDecl() ) { - auto ptd = (ExprTypeDecl *)(yyvsp[-1].pExpression); - (yyval.pExpression) = new ExprTypeInfo(tokAt(scanner,(yylsp[-7])),*(yyvsp[-6].s),ptd->typeexpr,*(yyvsp[-4].s)); - delete (yyvsp[-1].pExpression); - } else { - (yyval.pExpression) = new ExprTypeInfo(tokAt(scanner,(yylsp[-7])),*(yyvsp[-6].s),(yyvsp[-1].pExpression),*(yyvsp[-4].s)); - } - delete (yyvsp[-6].s); - delete (yyvsp[-4].s); - } - break; - - case 406: /* expr_type_info: "typeinfo" name_in_namespace '<' "name" semicolon "name" '>' '(' expr ')' */ - { - if ( (yyvsp[-1].pExpression)->rtti_isTypeDecl() ) { - auto ptd = (ExprTypeDecl *)(yyvsp[-1].pExpression); - (yyval.pExpression) = new ExprTypeInfo(tokAt(scanner,(yylsp[-9])),*(yyvsp[-8].s),ptd->typeexpr,*(yyvsp[-6].s),*(yyvsp[-4].s)); - delete (yyvsp[-1].pExpression); - } else { - (yyval.pExpression) = new ExprTypeInfo(tokAt(scanner,(yylsp[-9])),*(yyvsp[-8].s),(yyvsp[-1].pExpression),*(yyvsp[-6].s),*(yyvsp[-4].s)); - } - delete (yyvsp[-8].s); - delete (yyvsp[-6].s); - delete (yyvsp[-4].s); - } - break; - - case 407: /* expr_list: expr2 */ - { - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 408: /* expr_list: expr_list ',' expr2 */ - { - (yyval.pExpression) = new ExprSequence(tokAt(scanner,(yylsp[-2])),(yyvsp[-2].pExpression),(yyvsp[0].pExpression)); - } - break; - - case 409: /* block_or_simple_block: expression_block */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 410: /* block_or_simple_block: "=>" expr */ - { - auto retE = new ExprReturn(tokAt(scanner,(yylsp[-1])), (yyvsp[0].pExpression)); - auto blkE = new ExprBlock(); - blkE->at = tokAt(scanner,(yylsp[-1])); - blkE->list.push_back(retE); - (yyval.pExpression) = blkE; - } - break; - - case 411: /* block_or_simple_block: "=>" "<-" expr */ - { - auto retE = new ExprReturn(tokAt(scanner,(yylsp[-2])), (yyvsp[0].pExpression)); - retE->moveSemantics = true; - auto blkE = new ExprBlock(); - blkE->at = tokAt(scanner,(yylsp[-2])); - blkE->list.push_back(retE); - (yyval.pExpression) = blkE; - } - break; - - case 412: /* block_or_lambda: '$' */ - { (yyval.i) = 0; /* block */ } - break; - - case 413: /* block_or_lambda: '@' */ - { (yyval.i) = 1; /* lambda */ } - break; - - case 414: /* block_or_lambda: '@' '@' */ - { (yyval.i) = 2; /* local function */ } - break; - - case 415: /* capture_entry: '&' "name" */ - { (yyval.pCapt) = new CaptureEntry(*(yyvsp[0].s),CaptureMode::capture_by_reference); delete (yyvsp[0].s); } - break; - - case 416: /* capture_entry: '=' "name" */ - { (yyval.pCapt) = new CaptureEntry(*(yyvsp[0].s),CaptureMode::capture_by_copy); delete (yyvsp[0].s); } - break; - - case 417: /* capture_entry: "<-" "name" */ - { (yyval.pCapt) = new CaptureEntry(*(yyvsp[0].s),CaptureMode::capture_by_move); delete (yyvsp[0].s); } - break; - - case 418: /* capture_entry: ":=" "name" */ - { (yyval.pCapt) = new CaptureEntry(*(yyvsp[0].s),CaptureMode::capture_by_clone); delete (yyvsp[0].s); } - break; - - case 419: /* capture_entry: "name" '(' "name" ')' */ - { (yyval.pCapt) = ast_makeCaptureEntry(scanner,tokAt(scanner,(yylsp[-3])),*(yyvsp[-3].s),*(yyvsp[-1].s)); delete (yyvsp[-3].s); delete (yyvsp[-1].s); } - break; - - case 420: /* capture_list: capture_entry */ - { - (yyval.pCaptList) = new vector(); - (yyval.pCaptList)->push_back(*(yyvsp[0].pCapt)); - delete (yyvsp[0].pCapt); - } - break; - - case 421: /* capture_list: capture_list ',' capture_entry */ - { - (yyvsp[-2].pCaptList)->push_back(*(yyvsp[0].pCapt)); - delete (yyvsp[0].pCapt); - (yyval.pCaptList) = (yyvsp[-2].pCaptList); - } - break; - - case 422: /* optional_capture_list: %empty */ - { (yyval.pCaptList) = nullptr; } - break; - - case 423: /* optional_capture_list: "[[" capture_list ']' ']' */ - { - if (format::prepare_rule(format::Pos::from(tokAt(scanner, (yylsp[-3]))))) { - format::get_writer() - << "capture(" - << format::substring_between(tokAt(scanner, (yylsp[-3])), tokAt(scanner, (yylsp[-2]))) - << format::get_substring(tokAt(scanner, (yylsp[-2]))) - << format::substring_between(tokAt(scanner, (yylsp[-2])), tokAt(scanner, (yylsp[-1]))) - << ")"; - format::finish_rule(format::Pos::from_last(tokAt(scanner, (yylsp[0])))); - } - - ; (yyval.pCaptList) = (yyvsp[-2].pCaptList); - } - break; - - case 424: /* optional_capture_list: "capture" '(' capture_list ')' */ - { (yyval.pCaptList) = (yyvsp[-1].pCaptList); } - break; - - case 425: /* expr_block: expression_block */ - { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, (yylsp[0]))))) { - format::get_writer() << "$() "; - format::finish_rule(format::Pos::from(tokAt(scanner, (yylsp[0])))); - } - - ExprBlock * closure = (ExprBlock *) (yyvsp[0].pExpression); - (yyval.pExpression) = new ExprMakeBlock(tokAt(scanner,(yylsp[0])),(yyvsp[0].pExpression)); - closure->returnType = new TypeDecl(Type::autoinfer); - } - break; - - case 426: /* expr_block: block_or_lambda optional_annotation_list optional_capture_list optional_function_argument_list optional_function_type block_or_simple_block */ - { - (yyval.pExpression) = ast_makeBlock(scanner,(yyvsp[-5].i),(yyvsp[-4].faList),(yyvsp[-3].pCaptList),(yyvsp[-2].pVarDeclList),(yyvsp[-1].pTypeDecl),(yyvsp[0].pExpression),tokAt(scanner,(yylsp[0])),tokAt(scanner,(yylsp[-4])),tokAt(scanner,(yylsp[-3]))); - } - break; - - case 427: /* expr_full_block: block_or_lambda optional_annotation_list optional_capture_list optional_function_argument_list optional_function_type block_or_simple_block */ - { - (yyval.pExpression) = ast_makeBlock(scanner,(yyvsp[-5].i),(yyvsp[-4].faList),(yyvsp[-3].pCaptList),(yyvsp[-2].pVarDeclList),(yyvsp[-1].pTypeDecl),(yyvsp[0].pExpression),tokAt(scanner,(yylsp[0])),tokAt(scanner,(yylsp[-4])),tokAt(scanner,(yylsp[-3]))); - } - break; - - case 428: /* $@24: %empty */ - { yyextra->das_need_oxford_comma = false; } - break; - - case 429: /* expr_full_block_assumed_piped: block_or_lambda $@24 optional_annotation_list optional_capture_list optional_function_argument_list optional_function_type expression_block */ - { - (yyval.pExpression) = ast_makeBlock(scanner,(yyvsp[-6].i),(yyvsp[-4].faList),(yyvsp[-3].pCaptList),(yyvsp[-2].pVarDeclList),(yyvsp[-1].pTypeDecl),(yyvsp[0].pExpression),tokAt(scanner,(yylsp[0])),tokAt(scanner,(yylsp[-4])),tokAt(scanner,(yylsp[-3]))); - } - break; - - case 430: /* expr_numeric_const: "integer constant" */ - { (yyval.pExpression) = new ExprConstInt(tokAt(scanner,(yylsp[0])),(int32_t)(yyvsp[0].i)); } - break; - - case 431: /* expr_numeric_const: "unsigned integer constant" */ - { (yyval.pExpression) = new ExprConstUInt(tokAt(scanner,(yylsp[0])),(uint32_t)(yyvsp[0].ui)); } - break; - - case 432: /* expr_numeric_const: "long integer constant" */ - { (yyval.pExpression) = new ExprConstInt64(tokAt(scanner,(yylsp[0])),(int64_t)(yyvsp[0].i64)); } - break; - - case 433: /* expr_numeric_const: "unsigned long integer constant" */ - { (yyval.pExpression) = new ExprConstUInt64(tokAt(scanner,(yylsp[0])),(uint64_t)(yyvsp[0].ui64)); } - break; - - case 434: /* expr_numeric_const: "unsigned int8 constant" */ - { (yyval.pExpression) = new ExprConstUInt8(tokAt(scanner,(yylsp[0])),(uint8_t)(yyvsp[0].ui)); } - break; - - case 435: /* expr_numeric_const: "floating point constant" */ - { (yyval.pExpression) = new ExprConstFloat(tokAt(scanner,(yylsp[0])),(float)(yyvsp[0].fd)); } - break; - - case 436: /* expr_numeric_const: "float16 constant" */ - { (yyval.pExpression) = new ExprConstFloat16(tokAt(scanner,(yylsp[0])),(float)(yyvsp[0].fd)); } - break; - - case 437: /* expr_numeric_const: "double constant" */ - { (yyval.pExpression) = new ExprConstDouble(tokAt(scanner,(yylsp[0])),(double)(yyvsp[0].d)); } - break; - - case 438: /* expr_assign: expr */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 439: /* expr_assign: expr '=' expr */ - { (yyval.pExpression) = new ExprCopy(tokAt(scanner,(yylsp[-1])),(yyvsp[-2].pExpression),(yyvsp[0].pExpression)); } - break; - - case 440: /* expr_assign: expr "<-" expr */ - { (yyval.pExpression) = new ExprMove(tokAt(scanner,(yylsp[-1])),(yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 441: /* expr_assign: expr ":=" expr */ - { (yyval.pExpression) = new ExprClone(tokAt(scanner,(yylsp[-1])),(yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 442: /* expr_assign: expr "&=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"&=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 443: /* expr_assign: expr "|=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"|=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 444: /* expr_assign: expr "^=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"^=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 445: /* expr_assign: expr "&&=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"&&=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 446: /* expr_assign: expr "||=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"||=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 447: /* expr_assign: expr "^^=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"^^=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 448: /* expr_assign: expr "+=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"+=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 449: /* expr_assign: expr "-=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"-=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 450: /* expr_assign: expr "*=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"*=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 451: /* expr_assign: expr "/=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"/=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 452: /* expr_assign: expr "%=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"%=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 453: /* expr_assign: expr "<<=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"<<=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 454: /* expr_assign: expr ">>=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),">>=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 455: /* expr_assign: expr "<<<=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"<<<=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 456: /* expr_assign: expr ">>>=" expr */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),">>>=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 457: /* expr_assign_pipe_right: "@ <|" expr_block */ - { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, (yylsp[-1]))))) { - auto tok = tokAt(scanner, (yylsp[0])); - tok.column += 1; - format::get_writer() << "@" << format::get_substring(tok) << ";"; - format::finish_rule(format::Pos::from_last(tok)); - } - - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 458: /* expr_assign_pipe_right: "@@ <|" expr_block */ - { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, (yylsp[-1]))))) { - auto tok = tokAt(scanner, (yylsp[0])); - tok.column += 1; - format::get_writer() << "@@" << format::get_substring(tok) << ";"; - format::finish_rule(format::Pos::from_last(tok)); - } - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 459: /* expr_assign_pipe_right: "$ <|" expr_block */ - { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, (yylsp[-1]))))) { - auto tok = tokAt(scanner, (yylsp[0])); - tok.column += 1; - format::get_writer() << "$" << format::get_substring(tok) << ";"; - format::finish_rule(format::Pos::from_last(tok)); - } - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 460: /* expr_assign_pipe_right: expr_call_pipe */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 461: /* expr_assign_pipe: expr '=' expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprCopy(tokAt(scanner,(yylsp[-1])),(yyvsp[-2].pExpression),(yyvsp[0].pExpression)); } - break; - - case 462: /* expr_assign_pipe: expr "<-" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprMove(tokAt(scanner,(yylsp[-1])),(yyvsp[-2].pExpression),(yyvsp[0].pExpression)); } - break; - - case 463: /* expr_assign_pipe: expr "&=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"&=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 464: /* expr_assign_pipe: expr "|=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"|=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 465: /* expr_assign_pipe: expr "^=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"^=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 466: /* expr_assign_pipe: expr "&&=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"&&=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 467: /* expr_assign_pipe: expr "||=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"||=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 468: /* expr_assign_pipe: expr "^^=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"^^=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 469: /* expr_assign_pipe: expr "+=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"+=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 470: /* expr_assign_pipe: expr "-=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"-=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 471: /* expr_assign_pipe: expr "*=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"*=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 472: /* expr_assign_pipe: expr "/=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"/=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 473: /* expr_assign_pipe: expr "%=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"%=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 474: /* expr_assign_pipe: expr "<<=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"<<=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 475: /* expr_assign_pipe: expr ">>=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),">>=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 476: /* expr_assign_pipe: expr "<<<=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),"<<<=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 477: /* expr_assign_pipe: expr ">>>=" expr_assign_pipe_right */ - { (yyval.pExpression) = new ExprOp2(tokAt(scanner,(yylsp[-1])),">>>=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 478: /* expr_named_call: name_in_namespace '(' '[' make_struct_fields ']' ')' */ - { - auto nc = new ExprNamedCall(tokAt(scanner,(yylsp[-5])),*(yyvsp[-5].s)); - nc->arguments = (yyvsp[-2].pMakeStruct); - delete (yyvsp[-5].s); - (yyval.pExpression) = nc; - } - break; - - case 479: /* expr_named_call: name_in_namespace '(' expr_list ',' '[' make_struct_fields ']' ')' */ - { - auto nc = new ExprNamedCall(tokAt(scanner,(yylsp[-7])),*(yyvsp[-7].s)); - nc->nonNamedArguments = sequenceToList((yyvsp[-5].pExpression)); - nc->arguments = (yyvsp[-2].pMakeStruct); - delete (yyvsp[-7].s); - (yyval.pExpression) = nc; - } - break; - - case 480: /* expr_method_call: expr2 "->" "name" '(' ')' */ - { - auto pInvoke = makeInvokeMethod(tokAt(scanner,(yylsp[-3])), (yyvsp[-4].pExpression), *(yyvsp[-2].s)); - delete (yyvsp[-2].s); - (yyval.pExpression) = pInvoke; - } - break; - - case 481: /* expr_method_call: expr2 "->" "name" '(' expr_list ')' */ - { - auto pInvoke = makeInvokeMethod(tokAt(scanner,(yylsp[-4])), (yyvsp[-5].pExpression), *(yyvsp[-3].s)); - auto callArgs = sequenceToList((yyvsp[-1].pExpression)); - pInvoke->arguments.insert ( pInvoke->arguments.end(), callArgs.begin(), callArgs.end() ); - delete (yyvsp[-3].s); - (yyval.pExpression) = pInvoke; - } - break; - - case 482: /* func_addr_name: name_in_namespace */ - { - (yyval.pExpression) = new ExprAddr(tokAt(scanner,(yylsp[0])),*(yyvsp[0].s)); - delete (yyvsp[0].s); - } - break; - - case 483: /* func_addr_name: "$i" '(' expr2 ')' */ - { - auto expr = new ExprAddr(tokAt(scanner,(yylsp[-3])),"``MACRO``TAG``ADDR``"); - (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression), expr, "i"); - } - break; - - case 484: /* func_addr_expr: '@' '@' func_addr_name */ - { - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 485: /* $@25: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 486: /* $@26: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 487: /* func_addr_expr: '@' '@' '<' $@25 type_declaration_no_options '>' $@26 func_addr_name */ - { - auto expr = (ExprAddr *) ((yyvsp[0].pExpression)->rtti_isAddr() ? (yyvsp[0].pExpression) : (((ExprTag *) (yyvsp[0].pExpression))->value)); - expr->funcType = (yyvsp[-3].pTypeDecl); - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 488: /* $@27: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 489: /* $@28: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 490: /* func_addr_expr: '@' '@' '<' $@27 optional_function_argument_list optional_function_type '>' $@28 func_addr_name */ - { - auto expr = (ExprAddr *) ((yyvsp[0].pExpression)->rtti_isAddr() ? (yyvsp[0].pExpression) : (((ExprTag *) (yyvsp[0].pExpression))->value)); - expr->funcType = new TypeDecl(Type::tFunction); - expr->funcType->firstType = (yyvsp[-3].pTypeDecl); - if ( (yyvsp[-4].pVarDeclList) ) { - varDeclToTypeDecl(scanner, expr->funcType, (yyvsp[-4].pVarDeclList)); - deleteVariableDeclarationList((yyvsp[-4].pVarDeclList)); - } - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 491: /* expr_field: expr2 '.' "name" */ - { - (yyval.pExpression) = new ExprField(tokAt(scanner,(yylsp[-1])), tokAt(scanner,(yylsp[0])), (yyvsp[-2].pExpression), *(yyvsp[0].s)); - delete (yyvsp[0].s); - } - break; - - case 492: /* expr_field: expr2 '.' '.' "name" */ - { - (yyval.pExpression) = new ExprField(tokAt(scanner,(yylsp[-1])), tokAt(scanner,(yylsp[0])), (yyvsp[-3].pExpression), *(yyvsp[0].s), true); - delete (yyvsp[0].s); - } - break; - - case 493: /* expr_field: expr2 '.' "name" '(' ')' */ - { - auto pInvoke = makeInvokeMethod(tokAt(scanner,(yylsp[-3])), (yyvsp[-4].pExpression), *(yyvsp[-2].s)); - delete (yyvsp[-2].s); - (yyval.pExpression) = pInvoke; - } - break; - - case 494: /* expr_field: expr2 '.' "name" '(' expr_list ')' */ - { - auto pInvoke = makeInvokeMethod(tokAt(scanner,(yylsp[-4])), (yyvsp[-5].pExpression), *(yyvsp[-3].s)); - auto callArgs = sequenceToList((yyvsp[-1].pExpression)); - pInvoke->arguments.insert ( pInvoke->arguments.end(), callArgs.begin(), callArgs.end() ); - delete (yyvsp[-3].s); - (yyval.pExpression) = pInvoke; - } - break; - - case 495: /* expr_field: expr2 '.' "name" '(' '[' make_struct_fields ']' ')' */ - { - auto nc = new ExprNamedCall(tokAt(scanner,(yylsp[-5])),*(yyvsp[-5].s)); - nc->methodCall = true; - nc->arguments = (yyvsp[-2].pMakeStruct); - nc->nonNamedArguments.push_back((yyvsp[-7].pExpression)); - delete (yyvsp[-5].s); - (yyval.pExpression) = nc; - } - break; - - case 496: /* expr_field: expr2 '.' basic_type_declaration '(' ')' */ - { - auto method_name = das_to_string((yyvsp[-2].type)); - auto pInvoke = makeInvokeMethod(tokAt(scanner,(yylsp[-3])), (yyvsp[-4].pExpression), method_name); - (yyval.pExpression) = pInvoke; - } - break; - - case 497: /* expr_field: expr2 '.' basic_type_declaration '(' expr_list ')' */ - { - auto method_name = das_to_string((yyvsp[-3].type)); - auto pInvoke = makeInvokeMethod(tokAt(scanner,(yylsp[-4])), (yyvsp[-5].pExpression), method_name); - auto callArgs = sequenceToList((yyvsp[-1].pExpression)); - pInvoke->arguments.insert ( pInvoke->arguments.end(), callArgs.begin(), callArgs.end() ); - (yyval.pExpression) = pInvoke; - } - break; - - case 498: /* $@29: %empty */ - { yyextra->das_suppress_errors=true; } - break; - - case 499: /* $@30: %empty */ - { yyextra->das_suppress_errors=false; } - break; - - case 500: /* expr_field: expr2 '.' $@29 error $@30 */ - { - (yyval.pExpression) = new ExprField(tokAt(scanner,(yylsp[-3])), tokAt(scanner,(yylsp[-3])), (yyvsp[-4].pExpression), ""); - yyerrok; - } - break; - - case 501: /* expr_call: name_in_namespace '(' ')' */ - { - (yyval.pExpression) = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-2])),tokAt(scanner,(yylsp[0])),*(yyvsp[-2].s)); - delete (yyvsp[-2].s); - } - break; - - case 502: /* expr_call: name_in_namespace '(' "uninitialized" ')' */ - { - auto dd = new ExprMakeStruct(tokAt(scanner,(yylsp[-3]))); - dd->at = tokAt(scanner,(yylsp[-3])); - dd->makeType = new TypeDecl(Type::alias); - dd->makeType->alias = *(yyvsp[-3].s); - dd->useInitializer = false; - dd->alwaysUseInitializer = true; - delete (yyvsp[-3].s); - (yyval.pExpression) = dd; - } - break; - - case 503: /* expr_call: name_in_namespace '(' make_struct_single ')' */ - { - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->at = tokAt(scanner,(yylsp[-3])); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->makeType = new TypeDecl(Type::alias); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->makeType->alias = *(yyvsp[-3].s); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->useInitializer = true; - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->alwaysUseInitializer = true; - delete (yyvsp[-3].s); - (yyval.pExpression) = (yyvsp[-1].pExpression); - } - break; - - case 504: /* expr_call: name_in_namespace '(' "uninitialized" make_struct_single ')' */ - { - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->at = tokAt(scanner,(yylsp[-4])); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->makeType = new TypeDecl(Type::alias); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->makeType->alias = *(yyvsp[-4].s); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->useInitializer = false; - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->alwaysUseInitializer = true; - delete (yyvsp[-4].s); - (yyval.pExpression) = (yyvsp[-1].pExpression); - } - break; - - case 505: /* expr_call: name_in_namespace '(' expr_list ')' */ - { - (yyval.pExpression) = parseFunctionArguments(yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-3])),tokAt(scanner,(yylsp[0])),*(yyvsp[-3].s)),(yyvsp[-1].pExpression)); - delete (yyvsp[-3].s); - } - break; - - case 506: /* expr_call: basic_type_declaration '(' ')' */ - { - (yyval.pExpression) = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-2])),tokAt(scanner,(yylsp[0])),das_to_string((yyvsp[-2].type))); - } - break; - - case 507: /* expr_call: basic_type_declaration '(' expr_list ')' */ - { - (yyval.pExpression) = parseFunctionArguments(yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-3])),tokAt(scanner,(yylsp[0])),das_to_string((yyvsp[-3].type))),(yyvsp[-1].pExpression)); - } - break; - - case 508: /* expr2: name_in_namespace */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprVar(tokAt(scanner,(yylsp[0])),*(yyvsp[0].s)); delete (yyvsp[0].s); } - break; - - case 509: /* expr2: expr_field */ - { need_wrap_current_expr = true; (yyvsp[0].pExpression)->at = tokAt(scanner,(yylsp[0])); (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 510: /* expr2: expr_mtag */ - { need_wrap_current_expr = true; (yyvsp[0].pExpression)->at = tokAt(scanner,(yylsp[0])); (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 511: /* expr2: '!' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp1(tokRangeAt(scanner,(yylsp[-1]), (yylsp[0])),"!",(yyvsp[0].pExpression)); } - break; - - case 512: /* expr2: '~' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp1(tokRangeAt(scanner,(yylsp[-1]), (yylsp[0])),"~",(yyvsp[0].pExpression)); } - break; - - case 513: /* expr2: '+' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp1(tokRangeAt(scanner,(yylsp[-1]), (yylsp[0])),"+",(yyvsp[0].pExpression)); } - break; - - case 514: /* expr2: '-' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp1(tokRangeAt(scanner,(yylsp[-1]), (yylsp[0])),"-",(yyvsp[0].pExpression)); } - break; - - case 515: /* expr2: expr2 "<<" expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"<<", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 516: /* expr2: expr2 ">>" expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),">>", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 517: /* expr2: expr2 "<<<" expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"<<<", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 518: /* expr2: expr2 ">>>" expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),">>>", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 519: /* expr2: expr2 '+' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"+", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 520: /* expr2: expr2 '-' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"-", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 521: /* expr2: expr2 '*' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"*", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 522: /* expr2: expr2 '/' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"/", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 523: /* expr2: expr2 '%' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"%", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 524: /* expr2: expr2 '<' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"<", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 525: /* expr2: expr2 '>' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),">", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 526: /* expr2: expr2 "==" expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"==", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 527: /* expr2: expr2 "!=" expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"!=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 528: /* expr2: expr2 "<=" expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"<=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 529: /* expr2: expr2 ">=" expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),">=", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 530: /* expr2: expr2 '&' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"&", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 531: /* expr2: expr2 '|' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"|", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 532: /* expr2: expr2 '^' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"^", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 533: /* expr2: expr2 "&&" expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"&&", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 534: /* expr2: expr2 "||" expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"||", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 535: /* expr2: expr2 "^^" expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp2(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),"^^", (yyvsp[-2].pExpression), (yyvsp[0].pExpression)); } - break; - - case 536: /* expr2: expr2 ".." expr2 */ - { - need_wrap_current_expr = true; - auto itv = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-1])),"interval"); - itv->arguments.push_back((yyvsp[-2].pExpression)); - itv->arguments.push_back((yyvsp[0].pExpression)); - (yyval.pExpression) = itv; - } - break; - - case 537: /* expr2: "++" expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp1(tokRangeAt(scanner,(yylsp[-1]), (yylsp[0])),"++", (yyvsp[0].pExpression)); } - break; - - case 538: /* expr2: "--" expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp1(tokRangeAt(scanner,(yylsp[-1]), (yylsp[0])),"--", (yyvsp[0].pExpression)); } - break; - - case 539: /* expr2: expr2 "++" */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp1(tokRangeAt(scanner,(yylsp[-1]), (yylsp[0])),"+++", (yyvsp[-1].pExpression)); } - break; - - case 540: /* expr2: expr2 "--" */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp1(tokRangeAt(scanner,(yylsp[-1]), (yylsp[0])),"---", (yyvsp[-1].pExpression)); } - break; - - case 541: /* expr2: expr2 '[' expr2 ']' */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprAt(tokRangeAt(scanner,(yylsp[-3]), (yylsp[0])), (yyvsp[-3].pExpression), (yyvsp[-1].pExpression)); } - break; - - case 542: /* expr2: expr2 '.' '[' expr2 ']' */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprAt(tokRangeAt(scanner,(yylsp[-4]), (yylsp[0])), (yyvsp[-4].pExpression), (yyvsp[-1].pExpression), true); } - break; - - case 543: /* expr2: expr2 "?[" expr2 ']' */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprSafeAt(tokRangeAt(scanner,(yylsp[-3]), (yylsp[0])), (yyvsp[-3].pExpression), (yyvsp[-1].pExpression)); } - break; - - case 544: /* expr2: expr2 '.' "?[" expr2 ']' */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprSafeAt(tokRangeAt(scanner,(yylsp[-4]), (yylsp[0])), (yyvsp[-4].pExpression), (yyvsp[-1].pExpression), true); } - break; - - case 545: /* expr2: expr2 "?." "name" */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprSafeField(tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])), tokAt(scanner,(yylsp[0])), (yyvsp[-2].pExpression), *(yyvsp[0].s)); delete (yyvsp[0].s); } - break; - - case 546: /* expr2: expr2 '.' "?." "name" */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprSafeField(tokRangeAt(scanner,(yylsp[-3]),(yylsp[0])), tokAt(scanner,(yylsp[0])), (yyvsp[-3].pExpression), *(yyvsp[0].s), true); delete (yyvsp[0].s); } - break; - - case 547: /* expr2: '*' expr2 */ - { need_wrap_current_expr = true; (yyval.pExpression) = new ExprPtr2Ref(tokAt(scanner,(yylsp[-1])),(yyvsp[0].pExpression)); } - break; - - case 548: /* expr2: expr2 '?' expr2 ':' expr2 */ - { - need_wrap_current_expr = true; (yyval.pExpression) = new ExprOp3(tokRangeAt(scanner,(yylsp[-4]), (yylsp[0])),"?",(yyvsp[-4].pExpression),(yyvsp[-2].pExpression),(yyvsp[0].pExpression)); - } - break; - - case 549: /* expr2: "null" */ - { (yyval.pExpression) = new ExprConstPtr(tokAt(scanner,(yylsp[0])),nullptr); } - break; - - case 550: /* expr2: expr_numeric_const */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 551: /* expr2: expr_reader */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 552: /* expr2: string_builder */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 553: /* expr2: make_decl */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 554: /* expr2: "true" */ - { (yyval.pExpression) = new ExprConstBool(tokAt(scanner,(yylsp[0])),true); } - break; - - case 555: /* expr2: "false" */ - { (yyval.pExpression) = new ExprConstBool(tokAt(scanner,(yylsp[0])),false); } - break; - - case 556: /* expr2: '(' expr_list optional_comma ')' */ - { - if ( (yyvsp[-2].pExpression)->rtti_isSequence() ) { - auto mkt = new ExprMakeTuple(tokAt(scanner,(yylsp[-2]))); - mkt->values = sequenceToList((yyvsp[-2].pExpression)); - mkt->shorthandRecordNames = ast_tupleCollectShorthandNames(mkt->values); - (yyval.pExpression) = mkt; - } else if ( (yyvsp[-1].b) ) { - auto mkt = new ExprMakeTuple(tokAt(scanner,(yylsp[-2]))); - mkt->values.push_back((yyvsp[-2].pExpression)); - mkt->shorthandRecordNames = ast_tupleCollectShorthandNames(mkt->values); - (yyval.pExpression) = mkt; - } else { - (yyvsp[-2].pExpression)->at = tokAt(scanner, (yylsp[-2])); - (yyval.pExpression) = (yyvsp[-2].pExpression); - } - } - break; - - case 557: /* expr2: func_addr_expr */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 558: /* expr2: expr_call */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 559: /* expr2: "deref" '(' expr2 ')' */ - { (yyval.pExpression) = new ExprPtr2Ref(tokAt(scanner,(yylsp[-3])),(yyvsp[-1].pExpression)); } - break; - - case 560: /* expr2: "addr" '(' expr2 ')' */ - { (yyval.pExpression) = new ExprRef2Ptr(tokAt(scanner,(yylsp[-3])),(yyvsp[-1].pExpression)); } - break; - - case 561: /* expr2: "generator" '<' type_declaration_no_options '>' optional_capture_list '(' ')' */ - { - (yyval.pExpression) = ast_makeGenerator(scanner,(yyvsp[-4].pTypeDecl),(yyvsp[-2].pCaptList),nullptr,tokAt(scanner,(yylsp[-6])),tokAt(scanner,(yylsp[-2]))); - } - break; - - case 562: /* expr2: "generator" '<' type_declaration_no_options '>' optional_capture_list '(' expr2 ')' */ - { - (yyval.pExpression) = ast_makeGenerator(scanner,(yyvsp[-5].pTypeDecl),(yyvsp[-3].pCaptList),(yyvsp[-1].pExpression),tokAt(scanner,(yylsp[-7])),tokAt(scanner,(yylsp[-3]))); - } - break; - - case 563: /* expr2: expr2 "??" expr2 */ - { (yyval.pExpression) = new ExprNullCoalescing(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),(yyvsp[-2].pExpression),(yyvsp[0].pExpression)); } - break; - - case 564: /* $@31: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 565: /* $@32: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 566: /* expr2: expr2 "is" "type" '<' $@31 type_declaration_no_options '>' $@32 */ - { - (yyval.pExpression) = new ExprIs(tokRangeAt(scanner,(yylsp[-7]), (yylsp[-1])),(yyvsp[-7].pExpression),(yyvsp[-2].pTypeDecl)); - } - break; - - case 567: /* expr2: expr2 "is" basic_type_declaration */ - { - auto vdecl = new TypeDecl((yyvsp[0].type)); - vdecl->at = tokAt(scanner,(yylsp[0])); - (yyval.pExpression) = new ExprIs(tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])),(yyvsp[-2].pExpression),vdecl); - } - break; - - case 568: /* expr2: expr2 "is" "name" */ - { - (yyval.pExpression) = new ExprIsVariant(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),(yyvsp[-2].pExpression),*(yyvsp[0].s)); - delete (yyvsp[0].s); - } - break; - - case 569: /* expr2: expr2 "as" "name" */ - { - (yyval.pExpression) = new ExprAsVariant(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),(yyvsp[-2].pExpression),*(yyvsp[0].s)); - delete (yyvsp[0].s); - } - break; - - case 570: /* $@33: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 571: /* $@34: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 572: /* expr2: expr2 "as" "type" '<' $@33 type_declaration '>' $@34 */ - { - auto vname = (yyvsp[-2].pTypeDecl)->describe(); - (yyval.pExpression) = new ExprAsVariant(tokRangeAt(scanner,(yylsp[-7]), (yylsp[-1])),(yyvsp[-7].pExpression),vname); - delete (yyvsp[-2].pTypeDecl); - } - break; - - case 573: /* expr2: expr2 "as" basic_type_declaration */ - { - (yyval.pExpression) = new ExprAsVariant(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),(yyvsp[-2].pExpression),das_to_string((yyvsp[0].type))); - } - break; - - case 574: /* expr2: expr2 '?' "as" "name" */ - { - (yyval.pExpression) = new ExprSafeAsVariant(tokRangeAt(scanner,(yylsp[-3]), (yylsp[0])),(yyvsp[-3].pExpression),*(yyvsp[0].s)); - delete (yyvsp[0].s); - } - break; - - case 575: /* $@35: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 576: /* $@36: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 577: /* expr2: expr2 '?' "as" "type" '<' $@35 type_declaration '>' $@36 */ - { - auto vname = (yyvsp[-2].pTypeDecl)->describe(); - (yyval.pExpression) = new ExprSafeAsVariant(tokRangeAt(scanner,(yylsp[-8]), (yylsp[-1])),(yyvsp[-8].pExpression),vname); - delete (yyvsp[-2].pTypeDecl); - } - break; - - case 578: /* expr2: expr2 '?' "as" basic_type_declaration */ - { - (yyval.pExpression) = new ExprSafeAsVariant(tokRangeAt(scanner,(yylsp[-3]), (yylsp[0])),(yyvsp[-3].pExpression),das_to_string((yyvsp[0].type))); - } - break; - - case 579: /* expr2: expr_type_info */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 580: /* expr2: expr_type_decl */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 581: /* expr2: expr_cast */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 582: /* expr2: expr_new */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 583: /* expr2: expr_method_call */ - { (yyval.pExpression) = (yyvsp[0].pExpression); (yyval.pExpression)->at = tokAt(scanner, (yylsp[0])); } - break; - - case 584: /* expr2: expr_named_call */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 585: /* expr2: expr_full_block */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 586: /* expr2: expr2 "<|" expr2 */ - { (yyval.pExpression) = ast_lpipe(scanner,(yyvsp[-2].pExpression),(yyvsp[0].pExpression),tokRangeAt(scanner,(yylsp[-2]),(yylsp[0]))); } - break; - - case 587: /* expr2: expr2 "|>" expr2 */ - { (yyval.pExpression) = ast_rpipe(scanner,(yyvsp[-2].pExpression),(yyvsp[0].pExpression),tokRangeAt(scanner,(yylsp[-2]), (yylsp[0]))); (yyval.pExpression)->at = tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])); } - break; - - case 588: /* expr2: expr2 "|>" basic_type_declaration */ - { - auto fncall = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[0])),tokAt(scanner,(yylsp[0])),das_to_string((yyvsp[0].type))); - (yyval.pExpression) = ast_rpipe(scanner,(yyvsp[-2].pExpression),fncall,tokRangeAt(scanner,(yylsp[-2]), (yylsp[0]))); - } - break; - - case 589: /* expr2: name_in_namespace "name" */ - { - if (format::prepare_rule(format::Pos::from_last(tokAt(scanner,(yylsp[-1]))))) { - format::get_writer() << "." << format::get_substring(tokAt(scanner,(yylsp[0]))); - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - } - - (yyval.pExpression) = ast_NameName(scanner,(yyvsp[-1].s),(yyvsp[0].s),tokRangeAt(scanner,(yylsp[-1]),(yylsp[0])),tokAt(scanner,(yylsp[0]))); - } - break; - - case 590: /* expr2: "unsafe" '(' expr2 ')' */ - { - (yyvsp[-1].pExpression)->alwaysSafe = true; - (yyvsp[-1].pExpression)->userSaidItsSafe = true; - (yyval.pExpression) = (yyvsp[-1].pExpression); - } - break; - - case 591: /* expr2: expression_keyword */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 592: /* expr: expr2 */ - { - if (need_wrap_current_expr) { - format::wrap_par_expr_newline(tokAt(scanner,(yylsp[0])), (yyvsp[0].pExpression)->at); - need_wrap_current_expr = false; - } - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 593: /* expr_mtag: "$$" '(' expr2 ')' */ - { (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression),"e"); } - break; - - case 594: /* expr_mtag: "$i" '(' expr2 ')' */ - { (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression),"i"); } - break; - - case 595: /* expr_mtag: "$v" '(' expr2 ')' */ - { (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression),"v"); } - break; - - case 596: /* expr_mtag: "$b" '(' expr2 ')' */ - { (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression),"b"); } - break; - - case 597: /* expr_mtag: "$a" '(' expr2 ')' */ - { (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression),"a"); } - break; - - case 598: /* expr_mtag: "..." */ - { (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[0])),nullptr,"..."); } - break; - - case 599: /* expr_mtag: "$c" '(' expr2 ')' '(' ')' */ - { - auto ccall = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-5])),tokAt(scanner,(yylsp[0])),"``MACRO``TAG``CALL``"); - (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-5])),(yyvsp[-3].pExpression),ccall,"c"); - } - break; - - case 600: /* expr_mtag: "$c" '(' expr2 ')' '(' expr_list ')' */ - { - auto ccall = parseFunctionArguments(yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-6])),tokAt(scanner,(yylsp[0])),"``MACRO``TAG``CALL``"),(yyvsp[-1].pExpression)); - (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-6])),(yyvsp[-4].pExpression),ccall,"c"); - } - break; - - case 601: /* expr_mtag: expr2 '.' "$f" '(' expr2 ')' */ - { - auto cfield = new ExprField(tokAt(scanner,(yylsp[-4])), tokAt(scanner,(yylsp[-1])), (yyvsp[-5].pExpression), "``MACRO``TAG``FIELD``"); - (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression),cfield,"f"); - } - break; - - case 602: /* expr_mtag: expr2 "?." "$f" '(' expr2 ')' */ - { - auto cfield = new ExprSafeField(tokAt(scanner,(yylsp[-4])), tokAt(scanner,(yylsp[-1])), (yyvsp[-5].pExpression), "``MACRO``TAG``FIELD``"); - (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression),cfield,"f"); - } - break; - - case 603: /* expr_mtag: expr2 '.' '.' "$f" '(' expr2 ')' */ - { - auto cfield = new ExprField(tokAt(scanner,(yylsp[-4])), tokAt(scanner,(yylsp[-1])), (yyvsp[-6].pExpression), "``MACRO``TAG``FIELD``", true); - (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression),cfield,"f"); - } - break; - - case 604: /* expr_mtag: expr2 '.' "?." "$f" '(' expr2 ')' */ - { - auto cfield = new ExprSafeField(tokAt(scanner,(yylsp[-4])), tokAt(scanner,(yylsp[-1])), (yyvsp[-6].pExpression), "``MACRO``TAG``FIELD``", true); - (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression),cfield,"f"); - } - break; - - case 605: /* expr_mtag: expr2 "as" "$f" '(' expr2 ')' */ - { - auto cfield = new ExprAsVariant(tokAt(scanner,(yylsp[-4])),(yyvsp[-5].pExpression),"``MACRO``TAG``FIELD``"); - (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression),cfield,"f"); - } - break; - - case 606: /* expr_mtag: expr2 '?' "as" "$f" '(' expr2 ')' */ - { - auto cfield = new ExprSafeAsVariant(tokAt(scanner,(yylsp[-4])),(yyvsp[-6].pExpression),"``MACRO``TAG``FIELD``"); - (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression),cfield,"f"); - } - break; - - case 607: /* expr_mtag: expr2 "is" "$f" '(' expr2 ')' */ - { - auto cfield = new ExprIsVariant(tokAt(scanner,(yylsp[-4])),(yyvsp[-5].pExpression),"``MACRO``TAG``FIELD``"); - (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression),cfield,"f"); - } - break; - - case 608: /* expr_mtag: '@' '@' "$c" '(' expr2 ')' */ - { - auto ccall = new ExprAddr(tokAt(scanner,(yylsp[-4])),"``MACRO``TAG``ADDR``"); - (yyval.pExpression) = new ExprTag(tokAt(scanner,(yylsp[-3])),(yyvsp[-1].pExpression),ccall,"c"); - } - break; - - case 609: /* optional_field_annotation: %empty */ - { (yyval.aaList) = nullptr; } - break; - - case 610: /* optional_field_annotation: "[[" annotation_argument_list ']' ']' */ - { - if (format::prepare_rule(format::Pos::from(tokAt(scanner, (yylsp[-3]))))) { - for (const auto &arg: *(yyvsp[-2].aaList)) { - format::get_writer() << "@" << format::get_substring(arg.at); - } - format::finish_rule(format::Pos::from_last(tokAt(scanner, (yylsp[0])))); - } - (yyval.aaList) = (yyvsp[-2].aaList); /*this one is gone when BRABRA is disabled*/ - } - break; - - case 611: /* optional_field_annotation: metadata_argument_list */ - { (yyval.aaList) = (yyvsp[0].aaList); } - break; - - case 612: /* optional_override: %empty */ - { (yyval.i) = OVERRIDE_NONE; } - break; - - case 613: /* optional_override: "override" */ - { (yyval.i) = OVERRIDE_OVERRIDE; } - break; - - case 614: /* optional_override: "sealed" */ - { (yyval.i) = OVERRIDE_SEALED; } - break; - - case 615: /* optional_constant: %empty */ - { (yyval.b) = false; } - break; - - case 616: /* optional_constant: "const" */ - { (yyval.b) = true; } - break; - - case 617: /* optional_public_or_private_member_variable: %empty */ - { (yyval.b) = false; } - break; - - case 618: /* optional_public_or_private_member_variable: "public" */ - { (yyval.b) = false; } - break; - - case 619: /* optional_public_or_private_member_variable: "private" */ - { (yyval.b) = true; } - break; - - case 620: /* optional_static_member_variable: %empty */ - { (yyval.b) = false; } - break; - - case 621: /* optional_static_member_variable: "static" */ - { (yyval.b) = true; } - break; - - case 622: /* structure_variable_declaration: optional_field_annotation optional_static_member_variable optional_override optional_public_or_private_member_variable variable_declaration */ - { - (yyvsp[0].pVarDecl)->override = (yyvsp[-2].i) == OVERRIDE_OVERRIDE; - (yyvsp[0].pVarDecl)->sealed = (yyvsp[-2].i) == OVERRIDE_SEALED; - (yyvsp[0].pVarDecl)->annotation = (yyvsp[-4].aaList); - (yyvsp[0].pVarDecl)->isPrivate = (yyvsp[-1].b); - (yyvsp[0].pVarDecl)->isStatic = (yyvsp[-3].b); - (yyval.pVarDecl) = (yyvsp[0].pVarDecl); - } - break; - - case 623: /* opt_sem: SEMICOLON */ - { (yyval.b) = false; } - break; - - case 624: /* opt_sem: "end of expression" */ - { (yyval.b) = true; } - break; - - case 625: /* opt_sem: "end of expression" SEMICOLON */ - { (yyval.b) = true; } - break; - - case 626: /* opt_sem: %empty */ - {(yyval.b) = false; } - break; - - case 627: /* struct_variable_declaration_list: %empty */ - { - (yyval.pVarDeclList) = new vector(); - } - break; - - case 628: /* $@37: %empty */ - { yyextra->das_force_oxford_comma=true;} - break; - - case 629: /* struct_variable_declaration_list: struct_variable_declaration_list "typedef" $@37 "name" '=' type_declaration semicolon opt_sem */ - { - (yyval.pVarDeclList) = (yyvsp[-7].pVarDeclList); - ast_structureAlias(scanner,(yyvsp[-4].s),(yyvsp[-2].pTypeDecl),tokAt(scanner,(yylsp[-6]))); - } - break; - - case 630: /* $@38: %empty */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[0])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeStructureFields(tak); - } - } - break; - - case 631: /* struct_variable_declaration_list: struct_variable_declaration_list $@38 structure_variable_declaration semicolon opt_sem */ - { - (yyval.pVarDeclList) = (yyvsp[-4].pVarDeclList); - if ( (yyvsp[-2].pVarDecl) ) (yyvsp[-4].pVarDeclList)->push_back((yyvsp[-2].pVarDecl)); - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[-4])); - for ( auto & crd : yyextra->g_CommentReaders ) { - for ( const auto & nl : *((yyvsp[-2].pVarDecl)->pNameList) ) { - crd->afterStructureField(nl.name.c_str(), nl.at); - } - } - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterStructureFields(tak); - } - } - break; - - case 632: /* $@39: %empty */ - { - yyextra->das_force_oxford_comma=true; - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[-2])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeFunction(tak); - } - } - break; - - case 633: /* struct_variable_declaration_list: struct_variable_declaration_list optional_annotation_list "def" optional_public_or_private_member_variable "abstract" optional_constant $@39 function_declaration_header semicolon opt_sem */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[-2])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterFunction((yyvsp[-2].pFuncDecl),tak); - } - (yyvsp[-2].pFuncDecl)->isTemplate = yyextra->g_thisStructure->isTemplate; - (yyval.pVarDeclList) = ast_structVarDefAbstract(scanner,(yyvsp[-9].pVarDeclList),(yyvsp[-8].faList),(yyvsp[-6].b),(yyvsp[-4].b), (yyvsp[-2].pFuncDecl)); - } - break; - - case 634: /* $@40: %empty */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[0])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeFunction(tak); - } - } - break; - - case 635: /* struct_variable_declaration_list: struct_variable_declaration_list optional_annotation_list "def" optional_public_or_private_member_variable optional_static_member_variable optional_override optional_constant $@40 function_declaration_header expression_block opt_sem */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[-1])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterFunction((yyvsp[-2].pFuncDecl),tak); - } - (yyvsp[-2].pFuncDecl)->isTemplate = yyextra->g_thisStructure->isTemplate; - (yyval.pVarDeclList) = ast_structVarDef(scanner,(yyvsp[-10].pVarDeclList),(yyvsp[-9].faList),(yyvsp[-6].b),(yyvsp[-7].b),(yyvsp[-5].i),(yyvsp[-4].b),(yyvsp[-2].pFuncDecl),(yyvsp[-1].pExpression),tokRangeAt(scanner,(yylsp[-8]),(yylsp[-1])),tokAt(scanner,(yylsp[-9]))); - } - break; - - case 636: /* struct_variable_declaration_list: struct_variable_declaration_list '[' annotation_list ']' semicolon opt_sem */ - { - das_yyerror(scanner,"structure field or class method annotation expected to remain on the same line with the field or the class", - tokAt(scanner,(yylsp[-3])), CompilationError::syntax_error); - delete (yyvsp[-3].faList); - (yyval.pVarDeclList) = (yyvsp[-5].pVarDeclList); - } - break; - - case 637: /* function_argument_declaration_no_type: optional_field_annotation kwd_let_var_or_nothing variable_declaration_no_type */ - { - (yyval.pVarDecl) = (yyvsp[0].pVarDecl); - if ( (yyvsp[-1].b) ) { - (yyvsp[0].pVarDecl)->pTypeDecl->constant = true; - } else { - (yyvsp[0].pVarDecl)->pTypeDecl->removeConstant = true; - } - (yyvsp[0].pVarDecl)->annotation = (yyvsp[-2].aaList); - } - break; - - case 638: /* function_argument_declaration_type: optional_field_annotation kwd_let_var_or_nothing variable_declaration_type */ - { - (yyval.pVarDecl) = (yyvsp[0].pVarDecl); - if ( (yyvsp[-1].b) ) { - (yyvsp[0].pVarDecl)->pTypeDecl->constant = true; - } else { - (yyvsp[0].pVarDecl)->pTypeDecl->removeConstant = true; - } - (yyvsp[0].pVarDecl)->annotation = (yyvsp[-2].aaList); - } - break; - - case 639: /* function_argument_declaration_type: "$a" '(' expr2 ')' */ - { - auto na = new vector(); - na->push_back(VariableNameAndPosition("``MACRO``TAG``","",tokAt(scanner,(yylsp[-1])))); - auto decl = new VariableDeclaration(na, new TypeDecl(Type::none), (yyvsp[-1].pExpression)); - decl->pTypeDecl->isTag = true; - (yyval.pVarDecl) = decl; - } - break; - - case 640: /* function_argument_list: function_argument_declaration_no_type */ - { (yyval.pVarDeclList) = new vector(); (yyval.pVarDeclList)->push_back((yyvsp[0].pVarDecl)); } - break; - - case 641: /* function_argument_list: function_argument_declaration_type */ - { (yyval.pVarDeclList) = new vector(); (yyval.pVarDeclList)->push_back((yyvsp[0].pVarDecl)); } - break; - - case 642: /* function_argument_list: function_argument_declaration_no_type "end of expression" function_argument_list */ - { (yyval.pVarDeclList) = (yyvsp[0].pVarDeclList); (yyvsp[0].pVarDeclList)->insert((yyvsp[0].pVarDeclList)->begin(),(yyvsp[-2].pVarDecl)); } - break; - - case 643: /* function_argument_list: function_argument_declaration_type "end of expression" function_argument_list */ - { (yyval.pVarDeclList) = (yyvsp[0].pVarDeclList); (yyvsp[0].pVarDeclList)->insert((yyvsp[0].pVarDeclList)->begin(),(yyvsp[-2].pVarDecl)); } - break; - - case 644: /* function_argument_list: function_argument_declaration_type ',' function_argument_list */ - { (yyval.pVarDeclList) = (yyvsp[0].pVarDeclList); (yyvsp[0].pVarDeclList)->insert((yyvsp[0].pVarDeclList)->begin(),(yyvsp[-2].pVarDecl)); } - break; - - case 645: /* tuple_type: type_declaration */ - { - (yyval.pVarDecl) = new VariableDeclaration(nullptr,(yyvsp[0].pTypeDecl),nullptr); - } - break; - - case 646: /* tuple_type: "name" ':' type_declaration */ - { - auto na = new vector(); - na->push_back(VariableNameAndPosition(*(yyvsp[-2].s),"",tokAt(scanner,(yylsp[-2])))); - (yyval.pVarDecl) = new VariableDeclaration(na,(yyvsp[0].pTypeDecl),nullptr); - delete (yyvsp[-2].s); - } - break; - - case 647: /* tuple_type_list: tuple_type */ - { (yyval.pVarDeclList) = new vector(); (yyval.pVarDeclList)->push_back((yyvsp[0].pVarDecl)); } - break; - - case 648: /* tuple_type_list: tuple_type_list c_or_s tuple_type */ - { (yyval.pVarDeclList) = (yyvsp[-2].pVarDeclList); (yyvsp[-2].pVarDeclList)->push_back((yyvsp[0].pVarDecl)); } - break; - - case 649: /* tuple_alias_type_list: %empty */ - { - (yyval.pVarDeclList) = new vector(); - } - break; - - case 650: /* tuple_alias_type_list: tuple_alias_type_list c_or_s */ - { - (yyval.pVarDeclList) = (yyvsp[-1].pVarDeclList); - } - break; - - case 651: /* tuple_alias_type_list: tuple_alias_type_list tuple_type c_or_s */ - { - (yyval.pVarDeclList) = (yyvsp[-2].pVarDeclList); (yyvsp[-2].pVarDeclList)->push_back((yyvsp[-1].pVarDecl)); - /* - if ( !yyextra->g_CommentReaders.empty() ) { - for ( auto & crd : yyextra->g_CommentReaders ) { - for ( const auto & nl : *($decl->pNameList) ) { - crd->afterVariantEntry(nl.name.c_str(), nl.at); - } - } - } - */ - } - break; - - case 652: /* variant_type: "name" ':' type_declaration */ - { - auto na = new vector(); - na->push_back(VariableNameAndPosition(*(yyvsp[-2].s),"",tokAt(scanner,(yylsp[-2])))); - (yyval.pVarDecl) = new VariableDeclaration(na,(yyvsp[0].pTypeDecl),nullptr); - delete (yyvsp[-2].s); - } - break; - - case 653: /* variant_type_list: variant_type */ - { (yyval.pVarDeclList) = new vector(); (yyval.pVarDeclList)->push_back((yyvsp[0].pVarDecl)); } - break; - - case 654: /* variant_type_list: variant_type_list c_or_s variant_type */ - { (yyval.pVarDeclList) = (yyvsp[-2].pVarDeclList); (yyvsp[-2].pVarDeclList)->push_back((yyvsp[0].pVarDecl)); } - break; - - case 655: /* variant_alias_type_list: %empty */ - { - (yyval.pVarDeclList) = new vector(); - } - break; - - case 656: /* variant_alias_type_list: variant_alias_type_list c_or_s */ - { - (yyval.pVarDeclList) = (yyvsp[-1].pVarDeclList); - } - break; - - case 657: /* variant_alias_type_list: variant_alias_type_list variant_type c_or_s */ - { - (yyval.pVarDeclList) = (yyvsp[-2].pVarDeclList); (yyvsp[-2].pVarDeclList)->push_back((yyvsp[-1].pVarDecl)); - if ( !yyextra->g_CommentReaders.empty() ) { - for ( auto & crd : yyextra->g_CommentReaders ) { - for ( const auto & nl : *((yyvsp[-1].pVarDecl)->pNameList) ) { - crd->afterVariantEntry(nl.name.c_str(), nl.at); - } - } - } - } - break; - - case 658: /* copy_or_move: '=' */ - { (yyval.b) = false; } - break; - - case 659: /* copy_or_move: "<-" */ - { (yyval.b) = true; } - break; - - case 660: /* variable_declaration_no_type: variable_name_with_pos_list */ - { - auto autoT = new TypeDecl(Type::autoinfer); - autoT->at = tokAt(scanner,(yylsp[0])); - autoT->ref = false; - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[0].pNameWithPosList),autoT,nullptr); - } - break; - - case 661: /* variable_declaration_no_type: variable_name_with_pos_list '&' */ - { - auto autoT = new TypeDecl(Type::autoinfer); - autoT->at = tokAt(scanner,(yylsp[-1])); - autoT->ref = true; - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[-1].pNameWithPosList),autoT,nullptr); - } - break; - - case 662: /* variable_declaration_no_type: variable_name_with_pos_list copy_or_move expr */ - { - auto typeDecl = new TypeDecl(Type::autoinfer); - typeDecl->at = tokAt(scanner,(yylsp[-2])); - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[-2].pNameWithPosList),typeDecl,(yyvsp[0].pExpression)); - (yyval.pVarDecl)->init_via_move = (yyvsp[-1].b); - } - break; - - case 663: /* variable_declaration_type: variable_name_with_pos_list ':' type_declaration */ - { - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[-2].pNameWithPosList),(yyvsp[0].pTypeDecl),nullptr); - } - break; - - case 664: /* variable_declaration_type: variable_name_with_pos_list ':' type_declaration copy_or_move expr */ - { - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[-4].pNameWithPosList),(yyvsp[-2].pTypeDecl),(yyvsp[0].pExpression)); - (yyval.pVarDecl)->init_via_move = (yyvsp[-1].b); - } - break; - - case 665: /* variable_declaration: variable_declaration_type */ - { - (yyval.pVarDecl) = (yyvsp[0].pVarDecl); - } - break; - - case 666: /* variable_declaration: variable_declaration_no_type */ - { - (yyval.pVarDecl) = (yyvsp[0].pVarDecl); - } - break; - - case 667: /* copy_or_move_or_clone: '=' */ - { (yyval.i) = CorM_COPY; } - break; - - case 668: /* copy_or_move_or_clone: "<-" */ - { (yyval.i) = CorM_MOVE; } - break; - - case 669: /* copy_or_move_or_clone: ":=" */ - { (yyval.i) = CorM_CLONE; } - break; - - case 670: /* optional_ref: %empty */ - { (yyval.b) = false; } - break; - - case 671: /* optional_ref: '&' */ - { (yyval.b) = true; } - break; - - case 672: /* let_variable_name_with_pos_list: "name" */ - { - das_checkName(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))); - auto pSL = new vector(); - pSL->push_back(VariableNameAndPosition(*(yyvsp[0].s),"",tokAt(scanner,(yylsp[0])))); - (yyval.pNameWithPosList) = pSL; - delete (yyvsp[0].s); - } - break; - - case 673: /* let_variable_name_with_pos_list: "$i" '(' expr2 ')' */ - { - auto pSL = new vector(); - pSL->push_back(VariableNameAndPosition("``MACRO``TAG``","",tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression))); - (yyval.pNameWithPosList) = pSL; - } - break; - - case 674: /* let_variable_name_with_pos_list: "name" "aka" "name" */ - { - das_checkName(scanner,*(yyvsp[-2].s),tokAt(scanner,(yylsp[-2]))); - das_checkName(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))); - auto pSL = new vector(); - pSL->push_back(VariableNameAndPosition(*(yyvsp[-2].s),*(yyvsp[0].s),tokAt(scanner,(yylsp[-2])))); - (yyval.pNameWithPosList) = pSL; - delete (yyvsp[-2].s); - delete (yyvsp[0].s); - } - break; - - case 675: /* let_variable_name_with_pos_list: let_variable_name_with_pos_list ',' "name" */ - { - das_checkName(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))); - (yyvsp[-2].pNameWithPosList)->push_back(VariableNameAndPosition(*(yyvsp[0].s),"",tokAt(scanner,(yylsp[0])))); - (yyval.pNameWithPosList) = (yyvsp[-2].pNameWithPosList); - delete (yyvsp[0].s); - } - break; - - case 676: /* let_variable_name_with_pos_list: let_variable_name_with_pos_list ',' "name" "aka" "name" */ - { - das_checkName(scanner,*(yyvsp[-2].s),tokAt(scanner,(yylsp[-2]))); - das_checkName(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))); - (yyvsp[-4].pNameWithPosList)->push_back(VariableNameAndPosition(*(yyvsp[-2].s),*(yyvsp[0].s),tokAt(scanner,(yylsp[-2])))); - (yyval.pNameWithPosList) = (yyvsp[-4].pNameWithPosList); - delete (yyvsp[-2].s); - delete (yyvsp[0].s); - } - break; - - case 677: /* let_variable_declaration: let_variable_name_with_pos_list ':' type_declaration_no_options semicolon */ - { - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[-3].pNameWithPosList),(yyvsp[-1].pTypeDecl),nullptr); - } - break; - - case 678: /* let_variable_declaration: let_variable_name_with_pos_list ':' type_declaration_no_options copy_or_move_or_clone expr semicolon */ - { - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[-5].pNameWithPosList),(yyvsp[-3].pTypeDecl),(yyvsp[-1].pExpression)); - (yyval.pVarDecl)->init_via_move = ((yyvsp[-2].i) & CorM_MOVE) !=0; - (yyval.pVarDecl)->init_via_clone = ((yyvsp[-2].i) & CorM_CLONE) !=0; - } - break; - - case 679: /* let_variable_declaration: let_variable_name_with_pos_list ':' type_declaration_no_options copy_or_move_or_clone expr_pipe */ - { - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[-4].pNameWithPosList),(yyvsp[-2].pTypeDecl),(yyvsp[0].pExpression)); - (yyval.pVarDecl)->init_via_move = ((yyvsp[-1].i) & CorM_MOVE) !=0; - (yyval.pVarDecl)->init_via_clone = ((yyvsp[-1].i) & CorM_CLONE) !=0; - } - break; - - case 680: /* let_variable_declaration: let_variable_name_with_pos_list optional_ref copy_or_move_or_clone expr semicolon */ - { - auto typeDecl = new TypeDecl(Type::autoinfer); - typeDecl->at = tokAt(scanner,(yylsp[-4])); - typeDecl->ref = (yyvsp[-3].b); - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[-4].pNameWithPosList),typeDecl,(yyvsp[-1].pExpression)); - (yyval.pVarDecl)->init_via_move = ((yyvsp[-2].i) & CorM_MOVE) !=0; - (yyval.pVarDecl)->init_via_clone = ((yyvsp[-2].i) & CorM_CLONE) !=0; - } - break; - - case 681: /* let_variable_declaration: let_variable_name_with_pos_list optional_ref copy_or_move_or_clone expr */ - { - // Until absence of semicolon with lambda is not fixed - format::try_semicolon_at_eol(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - auto typeDecl = new TypeDecl(Type::autoinfer); - typeDecl->at = tokAt(scanner,(yylsp[-3])); - typeDecl->ref = (yyvsp[-2].b); - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[-3].pNameWithPosList),typeDecl,(yyvsp[0].pExpression)); - (yyval.pVarDecl)->init_via_move = ((yyvsp[-1].i) & CorM_MOVE) !=0; - (yyval.pVarDecl)->init_via_clone = ((yyvsp[-1].i) & CorM_CLONE) !=0; - } - break; - - case 682: /* let_variable_declaration: let_variable_name_with_pos_list optional_ref copy_or_move_or_clone expr_pipe */ - { - auto typeDecl = new TypeDecl(Type::autoinfer); - typeDecl->at = tokAt(scanner,(yylsp[-3])); - typeDecl->ref = (yyvsp[-2].b); - (yyval.pVarDecl) = new VariableDeclaration((yyvsp[-3].pNameWithPosList),typeDecl,(yyvsp[0].pExpression)); - (yyval.pVarDecl)->init_via_move = ((yyvsp[-1].i) & CorM_MOVE) !=0; - (yyval.pVarDecl)->init_via_clone = ((yyvsp[-1].i) & CorM_CLONE) !=0; - } - break; - - case 683: /* global_variable_declaration_list: %empty */ - { - (yyval.pVarDeclList) = new vector(); - } - break; - - case 684: /* $@41: %empty */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[0])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeGlobalVariables(tak); - } - } - break; - - case 685: /* global_variable_declaration_list: global_variable_declaration_list $@41 optional_field_annotation let_variable_declaration opt_sem */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[-1])); - for ( auto & crd : yyextra->g_CommentReaders ) - for ( auto & nl : *((yyvsp[-1].pVarDecl)->pNameList) ) - crd->afterGlobalVariable(nl.name.c_str(),tak); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterGlobalVariables(tak); - } - (yyval.pVarDeclList) = (yyvsp[-4].pVarDeclList); - (yyvsp[-1].pVarDecl)->annotation = (yyvsp[-2].aaList); - (yyvsp[-4].pVarDeclList)->push_back((yyvsp[-1].pVarDecl)); - } - break; - - case 686: /* optional_shared: %empty */ - { (yyval.b) = false; } - break; - - case 687: /* optional_shared: "shared" */ - { (yyval.b) = true; } - break; - - case 688: /* optional_public_or_private_variable: %empty */ - { (yyval.b) = yyextra->g_Program->thisModule->isPublic; } - break; - - case 689: /* optional_public_or_private_variable: "private" */ - { (yyval.b) = false; } - break; - - case 690: /* optional_public_or_private_variable: "public" */ - { (yyval.b) = true; } - break; - - case 691: /* global_let: kwd_let optional_shared optional_public_or_private_variable open_block global_variable_declaration_list close_block */ - { - handle_brace(format::Pos::from(tokAt(scanner, (yylsp[-2]))), (yyvsp[-2].ui), - format::get_substring(tokRangeAt(scanner, (yylsp[-2]), (yylsp[0]))), - yyextra->das_tab_size, - format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - ast_globalLetList(scanner,(yyvsp[-5].b),(yyvsp[-4].b),(yyvsp[-3].b),(yyvsp[-1].pVarDeclList)); - } - break; - - case 692: /* $@42: %empty */ - { - yyextra->das_force_oxford_comma=true; - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[0])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeGlobalVariables(tak); - } - } - break; - - case 693: /* global_let: kwd_let optional_shared optional_public_or_private_variable $@42 optional_field_annotation let_variable_declaration */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[0])); - for ( auto & crd : yyextra->g_CommentReaders ) - for ( auto & nl : *((yyvsp[0].pVarDecl)->pNameList) ) - crd->afterGlobalVariable(nl.name.c_str(),tak); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterGlobalVariables(tak); - } - ast_globalLet(scanner,(yyvsp[-5].b),(yyvsp[-4].b),(yyvsp[-3].b),(yyvsp[-1].aaList),(yyvsp[0].pVarDecl)); - } - break; - - case 694: /* enum_list: %empty */ - { - (yyval.pEnumList) = new Enumeration(); - } - break; - - case 695: /* enum_list: enum_list "name" opt_sem */ - { - format::skip_token(true, false, tokAt(scanner,(yylsp[0]))); - das_checkName(scanner,*(yyvsp[-1].s),tokAt(scanner,(yylsp[-1]))); - if ( !(yyvsp[-2].pEnumList)->add(*(yyvsp[-1].s),nullptr,tokAt(scanner,(yylsp[-1]))) ) { - das_yyerror(scanner,"enumeration already declared " + *(yyvsp[-1].s), tokAt(scanner,(yylsp[-1])), - CompilationError::enumeration_value_already_declared); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto tokName = tokAt(scanner,(yylsp[-1])); - for ( auto & crd : yyextra->g_CommentReaders ) { - crd->afterEnumerationEntry((yyvsp[-1].s)->c_str(), tokName); - } - } - delete (yyvsp[-1].s); - (yyval.pEnumList) = (yyvsp[-2].pEnumList); - } - break; - - case 696: /* enum_list: enum_list "name" '=' expr opt_sem */ - { - format::skip_token(true, false, tokAt(scanner,(yylsp[0]))); - das_checkName(scanner,*(yyvsp[-3].s),tokAt(scanner,(yylsp[-3]))); - if ( !(yyvsp[-4].pEnumList)->add(*(yyvsp[-3].s),(yyvsp[-1].pExpression),tokAt(scanner,(yylsp[-3]))) ) { - das_yyerror(scanner,"enumeration value already declared " + *(yyvsp[-3].s), tokAt(scanner,(yylsp[-3])), - CompilationError::enumeration_value_already_declared); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto tokName = tokAt(scanner,(yylsp[-3])); - for ( auto & crd : yyextra->g_CommentReaders ) { - crd->afterEnumerationEntry((yyvsp[-3].s)->c_str(), tokName); - } - } - delete (yyvsp[-3].s); - (yyval.pEnumList) = (yyvsp[-4].pEnumList); - } - break; - - case 697: /* optional_public_or_private_alias: %empty */ - { (yyval.b) = yyextra->g_Program->thisModule->isPublic; } - break; - - case 698: /* optional_public_or_private_alias: "private" */ - { (yyval.b) = false; } - break; - - case 699: /* optional_public_or_private_alias: "public" */ - { (yyval.b) = true; } - break; - - case 700: /* $@43: %empty */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto pubename = tokAt(scanner,(yylsp[0])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeAlias(pubename); - } - } - break; - - case 701: /* single_alias: optional_public_or_private_alias "name" $@43 '=' type_declaration */ - { - das_checkName(scanner,*(yyvsp[-3].s),tokAt(scanner,(yylsp[-3]))); - (yyvsp[0].pTypeDecl)->isPrivateAlias = !(yyvsp[-4].b); - if ( (yyvsp[0].pTypeDecl)->baseType == Type::alias ) { - das_yyerror(scanner,"alias cannot be defined in terms of another alias "+*(yyvsp[-3].s),tokAt(scanner,(yylsp[-3])), - CompilationError::invalid_type); - } - (yyvsp[0].pTypeDecl)->alias = *(yyvsp[-3].s); - if ( !yyextra->g_Program->addAlias((yyvsp[0].pTypeDecl)) ) { - das_yyerror(scanner,"type alias is already defined "+*(yyvsp[-3].s),tokAt(scanner,(yylsp[-3])), - CompilationError::type_alias_already_declared); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto pubename = tokAt(scanner,(yylsp[0])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterAlias((yyvsp[-3].s)->c_str(),pubename); - } - if ((yylsp[-4]).first_column == (yylsp[-4]).last_column) { - (yyloc).first_line = (yylsp[-3]).first_line; - (yyloc).first_column = (yylsp[-3]).first_column; - } - delete (yyvsp[-3].s); - } - break; - - case 702: /* alias_list: single_alias opt_sem */ - { - (yyval.positions) = new vector(1, tokAt(scanner, (yylsp[-1]))); - } - break; - - case 703: /* alias_list: alias_list single_alias opt_sem */ - { - (yyvsp[-2].positions)->emplace_back(tokAt(scanner, (yylsp[-1]))); - (yyval.positions) = (yyvsp[-2].positions); - } - break; - - case 704: /* alias_declaration: "typedef" open_block alias_list close_block */ - { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, (yylsp[-3]))))) { - // todo: comments here and all such places, same rule - for (const auto single: *(yyvsp[-1].positions)) { - format::get_writer() << "typedef " << format::get_substring(single) << '\n'; - } - format::finish_rule(format::Pos::from_last(tokAt(scanner, (yylsp[0])))); - } - - } - break; - - case 705: /* $@44: %empty */ - { yyextra->das_force_oxford_comma=true;} - break; - - case 707: /* optional_public_or_private_enum: %empty */ - { (yyval.b) = yyextra->g_Program->thisModule->isPublic; } - break; - - case 708: /* optional_public_or_private_enum: "private" */ - { (yyval.b) = false; } - break; - - case 709: /* optional_public_or_private_enum: "public" */ - { (yyval.b) = true; } - break; - - case 710: /* enum_name: "name" */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto pubename = tokAt(scanner,(yylsp[0])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeEnumeration(pubename); - } - (yyval.pEnum) = ast_addEmptyEnum(scanner, (yyvsp[0].s), tokAt(scanner,(yylsp[0]))); - } - break; - - case 711: /* enum_declaration: optional_annotation_list "enum" optional_public_or_private_enum enum_name open_block enum_list close_block */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[-3])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeEnumerationEntries(tak); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[-1])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterEnumerationEntries(tak); - } - const auto first_loc = format::Pos::from(tokAt(scanner,(yylsp[-2]))); - handle_brace(first_loc, (yyvsp[-2].ui), - format::get_substring(first_loc, format::Pos::from_last(tokAt(scanner,(yylsp[-1])))), - yyextra->das_tab_size, - format::Pos::from_last(tokAt(scanner,(yylsp[-1])))); - if ( !yyextra->g_CommentReaders.empty() ) { - auto pubename = tokAt(scanner,(yylsp[-1])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterEnumeration((yyvsp[-3].pEnum)->name.c_str(),pubename); - } - ast_enumDeclaration(scanner,(yyvsp[-6].faList),tokAt(scanner,(yylsp[-6])),(yyvsp[-4].b),(yyvsp[-3].pEnum),(yyvsp[-1].pEnumList),Type::tInt); - } - break; - - case 712: /* enum_declaration: optional_annotation_list "enum" optional_public_or_private_enum enum_name ':' enum_basic_type_declaration open_block enum_list close_block */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[-5])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeEnumerationEntries(tak); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[-1])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterEnumerationEntries(tak); - } - const auto first_loc = format::Pos::from(tokAt(scanner,(yylsp[-2]))); - handle_brace(first_loc, (yyvsp[-2].ui), - format::get_substring(first_loc, format::Pos::from_last(tokAt(scanner,(yylsp[-1])))), - yyextra->das_tab_size, - format::Pos::from_last(tokAt(scanner,(yylsp[-1])))); - if ( !yyextra->g_CommentReaders.empty() ) { - auto pubename = tokAt(scanner,(yylsp[-1])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterEnumeration((yyvsp[-5].pEnum)->name.c_str(),pubename); - } - ast_enumDeclaration(scanner,(yyvsp[-8].faList),tokAt(scanner,(yylsp[-8])),(yyvsp[-6].b),(yyvsp[-5].pEnum),(yyvsp[-1].pEnumList),(yyvsp[-3].type)); - } - break; - - case 713: /* optional_structure_parent: %empty */ - { (yyval.s) = nullptr; } - break; - - case 714: /* optional_structure_parent: ':' name_in_namespace */ - { (yyval.s) = (yyvsp[0].s); } - break; - - case 715: /* optional_sealed: %empty */ - { (yyval.b) = false; } - break; - - case 716: /* optional_sealed: "sealed" */ - { (yyval.b) = true; } - break; - - case 717: /* structure_name: optional_sealed "name" optional_structure_parent */ - { - (yyval.pStructure) = ast_structureName(scanner,(yyvsp[-2].b),(yyvsp[-1].s),tokAt(scanner,(yylsp[-1])),(yyvsp[0].s),tokAt(scanner,(yylsp[0]))); - } - break; - - case 718: /* class_or_struct: "class" */ - { (yyval.i) = CorS_Class; } - break; - - case 719: /* class_or_struct: "struct" */ - { (yyval.i) = CorS_Struct; } - break; - - case 720: /* class_or_struct: "class" "template" */ - { (yyval.i) = CorS_ClassTemplate; } - break; - - case 721: /* class_or_struct: "struct" "template" */ - { (yyval.i) = CorS_StructTemplate; } - break; - - case 722: /* optional_public_or_private_structure: %empty */ - { (yyval.b) = yyextra->g_Program->thisModule->isPublic; } - break; - - case 723: /* optional_public_or_private_structure: "private" */ - { (yyval.b) = false; } - break; - - case 724: /* optional_public_or_private_structure: "public" */ - { (yyval.b) = true; } - break; - - case 725: /* optional_struct_variable_declaration_list: %empty */ - { - (yyval.pVarDeclList) = new vector(); - } - break; - - case 726: /* optional_struct_variable_declaration_list: open_block struct_variable_declaration_list close_block */ - { - const auto prev_loc = format::Pos::from(tokAt(scanner,(yylsp[-2]))); - handle_brace(prev_loc, (yyvsp[-2].ui), - format::get_substring(prev_loc, format::Pos::from_last(tokAt(scanner,(yylsp[-1])))), - yyextra->das_tab_size, - format::Pos::from_last(tokAt(scanner,(yylsp[-1])))); - (yyval.pVarDeclList) = (yyvsp[-1].pVarDeclList); - } - break; - - case 727: /* $@45: %empty */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[-1])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeStructure(tak); - } - } - break; - - case 728: /* $@46: %empty */ - { - if ( (yyvsp[0].pStructure) ) { - (yyvsp[0].pStructure)->isClass = (yyvsp[-3].i)==CorS_Class || (yyvsp[-3].i)==CorS_ClassTemplate; - (yyvsp[0].pStructure)->isTemplate = (yyvsp[-3].i)==CorS_ClassTemplate || (yyvsp[-3].i)==CorS_StructTemplate; - (yyvsp[0].pStructure)->privateStructure = !(yyvsp[-2].b); - } - } - break; - - case 729: /* structure_declaration: optional_annotation_list class_or_struct optional_public_or_private_structure $@45 structure_name $@46 optional_struct_variable_declaration_list */ - { - if ( (yyvsp[-2].pStructure) ) { - ast_structureDeclaration ( scanner, (yyvsp[-6].faList), tokAt(scanner,(yylsp[-5])), (yyvsp[-2].pStructure), tokAt(scanner,(yylsp[-2])), (yyvsp[0].pVarDeclList) ); - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,(yylsp[-5])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterStructure((yyvsp[-2].pStructure),tak); - } - } else { - deleteVariableDeclarationList((yyvsp[0].pVarDeclList)); - } - } - break; - - case 730: /* variable_name_with_pos_list: "name" */ - { - das_checkName(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))); - auto pSL = new vector(); - pSL->push_back(VariableNameAndPosition(*(yyvsp[0].s),"",tokAt(scanner,(yylsp[0])))); - (yyval.pNameWithPosList) = pSL; - delete (yyvsp[0].s); - } - break; - - case 731: /* variable_name_with_pos_list: "$i" '(' expr2 ')' */ - { - auto pSL = new vector(); - pSL->push_back(VariableNameAndPosition("``MACRO``TAG``","",tokAt(scanner,(yylsp[-1])),(yyvsp[-1].pExpression))); - (yyval.pNameWithPosList) = pSL; - } - break; - - case 732: /* variable_name_with_pos_list: "name" "aka" "name" */ - { - das_checkName(scanner,*(yyvsp[-2].s),tokAt(scanner,(yylsp[-2]))); - das_checkName(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))); - auto pSL = new vector(); - pSL->push_back(VariableNameAndPosition(*(yyvsp[-2].s),*(yyvsp[0].s),tokAt(scanner,(yylsp[-2])))); - (yyval.pNameWithPosList) = pSL; - delete (yyvsp[-2].s); - delete (yyvsp[0].s); - } - break; - - case 733: /* variable_name_with_pos_list: variable_name_with_pos_list ',' "name" */ - { - das_checkName(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))); - (yyvsp[-2].pNameWithPosList)->push_back(VariableNameAndPosition(*(yyvsp[0].s),"",tokAt(scanner,(yylsp[0])))); - (yyval.pNameWithPosList) = (yyvsp[-2].pNameWithPosList); - delete (yyvsp[0].s); - } - break; - - case 734: /* variable_name_with_pos_list: variable_name_with_pos_list ',' "name" "aka" "name" */ - { - das_checkName(scanner,*(yyvsp[-2].s),tokAt(scanner,(yylsp[-2]))); - das_checkName(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))); - (yyvsp[-4].pNameWithPosList)->push_back(VariableNameAndPosition(*(yyvsp[-2].s),*(yyvsp[0].s),tokAt(scanner,(yylsp[-2])))); - (yyval.pNameWithPosList) = (yyvsp[-4].pNameWithPosList); - delete (yyvsp[-2].s); - delete (yyvsp[0].s); - } - break; - - case 735: /* basic_type_declaration: "bool" */ - { (yyval.type) = Type::tBool; } - break; - - case 736: /* basic_type_declaration: "string" */ - { (yyval.type) = Type::tString; } - break; - - case 737: /* basic_type_declaration: "int" */ - { (yyval.type) = Type::tInt; } - break; - - case 738: /* basic_type_declaration: "int8" */ - { (yyval.type) = Type::tInt8; } - break; - - case 739: /* basic_type_declaration: "int16" */ - { (yyval.type) = Type::tInt16; } - break; - - case 740: /* basic_type_declaration: "int64" */ - { (yyval.type) = Type::tInt64; } - break; - - case 741: /* basic_type_declaration: "int2" */ - { (yyval.type) = Type::tInt2; } - break; - - case 742: /* basic_type_declaration: "int3" */ - { (yyval.type) = Type::tInt3; } - break; - - case 743: /* basic_type_declaration: "int4" */ - { (yyval.type) = Type::tInt4; } - break; - - case 744: /* basic_type_declaration: "uint" */ - { (yyval.type) = Type::tUInt; } - break; - - case 745: /* basic_type_declaration: "uint8" */ - { (yyval.type) = Type::tUInt8; } - break; - - case 746: /* basic_type_declaration: "uint16" */ - { (yyval.type) = Type::tUInt16; } - break; - - case 747: /* basic_type_declaration: "uint64" */ - { (yyval.type) = Type::tUInt64; } - break; - - case 748: /* basic_type_declaration: "uint2" */ - { (yyval.type) = Type::tUInt2; } - break; - - case 749: /* basic_type_declaration: "uint3" */ - { (yyval.type) = Type::tUInt3; } - break; - - case 750: /* basic_type_declaration: "uint4" */ - { (yyval.type) = Type::tUInt4; } - break; - - case 751: /* basic_type_declaration: "float" */ - { (yyval.type) = Type::tFloat; } - break; - - case 752: /* basic_type_declaration: "float2" */ - { (yyval.type) = Type::tFloat2; } - break; - - case 753: /* basic_type_declaration: "float3" */ - { (yyval.type) = Type::tFloat3; } - break; - - case 754: /* basic_type_declaration: "float4" */ - { (yyval.type) = Type::tFloat4; } - break; - - case 755: /* basic_type_declaration: "float16" */ - { (yyval.type) = Type::tFloat16; } - break; - - case 756: /* basic_type_declaration: "half2" */ - { (yyval.type) = Type::tHalf2; } - break; - - case 757: /* basic_type_declaration: "half3" */ - { (yyval.type) = Type::tHalf3; } - break; - - case 758: /* basic_type_declaration: "half4" */ - { (yyval.type) = Type::tHalf4; } - break; - - case 759: /* basic_type_declaration: "half8" */ - { (yyval.type) = Type::tHalf8; } - break; - - case 760: /* basic_type_declaration: "short2" */ - { (yyval.type) = Type::tShort2; } - break; - - case 761: /* basic_type_declaration: "short3" */ - { (yyval.type) = Type::tShort3; } - break; - - case 762: /* basic_type_declaration: "short4" */ - { (yyval.type) = Type::tShort4; } - break; - - case 763: /* basic_type_declaration: "short8" */ - { (yyval.type) = Type::tShort8; } - break; - - case 764: /* basic_type_declaration: "ushort2" */ - { (yyval.type) = Type::tUShort2; } - break; - - case 765: /* basic_type_declaration: "ushort3" */ - { (yyval.type) = Type::tUShort3; } - break; - - case 766: /* basic_type_declaration: "ushort4" */ - { (yyval.type) = Type::tUShort4; } - break; - - case 767: /* basic_type_declaration: "ushort8" */ - { (yyval.type) = Type::tUShort8; } - break; - - case 768: /* basic_type_declaration: "byte2" */ - { (yyval.type) = Type::tByte2; } - break; - - case 769: /* basic_type_declaration: "byte3" */ - { (yyval.type) = Type::tByte3; } - break; - - case 770: /* basic_type_declaration: "byte4" */ - { (yyval.type) = Type::tByte4; } - break; - - case 771: /* basic_type_declaration: "byte8" */ - { (yyval.type) = Type::tByte8; } - break; - - case 772: /* basic_type_declaration: "byte16" */ - { (yyval.type) = Type::tByte16; } - break; - - case 773: /* basic_type_declaration: "ubyte2" */ - { (yyval.type) = Type::tUByte2; } - break; - - case 774: /* basic_type_declaration: "ubyte3" */ - { (yyval.type) = Type::tUByte3; } - break; - - case 775: /* basic_type_declaration: "ubyte4" */ - { (yyval.type) = Type::tUByte4; } - break; - - case 776: /* basic_type_declaration: "ubyte8" */ - { (yyval.type) = Type::tUByte8; } - break; - - case 777: /* basic_type_declaration: "ubyte16" */ - { (yyval.type) = Type::tUByte16; } - break; - - case 778: /* basic_type_declaration: "void" */ - { (yyval.type) = Type::tVoid; } - break; - - case 779: /* basic_type_declaration: "range" */ - { (yyval.type) = Type::tRange; } - break; - - case 780: /* basic_type_declaration: "urange" */ - { (yyval.type) = Type::tURange; } - break; - - case 781: /* basic_type_declaration: "range64" */ - { (yyval.type) = Type::tRange64; } - break; - - case 782: /* basic_type_declaration: "urange64" */ - { (yyval.type) = Type::tURange64; } - break; - - case 783: /* basic_type_declaration: "double" */ - { (yyval.type) = Type::tDouble; } - break; - - case 784: /* basic_type_declaration: "bitfield" */ - { (yyval.type) = Type::tBitfield; } - break; - - case 785: /* enum_basic_type_declaration: "int" */ - { (yyval.type) = Type::tInt; } - break; - - case 786: /* enum_basic_type_declaration: "int8" */ - { (yyval.type) = Type::tInt8; } - break; - - case 787: /* enum_basic_type_declaration: "int16" */ - { (yyval.type) = Type::tInt16; } - break; - - case 788: /* enum_basic_type_declaration: "uint" */ - { (yyval.type) = Type::tUInt; } - break; - - case 789: /* enum_basic_type_declaration: "uint8" */ - { (yyval.type) = Type::tUInt8; } - break; - - case 790: /* enum_basic_type_declaration: "uint16" */ - { (yyval.type) = Type::tUInt16; } - break; - - case 791: /* enum_basic_type_declaration: "int64" */ - { (yyval.type) = Type::tInt64; } - break; - - case 792: /* enum_basic_type_declaration: "uint64" */ - { (yyval.type) = Type::tUInt64; } - break; - - case 793: /* structure_type_declaration: name_in_namespace */ - { - (yyval.pTypeDecl) = yyextra->g_Program->makeTypeDeclaration(tokAt(scanner,(yylsp[0])),*(yyvsp[0].s)); - if ( !(yyval.pTypeDecl) ) { - (yyval.pTypeDecl) = new TypeDecl(Type::tVoid); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[0])); - } - delete (yyvsp[0].s); - } - break; - - case 794: /* auto_type_declaration: "auto" */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::autoinfer); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[0])); - } - break; - - case 795: /* auto_type_declaration: "auto" '(' "name" ')' */ - { - das_checkName(scanner,*(yyvsp[-1].s),tokAt(scanner,(yylsp[-1]))); - (yyval.pTypeDecl) = new TypeDecl(Type::autoinfer); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-3])); - (yyval.pTypeDecl)->alias = *(yyvsp[-1].s); - delete (yyvsp[-1].s); - } - break; - - case 796: /* auto_type_declaration: "$t" '(' expr2 ')' */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::alias); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-3])); - (yyval.pTypeDecl)->alias = "``MACRO``TAG``"; - (yyval.pTypeDecl)->isTag = true; - (yyval.pTypeDecl)->firstType = new TypeDecl(Type::autoinfer); - (yyval.pTypeDecl)->firstType->at = tokAt(scanner, (yylsp[-1])); - (yyval.pTypeDecl)->firstType->typeMacroExpr.push_back((yyvsp[-1].pExpression)); - } - break; - - case 797: /* bitfield_bits: "name" */ - { - das_checkName(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))); - auto pSL = new vector(); - pSL->push_back(*(yyvsp[0].s)); - (yyval.pNameList) = pSL; - delete (yyvsp[0].s); - } - break; - - case 798: /* bitfield_bits: bitfield_bits semicolon "name" */ - { - das_checkName(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))); - (yyvsp[-2].pNameList)->push_back(*(yyvsp[0].s)); - (yyval.pNameList) = (yyvsp[-2].pNameList); - delete (yyvsp[0].s); - } - break; - - case 799: /* bitfield_bits: bitfield_bits ',' "name" */ - { - das_checkName(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))); - (yyvsp[-2].pNameList)->push_back(*(yyvsp[0].s)); - (yyval.pNameList) = (yyvsp[-2].pNameList); - delete (yyvsp[0].s); - } - break; - - case 802: /* bitfield_alias_bits: %empty */ - { - auto pSL = new vector>(); - (yyval.pNameExprList) = pSL; - - } - break; - - case 803: /* bitfield_alias_bits: bitfield_alias_bits "name" SEMICOLON */ - { - if (format::enum_bitfield_with_comma() && format::is_replace_braces() && format::prepare_rule(format::Pos::from_last(tokAt(scanner,(yylsp[-1]))))) { - format::get_writer() << ","; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[-1])))); - } - das_checkName(scanner,*(yyvsp[-1].s),tokAt(scanner,(yylsp[-1]))); - (yyval.pNameExprList) = (yyvsp[-2].pNameExprList); - (yyval.pNameExprList)->emplace_back(*(yyvsp[-1].s),nullptr); - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[-1])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfieldEntry((yyvsp[-1].s)->c_str(),atvname); - } - delete (yyvsp[-1].s); - } - break; - - case 804: /* bitfield_alias_bits: bitfield_alias_bits "name" commas */ - { - das_checkName(scanner,*(yyvsp[-1].s),tokAt(scanner,(yylsp[-1]))); - (yyval.pNameExprList) = (yyvsp[-2].pNameExprList); - (yyval.pNameExprList)->emplace_back(*(yyvsp[-1].s),nullptr); - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[-1])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfieldEntry((yyvsp[-1].s)->c_str(),atvname); - } - delete (yyvsp[-1].s); - } - break; - - case 805: /* bitfield_alias_bits: bitfield_alias_bits "name" */ - { - das_checkName(scanner,*(yyvsp[0].s),tokAt(scanner,(yylsp[0]))); - (yyval.pNameExprList) = (yyvsp[-1].pNameExprList); - (yyval.pNameExprList)->emplace_back(*(yyvsp[0].s),nullptr); - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[0])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfieldEntry((yyvsp[0].s)->c_str(),atvname); - } - delete (yyvsp[0].s); - } - break; - - case 806: /* bitfield_alias_bits: bitfield_alias_bits "name" '=' expr SEMICOLON */ - { - das_checkName(scanner,*(yyvsp[-3].s),tokAt(scanner,(yylsp[-3]))); - (yyval.pNameExprList) = (yyvsp[-4].pNameExprList); - (yyval.pNameExprList)->emplace_back(*(yyvsp[-3].s),(yyvsp[-1].pExpression)); - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[-3])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfieldEntry((yyvsp[-3].s)->c_str(),atvname); - } - delete (yyvsp[-3].s); - } - break; - - case 807: /* bitfield_alias_bits: bitfield_alias_bits "name" '=' expr commas */ - { - das_checkName(scanner,*(yyvsp[-3].s),tokAt(scanner,(yylsp[-3]))); - (yyval.pNameExprList) = (yyvsp[-4].pNameExprList); - (yyval.pNameExprList)->emplace_back(*(yyvsp[-3].s),(yyvsp[-1].pExpression)); - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[-3])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfieldEntry((yyvsp[-3].s)->c_str(),atvname); - } - delete (yyvsp[-3].s); - } - break; - - case 808: /* bitfield_alias_bits: bitfield_alias_bits "name" '=' expr */ - { - das_checkName(scanner,*(yyvsp[-2].s),tokAt(scanner,(yylsp[-2]))); - (yyval.pNameExprList) = (yyvsp[-3].pNameExprList); - (yyval.pNameExprList)->emplace_back(*(yyvsp[-2].s),(yyvsp[0].pExpression)); - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[-2])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfieldEntry((yyvsp[-2].s)->c_str(),atvname); - } - delete (yyvsp[-2].s); - } - break; - - case 809: /* bitfield_basic_type_declaration: %empty */ - { (yyval.type) = Type::tBitfield; } - break; - - case 810: /* bitfield_basic_type_declaration: ':' "uint8" */ - { (yyval.type) = Type::tBitfield8; } - break; - - case 811: /* bitfield_basic_type_declaration: ':' "uint16" */ - { (yyval.type) = Type::tBitfield16; } - break; - - case 812: /* bitfield_basic_type_declaration: ':' "uint" */ - { (yyval.type) = Type::tBitfield; } - break; - - case 813: /* bitfield_basic_type_declaration: ':' "uint64" */ - { (yyval.type) = Type::tBitfield64; } - break; - - case 814: /* bitfield_type_declaration: "bitfield" bitfield_basic_type_declaration '<' '>' */ - { - (yyval.pTypeDecl) = new TypeDecl((yyvsp[-2].type)); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-2])); - } - break; - - case 815: /* $@47: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 816: /* $@48: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 817: /* bitfield_type_declaration: "bitfield" bitfield_basic_type_declaration '<' $@47 bitfield_bits '>' $@48 */ - { - (yyval.pTypeDecl) = new TypeDecl((yyvsp[-5].type)); - (yyval.pTypeDecl)->argNames = *(yyvsp[-2].pNameList); - auto maxBits = (yyval.pTypeDecl)->maxBitfieldBits(); - if ( (yyval.pTypeDecl)->argNames.size()>maxBits ) { - das_yyerror(scanner,"only " + to_string(maxBits) + " different bits are allowed in a bitfield",tokAt(scanner,(yylsp[-5])), - CompilationError::invalid_type); - } - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-5])); - delete (yyvsp[-2].pNameList); - } - break; - - case 820: /* table_type_pair: type_declaration */ - { - (yyval.aTypePair).firstType = (yyvsp[0].pTypeDecl); - (yyval.aTypePair).secondType = new TypeDecl(Type::tVoid); - } - break; - - case 821: /* table_type_pair: type_declaration c_or_s type_declaration */ - { - (yyval.aTypePair).firstType = (yyvsp[-2].pTypeDecl); - (yyval.aTypePair).secondType = (yyvsp[0].pTypeDecl); - } - break; - - case 822: /* dim_list: '[' expr2 ']' */ - { - (yyval.pTypeDecl) = appendDimExpr(nullptr, (yyvsp[-1].pExpression), tokAt(scanner,(yylsp[-1]))); - } - break; - - case 823: /* dim_list: dim_list '[' expr2 ']' */ - { - (yyval.pTypeDecl) = appendDimExpr((yyvsp[-3].pTypeDecl), (yyvsp[-1].pExpression), tokAt(scanner,(yylsp[-1]))); - } - break; - - case 824: /* type_declaration_no_options: basic_type_declaration */ - { (yyval.pTypeDecl) = new TypeDecl((yyvsp[0].type)); (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[0])); } - break; - - case 825: /* type_declaration_no_options: auto_type_declaration */ - { (yyval.pTypeDecl) = (yyvsp[0].pTypeDecl); } - break; - - case 826: /* type_declaration_no_options: bitfield_type_declaration */ - { (yyval.pTypeDecl) = (yyvsp[0].pTypeDecl); } - break; - - case 827: /* type_declaration_no_options: structure_type_declaration */ - { (yyval.pTypeDecl) = (yyvsp[0].pTypeDecl); } - break; - - case 828: /* type_declaration_no_options: type_declaration_no_options dim_list */ - { - if ( (yyvsp[-1].pTypeDecl)->baseType==Type::typeDecl ) { - das_yyerror(scanner,"type declaration can`t be used as array base type",tokAt(scanner,(yylsp[-1])), - CompilationError::invalid_type); - } else if ( (yyvsp[-1].pTypeDecl)->baseType==Type::typeMacro ) { - das_yyerror(scanner,"macro can`t be used as array base type",tokAt(scanner,(yylsp[-1])), - CompilationError::invalid_type); - } - (yyval.pTypeDecl) = attachDimChain((yyvsp[0].pTypeDecl), (yyvsp[-1].pTypeDecl)); - } - break; - - case 829: /* type_declaration_no_options: type_declaration_no_options '[' ']' */ - { - (yyval.pTypeDecl) = appendAutoDim((yyvsp[-2].pTypeDecl), tokAt(scanner,(yylsp[-1]))); - } - break; - - case 830: /* $@49: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 831: /* $@50: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 832: /* type_declaration_no_options: "type" '<' $@49 type_declaration '>' $@50 */ - { - (yyvsp[-2].pTypeDecl)->autoToAlias = true; - (yyval.pTypeDecl) = (yyvsp[-2].pTypeDecl); - } - break; - - case 833: /* type_declaration_no_options: "typedecl" '(' expr2 ')' */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::typeDecl); - (yyval.pTypeDecl)->at = tokRangeAt(scanner,(yylsp[-3]),(yylsp[-1])); - (yyval.pTypeDecl)->typeMacroExpr.push_back((yyvsp[-1].pExpression)); - } - break; - - case 834: /* type_declaration_no_options: '$' name_in_namespace optional_expr_list_in_braces */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::typeMacro); - (yyval.pTypeDecl)->at = tokRangeAt(scanner,(yylsp[-1]), (yylsp[0])); - (yyval.pTypeDecl)->typeMacroExpr = sequenceToList((yyvsp[0].pExpression)); - (yyval.pTypeDecl)->typeMacroExpr.insert((yyval.pTypeDecl)->typeMacroExpr.begin(), new ExprConstString(tokAt(scanner,(yylsp[-1])), *(yyvsp[-1].s))); - delete (yyvsp[-1].s); - } - break; - - case 835: /* $@51: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 836: /* type_declaration_no_options: '$' name_in_namespace '<' $@51 type_declaration_no_options_list '>' optional_expr_list_in_braces */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::typeMacro); - (yyval.pTypeDecl)->at = tokRangeAt(scanner,(yylsp[-5]), (yylsp[0])); - (yyval.pTypeDecl)->typeMacroExpr = typesAndSequenceToList((yyvsp[-2].pTypeDeclList),(yyvsp[0].pExpression)); - (yyval.pTypeDecl)->typeMacroExpr.insert((yyval.pTypeDecl)->typeMacroExpr.begin(), new ExprConstString(tokAt(scanner,(yylsp[-5])), *(yyvsp[-5].s))); - delete (yyvsp[-5].s); - } - break; - - case 837: /* type_declaration_no_options: type_declaration_no_options '-' '[' ']' */ - { - (yyvsp[-3].pTypeDecl)->removeDim = true; - (yyval.pTypeDecl) = (yyvsp[-3].pTypeDecl); - } - break; - - case 838: /* type_declaration_no_options: type_declaration_no_options "explicit" */ - { - (yyvsp[-1].pTypeDecl)->isExplicit = true; - (yyval.pTypeDecl) = (yyvsp[-1].pTypeDecl); - } - break; - - case 839: /* type_declaration_no_options: type_declaration_no_options "const" */ - { - (yyvsp[-1].pTypeDecl)->constant = true; - (yyvsp[-1].pTypeDecl)->removeConstant = false; - (yyval.pTypeDecl) = (yyvsp[-1].pTypeDecl); - } - break; - - case 840: /* type_declaration_no_options: type_declaration_no_options '-' "const" */ - { - (yyvsp[-2].pTypeDecl)->constant = false; - (yyvsp[-2].pTypeDecl)->removeConstant = true; - (yyval.pTypeDecl) = (yyvsp[-2].pTypeDecl); - } - break; - - case 841: /* type_declaration_no_options: type_declaration_no_options '&' */ - { - (yyvsp[-1].pTypeDecl)->ref = true; - (yyvsp[-1].pTypeDecl)->removeRef = false; - (yyval.pTypeDecl) = (yyvsp[-1].pTypeDecl); - } - break; - - case 842: /* type_declaration_no_options: type_declaration_no_options '-' '&' */ - { - (yyvsp[-2].pTypeDecl)->ref = false; - (yyvsp[-2].pTypeDecl)->removeRef = true; - (yyval.pTypeDecl) = (yyvsp[-2].pTypeDecl); - } - break; - - case 843: /* type_declaration_no_options: type_declaration_no_options '#' */ - { - (yyval.pTypeDecl) = (yyvsp[-1].pTypeDecl); - (yyval.pTypeDecl)->temporary = true; - } - break; - - case 844: /* type_declaration_no_options: type_declaration_no_options "implicit" */ - { - (yyval.pTypeDecl) = (yyvsp[-1].pTypeDecl); - (yyval.pTypeDecl)->implicit = true; - } - break; - - case 845: /* type_declaration_no_options: type_declaration_no_options '-' '#' */ - { - (yyvsp[-2].pTypeDecl)->temporary = false; - (yyvsp[-2].pTypeDecl)->removeTemporary = true; - (yyval.pTypeDecl) = (yyvsp[-2].pTypeDecl); - } - break; - - case 846: /* type_declaration_no_options: type_declaration_no_options "==" "const" */ - { - (yyvsp[-2].pTypeDecl)->explicitConst = true; - (yyval.pTypeDecl) = (yyvsp[-2].pTypeDecl); - } - break; - - case 847: /* type_declaration_no_options: type_declaration_no_options "==" '&' */ - { - (yyvsp[-2].pTypeDecl)->explicitRef = true; - (yyval.pTypeDecl) = (yyvsp[-2].pTypeDecl); - } - break; - - case 848: /* type_declaration_no_options: type_declaration_no_options '?' */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tPointer); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-1])); - (yyval.pTypeDecl)->firstType = (yyvsp[-1].pTypeDecl); - } - break; - - case 849: /* $@52: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 850: /* $@53: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 851: /* type_declaration_no_options: "smart_ptr" '<' $@52 type_declaration '>' $@53 */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tPointer); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-5])); - (yyval.pTypeDecl)->smartPtr = true; - (yyval.pTypeDecl)->firstType = (yyvsp[-2].pTypeDecl); - } - break; - - case 852: /* type_declaration_no_options: type_declaration_no_options "??" */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tPointer); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-1])); - (yyval.pTypeDecl)->firstType = new TypeDecl(Type::tPointer); - (yyval.pTypeDecl)->firstType->at = tokAt(scanner,(yylsp[-1])); - (yyval.pTypeDecl)->firstType->firstType = (yyvsp[-1].pTypeDecl); - } - break; - - case 853: /* $@54: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 854: /* $@55: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 855: /* type_declaration_no_options: "array" '<' $@54 type_declaration '>' $@55 */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tArray); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-5])); - (yyval.pTypeDecl)->firstType = (yyvsp[-2].pTypeDecl); - } - break; - - case 856: /* $@56: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 857: /* $@57: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 858: /* type_declaration_no_options: "table" '<' $@56 table_type_pair '>' $@57 */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tTable); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-5])); - (yyval.pTypeDecl)->firstType = (yyvsp[-2].aTypePair).firstType; - (yyval.pTypeDecl)->secondType = (yyvsp[-2].aTypePair).secondType; - } - break; - - case 859: /* $@58: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 860: /* $@59: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 861: /* type_declaration_no_options: "iterator" '<' $@58 type_declaration '>' $@59 */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tIterator); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-5])); - (yyval.pTypeDecl)->firstType = (yyvsp[-2].pTypeDecl); - } - break; - - case 862: /* type_declaration_no_options: "block" */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tBlock); - (yyval.pTypeDecl)->firstType = new TypeDecl(Type::tVoid); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[0])); - } - break; - - case 863: /* $@60: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 864: /* $@61: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 865: /* type_declaration_no_options: "block" '<' $@60 type_declaration '>' $@61 */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tBlock); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-5])); - (yyval.pTypeDecl)->firstType = (yyvsp[-2].pTypeDecl); - } - break; - - case 866: /* $@62: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 867: /* $@63: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 868: /* type_declaration_no_options: "block" '<' $@62 optional_function_argument_list optional_function_type '>' $@63 */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tBlock); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-6])); - (yyval.pTypeDecl)->firstType = (yyvsp[-2].pTypeDecl); - if ( (yyvsp[-3].pVarDeclList) ) { - varDeclToTypeDecl(scanner, (yyval.pTypeDecl), (yyvsp[-3].pVarDeclList)); - deleteVariableDeclarationList((yyvsp[-3].pVarDeclList)); - } - } - break; - - case 869: /* type_declaration_no_options: "function" */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tFunction); - (yyval.pTypeDecl)->firstType = new TypeDecl(Type::tVoid); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[0])); - } - break; - - case 870: /* $@64: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 871: /* $@65: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 872: /* type_declaration_no_options: "function" '<' $@64 type_declaration '>' $@65 */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tFunction); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-5])); - (yyval.pTypeDecl)->firstType = (yyvsp[-2].pTypeDecl); - } - break; - - case 873: /* $@66: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 874: /* $@67: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 875: /* type_declaration_no_options: "function" '<' $@66 optional_function_argument_list optional_function_type '>' $@67 */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tFunction); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-6])); - (yyval.pTypeDecl)->firstType = (yyvsp[-2].pTypeDecl); - if ( (yyvsp[-3].pVarDeclList) ) { - varDeclToTypeDecl(scanner, (yyval.pTypeDecl), (yyvsp[-3].pVarDeclList)); - deleteVariableDeclarationList((yyvsp[-3].pVarDeclList)); - } - } - break; - - case 876: /* type_declaration_no_options: "lambda" */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tLambda); - (yyval.pTypeDecl)->firstType = new TypeDecl(Type::tVoid); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[0])); - } - break; - - case 877: /* $@68: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 878: /* $@69: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 879: /* type_declaration_no_options: "lambda" '<' $@68 type_declaration '>' $@69 */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tLambda); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-5])); - (yyval.pTypeDecl)->firstType = (yyvsp[-2].pTypeDecl); - } - break; - - case 880: /* $@70: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 881: /* $@71: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 882: /* type_declaration_no_options: "lambda" '<' $@70 optional_function_argument_list optional_function_type '>' $@71 */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tLambda); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-6])); - (yyval.pTypeDecl)->firstType = (yyvsp[-2].pTypeDecl); - if ( (yyvsp[-3].pVarDeclList) ) { - varDeclToTypeDecl(scanner, (yyval.pTypeDecl), (yyvsp[-3].pVarDeclList)); - deleteVariableDeclarationList((yyvsp[-3].pVarDeclList)); - } - } - break; - - case 883: /* $@72: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 884: /* $@73: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 885: /* type_declaration_no_options: "tuple" '<' $@72 tuple_type_list '>' $@73 */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tTuple); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-5])); - varDeclToTypeDecl(scanner, (yyval.pTypeDecl), (yyvsp[-2].pVarDeclList), true); - deleteVariableDeclarationList((yyvsp[-2].pVarDeclList)); - } - break; - - case 886: /* $@74: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 887: /* $@75: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 888: /* type_declaration_no_options: "variant" '<' $@74 variant_type_list '>' $@75 */ - { - (yyval.pTypeDecl) = new TypeDecl(Type::tVariant); - (yyval.pTypeDecl)->at = tokAt(scanner,(yylsp[-5])); - varDeclToTypeDecl(scanner, (yyval.pTypeDecl), (yyvsp[-2].pVarDeclList), true); - deleteVariableDeclarationList((yyvsp[-2].pVarDeclList)); - } - break; - - case 889: /* type_declaration: type_declaration_no_options */ - { - (yyval.pTypeDecl) = (yyvsp[0].pTypeDecl); - } - break; - - case 890: /* type_declaration: type_declaration '|' type_declaration_no_options */ - { - if ( (yyvsp[-2].pTypeDecl)->baseType==Type::option ) { - (yyval.pTypeDecl) = (yyvsp[-2].pTypeDecl); - (yyval.pTypeDecl)->argTypes.push_back((yyvsp[0].pTypeDecl)); - } else { - (yyval.pTypeDecl) = new TypeDecl(Type::option); - (yyval.pTypeDecl)->at = tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])); - (yyval.pTypeDecl)->argTypes.push_back((yyvsp[-2].pTypeDecl)); - (yyval.pTypeDecl)->argTypes.push_back((yyvsp[0].pTypeDecl)); - } - } - break; - - case 891: /* type_declaration: type_declaration '|' '#' */ - { - if ( (yyvsp[-2].pTypeDecl)->baseType==Type::option ) { - (yyval.pTypeDecl) = (yyvsp[-2].pTypeDecl); - (yyval.pTypeDecl)->argTypes.push_back(new TypeDecl(*(yyvsp[-2].pTypeDecl)->argTypes.back())); - (yyvsp[-2].pTypeDecl)->argTypes.back()->temporary ^= true; - } else { - (yyval.pTypeDecl) = new TypeDecl(Type::option); - (yyval.pTypeDecl)->at = tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])); - (yyval.pTypeDecl)->argTypes.push_back((yyvsp[-2].pTypeDecl)); - (yyval.pTypeDecl)->argTypes.push_back(new TypeDecl(*(yyvsp[-2].pTypeDecl))); - (yyval.pTypeDecl)->argTypes.back()->temporary ^= true; - } - } - break; - - case 892: /* $@76: %empty */ - { yyextra->das_need_oxford_comma=false; } - break; - - case 893: /* $@77: %empty */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[0])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeTuple(atvname); - } - } - break; - - case 894: /* $@78: %empty */ - { - if (format::is_replace_braces() && (yyvsp[0].ui) != 0xdeadbeef && format::prepare_rule(format::Pos::from(tokAt(scanner, (yylsp[0]))))) { - format::get_writer() << " {"; - format::finish_rule(format::Pos::from(tokAt(scanner,(yylsp[0])))); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[-2])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeTupleEntries(atvname); - } - } - break; - - case 895: /* $@79: %empty */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[-4])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterTupleEntries(atvname); - } - } - break; - - case 896: /* tuple_alias_declaration: "tuple" optional_public_or_private_alias $@76 "name" $@77 open_block $@78 tuple_alias_type_list $@79 close_block */ - { - if (format::is_replace_braces() && (yyvsp[-4].ui) != 0xdeadbeef && format::prepare_rule(format::Pos::from(tokAt(scanner, (yylsp[0]))))) { - format::get_writer() << "\n" << string((yyvsp[0].ui) * yyextra->das_tab_size, ' ') + "}"; - format::finish_rule(format::Pos::from(tokAt(scanner,(yylsp[0])))); - } - auto vtype = new TypeDecl(Type::tTuple); - vtype->alias = *(yyvsp[-6].s); - vtype->at = tokAt(scanner,(yylsp[-6])); - vtype->isPrivateAlias = !(yyvsp[-8].b); - varDeclToTypeDecl(scanner, vtype, (yyvsp[-2].pVarDeclList), true); - deleteVariableDeclarationList((yyvsp[-2].pVarDeclList)); - if ( !yyextra->g_Program->addAlias(vtype) ) { - das_yyerror(scanner,"type alias is already defined "+*(yyvsp[-6].s),tokAt(scanner,(yylsp[-6])), - CompilationError::type_alias_already_declared); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[-6])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterTuple((yyvsp[-6].s)->c_str(),atvname); - } - delete (yyvsp[-6].s); - } - break; - - case 897: /* $@80: %empty */ - { yyextra->das_need_oxford_comma=false; } - break; - - case 898: /* $@81: %empty */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[0])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeVariant(atvname); - } - } - break; - - case 899: /* $@82: %empty */ - { - if (format::is_replace_braces() && (yyvsp[0].ui) != 0xdeadbeef && format::prepare_rule(format::Pos::from(tokAt(scanner, (yylsp[0]))))) { - format::get_writer() << " {"; - format::finish_rule(format::Pos::from(tokAt(scanner,(yylsp[0])))); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[-2])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeVariantEntries(atvname); - } - - } - break; - - case 900: /* $@83: %empty */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[-4])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterVariantEntries(atvname); - } - } - break; - - case 901: /* variant_alias_declaration: "variant" optional_public_or_private_alias $@80 "name" $@81 open_block $@82 variant_alias_type_list $@83 close_block */ - { - if (format::is_replace_braces() && (yyvsp[0].ui) != 0xdeadbeef && format::prepare_rule(format::Pos::from(tokAt(scanner, (yylsp[0]))))) { - format::get_writer() << "\n" << string((yyvsp[0].ui) * yyextra->das_tab_size, ' ') + "}"; - format::finish_rule(format::Pos::from(tokAt(scanner,(yylsp[0])))); - } - auto vtype = new TypeDecl(Type::tVariant); - vtype->alias = *(yyvsp[-6].s); - vtype->at = tokAt(scanner,(yylsp[-6])); - vtype->isPrivateAlias = !(yyvsp[-8].b); - varDeclToTypeDecl(scanner, vtype, (yyvsp[-2].pVarDeclList), true); - deleteVariableDeclarationList((yyvsp[-2].pVarDeclList)); - if ( !yyextra->g_Program->addAlias(vtype) ) { - das_yyerror(scanner,"type alias is already defined "+*(yyvsp[-6].s),tokAt(scanner,(yylsp[-6])), - CompilationError::type_alias_already_declared); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[-6])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterVariant((yyvsp[-6].s)->c_str(),atvname); - } - delete (yyvsp[-6].s); - } - break; - - case 902: /* $@84: %empty */ - { yyextra->das_need_oxford_comma=false; } - break; - - case 903: /* $@85: %empty */ - { - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[0])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeBitfield(atvname); - } - } - break; - - case 904: /* bitfield_alias_declaration: "bitfield" optional_public_or_private_alias $@84 "name" $@85 bitfield_basic_type_declaration open_block bitfield_alias_bits close_block */ - { - const auto prev_loc = format::Pos::from(tokAt(scanner,(yylsp[-2]))); - handle_brace(prev_loc, (yyvsp[-2].ui), - format::get_substring(prev_loc, format::Pos::from_last(tokAt(scanner,(yylsp[-1])))), - yyextra->das_tab_size, - format::Pos::from_last(tokAt(scanner,(yylsp[-1])))); - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[-5])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeBitfieldEntries(atvname); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[-5])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfieldEntries(atvname); - } - auto btype = new TypeDecl((yyvsp[-3].type)); - btype->alias = *(yyvsp[-5].s); - btype->at = tokAt(scanner,(yylsp[-5])); - btype->isPrivateAlias = !(yyvsp[-7].b); - for ( auto & p : *(yyvsp[-1].pNameExprList) ) { - if ( !get<1>(p) ) { - btype->argNames.push_back(get<0>(p)); - } - } - auto maxBits = btype->maxBitfieldBits(); - if ( btype->argNames.size()>maxBits ) { - das_yyerror(scanner,"only " + to_string(maxBits) + " different bits are allowed in a bitfield",tokAt(scanner,(yylsp[-5])), - CompilationError::invalid_type); - } - for ( auto & p : *(yyvsp[-1].pNameExprList) ) { - if ( get<1>(p) ) { - ast_globalBitfieldConst ( scanner, btype, (yyvsp[-7].b), get<0>(p), get<1>(p) ); - } - } - if ( !yyextra->g_Program->addAlias(btype) ) { - das_yyerror(scanner,"type alias is already defined "+*(yyvsp[-5].s),tokAt(scanner,(yylsp[-5])), - CompilationError::type_alias_already_declared); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,(yylsp[-5])); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfield((yyvsp[-5].s)->c_str(),atvname); - } - delete (yyvsp[-5].s); - delete (yyvsp[-1].pNameExprList); - } - break; - - case 905: /* make_decl: make_struct_decl */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 906: /* make_decl: make_dim_decl */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 907: /* make_decl: make_table_decl */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 908: /* make_decl: array_comprehension */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 909: /* make_decl: make_tuple_call */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 910: /* make_struct_fields: "name" copy_or_move expr */ - { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),*(yyvsp[-2].s),(yyvsp[0].pExpression),(yyvsp[-1].b),false); - delete (yyvsp[-2].s); - auto msd = new MakeStruct(); - msd->push_back(mfd); - (yyval.pMakeStruct) = msd; - } - break; - - case 911: /* make_struct_fields: "name" ":=" expr */ - { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),*(yyvsp[-2].s),(yyvsp[0].pExpression),false,true); - delete (yyvsp[-2].s); - auto msd = new MakeStruct(); - msd->push_back(mfd); - (yyval.pMakeStruct) = msd; - } - break; - - case 912: /* make_struct_fields: make_struct_fields ',' "name" copy_or_move expr */ - { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),*(yyvsp[-2].s),(yyvsp[0].pExpression),(yyvsp[-1].b),false); - delete (yyvsp[-2].s); - ((MakeStruct *)(yyvsp[-4].pMakeStruct))->push_back(mfd); - (yyval.pMakeStruct) = (yyvsp[-4].pMakeStruct); - } - break; - - case 913: /* make_struct_fields: make_struct_fields ',' "name" ":=" expr */ - { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0])),*(yyvsp[-2].s),(yyvsp[0].pExpression),false,true); - delete (yyvsp[-2].s); - ((MakeStruct *)(yyvsp[-4].pMakeStruct))->push_back(mfd); - (yyval.pMakeStruct) = (yyvsp[-4].pMakeStruct); - } - break; - - case 914: /* make_struct_fields: "$f" '(' expr2 ')' copy_or_move expr */ - { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner,(yylsp[-5]), (yylsp[0])),"``MACRO``TAG``FIELD``",(yyvsp[0].pExpression),(yyvsp[-1].b),false); - mfd->tag = (yyvsp[-3].pExpression); - auto msd = new MakeStruct(); - msd->push_back(mfd); - (yyval.pMakeStruct) = msd; - } - break; - - case 915: /* make_struct_fields: "$f" '(' expr2 ')' ":=" expr */ - { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner, (yylsp[-5]), (yylsp[0])),"``MACRO``TAG``FIELD``",(yyvsp[0].pExpression),false,true); - mfd->tag = (yyvsp[-3].pExpression); - auto msd = new MakeStruct(); - msd->push_back(mfd); - (yyval.pMakeStruct) = msd; - } - break; - - case 916: /* make_struct_fields: make_struct_fields ',' "$f" '(' expr2 ')' copy_or_move expr */ - { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner,(yylsp[-5]),(yylsp[0])),"``MACRO``TAG``FIELD``",(yyvsp[0].pExpression),(yyvsp[-1].b),false); - mfd->tag = (yyvsp[-3].pExpression); - ((MakeStruct *)(yyvsp[-7].pMakeStruct))->push_back(mfd); - (yyval.pMakeStruct) = (yyvsp[-7].pMakeStruct); - } - break; - - case 917: /* make_struct_fields: make_struct_fields ',' "$f" '(' expr2 ')' ":=" expr */ - { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner,(yylsp[-5]), (yylsp[0])),"``MACRO``TAG``FIELD``",(yyvsp[0].pExpression),false,true); - mfd->tag = (yyvsp[-3].pExpression); - ((MakeStruct *)(yyvsp[-7].pMakeStruct))->push_back(mfd); - (yyval.pMakeStruct) = (yyvsp[-7].pMakeStruct); - } - break; - - case 918: /* make_variant_dim: %empty */ - { - (yyval.pExpression) = ast_makeStructToMakeVariant(nullptr, LineInfo()); - } - break; - - case 919: /* make_variant_dim: make_struct_fields */ - { - (yyval.pExpression) = ast_makeStructToMakeVariant((yyvsp[0].pMakeStruct), tokAt(scanner,(yylsp[0]))); - } - break; - - case 920: /* make_struct_single: make_struct_fields optional_comma */ - { - auto msd = new ExprMakeStruct(); - msd->structs.push_back(MakeStructPtr((yyvsp[-1].pMakeStruct))); - (yyval.pExpression) = msd; - } - break; - - case 921: /* make_struct_dim: make_struct_fields */ - { - auto msd = new ExprMakeStruct(); - msd->structs.push_back(MakeStructPtr((yyvsp[0].pMakeStruct))); - (yyval.pExpression) = msd; - } - break; - - case 922: /* make_struct_dim: make_struct_dim semicolon make_struct_fields */ - { - ((ExprMakeStruct *) (yyvsp[-2].pExpression))->structs.push_back(MakeStructPtr((yyvsp[0].pMakeStruct))); - (yyval.pExpression) = (yyvsp[-2].pExpression); - } - break; - - case 923: /* make_struct_dim_list: '(' make_struct_fields ')' */ - { - auto msd = new ExprMakeStruct(); - msd->structs.push_back(MakeStructPtr((yyvsp[-1].pMakeStruct))); - (yyval.pExpression) = msd; - } - break; - - case 924: /* make_struct_dim_list: make_struct_dim_list ',' '(' make_struct_fields ')' */ - { - ((ExprMakeStruct *) (yyvsp[-4].pExpression))->structs.push_back(MakeStructPtr((yyvsp[-1].pMakeStruct))); - (yyval.pExpression) = (yyvsp[-4].pExpression); - } - break; - - case 925: /* make_struct_dim_decl: make_struct_fields */ - { - auto msd = new ExprMakeStruct(); - msd->structs.push_back(MakeStructPtr((yyvsp[0].pMakeStruct))); - (yyval.pExpression) = msd; - } - break; - - case 926: /* make_struct_dim_decl: make_struct_dim_list optional_comma */ - { - (yyval.pExpression) = (yyvsp[-1].pExpression); - } - break; - - case 927: /* optional_make_struct_dim_decl: make_struct_dim_decl */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 928: /* optional_make_struct_dim_decl: %empty */ - { (yyval.pExpression) = new ExprMakeStruct(); } - break; - - case 929: /* optional_block: %empty */ - { (yyval.pExpression) = nullptr; } - break; - - case 930: /* optional_block: "where" expr_block */ - { (yyvsp[0].pExpression)->at = tokAt(scanner, (yylsp[0])); (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 943: /* use_initializer: %empty */ - { (yyval.b) = true; } - break; - - case 944: /* use_initializer: "uninitialized" */ - { (yyval.b) = false; } - break; - - case 945: /* make_struct_decl: "[[" type_declaration_no_options make_struct_dim optional_block optional_trailing_delim_sqr_sqr */ - { - // std::cout << "case1" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-4]))))) { - auto type = format::type_to_string((yyvsp[-3].pTypeDecl), tokAt(scanner,(yylsp[-3]))).value_or(""); - const bool is_initialized = false; - const auto before = format::substring_between(tokAt(scanner,(yylsp[-4])), tokAt(scanner, (yylsp[-3]))); - const auto internal = format::handle_msd(tokAt(scanner, (yylsp[-3])), - static_cast((yyvsp[-2].pExpression)), - tokAt(scanner, (yyvsp[-1].pExpression) != nullptr ? (yylsp[-1]) : (yylsp[0])), - type, is_initialized); - if (static_cast((yyvsp[-2].pExpression))->structs.size() == 1) { - // single struct - if (type.find('[') != size_t(-1)) { - format::get_writer() << "fixed_array(" << before << internal << ")"; - } else { - format::get_writer() << before << internal; - } - if ((yyvsp[-1].pExpression) != nullptr) { - format::get_writer() << " <| " << format::get_substring((yyvsp[-1].pExpression)->at); - } - } else { - // array of structs - // const auto internal = format::get_substring(format::Pos::from(tokAt(scanner,@msd)), - // format::Pos::from(tokAt(scanner,@end))); - format::get_writer() << "fixed_array(" << internal << ")"; - } - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - } - ((ExprMakeStruct *)(yyvsp[-2].pExpression))->makeType = (yyvsp[-3].pTypeDecl); - ((ExprMakeStruct *)(yyvsp[-2].pExpression))->block = (yyvsp[-1].pExpression); - (yyvsp[-2].pExpression)->at = tokAt(scanner,(yylsp[-4])); - (yyval.pExpression) = (yyvsp[-2].pExpression); - } - break; - - case 946: /* make_struct_decl: "[[" type_declaration_no_options optional_block optional_trailing_delim_sqr_sqr */ - { - // // std::cout << "case2" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-3]))))) { - auto type = format::type_to_string((yyvsp[-2].pTypeDecl), tokAt(scanner,(yylsp[-2]))); - das_hash_set always_init = { - // Is there a method to describe all this types? - "structisPointer()) { - format::get_writer() << "default<" << type.value() << ">"; - suffix.clear(); - } else if (any_of(always_init.begin(), always_init.end(), - [&type](auto t){ return type.value_or("").find(t) == 0; })) { - format::get_writer() << type.value_or("") << "("; - } else { - format::get_writer() << type.value_or("") << "("; // Possible uninitialized - } - format::get_writer() << before << after << suffix; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - } - - auto msd = new ExprMakeStruct(); - msd->makeType = (yyvsp[-2].pTypeDecl); - msd->block = (yyvsp[-1].pExpression); - msd->at = tokAt(scanner,(yylsp[-3])); - (yyval.pExpression) = msd; - } - break; - - case 947: /* make_struct_decl: "[[" type_declaration_no_options '(' ')' optional_block optional_trailing_delim_sqr_sqr */ - { - // std::cout << "case3" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-5]))))) { - const auto type_name = format::type_to_string((yyvsp[-4].pTypeDecl), tokAt(scanner,(yylsp[-4]))); - auto maybe_init = (format::can_default_init(type_name.value_or(""))) ? "" : ""; // Possible uninitialized - format::get_writer() << type_name.value_or("") << "(" - << format::substring_between(tokAt(scanner,(yylsp[-5])), tokAt(scanner, (yylsp[-4]))) - << format::substring_between(tokAt(scanner,(yylsp[-3])), tokAt(scanner, (yylsp[-2]))) - << format::substring_between(tokAt(scanner,(yylsp[-2])), tokAt(scanner, (yylsp[0]))) - << maybe_init << ")"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - } - auto msd = new ExprMakeStruct(); - msd->makeType = (yyvsp[-4].pTypeDecl); - msd->useInitializer = true; - msd->block = (yyvsp[-1].pExpression); - msd->at = tokAt(scanner,(yylsp[-5])); - (yyval.pExpression) = msd; - } - break; - - case 948: /* make_struct_decl: "[[" type_declaration_no_options '(' ')' make_struct_dim optional_block optional_trailing_delim_sqr_sqr */ - { - // std::cout << "case4" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-6]))))) { - auto type_name = format::type_to_string((yyvsp[-5].pTypeDecl), tokAt(scanner,(yylsp[-5]))).value_or(""); - const auto internal = format::handle_msd(tokAt(scanner, (yylsp[-3])), - static_cast((yyvsp[-2].pExpression)), - tokAt(scanner, (yylsp[0])), - type_name); - format::get_writer() << format::substring_between(tokAt(scanner, (yylsp[-6])), tokAt(scanner, (yylsp[-5]))) - << format::substring_between(tokAt(scanner, (yylsp[-4])), tokAt(scanner, (yylsp[-3]))) - << internal; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - } - - ((ExprMakeStruct *)(yyvsp[-2].pExpression))->makeType = (yyvsp[-5].pTypeDecl); - ((ExprMakeStruct *)(yyvsp[-2].pExpression))->useInitializer = true; - ((ExprMakeStruct *)(yyvsp[-2].pExpression))->block = (yyvsp[-1].pExpression); - (yyvsp[-2].pExpression)->at = tokAt(scanner,(yylsp[-6])); - (yyval.pExpression) = (yyvsp[-2].pExpression); - } - break; - - case 949: /* make_struct_decl: "[{" type_declaration_no_options make_struct_dim optional_block optional_trailing_delim_cur_sqr */ - { - // std::cout << "case6" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-4]))))) { - auto type_name = format::type_to_string((yyvsp[-3].pTypeDecl), tokAt(scanner,(yylsp[-3]))).value_or(""); - format::get_writer() << "[" << format::substring_between(tokAt(scanner, (yylsp[-4])), tokAt(scanner, (yylsp[-3]))) - << format::handle_msd(tokAt(scanner, (yylsp[-3])), - static_cast((yyvsp[-2].pExpression)), - tokAt(scanner, (yylsp[0])), - type_name) - << "]"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - } - - ((ExprMakeStruct *)(yyvsp[-2].pExpression))->makeType = (yyvsp[-3].pTypeDecl); - ((ExprMakeStruct *)(yyvsp[-2].pExpression))->block = (yyvsp[-1].pExpression); - (yyvsp[-2].pExpression)->at = tokAt(scanner,(yylsp[-4])); - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-4])),"to_array_move"); - tam->arguments.push_back((yyvsp[-2].pExpression)); - (yyval.pExpression) = tam; - } - break; - - case 950: /* make_struct_decl: "[{" type_declaration_no_options '(' ')' make_struct_dim optional_block optional_trailing_delim_cur_sqr */ - { - // std::cout << "case7" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-6]))))) { - auto type_name = format::type_to_string((yyvsp[-5].pTypeDecl), tokAt(scanner,(yylsp[-5]))).value_or(""); - format::get_writer() << "[" << format::substring_between(tokAt(scanner, (yylsp[-6])), tokAt(scanner, (yylsp[-5]))) - << format::handle_msd(tokAt(scanner, (yylsp[-3])), - static_cast((yyvsp[-2].pExpression)), - tokAt(scanner, (yylsp[0])), - type_name) - << "]"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - } - - ((ExprMakeStruct *)(yyvsp[-2].pExpression))->makeType = (yyvsp[-5].pTypeDecl); - ((ExprMakeStruct *)(yyvsp[-2].pExpression))->useInitializer = true; - ((ExprMakeStruct *)(yyvsp[-2].pExpression))->block = (yyvsp[-1].pExpression); - (yyvsp[-2].pExpression)->at = tokAt(scanner,(yylsp[-6])); - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-6])),"to_array_move"); - tam->arguments.push_back((yyvsp[-2].pExpression)); - (yyval.pExpression) = tam; - } - break; - - case 951: /* $@86: %empty */ - { yyextra->das_force_oxford_comma=true; yyextra->das_arrow_depth ++; } - break; - - case 952: /* $@87: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 953: /* make_struct_decl: "struct" '<' $@86 type_declaration_no_options '>' $@87 '(' use_initializer optional_make_struct_dim_decl ')' */ - { - (yyvsp[-1].pExpression)->at = tokAt(scanner,(yylsp[-9])); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->makeType = (yyvsp[-6].pTypeDecl); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->useInitializer = (yyvsp[-2].b); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->forceStruct = true; - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->alwaysUseInitializer = true; - (yyval.pExpression) = (yyvsp[-1].pExpression); - } - break; - - case 954: /* $@88: %empty */ - { yyextra->das_force_oxford_comma=true; yyextra->das_arrow_depth ++; } - break; - - case 955: /* $@89: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 956: /* make_struct_decl: "class" '<' $@88 type_declaration_no_options '>' $@89 '(' use_initializer optional_make_struct_dim_decl ')' */ - { - (yyvsp[-1].pExpression)->at = tokAt(scanner,(yylsp[-9])); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->makeType = (yyvsp[-6].pTypeDecl); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->useInitializer = (yyvsp[-2].b); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->forceClass = true; - (yyval.pExpression) = (yyvsp[-1].pExpression); - } - break; - - case 957: /* $@90: %empty */ - { yyextra->das_force_oxford_comma=true; yyextra->das_arrow_depth ++; } - break; - - case 958: /* $@91: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 959: /* make_struct_decl: "variant" '<' $@90 variant_type_list '>' $@91 '(' use_initializer make_variant_dim ')' */ - { - auto mkt = new TypeDecl(Type::tVariant); - mkt->at = tokAt(scanner,(yylsp[-9])); - varDeclToTypeDecl(scanner, mkt, (yyvsp[-6].pVarDeclList), true); - deleteVariableDeclarationList((yyvsp[-6].pVarDeclList)); - (yyvsp[-1].pExpression)->at = tokAt(scanner,(yylsp[-9])); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->makeType = mkt; - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->useInitializer = (yyvsp[-2].b); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->forceVariant = true; - (yyval.pExpression) = (yyvsp[-1].pExpression); - } - break; - - case 960: /* $@92: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 961: /* $@93: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 962: /* make_struct_decl: "default" '<' $@92 type_declaration_no_options '>' $@93 use_initializer */ - { - auto msd = new ExprMakeStruct(); - msd->at = tokAt(scanner,(yylsp[-6])); - msd->makeType = (yyvsp[-3].pTypeDecl); - msd->useInitializer = (yyvsp[0].b); - msd->alwaysUseInitializer = true; - (yyval.pExpression) = msd; - } - break; - - case 963: /* make_tuple: expr */ - { - (yyvsp[0].pExpression)->at = tokAt(scanner,(yylsp[0])); - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 964: /* make_tuple: expr "=>" expr */ - { - ExprMakeTuple * mt = new ExprMakeTuple(tokRangeAt(scanner,(yylsp[-2]), (yylsp[0]))); - mt->values.push_back((yyvsp[-2].pExpression)); - mt->values.push_back((yyvsp[0].pExpression)); - (yyval.pExpression) = mt; - } - break; - - case 965: /* make_tuple: make_tuple ',' expr */ - { - (yyvsp[0].pExpression)->at = tokAt(scanner,(yylsp[0])); - ExprMakeTuple * mt; - if ( (yyvsp[-2].pExpression)->rtti_isMakeTuple() ) { - mt = static_cast((yyvsp[-2].pExpression)); - } else { - mt = new ExprMakeTuple(tokAt(scanner,(yylsp[-2]))); - mt->values.push_back((yyvsp[-2].pExpression)); - } - mt->values.push_back((yyvsp[0].pExpression)); - mt->at = format::concat(mt->at, tokAt(scanner, (yylsp[0]))); - (yyval.pExpression) = mt; - } - break; - - case 966: /* make_map_tuple: expr "=>" expr */ - { - ExprMakeTuple * mt = new ExprMakeTuple(tokRangeAt(scanner,(yylsp[-2]),(yylsp[0]))); - mt->values.push_back((yyvsp[-2].pExpression)); - mt->values.push_back((yyvsp[0].pExpression)); - (yyval.pExpression) = mt; - } - break; - - case 967: /* make_map_tuple: expr */ - { - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 968: /* make_tuple_call: "tuple" '(' expr_list optional_comma ')' */ - { - auto mkt = new ExprMakeTuple(tokAt(scanner,(yylsp[-4]))); - mkt->values = sequenceToList((yyvsp[-2].pExpression)); - mkt->makeType = new TypeDecl(Type::autoinfer); - (yyval.pExpression) = mkt; - } - break; - - case 969: /* $@94: %empty */ - { yyextra->das_force_oxford_comma=true; yyextra->das_arrow_depth ++; } - break; - - case 970: /* $@95: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 971: /* make_tuple_call: "tuple" '<' $@94 tuple_type_list '>' $@95 '(' use_initializer optional_make_struct_dim_decl ')' */ - { - auto mkt = new TypeDecl(Type::tTuple); - mkt->at = tokAt(scanner,(yylsp[-9])); - varDeclToTypeDecl(scanner, mkt, (yyvsp[-6].pVarDeclList), true); - deleteVariableDeclarationList((yyvsp[-6].pVarDeclList)); - (yyvsp[-1].pExpression)->at = tokAt(scanner,(yylsp[-9])); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->makeType = mkt; - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->useInitializer = (yyvsp[-2].b); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->forceTuple = true; - (yyval.pExpression) = (yyvsp[-1].pExpression); - } - break; - - case 972: /* make_dim: make_tuple */ - { - auto mka = new ExprMakeArray(); - mka->values.push_back((yyvsp[0].pExpression)); - (yyval.pExpression) = mka; - } - break; - - case 973: /* make_dim: make_dim semicolon make_tuple */ - { - ((ExprMakeArray *) (yyvsp[-2].pExpression))->values.push_back((yyvsp[0].pExpression)); - (yyval.pExpression) = (yyvsp[-2].pExpression); - } - break; - - case 974: /* make_dim_decl: '[' optional_expr_list ']' */ - { - if ( (yyvsp[-1].pExpression) ) { - auto mka = new ExprMakeArray(tokAt(scanner,(yylsp[-2]))); - mka->values = sequenceToList((yyvsp[-1].pExpression)); - mka->makeType = new TypeDecl(Type::autoinfer); - mka->gen2 = true; - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-2])),"to_array_move"); - tam->arguments.push_back(mka); - (yyval.pExpression) = tam; - } else { - auto mks = new ExprMakeStruct(); - mks->at = tokAt(scanner,(yylsp[-2])); - mks->makeType = new TypeDecl(Type::tArray); - mks->makeType->firstType = new TypeDecl(Type::autoinfer); - mks->useInitializer = true; - mks->alwaysUseInitializer = true; - (yyval.pExpression) = mks; - } - - } - break; - - case 975: /* make_dim_decl: "[[" type_declaration_no_options make_dim optional_trailing_semicolon_sqr_sqr */ - { - // std::cout << "case13" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-3]))))) { - auto type_name = format::type_to_string((yyvsp[-2].pTypeDecl), tokAt(scanner,(yylsp[-2]))); - auto internal = format::handle_mka(tokAt(scanner, (yylsp[-2])), - static_cast((yyvsp[-1].pExpression)), - tokAt(scanner, (yylsp[0]))); - const auto before = format::substring_between(tokAt(scanner, (yylsp[-3])), tokAt(scanner, (yylsp[-2]))); - if (static_cast((yyvsp[-1].pExpression))->values.size() == 1) { - // single element - if (type_name.value_or("").find('[') != size_t(-1)) { - format::get_writer() << "fixed_array(" << before << internal << ")"; - } else { - format::get_writer() << before << internal; - } - } else { - format::get_writer() << "fixed_array"; - if (!(yyvsp[-2].pTypeDecl)->isAuto()) { - format::get_writer() << "<" << type_name.value().substr(0, type_name.value().find('[')) << ">"; - } - format::get_writer() << "(" << before << internal << ")"; - } - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - } - ((ExprMakeArray *)(yyvsp[-1].pExpression))->makeType = (yyvsp[-2].pTypeDecl); - (yyvsp[-1].pExpression)->at = tokAt(scanner,(yylsp[-3])); - (yyval.pExpression) = (yyvsp[-1].pExpression); - } - break; - - case 976: /* make_dim_decl: "[{" type_declaration_no_options make_dim optional_trailing_semicolon_cur_sqr */ - { - // std::cout << "case8" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-3]))))) { - string prefix = "["; - string suffix = "]"; - if (!(yyvsp[-2].pTypeDecl)->isAuto()) { - prefix = "array<" + format::get_substring(tokAt(scanner,(yylsp[-2]))) + ">("; - suffix = ")"; - } - format::get_writer() << prefix - << format::substring_between(tokAt(scanner, (yylsp[-3])), tokAt(scanner, (yylsp[-2]))) - << format::handle_mka(tokAt(scanner, (yylsp[-2])), - static_cast((yyvsp[-1].pExpression)), - tokAt(scanner, (yylsp[0]))) - << suffix; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - } - - ((ExprMakeArray *)(yyvsp[-1].pExpression))->makeType = (yyvsp[-2].pTypeDecl); - (yyvsp[-1].pExpression)->at = tokAt(scanner,(yylsp[-3])); - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-3])),"to_array_move"); - tam->arguments.push_back((yyvsp[-1].pExpression)); - (yyval.pExpression) = tam; - } - break; - - case 977: /* $@96: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 978: /* $@97: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 979: /* make_dim_decl: "array" "struct" '<' $@96 type_declaration_no_options '>' $@97 '(' use_initializer optional_make_struct_dim_decl ')' */ - { - (yyvsp[-1].pExpression)->at = tokAt(scanner,(yylsp[-10])); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->makeType = (yyvsp[-6].pTypeDecl); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->useInitializer = (yyvsp[-2].b); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->forceStruct = true; - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->alwaysUseInitializer = true; - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-10])),"to_array_move"); - tam->arguments.push_back((yyvsp[-1].pExpression)); - (yyval.pExpression) = tam; - } - break; - - case 980: /* $@98: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 981: /* $@99: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 982: /* make_dim_decl: "array" "tuple" '<' $@98 tuple_type_list '>' $@99 '(' use_initializer optional_make_struct_dim_decl ')' */ - { - auto mkt = new TypeDecl(Type::tTuple); - mkt->at = tokAt(scanner,(yylsp[-10])); - varDeclToTypeDecl(scanner, mkt, (yyvsp[-6].pVarDeclList), true); - deleteVariableDeclarationList((yyvsp[-6].pVarDeclList)); - (yyvsp[-1].pExpression)->at = tokAt(scanner,(yylsp[-10])); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->makeType = mkt; - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->useInitializer = (yyvsp[-2].b); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->forceTuple = true; - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->alwaysUseInitializer = true; - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-10])),"to_array_move"); - tam->arguments.push_back((yyvsp[-1].pExpression)); - (yyval.pExpression) = tam; - } - break; - - case 983: /* $@100: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 984: /* $@101: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 985: /* make_dim_decl: "array" "variant" '<' $@100 variant_type_list '>' $@101 '(' make_variant_dim ')' */ - { - auto mkt = new TypeDecl(Type::tVariant); - mkt->at = tokAt(scanner,(yylsp[-9])); - varDeclToTypeDecl(scanner, mkt, (yyvsp[-5].pVarDeclList), true); - deleteVariableDeclarationList((yyvsp[-5].pVarDeclList)); - (yyvsp[-1].pExpression)->at = tokAt(scanner,(yylsp[-9])); - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->makeType = mkt; - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->useInitializer = true; - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->forceVariant = true; - ((ExprMakeStruct *)(yyvsp[-1].pExpression))->alwaysUseInitializer = true; - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-9])),"to_array_move"); - tam->arguments.push_back((yyvsp[-1].pExpression)); - (yyval.pExpression) = tam; - } - break; - - case 986: /* make_dim_decl: "array" '(' expr_list optional_comma ')' */ - { - auto mka = new ExprMakeArray(tokAt(scanner,(yylsp[-4]))); - mka->values = sequenceToList((yyvsp[-2].pExpression)); - mka->makeType = new TypeDecl(Type::autoinfer); - mka->gen2 = true; - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-4])),"to_array_move"); - tam->arguments.push_back(mka); - (yyval.pExpression) = tam; - } - break; - - case 987: /* $@102: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 988: /* $@103: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 989: /* make_dim_decl: "array" '<' $@102 type_declaration_no_options '>' $@103 '(' optional_expr_list ')' */ - { - if ( (yyvsp[-1].pExpression) ) { - auto mka = new ExprMakeArray(tokAt(scanner,(yylsp[-8]))); - mka->values = sequenceToList((yyvsp[-1].pExpression)); - mka->makeType = (yyvsp[-5].pTypeDecl); - mka->gen2 = true; - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-8])),"to_array_move"); - tam->arguments.push_back(mka); - (yyval.pExpression) = tam; - } else { - auto msd = new ExprMakeStruct(); - msd->at = tokAt(scanner,(yylsp[-8])); - msd->makeType = new TypeDecl(Type::tArray); - msd->makeType->firstType = (yyvsp[-5].pTypeDecl); - msd->at = tokAt(scanner,(yylsp[-5])); - msd->useInitializer = true; - msd->alwaysUseInitializer = true; - (yyval.pExpression) = msd; - } - } - break; - - case 990: /* make_dim_decl: "fixed_array" '(' expr_list optional_comma ')' */ - { - auto mka = new ExprMakeArray(tokAt(scanner,(yylsp[-4]))); - mka->values = sequenceToList((yyvsp[-2].pExpression)); - mka->makeType = new TypeDecl(Type::autoinfer); - mka->gen2 = true; - (yyval.pExpression) = mka; - } - break; - - case 991: /* $@104: %empty */ - { yyextra->das_arrow_depth ++; } - break; - - case 992: /* $@105: %empty */ - { yyextra->das_arrow_depth --; } - break; - - case 993: /* make_dim_decl: "fixed_array" '<' $@104 type_declaration_no_options '>' $@105 '(' expr_list optional_comma ')' */ - { - auto mka = new ExprMakeArray(tokAt(scanner,(yylsp[-9]))); - mka->values = sequenceToList((yyvsp[-2].pExpression)); - mka->makeType = (yyvsp[-6].pTypeDecl); - mka->gen2 = true; - (yyval.pExpression) = mka; - } - break; - - case 994: /* make_table: make_map_tuple */ - { - auto mka = new ExprMakeArray(); - mka->values.push_back((yyvsp[0].pExpression)); - (yyval.pExpression) = mka; - } - break; - - case 995: /* make_table: make_table semicolon make_map_tuple */ - { - ((ExprMakeArray *) (yyvsp[-2].pExpression))->values.push_back((yyvsp[0].pExpression)); - (yyval.pExpression) = (yyvsp[-2].pExpression); - } - break; - - case 996: /* expr_map_tuple_list: make_map_tuple */ - { - (yyval.pExpression) = (yyvsp[0].pExpression); - } - break; - - case 997: /* expr_map_tuple_list: expr_map_tuple_list ',' make_map_tuple */ - { - (yyval.pExpression) = new ExprSequence(tokAt(scanner,(yylsp[-2])),(yyvsp[-2].pExpression),(yyvsp[0].pExpression)); - } - break; - - case 998: /* make_table_decl: open_block optional_expr_map_tuple_list close_block */ - { - if ( (yyvsp[-1].pExpression) ) { - auto mka = new ExprMakeArray(tokAt(scanner,(yylsp[-2]))); - mka->values = sequenceToList((yyvsp[-1].pExpression)); - mka->makeType = new TypeDecl(Type::autoinfer); - auto ttm = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-2])),"to_table_move"); - ttm->arguments.push_back(mka); - (yyval.pExpression) = ttm; - } else { - auto mks = new ExprMakeStruct(); - mks->at = tokAt(scanner,(yylsp[-2])); - mks->makeType = new TypeDecl(Type::tTable); - mks->makeType->firstType = new TypeDecl(Type::autoinfer); - mks->makeType->secondType = new TypeDecl(Type::autoinfer); - mks->useInitializer = true; - mks->alwaysUseInitializer = true; - (yyval.pExpression) = mks; - } - - } - break; - - case 999: /* make_table_decl: "{{" make_table optional_trailing_semicolon_cur_cur */ - { - // std::cout << "case10" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-2]))))) { - format::get_writer() << "{" - << format::substring_between(tokAt(scanner, (yylsp[-2])), tokAt(scanner, (yylsp[-1]))) - << format::convert_to_string(((ExprMakeArray *)(yyvsp[-1].pExpression))->values, ",", ";") - << format::substring_between(tokAt(scanner, (yylsp[-1])), tokAt(scanner, (yylsp[0]))) - << "}"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - } - - auto mkt = new TypeDecl(Type::tFixedArray); - mkt->fixedDim = TypeDecl::dimAuto; - mkt->at = tokAt(scanner,(yylsp[-2])); - mkt->firstType = new TypeDecl(Type::autoinfer); - mkt->firstType->at = mkt->at; - ((ExprMakeArray *)(yyvsp[-1].pExpression))->makeType = mkt; - (yyvsp[-1].pExpression)->at = tokAt(scanner,(yylsp[-2])); - auto ttm = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-2])),"to_table_move"); - ttm->arguments.push_back((yyvsp[-1].pExpression)); - (yyval.pExpression) = ttm; - } - break; - - case 1000: /* make_table_decl: "table" '(' optional_expr_map_tuple_list ')' */ - { - auto mka = new ExprMakeArray(tokAt(scanner,(yylsp[-3]))); - mka->values = sequenceToList((yyvsp[-1].pExpression)); - mka->makeType = new TypeDecl(Type::autoinfer); - auto ttm = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-3])),"to_table_move"); - ttm->arguments.push_back(mka); - (yyval.pExpression) = ttm; - } - break; - - case 1001: /* make_table_decl: "table" '<' type_declaration_no_options '>' '(' optional_expr_map_tuple_list ')' */ - { - if ( (yyvsp[-1].pExpression) ) { - auto mka = new ExprMakeArray(tokAt(scanner,(yylsp[-6]))); - mka->values = sequenceToList((yyvsp[-1].pExpression)); - mka->makeType = (yyvsp[-4].pTypeDecl); - auto ttm = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-6])),"to_table_move"); - ttm->arguments.push_back(mka); - (yyval.pExpression) = ttm; - } else { - auto msd = new ExprMakeStruct(); - msd->at = tokAt(scanner,(yylsp[-6])); - msd->makeType = new TypeDecl(Type::tTable); - msd->makeType->firstType = (yyvsp[-4].pTypeDecl); - msd->makeType->secondType = new TypeDecl(Type::tVoid); - msd->at = tokAt(scanner,(yylsp[-6])); - msd->useInitializer = true; - msd->alwaysUseInitializer = true; - (yyval.pExpression) = msd; - } - } - break; - - case 1002: /* make_table_decl: "table" '<' type_declaration_no_options c_or_s type_declaration_no_options '>' '(' optional_expr_map_tuple_list ')' */ - { - if ( (yyvsp[-1].pExpression) ) { - auto mka = new ExprMakeArray(tokAt(scanner,(yylsp[-8]))); - mka->values = sequenceToList((yyvsp[-1].pExpression)); - mka->makeType = new TypeDecl(Type::tTuple); - mka->makeType->argTypes.push_back((yyvsp[-6].pTypeDecl)); - mka->makeType->argTypes.push_back((yyvsp[-4].pTypeDecl)); - auto ttm = yyextra->g_Program->makeCall(tokAt(scanner,(yylsp[-8])),"to_table_move"); - ttm->arguments.push_back(mka); - (yyval.pExpression) = ttm; - } else { - auto msd = new ExprMakeStruct(); - msd->at = tokAt(scanner,(yylsp[-8])); - msd->makeType = new TypeDecl(Type::tTable); - msd->makeType->firstType = (yyvsp[-6].pTypeDecl); - msd->makeType->secondType = (yyvsp[-4].pTypeDecl); - msd->at = tokAt(scanner,(yylsp[-8])); - msd->useInitializer = true; - msd->alwaysUseInitializer = true; - (yyval.pExpression) = msd; - } - } - break; - - case 1003: /* array_comprehension_where: %empty */ - { (yyval.pExpression) = nullptr; } - break; - - case 1004: /* array_comprehension_where: semicolon "where" expr */ - { (yyval.pExpression) = (yyvsp[0].pExpression); } - break; - - case 1005: /* optional_comma: %empty */ - { (yyval.b) = false; } - break; - - case 1006: /* optional_comma: ',' */ - { (yyval.b) = true; } - break; - - case 1007: /* array_comprehension: '[' "for" variable_name_with_pos_list "in" expr_list "end of expression" expr2 array_comprehension_where ']' */ - { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-6]))))) { - format::get_writer() << "(" << format::get_substring(format::Pos::from(tokAt(scanner,(yylsp[-6]))), - format::Pos::from_last(tokAt(scanner,(yylsp[-4])))) << ")"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[-4])))); - } - - (yyval.pExpression) = ast_arrayComprehension(scanner,tokAt(scanner,(yylsp[-7])),(yyvsp[-6].pNameWithPosList),(yyvsp[-4].pExpression),(yyvsp[-2].pExpression),(yyvsp[-1].pExpression),tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])),false,false); - } - break; - - case 1008: /* array_comprehension: '[' "for" '(' variable_name_with_pos_list "in" expr_list ')' "end of expression" expr2 array_comprehension_where ']' */ - { - (yyval.pExpression) = ast_arrayComprehension(scanner,tokAt(scanner,(yylsp[-9])),(yyvsp[-7].pNameWithPosList),(yyvsp[-5].pExpression),(yyvsp[-2].pExpression),(yyvsp[-1].pExpression),tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])),false,false); - } - break; - - case 1009: /* array_comprehension: '[' "iterator" "for" '(' variable_name_with_pos_list "in" expr_list ')' "end of expression" expr2 array_comprehension_where ']' */ - { - (yyval.pExpression) = ast_arrayComprehension(scanner,tokAt(scanner,(yylsp[-9])),(yyvsp[-7].pNameWithPosList),(yyvsp[-5].pExpression),(yyvsp[-2].pExpression),(yyvsp[-1].pExpression),tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])),true,false); - } - break; - - case 1010: /* array_comprehension: "begin of code block" "for" '(' variable_name_with_pos_list "in" expr_list ')' "end of expression" make_map_tuple array_comprehension_where "end of code block" */ - { - (yyval.pExpression) = ast_arrayComprehension(scanner,tokAt(scanner,(yylsp[-9])),(yyvsp[-7].pNameWithPosList),(yyvsp[-5].pExpression),(yyvsp[-2].pExpression),(yyvsp[-1].pExpression),tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])),false,true); - } - break; - - case 1011: /* array_comprehension: '[' "iterator" "for" variable_name_with_pos_list "in" expr_list "end of expression" expr2 array_comprehension_where ']' */ - { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-6]))))) { - format::get_writer() << "(" << format::get_substring(format::Pos::from(tokAt(scanner,(yylsp[-6]))), - format::Pos::from_last(tokAt(scanner,(yylsp[-4])))) << ")"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[-4])))); - } - (yyval.pExpression) = ast_arrayComprehension(scanner,tokAt(scanner,(yylsp[-7])),(yyvsp[-6].pNameWithPosList),(yyvsp[-4].pExpression),(yyvsp[-2].pExpression),(yyvsp[-1].pExpression),tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])),true,false); - } - break; - - case 1012: /* array_comprehension: "[[" "for" variable_name_with_pos_list "in" expr_list "end of expression" expr2 array_comprehension_where ']' ']' */ - { - // std::cout << "case5" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-9]))))) { - auto internal = format::get_substring(format::Pos::from(tokAt(scanner,(yylsp[-8]))), format::Pos::from_last(tokAt(scanner,(yylsp[-2])))); - format::get_writer() << "[iterator " << internal << "]"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - } - (yyval.pExpression) = ast_arrayComprehension(scanner,tokAt(scanner,(yylsp[-8])),(yyvsp[-7].pNameWithPosList),(yyvsp[-5].pExpression),(yyvsp[-3].pExpression),(yyvsp[-2].pExpression),tokRangeAt(scanner,(yylsp[-3]),(yylsp[0])),true,false); - } - break; - - case 1013: /* array_comprehension: "[{" "for" variable_name_with_pos_list "in" expr_list "end of expression" expr2 array_comprehension_where "end of code block" ']' */ - { - // std::cout << "case9" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-9]))))) { - auto internal = format::get_substring(format::Pos::from(tokAt(scanner,(yylsp[-8]))), format::Pos::from_last(tokAt(scanner,(yylsp[-2])))); - format::get_writer() << "[" << format::substring_between(tokAt(scanner, (yylsp[-9])), tokAt(scanner, (yylsp[-8]))) - << internal - << format::substring_between(tokAt(scanner, (yylsp[-2])), tokAt(scanner, (yylsp[-1]))) << "]"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - } - - (yyval.pExpression) = ast_arrayComprehension(scanner,tokAt(scanner,(yylsp[-8])),(yyvsp[-7].pNameWithPosList),(yyvsp[-5].pExpression),(yyvsp[-3].pExpression),(yyvsp[-2].pExpression),tokRangeAt(scanner,(yylsp[-3]),(yylsp[0])),false,false); - } - break; - - case 1014: /* array_comprehension: open_block "for" variable_name_with_pos_list "in" expr_list "end of expression" make_map_tuple array_comprehension_where close_block */ - { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-6]))))) { - format::get_writer() << "(" << format::substring_between(tokAt(scanner, (yylsp[-8])), tokAt(scanner, (yylsp[-7]))) - << format::get_substring(format::Pos::from(tokAt(scanner,(yylsp[-6]))), - format::Pos::from_last(tokAt(scanner,(yylsp[-4])))) - << format::substring_between(tokAt(scanner, (yylsp[-1])), tokAt(scanner, (yylsp[0]))) << ")"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[-4])))); - } - (yyval.pExpression) = ast_arrayComprehension(scanner,tokAt(scanner,(yylsp[-7])),(yyvsp[-6].pNameWithPosList),(yyvsp[-4].pExpression),(yyvsp[-2].pExpression),(yyvsp[-1].pExpression),tokRangeAt(scanner,(yylsp[-2]),(yylsp[0])),false,true); - } - break; - - case 1015: /* array_comprehension: "{{" "for" variable_name_with_pos_list "in" expr_list "end of expression" make_map_tuple array_comprehension_where close_block close_block */ - { - // std::cout << "case12" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,(yylsp[-9]))))) { - auto internal = format::get_substring(format::Pos::from(tokAt(scanner,(yylsp[-8]))), format::Pos::from_last(tokAt(scanner,(yylsp[-2])))); - format::get_writer() << "[" << format::substring_between(tokAt(scanner, (yylsp[-9])), tokAt(scanner, (yylsp[-8]))) - << internal - << format::substring_between(tokAt(scanner, (yylsp[-2])), tokAt(scanner, (yylsp[-1]))) << "]"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,(yylsp[0])))); - } - (yyval.pExpression) = ast_arrayComprehension(scanner,tokAt(scanner,(yylsp[-8])),(yyvsp[-7].pNameWithPosList),(yyvsp[-5].pExpression),(yyvsp[-3].pExpression),(yyvsp[-2].pExpression),tokRangeAt(scanner,(yylsp[-3]),(yylsp[0])),true,true); - } - break; - - - - default: break; - } - /* User semantic actions sometimes alter yychar, and that requires - that yytoken be updated with the new translation. We take the - approach of translating immediately before every use of yytoken. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action invokes - YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or - if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an - incorrect destructor might then be invoked immediately. In the - case of YYERROR or YYBACKUP, subsequent parser actions might lead - to an incorrect destructor call or verbose syntax error message - before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - - *++yyvsp = yyval; - *++yylsp = yyloc; - - /* Now 'shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - { - const int yylhs = yyr1[yyn] - YYNTOKENS; - const int yyi = yypgoto[yylhs] + *yyssp; - yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp - ? yytable[yyi] - : yydefgoto[yylhs]); - } - - goto yynewstate; - - -/*--------------------------------------. -| yyerrlab -- here on detecting error. | -`--------------------------------------*/ -yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yychar == DAS_YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; - { - yypcontext_t yyctx - = {yyssp, yytoken, &yylloc}; - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx); - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == -1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = YY_CAST (char *, - YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc))); - if (yymsg) - { - yysyntax_error_status - = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx); - yymsgp = yymsg; - } - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = YYENOMEM; - } - } - yyerror (&yylloc, scanner, yymsgp); - if (yysyntax_error_status == YYENOMEM) - YYNOMEM; - } - } - - yyerror_range[1] = yylloc; - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= DAS_YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == DAS_YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval, &yylloc, scanner); - yychar = DAS_YYEMPTY; - } - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - /* Pacify compilers when the user code never invokes YYERROR and the - label yyerrorlab therefore never appears in user code. */ - if (0) - YYERROR; - ++yynerrs; - - /* Do not reclaim the symbols of the rule whose action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - /* Pop stack until we find a state that shifts the error token. */ - for (;;) - { - yyn = yypact[yystate]; - if (!yypact_value_is_default (yyn)) - { - yyn += YYSYMBOL_YYerror; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - yyerror_range[1] = *yylsp; - yydestruct ("Error: popping", - YY_ACCESSING_SYMBOL (yystate), yyvsp, yylsp, scanner); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - *++yyvsp = yylval; - YY_IGNORE_MAYBE_UNINITIALIZED_END - - yyerror_range[2] = yylloc; - ++yylsp; - YYLLOC_DEFAULT (*yylsp, yyerror_range, 2); - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturnlab; - - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturnlab; - - -/*-----------------------------------------------------------. -| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. | -`-----------------------------------------------------------*/ -yyexhaustedlab: - yyerror (&yylloc, scanner, YY_("memory exhausted")); - yyresult = 2; - goto yyreturnlab; - - -/*----------------------------------------------------------. -| yyreturnlab -- parsing is finished, clean up and return. | -`----------------------------------------------------------*/ -yyreturnlab: - if (yychar != DAS_YYEMPTY) - { - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = YYTRANSLATE (yychar); - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, &yylloc, scanner); - } - /* Do not reclaim the symbols of the rule whose action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, yylsp, scanner); - YYPOPSTACK (1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - return yyresult; -} - - diff --git a/utils/gen1-to-gen2/ds_parser.hpp b/utils/gen1-to-gen2/ds_parser.hpp deleted file mode 100644 index 6e1f09a130..0000000000 --- a/utils/gen1-to-gen2/ds_parser.hpp +++ /dev/null @@ -1,396 +0,0 @@ -/* A Bison parser, made by GNU Bison 3.8.2. */ - -/* Bison interface for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, - Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, - especially those whose name start with YY_ or yy_. They are - private implementation details that can be changed or removed. */ - -#ifndef YY_DAS_YY_DS_PARSER_HPP_INCLUDED -# define YY_DAS_YY_DS_PARSER_HPP_INCLUDED -/* Debug traces. */ -#ifndef DAS_YYDEBUG -# if defined YYDEBUG -#if YYDEBUG -# define DAS_YYDEBUG 1 -# else -# define DAS_YYDEBUG 0 -# endif -# else /* ! defined YYDEBUG */ -# define DAS_YYDEBUG 0 -# endif /* ! defined YYDEBUG */ -#endif /* ! defined DAS_YYDEBUG */ -#if DAS_YYDEBUG -extern int das_yydebug; -#endif -/* "%code requires" blocks. */ - - #include "daScript/misc/platform.h" - #include "daScript/ast/ast.h" - #include "daScript/ast/ast_generate.h" - #include "daScript/ast/ast_expressions.h" - - #include "../src/parser/parser_state.h" - #include "helpers.h" - #include "formatter.h" - -#if defined(_MSC_VER) && !defined(__clang__) - #if !defined(_DEBUG) - #pragma optimize( "", off ) - #pragma optimize( "s", on ) - #endif -#endif - - enum { - CorM_COPY = 0, - CorM_MOVE = (1<<0), - CorM_CLONE = (1<<1) - }; - - enum { - CorS_Struct = 0, - CorS_Class = 1, - CorS_StructTemplate = 2, - CorS_ClassTemplate = 3 - }; - - using namespace das; - - #include "../src/parser/parser_impl.h" - - LineInfo tokAt ( yyscan_t scanner, const struct DAS_YYLTYPE & li ); - LineInfo tokRangeAt ( yyscan_t scanner, const struct DAS_YYLTYPE & li, const struct DAS_YYLTYPE & lie ); - - struct TypePair { - TypeDecl * firstType; - TypeDecl * secondType; - }; - - static bool need_wrap_current_expr = false; - - -/* Token kinds. */ -#ifndef DAS_YYTOKENTYPE -# define DAS_YYTOKENTYPE - enum das_yytokentype - { - DAS_YYEMPTY = -2, - DAS_YYEOF = 0, /* "end of file" */ - DAS_YYerror = 256, /* error */ - DAS_YYUNDEF = 257, /* "invalid token" */ - LEXER_ERROR = 258, /* "lexer error" */ - DAS_CAPTURE = 259, /* "capture" */ - DAS_STRUCT = 260, /* "struct" */ - DAS_CLASS = 261, /* "class" */ - DAS_LET = 262, /* "let" */ - DAS_DEF = 263, /* "def" */ - DAS_WHILE = 264, /* "while" */ - DAS_IF = 265, /* "if" */ - DAS_STATIC_IF = 266, /* "static_if" */ - DAS_ELSE = 267, /* "else" */ - DAS_FOR = 268, /* "for" */ - DAS_CATCH = 269, /* "recover" */ - DAS_TRUE = 270, /* "true" */ - DAS_FALSE = 271, /* "false" */ - DAS_NEWT = 272, /* "new" */ - DAS_TYPEINFO = 273, /* "typeinfo" */ - DAS_TYPE = 274, /* "type" */ - DAS_IN = 275, /* "in" */ - DAS_IS = 276, /* "is" */ - DAS_AS = 277, /* "as" */ - DAS_ELIF = 278, /* "elif" */ - DAS_STATIC_ELIF = 279, /* "static_elif" */ - DAS_ARRAY = 280, /* "array" */ - DAS_RETURN = 281, /* "return" */ - DAS_NULL = 282, /* "null" */ - DAS_BREAK = 283, /* "break" */ - DAS_TRY = 284, /* "try" */ - DAS_OPTIONS = 285, /* "options" */ - DAS_TABLE = 286, /* "table" */ - DAS_EXPECT = 287, /* "expect" */ - DAS_CONST = 288, /* "const" */ - DAS_REQUIRE = 289, /* "require" */ - DAS_OPERATOR = 290, /* "operator" */ - DAS_ENUM = 291, /* "enum" */ - DAS_FINALLY = 292, /* "finally" */ - DAS_DELETE = 293, /* "delete" */ - DAS_DEREF = 294, /* "deref" */ - DAS_TYPEDEF = 295, /* "typedef" */ - DAS_TYPEDECL = 296, /* "typedecl" */ - DAS_WITH = 297, /* "with" */ - DAS_AKA = 298, /* "aka" */ - DAS_ASSUME = 299, /* "assume" */ - DAS_CAST = 300, /* "cast" */ - DAS_OVERRIDE = 301, /* "override" */ - DAS_ABSTRACT = 302, /* "abstract" */ - DAS_UPCAST = 303, /* "upcast" */ - DAS_ITERATOR = 304, /* "iterator" */ - DAS_VAR = 305, /* "var" */ - DAS_ADDR = 306, /* "addr" */ - DAS_CONTINUE = 307, /* "continue" */ - DAS_WHERE = 308, /* "where" */ - DAS_PASS = 309, /* "pass" */ - DAS_REINTERPRET = 310, /* "reinterpret" */ - DAS_MODULE = 311, /* "module" */ - DAS_PUBLIC = 312, /* "public" */ - DAS_LABEL = 313, /* "label" */ - DAS_GOTO = 314, /* "goto" */ - DAS_IMPLICIT = 315, /* "implicit" */ - DAS_EXPLICIT = 316, /* "explicit" */ - DAS_SHARED = 317, /* "shared" */ - DAS_PRIVATE = 318, /* "private" */ - DAS_SMART_PTR = 319, /* "smart_ptr" */ - DAS_UNSAFE = 320, /* "unsafe" */ - DAS_INSCOPE = 321, /* "inscope" */ - DAS_STATIC = 322, /* "static" */ - DAS_FIXED_ARRAY = 323, /* "fixed_array" */ - DAS_DEFAULT = 324, /* "default" */ - DAS_UNINITIALIZED = 325, /* "uninitialized" */ - DAS_TBOOL = 326, /* "bool" */ - DAS_TVOID = 327, /* "void" */ - DAS_TSTRING = 328, /* "string" */ - DAS_TAUTO = 329, /* "auto" */ - DAS_TINT = 330, /* "int" */ - DAS_TINT2 = 331, /* "int2" */ - DAS_TINT3 = 332, /* "int3" */ - DAS_TINT4 = 333, /* "int4" */ - DAS_TUINT = 334, /* "uint" */ - DAS_TBITFIELD = 335, /* "bitfield" */ - DAS_TUINT2 = 336, /* "uint2" */ - DAS_TUINT3 = 337, /* "uint3" */ - DAS_TUINT4 = 338, /* "uint4" */ - DAS_TFLOAT = 339, /* "float" */ - DAS_TFLOAT2 = 340, /* "float2" */ - DAS_TFLOAT3 = 341, /* "float3" */ - DAS_TFLOAT4 = 342, /* "float4" */ - DAS_TRANGE = 343, /* "range" */ - DAS_TURANGE = 344, /* "urange" */ - DAS_TRANGE64 = 345, /* "range64" */ - DAS_TURANGE64 = 346, /* "urange64" */ - DAS_TBLOCK = 347, /* "block" */ - DAS_TINT64 = 348, /* "int64" */ - DAS_TUINT64 = 349, /* "uint64" */ - DAS_TDOUBLE = 350, /* "double" */ - DAS_TFUNCTION = 351, /* "function" */ - DAS_TLAMBDA = 352, /* "lambda" */ - DAS_TINT8 = 353, /* "int8" */ - DAS_TUINT8 = 354, /* "uint8" */ - DAS_TINT16 = 355, /* "int16" */ - DAS_TUINT16 = 356, /* "uint16" */ - DAS_TFLOAT16 = 357, /* "float16" */ - DAS_THALF2 = 358, /* "half2" */ - DAS_THALF3 = 359, /* "half3" */ - DAS_THALF4 = 360, /* "half4" */ - DAS_THALF8 = 361, /* "half8" */ - DAS_TSHORT2 = 362, /* "short2" */ - DAS_TSHORT3 = 363, /* "short3" */ - DAS_TSHORT4 = 364, /* "short4" */ - DAS_TSHORT8 = 365, /* "short8" */ - DAS_TUSHORT2 = 366, /* "ushort2" */ - DAS_TUSHORT3 = 367, /* "ushort3" */ - DAS_TUSHORT4 = 368, /* "ushort4" */ - DAS_TUSHORT8 = 369, /* "ushort8" */ - DAS_TBYTE2 = 370, /* "byte2" */ - DAS_TBYTE3 = 371, /* "byte3" */ - DAS_TBYTE4 = 372, /* "byte4" */ - DAS_TBYTE8 = 373, /* "byte8" */ - DAS_TBYTE16 = 374, /* "byte16" */ - DAS_TUBYTE2 = 375, /* "ubyte2" */ - DAS_TUBYTE3 = 376, /* "ubyte3" */ - DAS_TUBYTE4 = 377, /* "ubyte4" */ - DAS_TUBYTE8 = 378, /* "ubyte8" */ - DAS_TUBYTE16 = 379, /* "ubyte16" */ - DAS_TTUPLE = 380, /* "tuple" */ - DAS_TVARIANT = 381, /* "variant" */ - DAS_GENERATOR = 382, /* "generator" */ - DAS_YIELD = 383, /* "yield" */ - DAS_SEALED = 384, /* "sealed" */ - DAS_TEMPLATE = 385, /* "template" */ - ADDEQU = 386, /* "+=" */ - SUBEQU = 387, /* "-=" */ - DIVEQU = 388, /* "/=" */ - MULEQU = 389, /* "*=" */ - MODEQU = 390, /* "%=" */ - ANDEQU = 391, /* "&=" */ - OREQU = 392, /* "|=" */ - XOREQU = 393, /* "^=" */ - SHL = 394, /* "<<" */ - SHR = 395, /* ">>" */ - ADDADD = 396, /* "++" */ - SUBSUB = 397, /* "--" */ - LEEQU = 398, /* "<=" */ - SHLEQU = 399, /* "<<=" */ - SHREQU = 400, /* ">>=" */ - GREQU = 401, /* ">=" */ - EQUEQU = 402, /* "==" */ - NOTEQU = 403, /* "!=" */ - RARROW = 404, /* "->" */ - LARROW = 405, /* "<-" */ - QQ = 406, /* "??" */ - QDOT = 407, /* "?." */ - QBRA = 408, /* "?[" */ - LPIPE = 409, /* "<|" */ - LBPIPE = 410, /* " <|" */ - LLPIPE = 411, /* "$ <|" */ - LAPIPE = 412, /* "@ <|" */ - LFPIPE = 413, /* "@@ <|" */ - RPIPE = 414, /* "|>" */ - CLONEEQU = 415, /* ":=" */ - ROTL = 416, /* "<<<" */ - ROTR = 417, /* ">>>" */ - ROTLEQU = 418, /* "<<<=" */ - ROTREQU = 419, /* ">>>=" */ - MAPTO = 420, /* "=>" */ - COLCOL = 421, /* "::" */ - ANDAND = 422, /* "&&" */ - OROR = 423, /* "||" */ - XORXOR = 424, /* "^^" */ - ANDANDEQU = 425, /* "&&=" */ - OROREQU = 426, /* "||=" */ - XORXOREQU = 427, /* "^^=" */ - DOTDOT = 428, /* ".." */ - MTAG_E = 429, /* "$$" */ - MTAG_I = 430, /* "$i" */ - MTAG_V = 431, /* "$v" */ - MTAG_B = 432, /* "$b" */ - MTAG_A = 433, /* "$a" */ - MTAG_T = 434, /* "$t" */ - MTAG_C = 435, /* "$c" */ - MTAG_F = 436, /* "$f" */ - MTAG_DOTDOTDOT = 437, /* "..." */ - BRABRAB = 438, /* "[[" */ - BRACBRB = 439, /* "[{" */ - CBRCBRB = 440, /* "{{" */ - OPEN_BRACE = 441, /* "new scope" */ - CLOSE_BRACE = 442, /* "close scope" */ - SEMICOLON = 443, /* SEMICOLON */ - INTEGER = 444, /* "integer constant" */ - LONG_INTEGER = 445, /* "long integer constant" */ - UNSIGNED_INTEGER = 446, /* "unsigned integer constant" */ - UNSIGNED_LONG_INTEGER = 447, /* "unsigned long integer constant" */ - UNSIGNED_INT8 = 448, /* "unsigned int8 constant" */ - DAS_FLOAT = 449, /* "floating point constant" */ - DAS_FLOAT16_CONST = 450, /* "float16 constant" */ - DOUBLE = 451, /* "double constant" */ - NAME = 452, /* "name" */ - KEYWORD = 453, /* "keyword" */ - TYPE_FUNCTION = 454, /* "type function" */ - BEGIN_STRING = 455, /* "start of the string" */ - STRING_CHARACTER = 456, /* STRING_CHARACTER */ - STRING_CHARACTER_ESC = 457, /* STRING_CHARACTER_ESC */ - END_STRING = 458, /* "end of the string" */ - BEGIN_STRING_EXPR = 459, /* "{" */ - END_STRING_EXPR = 460, /* "}" */ - END_OF_READ = 461, /* "end of failed eader macro" */ - SEMICOLON_CUR_CUR = 462, /* ";}}" */ - SEMICOLON_CUR_SQR = 463, /* ";}]" */ - SEMICOLON_SQR_SQR = 464, /* ";]]" */ - COMMA_SQR_SQR = 465, /* ",]]" */ - COMMA_CUR_SQR = 466, /* ",}]" */ - END_OF_EXPR = 467, /* END_OF_EXPR */ - EMPTY = 468, /* EMPTY */ - UNARY_MINUS = 469, /* UNARY_MINUS */ - UNARY_PLUS = 470, /* UNARY_PLUS */ - PRE_INC = 471, /* PRE_INC */ - PRE_DEC = 472, /* PRE_DEC */ - POST_INC = 473, /* POST_INC */ - POST_DEC = 474, /* POST_DEC */ - DEREF = 475 /* DEREF */ - }; - typedef enum das_yytokentype das_yytoken_kind_t; -#endif - -/* Value type. */ -#if ! defined DAS_YYSTYPE && ! defined DAS_YYSTYPE_IS_DECLARED -union DAS_YYSTYPE -{ - - char ch; - bool b; - int32_t i; - uint32_t ui; - int64_t i64; - uint64_t ui64; - double d; - double fd; - string * s; - vector * pNameList; - vector> * pNameExprList; - vector * pNameWithPosList; - VariableDeclaration * pVarDecl; - vector * pVarDeclList; - TypeDecl * pTypeDecl; - vector * pTypeDeclList; - Expression * pExpression; - Type type; - AnnotationArgument * aa; - AnnotationArgumentList * aaList; - AnnotationDeclaration * fa; - AnnotationList * faList; - MakeStruct * pMakeStruct; - Enumeration * pEnum; - Enumeration * pEnumList; - Structure * pStructure; - Function * pFuncDecl; - CaptureEntry * pCapt; - vector * pCaptList; - TypePair aTypePair; - vector * positions; - - -}; -typedef union DAS_YYSTYPE DAS_YYSTYPE; -# define DAS_YYSTYPE_IS_TRIVIAL 1 -# define DAS_YYSTYPE_IS_DECLARED 1 -#endif - -/* Location type. */ -#if ! defined DAS_YYLTYPE && ! defined DAS_YYLTYPE_IS_DECLARED -typedef struct DAS_YYLTYPE DAS_YYLTYPE; -struct DAS_YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; -}; -# define DAS_YYLTYPE_IS_DECLARED 1 -# define DAS_YYLTYPE_IS_TRIVIAL 1 -#endif - - - - -int das_yyparse (yyscan_t scanner); - - -#endif /* !YY_DAS_YY_DS_PARSER_HPP_INCLUDED */ diff --git a/utils/gen1-to-gen2/ds_parser.ypp b/utils/gen1-to-gen2/ds_parser.ypp deleted file mode 100644 index c2f8f69051..0000000000 --- a/utils/gen1-to-gen2/ds_parser.ypp +++ /dev/null @@ -1,4627 +0,0 @@ -%define api.prefix {das_yy} - -/* - how to write error messages (style guidelines) - - 1. start with lower case - 2. no . at the end - 3. no , before any names ("invalid name "+blah) - 4. 'use' word macro for the annotation - 5. give options where possible ("try <- instead") -*/ - -%code requires { - #include "daScript/misc/platform.h" - #include "daScript/ast/ast.h" - #include "daScript/ast/ast_generate.h" - #include "daScript/ast/ast_expressions.h" - - #include "../src/parser/parser_state.h" - #include "helpers.h" - #include "formatter.h" - -#if defined(_MSC_VER) && !defined(__clang__) - #if !defined(_DEBUG) - #pragma optimize( "", off ) - #pragma optimize( "s", on ) - #endif -#endif - - enum { - CorM_COPY = 0, - CorM_MOVE = (1<<0), - CorM_CLONE = (1<<1) - }; - - enum { - CorS_Struct = 0, - CorS_Class = 1, - CorS_StructTemplate = 2, - CorS_ClassTemplate = 3 - }; - - using namespace das; - - #include "../src/parser/parser_impl.h" - - LineInfo tokAt ( yyscan_t scanner, const struct DAS_YYLTYPE & li ); - LineInfo tokRangeAt ( yyscan_t scanner, const struct DAS_YYLTYPE & li, const struct DAS_YYLTYPE & lie ); - - struct TypePair { - TypeDecl * firstType; - TypeDecl * secondType; - }; - - static bool need_wrap_current_expr = false; -} - -%{ - #define das_yyparse fmt_yyparse // We can't change flex prefix, since we have only one lexer file, seems like to define is the best way - - #include "daScript/misc/platform.h" - #include "daScript/simulate/debug_info.h" - #include "daScript/ast/compilation_errors.h" - - #ifdef _MSC_VER - #pragma warning(disable:4262) - #pragma warning(disable:4127) - #pragma warning(disable:4702) - #endif - - using namespace das; - - union DAS_YYSTYPE; - struct DAS_YYLTYPE; - - #define YY_NO_UNISTD_H - #include "../src/parser/lex.yy.h" - - void das_yyerror ( DAS_YYLTYPE * lloc, yyscan_t scanner, const string & error ); - void das_yyfatalerror ( DAS_YYLTYPE * lloc, yyscan_t scanner, const string & error, CompilationError cerr ); - int yylex ( DAS_YYSTYPE *lvalp, DAS_YYLTYPE *llocp, yyscan_t scanner ); - void yybegin ( const char * str ); - - void das_yybegin_reader ( yyscan_t yyscanner ); - void das_yyend_reader ( yyscan_t yyscanner ); - void das_accept_sequence ( yyscan_t yyscanner, const char * seq, size_t seqLen, int lineNo, FileInfo * info ); - - namespace das { class Module; } - void das_collect_keywords ( das::Module * mod, yyscan_t yyscanner ); - void das_strfmt ( yyscan_t yyscanner ); - - #undef yyextra - #define yyextra (*((das::DasParserState **)(scanner))) -%} - -%define api.pure full - -%lex-param {yyscan_t scanner} -%parse-param {yyscan_t scanner} - -%locations -%verbose -%no-lines -// %debug - -%define parse.error verbose - -%union { - char ch; - bool b; - int32_t i; - uint32_t ui; - int64_t i64; - uint64_t ui64; - double d; - double fd; - string * s; - vector * pNameList; - vector> * pNameExprList; - vector * pNameWithPosList; - VariableDeclaration * pVarDecl; - vector * pVarDeclList; - TypeDecl * pTypeDecl; - vector * pTypeDeclList; - Expression * pExpression; - Type type; - AnnotationArgument * aa; - AnnotationArgumentList * aaList; - AnnotationDeclaration * fa; - AnnotationList * faList; - MakeStruct * pMakeStruct; - Enumeration * pEnum; - Enumeration * pEnumList; - Structure * pStructure; - Function * pFuncDecl; - CaptureEntry * pCapt; - vector * pCaptList; - TypePair aTypePair; - vector * positions; -} - -%destructor { delete $$; } -%destructor { delete $$; } -%destructor { deleteNameExprList($$); } -%destructor { delete $$; } -%destructor { delete $$; } -%destructor { deleteVariableDeclarationList($$); } -%destructor { delete $$; } -%destructor { deleteTypeDeclarationList($$); } -%destructor { delete $$; } -%destructor { delete $$; } -%destructor { delete $$; } -%destructor { /* gc owns AnnotationDeclaration */ } -%destructor { delete $$; } -%destructor { /* gc owns MakeStruct */ } -%destructor { /* $$->delRef(); // if enum rule returns, module already has the link */ } -%destructor { delete $$; } -%destructor { delete $$; } -%destructor { delete $$; } -%destructor { delete $$.firstType; delete $$.secondType; } -%destructor { $$->delRef(); } -%destructor { delete $$; } - -%token LEXER_ERROR "lexer error" - -/* keywords */ -%token DAS_CAPTURE "capture" -%token DAS_STRUCT "struct" -%token DAS_CLASS "class" -%token DAS_LET "let" -%token DAS_DEF "def" -%token DAS_WHILE "while" -%token DAS_IF "if" -%token DAS_STATIC_IF "static_if" -%token DAS_ELSE "else" -%token DAS_FOR "for" -%token DAS_CATCH "recover" -%token DAS_TRUE "true" -%token DAS_FALSE "false" -%token DAS_NEWT "new" -%token DAS_TYPEINFO "typeinfo" -%token DAS_TYPE "type" -%token DAS_IN "in" -%token DAS_IS "is" -%token DAS_AS "as" -%token DAS_ELIF "elif" -%token DAS_STATIC_ELIF "static_elif" -%token DAS_ARRAY "array" -%token DAS_RETURN "return" -%token DAS_NULL "null" -%token DAS_BREAK "break" -%token DAS_TRY "try" -%token DAS_OPTIONS "options" -%token DAS_TABLE "table" -%token DAS_EXPECT "expect" -%token DAS_CONST "const" -%token DAS_REQUIRE "require" -%token DAS_OPERATOR "operator" -%token DAS_ENUM "enum" -%token DAS_FINALLY "finally" -%token DAS_DELETE "delete" -%token DAS_DEREF "deref" -%token DAS_TYPEDEF "typedef" -%token DAS_TYPEDECL "typedecl" -%token DAS_WITH "with" -%token DAS_AKA "aka" -%token DAS_ASSUME "assume" -%token DAS_CAST "cast" -%token DAS_OVERRIDE "override" -%token DAS_ABSTRACT "abstract" -%token DAS_UPCAST "upcast" -%token DAS_ITERATOR "iterator" -%token DAS_VAR "var" -%token DAS_ADDR "addr" -%token DAS_CONTINUE "continue" -%token DAS_WHERE "where" -%token DAS_PASS "pass" -%token DAS_REINTERPRET "reinterpret" -%token DAS_MODULE "module" -%token DAS_PUBLIC "public" -%token DAS_LABEL "label" -%token DAS_GOTO "goto" -%token DAS_IMPLICIT "implicit" -%token DAS_EXPLICIT "explicit" -%token DAS_SHARED "shared" -%token DAS_PRIVATE "private" -%token DAS_SMART_PTR "smart_ptr" -%token DAS_UNSAFE "unsafe" -%token DAS_INSCOPE "inscope" -%token DAS_STATIC "static" -%token DAS_FIXED_ARRAY "fixed_array" -%token DAS_DEFAULT "default" -%token DAS_UNINITIALIZED "uninitialized" - -/* basic types */ -%token DAS_TBOOL "bool" -%token DAS_TVOID "void" -%token DAS_TSTRING "string" -%token DAS_TAUTO "auto" -%token DAS_TINT "int" -%token DAS_TINT2 "int2" -%token DAS_TINT3 "int3" -%token DAS_TINT4 "int4" -%token DAS_TUINT "uint" -%token DAS_TBITFIELD "bitfield" -%token DAS_TUINT2 "uint2" -%token DAS_TUINT3 "uint3" -%token DAS_TUINT4 "uint4" -%token DAS_TFLOAT "float" -%token DAS_TFLOAT2 "float2" -%token DAS_TFLOAT3 "float3" -%token DAS_TFLOAT4 "float4" -%token DAS_TRANGE "range" -%token DAS_TURANGE "urange" -%token DAS_TRANGE64 "range64" -%token DAS_TURANGE64 "urange64" -%token DAS_TBLOCK "block" -%token DAS_TINT64 "int64" -%token DAS_TUINT64 "uint64" -%token DAS_TDOUBLE "double" -%token DAS_TFUNCTION "function" -%token DAS_TLAMBDA "lambda" -%token DAS_TINT8 "int8" -%token DAS_TUINT8 "uint8" -%token DAS_TINT16 "int16" -%token DAS_TUINT16 "uint16" -%token DAS_TFLOAT16 "float16" -%token DAS_THALF2 "half2" -%token DAS_THALF3 "half3" -%token DAS_THALF4 "half4" -%token DAS_THALF8 "half8" -%token DAS_TSHORT2 "short2" -%token DAS_TSHORT3 "short3" -%token DAS_TSHORT4 "short4" -%token DAS_TSHORT8 "short8" -%token DAS_TUSHORT2 "ushort2" -%token DAS_TUSHORT3 "ushort3" -%token DAS_TUSHORT4 "ushort4" -%token DAS_TUSHORT8 "ushort8" -%token DAS_TBYTE2 "byte2" -%token DAS_TBYTE3 "byte3" -%token DAS_TBYTE4 "byte4" -%token DAS_TBYTE8 "byte8" -%token DAS_TBYTE16 "byte16" -%token DAS_TUBYTE2 "ubyte2" -%token DAS_TUBYTE3 "ubyte3" -%token DAS_TUBYTE4 "ubyte4" -%token DAS_TUBYTE8 "ubyte8" -%token DAS_TUBYTE16 "ubyte16" -%token DAS_TTUPLE "tuple" -%token DAS_TVARIANT "variant" -%token DAS_GENERATOR "generator" -%token DAS_YIELD "yield" -%token DAS_SEALED "sealed" -%token DAS_TEMPLATE "template" - -/* operators */ -%token ADDEQU "+=" -%token SUBEQU "-=" -%token DIVEQU "/=" -%token MULEQU "*=" -%token MODEQU "%=" -%token ANDEQU "&=" -%token OREQU "|=" -%token XOREQU "^=" -%token SHL "<<" -%token SHR ">>" -%token ADDADD "++" -%token SUBSUB "--" -%token LEEQU "<=" -%token SHLEQU "<<=" -%token SHREQU ">>=" -%token GREQU ">=" -%token EQUEQU "==" -%token NOTEQU "!=" -%token RARROW "->" -%token LARROW "<-" -%token QQ "??" -%token QDOT "?." -%token QBRA "?[" -%token LPIPE "<|" -%token LBPIPE " <|" -%token LLPIPE "$ <|" -%token LAPIPE "@ <|" -%token LFPIPE "@@ <|" -%token RPIPE "|>" -%token CLONEEQU ":=" -%token ROTL "<<<" -%token ROTR ">>>" -%token ROTLEQU "<<<=" -%token ROTREQU ">>>=" -%token MAPTO "=>" -%token COLCOL "::" -%token ANDAND "&&" -%token OROR "||" -%token XORXOR "^^" -%token ANDANDEQU "&&=" -%token OROREQU "||=" -%token XORXOREQU "^^=" -%token DOTDOT ".." -%token MTAG_E "$$" -%token MTAG_I "$i" -%token MTAG_V "$v" -%token MTAG_B "$b" -%token MTAG_A "$a" -%token MTAG_T "$t" -%token MTAG_C "$c" -%token MTAG_F "$f" -%token MTAG_DOTDOTDOT "..." - -%token BRABRAB "[[" /* [[ */ -%token BRACBRB "[{" /* [{ */ -%token CBRCBRB "{{" /* {{ */ -%token OPEN_BRACE "new scope" -%token CLOSE_BRACE "close scope" -%token SEMICOLON - -%token INTEGER "integer constant" -%token LONG_INTEGER "long integer constant" -%token UNSIGNED_INTEGER "unsigned integer constant" -%token UNSIGNED_LONG_INTEGER "unsigned long integer constant" -%token UNSIGNED_INT8 "unsigned int8 constant" -%token DAS_FLOAT "floating point constant" -%token DAS_FLOAT16_CONST "float16 constant" -%token DOUBLE "double constant" -%token NAME "name" -%token KEYWORD "keyword" -%token TYPE_FUNCTION "type function" - -/* %printer { fprintf (yyo, "%i", $$); } */ - -%token BEGIN_STRING "start of the string" -%token STRING_CHARACTER -%token STRING_CHARACTER_ESC -%token END_STRING "end of the string" -%token BEGIN_STRING_EXPR "{" -%token END_STRING_EXPR "}" -%token END_OF_READ "end of failed eader macro" - -%token '{' "begin of code block" -%token '}' "end of code block" -%token ';' "end of expression" - -%token SEMICOLON_CUR_CUR ";}}" -%token SEMICOLON_CUR_SQR ";}]" -%token SEMICOLON_SQR_SQR ";]]" -%token COMMA_SQR_SQR ",]]" -%token COMMA_CUR_SQR ",}]" - - -%type enum_name -%type bitfield_bits -%type bitfield_alias_bits -%type tuple_expansion -%type variable_name_with_pos_list -%type let_variable_name_with_pos_list -%type basic_type_declaration -%type bitfield_basic_type_declaration -%type enum_basic_type_declaration -%type type_declaration -%type type_declaration_no_options -%type new_type_declaration -%type auto_type_declaration -%type bitfield_type_declaration -%type optional_function_type -%type structure_type_declaration -%type dim_list -%type type_declaration_no_options_list -%type struct_variable_declaration_list -%type optional_struct_variable_declaration_list -%type global_variable_declaration_list -%type optional_function_argument_list -%type function_argument_list -%type variable_declaration -%type variable_declaration_type -%type variable_declaration_no_type -%type function_argument_declaration_type -%type function_argument_declaration_no_type -%type structure_variable_declaration -%type let_variable_declaration -%type tuple_expansion_variable_declaration -%type tuple_type -%type tuple_type_list -%type tuple_alias_type_list -%type variant_type -%type variant_type_list -%type variant_alias_type_list -%type keyword_or_name -%type name_in_namespace -%type annotation_declaration_name -%type function_name -%type optional_structure_parent -%type format_string -%type optional_format_string -%type require_module_name -%type annotation_argument_name -%type annotation_argument -%type annotation_argument_value -%type annotation_argument_list -%type metadata_argument_list -%type annotation_argument_value_list -%type optional_field_annotation -%type annotation_declaration_basic -%type annotation_declaration -%type annotation_list -%type optional_annotation_list -%type structure_name -%type table_type_pair - - -%type alias_list -%type open_block -%type close_block -%type opt_sem -%type class_or_struct -%type copy_or_move -%type optional_override -%type optional_constant -%type kwd_let -%type kwd_let_var_or_nothing -%type is_public_module -%type optional_shared -%type optional_not_required -%type optional_sealed -%type block_or_lambda -%type optional_ref -%type optional_public_or_private_module -%type optional_public_or_private_variable -%type optional_public_or_private_structure -%type optional_public_or_private_function -%type optional_public_or_private_member_variable -%type optional_public_or_private_alias -%type optional_static_member_variable -%type optional_public_or_private_enum -%type optional_in_scope -%type optional_comma -%type use_initializer -%type if_or_static_if -%type elif_or_static_elif -%type optional_template - -%type copy_or_move_or_clone - -%type enum_list - -%type expr -%type expr2 -%type expr_mtag -%type expr_field -%type expr_assign -%type expr_assign_pipe -%type expr_assign_pipe_right -%type expr_list -%type optional_expr_list -%type optional_expr_list_in_braces -%type optional_expr_map_tuple_list -%type expr_map_tuple_list -%type expression_label -%type expression_goto -%type expression_let -%type expressions -%type expression_block -%type expression_with -%type expression_with_alias -%type expression_while_loop -%type expression_unsafe -%type expression_for_loop -%type expression_break -%type expression_continue -%type expression_delete -%type expression_return -%type expression_return_no_pipe -%type expression_yield -%type expression_yield_no_pipe -%type expression_else -%type expression_if_then_else -%type expression_if_one_liner -%type expression_else_one_liner -%type expression_try_catch -%type expression_keyword -%type expr_new -%type expr_pipe -%type expr_keyword -%type expr_type_info -%type expr_type_decl -%type expr_cast -%type expr_block -%type expr_full_block -%type expr_full_block_assumed_piped -%type expr_named_call -%type expression_any -%type expr_numeric_const -%type string_builder_body -%type string_builder -%type expr_reader -%type make_decl -%type make_struct_fields -%type make_struct_decl -%type make_struct_dim -%type make_struct_dim_list -%type make_struct_dim_decl -%type optional_make_struct_dim_decl -%type make_variant_dim -%type make_struct_single -%type make_tuple -%type make_map_tuple -%type make_dim -%type make_dim_decl -%type make_tuple_call -%type make_table -%type make_table_decl -%type array_comprehension_where -%type array_comprehension -%type expr_method_call -%type block_or_simple_block -%type func_addr_expr -%type func_addr_name -%type expr_call -%type expr_call_pipe - -%type optional_block - -%type function_declaration -%type function_declaration_header - -%type capture_entry -%type capture_list -%type optional_capture_list - -%type character_sequence -%type string_constant -%type module_name - -%nonassoc END_OF_EXPR -%nonassoc ';' -%right SEMICOLON -%nonassoc EMPTY - -/* operation precedence*/ -%left ',' -%nonassoc DOTDOT MAPTO -%right '=' ADDEQU SUBEQU DIVEQU MULEQU MODEQU ANDEQU OREQU XOREQU LARROW SHLEQU SHREQU ROTLEQU ROTREQU ANDANDEQU XORXOREQU OROREQU -%right '?' ':' -%left OROR -%left XORXOR -%left ANDAND -%left '|' -%left '^' -%left '&' -%left EQUEQU NOTEQU -%left '<' '>' LEEQU GREQU -%left SHL SHR ROTL ROTR -%left '-' '+' -%left '*' '/' '%' -%right QQ -%right UNARY_MINUS UNARY_PLUS '~' '!' PRE_INC PRE_DEC ADDADD SUBSUB -%left DAS_IS DAS_AS -%left LPIPE RPIPE LBPIPE LAPIPE LFPIPE LLPIPE -%left POST_INC POST_DEC RARROW DEREF -%left '.' -%nonassoc '[' ']' '(' ')' QDOT QBRA BRABRAB BRACBRB CBRCBRB -%nonassoc '$' '@' -%nonassoc COLCOL - -%right STRING_CHARACTER STRING_CHARACTER_ESC -%right BEGIN_STRING_EXPR END_STRING_EXPR -%% - -program - : - | program module_declaration { - if ( yyextra->das_has_type_declarations ) { - das_yyerror(scanner,"module name has to be first declaration",tokAt(scanner,@module_declaration), CompilationError::syntax_error); - } - } - | program structure_declaration { yyextra->das_has_type_declarations = true; } - | program enum_declaration { yyextra->das_has_type_declarations = true; } - | program global_let { yyextra->das_has_type_declarations = true; } - | program global_function_declaration { yyextra->das_has_type_declarations = true; } - | program expect_declaration - | program require_declaration - | program options_declaration - | program alias_declaration { yyextra->das_has_type_declarations = true; } - | program variant_alias_declaration { yyextra->das_has_type_declarations = true; } - | program tuple_alias_declaration { yyextra->das_has_type_declarations = true; } - | program bitfield_alias_declaration { yyextra->das_has_type_declarations = true; } - | program top_level_reader_macro - | program semicolon - ; - -semicolon - : SEMICOLON[colon] { - format::try_semicolon_at_eol(format::Pos::from_last(tokAt(scanner,@colon))); - } - | ';' {} - -top_level_reader_macro - : expr_reader[rdr] semicolon { - delete $rdr; // we do nothing, we don't even attemp to 'visit' - } - ; - -optional_public_or_private_module - : { $$ = yyextra->g_Program->policies.default_module_public; } - | DAS_PUBLIC { $$ = true; } - | DAS_PRIVATE { $$ = false; } - ; - -module_name - : '$' { $$ = new string("$"); } - | NAME[name] { $$ = $name; } - ; - -optional_not_required - : { $$ = false; } - | '!' DAS_INSCOPE { $$ = true; } - ; - -module_declaration - : DAS_MODULE module_name[name] optional_shared[mtype] optional_public_or_private_module[ispub] optional_not_required[notreq] { - yyextra->g_Program->thisModuleName = *$name; - yyextra->g_Program->thisModule->isPublic = $ispub; - yyextra->g_Program->thisModule->isModule = true; - yyextra->g_Program->thisModule->visibleEverywhere = $notreq; - if ( yyextra->g_Program->thisModule->name.empty() ) { - yyextra->g_Program->library.renameModule(yyextra->g_Program->thisModule.get(),*$name); - } else if ( yyextra->g_Program->thisModule->name != *$name ){ - das_yyerror(scanner,"this module already has a name " + yyextra->g_Program->thisModule->name,tokAt(scanner,@name), - CompilationError::module_already_has_a_name); - } - if ( !yyextra->g_Program->policies.ignore_shared_modules ) { - yyextra->g_Program->promoteToBuiltin = $mtype; - } - delete $name; - } - ; - -character_sequence - : STRING_CHARACTER[char] { $$ = new string(); *$$ += $char; } - | STRING_CHARACTER_ESC { $$ = new string(); *$$ += "\\\\"; } - | character_sequence[elem] STRING_CHARACTER[char] %prec STRING_CHARACTER { $$ = $elem; *$elem += $char; } - | character_sequence[elem] STRING_CHARACTER_ESC %prec STRING_CHARACTER { $$ = $elem; *$elem += "\\\\"; } - ; - -string_constant - : BEGIN_STRING character_sequence[seq] END_STRING { $$ = $seq; } - | BEGIN_STRING END_STRING { $$ = new string(); } - ; - -format_string - : { $$ = new string(); } - | format_string[ss] STRING_CHARACTER[char] { $$ = $ss; $ss->push_back($char); } - ; - -optional_format_string - : { $$ = new string(""); } - | ':' { das_strfmt(scanner); } format_string[fmt] { $$ = $fmt; } - ; - -string_builder_body - : { - $$ = new ExprStringBuilder(); - $$->at = LineInfo(yyextra->g_FileAccessStack.back(), - yylloc.first_column,yylloc.first_line,yylloc.last_column,yylloc.last_line); - } - | string_builder_body[sb] character_sequence[sconst] %prec STRING_CHARACTER { - bool err; - auto esconst = unescapeString(*$sconst,&err); - if ( err ) das_yyerror(scanner,"invalid escape sequence",tokAt(scanner,@sb), CompilationError::invalid_escape_sequence); - auto sc = new ExprConstString(tokAt(scanner,@sconst),esconst); - delete $sconst; - static_cast($sb)->elements.push_back(sc); - $$ = $sb; - } - | string_builder_body[sb] BEGIN_STRING_EXPR expr[subexpr] optional_format_string[sfmt] END_STRING_EXPR %prec BEGIN_STRING_EXPR { - auto se = $subexpr; - if ( !$sfmt->empty() ) { - auto call_fmt = new ExprCall(tokAt(scanner,@sfmt), "_::fmt"); - call_fmt->arguments.push_back(new ExprConstString(tokAt(scanner,@sfmt),":" + *$sfmt)); - call_fmt->arguments.push_back(se); - se = call_fmt; - } - static_cast($sb)->elements.push_back(se); - $$ = $sb; - delete $sfmt; - } - ; - -string_builder - : BEGIN_STRING[sfrm] string_builder_body[sb] END_STRING[sto] { - auto strb = static_cast($sb); - if ( strb->elements.size()==0 ) { - $$ = new ExprConstString(tokRangeAt(scanner,@sfrm,@sto),""); - delete $sb; - } else if ( strb->elements.size()==1 && strb->elements[0]->rtti_isStringConstant() ) { - auto sconst = static_cast(strb->elements[0]); - $$ = new ExprConstString(tokRangeAt(scanner,@sfrm,@sto),sconst->text); - delete $sb; - } else { - $$ = $sb; - } - } - ; - -reader_character_sequence - : STRING_CHARACTER[char] { - if ( !yyextra->g_ReaderMacro->accept(yyextra->g_Program.get(), yyextra->g_Program->thisModule.get(), yyextra->g_ReaderExpr, $char, tokAt(scanner,@char)) ) { - das_yyend_reader(scanner); - } - } - | reader_character_sequence[elem] STRING_CHARACTER[char] { - if ( !yyextra->g_ReaderMacro->accept(yyextra->g_Program.get(), yyextra->g_Program->thisModule.get(), yyextra->g_ReaderExpr, $char, tokAt(scanner,@char)) ) { - das_yyend_reader(scanner); - } - } - ; - -expr_reader - : '%' [loc] name_in_namespace[mark] { - auto macros = yyextra->g_Program->getReaderMacro(*$mark); - if ( macros.size()==0 ) { - das_yyerror(scanner,"reader macro " + *$mark + " not found",tokAt(scanner,@mark), - CompilationError::unsupported_read_macro); - } else if ( macros.size()>1 ) { - string options; - for ( auto & x : macros ) { - options += "\t" + x->module->name + "::" + x->name + "\n"; - } - das_yyerror(scanner,"too many options for the reader macro " + *$mark + "\n" + options, tokAt(scanner,@mark), - CompilationError::unsupported_read_macro); - } else if ( yychar != '~' ) { - das_yyerror(scanner,"expecting ~ after the reader macro", tokAt(scanner,@mark), - CompilationError::syntax_error); - } else { - yyextra->g_ReaderMacro = macros.back(); - yyextra->g_ReaderExpr = new ExprReader(tokAt(scanner,@loc),yyextra->g_ReaderMacro); - yyclearin ; - das_yybegin_reader(scanner); - } - } reader_character_sequence[seq] { - yyextra->g_ReaderExpr->at = tokRangeAt(scanner,@loc,@seq); - $$ = yyextra->g_ReaderExpr; - int thisLine = 0; - FileInfo * info = nullptr; - if (!format::is_formatter_enabled()) { - if ( auto seqt = yyextra->g_ReaderMacro->suffix(yyextra->g_Program.get(), yyextra->g_Program->thisModule.get(), yyextra->g_ReaderExpr, thisLine, info, tokAt(scanner,@seq)) ) { - das_accept_sequence(scanner,seqt,strlen(seqt),thisLine,info); - yylloc.first_column = @seq.first_column; - yylloc.first_line = @seq.first_line; - yylloc.last_column = @seq.last_column; - yylloc.last_line = @seq.last_line; - } - } - delete $mark; - yyextra->g_ReaderMacro = nullptr; - yyextra->g_ReaderExpr = nullptr; - } - -options_declaration - : DAS_OPTIONS annotation_argument_list[list] { - for ( auto & opt : *$list ) { - if ( opt.name=="indenting" && opt.type==Type::tInt ) { - if (opt.iValue != 0 && opt.iValue != 2 && opt.iValue != 4 && opt.iValue != 8) { //this is error - yyextra->das_tab_size = yyextra->das_def_tab_size; - } else { - yyextra->das_tab_size = opt.iValue ? opt.iValue : yyextra->das_def_tab_size;//0 is default - } - yyextra->g_FileAccessStack.back()->tabSize = yyextra->das_tab_size; - } else if ( opt.name=="gen2_make_syntax" && opt.type==Type::tBool ) { - yyextra->das_gen2_make_syntax = opt.bValue; - } - } - for ( auto & opt : *$list ) { - if ( yyextra->g_Access->isOptionAllowed(opt.name, yyextra->g_Program->thisModule->fileName) ) { - if ( yyextra->g_Access->isOptionBlocked(opt.name, yyextra->g_Program->thisModule->fileName) ) { - // blocked: ok to write, silently ignored (not applied) - } else { - yyextra->g_Program->options.push_back(opt); - } - } else { - das_yyerror(scanner,"option " + opt.name + " is not allowed here", - tokAt(scanner,@list), CompilationError::invalid_option); - } - } - delete $list; - } - ; - -require_declaration - : DAS_REQUIRE require_module - ; - -keyword_or_name - : NAME[name] { $$ = $name; } - | KEYWORD[name] { $$ = $name; } - | TYPE_FUNCTION[name] { $$ = $name; } - ; - -require_module_name - : keyword_or_name[name] { - $$ = $name; - } - | '%' require_module_name[req] { - *$req = "%" + *$req; - $$ = $req; - } - | '.' '/' require_module_name[req] { - *$req = "./" + *$req; - $$ = $req; - } - | DOTDOT '/' require_module_name[req] { - *$req = "../" + *$req; - $$ = $req; - } - | '%' '/' require_module_name[req] { - *$req = "%/" + *$req; - $$ = $req; - } - | require_module_name[req] '.' keyword_or_name[name] { - *$req += "."; - *$req += *$name; - delete $name; - $$ = $req; - } - | require_module_name[req] '/' keyword_or_name[name] { - *$req += "/"; - *$req += *$name; - delete $name; - $$ = $req; - } - ; - -require_module - : require_module_name[name] is_public_module[pub] { - ast_requireModule(scanner,$name,nullptr,$pub,tokAt(scanner,@name)); - } - | require_module_name[name] DAS_AS NAME[modalias] is_public_module[pub] { - ast_requireModule(scanner,$name,$modalias,$pub,tokAt(scanner,@name)); - } - ; - -is_public_module - : { $$ = false; } - | DAS_PUBLIC { $$ = true; } - ; - -expect_declaration - : DAS_EXPECT expect_list - ; - -expect_list - : expect_error - | expect_list ',' expect_error - ; - -expect_error - : INTEGER[err] { - yyextra->g_Program->expectErrors[CompilationError($err)] ++; - } - | INTEGER[err] ':' INTEGER[count] { - yyextra->g_Program->expectErrors[CompilationError($err)] += $count; - } - ; - -expression_label - : DAS_LABEL[loc] INTEGER[labname] ':' { - $$ = new ExprLabel(tokAt(scanner,@loc),$labname); - } - ; - -expression_goto - : DAS_GOTO[loc] DAS_LABEL INTEGER[labname] { - $$ = new ExprGoto(tokAt(scanner,@loc),$labname); - } - | DAS_GOTO[loc] expr[lab] { - $$ = new ExprGoto(tokAt(scanner,@loc),$lab); - } - ; - -elif_or_static_elif - : DAS_ELIF { $$ = false; } - | DAS_STATIC_ELIF { $$ = true; } - ; - -expression_else - : { $$ = nullptr; } - | DAS_ELSE expression_block[block] { $$ = $block; } - | elif_or_static_elif[loc] expr[cond] expression_block[block] expression_else[then] { - format::wrap_par_expr(tokAt(scanner,@cond), $cond->at); - if (!format::is_else_newline() && $then != nullptr) { - format::skip_spaces_or_print(tokAt(scanner,@loc), tokAt(scanner,@block), tokAt(scanner,@then), yyextra->das_tab_size); - } - - auto eite = new ExprIfThenElse(tokAt(scanner,@loc),$cond,$block,$then); - eite->isStatic = $loc; - $$ = eite; - } - | elif_or_static_elif[loc] expr[cond] expression_block[block] SEMICOLON expression_else[then] { - format::wrap_par_expr(tokAt(scanner,@cond), $cond->at); - if (!format::is_else_newline() && $then != nullptr) { - format::skip_spaces_or_print(tokAt(scanner,@loc), tokAt(scanner,@block), tokAt(scanner,@then), yyextra->das_tab_size); - } - - auto eite = new ExprIfThenElse(tokAt(scanner,@loc),$cond,$block,$then); - eite->isStatic = $loc; - $$ = eite; - } - ; - -if_or_static_if - : DAS_IF { $$ = false; } - | DAS_STATIC_IF { $$ = true; } - ; - -expression_else_one_liner - : { $$ = nullptr; } - | DAS_ELSE[loc] { yyextra->das_need_oxford_comma = true; } expression_if_one_liner[result] { - $$ = $result; - } - ; - -expression_if_one_liner - : expr[result] { $$ = $result; } - | expression_return_no_pipe[result] { $$ = $result; } - | expression_yield_no_pipe[result] { $$ = $result; } - | expression_break[result] { $$ = $result; } - | expression_continue[result] { $$ = $result; } - ; - -expression_if_then_else - : if_or_static_if[loc] expr[cond] expression_block[block] SEMICOLON expression_else[then] { - format::wrap_par_expr(tokAt(scanner,@cond), $cond->at); - if (!format::is_else_newline() && $then != nullptr) { - format::skip_spaces_or_print(tokAt(scanner,@loc), tokAt(scanner,@block), tokAt(scanner,@then), yyextra->das_tab_size); - } - - auto eite = new ExprIfThenElse(tokAt(scanner,@loc),$cond,$block,$then); - eite->isStatic = $loc; - $$ = eite; - } - | if_or_static_if[loc] expr[cond] expression_block[block] expression_else[then] { - format::wrap_par_expr(tokAt(scanner,@cond), $cond->at); - if (!format::is_else_newline() && $then != nullptr) { - format::skip_spaces_or_print(tokAt(scanner,@loc), tokAt(scanner,@block), tokAt(scanner,@then), yyextra->das_tab_size); - } - - auto eite = new ExprIfThenElse(tokAt(scanner,@loc),$cond,$block,$then); - eite->isStatic = $loc; - $$ = eite; - } - | expression_if_one_liner[if_true] DAS_IF[loc] { yyextra->das_need_oxford_comma = true; } expr[cond] expression_else_one_liner[if_false] semicolon { - format::wrap_par_expr(tokAt(scanner,@cond), $cond->at); - - $$ = new ExprIfThenElse(tokAt(scanner,@loc),$cond,ast_wrapInBlock($if_true),$if_false ? ast_wrapInBlock($if_false) : nullptr); - } - ; - -expression_for_loop - : DAS_FOR[loc] { yyextra->das_need_oxford_comma=false; } variable_name_with_pos_list[iters] DAS_IN expr_list[srcs] expression_block[block] { - format::wrap_par_expr(tokRangeAt(scanner, @iters, @srcs), tokRangeAt(scanner, @iters, @srcs)); - $$ = ast_forLoop(scanner,$iters,$srcs,$block,tokAt(scanner,@loc),tokAt(scanner,@block)); - } - | DAS_FOR[loc] { // Had to add to successfully convert to v2 syntax, just copied from ds2_parser - yyextra->das_keyword = true; - } '(' variable_name_with_pos_list[iters] DAS_IN expr_list[srcs] ')' expression_block[block] { - yyextra->das_keyword = false; - $$ = ast_forLoop(scanner,$iters,$srcs,$block,tokAt(scanner,@loc),tokAt(scanner,@block)); - } - ; - -expression_unsafe - : DAS_UNSAFE[loc] expression_block[block] { - auto pUnsafe = new ExprUnsafe(tokAt(scanner,@loc)); - pUnsafe->body = $block; - $$ = pUnsafe; - } - ; - -expression_while_loop - : DAS_WHILE[loc] expr[condition] expression_block[block] { - format::wrap_par_expr(tokAt(scanner,@condition), $condition->at); - - auto pWhile = new ExprWhile(tokAt(scanner,@loc)); - pWhile->cond = $condition; - pWhile->body = $block; - ((ExprBlock *)$block)->inTheLoop = true; - $$ = pWhile; - } - ; - -expression_with - : DAS_WITH[loc] expr[with] expression_block[block] { - format::wrap_par_expr(tokAt(scanner,@with), $with->at); - auto pWith = new ExprWith(tokAt(scanner,@loc)); - pWith->with = $with; - pWith->body = $block; - $$ = pWith; - } - ; - -expression_with_alias - : DAS_ASSUME[loc] NAME[aname] '=' { yyextra->das_need_oxford_comma=true; } expr[subexpr] semicolon { - $$ = new ExprAssume(tokAt(scanner,@loc), *$aname, ExpressionPtr($subexpr)); - delete $aname; - } - | DAS_TYPEDEF[loc] { yyextra->das_force_oxford_comma=true;} NAME[aname] '=' type_declaration[decl] semicolon { - $$ = new ExprAssume(tokAt(scanner,@loc), *$aname, TypeDeclPtr($decl)); - } - ; - -annotation_argument_value - : string_constant[value] { $$ = new AnnotationArgument("",*$value); delete $value; } - | NAME[value] { $$ = new AnnotationArgument("",*$value); delete $value; } - | INTEGER[value] { $$ = new AnnotationArgument("",$value); } - | DAS_FLOAT[value] { $$ = new AnnotationArgument("",float($value)); } - | DAS_TRUE { $$ = new AnnotationArgument("",true); } - | DAS_FALSE { $$ = new AnnotationArgument("",false); } - ; - -annotation_argument_value_list - : annotation_argument_value[arg] { - $$ = new AnnotationArgumentList(); - $$->push_back(*$arg); - delete $arg; - } - | annotation_argument_value_list[argL] ',' annotation_argument_value[arg] { - $$ = $argL; - $$->push_back(*$arg); - delete $arg; - } - ; - -annotation_argument_name - : NAME[name] { $$ = $name; } - | DAS_TYPE { $$ = new string("type"); } - | DAS_IN { $$ = new string("in"); } - ; - -annotation_argument - : annotation_argument_name[name] '=' string_constant[value] { $$ = new AnnotationArgument(*$name,*$value,tokRangeAt(scanner,@name,@value)); delete $value; delete $name; } - | annotation_argument_name[name] '=' NAME[value] { $$ = new AnnotationArgument(*$name,*$value,tokRangeAt(scanner,@name,@value)); delete $value; delete $name; } - | annotation_argument_name[name] '=' '@' '@' NAME[value] { $$ = new AnnotationArgument(*$name,*$value,tokAt(scanner,@name)); delete $value; delete $name; } - | annotation_argument_name[name] '=' INTEGER[value] { $$ = new AnnotationArgument(*$name,$value,tokRangeAt(scanner,@name,@value)); delete $name; } - | annotation_argument_name[name] '=' DAS_FLOAT[value] { $$ = new AnnotationArgument(*$name,float($value),tokRangeAt(scanner,@name,@value)); delete $name; } - | annotation_argument_name[name] '=' DAS_TRUE[value] { $$ = new AnnotationArgument(*$name,true,tokRangeAt(scanner,@name,@value)); delete $name; } - | annotation_argument_name[name] '=' DAS_FALSE[value] { $$ = new AnnotationArgument(*$name,false,tokRangeAt(scanner,@name,@value)); delete $name; } - | annotation_argument_name[name] { $$ = new AnnotationArgument(*$name,true,tokAt(scanner,@name)); delete $name; } - | annotation_argument_name[name] '=' '(' annotation_argument_value_list[values] ')'[end] { - { $$ = new AnnotationArgument(*$name,$values,tokRangeAt(scanner,@name,@end)); delete $name; } - } - ; - -annotation_argument_list - : annotation_argument[arg] { - $$ = ast_annotationArgumentListEntry(scanner,new AnnotationArgumentList(),$arg); - } - | annotation_argument_list[argL] ',' annotation_argument[arg] { - $$ = ast_annotationArgumentListEntry(scanner,$argL,$arg); - } - ; - -metadata_argument_list - : '@' annotation_argument[arg] { - $$ = ast_annotationArgumentListEntry(scanner,new AnnotationArgumentList(),$arg); - } - | metadata_argument_list[argL] '@' annotation_argument[arg] { - $$ = ast_annotationArgumentListEntry(scanner,$argL,$arg); - } - | metadata_argument_list[argL] semicolon { - $$ = $argL; - } - ; - -annotation_declaration_name - : name_in_namespace[name] { $$ = $name; } - | DAS_REQUIRE { $$ = new string("require"); } - | DAS_PRIVATE { $$ = new string("private"); } - | DAS_TEMPLATE { $$ = new string("template"); } - ; - -annotation_declaration_basic - : annotation_declaration_name[name] { - $$ = new AnnotationDeclaration(); - $$->at = tokAt(scanner,@name); - if ( yyextra->g_Access->isAnnotationAllowed(*$name, yyextra->g_Program->thisModuleName) ) { - if ( auto ann = findAnnotation(scanner,*$name,tokAt(scanner,@name)) ) { - $$->annotation = ann; - } - } else { - das_yyerror(scanner,"annotation " + *$name + " is not allowed here", - tokAt(scanner,@name), CompilationError::invalid_annotation); - } - delete $name; - } - | annotation_declaration_name[name] '(' annotation_argument_list[argL] ')' { - $$ = new AnnotationDeclaration(); - $$->at = tokAt(scanner,@name); - if ( yyextra->g_Access->isAnnotationAllowed(*$name, yyextra->g_Program->thisModuleName) ) { - if ( auto ann = findAnnotation(scanner,*$name,tokAt(scanner,@name)) ) { - $$->annotation = ann; - } - } else { - das_yyerror(scanner,"annotation " + *$name + " is not allowed here", - tokAt(scanner,@name), CompilationError::invalid_annotation); - } - swap ( $$->arguments, *$argL ); - delete $argL; - delete $name; - } - ; - -annotation_declaration - : annotation_declaration_basic[ann] { - $$ = $ann; - } - | '!'[nott] annotation_declaration[ann] { - if ( !$ann->annotation->rtti_isFunctionAnnotation() || !((FunctionAnnotation *)($ann->annotation))->isSpecialized() ) { - das_yyerror(scanner,"can only run logical operations on contracts", tokAt(scanner, @ann), - CompilationError::invalid_annotation); } - $$ = new AnnotationDeclaration(); - $$->at = tokAt(scanner, @nott); - $$->annotation = newLogicAnnotation(LogicAnnotationOp::Not,$ann,nullptr); - } - | annotation_declaration[ann] ANDAND[andd] annotation_declaration[ann2] { - if ( !$ann->annotation->rtti_isFunctionAnnotation() || !((FunctionAnnotation *)($ann->annotation))->isSpecialized() ) { - das_yyerror(scanner,"can only run logical operations on contracts", tokAt(scanner, @ann), - CompilationError::invalid_annotation); } - if ( !$ann2->annotation->rtti_isFunctionAnnotation() || !((FunctionAnnotation *)($ann2->annotation))->isSpecialized() ) { - das_yyerror(scanner,"can only run logical operations on contracts", tokAt(scanner, @ann2), - CompilationError::invalid_annotation); } - $$ = new AnnotationDeclaration(); - $$->at = tokAt(scanner, @andd); - $$->annotation = newLogicAnnotation(LogicAnnotationOp::And,$ann,$ann2); - } - | annotation_declaration[ann] OROR[andd] annotation_declaration[ann2] { - if ( !$ann->annotation || !$ann->annotation->rtti_isFunctionAnnotation() || !((FunctionAnnotation *)($ann->annotation))->isSpecialized() ) { - das_yyerror(scanner,"can only run logical operations on contracts", tokAt(scanner, @ann), - CompilationError::invalid_annotation); } - if ( !$ann2->annotation || !$ann2->annotation->rtti_isFunctionAnnotation() || !((FunctionAnnotation *)($ann2->annotation))->isSpecialized() ) { - das_yyerror(scanner,"can only run logical operations on contracts", tokAt(scanner, @ann2), - CompilationError::invalid_annotation); } - $$ = new AnnotationDeclaration(); - $$->at = tokAt(scanner, @andd); - $$->annotation = newLogicAnnotation(LogicAnnotationOp::Or,$ann,$ann2); - } - | annotation_declaration[ann] XORXOR[andd] annotation_declaration[ann2] { - if ( !$ann->annotation->rtti_isFunctionAnnotation() || !((FunctionAnnotation *)($ann->annotation))->isSpecialized() ) { - das_yyerror(scanner,"can only run logical operations on contracts", tokAt(scanner, @ann), - CompilationError::invalid_annotation); } - if ( !$ann2->annotation->rtti_isFunctionAnnotation() || !((FunctionAnnotation *)($ann2->annotation))->isSpecialized() ) { - das_yyerror(scanner,"can only run logical operations on contracts", tokAt(scanner, @ann2), - CompilationError::invalid_annotation); } - $$ = new AnnotationDeclaration(); - $$->at = tokAt(scanner, @andd); - $$->annotation = newLogicAnnotation(LogicAnnotationOp::Xor,$ann,$ann2); - } - | '(' annotation_declaration[ann] ')' { - $$ = $ann; - } - | RPIPE annotation_declaration[ann] { - $$ = $ann; - $ann->inherited = true; - } - ; - -annotation_list - : annotation_declaration[ann] { - $$ = new AnnotationList(); - $$->push_back(AnnotationDeclarationPtr($ann)); - } - | annotation_list[annL] ',' annotation_declaration[ann] { - $$ = $annL; - $$->push_back(AnnotationDeclarationPtr($ann)); - } - ; - -optional_annotation_list - : { $$ = nullptr; } - | '[' annotation_list[annL] ']' { $$ = $annL; } - ; - -optional_function_argument_list - : { $$ = nullptr; } - | '(' ')' { $$ = nullptr; } - | '(' function_argument_list[list] ')' { $$ = $list; } - ; - -optional_function_type - : { - $$ = new TypeDecl(Type::autoinfer); - } - | ':' type_declaration[typeDecl] { - $$ = $typeDecl; - $$->at = tokAt(scanner,@typeDecl); - } - | RARROW type_declaration[typeDecl] { - $$ = $typeDecl; - $$->at = tokAt(scanner,@typeDecl); - } - ; - -function_name - : NAME[name] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - $$ = $name; - } - | DAS_OPERATOR '!' { $$ = new string("!"); } - | DAS_OPERATOR '~' { $$ = new string("~"); } - | DAS_OPERATOR ADDEQU { $$ = new string("+="); } - | DAS_OPERATOR SUBEQU { $$ = new string("-="); } - | DAS_OPERATOR MULEQU { $$ = new string("*="); } - | DAS_OPERATOR DIVEQU { $$ = new string("/="); } - | DAS_OPERATOR MODEQU { $$ = new string("%="); } - | DAS_OPERATOR ANDEQU { $$ = new string("&="); } - | DAS_OPERATOR OREQU { $$ = new string("|="); } - | DAS_OPERATOR XOREQU { $$ = new string("^="); } - | DAS_OPERATOR ANDANDEQU { $$ = new string("&&="); } - | DAS_OPERATOR OROREQU { $$ = new string("||="); } - | DAS_OPERATOR XORXOREQU { $$ = new string("^^="); } - | DAS_OPERATOR ANDAND { $$ = new string("&&"); } - | DAS_OPERATOR OROR { $$ = new string("||"); } - | DAS_OPERATOR XORXOR { $$ = new string("^^"); } - | DAS_OPERATOR '+' { $$ = new string("+"); } - | DAS_OPERATOR '-' { $$ = new string("-"); } - | DAS_OPERATOR '*' { $$ = new string("*"); } - | DAS_OPERATOR '/' { $$ = new string("/"); } - | DAS_OPERATOR '%' { $$ = new string("%"); } - | DAS_OPERATOR '<' { $$ = new string("<"); } - | DAS_OPERATOR '>' { $$ = new string(">"); } - | DAS_OPERATOR DOTDOT { $$ = new string("interval"); } - | DAS_OPERATOR EQUEQU { $$ = new string("=="); } - | DAS_OPERATOR NOTEQU { $$ = new string("!="); } - | DAS_OPERATOR LEEQU { $$ = new string("<="); } - | DAS_OPERATOR GREQU { $$ = new string(">="); } - | DAS_OPERATOR '&' { $$ = new string("&"); } - | DAS_OPERATOR '|' { $$ = new string("|"); } - | DAS_OPERATOR '^' { $$ = new string("^"); } - | ADDADD DAS_OPERATOR { $$ = new string("++"); } - | SUBSUB DAS_OPERATOR { $$ = new string("--"); } - | DAS_OPERATOR ADDADD { $$ = new string("+++"); } - | DAS_OPERATOR SUBSUB { $$ = new string("---"); } - | DAS_OPERATOR SHL { $$ = new string("<<"); } - | DAS_OPERATOR SHR { $$ = new string(">>"); } - | DAS_OPERATOR SHLEQU { $$ = new string("<<="); } - | DAS_OPERATOR SHREQU { $$ = new string(">>="); } - | DAS_OPERATOR ROTL { $$ = new string("<<<"); } - | DAS_OPERATOR ROTR { $$ = new string(">>>"); } - | DAS_OPERATOR ROTLEQU { $$ = new string("<<<="); } - | DAS_OPERATOR ROTREQU { $$ = new string(">>>="); } - | DAS_OPERATOR '[' ']' { $$ = new string("[]"); } - | DAS_OPERATOR '[' ']' LARROW { $$ = new string("[]<-"); } - | DAS_OPERATOR '[' ']' CLONEEQU { $$ = new string("[]:="); } - | DAS_OPERATOR '[' ']' ADDEQU { $$ = new string("[]+="); } - | DAS_OPERATOR '[' ']' SUBEQU { $$ = new string("[]-="); } - | DAS_OPERATOR '[' ']' MULEQU { $$ = new string("[]*="); } - | DAS_OPERATOR '[' ']' DIVEQU { $$ = new string("[]/="); } - | DAS_OPERATOR '[' ']' MODEQU { $$ = new string("[]%="); } - | DAS_OPERATOR '[' ']' ANDEQU { $$ = new string("[]&="); } - | DAS_OPERATOR '[' ']' OREQU { $$ = new string("[]|="); } - | DAS_OPERATOR '[' ']' XOREQU { $$ = new string("[]^="); } - | DAS_OPERATOR '[' ']' ANDANDEQU { $$ = new string("[]&&="); } - | DAS_OPERATOR '[' ']' OROREQU { $$ = new string("[]||="); } - | DAS_OPERATOR '[' ']' XORXOREQU { $$ = new string("[]^^="); } - | DAS_OPERATOR QBRA ']' { $$ = new string("?[]"); } - | DAS_OPERATOR '.' { $$ = new string("."); } - | DAS_OPERATOR QDOT { $$ = new string("?."); } - | DAS_OPERATOR '.' NAME[name] { $$ = new string(".`"+*$name); delete $name; } - | DAS_OPERATOR '.' NAME[name] CLONEEQU { $$ = new string(".`"+*$name+"`clone"); delete $name; } - | DAS_OPERATOR '.' NAME[name] ADDEQU { $$ = new string(".`"+*$name+"`+="); delete $name; } - | DAS_OPERATOR '.' NAME[name] SUBEQU { $$ = new string(".`"+*$name+"`-="); delete $name; } - | DAS_OPERATOR '.' NAME[name] MULEQU { $$ = new string(".`"+*$name+"`*="); delete $name; } - | DAS_OPERATOR '.' NAME[name] DIVEQU { $$ = new string(".`"+*$name+"`/="); delete $name; } - | DAS_OPERATOR '.' NAME[name] MODEQU { $$ = new string(".`"+*$name+"`%="); delete $name; } - | DAS_OPERATOR '.' NAME[name] ANDEQU { $$ = new string(".`"+*$name+"`&="); delete $name; } - | DAS_OPERATOR '.' NAME[name] OREQU { $$ = new string(".`"+*$name+"`|="); delete $name; } - | DAS_OPERATOR '.' NAME[name] XOREQU { $$ = new string(".`"+*$name+"`^="); delete $name; } - | DAS_OPERATOR '.' NAME[name] ANDANDEQU { $$ = new string(".`"+*$name+"`&&="); delete $name; } - | DAS_OPERATOR '.' NAME[name] OROREQU { $$ = new string(".`"+*$name+"`||="); delete $name; } - | DAS_OPERATOR '.' NAME[name] XORXOREQU { $$ = new string(".`"+*$name+"`^^="); delete $name; } - | DAS_OPERATOR QDOT NAME[name] { $$ = new string("?.`"+*$name); delete $name;} - | DAS_OPERATOR CLONEEQU { $$ = new string("clone"); } - | DAS_OPERATOR DAS_DELETE { $$ = new string("finalize"); } - | DAS_OPERATOR QQ { $$ = new string("??"); } - | DAS_OPERATOR DAS_IS { $$ = new string("`is"); } - | DAS_OPERATOR DAS_AS { $$ = new string("`as"); } - | DAS_OPERATOR DAS_IS NAME[name] { $$ = $name; *$name = "`is`" + *$name; } - | DAS_OPERATOR DAS_AS NAME[name] { $$ = $name; *$name = "`as`" + *$name; } - | DAS_OPERATOR '?' DAS_AS { $$ = new string("?as"); } - | DAS_OPERATOR '?' DAS_AS NAME[name] { $$ = $name; *$name = "?as`" + *$name; } - | DAS_TBOOL { $$ = new string("bool"); } - | DAS_TSTRING { $$ = new string("string"); } - | DAS_TINT { $$ = new string("int"); } - | DAS_TINT2 { $$ = new string("int2"); } - | DAS_TINT3 { $$ = new string("int3"); } - | DAS_TINT4 { $$ = new string("int4"); } - | DAS_TUINT { $$ = new string("uint"); } - | DAS_TUINT2 { $$ = new string("uint2"); } - | DAS_TUINT3 { $$ = new string("uint3"); } - | DAS_TUINT4 { $$ = new string("uint4"); } - | DAS_TFLOAT { $$ = new string("float"); } - | DAS_TFLOAT2 { $$ = new string("float2"); } - | DAS_TFLOAT3 { $$ = new string("float3"); } - | DAS_TFLOAT4 { $$ = new string("float4"); } - | DAS_TRANGE { $$ = new string("range"); } - | DAS_TURANGE { $$ = new string("urange"); } - | DAS_TRANGE64 { $$ = new string("range64"); } - | DAS_TURANGE64{ $$ = new string("urange64"); } - | DAS_TINT64 { $$ = new string("int64"); } - | DAS_TUINT64 { $$ = new string("uint64"); } - | DAS_TDOUBLE { $$ = new string("double"); } - | DAS_TINT8 { $$ = new string("int8"); } - | DAS_TUINT8 { $$ = new string("uint8"); } - | DAS_TINT16 { $$ = new string("int16"); } - | DAS_TUINT16 { $$ = new string("uint16"); } - | DAS_TFLOAT16 { $$ = new string("float16"); } - | DAS_THALF2 { $$ = new string("half2"); } - | DAS_THALF3 { $$ = new string("half3"); } - | DAS_THALF4 { $$ = new string("half4"); } - | DAS_THALF8 { $$ = new string("half8"); } - | DAS_TSHORT2 { $$ = new string("short2"); } - | DAS_TSHORT3 { $$ = new string("short3"); } - | DAS_TSHORT4 { $$ = new string("short4"); } - | DAS_TSHORT8 { $$ = new string("short8"); } - | DAS_TUSHORT2 { $$ = new string("ushort2"); } - | DAS_TUSHORT3 { $$ = new string("ushort3"); } - | DAS_TUSHORT4 { $$ = new string("ushort4"); } - | DAS_TUSHORT8 { $$ = new string("ushort8"); } - | DAS_TBYTE2 { $$ = new string("byte2"); } - | DAS_TBYTE3 { $$ = new string("byte3"); } - | DAS_TBYTE4 { $$ = new string("byte4"); } - | DAS_TBYTE8 { $$ = new string("byte8"); } - | DAS_TBYTE16 { $$ = new string("byte16"); } - | DAS_TUBYTE2 { $$ = new string("ubyte2"); } - | DAS_TUBYTE3 { $$ = new string("ubyte3"); } - | DAS_TUBYTE4 { $$ = new string("ubyte4"); } - | DAS_TUBYTE8 { $$ = new string("ubyte8"); } - | DAS_TUBYTE16 { $$ = new string("ubyte16"); } - ; - -optional_template - : { $$ = false; } - | DAS_TEMPLATE { $$ = true; } - ; - -global_function_declaration - : optional_annotation_list[annL] DAS_DEF[from] optional_template[isTemplate] function_declaration[func] { - $func->atDecl = tokRangeAt(scanner,@from,@func); - $func->isTemplate = $isTemplate; - assignDefaultArguments($func); - runFunctionAnnotations(scanner, yyextra, $func, $annL, tokAt(scanner,@annL)); - if ( $func->isGeneric() ) { - implAddGenericFunction(scanner,$func); - } else { - if ( !yyextra->g_Program->addFunction($func) ) { - das_yyerror(scanner,"function is already defined " + - $func->getMangledName(),$func->at, - CompilationError::function_already_declared); - } - } - $func->delRef(); - } - ; - -optional_public_or_private_function - : { $$ = yyextra->g_thisStructure ? !yyextra->g_thisStructure->privateStructure : yyextra->g_Program->thisModule->isPublic; } - | DAS_PRIVATE { $$ = false; } - | DAS_PUBLIC { $$ = true; } - ; - -function_declaration_header - : function_name[name] optional_function_argument_list[list] optional_function_type[result] { - $$ = ast_functionDeclarationHeader(scanner,$name,$list,$result,tokAt(scanner,@name)); - } - ; - -function_declaration - : optional_public_or_private_function[pub_func] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@pub_func); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeFunction(tak); - } - } function_declaration_header[func] expression_block[block] { - $func->body = $block; - $func->privateFunction = !$pub_func; - $$ = $func; - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@block); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterFunction($func,tak); - } - } - ; - -open_block - : '{' { $$ = 0xdeadbeef; } - | OPEN_BRACE[depth] { $$ = $depth; } - -close_block - : '}' { $$ = 0xdeadbeef; } - | CLOSE_BRACE[depth] { $$ = $depth; } - -expression_block - : open_block [bbegin] expressions[block] close_block [bend] { - auto prev_loc = format::Pos::from(tokAt(scanner,@bbegin)); - handle_brace(prev_loc, $bbegin, format::get_substring(prev_loc, format::Pos::from_last(tokAt(scanner,@block))), - yyextra->das_tab_size, format::Pos::from_last(tokAt(scanner,@block))); - $$ = $block; - $$->at = tokRangeAt(scanner,@bbegin,@bend); - } - | open_block [bbegin] expressions[block] close_block DAS_FINALLY open_block[bbegin_f] expressions[final] close_block [bend] { - auto prev_loc = format::Pos::from(tokAt(scanner,@bbegin)); - if (format::is_replace_braces() && $bbegin != 0xdeadbeef && format::prepare_rule(prev_loc)) { - handle_brace(prev_loc, $bbegin, format::get_substring(prev_loc, format::Pos::from_last(tokAt(scanner,@block))), - yyextra->das_tab_size, format::Pos::from_last(tokAt(scanner,@block))); - auto prev_loc_f = format::Pos::from(tokAt(scanner,@bbegin_f)); - assert($bbegin_f != 0xdeadbeef); - { - const auto internal_f = format::get_substring(prev_loc_f, format::Pos::from_last(tokAt(scanner,@final))); - format::get_writer() << " finally {" << internal_f << "\n" << string($bbegin_f * yyextra->das_tab_size, ' ') + "}"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@final))); - } - } - - auto pB = (ExprBlock *) $block; - auto pF = (ExprBlock *) $final; - swap ( pB->finalList, pF->list ); - $$ = $block; - $$->at = tokRangeAt(scanner,@bbegin,@bend); - delete $final; - } - ; - -expr_call_pipe - : expr[call] expr_full_block_assumed_piped[block] { - if ( $call->rtti_isCallLikeExpr() ) { - auto start = format::Pos::from_last(tokAt(scanner, @call)); - start.column -= 1; // drop ) - if (format::is_replace_braces() && format::prepare_rule(start)) { - if (!((ExprLooksLikeCall *)$call)->arguments.empty()) { - format::get_writer() << ", "; - } - format::get_writer() << format::get_substring(tokAt(scanner, @block)) << ");"; - format::finish_rule(format::Pos::from_last(tokAt(scanner, @block))); - } - ((ExprLooksLikeCall *)$call)->arguments.push_back($block); - $$ = $call; - } else { - $$ = $call; - delete $block; - } - } - | expression_keyword[call] expr_full_block_assumed_piped[block] { - if ( $call->rtti_isCallLikeExpr() ) { - ((ExprLooksLikeCall *)$call)->arguments.push_back($block); - $$ = $call; - } else { - $$ = $call; - delete $block; - } - } - | DAS_GENERATOR[loc] '<' type_declaration_no_options[typeDecl] '>' optional_capture_list[clist] expr_full_block_assumed_piped[subexpr] { - $$ = ast_makeGenerator(scanner,$typeDecl,$clist,$subexpr,tokAt(scanner,@loc),tokAt(scanner,@clist)); - } - ; - -expression_any - : SEMICOLON { $$ = nullptr; } - | ';' { $$ = nullptr; } - | expr_pipe[subexpr] { $$ = $subexpr; } - | expr_keyword[subexpr] { $$ = $subexpr; } - | expr_assign_pipe[subexpr] { $$ = $subexpr; } - | expr_assign[subexpr] semicolon { $$ = $subexpr; } - | expression_delete[subexpr] semicolon { $$ = $subexpr; } - | expression_let[subexpr] { $$ = $subexpr; } - | expression_while_loop[subexpr] { $$ = $subexpr; } - | expression_unsafe[subexpr] { $$ = $subexpr; } - | expression_with[subexpr] { $$ = $subexpr; } - | expression_with_alias[subexpr] { $$ = $subexpr; } - | expression_for_loop[subexpr] { $$ = $subexpr; } - | expression_break[subexpr] semicolon { $$ = $subexpr; } - | expression_continue[subexpr] semicolon { $$ = $subexpr; } - | expression_return[subexpr] { $$ = $subexpr; } - | expression_yield[subexpr] { $$ = $subexpr; } - | expression_if_then_else[subexpr] { $$ = $subexpr; } - | expression_try_catch[subexpr] { $$ = $subexpr; } - | expression_label[subexpr] semicolon { $$ = $subexpr; } - | expression_goto[subexpr] semicolon { $$ = $subexpr; } - | DAS_PASS semicolon { $$ = nullptr; } - ; - -expressions - : { - $$ = new ExprBlock(); - $$->at = LineInfo(yyextra->g_FileAccessStack.back(), - yylloc.first_column,yylloc.first_line,yylloc.last_column,yylloc.last_line); - } - | expressions[block] expression_any[subexpr] { - $$ = $block; - if ( $subexpr ) { - static_cast($block)->list.push_back($subexpr); - } - } - | expressions[block] error { - delete $block; $$ = nullptr; YYABORT; - } - ; - -expr_keyword - : KEYWORD[kwd] expr[subexpr] expression_block[block] { - format::wrap_par_expr(tokAt(scanner,@subexpr), $subexpr->at); // wrap match (expr) - auto pCall = yyextra->g_Program->makeCall(tokAt(scanner,@kwd),*$kwd); - pCall->arguments.push_back($subexpr); - auto resT = new TypeDecl(Type::autoinfer); - auto blk = ast_makeBlock(scanner,0,nullptr,nullptr,nullptr,resT,$block,tokAt(scanner,@block),tokAt(scanner,@block),LineInfo()); - pCall->arguments.push_back(blk); - delete $kwd; - $$ = pCall; - }; - -optional_expr_list - : { $$ = nullptr; } - | expr_list[arguments] optional_comma { $$ = $arguments; } - ; - -optional_expr_list_in_braces - : { $$ = nullptr; } - | '(' optional_expr_list[arguments] optional_comma ')' { $$ = $arguments; } - ; - -optional_expr_map_tuple_list - : { $$ = nullptr; } - | expr_map_tuple_list[arguments] optional_comma { $$ = $arguments; } - ; - -type_declaration_no_options_list - : type_declaration[decl] { - $$ = new vector(); - $$->push_back(new ExprTypeDecl(tokAt(scanner,@decl),$decl)); - } - | type_declaration_no_options_list[declL] c_or_s type_declaration[decl] { - $$ = $declL; - $$->push_back(new ExprTypeDecl(tokAt(scanner,@decl),$decl)); - } - ; - -expression_keyword - : KEYWORD[kwd] '<' { yyextra->das_arrow_depth ++; } type_declaration_no_options_list[declL] '>' { yyextra->das_arrow_depth --; } expr[subexpr] { - auto pCall = yyextra->g_Program->makeCall(tokAt(scanner,@kwd),tokAt(scanner,@subexpr),*$kwd); - pCall->arguments = typesAndSequenceToList($declL,$subexpr); - delete $kwd; - $$ = pCall; - } - | TYPE_FUNCTION[kwd] '<' { yyextra->das_arrow_depth ++; } type_declaration_no_options_list[declL] '>' { yyextra->das_arrow_depth --; } optional_expr_list_in_braces[subexpr] { - auto pCall = yyextra->g_Program->makeCall(tokAt(scanner,@kwd),tokAt(scanner,@subexpr),*$kwd); - pCall->arguments = typesAndSequenceToList($declL,$subexpr); - delete $kwd; - $$ = pCall; - } - ; - -expr_pipe - : expr_assign[fncall] LBPIPE[loc] expr_block[arg] { - Expression * pipeCall = $fncall->tail(); - if ( pipeCall->rtti_isCallLikeExpr() ) { - auto pCall = (ExprLooksLikeCall *) pipeCall; - pCall->arguments.push_back($arg); - $$ = $fncall; - } else if ( pipeCall->rtti_isVar() ) { - // a += b <| c - auto pVar = (ExprVar *) pipeCall; - auto pCall = yyextra->g_Program->makeCall(pVar->at,pVar->name); - pCall->arguments.push_back($arg); - if ( !$fncall->swap_tail(pVar,pCall) ) { - delete pVar; - $$ = pCall; - } else { - $$ = $fncall; - } - } else if ( pipeCall->rtti_isMakeStruct() ) { - auto pMS = (ExprMakeStruct *) pipeCall; - if ( pMS->block ) { - das_yyerror(scanner,"can't pipe into [[ make structure ]]. it already has where closure", - tokAt(scanner,@loc),CompilationError::cant_pipe); - delete $arg; - } else { - pMS->block = $arg; - } - $$ = $fncall; - } else { - das_yyerror(scanner,"can only pipe into function call or [[ make structure ]]", - tokAt(scanner,@loc),CompilationError::cant_pipe); - delete $arg; - $$ = $fncall; - } - } - | LAPIPE[pipe] expr_block[arg] { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, @pipe)))) { - format::get_writer() << "@"; - format::finish_rule(format::Pos::from_last(tokAt(scanner, @pipe))); - } - - $$ = $arg; - } - | LFPIPE[pipe] expr_block[arg] { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, @pipe)))) { - format::get_writer() << "@@"; - format::finish_rule(format::Pos::from_last(tokAt(scanner, @pipe))); - } - $$ = $arg; - } - | LLPIPE[pipe] expr_block[arg] { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, @pipe)))) { - format::get_writer() << "$"; - format::finish_rule(format::Pos::from_last(tokAt(scanner, @pipe))); - } - $$ = $arg; - } - | expr_call_pipe[call] { - $$ = $call; - } - ; - -name_in_namespace - : NAME[name] { $$ = $name; } - | NAME[namespace] COLCOL NAME[name] { - auto ita = yyextra->das_module_alias.find(*$namespace); - if ( ita == yyextra->das_module_alias.end() ) { - *$namespace += "::"; - } else { - *$namespace = ita->second + "::"; - } - *$namespace += *$name; - delete $name; - $$ = $namespace; - } - | COLCOL NAME[name] { *$name = "::" + *$name; $$ = $name; } - ; - -expression_delete - : DAS_DELETE[loc] expr[subexpr] { - $$ = new ExprDelete(tokAt(scanner,@loc), $subexpr); - } - | DAS_DELETE[loc] DAS_EXPLICIT expr[subexpr] { - auto delExpr = new ExprDelete(tokAt(scanner,@loc), $subexpr); - delExpr->native = true; - $$ = delExpr; - } - ; - -new_type_declaration - : '<' { yyextra->das_arrow_depth ++; } type_declaration[typeDecl] '>' { yyextra->das_arrow_depth --; } { - $$ = $typeDecl; - } - | structure_type_declaration[typeDecl] { - $$ = $typeDecl; - } - ; - -expr_new - : DAS_NEWT[loc] new_type_declaration[typeDecl] { - $$ = new ExprNew(tokAt(scanner,@loc),$typeDecl,false); - } - | DAS_NEWT[loc] new_type_declaration[typeDecl] '(' use_initializer[init] ')' { - $$ = new ExprNew(tokAt(scanner,@loc),$typeDecl,true); - ((ExprNew *)$$)->initializer = $init; - } - | DAS_NEWT[loc] new_type_declaration[typeDecl] '(' expr_list[arguments] ')' { - auto pNew = new ExprNew(tokAt(scanner,@loc),$typeDecl,true); - $$ = parseFunctionArguments(pNew,$arguments); - } - | DAS_NEWT[loc] new_type_declaration[typeDecl] '(' make_struct_single[dd] ')' { - ((ExprMakeStruct *)$dd)->at = tokAt(scanner,@typeDecl); - ((ExprMakeStruct *)$dd)->makeType = $typeDecl; - ((ExprMakeStruct *)$dd)->useInitializer = true; // $init; - ((ExprMakeStruct *)$dd)->alwaysUseInitializer = true; - $$ = new ExprAscend(tokAt(scanner,@loc),$dd); - } - | DAS_NEWT[loc] new_type_declaration[typeDecl] '(' DAS_UNINITIALIZED make_struct_single[dd] ')' { - ((ExprMakeStruct *)$dd)->at = tokAt(scanner,@typeDecl); - ((ExprMakeStruct *)$dd)->makeType = $typeDecl; - ((ExprMakeStruct *)$dd)->useInitializer = false; // $init; - ((ExprMakeStruct *)$dd)->alwaysUseInitializer = true; - $$ = new ExprAscend(tokAt(scanner,@loc),$dd); - } - | DAS_NEWT[loc] make_decl[md] { - $$ = new ExprAscend(tokAt(scanner,@loc),$md); - } - ; - -expression_break - : DAS_BREAK[loc] { $$ = new ExprBreak(tokAt(scanner,@loc)); } - ; - -expression_continue - : DAS_CONTINUE[loc] { $$ = new ExprContinue(tokAt(scanner,@loc)); } - ; - -expression_return_no_pipe - : DAS_RETURN[loc] { - $$ = new ExprReturn(tokAt(scanner,@loc),nullptr); - } - | DAS_RETURN[loc] expr_list[subexpr] { - $$ = new ExprReturn(tokAt(scanner,@loc),sequenceToTuple($subexpr)); - } - | DAS_RETURN[loc] LARROW expr_list[subexpr] { - auto pRet = new ExprReturn(tokAt(scanner,@loc),sequenceToTuple($subexpr)); - pRet->moveSemantics = true; - $$ = pRet; - } - ; - -expression_return - : expression_return_no_pipe[result] semicolon { - $$ = $result; - } - | DAS_RETURN[loc] expr_pipe[subexpr] { - $$ = new ExprReturn(tokAt(scanner,@loc),$subexpr); - } - | DAS_RETURN[loc] LARROW expr_pipe[subexpr] { - auto pRet = new ExprReturn(tokAt(scanner,@loc),$subexpr); - pRet->moveSemantics = true; - $$ = pRet; - } - ; - -expression_yield_no_pipe - : DAS_YIELD[loc] expr[subexpr] { - $$ = new ExprYield(tokAt(scanner,@loc),$subexpr); - } - | DAS_YIELD[loc] LARROW expr[subexpr] { - auto pRet = new ExprYield(tokAt(scanner,@loc),$subexpr); - pRet->moveSemantics = true; - $$ = pRet; - } - ; - -expression_yield - : expression_yield_no_pipe[result] semicolon { - $$ = $result; - } - | DAS_YIELD[loc] expr_pipe[subexpr] { - $$ = new ExprYield(tokAt(scanner,@loc),$subexpr); - } - | DAS_YIELD[loc] LARROW expr_pipe[subexpr] { - auto pRet = new ExprYield(tokAt(scanner,@loc),$subexpr); - pRet->moveSemantics = true; - $$ = pRet; - } - ; - -expression_try_catch - : DAS_TRY[loc] expression_block[tryBlock] DAS_CATCH[catch] expression_block[catchBlock] { - const auto end_block = format::Pos::from_last(tokAt(scanner, @tryBlock)); - const auto start = format::Pos::from(tokAt(scanner, @loc)); - if (format::is_replace_braces()) { - format::skip_spaces_or_print(tokAt(scanner, @loc), tokAt(scanner, @tryBlock), tokAt(scanner, @catch), yyextra->das_tab_size); - } - - $$ = new ExprTryCatch(tokAt(scanner,@loc),$tryBlock,$catchBlock); - } - ; - -kwd_let_var_or_nothing - : DAS_LET { $$ = true; } - | DAS_VAR { $$ = false; } - | /* empty */ { $$ = true; } - ; - -kwd_let - : DAS_LET { $$ = true; } - | DAS_VAR { $$ = false; } - ; - -optional_in_scope - : DAS_INSCOPE { $$ = true; } - | /* empty */ { $$ = false; } - ; - -tuple_expansion - : NAME [name] { - $$ = new vector(); - $$->push_back(*$name); - delete $name; - } - | tuple_expansion[list] ',' NAME[name] { - $list->push_back(*$name); - delete $name; - $$ = $list; - } - ; - -tuple_expansion_variable_declaration - : BRABRAB[loc] tuple_expansion[list] ']'[sq_start] ']' [end_expansion] ':' type_declaration_no_options[typeDecl] copy_or_move_or_clone[com] expr[init] semicolon[end] { - // std::cout << "case11" << std::endl; - format::replace_with(false, - format::Pos::from(tokAt(scanner,@loc)), - format::substring_between(tokAt(scanner, @loc), tokAt(scanner, @sq_start)), - format::Pos::from_last(tokAt(scanner,@end_expansion)), "(", ")"); - $$ = new VariableDeclaration($list,tokAt(scanner,@list),$typeDecl,$init); - $$->init_via_move = ($com & CorM_MOVE) !=0; - $$->init_via_clone = ($com & CorM_CLONE) !=0; - $$->isTupleExpansion = true; - } - | '(' tuple_expansion[list] ')' ':' type_declaration_no_options[typeDecl] copy_or_move_or_clone[com] expr[init] semicolon { - $$ = new VariableDeclaration($list,tokAt(scanner,@list),$typeDecl,$init); - $$->init_via_move = ($com & CorM_MOVE) !=0; - $$->init_via_clone = ($com & CorM_CLONE) !=0; - $$->isTupleExpansion = true; - } - | BRABRAB [loc] tuple_expansion[list] ']'[sq_start] ']' [end_expansion] optional_ref[ref] copy_or_move_or_clone[com] expr[init] semicolon { - // std::cout << "case12" << std::endl; - format::replace_with(false, - format::Pos::from(tokAt(scanner,@loc)), - format::substring_between(tokAt(scanner, @loc), tokAt(scanner, @sq_start)), - format::Pos::from_last(tokAt(scanner,@end_expansion)), "(", ")"); - - auto typeDecl = new TypeDecl(Type::autoinfer); - typeDecl->at = tokAt(scanner,@list); - typeDecl->ref = $ref; - $$ = new VariableDeclaration($list,tokAt(scanner,@list),typeDecl,$init); - $$->init_via_move = ($com & CorM_MOVE) !=0; - $$->init_via_clone = ($com & CorM_CLONE) !=0; - $$->isTupleExpansion = true; - } - | '(' tuple_expansion[list] ')' optional_ref[ref] copy_or_move_or_clone[com] expr[init] semicolon { - auto typeDecl = new TypeDecl(Type::autoinfer); - typeDecl->at = tokAt(scanner,@list); - typeDecl->ref = $ref; - $$ = new VariableDeclaration($list,tokAt(scanner,@list),typeDecl,$init); - $$->init_via_move = ($com & CorM_MOVE) !=0; - $$->init_via_clone = ($com & CorM_CLONE) !=0; - $$->isTupleExpansion = true; - } - ; - -expression_let - : kwd_let optional_in_scope let_variable_declaration[decl] { - $$ = ast_Let(scanner,$kwd_let,$optional_in_scope,$decl,tokAt(scanner,@kwd_let),tokAt(scanner,@decl)); - } - | kwd_let optional_in_scope tuple_expansion_variable_declaration[decl] { - $$ = ast_Let(scanner,$kwd_let,$optional_in_scope,$decl,tokAt(scanner,@kwd_let),tokAt(scanner,@decl)); - } - ; - -expr_cast - : DAS_CAST[loc] '<' { yyextra->das_arrow_depth ++; } type_declaration_no_options[decl] '>' { yyextra->das_arrow_depth --; } expr[subexpr] { - $$ = new ExprCast(tokAt(scanner,@loc),$subexpr,$decl); - } - | DAS_UPCAST[loc] '<' { yyextra->das_arrow_depth ++; } type_declaration_no_options[decl] '>' { yyextra->das_arrow_depth --; } expr[subexpr] { - auto pCast = new ExprCast(tokAt(scanner,@loc),$subexpr,$decl); - pCast->upcast = true; - $$ = pCast; - } - | DAS_REINTERPRET[loc] '<' { yyextra->das_arrow_depth ++; } type_declaration_no_options[decl] '>' { yyextra->das_arrow_depth --; } expr[subexpr] { - auto pCast = new ExprCast(tokAt(scanner,@loc),$subexpr,$decl); - pCast->reinterpret = true; - $$ = pCast; - } - ; - -expr_type_decl - : DAS_TYPE[loc] '<' { yyextra->das_arrow_depth ++; } type_declaration[decl] '>' { yyextra->das_arrow_depth --; } { - $$ = new ExprTypeDecl(tokAt(scanner,@loc),$decl); - } - ; - -expr_type_info - : DAS_TYPEINFO[loc] '(' [par1] name_in_namespace[trait] expr[subexpr] ')' { - format::replace_with(false, - format::Pos::from(tokAt(scanner,@par1)), - format::get_substring(tokAt(scanner,@trait)), - format::Pos::from(tokAt(scanner,@subexpr)), " ", "("); - if ( $subexpr->rtti_isTypeDecl() ) { - auto ptd = (ExprTypeDecl *)$subexpr; - $$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,ptd->typeexpr); - delete $subexpr; - } else { - $$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,$subexpr); - } - delete $trait; - } - | DAS_TYPEINFO[loc] '('[par1] name_in_namespace[trait] '<' NAME[subtrait] '>' [rang] expr[subexpr] ')' { - format::replace_with(false, - format::Pos::from(tokAt(scanner,@par1)), - format::get_substring(tokRangeAt(scanner,@trait,@rang)), - format::Pos::from(tokAt(scanner,@subexpr)), " ", "("); - - if ( $subexpr->rtti_isTypeDecl() ) { - auto ptd = (ExprTypeDecl *)$subexpr; - $$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,ptd->typeexpr,*$subtrait); - delete $subexpr; - } else { - $$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,$subexpr,*$subtrait); - } - delete $trait; - delete $subtrait; - } - | DAS_TYPEINFO[loc] '('[par1] name_in_namespace[trait] '<' NAME[subtrait] c_or_s NAME[extratrait] '>'[rang] expr[subexpr] ')' { - format::replace_with(false, - format::Pos::from(tokAt(scanner,@par1)), - format::get_substring(tokRangeAt(scanner,@trait,@rang)), - format::Pos::from(tokAt(scanner,@subexpr)), " ", "("); - - if ( $subexpr->rtti_isTypeDecl() ) { - auto ptd = (ExprTypeDecl *)$subexpr; - $$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,ptd->typeexpr,*$subtrait,*$extratrait); - delete $subexpr; - } else { - $$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,$subexpr,*$subtrait,*$extratrait); - } - delete $trait; - delete $subtrait; - delete $extratrait; - } -/* also new syntax */ - | DAS_TYPEINFO[loc] name_in_namespace[trait] '(' expr[subexpr] ')' { - if ( $subexpr->rtti_isTypeDecl() ) { - auto ptd = (ExprTypeDecl *)$subexpr; - $$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,ptd->typeexpr); - delete $subexpr; - } else { - $$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,$subexpr); - } - delete $trait; - } - | DAS_TYPEINFO[loc] name_in_namespace[trait] '<' NAME[subtrait] '>' '(' expr[subexpr] ')' { - if ( $subexpr->rtti_isTypeDecl() ) { - auto ptd = (ExprTypeDecl *)$subexpr; - $$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,ptd->typeexpr,*$subtrait); - delete $subexpr; - } else { - $$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,$subexpr,*$subtrait); - } - delete $trait; - delete $subtrait; - } - | DAS_TYPEINFO[loc] name_in_namespace[trait] '<' NAME[subtrait] semicolon NAME[extratrait] '>' '(' expr[subexpr] ')' { - if ( $subexpr->rtti_isTypeDecl() ) { - auto ptd = (ExprTypeDecl *)$subexpr; - $$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,ptd->typeexpr,*$subtrait,*$extratrait); - delete $subexpr; - } else { - $$ = new ExprTypeInfo(tokAt(scanner,@loc),*$trait,$subexpr,*$subtrait,*$extratrait); - } - delete $trait; - delete $subtrait; - delete $extratrait; - } - ; - -expr_list - : expr2[subexpr] { - $$ = $subexpr; - } - | expr_list[left] ',' expr2[right] { - $$ = new ExprSequence(tokAt(scanner,@left),$left,$right); - } - ; - -block_or_simple_block - : expression_block[block] { $$ = $block; } - | MAPTO[loc] expr[subexpr] { - auto retE = new ExprReturn(tokAt(scanner,@loc), $subexpr); - auto blkE = new ExprBlock(); - blkE->at = tokAt(scanner,@loc); - blkE->list.push_back(retE); - $$ = blkE; - } - | MAPTO[loc] LARROW expr[subexpr] { - auto retE = new ExprReturn(tokAt(scanner,@loc), $subexpr); - retE->moveSemantics = true; - auto blkE = new ExprBlock(); - blkE->at = tokAt(scanner,@loc); - blkE->list.push_back(retE); - $$ = blkE; - } - ; - -block_or_lambda - : '$' { $$ = 0; /* block */ } - | '@' { $$ = 1; /* lambda */ } - | '@' '@' { $$ = 2; /* local function */ } - ; - -capture_entry - : '&' NAME[name] { $$ = new CaptureEntry(*$name,CaptureMode::capture_by_reference); delete $name; } - | '=' NAME[name] { $$ = new CaptureEntry(*$name,CaptureMode::capture_by_copy); delete $name; } - | LARROW NAME[name] { $$ = new CaptureEntry(*$name,CaptureMode::capture_by_move); delete $name; } - | CLONEEQU NAME[name] { $$ = new CaptureEntry(*$name,CaptureMode::capture_by_clone); delete $name; } - | NAME[op] '(' NAME[name] ')' { $$ = ast_makeCaptureEntry(scanner,tokAt(scanner,@op),*$op,*$name); delete $op; delete $name; } - ; - -capture_list - : capture_entry[ce] { - $$ = new vector(); - $$->push_back(*$ce); - delete $ce; - } - | capture_list[cl] ',' capture_entry[ce] { - $cl->push_back(*$ce); - delete $ce; - $$ = $cl; - } - ; - -optional_capture_list - : { $$ = nullptr; } - | BRABRAB[open] capture_list[cl] ']'[sq_end] ']'[close] { - if (format::prepare_rule(format::Pos::from(tokAt(scanner, @open)))) { - format::get_writer() - << "capture(" - << format::substring_between(tokAt(scanner, @open), tokAt(scanner, @cl)) - << format::get_substring(tokAt(scanner, @cl)) - << format::substring_between(tokAt(scanner, @cl), tokAt(scanner, @sq_end)) - << ")"; - format::finish_rule(format::Pos::from_last(tokAt(scanner, @close))); - } - - ; $$ = $cl; - } - | DAS_CAPTURE '(' capture_list[cl] ')' { $$ = $cl; } - ; - -expr_block - : expression_block[block] { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, @block)))) { - format::get_writer() << "$() "; - format::finish_rule(format::Pos::from(tokAt(scanner, @block))); - } - - ExprBlock * closure = (ExprBlock *) $block; - $$ = new ExprMakeBlock(tokAt(scanner,@block),$block); - closure->returnType = new TypeDecl(Type::autoinfer); - } - | block_or_lambda[bal] optional_annotation_list[annL] optional_capture_list[clist] optional_function_argument_list[list] - optional_function_type[result] block_or_simple_block[block] { - $$ = ast_makeBlock(scanner,$bal,$annL,$clist,$list,$result,$block,tokAt(scanner,@block),tokAt(scanner,@annL),tokAt(scanner,@clist)); - } - ; - -expr_full_block - : block_or_lambda[bal] optional_annotation_list[annL] optional_capture_list[clist] optional_function_argument_list[list] - optional_function_type[result] block_or_simple_block[block] { - $$ = ast_makeBlock(scanner,$bal,$annL,$clist,$list,$result,$block,tokAt(scanner,@block),tokAt(scanner,@annL),tokAt(scanner,@clist)); - } - ; - -expr_full_block_assumed_piped - : block_or_lambda[bal] { yyextra->das_need_oxford_comma = false; } - optional_annotation_list[annL] optional_capture_list[clist] optional_function_argument_list[list] - optional_function_type[result] expression_block[block] { - $$ = ast_makeBlock(scanner,$bal,$annL,$clist,$list,$result,$block,tokAt(scanner,@block),tokAt(scanner,@annL),tokAt(scanner,@clist)); - } - ; - - -expr_numeric_const - : INTEGER[const] { $$ = new ExprConstInt(tokAt(scanner,@const),(int32_t)$const); } - | UNSIGNED_INTEGER[const] { $$ = new ExprConstUInt(tokAt(scanner,@const),(uint32_t)$const); } - | LONG_INTEGER[const] { $$ = new ExprConstInt64(tokAt(scanner,@const),(int64_t)$const); } - | UNSIGNED_LONG_INTEGER[const] { $$ = new ExprConstUInt64(tokAt(scanner,@const),(uint64_t)$const); } - | UNSIGNED_INT8[const] { $$ = new ExprConstUInt8(tokAt(scanner,@const),(uint8_t)$const); } - | DAS_FLOAT[const] { $$ = new ExprConstFloat(tokAt(scanner,@const),(float)$const); } - | DAS_FLOAT16_CONST[const] { $$ = new ExprConstFloat16(tokAt(scanner,@const),(float)$const); } - | DOUBLE[const] { $$ = new ExprConstDouble(tokAt(scanner,@const),(double)$const); } - ; - -expr_assign - : expr[ex] { $$ = $ex; } - | expr[left] '='[loc] expr[right] { $$ = new ExprCopy(tokAt(scanner,@loc),$left,$right); } - | expr[left] LARROW[loc] expr[right] { $$ = new ExprMove(tokAt(scanner,@loc),$left, $right); } - | expr[left] CLONEEQU[loc] expr[right] { $$ = new ExprClone(tokAt(scanner,@loc),$left, $right); } - | expr[left] ANDEQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"&=", $left, $right); } - | expr[left] OREQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"|=", $left, $right); } - | expr[left] XOREQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"^=", $left, $right); } - | expr[left] ANDANDEQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"&&=", $left, $right); } - | expr[left] OROREQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"||=", $left, $right); } - | expr[left] XORXOREQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"^^=", $left, $right); } - | expr[left] ADDEQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"+=", $left, $right); } - | expr[left] SUBEQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"-=", $left, $right); } - | expr[left] MULEQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"*=", $left, $right); } - | expr[left] DIVEQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"/=", $left, $right); } - | expr[left] MODEQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"%=", $left, $right); } - | expr[left] SHLEQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"<<=", $left, $right); } - | expr[left] SHREQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),">>=", $left, $right); } - | expr[left] ROTLEQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"<<<=", $left, $right); } - | expr[left] ROTREQU[loc] expr[right] { $$ = new ExprOp2(tokAt(scanner,@loc),">>>=", $left, $right); } - ; - -expr_assign_pipe_right - : LAPIPE[pipe] expr_block[right] { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, @pipe)))) { - auto tok = tokAt(scanner, @right); - tok.column += 1; - format::get_writer() << "@" << format::get_substring(tok) << ";"; - format::finish_rule(format::Pos::from_last(tok)); - } - - $$ = $right; - } - | LFPIPE[pipe] expr_block[right] { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, @pipe)))) { - auto tok = tokAt(scanner, @right); - tok.column += 1; - format::get_writer() << "@@" << format::get_substring(tok) << ";"; - format::finish_rule(format::Pos::from_last(tok)); - } - $$ = $right; - } - | LLPIPE[pipe] expr_block[right] { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, @pipe)))) { - auto tok = tokAt(scanner, @right); - tok.column += 1; - format::get_writer() << "$" << format::get_substring(tok) << ";"; - format::finish_rule(format::Pos::from_last(tok)); - } - $$ = $right; - } - | expr_call_pipe[right] { $$ = $right; } - ; - - -expr_assign_pipe - : expr[left] '='[loc] expr_assign_pipe_right[right] { $$ = new ExprCopy(tokAt(scanner,@loc),$left,$right); } - | expr[left] LARROW[loc] expr_assign_pipe_right[right] { $$ = new ExprMove(tokAt(scanner,@loc),$left,$right); } - | expr[left] ANDEQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"&=", $left, $right); } - | expr[left] OREQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"|=", $left, $right); } - | expr[left] XOREQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"^=", $left, $right); } - | expr[left] ANDANDEQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"&&=", $left, $right); } - | expr[left] OROREQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"||=", $left, $right); } - | expr[left] XORXOREQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"^^=", $left, $right); } - | expr[left] ADDEQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"+=", $left, $right); } - | expr[left] SUBEQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"-=", $left, $right); } - | expr[left] MULEQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"*=", $left, $right); } - | expr[left] DIVEQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"/=", $left, $right); } - | expr[left] MODEQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"%=", $left, $right); } - | expr[left] SHLEQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"<<=", $left, $right); } - | expr[left] SHREQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),">>=", $left, $right); } - | expr[left] ROTLEQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),"<<<=", $left, $right); } - | expr[left] ROTREQU[loc] expr_assign_pipe_right[right] { $$ = new ExprOp2(tokAt(scanner,@loc),">>>=", $left, $right); } - - ; - -expr_named_call - : name_in_namespace[name] '(' '[' make_struct_fields[list] ']' ')' { - auto nc = new ExprNamedCall(tokAt(scanner,@name),*$name); - nc->arguments = $list; - delete $name; - $$ = nc; - } - | name_in_namespace[name] '(' expr_list[arguments] ',' '[' make_struct_fields[list] ']' ')' { - auto nc = new ExprNamedCall(tokAt(scanner,@name),*$name); - nc->nonNamedArguments = sequenceToList($arguments); - nc->arguments = $list; - delete $name; - $$ = nc; - } - ; - -/* a->b(args) is short for invoke(a.b, a, args) */ -expr_method_call - : expr2[left] RARROW[loc] NAME[method_name] '(' ')' { - auto pInvoke = makeInvokeMethod(tokAt(scanner,@loc), $left, *$method_name); - delete $method_name; - $$ = pInvoke; - } - | expr2[left] RARROW[loc] NAME[method_name] '(' expr_list[arguments] ')' { - auto pInvoke = makeInvokeMethod(tokAt(scanner,@loc), $left, *$method_name); - auto callArgs = sequenceToList($arguments); - pInvoke->arguments.insert ( pInvoke->arguments.end(), callArgs.begin(), callArgs.end() ); - delete $method_name; - $$ = pInvoke; - } - ; - -func_addr_name - : name_in_namespace[name] { - $$ = new ExprAddr(tokAt(scanner,@name),*$name); - delete $name; - } - | MTAG_I[loc] '(' expr2[subexpr] ')' { - auto expr = new ExprAddr(tokAt(scanner,@loc),"``MACRO``TAG``ADDR``"); - $$ = new ExprTag(tokAt(scanner,@subexpr),$subexpr, expr, "i"); - } - ; - -func_addr_expr - : '@' '@' func_addr_name[faddr] { - $$ = $faddr; - } - | '@' '@' '<' { yyextra->das_arrow_depth ++; } type_declaration_no_options[blockType] '>' { yyextra->das_arrow_depth --; } func_addr_name[faddr] { - auto expr = (ExprAddr *) ($faddr->rtti_isAddr() ? $faddr : (((ExprTag *) $faddr)->value)); - expr->funcType = $blockType; - $$ = $faddr; - } - | '@' '@' '<' { yyextra->das_arrow_depth ++; } optional_function_argument_list[list] optional_function_type[result] '>' { yyextra->das_arrow_depth --; } func_addr_name[faddr] { - auto expr = (ExprAddr *) ($faddr->rtti_isAddr() ? $faddr : (((ExprTag *) $faddr)->value)); - expr->funcType = new TypeDecl(Type::tFunction); - expr->funcType->firstType = $result; - if ( $list ) { - varDeclToTypeDecl(scanner, expr->funcType, $list); - deleteVariableDeclarationList($list); - } - $$ = $faddr; - } - ; - -expr_field - : expr2[subexpr] '.'[loc] NAME[name] { - $$ = new ExprField(tokAt(scanner,@loc), tokAt(scanner,@name), $subexpr, *$name); - delete $name; - } - | expr2[subexpr] '.' '.'[loc] NAME[name] { - $$ = new ExprField(tokAt(scanner,@loc), tokAt(scanner,@name), $subexpr, *$name, true); - delete $name; - } - | expr2[left] '.'[loc] NAME[method_name] '(' ')' { - auto pInvoke = makeInvokeMethod(tokAt(scanner,@loc), $left, *$method_name); - delete $method_name; - $$ = pInvoke; - } - | expr2[left] '.'[loc] NAME[method_name] '(' expr_list[arguments] ')' { - auto pInvoke = makeInvokeMethod(tokAt(scanner,@loc), $left, *$method_name); - auto callArgs = sequenceToList($arguments); - pInvoke->arguments.insert ( pInvoke->arguments.end(), callArgs.begin(), callArgs.end() ); - delete $method_name; - $$ = pInvoke; - } - | expr2[left] '.'[loc] NAME[method_name] '(' '[' make_struct_fields[list] ']' ')' { - auto nc = new ExprNamedCall(tokAt(scanner,@method_name),*$method_name); - nc->methodCall = true; - nc->arguments = $list; - nc->nonNamedArguments.push_back($left); - delete $method_name; - $$ = nc; - } - | expr2[left] '.'[loc] basic_type_declaration[method_type] '(' ')' { - auto method_name = das_to_string($method_type); - auto pInvoke = makeInvokeMethod(tokAt(scanner,@loc), $left, method_name); - $$ = pInvoke; - } - | expr2[left] '.'[loc] basic_type_declaration[method_type] '(' expr_list[arguments] ')' { - auto method_name = das_to_string($method_type); - auto pInvoke = makeInvokeMethod(tokAt(scanner,@loc), $left, method_name); - auto callArgs = sequenceToList($arguments); - pInvoke->arguments.insert ( pInvoke->arguments.end(), callArgs.begin(), callArgs.end() ); - $$ = pInvoke; - } - | expr2[subexpr] '.'[loc] { yyextra->das_suppress_errors=true; } error { yyextra->das_suppress_errors=false; } { - $$ = new ExprField(tokAt(scanner,@loc), tokAt(scanner,@loc), $subexpr, ""); - yyerrok; - } - ; - -expr_call - : name_in_namespace[name] '(' ')'[atend] { - $$ = yyextra->g_Program->makeCall(tokAt(scanner,@name),tokAt(scanner,@atend),*$name); - delete $name; - } - | name_in_namespace[name] '(' DAS_UNINITIALIZED ')' { - auto dd = new ExprMakeStruct(tokAt(scanner,@name)); - dd->at = tokAt(scanner,@name); - dd->makeType = new TypeDecl(Type::alias); - dd->makeType->alias = *$name; - dd->useInitializer = false; - dd->alwaysUseInitializer = true; - delete $name; - $$ = dd; - } - | name_in_namespace[name] '(' make_struct_single[dd] ')' { - ((ExprMakeStruct *)$dd)->at = tokAt(scanner,@name); - ((ExprMakeStruct *)$dd)->makeType = new TypeDecl(Type::alias); - ((ExprMakeStruct *)$dd)->makeType->alias = *$name; - ((ExprMakeStruct *)$dd)->useInitializer = true; - ((ExprMakeStruct *)$dd)->alwaysUseInitializer = true; - delete $name; - $$ = $dd; - } - | name_in_namespace[name] '(' DAS_UNINITIALIZED make_struct_single[dd] ')' { - ((ExprMakeStruct *)$dd)->at = tokAt(scanner,@name); - ((ExprMakeStruct *)$dd)->makeType = new TypeDecl(Type::alias); - ((ExprMakeStruct *)$dd)->makeType->alias = *$name; - ((ExprMakeStruct *)$dd)->useInitializer = false; - ((ExprMakeStruct *)$dd)->alwaysUseInitializer = true; - delete $name; - $$ = $dd; - } - | name_in_namespace[name] '(' expr_list[arguments] ')'[atend] { - $$ = parseFunctionArguments(yyextra->g_Program->makeCall(tokAt(scanner,@name),tokAt(scanner,@atend),*$name),$arguments); - delete $name; - } - | basic_type_declaration[type] '(' ')'[atend] { - $$ = yyextra->g_Program->makeCall(tokAt(scanner,@type),tokAt(scanner,@atend),das_to_string($type)); - } - | basic_type_declaration[type] '(' expr_list[arguments] ')'[atend] { - $$ = parseFunctionArguments(yyextra->g_Program->makeCall(tokAt(scanner,@type),tokAt(scanner,@atend),das_to_string($type)),$arguments); - } - ; - -expr2 - : name_in_namespace[name] { need_wrap_current_expr = true; $$ = new ExprVar(tokAt(scanner,@name),*$name); delete $name; } - | expr_field[subexpr] { need_wrap_current_expr = true; $subexpr->at = tokAt(scanner,@subexpr); $$ = $subexpr; } - | expr_mtag[subexpr] { need_wrap_current_expr = true; $subexpr->at = tokAt(scanner,@subexpr); $$ = $subexpr; } - | '!'[loc] expr2[subexpr] { need_wrap_current_expr = true; $$ = new ExprOp1(tokRangeAt(scanner,@loc, @subexpr),"!",$subexpr); } - | '~'[loc] expr2[subexpr] { need_wrap_current_expr = true; $$ = new ExprOp1(tokRangeAt(scanner,@loc, @subexpr),"~",$subexpr); } - | '+'[loc] expr2[subexpr] %prec UNARY_PLUS { need_wrap_current_expr = true; $$ = new ExprOp1(tokRangeAt(scanner,@loc, @subexpr),"+",$subexpr); } - | '-'[loc] expr2[subexpr] %prec UNARY_MINUS { need_wrap_current_expr = true; $$ = new ExprOp1(tokRangeAt(scanner,@loc, @subexpr),"-",$subexpr); } - | expr2[left] SHL[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"<<", $left, $right); } - | expr2[left] SHR[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),">>", $left, $right); } - | expr2[left] ROTL[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"<<<", $left, $right); } - | expr2[left] ROTR[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),">>>", $left, $right); } - | expr2[left] '+'[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"+", $left, $right); } - | expr2[left] '-'[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"-", $left, $right); } - | expr2[left] '*'[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"*", $left, $right); } - | expr2[left] '/'[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"/", $left, $right); } - | expr2[left] '%'[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"%", $left, $right); } - | expr2[left] '<'[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"<", $left, $right); } - | expr2[left] '>'[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),">", $left, $right); } - | expr2[left] EQUEQU[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"==", $left, $right); } - | expr2[left] NOTEQU[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"!=", $left, $right); } - | expr2[left] LEEQU[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"<=", $left, $right); } - | expr2[left] GREQU[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),">=", $left, $right); } - | expr2[left] '&'[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"&", $left, $right); } - | expr2[left] '|'[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"|", $left, $right); } - | expr2[left] '^'[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"^", $left, $right); } - | expr2[left] ANDAND[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"&&", $left, $right); } - | expr2[left] OROR[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"||", $left, $right); } - | expr2[left] XORXOR[loc] expr2[right] { need_wrap_current_expr = true; $$ = new ExprOp2(tokRangeAt(scanner,@left, @right),"^^", $left, $right); } - | expr2[left] DOTDOT[loc] expr2[right] { - need_wrap_current_expr = true; - auto itv = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"interval"); - itv->arguments.push_back($left); - itv->arguments.push_back($right); - $$ = itv; - } - | ADDADD[loc] expr2[subexpr] %prec PRE_INC { need_wrap_current_expr = true; $$ = new ExprOp1(tokRangeAt(scanner,@loc, @subexpr),"++", $subexpr); } - | SUBSUB[loc] expr2[subexpr] %prec PRE_DEC { need_wrap_current_expr = true; $$ = new ExprOp1(tokRangeAt(scanner,@loc, @subexpr),"--", $subexpr); } - | expr2[subexpr] ADDADD[loc] %prec POST_INC { need_wrap_current_expr = true; $$ = new ExprOp1(tokRangeAt(scanner,@subexpr, @loc),"+++", $subexpr); } - | expr2[subexpr] SUBSUB[loc] %prec POST_DEC { need_wrap_current_expr = true; $$ = new ExprOp1(tokRangeAt(scanner,@subexpr, @loc),"---", $subexpr); } - | expr2[subexpr] '['[loc] expr2[index] ']'[end] { need_wrap_current_expr = true; $$ = new ExprAt(tokRangeAt(scanner,@subexpr, @end), $subexpr, $index); } - | expr2[subexpr] '.' '['[loc] expr2[index] ']'[end] { need_wrap_current_expr = true; $$ = new ExprAt(tokRangeAt(scanner,@subexpr, @end), $subexpr, $index, true); } - | expr2[subexpr] QBRA[loc] expr2[index] ']'[end] { need_wrap_current_expr = true; $$ = new ExprSafeAt(tokRangeAt(scanner,@subexpr, @end), $subexpr, $index); } - | expr2[subexpr] '.' QBRA[loc] expr2[index] ']'[end] { need_wrap_current_expr = true; $$ = new ExprSafeAt(tokRangeAt(scanner,@subexpr, @end), $subexpr, $index, true); } - | expr2[subexpr] QDOT[loc] NAME[name] { need_wrap_current_expr = true; $$ = new ExprSafeField(tokRangeAt(scanner,@subexpr,@name), tokAt(scanner,@name), $subexpr, *$name); delete $name; } - | expr2[subexpr] '.' QDOT[loc] NAME[name] { need_wrap_current_expr = true; $$ = new ExprSafeField(tokRangeAt(scanner,@subexpr,@name), tokAt(scanner,@name), $subexpr, *$name, true); delete $name; } - | '*'[loc] expr2[subexpr] %prec DEREF { need_wrap_current_expr = true; $$ = new ExprPtr2Ref(tokAt(scanner,@loc),$subexpr); } - | expr2[subexpr] '?'[loc] expr2[left] ':' expr2[right] { - need_wrap_current_expr = true; $$ = new ExprOp3(tokRangeAt(scanner,@subexpr, @right),"?",$subexpr,$left,$right); - } -// -------------------------------------------------------------------------------------------------------------------- -// Later expressions are wrapped. Before not. Which means if they are mult line we should wrap them with parentheses! -// -------------------------------------------------------------------------------------------------------------------- - - | DAS_NULL[loc] { $$ = new ExprConstPtr(tokAt(scanner,@loc),nullptr); } - | expr_numeric_const[nc] { $$ = $nc; } - | expr_reader[rdr] { $$ = $rdr; } - | string_builder[sb] { $$ = $sb; } - | make_decl[md] { $$ = $md; } - | DAS_TRUE[loc] { $$ = new ExprConstBool(tokAt(scanner,@loc),true); } - | DAS_FALSE[loc] { $$ = new ExprConstBool(tokAt(scanner,@loc),false); } - | '(' expr_list[subexpr] optional_comma[comma] ')' { - if ( $subexpr->rtti_isSequence() ) { - auto mkt = new ExprMakeTuple(tokAt(scanner,@subexpr)); - mkt->values = sequenceToList($subexpr); - mkt->shorthandRecordNames = ast_tupleCollectShorthandNames(mkt->values); - $$ = mkt; - } else if ( $comma ) { - auto mkt = new ExprMakeTuple(tokAt(scanner,@subexpr)); - mkt->values.push_back($subexpr); - mkt->shorthandRecordNames = ast_tupleCollectShorthandNames(mkt->values); - $$ = mkt; - } else { - $subexpr->at = tokAt(scanner, @subexpr); - $$ = $subexpr; - } - } - | func_addr_expr[subexpr] { $$ = $subexpr; } - | expr_call[call] { $$ = $call; } - | DAS_DEREF[loc] '(' expr2[subexpr] ')' { $$ = new ExprPtr2Ref(tokAt(scanner,@loc),$subexpr); } - | DAS_ADDR[loc] '(' expr2[subexpr] ')' { $$ = new ExprRef2Ptr(tokAt(scanner,@loc),$subexpr); } - | DAS_GENERATOR[loc] '<' type_declaration_no_options[typeDecl] '>' optional_capture_list[clist] '(' ')' { - $$ = ast_makeGenerator(scanner,$typeDecl,$clist,nullptr,tokAt(scanner,@loc),tokAt(scanner,@clist)); - } - | DAS_GENERATOR[loc] '<' type_declaration_no_options[typeDecl] '>' optional_capture_list[clist] '(' expr2[subexpr] ')' { - $$ = ast_makeGenerator(scanner,$typeDecl,$clist,$subexpr,tokAt(scanner,@loc),tokAt(scanner,@clist)); - } - | expr2[subexpr] QQ[loc] expr2[dval] { $$ = new ExprNullCoalescing(tokRangeAt(scanner,@subexpr, @dval),$subexpr,$dval); } - | expr2[subexpr] DAS_IS[loc] DAS_TYPE '<' { yyextra->das_arrow_depth ++; } type_declaration_no_options[decl] '>'[end] { yyextra->das_arrow_depth --; } { - $$ = new ExprIs(tokRangeAt(scanner,@subexpr, @end),$subexpr,$decl); - } - | expr2[subexpr] DAS_IS[loc] basic_type_declaration[decl] { - auto vdecl = new TypeDecl($decl); - vdecl->at = tokAt(scanner,@decl); - $$ = new ExprIs(tokRangeAt(scanner,@subexpr,@decl),$subexpr,vdecl); - } - | expr2[subexpr] DAS_IS[loc] NAME[vname] { - $$ = new ExprIsVariant(tokRangeAt(scanner,@subexpr, @vname),$subexpr,*$vname); - delete $vname; - } - | expr2[subexpr] DAS_AS[loc] NAME[vname] { - $$ = new ExprAsVariant(tokRangeAt(scanner,@subexpr, @vname),$subexpr,*$vname); - delete $vname; - } - | expr2[subexpr] DAS_AS[loc] DAS_TYPE '<' { yyextra->das_arrow_depth ++; } type_declaration[decl] '>'[end] { yyextra->das_arrow_depth --; } { - auto vname = $decl->describe(); - $$ = new ExprAsVariant(tokRangeAt(scanner,@subexpr, @end),$subexpr,vname); - delete $decl; - } - | expr2[subexpr] DAS_AS[loc] basic_type_declaration[decl] { - $$ = new ExprAsVariant(tokRangeAt(scanner,@subexpr, @decl),$subexpr,das_to_string($decl)); - } - | expr2[subexpr] '?' DAS_AS[loc] NAME[vname] { - $$ = new ExprSafeAsVariant(tokRangeAt(scanner,@subexpr, @vname),$subexpr,*$vname); - delete $vname; - } - | expr2[subexpr] '?' DAS_AS[loc] DAS_TYPE '<' { yyextra->das_arrow_depth ++; } type_declaration[decl] '>'[end] { yyextra->das_arrow_depth --; } { - auto vname = $decl->describe(); - $$ = new ExprSafeAsVariant(tokRangeAt(scanner,@subexpr, @end),$subexpr,vname); - delete $decl; - } - | expr2[subexpr] '?' DAS_AS[loc] basic_type_declaration[decl] { - $$ = new ExprSafeAsVariant(tokRangeAt(scanner,@subexpr, @decl),$subexpr,das_to_string($decl)); - } - | expr_type_info[subexpr] { $$ = $subexpr; } - | expr_type_decl[subexpr] { $$ = $subexpr; } - | expr_cast[subexpr] { $$ = $subexpr; } - | expr_new[subexpr] { $$ = $subexpr; } - | expr_method_call[subexpr] { $$ = $subexpr; $$->at = tokAt(scanner, @subexpr); } - | expr_named_call[subexpr] { $$ = $subexpr; } - | expr_full_block[subexpr] { $$ = $subexpr; } - | expr2[fncall] LPIPE[loc] expr2[arg] { $$ = ast_lpipe(scanner,$fncall,$arg,tokRangeAt(scanner,@fncall,@arg)); } - | expr2[arg] RPIPE[loc] expr2[fncall] { $$ = ast_rpipe(scanner,$arg,$fncall,tokRangeAt(scanner,@arg, @fncall)); $$->at = tokRangeAt(scanner,@arg, @fncall); } - - | expr2[arg] RPIPE[loc] basic_type_declaration[type] { - auto fncall = yyextra->g_Program->makeCall(tokAt(scanner,@type),tokAt(scanner,@type),das_to_string($type)); - $$ = ast_rpipe(scanner,$arg,fncall,tokRangeAt(scanner,@arg, @type)); - } - | name_in_namespace[ena] NAME[eni] { - if (format::prepare_rule(format::Pos::from_last(tokAt(scanner,@ena)))) { - format::get_writer() << "." << format::get_substring(tokAt(scanner,@eni)); - format::finish_rule(format::Pos::from_last(tokAt(scanner,@eni))); - } - - $$ = ast_NameName(scanner,$ena,$eni,tokRangeAt(scanner,@ena,@eni),tokAt(scanner,@eni)); - } - | DAS_UNSAFE '(' expr2[subexpr] ')' { - $subexpr->alwaysSafe = true; - $subexpr->userSaidItsSafe = true; - $$ = $subexpr; - } - | expression_keyword[kwd] { $$ = $kwd; } - ; - -expr - : expr2[subexpr] %prec END_OF_EXPR { - if (need_wrap_current_expr) { - format::wrap_par_expr_newline(tokAt(scanner,@subexpr), $subexpr->at); - need_wrap_current_expr = false; - } - $$ = $subexpr; - } - -expr_mtag - : MTAG_E '(' expr2[subexpr] ')' { $$ = new ExprTag(tokAt(scanner,@subexpr),$subexpr,"e"); } - | MTAG_I '(' expr2[subexpr] ')' { $$ = new ExprTag(tokAt(scanner,@subexpr),$subexpr,"i"); } - | MTAG_V '(' expr2[subexpr] ')' { $$ = new ExprTag(tokAt(scanner,@subexpr),$subexpr,"v"); } - | MTAG_B '(' expr2[subexpr] ')' { $$ = new ExprTag(tokAt(scanner,@subexpr),$subexpr,"b"); } - | MTAG_A '(' expr2[subexpr] ')' { $$ = new ExprTag(tokAt(scanner,@subexpr),$subexpr,"a"); } - | MTAG_DOTDOTDOT[subexpr] { $$ = new ExprTag(tokAt(scanner,@subexpr),nullptr,"..."); } - | MTAG_C[cname] '(' expr2[subexpr] ')' '(' ')' [atend] { - auto ccall = yyextra->g_Program->makeCall(tokAt(scanner,@cname),tokAt(scanner,@atend),"``MACRO``TAG``CALL``"); - $$ = new ExprTag(tokAt(scanner,@cname),$subexpr,ccall,"c"); - } - | MTAG_C[cname] '(' expr2[subexpr] ')' '(' expr_list[arguments] ')'[atend] { - auto ccall = parseFunctionArguments(yyextra->g_Program->makeCall(tokAt(scanner,@cname),tokAt(scanner,@atend),"``MACRO``TAG``CALL``"),$arguments); - $$ = new ExprTag(tokAt(scanner,@cname),$subexpr,ccall,"c"); - } - | expr2[subexpr] '.'[loc] MTAG_F[cname] '(' expr2[name] ')' { - auto cfield = new ExprField(tokAt(scanner,@loc), tokAt(scanner,@name), $subexpr, "``MACRO``TAG``FIELD``"); - $$ = new ExprTag(tokAt(scanner,@name),$name,cfield,"f"); - } - | expr2[subexpr] QDOT[loc] MTAG_F[cname] '(' expr2[name] ')' { - auto cfield = new ExprSafeField(tokAt(scanner,@loc), tokAt(scanner,@name), $subexpr, "``MACRO``TAG``FIELD``"); - $$ = new ExprTag(tokAt(scanner,@name),$name,cfield,"f"); - } - | expr2[subexpr] '.' '.'[loc] MTAG_F[cname] '(' expr2[name] ')' { - auto cfield = new ExprField(tokAt(scanner,@loc), tokAt(scanner,@name), $subexpr, "``MACRO``TAG``FIELD``", true); - $$ = new ExprTag(tokAt(scanner,@name),$name,cfield,"f"); - } - | expr2[subexpr] '.' QDOT[loc] MTAG_F[cname] '(' expr2[name] ')' { - auto cfield = new ExprSafeField(tokAt(scanner,@loc), tokAt(scanner,@name), $subexpr, "``MACRO``TAG``FIELD``", true); - $$ = new ExprTag(tokAt(scanner,@name),$name,cfield,"f"); - } - | expr2[subexpr] DAS_AS[loc] MTAG_F[cname] '(' expr2[name] ')' { - auto cfield = new ExprAsVariant(tokAt(scanner,@loc),$subexpr,"``MACRO``TAG``FIELD``"); - $$ = new ExprTag(tokAt(scanner,@name),$name,cfield,"f"); - } - | expr2[subexpr] '?' DAS_AS[loc] MTAG_F[cname] '(' expr2[name] ')' { - auto cfield = new ExprSafeAsVariant(tokAt(scanner,@loc),$subexpr,"``MACRO``TAG``FIELD``"); - $$ = new ExprTag(tokAt(scanner,@name),$name,cfield,"f"); - } - | expr2[subexpr] DAS_IS[loc] MTAG_F[cname] '(' expr2[name] ')' { - auto cfield = new ExprIsVariant(tokAt(scanner,@loc),$subexpr,"``MACRO``TAG``FIELD``"); - $$ = new ExprTag(tokAt(scanner,@name),$name,cfield,"f"); - } - | '@' '@'[loc] MTAG_C[cname] '(' expr2[subexpr] ')' { - auto ccall = new ExprAddr(tokAt(scanner,@loc),"``MACRO``TAG``ADDR``"); - $$ = new ExprTag(tokAt(scanner,@cname),$subexpr,ccall,"c"); - } - ; - -optional_field_annotation - : { $$ = nullptr; } - | BRABRAB[open] annotation_argument_list[alist] ']' ']'[close] { - if (format::prepare_rule(format::Pos::from(tokAt(scanner, @open)))) { - for (const auto &arg: *$alist) { - format::get_writer() << "@" << format::get_substring(arg.at); - } - format::finish_rule(format::Pos::from_last(tokAt(scanner, @close))); - } - $$ = $alist; /*this one is gone when BRABRA is disabled*/ - } - | metadata_argument_list[alist] { $$ = $alist; } - ; - -optional_override - : { $$ = OVERRIDE_NONE; } - | DAS_OVERRIDE { $$ = OVERRIDE_OVERRIDE; } - | DAS_SEALED { $$ = OVERRIDE_SEALED; } - ; - -optional_constant - : { $$ = false; } - | DAS_CONST { $$ = true; } - ; - -optional_public_or_private_member_variable - : { $$ = false; } - | DAS_PUBLIC { $$ = false; } - | DAS_PRIVATE { $$ = true; } - ; - -optional_static_member_variable - : { $$ = false; } - | DAS_STATIC { $$ = true; } - ; - -structure_variable_declaration - : optional_field_annotation[alist] optional_static_member_variable[sta] optional_override[ovr] optional_public_or_private_member_variable[isPrivate] variable_declaration[decl] { - $decl->override = $ovr == OVERRIDE_OVERRIDE; - $decl->sealed = $ovr == OVERRIDE_SEALED; - $decl->annotation = $alist; - $decl->isPrivate = $isPrivate; - $decl->isStatic = $sta; - $$ = $decl; - } - ; - -opt_sem - : SEMICOLON { $$ = false; } - | ';' { $$ = true; } - | ';' SEMICOLON { $$ = true; } - | %prec EMPTY {$$ = false; } - ; - - -struct_variable_declaration_list - : { - $$ = new vector(); - } - | struct_variable_declaration_list[list] DAS_TYPEDEF[loc] { yyextra->das_force_oxford_comma=true;} NAME[aname] '=' type_declaration[decl] semicolon opt_sem { - $$ = $list; - ast_structureAlias(scanner,$aname,$decl,tokAt(scanner,@loc)); - } - | struct_variable_declaration_list[list] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@list); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeStructureFields(tak); - } - } structure_variable_declaration[decl] semicolon opt_sem { - $$ = $list; - if ( $decl ) $list->push_back($decl); - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@list); - for ( auto & crd : yyextra->g_CommentReaders ) { - for ( const auto & nl : *($decl->pNameList) ) { - crd->afterStructureField(nl.name.c_str(), nl.at); - } - } - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterStructureFields(tak); - } - } - | struct_variable_declaration_list[list] optional_annotation_list[annL] - DAS_DEF[from] optional_public_or_private_member_variable[isPrivate] DAS_ABSTRACT optional_constant[cnst] { - yyextra->das_force_oxford_comma=true; - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@isPrivate); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeFunction(tak); - } - } function_declaration_header[func] semicolon opt_sem { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@func); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterFunction($func,tak); - } - $func->isTemplate = yyextra->g_thisStructure->isTemplate; - $$ = ast_structVarDefAbstract(scanner,$list,$annL,$isPrivate,$cnst, $func); - } - | struct_variable_declaration_list[list] optional_annotation_list[annL] - DAS_DEF[from] optional_public_or_private_member_variable[isPrivate] optional_static_member_variable[isStatic] optional_override[ovr] optional_constant[cnst] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@cnst); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeFunction(tak); - } - } function_declaration_header[func] expression_block[block] opt_sem { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@block); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterFunction($func,tak); - } - $func->isTemplate = yyextra->g_thisStructure->isTemplate; - $$ = ast_structVarDef(scanner,$list,$annL,$isStatic,$isPrivate,$ovr,$cnst,$func,$block,tokRangeAt(scanner,@from,@block),tokAt(scanner,@annL)); - } - | struct_variable_declaration_list[list] '[' annotation_list[annL] ']' semicolon opt_sem { - das_yyerror(scanner,"structure field or class method annotation expected to remain on the same line with the field or the class", - tokAt(scanner,@annL), CompilationError::syntax_error); - delete $annL; - $$ = $list; - } - ; - -function_argument_declaration_no_type - : optional_field_annotation[ann] kwd_let_var_or_nothing[is_let] variable_declaration_no_type[decl] { - $$ = $decl; - if ( $is_let ) { - $decl->pTypeDecl->constant = true; - } else { - $decl->pTypeDecl->removeConstant = true; - } - $decl->annotation = $ann; - } - ; - -function_argument_declaration_type - : optional_field_annotation[ann] kwd_let_var_or_nothing[is_let] variable_declaration_type[decl] { - $$ = $decl; - if ( $is_let ) { - $decl->pTypeDecl->constant = true; - } else { - $decl->pTypeDecl->removeConstant = true; - } - $decl->annotation = $ann; - } - | MTAG_A '(' expr2[subexpr] ')' { - auto na = new vector(); - na->push_back(VariableNameAndPosition("``MACRO``TAG``","",tokAt(scanner,@subexpr))); - auto decl = new VariableDeclaration(na, new TypeDecl(Type::none), $subexpr); - decl->pTypeDecl->isTag = true; - $$ = decl; - } - ; - -function_argument_list - : function_argument_declaration_no_type[decl] { $$ = new vector(); $$->push_back($decl); } - | function_argument_declaration_type[decl] { $$ = new vector(); $$->push_back($decl); } - | function_argument_declaration_no_type[decl] ';' function_argument_list[list] { $$ = $list; $list->insert($list->begin(),$decl); } - | function_argument_declaration_type[decl] ';' function_argument_list[list] { $$ = $list; $list->insert($list->begin(),$decl); } - | function_argument_declaration_type[decl] ',' function_argument_list[list] { $$ = $list; $list->insert($list->begin(),$decl); } - ; - -tuple_type - : type_declaration [typeDecl] { - $$ = new VariableDeclaration(nullptr,$typeDecl,nullptr); - } - | NAME[name] ':' type_declaration [typeDecl] { - auto na = new vector(); - na->push_back(VariableNameAndPosition(*$name,"",tokAt(scanner,@name))); - $$ = new VariableDeclaration(na,$typeDecl,nullptr); - delete $name; - } - ; - -tuple_type_list - : tuple_type[decl] { $$ = new vector(); $$->push_back($decl); } - | tuple_type_list[list] c_or_s tuple_type[decl] { $$ = $list; $list->push_back($decl); } - ; - -tuple_alias_type_list - : { - $$ = new vector(); - } - | tuple_alias_type_list[list] c_or_s { - $$ = $list; - } - | tuple_alias_type_list[list] tuple_type[decl] c_or_s { - $$ = $list; $list->push_back($decl); - /* - if ( !yyextra->g_CommentReaders.empty() ) { - for ( auto & crd : yyextra->g_CommentReaders ) { - for ( const auto & nl : *($decl->pNameList) ) { - crd->afterVariantEntry(nl.name.c_str(), nl.at); - } - } - } - */ - } - ; - -variant_type - : NAME[name] ':' type_declaration [typeDecl] { - auto na = new vector(); - na->push_back(VariableNameAndPosition(*$name,"",tokAt(scanner,@name))); - $$ = new VariableDeclaration(na,$typeDecl,nullptr); - delete $name; - } - ; - -variant_type_list - : variant_type[decl] { $$ = new vector(); $$->push_back($decl); } - | variant_type_list[list] c_or_s variant_type[decl] { $$ = $list; $list->push_back($decl); } - ; - -variant_alias_type_list - : { - $$ = new vector(); - } - | variant_alias_type_list[list] c_or_s { - $$ = $list; - } - | variant_alias_type_list[list] variant_type[decl] c_or_s { - $$ = $list; $list->push_back($decl); - if ( !yyextra->g_CommentReaders.empty() ) { - for ( auto & crd : yyextra->g_CommentReaders ) { - for ( const auto & nl : *($decl->pNameList) ) { - crd->afterVariantEntry(nl.name.c_str(), nl.at); - } - } - } - } - ; - -copy_or_move - : '=' { $$ = false; } - | LARROW { $$ = true; } - ; - -variable_declaration_no_type /* this one can have uninitialized variable which has no type */ - : variable_name_with_pos_list[list] { - auto autoT = new TypeDecl(Type::autoinfer); - autoT->at = tokAt(scanner,@list); - autoT->ref = false; - $$ = new VariableDeclaration($list,autoT,nullptr); - } - | variable_name_with_pos_list[list] '&' { - auto autoT = new TypeDecl(Type::autoinfer); - autoT->at = tokAt(scanner,@list); - autoT->ref = true; - $$ = new VariableDeclaration($list,autoT,nullptr); - } - | variable_name_with_pos_list[list] copy_or_move[com] expr[init] { - auto typeDecl = new TypeDecl(Type::autoinfer); - typeDecl->at = tokAt(scanner,@list); - $$ = new VariableDeclaration($list,typeDecl,$init); - $$->init_via_move = $com; - } - ; - -variable_declaration_type - : variable_name_with_pos_list[list] ':' type_declaration[typeDecl] { - $$ = new VariableDeclaration($list,$typeDecl,nullptr); - } - | variable_name_with_pos_list[list] ':' type_declaration[typeDecl] copy_or_move[com] expr[init] { - $$ = new VariableDeclaration($list,$typeDecl,$init); - $$->init_via_move = $com; - } - ; - -variable_declaration - : variable_declaration_type[decl] { - $$ = $decl; - } - | variable_declaration_no_type[decl] { - $$ = $decl; - } - ; - -copy_or_move_or_clone - : '=' { $$ = CorM_COPY; } - | LARROW { $$ = CorM_MOVE; } - | CLONEEQU { $$ = CorM_CLONE; } - ; - -optional_ref - : { $$ = false; } - | '&' { $$ = true; } - ; - -let_variable_name_with_pos_list - : NAME[name] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - auto pSL = new vector(); - pSL->push_back(VariableNameAndPosition(*$name,"",tokAt(scanner,@name))); - $$ = pSL; - delete $name; - } - | MTAG_I '(' expr2[subexpr] ')' { - auto pSL = new vector(); - pSL->push_back(VariableNameAndPosition("``MACRO``TAG``","",tokAt(scanner,@subexpr),$subexpr)); - $$ = pSL; - } - | NAME[name] DAS_AKA NAME[akaname] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - das_checkName(scanner,*$akaname,tokAt(scanner,@akaname)); - auto pSL = new vector(); - pSL->push_back(VariableNameAndPosition(*$name,*$akaname,tokAt(scanner,@name))); - $$ = pSL; - delete $name; - delete $akaname; - } - | let_variable_name_with_pos_list[list] ',' NAME[name] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - $list->push_back(VariableNameAndPosition(*$name,"",tokAt(scanner,@name))); - $$ = $list; - delete $name; - } - | let_variable_name_with_pos_list[list] ',' NAME[name] DAS_AKA NAME[akaname] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - das_checkName(scanner,*$akaname,tokAt(scanner,@akaname)); - $list->push_back(VariableNameAndPosition(*$name,*$akaname,tokAt(scanner,@name))); - $$ = $list; - delete $name; - delete $akaname; - } - ; - -let_variable_declaration /* let x; is prohibited. this one can't have uninitialized variable which has no type */ - : let_variable_name_with_pos_list[list] ':' type_declaration_no_options[typeDecl] semicolon { - $$ = new VariableDeclaration($list,$typeDecl,nullptr); - } - | let_variable_name_with_pos_list[list] ':' type_declaration_no_options[typeDecl] copy_or_move_or_clone[com] expr[init] semicolon { - $$ = new VariableDeclaration($list,$typeDecl,$init); - $$->init_via_move = ($com & CorM_MOVE) !=0; - $$->init_via_clone = ($com & CorM_CLONE) !=0; - } - | let_variable_name_with_pos_list[list] ':' type_declaration_no_options[typeDecl] copy_or_move_or_clone[com] expr_pipe[init] { - $$ = new VariableDeclaration($list,$typeDecl,$init); - $$->init_via_move = ($com & CorM_MOVE) !=0; - $$->init_via_clone = ($com & CorM_CLONE) !=0; - } - | let_variable_name_with_pos_list[list] optional_ref[ref] copy_or_move_or_clone[com] expr[init] semicolon { - auto typeDecl = new TypeDecl(Type::autoinfer); - typeDecl->at = tokAt(scanner,@list); - typeDecl->ref = $ref; - $$ = new VariableDeclaration($list,typeDecl,$init); - $$->init_via_move = ($com & CorM_MOVE) !=0; - $$->init_via_clone = ($com & CorM_CLONE) !=0; - } - | let_variable_name_with_pos_list[list] optional_ref[ref] copy_or_move_or_clone[com] expr[init] %prec EMPTY { - // Until absence of semicolon with lambda is not fixed - format::try_semicolon_at_eol(format::Pos::from_last(tokAt(scanner,@init))); - auto typeDecl = new TypeDecl(Type::autoinfer); - typeDecl->at = tokAt(scanner,@list); - typeDecl->ref = $ref; - $$ = new VariableDeclaration($list,typeDecl,$init); - $$->init_via_move = ($com & CorM_MOVE) !=0; - $$->init_via_clone = ($com & CorM_CLONE) !=0; - } - | let_variable_name_with_pos_list[list] optional_ref[ref] copy_or_move_or_clone[com] expr_pipe[init] { - auto typeDecl = new TypeDecl(Type::autoinfer); - typeDecl->at = tokAt(scanner,@list); - typeDecl->ref = $ref; - $$ = new VariableDeclaration($list,typeDecl,$init); - $$->init_via_move = ($com & CorM_MOVE) !=0; - $$->init_via_clone = ($com & CorM_CLONE) !=0; - } - ; - -global_variable_declaration_list - : { - $$ = new vector(); - } - | global_variable_declaration_list[list] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@list); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeGlobalVariables(tak); - } - } optional_field_annotation[ann] let_variable_declaration[decl] opt_sem { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@decl); - for ( auto & crd : yyextra->g_CommentReaders ) - for ( auto & nl : *($decl->pNameList) ) - crd->afterGlobalVariable(nl.name.c_str(),tak); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterGlobalVariables(tak); - } - $$ = $list; - $decl->annotation = $ann; - $list->push_back($decl); - } - ; - -optional_shared - : { $$ = false; } - | DAS_SHARED { $$ = true; } - ; - -optional_public_or_private_variable - : { $$ = yyextra->g_Program->thisModule->isPublic; } - | DAS_PRIVATE { $$ = false; } - | DAS_PUBLIC { $$ = true; } - ; - -global_let - : kwd_let optional_shared[glob_shar] optional_public_or_private_variable[pub_var] open_block[open] global_variable_declaration_list[list] close_block[close] { - handle_brace(format::Pos::from(tokAt(scanner, @open)), $open, - format::get_substring(tokRangeAt(scanner, @open, @close)), - yyextra->das_tab_size, - format::Pos::from_last(tokAt(scanner,@close))); - ast_globalLetList(scanner,$kwd_let,$glob_shar,$pub_var,$list); - } - | kwd_let optional_shared[glob_shar] optional_public_or_private_variable[pub_var] { - yyextra->das_force_oxford_comma=true; - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@pub_var); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeGlobalVariables(tak); - } - } optional_field_annotation[ann] let_variable_declaration[decl] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@decl); - for ( auto & crd : yyextra->g_CommentReaders ) - for ( auto & nl : *($decl->pNameList) ) - crd->afterGlobalVariable(nl.name.c_str(),tak); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterGlobalVariables(tak); - } - ast_globalLet(scanner,$kwd_let,$glob_shar,$pub_var,$ann,$decl); - } - ; - -enum_list - : { - $$ = new Enumeration(); - } - | enum_list[pE] NAME[name] opt_sem[sem] { - format::skip_token(true, false, tokAt(scanner,@sem)); - das_checkName(scanner,*$name,tokAt(scanner,@name)); - if ( !$pE->add(*$name,nullptr,tokAt(scanner,@name)) ) { - das_yyerror(scanner,"enumeration already declared " + *$name, tokAt(scanner,@name), - CompilationError::enumeration_value_already_declared); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto tokName = tokAt(scanner,@name); - for ( auto & crd : yyextra->g_CommentReaders ) { - crd->afterEnumerationEntry($name->c_str(), tokName); - } - } - delete $name; - $$ = $pE; - } - | enum_list[pE] NAME[name] '=' expr[value] opt_sem[sem] { - format::skip_token(true, false, tokAt(scanner,@sem)); - das_checkName(scanner,*$name,tokAt(scanner,@name)); - if ( !$pE->add(*$name,$value,tokAt(scanner,@name)) ) { - das_yyerror(scanner,"enumeration value already declared " + *$name, tokAt(scanner,@name), - CompilationError::enumeration_value_already_declared); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto tokName = tokAt(scanner,@name); - for ( auto & crd : yyextra->g_CommentReaders ) { - crd->afterEnumerationEntry($name->c_str(), tokName); - } - } - delete $name; - $$ = $pE; - } - ; - - -optional_public_or_private_alias - : { $$ = yyextra->g_Program->thisModule->isPublic; } - | DAS_PRIVATE { $$ = false; } - | DAS_PUBLIC { $$ = true; } - ; - - -single_alias - : optional_public_or_private_alias[pubA] NAME[name] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto pubename = tokAt(scanner,@name); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeAlias(pubename); - } - } '=' type_declaration[tdecl] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - $tdecl->isPrivateAlias = !$pubA; - if ( $tdecl->baseType == Type::alias ) { - das_yyerror(scanner,"alias cannot be defined in terms of another alias "+*$name,tokAt(scanner,@name), - CompilationError::invalid_type); - } - $tdecl->alias = *$name; - if ( !yyextra->g_Program->addAlias($tdecl) ) { - das_yyerror(scanner,"type alias is already defined "+*$name,tokAt(scanner,@name), - CompilationError::type_alias_already_declared); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto pubename = tokAt(scanner,@tdecl); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterAlias($name->c_str(),pubename); - } - if (@pubA.first_column == @pubA.last_column) { - @$.first_line = @name.first_line; - @$.first_column = @name.first_column; - } - delete $name; - } - ; - -alias_list - : single_alias[alias] opt_sem { - $$ = new vector(1, tokAt(scanner, @alias)); - } - | alias_list[others] single_alias[alias] opt_sem { - $others->emplace_back(tokAt(scanner, @alias)); - $$ = $others; - } - ; - -alias_declaration - : DAS_TYPEDEF[start] open_block alias_list[alist] close_block[close] { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner, @start)))) { - // todo: comments here and all such places, same rule - for (const auto single: *$alist) { - format::get_writer() << "typedef " << format::get_substring(single) << '\n'; - } - format::finish_rule(format::Pos::from_last(tokAt(scanner, @close))); - } - - } - | DAS_TYPEDEF { yyextra->das_force_oxford_comma=true;} single_alias semicolon - ; - -optional_public_or_private_enum - : { $$ = yyextra->g_Program->thisModule->isPublic; } - | DAS_PRIVATE { $$ = false; } - | DAS_PUBLIC { $$ = true; } - ; - -enum_name - : NAME[name] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto pubename = tokAt(scanner,@name); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeEnumeration(pubename); - } - $$ = ast_addEmptyEnum(scanner, $name, tokAt(scanner,@name)); - } - ; - -enum_declaration - : optional_annotation_list[annL] DAS_ENUM[loc] optional_public_or_private_enum[pubE] enum_name[edecl] open_block[begin] enum_list[pE] close_block[end] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@edecl); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeEnumerationEntries(tak); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@pE); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterEnumerationEntries(tak); - } - const auto first_loc = format::Pos::from(tokAt(scanner,@begin)); - handle_brace(first_loc, $begin, - format::get_substring(first_loc, format::Pos::from_last(tokAt(scanner,@pE))), - yyextra->das_tab_size, - format::Pos::from_last(tokAt(scanner,@pE))); - if ( !yyextra->g_CommentReaders.empty() ) { - auto pubename = tokAt(scanner,@pE); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterEnumeration($edecl->name.c_str(),pubename); - } - ast_enumDeclaration(scanner,$annL,tokAt(scanner,@annL),$pubE,$edecl,$pE,Type::tInt); - } - | optional_annotation_list[annL] DAS_ENUM[loc] optional_public_or_private_enum[pubE] enum_name[edecl] ':' enum_basic_type_declaration[ebt] open_block[begin] enum_list[pE] close_block[end] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@edecl); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeEnumerationEntries(tak); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@pE); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterEnumerationEntries(tak); - } - const auto first_loc = format::Pos::from(tokAt(scanner,@begin)); - handle_brace(first_loc, $begin, - format::get_substring(first_loc, format::Pos::from_last(tokAt(scanner,@pE))), - yyextra->das_tab_size, - format::Pos::from_last(tokAt(scanner,@pE))); - if ( !yyextra->g_CommentReaders.empty() ) { - auto pubename = tokAt(scanner,@pE); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterEnumeration($edecl->name.c_str(),pubename); - } - ast_enumDeclaration(scanner,$annL,tokAt(scanner,@annL),$pubE,$edecl,$pE,$ebt); - } - ; - -optional_structure_parent - : { $$ = nullptr; } - | ':' name_in_namespace[name] { $$ = $name; } - ; - -optional_sealed - : { $$ = false; } - | DAS_SEALED { $$ = true; } - ; - -structure_name - : optional_sealed[sealed] NAME[name] optional_structure_parent[parent] { - $$ = ast_structureName(scanner,$sealed,$name,tokAt(scanner,@name),$parent,tokAt(scanner,@parent)); - } - ; - -class_or_struct - : DAS_CLASS { $$ = CorS_Class; } - | DAS_STRUCT { $$ = CorS_Struct; } - | DAS_CLASS DAS_TEMPLATE { $$ = CorS_ClassTemplate; } - | DAS_STRUCT DAS_TEMPLATE { $$ = CorS_StructTemplate; } - ; - -optional_public_or_private_structure - : { $$ = yyextra->g_Program->thisModule->isPublic; } - | DAS_PRIVATE { $$ = false; } - | DAS_PUBLIC { $$ = true; } - ; - -optional_struct_variable_declaration_list - : { - $$ = new vector(); - } - | open_block [sbegin] struct_variable_declaration_list[list] close_block [send] { - const auto prev_loc = format::Pos::from(tokAt(scanner,@sbegin)); - handle_brace(prev_loc, $sbegin, - format::get_substring(prev_loc, format::Pos::from_last(tokAt(scanner,@list))), - yyextra->das_tab_size, - format::Pos::from_last(tokAt(scanner,@list))); - $$ = $list; - } - ; - -structure_declaration - : optional_annotation_list[annL] class_or_struct[loc] optional_public_or_private_structure[pub_str] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@loc); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeStructure(tak); - } - } structure_name[ps] { - if ( $ps ) { - $ps->isClass = $loc==CorS_Class || $loc==CorS_ClassTemplate; - $ps->isTemplate = $loc==CorS_ClassTemplate || $loc==CorS_StructTemplate; - $ps->privateStructure = !$pub_str; - } - } optional_struct_variable_declaration_list[list] { - if ( $ps ) { - ast_structureDeclaration ( scanner, $annL, tokAt(scanner,@loc), $ps, tokAt(scanner,@ps), $list ); - if ( !yyextra->g_CommentReaders.empty() ) { - auto tak = tokAt(scanner,@loc); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterStructure($ps,tak); - } - } else { - deleteVariableDeclarationList($list); - } - } - ; - -variable_name_with_pos_list - : NAME[name] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - auto pSL = new vector(); - pSL->push_back(VariableNameAndPosition(*$name,"",tokAt(scanner,@name))); - $$ = pSL; - delete $name; - } - | MTAG_I '(' expr2[subexpr] ')' { - auto pSL = new vector(); - pSL->push_back(VariableNameAndPosition("``MACRO``TAG``","",tokAt(scanner,@subexpr),$subexpr)); - $$ = pSL; - } - | NAME[name] DAS_AKA NAME[akaname] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - das_checkName(scanner,*$akaname,tokAt(scanner,@akaname)); - auto pSL = new vector(); - pSL->push_back(VariableNameAndPosition(*$name,*$akaname,tokAt(scanner,@name))); - $$ = pSL; - delete $name; - delete $akaname; - } - | variable_name_with_pos_list[list] ',' NAME[name] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - $list->push_back(VariableNameAndPosition(*$name,"",tokAt(scanner,@name))); - $$ = $list; - delete $name; - } - | variable_name_with_pos_list[list] ',' NAME[name] DAS_AKA NAME[akaname] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - das_checkName(scanner,*$akaname,tokAt(scanner,@akaname)); - $list->push_back(VariableNameAndPosition(*$name,*$akaname,tokAt(scanner,@name))); - $$ = $list; - delete $name; - delete $akaname; - } - ; - -basic_type_declaration - : DAS_TBOOL { $$ = Type::tBool; } - | DAS_TSTRING { $$ = Type::tString; } - | DAS_TINT { $$ = Type::tInt; } - | DAS_TINT8 { $$ = Type::tInt8; } - | DAS_TINT16 { $$ = Type::tInt16; } - | DAS_TINT64 { $$ = Type::tInt64; } - | DAS_TINT2 { $$ = Type::tInt2; } - | DAS_TINT3 { $$ = Type::tInt3; } - | DAS_TINT4 { $$ = Type::tInt4; } - | DAS_TUINT { $$ = Type::tUInt; } - | DAS_TUINT8 { $$ = Type::tUInt8; } - | DAS_TUINT16 { $$ = Type::tUInt16; } - | DAS_TUINT64 { $$ = Type::tUInt64; } - | DAS_TUINT2 { $$ = Type::tUInt2; } - | DAS_TUINT3 { $$ = Type::tUInt3; } - | DAS_TUINT4 { $$ = Type::tUInt4; } - | DAS_TFLOAT { $$ = Type::tFloat; } - | DAS_TFLOAT2 { $$ = Type::tFloat2; } - | DAS_TFLOAT3 { $$ = Type::tFloat3; } - | DAS_TFLOAT4 { $$ = Type::tFloat4; } - | DAS_TFLOAT16 { $$ = Type::tFloat16; } - | DAS_THALF2 { $$ = Type::tHalf2; } - | DAS_THALF3 { $$ = Type::tHalf3; } - | DAS_THALF4 { $$ = Type::tHalf4; } - | DAS_THALF8 { $$ = Type::tHalf8; } - | DAS_TSHORT2 { $$ = Type::tShort2; } - | DAS_TSHORT3 { $$ = Type::tShort3; } - | DAS_TSHORT4 { $$ = Type::tShort4; } - | DAS_TSHORT8 { $$ = Type::tShort8; } - | DAS_TUSHORT2 { $$ = Type::tUShort2; } - | DAS_TUSHORT3 { $$ = Type::tUShort3; } - | DAS_TUSHORT4 { $$ = Type::tUShort4; } - | DAS_TUSHORT8 { $$ = Type::tUShort8; } - | DAS_TBYTE2 { $$ = Type::tByte2; } - | DAS_TBYTE3 { $$ = Type::tByte3; } - | DAS_TBYTE4 { $$ = Type::tByte4; } - | DAS_TBYTE8 { $$ = Type::tByte8; } - | DAS_TBYTE16 { $$ = Type::tByte16; } - | DAS_TUBYTE2 { $$ = Type::tUByte2; } - | DAS_TUBYTE3 { $$ = Type::tUByte3; } - | DAS_TUBYTE4 { $$ = Type::tUByte4; } - | DAS_TUBYTE8 { $$ = Type::tUByte8; } - | DAS_TUBYTE16 { $$ = Type::tUByte16; } - | DAS_TVOID { $$ = Type::tVoid; } - | DAS_TRANGE { $$ = Type::tRange; } - | DAS_TURANGE { $$ = Type::tURange; } - | DAS_TRANGE64 { $$ = Type::tRange64; } - | DAS_TURANGE64 { $$ = Type::tURange64; } - | DAS_TDOUBLE { $$ = Type::tDouble; } - | DAS_TBITFIELD { $$ = Type::tBitfield; } - ; - -enum_basic_type_declaration - : DAS_TINT { $$ = Type::tInt; } - | DAS_TINT8 { $$ = Type::tInt8; } - | DAS_TINT16 { $$ = Type::tInt16; } - | DAS_TUINT { $$ = Type::tUInt; } - | DAS_TUINT8 { $$ = Type::tUInt8; } - | DAS_TUINT16 { $$ = Type::tUInt16; } - | DAS_TINT64 { $$ = Type::tInt64; } - | DAS_TUINT64 { $$ = Type::tUInt64; } - ; - -structure_type_declaration - : name_in_namespace[name] { - $$ = yyextra->g_Program->makeTypeDeclaration(tokAt(scanner,@name),*$name); - if ( !$$ ) { - $$ = new TypeDecl(Type::tVoid); - $$->at = tokAt(scanner,@name); - } - delete $name; - } - ; - -auto_type_declaration - : DAS_TAUTO[loc] { - $$ = new TypeDecl(Type::autoinfer); - $$->at = tokAt(scanner,@loc); - } - | DAS_TAUTO[loc] '(' NAME[alias] ')' { - das_checkName(scanner,*$alias,tokAt(scanner,@alias)); - $$ = new TypeDecl(Type::autoinfer); - $$->at = tokAt(scanner,@loc); - $$->alias = *$alias; - delete $alias; - } - | MTAG_T[loc] '(' expr2[subexpr] ')' { - $$ = new TypeDecl(Type::alias); - $$->at = tokAt(scanner,@loc); - $$->alias = "``MACRO``TAG``"; - $$->isTag = true; - $$->firstType = new TypeDecl(Type::autoinfer); - $$->firstType->at = tokAt(scanner, @subexpr); - $$->firstType->typeMacroExpr.push_back($subexpr); - } - ; - -bitfield_bits - : NAME[name] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - auto pSL = new vector(); - pSL->push_back(*$name); - $$ = pSL; - delete $name; - } - | bitfield_bits[list] semicolon NAME[name] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - $list->push_back(*$name); - $$ = $list; - delete $name; - } - | bitfield_bits[list] ',' NAME[name] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - $list->push_back(*$name); - $$ = $list; - delete $name; - } - ; - - -commas - : ',' - | commas ',' - ; - - -bitfield_alias_bits - : { - auto pSL = new vector>(); - $$ = pSL; - - } - | bitfield_alias_bits[list] NAME[name] SEMICOLON { - if (format::enum_bitfield_with_comma() && format::is_replace_braces() && format::prepare_rule(format::Pos::from_last(tokAt(scanner,@name)))) { - format::get_writer() << ","; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@name))); - } - das_checkName(scanner,*$name,tokAt(scanner,@name)); - $$ = $list; - $$->emplace_back(*$name,nullptr); - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@name); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfieldEntry($name->c_str(),atvname); - } - delete $name; - } - | bitfield_alias_bits[list] NAME[name] commas { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - $$ = $list; - $$->emplace_back(*$name,nullptr); - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@name); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfieldEntry($name->c_str(),atvname); - } - delete $name; - } - | bitfield_alias_bits[list] NAME[name] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - $$ = $list; - $$->emplace_back(*$name,nullptr); - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@name); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfieldEntry($name->c_str(),atvname); - } - delete $name; - } - | bitfield_alias_bits[list] NAME[name] '=' expr[value] SEMICOLON { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - $$ = $list; - $$->emplace_back(*$name,$value); - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@name); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfieldEntry($name->c_str(),atvname); - } - delete $name; - } - | bitfield_alias_bits[list] NAME[name] '=' expr[value] commas { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - $$ = $list; - $$->emplace_back(*$name,$value); - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@name); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfieldEntry($name->c_str(),atvname); - } - delete $name; - } - | bitfield_alias_bits[list] NAME[name] '=' expr[value] { - das_checkName(scanner,*$name,tokAt(scanner,@name)); - $$ = $list; - $$->emplace_back(*$name,$value); - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@name); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfieldEntry($name->c_str(),atvname); - } - delete $name; - } - ; - -bitfield_basic_type_declaration - : { $$ = Type::tBitfield; } - | ':' DAS_TUINT8 { $$ = Type::tBitfield8; } - | ':' DAS_TUINT16 { $$ = Type::tBitfield16; } - | ':' DAS_TUINT { $$ = Type::tBitfield; } - | ':' DAS_TUINT64 { $$ = Type::tBitfield64; } - ; - -bitfield_type_declaration - : DAS_TBITFIELD bitfield_basic_type_declaration[basicType] '<' '>' { - $$ = new TypeDecl($basicType); - $$->at = tokAt(scanner,@basicType); - } - | DAS_TBITFIELD bitfield_basic_type_declaration[basicType] '<' { yyextra->das_arrow_depth ++; } bitfield_bits[nl] '>' { yyextra->das_arrow_depth --; } { - $$ = new TypeDecl($basicType); - $$->argNames = *$nl; - auto maxBits = $$->maxBitfieldBits(); - if ( $$->argNames.size()>maxBits ) { - das_yyerror(scanner,"only " + to_string(maxBits) + " different bits are allowed in a bitfield",tokAt(scanner,@basicType), - CompilationError::invalid_type); - } - $$->at = tokAt(scanner,@basicType); - delete $nl; - } - ; - -c_or_s - : ',' - | semicolon - ; - -table_type_pair - : type_declaration[keyTypeDecl] { - $$.firstType = $keyTypeDecl; - $$.secondType = new TypeDecl(Type::tVoid); - } - | type_declaration[keyTypeDecl] c_or_s type_declaration[valueTypeDecl] { - $$.firstType = $keyTypeDecl; - $$.secondType = $valueTypeDecl; - } - ; - -dim_list - : '[' expr2[dimExpr] ']' { - $$ = appendDimExpr(nullptr, $dimExpr, tokAt(scanner,@dimExpr)); - } - | dim_list[list] '[' expr2[dimExpr] ']' { - $$ = appendDimExpr($list, $dimExpr, tokAt(scanner,@dimExpr)); - } - ; - -type_declaration_no_options - : basic_type_declaration[basicType] { $$ = new TypeDecl($basicType); $$->at = tokAt(scanner,@basicType); } - | auto_type_declaration[typeDecl] { $$ = $typeDecl; } - | bitfield_type_declaration[typeDecl] { $$ = $typeDecl; } - | structure_type_declaration[typeDecl] { $$ = $typeDecl; } - | type_declaration_no_options[typeDecl] dim_list[dimlist] { - if ( $typeDecl->baseType==Type::typeDecl ) { - das_yyerror(scanner,"type declaration can`t be used as array base type",tokAt(scanner,@typeDecl), - CompilationError::invalid_type); - } else if ( $typeDecl->baseType==Type::typeMacro ) { - das_yyerror(scanner,"macro can`t be used as array base type",tokAt(scanner,@typeDecl), - CompilationError::invalid_type); - } - $$ = attachDimChain($dimlist, $typeDecl); - } - | type_declaration_no_options[typeDecl] '[' ']' { - $$ = appendAutoDim($typeDecl, tokAt(scanner,@2)); - } - | DAS_TYPE '<' { yyextra->das_arrow_depth ++; } type_declaration[typeDecl] '>' { yyextra->das_arrow_depth --; } { - $typeDecl->autoToAlias = true; - $$ = $typeDecl; - } - | DAS_TYPEDECL[td] '(' expr2[subexpr] ')' { - $$ = new TypeDecl(Type::typeDecl); - $$->at = tokRangeAt(scanner,@td,@subexpr); - $$->typeMacroExpr.push_back($subexpr); - } - | '$' name_in_namespace[name] optional_expr_list_in_braces[arguments] { - $$ = new TypeDecl(Type::typeMacro); - $$->at = tokRangeAt(scanner,@name, @arguments); - $$->typeMacroExpr = sequenceToList($arguments); - $$->typeMacroExpr.insert($$->typeMacroExpr.begin(), new ExprConstString(tokAt(scanner,@name), *$name)); - delete $name; - } - | '$' name_in_namespace[name] '<' { yyextra->das_arrow_depth ++; } type_declaration_no_options_list[declL] '>' optional_expr_list_in_braces[arguments] { - $$ = new TypeDecl(Type::typeMacro); - $$->at = tokRangeAt(scanner,@name, @arguments); - $$->typeMacroExpr = typesAndSequenceToList($declL,$arguments); - $$->typeMacroExpr.insert($$->typeMacroExpr.begin(), new ExprConstString(tokAt(scanner,@name), *$name)); - delete $name; - } - | type_declaration_no_options[typeDecl] '-' '[' ']' { - $typeDecl->removeDim = true; - $$ = $typeDecl; - } - | type_declaration_no_options[typeDecl] DAS_EXPLICIT { - $typeDecl->isExplicit = true; - $$ = $typeDecl; - } - | type_declaration_no_options[typeDecl] DAS_CONST { - $typeDecl->constant = true; - $typeDecl->removeConstant = false; - $$ = $typeDecl; - } - | type_declaration_no_options[typeDecl] '-' DAS_CONST { - $typeDecl->constant = false; - $typeDecl->removeConstant = true; - $$ = $typeDecl; - } - | type_declaration_no_options[typeDecl] '&' { - $typeDecl->ref = true; - $typeDecl->removeRef = false; - $$ = $typeDecl; - } - | type_declaration_no_options[typeDecl] '-' '&' { - $typeDecl->ref = false; - $typeDecl->removeRef = true; - $$ = $typeDecl; - } - | type_declaration_no_options[typeDecl] '#' { - $$ = $typeDecl; - $$->temporary = true; - } - | type_declaration_no_options[typeDecl] DAS_IMPLICIT { - $$ = $typeDecl; - $$->implicit = true; - } - | type_declaration_no_options[typeDecl] '-' '#' { - $typeDecl->temporary = false; - $typeDecl->removeTemporary = true; - $$ = $typeDecl; - } - | type_declaration_no_options[typeDecl] EQUEQU DAS_CONST { - $typeDecl->explicitConst = true; - $$ = $typeDecl; - } - | type_declaration_no_options[typeDecl] EQUEQU '&' { - $typeDecl->explicitRef = true; - $$ = $typeDecl; - } - | type_declaration_no_options[typeDecl] '?' { - $$ = new TypeDecl(Type::tPointer); - $$->at = tokAt(scanner,@typeDecl); - $$->firstType = $typeDecl; - } - | DAS_SMART_PTR[loc] '<' { yyextra->das_arrow_depth ++; } type_declaration[typeDecl] '>' { yyextra->das_arrow_depth --; } { - $$ = new TypeDecl(Type::tPointer); - $$->at = tokAt(scanner,@loc); - $$->smartPtr = true; - $$->firstType = $typeDecl; - } - | type_declaration_no_options[typeDecl] QQ { - $$ = new TypeDecl(Type::tPointer); - $$->at = tokAt(scanner,@typeDecl); - $$->firstType = new TypeDecl(Type::tPointer); - $$->firstType->at = tokAt(scanner,@typeDecl); - $$->firstType->firstType = $typeDecl; - } - | DAS_ARRAY[loc] '<' { yyextra->das_arrow_depth ++; } type_declaration[typeDecl] '>' { yyextra->das_arrow_depth --; } { - $$ = new TypeDecl(Type::tArray); - $$->at = tokAt(scanner,@loc); - $$->firstType = $typeDecl; - } - | DAS_TABLE[loc] '<' { yyextra->das_arrow_depth ++; } table_type_pair[ttp] '>' { yyextra->das_arrow_depth --; } { - $$ = new TypeDecl(Type::tTable); - $$->at = tokAt(scanner,@loc); - $$->firstType = $ttp.firstType; - $$->secondType = $ttp.secondType; - } - | DAS_ITERATOR[loc] '<' { yyextra->das_arrow_depth ++; } type_declaration[itTypeDecl] '>' { yyextra->das_arrow_depth --; } { - $$ = new TypeDecl(Type::tIterator); - $$->at = tokAt(scanner,@loc); - $$->firstType = $itTypeDecl; - } - | DAS_TBLOCK[loc] { - $$ = new TypeDecl(Type::tBlock); - $$->firstType = new TypeDecl(Type::tVoid); - $$->at = tokAt(scanner,@loc); - } - | DAS_TBLOCK[loc] '<' { yyextra->das_arrow_depth ++; } type_declaration[blockType] '>' { yyextra->das_arrow_depth --; } { - $$ = new TypeDecl(Type::tBlock); - $$->at = tokAt(scanner,@loc); - $$->firstType = $blockType; - } - | DAS_TBLOCK[loc] '<' { yyextra->das_arrow_depth ++; } optional_function_argument_list[list] optional_function_type[result] '>' { yyextra->das_arrow_depth --; } { - $$ = new TypeDecl(Type::tBlock); - $$->at = tokAt(scanner,@loc); - $$->firstType = $result; - if ( $list ) { - varDeclToTypeDecl(scanner, $$, $list); - deleteVariableDeclarationList($list); - } - } - | DAS_TFUNCTION[loc] { - $$ = new TypeDecl(Type::tFunction); - $$->firstType = new TypeDecl(Type::tVoid); - $$->at = tokAt(scanner,@loc); - } - | DAS_TFUNCTION[loc] '<' { yyextra->das_arrow_depth ++; } type_declaration[blockType] '>' { yyextra->das_arrow_depth --; } { - $$ = new TypeDecl(Type::tFunction); - $$->at = tokAt(scanner,@loc); - $$->firstType = $blockType; - } - | DAS_TFUNCTION[loc] '<' { yyextra->das_arrow_depth ++; } optional_function_argument_list[list] optional_function_type[result] '>' { yyextra->das_arrow_depth --; } { - $$ = new TypeDecl(Type::tFunction); - $$->at = tokAt(scanner,@loc); - $$->firstType = $result; - if ( $list ) { - varDeclToTypeDecl(scanner, $$, $list); - deleteVariableDeclarationList($list); - } - } - | DAS_TLAMBDA[loc] { - $$ = new TypeDecl(Type::tLambda); - $$->firstType = new TypeDecl(Type::tVoid); - $$->at = tokAt(scanner,@loc); - } - | DAS_TLAMBDA[loc] '<' { yyextra->das_arrow_depth ++; } type_declaration[blockType] '>' { yyextra->das_arrow_depth --; } { - $$ = new TypeDecl(Type::tLambda); - $$->at = tokAt(scanner,@loc); - $$->firstType = $blockType; - } - | DAS_TLAMBDA[loc] '<' { yyextra->das_arrow_depth ++; } optional_function_argument_list[list] optional_function_type[result] '>' { yyextra->das_arrow_depth --; } { - $$ = new TypeDecl(Type::tLambda); - $$->at = tokAt(scanner,@loc); - $$->firstType = $result; - if ( $list ) { - varDeclToTypeDecl(scanner, $$, $list); - deleteVariableDeclarationList($list); - } - } - | DAS_TTUPLE[loc] '<' { yyextra->das_arrow_depth ++; } tuple_type_list[list] '>' { yyextra->das_arrow_depth --; } { - $$ = new TypeDecl(Type::tTuple); - $$->at = tokAt(scanner,@loc); - varDeclToTypeDecl(scanner, $$, $list, true); - deleteVariableDeclarationList($list); - } - | DAS_TVARIANT[loc] '<' { yyextra->das_arrow_depth ++; } variant_type_list[list] '>' { yyextra->das_arrow_depth --; } { - $$ = new TypeDecl(Type::tVariant); - $$->at = tokAt(scanner,@loc); - varDeclToTypeDecl(scanner, $$, $list, true); - deleteVariableDeclarationList($list); - } - ; - -type_declaration - : type_declaration_no_options[td] { - $$ = $td; - } - | type_declaration[list] '|' type_declaration_no_options[rest] { - if ( $list->baseType==Type::option ) { - $$ = $list; - $$->argTypes.push_back($rest); - } else { - $$ = new TypeDecl(Type::option); - $$->at = tokRangeAt(scanner,@list,@rest); - $$->argTypes.push_back($list); - $$->argTypes.push_back($rest); - } - } - | type_declaration[list] '|' '#'[rest] { - if ( $list->baseType==Type::option ) { - $$ = $list; - $$->argTypes.push_back(new TypeDecl(*$list->argTypes.back())); - $list->argTypes.back()->temporary ^= true; - } else { - $$ = new TypeDecl(Type::option); - $$->at = tokRangeAt(scanner,@list,@rest); - $$->argTypes.push_back($list); - $$->argTypes.push_back(new TypeDecl(*$list)); - $$->argTypes.back()->temporary ^= true; - } - } - ; - -tuple_alias_declaration - : DAS_TTUPLE optional_public_or_private_alias[pubA] { yyextra->das_need_oxford_comma=false; } NAME[vname] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@vname); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeTuple(atvname); - } - } open_block[blk] { - if (format::is_replace_braces() && $blk != 0xdeadbeef && format::prepare_rule(format::Pos::from(tokAt(scanner, @blk)))) { - format::get_writer() << " {"; - format::finish_rule(format::Pos::from(tokAt(scanner,@blk))); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@vname); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeTupleEntries(atvname); - } - } tuple_alias_type_list[list] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@vname); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterTupleEntries(atvname); - } - } close_block[close] { - if (format::is_replace_braces() && $blk != 0xdeadbeef && format::prepare_rule(format::Pos::from(tokAt(scanner, @close)))) { - format::get_writer() << "\n" << string($close * yyextra->das_tab_size, ' ') + "}"; - format::finish_rule(format::Pos::from(tokAt(scanner,@close))); - } - auto vtype = new TypeDecl(Type::tTuple); - vtype->alias = *$vname; - vtype->at = tokAt(scanner,@vname); - vtype->isPrivateAlias = !$pubA; - varDeclToTypeDecl(scanner, vtype, $list, true); - deleteVariableDeclarationList($list); - if ( !yyextra->g_Program->addAlias(vtype) ) { - das_yyerror(scanner,"type alias is already defined "+*$vname,tokAt(scanner,@vname), - CompilationError::type_alias_already_declared); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@vname); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterTuple($vname->c_str(),atvname); - } - delete $vname; - } - ; - -variant_alias_declaration - : DAS_TVARIANT optional_public_or_private_alias[pubA] { yyextra->das_need_oxford_comma=false; } NAME[vname] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@vname); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeVariant(atvname); - } - } open_block[blk] { - if (format::is_replace_braces() && $blk != 0xdeadbeef && format::prepare_rule(format::Pos::from(tokAt(scanner, @blk)))) { - format::get_writer() << " {"; - format::finish_rule(format::Pos::from(tokAt(scanner,@blk))); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@vname); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeVariantEntries(atvname); - } - - } variant_alias_type_list[list] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@vname); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterVariantEntries(atvname); - } - } close_block[close] { - if (format::is_replace_braces() && $close != 0xdeadbeef && format::prepare_rule(format::Pos::from(tokAt(scanner, @close)))) { - format::get_writer() << "\n" << string($close * yyextra->das_tab_size, ' ') + "}"; - format::finish_rule(format::Pos::from(tokAt(scanner,@close))); - } - auto vtype = new TypeDecl(Type::tVariant); - vtype->alias = *$vname; - vtype->at = tokAt(scanner,@vname); - vtype->isPrivateAlias = !$pubA; - varDeclToTypeDecl(scanner, vtype, $list, true); - deleteVariableDeclarationList($list); - if ( !yyextra->g_Program->addAlias(vtype) ) { - das_yyerror(scanner,"type alias is already defined "+*$vname,tokAt(scanner,@vname), - CompilationError::type_alias_already_declared); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@vname); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterVariant($vname->c_str(),atvname); - } - delete $vname; - } - ; - -bitfield_alias_declaration - : DAS_TBITFIELD optional_public_or_private_alias[pubA] { yyextra->das_need_oxford_comma=false; } NAME[vname] { - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@vname); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeBitfield(atvname); - } - } bitfield_basic_type_declaration[basicType] open_block[blk] bitfield_alias_bits[list] close_block[close] { - const auto prev_loc = format::Pos::from(tokAt(scanner,@blk)); - handle_brace(prev_loc, $blk, - format::get_substring(prev_loc, format::Pos::from_last(tokAt(scanner,@list))), - yyextra->das_tab_size, - format::Pos::from_last(tokAt(scanner,@list))); - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@vname); - for ( auto & crd : yyextra->g_CommentReaders ) crd->beforeBitfieldEntries(atvname); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@vname); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfieldEntries(atvname); - } - auto btype = new TypeDecl($basicType); - btype->alias = *$vname; - btype->at = tokAt(scanner,@vname); - btype->isPrivateAlias = !$pubA; - for ( auto & p : *$list ) { - if ( !get<1>(p) ) { - btype->argNames.push_back(get<0>(p)); - } - } - auto maxBits = btype->maxBitfieldBits(); - if ( btype->argNames.size()>maxBits ) { - das_yyerror(scanner,"only " + to_string(maxBits) + " different bits are allowed in a bitfield",tokAt(scanner,@vname), - CompilationError::invalid_type); - } - for ( auto & p : *$list ) { - if ( get<1>(p) ) { - ast_globalBitfieldConst ( scanner, btype, $pubA, get<0>(p), get<1>(p) ); - } - } - if ( !yyextra->g_Program->addAlias(btype) ) { - das_yyerror(scanner,"type alias is already defined "+*$vname,tokAt(scanner,@vname), - CompilationError::type_alias_already_declared); - } - if ( !yyextra->g_CommentReaders.empty() ) { - auto atvname = tokAt(scanner,@vname); - for ( auto & crd : yyextra->g_CommentReaders ) crd->afterBitfield($vname->c_str(),atvname); - } - delete $vname; - delete $list; - } - ; - - -make_decl - : make_struct_decl[msd] { $$ = $msd; } - | make_dim_decl[mdd] { $$ = $mdd; } - | make_table_decl[mtd] { $$ = $mtd; } - | array_comprehension[mac] { $$ = $mac; } - | make_tuple_call[mtc] { $$ = $mtc; } - ; - -make_struct_fields - : NAME[fn] copy_or_move[com] expr[value] { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner,@fn, @value),*$fn,$value,$com,false); - delete $fn; - auto msd = new MakeStruct(); - msd->push_back(mfd); - $$ = msd; - } - | NAME[fn] CLONEEQU expr[value] { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner,@fn, @value),*$fn,$value,false,true); - delete $fn; - auto msd = new MakeStruct(); - msd->push_back(mfd); - $$ = msd; - } - | make_struct_fields[msd] ',' NAME[fn] copy_or_move[com] expr[value] { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner,@fn, @value),*$fn,$value,$com,false); - delete $fn; - ((MakeStruct *)$msd)->push_back(mfd); - $$ = $msd; - } - | make_struct_fields[msd] ',' NAME[fn] CLONEEQU expr[value] { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner,@fn, @value),*$fn,$value,false,true); - delete $fn; - ((MakeStruct *)$msd)->push_back(mfd); - $$ = $msd; - } - | MTAG_F [begin] '(' expr2[subexpr] ')' copy_or_move[com] expr[value] { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner,@begin, @value),"``MACRO``TAG``FIELD``",$value,$com,false); - mfd->tag = $subexpr; - auto msd = new MakeStruct(); - msd->push_back(mfd); - $$ = msd; - } - | MTAG_F [begin] '(' expr2[subexpr] ')' CLONEEQU expr[value] { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner, @begin, @value),"``MACRO``TAG``FIELD``",$value,false,true); - mfd->tag = $subexpr; - auto msd = new MakeStruct(); - msd->push_back(mfd); - $$ = msd; - } - | make_struct_fields[msd] ',' MTAG_F [begin] '(' expr2[subexpr] ')' copy_or_move[com] expr[value] { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner,@begin,@value),"``MACRO``TAG``FIELD``",$value,$com,false); - mfd->tag = $subexpr; - ((MakeStruct *)$msd)->push_back(mfd); - $$ = $msd; - } - | make_struct_fields[msd] ',' MTAG_F [begin] '(' expr2[subexpr] ')' CLONEEQU expr[value] { - auto mfd = new MakeFieldDecl(tokRangeAt(scanner,@begin, @value),"``MACRO``TAG``FIELD``",$value,false,true); - mfd->tag = $subexpr; - ((MakeStruct *)$msd)->push_back(mfd); - $$ = $msd; - } - ; - -make_variant_dim - : { - $$ = ast_makeStructToMakeVariant(nullptr, LineInfo()); - } - | make_struct_fields[msd] { - $$ = ast_makeStructToMakeVariant($msd, tokAt(scanner,@msd)); - } - ; - -make_struct_single - : make_struct_fields[msf] optional_comma { - auto msd = new ExprMakeStruct(); - msd->structs.push_back(MakeStructPtr($msf)); - $$ = msd; - } - ; - -make_struct_dim - : make_struct_fields[msf] { - auto msd = new ExprMakeStruct(); - msd->structs.push_back(MakeStructPtr($msf)); - $$ = msd; - } - | make_struct_dim[msd] semicolon make_struct_fields[msf] { - ((ExprMakeStruct *) $msd)->structs.push_back(MakeStructPtr($msf)); - $$ = $msd; - } - ; - -make_struct_dim_list - : '(' make_struct_fields[msf] ')' { - auto msd = new ExprMakeStruct(); - msd->structs.push_back(MakeStructPtr($msf)); - $$ = msd; - } - | make_struct_dim_list[msd] ',' '(' make_struct_fields[msf] ')' { - ((ExprMakeStruct *) $msd)->structs.push_back(MakeStructPtr($msf)); - $$ = $msd; - } - ; - -make_struct_dim_decl - : make_struct_fields[msf] { - auto msd = new ExprMakeStruct(); - msd->structs.push_back(MakeStructPtr($msf)); - $$ = msd; - } - | make_struct_dim_list[msd] optional_comma { - $$ = $msd; - } - ; - -optional_make_struct_dim_decl - : make_struct_dim_decl[msd] { $$ = $msd; } - | { $$ = new ExprMakeStruct(); } - ; - -optional_block - : { $$ = nullptr; } - | DAS_WHERE expr_block[blk] { $blk->at = tokAt(scanner, @blk); $$ = $blk; } - ; - - -optional_trailing_semicolon_cur_cur - : '}' '}' - | SEMICOLON_CUR_CUR - ; - -optional_trailing_semicolon_cur_sqr - : '}' ']' - | SEMICOLON_CUR_SQR - ; - -optional_trailing_semicolon_sqr_sqr - : ']' ']' - | SEMICOLON_SQR_SQR - ; - -optional_trailing_delim_sqr_sqr - : ']' ']' - | SEMICOLON_SQR_SQR - | COMMA_SQR_SQR - ; - -optional_trailing_delim_cur_sqr - : '}' ']' - | SEMICOLON_CUR_SQR - | COMMA_CUR_SQR - ; - -use_initializer - : { $$ = true; } - | DAS_UNINITIALIZED { $$ = false; } - ; - -make_struct_decl - : BRABRAB [loc] type_declaration_no_options[mkt] make_struct_dim[msd] optional_block[blk] optional_trailing_delim_sqr_sqr[end] { - // std::cout << "case1" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,@loc)))) { - auto type = format::type_to_string($mkt, tokAt(scanner,@mkt)).value_or(""); - const bool is_initialized = false; - const auto before = format::substring_between(tokAt(scanner,@loc), tokAt(scanner, @mkt)); - const auto internal = format::handle_msd(tokAt(scanner, @mkt), - static_cast($msd), - tokAt(scanner, $blk != nullptr ? @blk : @end), - type, is_initialized); - if (static_cast($msd)->structs.size() == 1) { - // single struct - if (type.find('[') != size_t(-1)) { - format::get_writer() << "fixed_array(" << before << internal << ")"; - } else { - format::get_writer() << before << internal; - } - if ($blk != nullptr) { - format::get_writer() << " <| " << format::get_substring($blk->at); - } - } else { - // array of structs - // const auto internal = format::get_substring(format::Pos::from(tokAt(scanner,@msd)), - // format::Pos::from(tokAt(scanner,@end))); - format::get_writer() << "fixed_array(" << internal << ")"; - } - format::finish_rule(format::Pos::from_last(tokAt(scanner,@end))); - } - ((ExprMakeStruct *)$msd)->makeType = $mkt; - ((ExprMakeStruct *)$msd)->block = $blk; - $msd->at = tokAt(scanner,@loc); - $$ = $msd; - } - | BRABRAB [loc] type_declaration_no_options[mkt] optional_block[blk] optional_trailing_delim_sqr_sqr[end] { - // // std::cout << "case2" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,@loc)))) { - auto type = format::type_to_string($mkt, tokAt(scanner,@mkt)); - das_hash_set always_init = { - // Is there a method to describe all this types? - "structisPointer()) { - format::get_writer() << "default<" << type.value() << ">"; - suffix.clear(); - } else if (any_of(always_init.begin(), always_init.end(), - [&type](auto t){ return type.value_or("").find(t) == 0; })) { - format::get_writer() << type.value_or("") << "("; - } else { - format::get_writer() << type.value_or("") << "("; // Possible uninitialized - } - format::get_writer() << before << after << suffix; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@end))); - } - - auto msd = new ExprMakeStruct(); - msd->makeType = $mkt; - msd->block = $blk; - msd->at = tokAt(scanner,@loc); - $$ = msd; - } - | BRABRAB [loc] type_declaration_no_options[mkt] '('[l_par] ')' [r_par] optional_block[blk] optional_trailing_delim_sqr_sqr [end_loc] { - // std::cout << "case3" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,@loc)))) { - const auto type_name = format::type_to_string($mkt, tokAt(scanner,@mkt)); - auto maybe_init = (format::can_default_init(type_name.value_or(""))) ? "" : ""; // Possible uninitialized - format::get_writer() << type_name.value_or("") << "(" - << format::substring_between(tokAt(scanner,@loc), tokAt(scanner, @mkt)) - << format::substring_between(tokAt(scanner,@l_par), tokAt(scanner, @r_par)) - << format::substring_between(tokAt(scanner,@r_par), tokAt(scanner, @end_loc)) - << maybe_init << ")"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@end_loc))); - } - auto msd = new ExprMakeStruct(); - msd->makeType = $mkt; - msd->useInitializer = true; - msd->block = $blk; - msd->at = tokAt(scanner,@loc); - $$ = msd; - } - | BRABRAB [loc] type_declaration_no_options[mkt] '('[l_par] ')'[r_par] make_struct_dim[msd] optional_block[blk] optional_trailing_delim_sqr_sqr [end_loc] { - // std::cout << "case4" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,@loc)))) { - auto type_name = format::type_to_string($mkt, tokAt(scanner,@mkt)).value_or(""); - const auto internal = format::handle_msd(tokAt(scanner, @r_par), - static_cast($msd), - tokAt(scanner, @end_loc), - type_name); - format::get_writer() << format::substring_between(tokAt(scanner, @loc), tokAt(scanner, @mkt)) - << format::substring_between(tokAt(scanner, @l_par), tokAt(scanner, @r_par)) - << internal; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@end_loc))); - } - - ((ExprMakeStruct *)$msd)->makeType = $mkt; - ((ExprMakeStruct *)$msd)->useInitializer = true; - ((ExprMakeStruct *)$msd)->block = $blk; - $msd->at = tokAt(scanner,@loc); - $$ = $msd; - } - | BRACBRB [loc] type_declaration_no_options[mkt] make_struct_dim[msd] optional_block[blk] optional_trailing_delim_cur_sqr [end_loc] { - // std::cout << "case6" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,@loc)))) { - auto type_name = format::type_to_string($mkt, tokAt(scanner,@mkt)).value_or(""); - format::get_writer() << "[" << format::substring_between(tokAt(scanner, @loc), tokAt(scanner, @mkt)) - << format::handle_msd(tokAt(scanner, @mkt), - static_cast($msd), - tokAt(scanner, @end_loc), - type_name) - << "]"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@end_loc))); - } - - ((ExprMakeStruct *)$msd)->makeType = $mkt; - ((ExprMakeStruct *)$msd)->block = $blk; - $msd->at = tokAt(scanner,@loc); - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"to_array_move"); - tam->arguments.push_back($msd); - $$ = tam; - } - | BRACBRB [loc] type_declaration_no_options[mkt] '(' ')'[st_msd] make_struct_dim[msd] optional_block[blk] optional_trailing_delim_cur_sqr [end_loc] { - // std::cout << "case7" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,@loc)))) { - auto type_name = format::type_to_string($mkt, tokAt(scanner,@mkt)).value_or(""); - format::get_writer() << "[" << format::substring_between(tokAt(scanner, @loc), tokAt(scanner, @mkt)) - << format::handle_msd(tokAt(scanner, @st_msd), - static_cast($msd), - tokAt(scanner, @end_loc), - type_name) - << "]"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@end_loc))); - } - - ((ExprMakeStruct *)$msd)->makeType = $mkt; - ((ExprMakeStruct *)$msd)->useInitializer = true; - ((ExprMakeStruct *)$msd)->block = $blk; - $msd->at = tokAt(scanner,@loc); - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"to_array_move"); - tam->arguments.push_back($msd); - $$ = tam; - } - | DAS_STRUCT [loc] '<' { yyextra->das_force_oxford_comma=true; yyextra->das_arrow_depth ++; } type_declaration_no_options[mkt] '>' { yyextra->das_arrow_depth --; } '(' use_initializer[init] optional_make_struct_dim_decl[msd] ')' { - $msd->at = tokAt(scanner,@loc); - ((ExprMakeStruct *)$msd)->makeType = $mkt; - ((ExprMakeStruct *)$msd)->useInitializer = $init; - ((ExprMakeStruct *)$msd)->forceStruct = true; - ((ExprMakeStruct *)$msd)->alwaysUseInitializer = true; - $$ = $msd; - } - | DAS_CLASS [loc] '<' { yyextra->das_force_oxford_comma=true; yyextra->das_arrow_depth ++; } type_declaration_no_options[mkt] '>' { yyextra->das_arrow_depth --; } '('use_initializer[init] optional_make_struct_dim_decl[msd] ')' { - $msd->at = tokAt(scanner,@loc); - ((ExprMakeStruct *)$msd)->makeType = $mkt; - ((ExprMakeStruct *)$msd)->useInitializer = $init; - ((ExprMakeStruct *)$msd)->forceClass = true; - $$ = $msd; - } - | DAS_TVARIANT [loc] '<' { yyextra->das_force_oxford_comma=true; yyextra->das_arrow_depth ++; } variant_type_list[list] '>' { yyextra->das_arrow_depth --; } '(' use_initializer[init] make_variant_dim[msd] ')' { - auto mkt = new TypeDecl(Type::tVariant); - mkt->at = tokAt(scanner,@loc); - varDeclToTypeDecl(scanner, mkt, $list, true); - deleteVariableDeclarationList($list); - $msd->at = tokAt(scanner,@loc); - ((ExprMakeStruct *)$msd)->makeType = mkt; - ((ExprMakeStruct *)$msd)->useInitializer = $init; - ((ExprMakeStruct *)$msd)->forceVariant = true; - $$ = $msd; - } - | DAS_DEFAULT [loc] '<' { yyextra->das_arrow_depth ++; } type_declaration_no_options[mkt] '>' { yyextra->das_arrow_depth --; } use_initializer[init] { - auto msd = new ExprMakeStruct(); - msd->at = tokAt(scanner,@loc); - msd->makeType = $mkt; - msd->useInitializer = $init; - msd->alwaysUseInitializer = true; - $$ = msd; - } - ; - -make_tuple - : expr[val] { - $val->at = tokAt(scanner,@val); - $$ = $val; - } - | expr[kval] MAPTO[mkt] expr[vval] { - ExprMakeTuple * mt = new ExprMakeTuple(tokRangeAt(scanner,@kval, @vval)); - mt->values.push_back($kval); - mt->values.push_back($vval); - $$ = mt; - } - | make_tuple[mkt] ',' expr[val] { - $val->at = tokAt(scanner,@val); - ExprMakeTuple * mt; - if ( $mkt->rtti_isMakeTuple() ) { - mt = static_cast($mkt); - } else { - mt = new ExprMakeTuple(tokAt(scanner,@mkt)); - mt->values.push_back($mkt); - } - mt->values.push_back($val); - mt->at = format::concat(mt->at, tokAt(scanner, @val)); - $$ = mt; - } - ; - -make_map_tuple - : expr[kval] MAPTO[mkt] expr[vval] { - ExprMakeTuple * mt = new ExprMakeTuple(tokRangeAt(scanner,@kval,@vval)); - mt->values.push_back($kval); - mt->values.push_back($vval); - $$ = mt; - } - | expr[kval] { - $$ = $kval; - } - ; - -make_tuple_call - : DAS_TTUPLE[loc] '(' expr_list[arguments] optional_comma ')' { - auto mkt = new ExprMakeTuple(tokAt(scanner,@loc)); - mkt->values = sequenceToList($arguments); - mkt->makeType = new TypeDecl(Type::autoinfer); - $$ = mkt; - } - | DAS_TTUPLE [loc] '<' { yyextra->das_force_oxford_comma=true; yyextra->das_arrow_depth ++; } tuple_type_list[list] '>' { yyextra->das_arrow_depth --; } '(' use_initializer[init] optional_make_struct_dim_decl[msd] ')' { - auto mkt = new TypeDecl(Type::tTuple); - mkt->at = tokAt(scanner,@loc); - varDeclToTypeDecl(scanner, mkt, $list, true); - deleteVariableDeclarationList($list); - $msd->at = tokAt(scanner,@loc); - ((ExprMakeStruct *)$msd)->makeType = mkt; - ((ExprMakeStruct *)$msd)->useInitializer = $init; - ((ExprMakeStruct *)$msd)->forceTuple = true; - $$ = $msd; - } - ; - -make_dim - : make_tuple[val] { - auto mka = new ExprMakeArray(); - mka->values.push_back($val); - $$ = mka; - } - | make_dim[mka] semicolon make_tuple[val] { - ((ExprMakeArray *) $mka)->values.push_back($val); - $$ = $mka; - } - ; - -make_dim_decl - : '[' [loc] optional_expr_list[arguments] ']' { - if ( $arguments ) { - auto mka = new ExprMakeArray(tokAt(scanner,@loc)); - mka->values = sequenceToList($arguments); - mka->makeType = new TypeDecl(Type::autoinfer); - mka->gen2 = true; - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"to_array_move"); - tam->arguments.push_back(mka); - $$ = tam; - } else { - auto mks = new ExprMakeStruct(); - mks->at = tokAt(scanner,@loc); - mks->makeType = new TypeDecl(Type::tArray); - mks->makeType->firstType = new TypeDecl(Type::autoinfer); - mks->useInitializer = true; - mks->alwaysUseInitializer = true; - $$ = mks; - } - - } - | BRABRAB [loc] type_declaration_no_options[mkt] make_dim[mka] optional_trailing_semicolon_sqr_sqr [end_loc] { - // std::cout << "case13" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,@loc)))) { - auto type_name = format::type_to_string($mkt, tokAt(scanner,@mkt)); - auto internal = format::handle_mka(tokAt(scanner, @mkt), - static_cast($mka), - tokAt(scanner, @end_loc)); - const auto before = format::substring_between(tokAt(scanner, @loc), tokAt(scanner, @mkt)); - if (static_cast($mka)->values.size() == 1) { - // single element - if (type_name.value_or("").find('[') != size_t(-1)) { - format::get_writer() << "fixed_array(" << before << internal << ")"; - } else { - format::get_writer() << before << internal; - } - } else { - format::get_writer() << "fixed_array"; - if (!$mkt->isAuto()) { - format::get_writer() << "<" << type_name.value().substr(0, type_name.value().find('[')) << ">"; - } - format::get_writer() << "(" << before << internal << ")"; - } - format::finish_rule(format::Pos::from_last(tokAt(scanner,@end_loc))); - } - ((ExprMakeArray *)$mka)->makeType = $mkt; - $mka->at = tokAt(scanner,@loc); - $$ = $mka; - } - | BRACBRB [loc] type_declaration_no_options[mkt] make_dim[mka] optional_trailing_semicolon_cur_sqr [end_loc] { - // std::cout << "case8" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,@loc)))) { - string prefix = "["; - string suffix = "]"; - if (!$mkt->isAuto()) { - prefix = "array<" + format::get_substring(tokAt(scanner,@mkt)) + ">("; - suffix = ")"; - } - format::get_writer() << prefix - << format::substring_between(tokAt(scanner, @loc), tokAt(scanner, @mkt)) - << format::handle_mka(tokAt(scanner, @mkt), - static_cast($mka), - tokAt(scanner, @end_loc)) - << suffix; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@end_loc))); - } - - ((ExprMakeArray *)$mka)->makeType = $mkt; - $mka->at = tokAt(scanner,@loc); - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"to_array_move"); - tam->arguments.push_back($mka); - $$ = tam; - } - | DAS_ARRAY [loc] DAS_STRUCT '<' { yyextra->das_arrow_depth ++; } type_declaration_no_options[mkt] '>' { yyextra->das_arrow_depth --; } '(' use_initializer[init] optional_make_struct_dim_decl[msd] ')' { - $msd->at = tokAt(scanner,@loc); - ((ExprMakeStruct *)$msd)->makeType = $mkt; - ((ExprMakeStruct *)$msd)->useInitializer = $init; - ((ExprMakeStruct *)$msd)->forceStruct = true; - ((ExprMakeStruct *)$msd)->alwaysUseInitializer = true; - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"to_array_move"); - tam->arguments.push_back($msd); - $$ = tam; - } - | DAS_ARRAY [loc] DAS_TTUPLE '<' { yyextra->das_arrow_depth ++; } tuple_type_list[list] '>' { yyextra->das_arrow_depth --; } '(' use_initializer[init] optional_make_struct_dim_decl[msd] ')' { - auto mkt = new TypeDecl(Type::tTuple); - mkt->at = tokAt(scanner,@loc); - varDeclToTypeDecl(scanner, mkt, $list, true); - deleteVariableDeclarationList($list); - $msd->at = tokAt(scanner,@loc); - ((ExprMakeStruct *)$msd)->makeType = mkt; - ((ExprMakeStruct *)$msd)->useInitializer = $init; - ((ExprMakeStruct *)$msd)->forceTuple = true; - ((ExprMakeStruct *)$msd)->alwaysUseInitializer = true; - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"to_array_move"); - tam->arguments.push_back($msd); - $$ = tam; - } - | DAS_ARRAY [loc] DAS_TVARIANT '<' { yyextra->das_arrow_depth ++; } variant_type_list[list] '>' { yyextra->das_arrow_depth --; } '(' make_variant_dim[msd] ')' { - auto mkt = new TypeDecl(Type::tVariant); - mkt->at = tokAt(scanner,@loc); - varDeclToTypeDecl(scanner, mkt, $list, true); - deleteVariableDeclarationList($list); - $msd->at = tokAt(scanner,@loc); - ((ExprMakeStruct *)$msd)->makeType = mkt; - ((ExprMakeStruct *)$msd)->useInitializer = true; - ((ExprMakeStruct *)$msd)->forceVariant = true; - ((ExprMakeStruct *)$msd)->alwaysUseInitializer = true; - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"to_array_move"); - tam->arguments.push_back($msd); - $$ = tam; - } - | DAS_ARRAY[loc] '(' expr_list[arguments] optional_comma ')' { - auto mka = new ExprMakeArray(tokAt(scanner,@loc)); - mka->values = sequenceToList($arguments); - mka->makeType = new TypeDecl(Type::autoinfer); - mka->gen2 = true; - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"to_array_move"); - tam->arguments.push_back(mka); - $$ = tam; - } - | DAS_ARRAY[loc] '<' { yyextra->das_arrow_depth ++; } type_declaration_no_options[mkt] '>' { yyextra->das_arrow_depth --; } '(' optional_expr_list[arguments] ')' { - if ( $arguments ) { - auto mka = new ExprMakeArray(tokAt(scanner,@loc)); - mka->values = sequenceToList($arguments); - mka->makeType = $mkt; - mka->gen2 = true; - auto tam = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"to_array_move"); - tam->arguments.push_back(mka); - $$ = tam; - } else { - auto msd = new ExprMakeStruct(); - msd->at = tokAt(scanner,@loc); - msd->makeType = new TypeDecl(Type::tArray); - msd->makeType->firstType = $mkt; - msd->at = tokAt(scanner,@mkt); - msd->useInitializer = true; - msd->alwaysUseInitializer = true; - $$ = msd; - } - } - | DAS_FIXED_ARRAY[loc] '(' expr_list[arguments] optional_comma ')' { - auto mka = new ExprMakeArray(tokAt(scanner,@loc)); - mka->values = sequenceToList($arguments); - mka->makeType = new TypeDecl(Type::autoinfer); - mka->gen2 = true; - $$ = mka; - } - | DAS_FIXED_ARRAY[loc] '<' { yyextra->das_arrow_depth ++; } type_declaration_no_options[mkt] '>' { yyextra->das_arrow_depth --; } '(' expr_list[arguments] optional_comma ')' { - auto mka = new ExprMakeArray(tokAt(scanner,@loc)); - mka->values = sequenceToList($arguments); - mka->makeType = $mkt; - mka->gen2 = true; - $$ = mka; - } - ; - -make_table - : make_map_tuple[val] { - auto mka = new ExprMakeArray(); - mka->values.push_back($val); - $$ = mka; - } - | make_table[mka] semicolon make_map_tuple[val] { - ((ExprMakeArray *) $mka)->values.push_back($val); - $$ = $mka; - } - ; - -expr_map_tuple_list - : make_map_tuple[subexpr] { - $$ = $subexpr; - } - | expr_map_tuple_list[left] ',' make_map_tuple[right] { - $$ = new ExprSequence(tokAt(scanner,@left),$left,$right); - } - ; - -make_table_decl - : open_block [loc] optional_expr_map_tuple_list[arguments] close_block { - if ( $arguments ) { - auto mka = new ExprMakeArray(tokAt(scanner,@loc)); - mka->values = sequenceToList($arguments); - mka->makeType = new TypeDecl(Type::autoinfer); - auto ttm = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"to_table_move"); - ttm->arguments.push_back(mka); - $$ = ttm; - } else { - auto mks = new ExprMakeStruct(); - mks->at = tokAt(scanner,@loc); - mks->makeType = new TypeDecl(Type::tTable); - mks->makeType->firstType = new TypeDecl(Type::autoinfer); - mks->makeType->secondType = new TypeDecl(Type::autoinfer); - mks->useInitializer = true; - mks->alwaysUseInitializer = true; - $$ = mks; - } - - } - | CBRCBRB [loc] make_table[mka] optional_trailing_semicolon_cur_cur [end] { - // std::cout << "case10" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,@loc)))) { - format::get_writer() << "{" - << format::substring_between(tokAt(scanner, @loc), tokAt(scanner, @mka)) - << format::convert_to_string(((ExprMakeArray *)$mka)->values, ",", ";") - << format::substring_between(tokAt(scanner, @mka), tokAt(scanner, @end)) - << "}"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@end))); - } - - auto mkt = new TypeDecl(Type::tFixedArray); - mkt->fixedDim = TypeDecl::dimAuto; - mkt->at = tokAt(scanner,@loc); - mkt->firstType = new TypeDecl(Type::autoinfer); - mkt->firstType->at = mkt->at; - ((ExprMakeArray *)$mka)->makeType = mkt; - $mka->at = tokAt(scanner,@loc); - auto ttm = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"to_table_move"); - ttm->arguments.push_back($mka); - $$ = ttm; - } - | DAS_TABLE[loc] '(' optional_expr_map_tuple_list[arguments] ')' { - auto mka = new ExprMakeArray(tokAt(scanner,@loc)); - mka->values = sequenceToList($arguments); - mka->makeType = new TypeDecl(Type::autoinfer); - auto ttm = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"to_table_move"); - ttm->arguments.push_back(mka); - $$ = ttm; - } - | DAS_TABLE[loc] '<' type_declaration_no_options[decl] '>' '(' optional_expr_map_tuple_list[arguments] ')' { - if ( $arguments ) { - auto mka = new ExprMakeArray(tokAt(scanner,@loc)); - mka->values = sequenceToList($arguments); - mka->makeType = $decl; - auto ttm = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"to_table_move"); - ttm->arguments.push_back(mka); - $$ = ttm; - } else { - auto msd = new ExprMakeStruct(); - msd->at = tokAt(scanner,@loc); - msd->makeType = new TypeDecl(Type::tTable); - msd->makeType->firstType = $decl; - msd->makeType->secondType = new TypeDecl(Type::tVoid); - msd->at = tokAt(scanner,@loc); - msd->useInitializer = true; - msd->alwaysUseInitializer = true; - $$ = msd; - } - } - | DAS_TABLE[loc] '<' type_declaration_no_options[decl] c_or_s type_declaration_no_options[to_decl] '>' '(' optional_expr_map_tuple_list[arguments] ')' { - if ( $arguments ) { - auto mka = new ExprMakeArray(tokAt(scanner,@loc)); - mka->values = sequenceToList($arguments); - mka->makeType = new TypeDecl(Type::tTuple); - mka->makeType->argTypes.push_back($decl); - mka->makeType->argTypes.push_back($to_decl); - auto ttm = yyextra->g_Program->makeCall(tokAt(scanner,@loc),"to_table_move"); - ttm->arguments.push_back(mka); - $$ = ttm; - } else { - auto msd = new ExprMakeStruct(); - msd->at = tokAt(scanner,@loc); - msd->makeType = new TypeDecl(Type::tTable); - msd->makeType->firstType = $decl; - msd->makeType->secondType = $to_decl; - msd->at = tokAt(scanner,@loc); - msd->useInitializer = true; - msd->alwaysUseInitializer = true; - $$ = msd; - } - } - ; - -array_comprehension_where - : { $$ = nullptr; } - | semicolon DAS_WHERE expr[clause] { $$ = $clause; } - ; - -optional_comma - : { $$ = false; } - | ',' { $$ = true; } - ; - - -array_comprehension - : '[' DAS_FOR[loc] variable_name_with_pos_list[iters] DAS_IN expr_list[srcs] ';' expr2[subexpr] array_comprehension_where[where] ']' [forend] { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner,@iters)))) { - format::get_writer() << "(" << format::get_substring(format::Pos::from(tokAt(scanner,@iters)), - format::Pos::from_last(tokAt(scanner,@srcs))) << ")"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@srcs))); - } - - $$ = ast_arrayComprehension(scanner,tokAt(scanner,@loc),$iters,$srcs,$subexpr,$where,tokRangeAt(scanner,@subexpr,@forend),false,false); - } - // we have to add v2 syntax - | '[' DAS_FOR[loc] '(' variable_name_with_pos_list[iters] DAS_IN expr_list[srcs] ')' ';' expr2[subexpr] array_comprehension_where[where] ']' [forend] { - $$ = ast_arrayComprehension(scanner,tokAt(scanner,@loc),$iters,$srcs,$subexpr,$where,tokRangeAt(scanner,@subexpr,@forend),false,false); - } - | '[' DAS_ITERATOR DAS_FOR[loc] '(' variable_name_with_pos_list[iters] DAS_IN expr_list[srcs] ')' ';' expr2[subexpr] array_comprehension_where[where] ']' [forend] { - $$ = ast_arrayComprehension(scanner,tokAt(scanner,@loc),$iters,$srcs,$subexpr,$where,tokRangeAt(scanner,@subexpr,@forend),true,false); - } - | '{' DAS_FOR[loc] '(' variable_name_with_pos_list[iters] DAS_IN expr_list[srcs] ')' ';' make_map_tuple[subexpr] array_comprehension_where[where] '}' [forend] { - $$ = ast_arrayComprehension(scanner,tokAt(scanner,@loc),$iters,$srcs,$subexpr,$where,tokRangeAt(scanner,@subexpr,@forend),false,true); - } - | '[' DAS_ITERATOR DAS_FOR[loc] variable_name_with_pos_list[iters] DAS_IN expr_list[srcs] ';' expr2[subexpr] array_comprehension_where[where] ']' [forend] { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner,@iters)))) { - format::get_writer() << "(" << format::get_substring(format::Pos::from(tokAt(scanner,@iters)), - format::Pos::from_last(tokAt(scanner,@srcs))) << ")"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@srcs))); - } - $$ = ast_arrayComprehension(scanner,tokAt(scanner,@loc),$iters,$srcs,$subexpr,$where,tokRangeAt(scanner,@subexpr,@forend),true,false); - } - | BRABRAB [loc_start] DAS_FOR[loc] variable_name_with_pos_list[iters] DAS_IN expr_list[srcs] ';' expr2[subexpr] array_comprehension_where[where] ']' ']' [forend] { - // std::cout << "case5" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,@loc_start)))) { - auto internal = format::get_substring(format::Pos::from(tokAt(scanner,@loc)), format::Pos::from_last(tokAt(scanner,@where))); - format::get_writer() << "[iterator " << internal << "]"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@forend))); - } - $$ = ast_arrayComprehension(scanner,tokAt(scanner,@loc),$iters,$srcs,$subexpr,$where,tokRangeAt(scanner,@subexpr,@forend),true,false); - } - | BRACBRB [loc_start] DAS_FOR[loc] variable_name_with_pos_list[iters] DAS_IN expr_list[srcs] ';' expr2[subexpr] array_comprehension_where[where] '}'[sq_end] ']' [forend] { - // std::cout << "case9" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,@loc_start)))) { - auto internal = format::get_substring(format::Pos::from(tokAt(scanner,@loc)), format::Pos::from_last(tokAt(scanner,@where))); - format::get_writer() << "[" << format::substring_between(tokAt(scanner, @loc_start), tokAt(scanner, @loc)) - << internal - << format::substring_between(tokAt(scanner, @where), tokAt(scanner, @sq_end)) << "]"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@forend))); - } - - $$ = ast_arrayComprehension(scanner,tokAt(scanner,@loc),$iters,$srcs,$subexpr,$where,tokRangeAt(scanner,@subexpr,@forend),false,false); - } - | open_block[loc_start] DAS_FOR[loc] variable_name_with_pos_list[iters] DAS_IN expr_list[srcs] ';' make_map_tuple[subexpr] array_comprehension_where[where] close_block [forend] { - if (format::is_replace_braces() && format::prepare_rule(format::Pos::from(tokAt(scanner,@iters)))) { - format::get_writer() << "(" << format::substring_between(tokAt(scanner, @loc_start), tokAt(scanner, @loc)) - << format::get_substring(format::Pos::from(tokAt(scanner,@iters)), - format::Pos::from_last(tokAt(scanner,@srcs))) - << format::substring_between(tokAt(scanner, @where), tokAt(scanner, @forend)) << ")"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@srcs))); - } - $$ = ast_arrayComprehension(scanner,tokAt(scanner,@loc),$iters,$srcs,$subexpr,$where,tokRangeAt(scanner,@subexpr,@forend),false,true); - } - | CBRCBRB[loc_start] DAS_FOR[loc] variable_name_with_pos_list[iters] DAS_IN expr_list[srcs] ';' make_map_tuple[subexpr] array_comprehension_where[where] close_block[sq_end] close_block [forend] { - // std::cout << "case12" << std::endl; - if (format::prepare_rule(format::Pos::from(tokAt(scanner,@loc_start)))) { - auto internal = format::get_substring(format::Pos::from(tokAt(scanner,@loc)), format::Pos::from_last(tokAt(scanner,@where))); - format::get_writer() << "[" << format::substring_between(tokAt(scanner, @loc_start), tokAt(scanner, @loc)) - << internal - << format::substring_between(tokAt(scanner, @where), tokAt(scanner, @sq_end)) << "]"; - format::finish_rule(format::Pos::from_last(tokAt(scanner,@forend))); - } - $$ = ast_arrayComprehension(scanner,tokAt(scanner,@loc),$iters,$srcs,$subexpr,$where,tokRangeAt(scanner,@subexpr,@forend),true,true); - } - ; - -%% diff --git a/utils/gen1-to-gen2/fmt.cpp b/utils/gen1-to-gen2/fmt.cpp deleted file mode 100644 index 89c1928cbd..0000000000 --- a/utils/gen1-to-gen2/fmt.cpp +++ /dev/null @@ -1,318 +0,0 @@ -#include "daScript/daScript.h" -#include "daScript/simulate/fs_file_info.h" -#include "../src/parser/parser_state.h" - -#include -#include - -#include "daScript/ast/ast.h" - -typedef void * yyscan_t; -union YYSTYPE; - -#define YY_EXTRA_TYPE das::DasParserState * - -#define YY_NO_UNISTD_H -#include "../src/parser/lex.yy.h" -#include "../src/parser/lex2.yy.h" -#include "../src/parser/parser_state.h" - -#include "formatter.h" -#include "fmt.h" -#include "helpers.h" - -void das_yybegin(const char * str, uint32_t len, yyscan_t yyscanner); -int fmt_yyparse(yyscan_t scanner); - -das::FileAccessPtr get_file_access(char *pak);//link time resolved dependencies - -namespace das::format { - -enum class NoCommentReason { - OpenComment, - CloseComment, - String, -}; - -/** - * Removes all useless semicolons - * @param str - * @return formatted string - */ -string remove_semicolons(string_view str, bool is_gen2) { - string result; - size_t line_end = size_t(-1); - int par_balance = 0; // () - int sq_braces_balance = 0; // [] - int braces_balance = 0; // {} - vector disables; - do { - size_t offset = line_end + 1; - line_end = str.find('\n', offset); - // bool is_eof = str.size() <= offset; - // bool indent_non_zero = (!is_eof && (str.at(offset) == ' ' || str.at(offset) == '\t')); - auto last_char_idx = offset + format::find_comma_place(str.substr(offset, line_end - offset)); - auto cur_line = str.substr(offset, last_char_idx - offset + 1); - for (size_t i = 0; i < cur_line.size(); i++) { - const auto c = cur_line.at(i); - if (c == '\\') { - i++; - continue; - } - optional maybe_reason; - if (disables.empty() && c == '/' && cur_line.size() > i + 1 && cur_line.at(i + 1) == '/') { - break; - } - if (c == '"') { - maybe_reason = NoCommentReason::String; - } else if (c == '/' && cur_line.size() > i + 1 && cur_line.at(i + 1) == '*') { - maybe_reason = NoCommentReason::OpenComment; - } else if (c == '*' && cur_line.size() > i + 1 && cur_line.at(i + 1) == '/') { - maybe_reason = NoCommentReason::CloseComment; - } - if (maybe_reason) { - if (!disables.empty() && disables.back() == maybe_reason) { - disables.pop_back(); - } else { - if (maybe_reason == NoCommentReason::OpenComment) { - maybe_reason = NoCommentReason::CloseComment; - } - if (disables.empty() || disables.back() != NoCommentReason::String) { - disables.emplace_back(maybe_reason.value()); - } - } - } - if (!disables.empty()) { - continue; - } - switch (c) { - case '(': par_balance += 1; break; - case ')': par_balance -= 1; break; - case '[': sq_braces_balance += 1; break; - case ']': sq_braces_balance -= 1; break; - case '{': braces_balance += 1; break; - case '}': braces_balance -= 1; break; - default: break; - } - } - if (par_balance == 0 && (braces_balance == 0 || is_gen2) && - sq_braces_balance == 0 && - last_char_idx != offset - 1 && - str.at(last_char_idx) == ';') { - result += string(str.substr(offset, last_char_idx - offset)); - result += string(str.substr(last_char_idx + 1, line_end - last_char_idx)); - } else { - result += string(str.substr(offset, line_end + 1 - offset)); - } - } while (line_end != size_t(-1)); - return result; -} - -void addNewModules(ModuleGroup &libGroup, ProgramPtr program) { - libGroup.addModule(program->thisModule.release()); - program->library.foreach([&](Module *pm) -> bool { - if (!pm->name.empty() && pm->name != "$") { - if (!libGroup.findModule(pm->name)) { - libGroup.addModule(pm); - } - } - return true; - }, "*"); -} - -Result transform_syntax(const string &filename, const string content, format::FormatOptions options) { - auto src = content; - if (src.find("options gen2") == 0) { - Result res; - res.ok = src; - return res; - } - string prev; - vector req; - vector missing; - vector circular, notAllowed; - vector chain; - das_set dependencies; - ModuleGroup libGroup; - CodeOfPolicies policies; - policies.aot = false; - policies.aot_module = false; - policies.fail_on_lack_of_aot_export = false; - policies.version_2_syntax = false; - - TextPrinter tp; - - auto access = get_file_access(nullptr); - TextPrinter tout; - string moduleName; - das_hash_map namelessReq; - vector namelessMismatches; - - // daslib/builtin defines to_array_move / to_table_move and the comprehension push that the - // gen2 make-literal lowering ([1,2,3], {k=>v}, [for ...]) emits. compileDaScript pulls it in - // automatically (addExtraDependency); this hand-rolled parse must do the same, or the - // verify-compile of converted make-literals fails generic resolution. (issue #3094) - { - const string builtinPath = getDasRoot() + "/daslib/builtin.das"; - string builtinModName; - if (getPrerequisits(builtinPath, access, builtinModName, req, missing, circular, notAllowed, chain, - dependencies, namelessReq, namelessMismatches, libGroup, nullptr, 1, !policies.ignore_shared_modules)) { - ModuleInfo info; - auto finfo = access->getFileInfo(builtinPath); - info.fileName = finfo ? finfo->name : builtinPath; - info.importName = ""; - info.moduleName = "builtin"; - info.extraDepModule = true; - req.push_back(info); - } - } - - // The input filename may be synthetic (e.g. the --tests harness, where the content is - // supplied directly and no such file exists on disk), so don't gate module loading on - // getPrerequisits resolving it — builtin (added above) must load either way. - getPrerequisits(filename, access, moduleName, req, missing, circular, notAllowed, chain, - dependencies, namelessReq, namelessMismatches, libGroup, nullptr, 1, !policies.ignore_shared_modules); - for (auto &mod: req) { - if (libGroup.findModule(mod.moduleName)) { - continue; - } - auto program = parseDaScript(mod.fileName, mod.moduleName, access, tout, libGroup, true, true, - policies); - policies.threadlock_context |= program->options.getBoolOption("threadlock_context", false); - if (program->failed()) { - for (const auto& err: program->errors) { - tp << err.what << " " << err.at.describe() << '\n'; - } - // return {}; // still try to compile - } - if (program->thisModule->name.empty()) { - program->thisModule->name = mod.moduleName; - program->thisModule->wasParsedNameless = true; - } - program->thisModule->fileName = mod.fileName; - addNewModules(libGroup, program); - } - - int iter = 0; - policies.version_2_syntax = false; - const auto tmp_name1 = std::filesystem::temp_directory_path() / "tmp1.das"; - { - std::ofstream ostream(tmp_name1); - ostream << src.c_str(); - } - auto src_program = parseDaScript(das::string(tmp_name1.string().c_str()), "", access, tout, libGroup, true, true, policies); - while (prev != src) { - prev = src; - - TextWriter ss; - format::init(&ss, src, options, src_program); - - // All initialization and parsing took from daslang source - yyscan_t scanner = nullptr; - ProgramPtr program = make_smart(); - daScriptEnvironment::getBound()->g_Program = program; - daScriptEnvironment::getBound()->g_compilerLog = &tout; - program->promoteToBuiltin = false; - program->isCompiling = true; - program->isDependency = false; - program->needMacroModule = false; - program->policies = policies; - program->thisModuleGroup = &libGroup; - program->thisModuleName = program->thisModule->name; - libGroup.foreach([&](Module *pm) { - program->library.addModule(pm); - return true; - }, "*"); - - - DasParserState parserState; - parserState.g_Access = access; - parserState.g_FileAccessStack.push_back(access->getFileInfo(filename)); - parserState.g_Program = program; - parserState.das_def_tab_size = daScriptEnvironment::getBound()->das_def_tab_size; - parserState.das_gen2_make_syntax = false; - libGroup.foreach([&](Module *mod) { - if (mod->commentReader) { - parserState.g_CommentReaders.push_back(mod->commentReader.get()); - } - return true; - }, "*"); - - das_yylex_init_extra(&parserState, &scanner); - das_yybegin(src.c_str(), uint32_t(src.size()), scanner); - auto err = fmt_yyparse(scanner); - - // end of parsing - - format::destroy(); - das_yylex_destroy(scanner); - if (err != 0) { - for (const auto & erR: program->errors) { - tp << erR.at.describe() << '\n' << erR.what << '\n'; - } - if (iter == 0) { - return {}; - } - Result res; - res.error = Result::ErrorInfo{prev, program->errors.front().what}; - return res; -// return {error=Result::ErrorInfo{prev, program->errors.front().what}}; // designated initializers is c++ 20 feature - } - src = ss.str(); - iter++; - } - if (!options.contains(FormatOpt::SemicolonEOL)) { - src = remove_semicolons(src, options.contains(FormatOpt::V2Syntax)); - } - const auto tmp_name = std::filesystem::temp_directory_path() / "tmp.das"; - { - std::ofstream ostream(tmp_name); - ostream << src.c_str(); - ostream.flush(); - } - policies.version_2_syntax = options.contains(format::FormatOpt::V2Syntax); - auto program = parseDaScript(das::string(tmp_name.string().c_str()), "", access, tout, libGroup, true, true, policies); - Result res; - if (!program->failed()) { - res.ok = src; // designated initializers not supported in CI - } else { - tp << program->errors.front().at.describe() << '\n'; - res.error = Result::ErrorInfo{prev, program->errors.front().what}; - } - return res; -} - -int run(FormatOptions opts, const vector &files) { - int ret_code = 0; - TextPrinter tp; - if (files.size() > 1 && !opts.contains(FormatOpt::Inplace)) { - tp << "Expected inplace mode in case of more than 1 file\n"; - } - for (const auto &file: files) { - tp << "input file=" << file << '\n'; - std::ifstream t(file.c_str()); - - string str(std::string((std::istreambuf_iterator(t)), - std::istreambuf_iterator()).c_str()); - - auto res = transform_syntax(file, str, opts); - if (res.ok) { - if (opts.contains(FormatOpt::Inplace)) { - std::ofstream out(file.c_str()); - out << res.ok.value().c_str(); - } else { - tp << res.ok.value().c_str(); - } - } else if (res.error) { - if (!opts.contains(FormatOpt::Inplace)) { - tp << res.error->content << '\n'; - } - tp << file << '\n' << res.error->what << '\n'; - ret_code = -1; - } else { - tp << "cant_compile=" << file << '\n'; - } - } - return ret_code; -} -} diff --git a/utils/gen1-to-gen2/fmt.h b/utils/gen1-to-gen2/fmt.h deleted file mode 100644 index cea8afc995..0000000000 --- a/utils/gen1-to-gen2/fmt.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include -#include "formatter.h" - - -namespace das::format { - - struct Result { - struct ErrorInfo { - string content; - string what; - }; - std::optional ok; - std::optional error; - }; - - /** - * Run formatter on single file and it's content - */ - DAS_CC_API Result transform_syntax(const string &filename, const string content, format::FormatOptions options = {}); - - /** - * Run formatter on following files - * @return 0 if everything is fine - */ - DAS_CC_API int run(FormatOptions opt, const vector &files); -}; diff --git a/utils/gen1-to-gen2/formatter.cpp b/utils/gen1-to-gen2/formatter.cpp deleted file mode 100644 index c32e8dec0e..0000000000 --- a/utils/gen1-to-gen2/formatter.cpp +++ /dev/null @@ -1,213 +0,0 @@ -#include "formatter.h" - -namespace das::format { - - struct State { - FormatOptions options; - vector content_; - Pos last; - ProgramPtr program; - bool enabled = false; - TextWriter *ss; - }; - - static State state; - - optional try_print_until(Pos info) { - if (!state.enabled) { - return nullopt; - } - if (info.line < state.last.line) { - return state.last; - } - get_writer() << get_substring(state.last, info); - state.last = info; - return nullopt; - } - - - void init(TextWriter *ss, string content, FormatOptions options, ProgramPtr program) { - string line; - content.push_back('\n'); // easiest way to flush the last line - for (const auto c: content) { - if (c != '\n') { - line.push_back(c); - } else { - state.content_.emplace_back(das::move(line)); - line.clear(); - } - } - state.ss = ss; - state.enabled = true; - state.last = Pos{1, 0}; - state.program = program; - state.options = das::move(options); - if ((state.content_.empty() || state.content_.front().substr(0, strlen("options gen2")) != "options gen2") && - state.options.contains(FormatOpt::V2Syntax)) { - *state.ss << "options gen2"; - if (state.options.contains(FormatOpt::SemicolonEOL)) { - *state.ss << ";"; - } - *state.ss << "\n"; - } - } - - void destroy() { - if (!state.content_.empty()) { - try_print_until(Pos{static_cast(state.content_.size()), - static_cast(state.content_.back().size())}); - } - state.ss = nullptr; - state.enabled = false; - state.last = {}; - state.options = {}; - state.content_ = {}; - state.program = nullptr; - } - - void set_to(Pos info) { - assert(state.last <= info); - state.last = info; - } - - string get_substring(Pos pos1, Pos pos2) { - if (!state.enabled || pos1 < state.last) { - return ""; - } - - TextPrinter tp; - string result; - for (; pos1.line < pos2.line; pos1.line++, pos1.column = 0) { - if (pos1.line > state.content_.size()) { - tp << "Warning, location line out of range\n"; - return ""; - } else if (pos1.column > state.content_[pos1.line - 1].length()) { -// tp << "incorrect location info, extra symbols " -// << pos1.column << " " -// << state.content_[pos1.line - 1].length() << '\n'; - } else { - result += state.content_[pos1.line - 1].substr(pos1.column); - } - result += '\n'; - } - if (pos2.column < pos1.column || pos2.line < pos1.line) { - assert(result.empty()); - assert(pos1.line == pos2.line); - return ""; - } - - if (pos1.line > state.content_.size()) { - tp << "Warning, location line out of range\n"; - return ""; - } - if (pos1.column > state.content_[pos1.line - 1].size()) { - tp << "Warning, location column out of range\n"; - return ""; - } - result += state.content_[pos1.line - 1].substr(pos1.column, pos2.column - pos1.column); - return result; - } - - - string get_substring(LineInfo info) { - return get_substring(Pos{info.line, info.column}, - Pos{info.last_line, info.last_column}); - } - - string substring_between(LineInfo info1, LineInfo info2) { - return get_substring(Pos{info1.last_line, info1.last_column}, - Pos{info2.line, info2.column}); - } - - string get_line(uint32_t line) { - if (line - 1 >= state.content_.size()) { - TextPrinter() << "Warning, requested line is too big\n"; - return ""; - } - return state.content_.at(line - 1); - } - - TextWriter& get_writer() { - return *state.ss; - } - - bool prepare_rule(Pos pos) { - if (state.enabled && state.last <= pos) { - try_print_until(pos); - return true; - } - return false; - } - - void finish_rule(Pos pos) { - assert(state.enabled && state.last <= pos); - set_to(pos); - } - - optional try_find_struct(const string &name) { - if (state.program != nullptr) { - const auto library = state.program->library; - auto structs = state.program->findStructure(name); - auto aliases = state.program->findAlias(name); - if (!structs.empty()) { - assert(structs.size() == 1); - assert(aliases.empty()); - return structs.front(); - } else if (!aliases.empty()) { - assert(aliases.size() == 1); - } - } - return std::nullopt; - } - - bool can_default_init(const string &name) { - auto maybe_struct = try_find_struct(name); - if (!maybe_struct) { - return false; - } else { - const auto &fields = (*maybe_struct)->fields; - return all_of(fields.begin(), fields.end(), [](auto field) { - return field.init; - }); - } - } - - CanInit can_init_with(const string &name, uint32_t arg_cnt) { - return CanInit::Can; - // Possible uninitialized - if (arg_cnt == 0) { - if (can_default_init(name)) { - return CanInit::Can; - } else { - return CanInit::Cannot; - } - } - auto maybe_struct = try_find_struct(name); - if (!maybe_struct) { - return CanInit::Unknown; - } - return (*maybe_struct)->fields.size() == arg_cnt ? CanInit::Can : CanInit::Unknown; - } - - bool is_else_newline() { - return state.options.contains(FormatOpt::ElseNewLine); - } - - bool is_replace_braces() { - return state.options.contains(FormatOpt::V2Syntax); - } - - bool end_with_semicolon() { - return true; // state.options.contains(FormatOpt::SemicolonEOL); - } - - bool enum_bitfield_with_comma() { - return state.options.contains(FormatOpt::CommaAtEndOfEnumBitfield); - } - - bool is_formatter_enabled() { - return state.enabled; - } - -} - diff --git a/utils/gen1-to-gen2/formatter.h b/utils/gen1-to-gen2/formatter.h deleted file mode 100644 index 98f3201748..0000000000 --- a/utils/gen1-to-gen2/formatter.h +++ /dev/null @@ -1,131 +0,0 @@ -#ifndef DAS_FORMATTER_H -#define DAS_FORMATTER_H - -#include -#include "daScript/daScript.h" -#include "daScript/das_config.h" - -using std::optional; -using std::nullopt; - -namespace das::format { - - // formatter config - enum class FormatOpt { - Inplace, - V2Syntax, - ElseNewLine, - CommaAtEndOfEnumBitfield, - SemicolonEOL, - // in some cases old -> new syntax conversion depends on actual types - // It can't be done just during parser - // This flags enables such checks - // (e.g. [[A()]] can be A() or A(uninitialized)) - VerifyUninitialized, - }; - - class FormatOptions { - public: - FormatOptions() = default; - FormatOptions(das_hash_set options_) : options(das::move(options_)) {} - - bool contains(FormatOpt opt) const { - return options.count(opt); - } - - void insert(FormatOpt opt) { - options.emplace(opt); - } - - private: - das_hash_set options; - }; - - struct Pos { - uint32_t line; - uint32_t column; - - static Pos from(LineInfo info) { - return Pos{info.line, info.column}; - } - - static Pos from_last(LineInfo info) { - return Pos{info.last_line, info.last_column}; - } - - - bool operator != (const Pos &rhs) const { - return line != rhs.line || column != rhs.column; - } - - bool operator == (const Pos &rhs) const { - return line == rhs.line && column == rhs.column; - } - - bool operator < (const Pos &rhs) const { - return line < rhs.line || (line == rhs.line && column < rhs.column); - } - - - bool operator <= (const Pos &rhs) const { - return line < rhs.line || (line == rhs.line && column <= rhs.column); - } - }; - - // Should be called before and after each formatting operation. Maintains internal compiler state - void init(TextWriter *ss, string content, FormatOptions options, ProgramPtr program); - void destroy(); - - /** - * @return output stream - */ - TextWriter& get_writer(); - - /** - * This function should be called before handling each rule - * @param pos beginning of the rule - * @return true if we can handle it now - * - * Ex: A(B()). Bison will parse in the following order: B(), A( ). - * Due to simplicity of formatter, we can't handle rule, if some part of it was somehow modified. - * So if B() already handled we can't handle A( ) in current iteration - */ - bool prepare_rule(Pos pos); - - /** - * Input file will be printed until current position. - * @param pos end of the rule - */ - void finish_rule(Pos pos); - - /** - * @return specified substring of input file - */ - string get_substring(LineInfo info); - string get_substring(Pos pos1, Pos pos2); - string substring_between(LineInfo info1, LineInfo info2); - - // hack to get current identation - string get_line(uint32_t line); - - // - std::optional try_find_struct(const string &name); - - enum class CanInit { - Can, - Cannot, - Unknown, - }; - - bool can_default_init(const string &name); - CanInit can_init_with(const string &name, uint32_t arg_cnt); - - // Maybe we should replace it with getConfig(), if there will be a lot of options - bool is_replace_braces(); // use v2 syntax - bool is_else_newline(); // start else from new line - bool end_with_semicolon(); // end statements with ';' - bool enum_bitfield_with_comma(); // end statements with ',' - bool is_formatter_enabled(); // are formatter enabled mode -} - -#endif //DAS_FORMATTER_H diff --git a/utils/gen1-to-gen2/helpers.cpp b/utils/gen1-to-gen2/helpers.cpp deleted file mode 100644 index 28491ad6a6..0000000000 --- a/utils/gen1-to-gen2/helpers.cpp +++ /dev/null @@ -1,247 +0,0 @@ -#include "daScript/misc/platform.h" -#include "daScript/ast/ast.h" - -#include "helpers.h" - -namespace das::format { - - optional type_to_string(const TypeDecl *type_decl, LineInfo loc) { - if (type_decl->isTemp(false) || type_decl->alias == "``MACRO``TAG``") { - return "struct<" + format::get_substring(loc) + ">"; - } else if (type_decl->isAuto() && !type_decl->isArray() && !type_decl->isPointer()) { - return nullopt; - } else { - return get_substring(loc); - } - } - - string handle_msd(LineInfo start, ExprMakeStruct *msd, LineInfo end, string type_name, bool is_initialized) { - // ";" -> "," - auto structs = msd->structs; - if (structs.empty()) { - return ""; - } - const string prev_sep = ";"; - string maybe_uninit = is_initialized ? "" : "uninitialized"; - const string prefix = type_name + "("; - const string sep = "), "; - const string suffix = ")"; - - string result; - auto last = start; - for (size_t i = 0; i < structs.size(); i++) { - const auto &el = structs.at(i); - auto concat = format::substring_between(last, el->front()->at); - auto prev_end = concat.find(prev_sep); - assert(i == 0 || prev_end != npos); // incorrect prev_sep - { - auto can_init = can_init_with(type_name, uint32_t(el->size())); - switch (can_init) { - case CanInit::Can: maybe_uninit.clear(); break; - case CanInit::Cannot: maybe_uninit = "uninitialized"; break; - case CanInit::Unknown: break; - } - } - const auto cur_prefix = prefix + maybe_uninit; - if (i == 0) { - concat = cur_prefix + concat; - } else if (prev_end != npos) { - concat.replace(prev_end, prev_sep.size(), sep + cur_prefix); - } else { - std::abort(); - } - auto new_line = convert_to_string(*el); - result - .append(concat) - .append(new_line); - last = el->back()->at; - } - result.append(format::substring_between(last, end)) - .append(suffix); - return result; - } - - string handle_mka(LineInfo start, ExprMakeArray *mka, LineInfo end) { - const auto &values = mka->values; - if (values.empty()) { - return ""; - } - const string prev_sep = ";"; - const string sep = ","; - - // const auto &front = static_cast(values.front().get())->values; - string result; - string suffix; - Pos last = Pos::from_last(start); - for (size_t i = 0; i < values.size(); i++) { - const auto &el = values.at(i); - string middle; - string prefix; - Pos from; - Pos to; - auto real_sep = suffix + sep; - if ( el->rtti_isMakeTuple() ) { - const auto & Values = static_cast(el)->values; - prefix = "("; - suffix = ")"; - middle = convert_to_string(Values); - from = Pos::from(Values.front()->at); - to = Pos::from_last(Values.back()->at); - } else { - suffix.clear(); - middle = format::get_substring(el->at); - from = Pos::from(el->at); - to = Pos::from_last(el->at); - } - auto concat = format::get_substring(last, from); - auto prev_end = concat.find(prev_sep); - assert(i == 0 || prev_end != npos); // incorrect prev_sep - if (i != 0 && prev_end != npos) { - concat.replace(prev_end, prev_sep.size(), real_sep); - } - result.append(concat) - .append(prefix) - .append(middle); - last = to; - } - result.append(get_substring(last, Pos::from(end))) - .append(suffix); - - return result; - } - - size_t find_comma_place(string_view line) { // dirty hack to find last meaningful character. - size_t comment_start = line.find("//"); - if (comment_start == 0) { - return 0; - } - if (comment_start != npos) { - const auto code_part = line.substr(0, comment_start); - const auto quotes_code = count(code_part.begin(), code_part.end(), '"'); - if (quotes_code % 2 != 0) { - comment_start = line.size(); // should be recursive call to find_comma_place, let's simply put to the end - } - } - return line.find_last_not_of(" \t\r", comment_start == npos ? npos : comment_start - 1); - } - - void try_emit_at_eol(Pos loc, char sep) { - if (format::is_replace_braces()) { - const auto &line = format::get_line(loc.line); - auto comma_place = format::find_comma_place(line); - if (comma_place == npos) { - // it means EOF. - return; - } - loc.column = uint32_t(comma_place + 1); - if (line.at(comma_place) != sep && // ad-hoc, fix location - format::prepare_rule(loc)) { - format::get_writer() << sep; - format::finish_rule(loc); - } - } - } - - void try_semicolon_at_eol(Pos loc) { - if (format::end_with_semicolon()) { - try_emit_at_eol(loc, ';'); - } - } - - size_t get_indent(Pos loc, size_t tab_size) { - auto start = loc; - start.column = 0; - auto substr = get_substring(start, loc); - size_t result = 0; - for (auto c: substr) { - if (c == ' ') { - result += 1; - } else if (c == '\t') { - result += tab_size; - } else { - break; - } - } - return result; - } - - void handle_brace(Pos prev_loc, uint32_t value, const string &internal, size_t tab_size, Pos end_loc) { - const auto &line = format::get_line(prev_loc.line); - auto brace_column = format::find_comma_place(line); - prev_loc.column = uint32_t(brace_column + 1); - if (format::is_replace_braces() && value != 0xdeadbeef && - format::prepare_rule(prev_loc)) { - - if (format::prepare_rule(prev_loc)) { - format::get_writer() << " {" << internal << "\n" << string(value * tab_size, ' ') + "}"; - format::finish_rule(end_loc); - } - } - } - - void replace_with(bool v2_only, Pos start, const string &internal, Pos end, const string &open, const string &close) { - if ((!v2_only || format::is_replace_braces()) && format::prepare_rule(start)) { - format::get_writer() << open << internal << close; - format::finish_rule(end); - } - } - - void replace_with(bool v2_only, Pos start, LineInfo internal, Pos end, const string &open, const string &close) { - replace_with(v2_only, start, format::get_substring(internal), end, open, close); - } - - bool skip_token(bool v2_only, bool need_skip, LineInfo token) { - if (!need_skip) { - return false; - } - auto start = format::Pos::from(token); - auto end = format::Pos::from_last(token); - if (start == end) { - return false; - } - if ((!v2_only || format::is_replace_braces()) && format::prepare_rule(start)) { - format::finish_rule(end); - return true; - } else { - return false; - } - } - - void wrap_par_expr(LineInfo real_expr, LineInfo info_expr) { - if (format::is_replace_braces() && real_expr == info_expr && format::prepare_rule(Pos::from(real_expr))) { - format::get_writer() << "(" << format::get_substring(real_expr) << ")"; - format::finish_rule(Pos::from_last(real_expr)); - } - } - - void wrap_par_expr_newline(LineInfo real_expr, LineInfo info_expr) { - if (real_expr.line != real_expr.last_line) { - wrap_par_expr(real_expr, info_expr); - } - } - - - LineInfo concat(LineInfo first, LineInfo last) { - return LineInfo( - first.fileInfo, - first.column, - first.line, - last.last_column, - last.last_line); - } - - static bool is_empty(const string &str) { - return all_of(str.begin(), str.end(), [](auto c) - { return c == ' ' || c == '\t' || c == '\r' || c == '\n'; }); - } - - void skip_spaces_or_print(LineInfo /*prev*/, LineInfo block, LineInfo next, size_t tab_size, const string& change) { - auto internal = format::substring_between(block, next); - auto same_depth = format::get_indent(format::Pos::from_last(block), tab_size) == - format::get_indent(format::Pos::from(next), tab_size); - if (is_empty(internal) && same_depth && internal != change && format::prepare_rule(Pos::from_last(block))) { - format::get_writer() << change; - format::finish_rule(Pos::from(next)); - } - } -} diff --git a/utils/gen1-to-gen2/helpers.h b/utils/gen1-to-gen2/helpers.h deleted file mode 100644 index 912acec7f1..0000000000 --- a/utils/gen1-to-gen2/helpers.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef DAS_HELPERS_H -#define DAS_HELPERS_H - -#include - -#include "formatter.h" - -namespace das::format { - - static inline constexpr size_t npos = size_t(-1); - - template - string convert_to_string(const vector &vec, string sep = ",", string prev_sep = ",") { - if (vec.empty()) { - return ""; - } - string result = format::get_substring(vec.front()->at); - Pos last = Pos::from_last(vec.front()->at); - for_each(vec.begin()+1, vec.end(), [&last, &prev_sep, &result, &sep](const auto& el) { - auto concat = format::get_substring(last, Pos::from(el->at)); - auto prev_end = concat.find(prev_sep); - if (prev_end != npos) { - concat.replace(prev_end, prev_sep.size(), sep); - } else { - assert(concat.find("=>") != npos); - TextPrinter() << "Be careful, => is not safe yet\n"; - concat.replace(concat.find("=>"), 2, ","); // It's not safe! - } - auto new_line = format::get_substring(el->at); - result += concat; - result += new_line; - last = Pos::from_last(el->at); - }); - return result; - } - - optional type_to_string(const TypeDecl *type_decl, LineInfo loc /* pass loc, since it's sometimes incorrect on type itself*/); - - string handle_msd(LineInfo start, ExprMakeStruct* msd, LineInfo end, string type_name, bool is_initialized = true); - - string handle_mka(LineInfo start, ExprMakeArray* mka, LineInfo end); - - size_t find_comma_place(string_view line); - - void try_emit_at_eol(Pos loc, char sep); - - void try_semicolon_at_eol(Pos loc); - - size_t get_indent(Pos loc, size_t tab_size); - - void handle_brace(Pos prev_loc, uint32_t value, const string &internal, size_t tab_size, Pos end_loc); - - void replace_with(bool v2_only, Pos start, const string &internal, Pos end, const string &open, const string &close); - - void replace_with(bool v2_only, Pos start, LineInfo internal, Pos end, const string &open, const string &close); - - bool skip_token(bool v2_only, bool need_skip, LineInfo token); - - void wrap_par_expr(LineInfo real_expr, LineInfo info_expr); - // wrap with parenthesis only if it is mult line expression - void wrap_par_expr_newline(LineInfo real_expr, LineInfo info_expr); - - LineInfo concat(LineInfo first, LineInfo last); - - void skip_spaces_or_print(LineInfo prev, LineInfo block, LineInfo next, size_t tab_size, const string& change = " "); -} - -#endif //DAS_HELPERS_H diff --git a/utils/gen1-to-gen2/main.cpp b/utils/gen1-to-gen2/main.cpp deleted file mode 100644 index 3a2740f3b9..0000000000 --- a/utils/gen1-to-gen2/main.cpp +++ /dev/null @@ -1,325 +0,0 @@ -#include "daScript/ast/ast.h" -#include "daScript/ast/dyn_modules.h" -#include "daScript/daScriptModule.h" -#include "daScript/ast/ast_serializer.h" -#include "daScript/misc/platform.h" -#include "daScript/misc/sysos.h" -#include "fmt.h" - -#if !defined(DAS_ENABLE_DLL) || !defined(DAS_ENABLE_DYN_INCLUDES) -#include "modules/external_declare.inc" -#endif - -using namespace das; - -das::FileAccessPtr get_file_access( char * pak ); - -void InitModules() { - // register modules - register_builtin_modules(); -#if !defined(DAS_ENABLE_DLL) || !defined(DAS_ENABLE_DYN_INCLUDES) -#include "modules/external_pull.inc" -#endif -#ifdef DAS_ENABLE_DYN_INCLUDES - daScriptEnvironment::ensure(); - auto access = get_file_access(nullptr); - TextPrinter tout; - vector load_modules; - require_dynamic_modules(access, getDasRoot(), "", load_modules, tout); -#endif - Module::Initialize(); - // compile and run - -} - -string help() { - return "Tool to convert daslang v1 syntax to v2\n" - "gen1_to_gen2 {-i} filename1 {filename2} ...:\n" - " -i inplace conversion, write to the same file. Multiple filenames only allowed in inplace mode\n" - " --tests Run tests, no filenames required\n" - " --semicolon Keep semicolon after convertion\n" - ""; -} - - -struct TestData { - string original; - string expected; - format::FormatOptions options = {}; -}; - -vector test_cases() { - const string in_prefix = "[safe_when_uninitialized]\n" - "struct Foo\n" - " a : int = 5\n" - " b : float = 3.0\n" - "struct Bar\n" - " a : Foo\n" - "var var1 = "; - const string out_prefix = in_prefix; - - const string postfix = "\n"; - vector base = { - {"[[/**/Foo/*0*/a/*a*/=/**/1/*a*///abc\n,//dsa\n/*dsa*/\nb=2.0/**/\n//dsa\n]]", - "/**/Foo(/*0*/a/*a*/=/**/1/*a*///abc\n,//dsa\n/*dsa*/\nb=2.0/**/\n//dsa\n)"}, // 1 // no uninit because it's redundant - {"[[/**/Foo/**/]]", "Foo(/**//**/)"}, // 2 - {"[[/*a*/Foo(/*b*/)/*c*/]]", "Foo(/*a*//*b*//*c*/)"}, // 3 - {"[[/*a*/Foo(/*b*/)/*c*/ a=1/*d*/,/*e*/b=2.0/*f*/]]", "/*a*//*b*/Foo(/*c*/ a=1/*d*/,/*e*/b=2.0/*f*/)"}, // 4 - {"[[/*a*/auto/*b*/1/*c*/,/*d*/2/*e*/]]", "/*a*//*b*/(1/*c*/,/*d*/2/*e*/)"}, // 13 -// {"[[for x in [1, 20]; x*x; where x%2 == 0]];", "[iterator for x in [1, 20]; x*x; where x%2 == 0];"}, // 5 // each result is discarded, which is unsaf - {"[{/*a*/Foo/*b*/a=1/*c*/,/*d*/b=2./*e*/;/*f*/a=2/*g*/,/*h*/b=1./*i*/}]", - "[/*a*/Foo(/*b*/a=1/*c*/,/*d*/b=2./*e*/), Foo(/*f*/a=2/*g*/,/*h*/b=1./*i*/)]"}, // 6 - {"[{/*a*/Foo()/*b*/a=1/*c*/,/*d*/b=2./*e*/;/*g*/a=2/*h*/,/*i*/b=1./*j*/}]", - "[/*a*/Foo(/*b*/a=1/*c*/,/*d*/b=2./*e*/), Foo(/*g*/a=2/*h*/,/*i*/b=1./*j*/)]"}, // 7 -// {"[{Foo a=1,b=2.;a=2,b=1. }]", "[Foo(a=1,b=2.),Foo(a=2,b=1.)]"}, // what about optional block in new syntax - {"[{/*a*/auto/*b*/1/*c*/;/*d*/2/*e*/;/*f*/3/*g*/;/*h*/4/*i*/}]", - "[/*a*//*b*/1/*c*/,/*d*/2/*e*/,/*f*/3/*g*/,/*h*/4/*i*/]"}, // 8 - {"[{/*a*/auto/*b*/1/*c*/,/*d*/2.2/*e*/}]", "[/*a*//*b*/(1/*c*/,/*d*/2.2/*e*/)]"}, // 8 - {"[{/*a*/for/*b*/x/*c*/in/*d*/0..10/*e*/;/*f*/x*x/*g*/;/*h*/where/*i*/x%2==0/*j*/}]", - "[/*a*/for/*b*/x/*c*/in/*d*/0..10/*e*/;/*f*/x*x/*g*/;/*h*/where/*i*/x%2==0/*j*/]"}, // 9 - {"{{/*a*/for/*b*/x/*c*/in/*d*/0..10/*e*/;/*f*/x*x/*g*/;/*h*/where/*i*/x%2==0/*j*/}}", - "[/*a*/for/*b*/x/*c*/in/*d*/0..10/*e*/;/*f*/x*x/*g*/;/*h*/where/*i*/x%2==0/*j*/]"}, // 12 - {"{{/*a*/1/*b*/;/*c*/2/*d*/;/*e*/3/*f*/;/*g*/4/*h*/}}", "{/*a*/1/*b*/,/*c*/2/*d*/,/*e*/3/*f*/,/*g*/4/*h*/}"}, // 10 - {R"({{/*a*/1=>"a"/*b*/;/*c*/2=>"b"/*d*/;/*e*/3=>"c"/*f*/;/*g*/4=>"d"/*h*/}})", - R"({/*a*/1=>"a"/*b*/,/*c*/2=>"b"/*d*/,/*e*/3=>"c"/*f*/,/*g*/4=>"d"/*h*/})"}, // 10 - {R"([[/*a*/auto/*b*/1/*c*/,/*d*/2./*e*/,/*f*/"3"/*g*/;/*h*/1/*i*/,/*j*/4./*k*/,/*l*/"2"/*m*/]])", - R"(fixed_array(/*a*//*b*/(1/*c*/,/*d*/2./*e*/,/*f*/"3"/*g*/),/*h*/(1/*i*/,/*j*/4./*k*/,/*l*/"2"/*m*/)))"}, // 13 -// -// // anything - {"[[/*a*/auto/*b*/1/*c*/;/*d*/2/*e*/]]", - "fixed_array(/*a*//*b*/1/*c*/,/*d*/2/*e*/)"}, - {"[[/*a*/Foo?/*b*/]]", "default/*a*//*b*/"}, - {"[[/*a*/Foo#/*b*/]]", "struct(/*a*//*b*/)"}, - {"[[tuple\n" - " \"a\", 1.0;\n" - " \"b\", 2.0;" - "]]", - "fixed_array>(\n" - " (\"a\", 1.0),\n" - " (\"b\", 2.0))"}, - { - "[[auto[] \"a\" ]]\n", - "fixed_array( \"a\" )\n", - }, - - - // nested - - {"[[/*a*/Bar/*b*/a=[[/*c*/Foo/*f*/b=2.0/*g*/]]/*h*/]]", - "/*a*/Bar(/*b*/a=/*c*/Foo(/*f*/b=2.0/*g*/)/*h*/)"}, - }; - for (auto &[in, out, options]: base) { - in = in_prefix + in + postfix; - out = out_prefix + out + postfix; - } - - vector tuple_expansion = { - // tuple expansion (doesn't work in global scope!) - {"def main()\n var [[/*a*/a/*b*/,/*c*/b/*d*/]] = (123, 321)", - "def main()\n var (/*a*/a/*b*/,/*c*/b/*d*/) = (123, 321)"}, - {"def main()\n var [[/*a*/a/*b*/,/*c*/b/*d*/]]: tuple = (123, 321)", - "def main()\n var (/*a*/a/*b*/,/*c*/b/*d*/): tuple = (123, 321)"}, - }; - - vector braces_tests = { - // test braces - {"typedef \n A = int\n B = string", "typedef A = int;\ntypedef B = string;\n"}, - {"def b()/**/\n /**/let a = 5", "def b()/**/ {\n /**/let a = 5;\n}"}, - {"def b()/**/\n /**/let a = 5", "def b()/**/ {\n /**/let a = 5;\n}"}, - {"def b() /**/\n let a = 5/**/;\n", "def b() /**/ {\n let a = 5/**/;\n}\n"}, - {"def b(it)\n let x = typeinfo is_iterable (it)", "def b(it) {\n let x = typeinfo is_iterable (it);\n}"}, - - {"class C\n" - " a : int = 5\n" - "class A : C\n" - " c : string = \"add_new_call_macro\"", - "class C {\n" - " a : int = 5;\n" - "}\n" - "class A : C {\n" - " c : string = \"add_new_call_macro\";\n" - "}", - }, - {"def main()//aa\n /**/let x = 1 // 123", "def main() {//aa\n /**/let x = 1; // 123\n}"}, - {"bitfield A\n refCount", "bitfield A {\n refCount\n}"}, - - {"def b(x, y)\n for x in y\n x = x + 1", - "def b(x, y) {\n for (x in y) {\n x = x + 1;\n }\n}"}, - {"def b()\n let a = 5\n if a<0\n a = a + 1", - "def b() {\n let a = 5;\n if (a<0) {\n a = a + 1;\n }\n}"}, - {"def lower_bound ( a:array; val : TT const-& )\n" - " // comment \n" - " return lower_bound(a,0,length(a),val)\n" - "let x = 1;", - "def lower_bound ( a:array; val : TT const-& ) {\n" - " // comment \n" - " return lower_bound(a,0,length(a),val);\n" - "}\n" - "let x = 1;"}, - { - "bitfield/*a*/Test// b\n" - " one //c\n" - " two //d\n" - " three//e", - "bitfield/*a*/Test {// b\n" - " one //c\n" - " two //d\n" - " three//e\n" - "}"}, - { - "enum/*a*/Test/*b*/:/*c*/int// a\n" - " b// d\n", - "enum/*a*/Test/*b*/:/*c*/int {// a\n" - " b// d\n" - "}\n" - }, - { - "def foo(x){}\n" - "def main() {\n" - " foo() $() {} \n" - "}\n", - "def foo(x){}\n" - "def main() {\n" - " foo($() {}); \n" - "}\n" - }, - { - "def foo(x, y){}\n" - "def main() {\n" - " foo(123) $() {} \n" - "}\n", - "def foo(x, y){}\n" - "def main() {\n" - " foo(123, $() {}); \n" - "}\n" - }, - { - "let x = @ <| () {}\n", - "let x = @ () {};\n" - }, - { - "def test()//a\n" - " try//b\n" - " for i in range(0, 1)\n" - " assert(false)// d\n" - " recover//c\n" - " assert(false)\n", - "def test() {//a\n" - " try {//b\n" - " for (i in range(0, 1)) {\n" - " assert(false);// d\n" - " }\n" - " } recover {//c\n" - " assert(false);\n" - " }\n" - "}\n", - }, - { - "def f()\n" - " assume x = 1", - "def f() {\n" - " assume x = 1;\n" - "}", - }, - { - "def main() {\n" - " let x = 1\n" - "+\n" - "2;\n" - "}", - "def main() {\n" - " let x = (1\n" - "+\n" - "2);\n" - "}", - }, - { - "def main() {\n" - " let x = (1\n" - "+\n" - "2 +\n3 + 4);\n" - "}", - "def main() {\n" - " let x = (1\n" - "+\n" - "2 +\n3 + 4);\n" - "}", - }, -// { -// "var css <- @ <| {\n" -// " saveLiveContext();\n" -// "}", -// "var css <- @ <| $() {\n" -// " saveLiveContext();\n" -// "}", -// }, - }; - for (auto &[in, out, opt]: braces_tests) { - opt = format::FormatOptions(das_hash_set{format::FormatOpt::V2Syntax, format::FormatOpt::SemicolonEOL}); - out = "options gen2;\n" + out; - } - vector res; - res.insert(res.end(), base.begin(), base.end()); - res.insert(res.end(), tuple_expansion.begin(), tuple_expansion.end()); - res.insert(res.end(), braces_tests.begin(), braces_tests.end()); // did not implement yet - return res; -} - -int test() { - TextPrinter tp; - auto cases = test_cases(); - int ret_code = 0; - for (const auto &[in, out, cfg]: cases) { - auto res = transform_syntax("test.das", in, cfg); // any filename - if (!res.ok) { - tp << "input:\n" << in << " \noutput:\n" << res.error->content << " \nerror:\n" << res.error->what - << "\n"; - ret_code = -1; - } else if (res.ok != out) { - tp << " output:\n" << res.ok.value() << "\nexpected:\n" << out << "\n"; - ret_code = -1; - } - } - return ret_code; -} - -int main(int argc, char** argv) { - format::FormatOptions opts; - bool is_tests = false; - TextPrinter tp; - vector files; - if (argc < 2) { - tp << help(); - return -1; - } - for (int i = 1; i < argc; i++) { - const string arg = argv[i]; - if (arg.front() != '-') { - files.emplace_back(arg); - } else { - if (arg == "--tests") { - is_tests = true; - } else if (arg == "-i" || arg == "--inplace") { - opts.insert(format::FormatOpt::Inplace); - } else if (arg == "-v2" || arg == "--v2") { - opts.insert(format::FormatOpt::V2Syntax); - } else if (arg == "--semicolon") { - opts.insert(format::FormatOpt::SemicolonEOL); - } else { - tp << help(); - } - } - } - if (!is_tests && files.empty()) { - tp << "no files" << "\n"; - } - InitModules(); - int rc; - if (is_tests) { - rc = test(); - } else { - rc = das::format::run(opts, files); - } - Module::Shutdown(); - return rc; -} diff --git a/utils/internal/test-release/utils_phase.das b/utils/internal/test-release/utils_phase.das index 94f554b14e..7e4beeeb46 100644 --- a/utils/internal/test-release/utils_phase.das +++ b/utils/internal/test-release/utils_phase.das @@ -39,9 +39,6 @@ def public utils_checks() : array { // the exe form must be able to compile a test at all: an -exe tool bakes its build machine's native paths ToolCheck(name = "dastest.exe/common-suite", argv <- ["@EXE:dastest@", "--test", "utils/common/tests"], want := DASTEST_OK, forbid := DASTEST_EMPTY, timeout = 300.0), - ToolCheck(name = "gen1_to_gen2/self-tests", argv <- ["@EXE:gen1_to_gen2@", "--tests"]), - ToolCheck(name = "gen1_to_gen2/convert", argv <- ["@EXE:gen1_to_gen2@", "-v2", "utils/mcp/tests/_fixture_gen1.das"], - want <- ["options gen2", "struct Point \{"]), // --- lint / format over the shipped daslib (the tree is at zero, and stays so) ----- ToolCheck(name = "lint.exe/help", argv <- ["@EXE:lint@", "--help"], want <- ["Unified lint checker for daslang files."]), ToolCheck(name = "lint.exe/daslib", argv <- ["@EXE:lint@", "daslib"], From d3e6fe50be275c8dfa6f590dfb56ca812fa44fc5 Mon Sep 17 00:00:00 2001 From: Churkin Aleksey Date: Tue, 25 Aug 2026 14:41:14 +0300 Subject: [PATCH 2/3] ast: parse_file, and the v1 block spans a source rewriter reads `parse_file` parses a file and everything it requires and stops there - no infer, no optimization, no simulate. The tree still mirrors the source one-to-one, which is what a source-rewriting tool needs: infer lowers make-syntax, resolves generics, folds constants and inserts generated nodes, none of which map back to a source span, and it rejects a file that does not type-check - which a converter still has to be able to read. Two v1 span fixes, both about where an indent block ends. It ran one column past the end of every line it closed on, because the dedent took the newline token's END. And a block closed by end of file in a file whose last line carries no newline ended at the line BEFORE its last statement, because `last_token_end` is maintained by the newline rule, which never runs for that line. The blocks and the `with` a class-method body is wrapped in are not in the source; they are flagged generated so a span consumer skips them rather than reporting the method name as a block. Co-Authored-By: Claude Opus 5 (1M context) --- doc/reflections/das2rst.das | 2 +- ...tion-ast-parse_file-0xd74487207cfe31a0.rst | 7 + include/daScript/ast/ast.h | 7 + src/ast/ast_generate.cpp | 2 + src/ast/ast_parse.cpp | 85 ++- src/builtin/module_builtin_ast.cpp | 33 + src/parser/ds2_parser.cpp | 128 ++-- src/parser/ds2_parser.ypp | 2 + src/parser/ds_lexer.cpp | 617 +++++++++--------- src/parser/ds_lexer.lpp | 19 +- src/parser/ds_parser.cpp | 124 ++-- src/parser/ds_parser.ypp | 2 + src/parser/lex.yy.h | 8 +- src/parser/parser_impl.cpp | 1 + tests/ast/_fixture_parse_file_gen1.das | 13 + tests/ast/test_lineinfo_ranges.das | 70 ++ tests/ast/test_parse_file.das | 180 +++++ 17 files changed, 864 insertions(+), 436 deletions(-) create mode 100644 doc/source/stdlib/handmade/function-ast-parse_file-0xd74487207cfe31a0.rst create mode 100644 tests/ast/_fixture_parse_file_gen1.das create mode 100644 tests/ast/test_parse_file.das diff --git a/doc/reflections/das2rst.das b/doc/reflections/das2rst.das index e57aa5bf89..e5be9f185f 100644 --- a/doc/reflections/das2rst.das +++ b/doc/reflections/das2rst.das @@ -448,7 +448,7 @@ def document_module_rtti(_root : string) { def document_module_ast(_root : string) { var mod = [get_module("ast_core"), find_module("ast")] var groups <- array( - group_by_regex("Compilation and file access", mod, %regex~(compile|compile_file|make_file_access)$%%), + group_by_regex("Compilation and file access", mod, %regex~(compile|compile_file|parse_file|make_file_access)$%%), group_by_regex("Call generation", mod, %regex~(make_call)$%%), group_by_regex("Visitor pattern", mod, %regex~visit.*%%), group_by_regex("Expression generation", mod, %regex~(force_generated|get_expression_annotation|make_type_info_structure|stamp_missing_at)%%), diff --git a/doc/source/stdlib/handmade/function-ast-parse_file-0xd74487207cfe31a0.rst b/doc/source/stdlib/handmade/function-ast-parse_file-0xd74487207cfe31a0.rst new file mode 100644 index 0000000000..1427d8193f --- /dev/null +++ b/doc/source/stdlib/handmade/function-ast-parse_file-0xd74487207cfe31a0.rst @@ -0,0 +1,7 @@ +Parses a daslang file and stops there — no type inference, no optimization, no simulation. The block receives ``(ok, program, issues)`` for the duration of the call, exactly like ``compile_file``. + +The resulting AST mirrors the source one-to-one: make-syntax is not lowered, generics are not resolved, constants are not folded and no generated nodes are inserted. That is what source-rewriting tools need — a node's ``at`` still points at the construct the author wrote. A file that does not type-check still yields a usable tree, since nothing past the parse runs. + +Modules the file requires are loaded normally (parsed and inferred), so ``require`` resolves; only the named file itself stops at the parse. Set ``codeOfPolicies.version_2_syntax`` to false to parse v1 syntax. + +The tree is owned by the program and dies with it: keep only plain data (positions, strings) past the block, never an ``ExpressionPtr``. diff --git a/include/daScript/ast/ast.h b/include/daScript/ast/ast.h index de4b5f1f72..d253573d0f 100644 --- a/include/daScript/ast/ast.h +++ b/include/daScript/ast/ast.h @@ -1705,6 +1705,13 @@ namespace das DAS_CC_API ProgramPtr parseDaScript ( const string & fileName, const string & moduleName, const FileAccessPtr & access, TextWriter & logs, ModuleGroup & libGroup, bool exportAll = false, bool isDep = false, CodeOfPolicies policies = CodeOfPolicies() ); + DAS_CC_API ProgramPtr parseDaScriptNoInfer ( const string & fileName, const string & moduleName, + const FileAccessPtr & access, TextWriter & logs, ModuleGroup & libGroup, bool exportAll = false, + bool isDep = false, CodeOfPolicies policies = CodeOfPolicies() ); + + DAS_CC_API ProgramPtr parseDaScriptWithPrerequisits ( const string & fileName, const FileAccessPtr & access, + TextWriter & logs, ModuleGroup & libGroup, CodeOfPolicies policies = CodeOfPolicies() ); + // this one collectes dependencies and compiles with modules DAS_CC_API ProgramPtr compileDaScript ( const string & fileName, const FileAccessPtr & access, TextWriter & logs, ModuleGroup & libGroup, CodeOfPolicies policies = CodeOfPolicies() ); diff --git a/src/ast/ast_generate.cpp b/src/ast/ast_generate.cpp index 6b97e72cc5..26446a7565 100644 --- a/src/ast/ast_generate.cpp +++ b/src/ast/ast_generate.cpp @@ -2170,8 +2170,10 @@ namespace das { auto bodyAt = func->body ? func->body->at : func->at; auto block = new ExprBlock(); block->at = bodyAt; + block->generated = true; auto wth = new ExprWith(); wth->at = bodyAt; + wth->generated = true; auto wvar = new ExprVar(func->at,"self"); wvar->generated = true; wth->with = wvar; diff --git a/src/ast/ast_parse.cpp b/src/ast/ast_parse.cpp index ad503a804d..75cc60d689 100644 --- a/src/ast/ast_parse.cpp +++ b/src/ast/ast_parse.cpp @@ -915,14 +915,15 @@ namespace das { exit(1); } - ProgramPtr parseDaScript ( const string & fileName, + static ProgramPtr parseDaScriptEx ( const string & fileName, const string & moduleName, const FileAccessPtr & access, TextWriter & logs, ModuleGroup & libGroup, bool exportAll, bool isDep, - CodeOfPolicies policies ) { + CodeOfPolicies policies, + bool inferAfterParse ) { verifyCodeOfPoliciesStamp(policies); CompilationCallbackGuard compilationCallbackGuard(moduleName, fileName); ProgramPtr program = make_smart(); @@ -1052,6 +1053,13 @@ namespace das { program->deduplicateErrors(); program->isCompiling = false; return program; + } else if ( !inferAfterParse ) { + daScriptEnvironment::getBound()->g_Program.reset(); + daScriptEnvironment::getBound()->g_compilerLog = nullptr; + daScriptEnvironment::getBound()->g_compilingFileName = nullptr; + daScriptEnvironment::getBound()->g_compilingModuleName = nullptr; + program->isCompiling = false; + return program; } else { if ( program->options.getBoolOption("force_inscope_pod", policies.force_inscope_pod) ) { program->thisModule->allowPodInscope = access->isPodInScopeAllowed(program->thisModule->name, fileName); @@ -1246,6 +1254,18 @@ namespace das { } } + ProgramPtr parseDaScript ( const string & fileName, const string & moduleName, + const FileAccessPtr & access, TextWriter & logs, ModuleGroup & libGroup, + bool exportAll, bool isDep, CodeOfPolicies policies ) { + return parseDaScriptEx(fileName, moduleName, access, logs, libGroup, exportAll, isDep, policies, true); + } + + ProgramPtr parseDaScriptNoInfer ( const string & fileName, const string & moduleName, + const FileAccessPtr & access, TextWriter & logs, ModuleGroup & libGroup, + bool exportAll, bool isDep, CodeOfPolicies policies ) { + return parseDaScriptEx(fileName, moduleName, access, logs, libGroup, exportAll, isDep, policies, false); + } + bool addExtraDependency( string modName, string modFile, @@ -1606,6 +1626,67 @@ namespace das { logs << "module dependency graph:\n" << tw.str(); } + ProgramPtr parseDaScriptWithPrerequisits ( const string & fileName, + const FileAccessPtr & access, + TextWriter & logs, + ModuleGroup & libGroup, + CodeOfPolicies policies ) { + verifyCodeOfPoliciesStamp(policies); + ReuseCacheGuard rcg; + vector req; + vector missing; + vector circular, notAllowed; + vector chain; + das_set dependencies; + das_hash_map namelessReq; + vector namelessMismatches; + string modName; + if ( !addExtraDependency("builtin", get_builtin_path(), missing, circular, notAllowed, req, + dependencies, namelessReq, namelessMismatches, access, libGroup, policies, &logs) ) { + auto res = make_smart(); + res->error("internal error: failed to build builtin.das", logs.str(), "", LineInfo(), + CompilationError::internal_module); + return res; + } + for ( const auto & em : access->getExtraModules() ) { + addExtraDependency(em.first, em.second, missing, circular, notAllowed, req, dependencies, + namelessReq, namelessMismatches, access, libGroup, policies, &logs); + } + if ( !getPrerequisits(fileName, access, modName, req, missing, circular, notAllowed, chain, + dependencies, namelessReq, namelessMismatches, libGroup, nullptr, 1, !policies.ignore_shared_modules) ) { + req.clear(); + missing.clear(); + circular.clear(); + notAllowed.clear(); + dependencies.clear(); + namelessReq.clear(); + namelessMismatches.clear(); + return reportPrerequisitesErrors(fileName, missing, circular, notAllowed, + req, dependencies, namelessReq, namelessMismatches, access, libGroup, policies); + } + if ( !verifyModuleNamesUnique(req, logs) ) { + auto res = make_smart(); + res->error("Several modules with invalid names", logs.str(), "", LineInfo(), + CompilationError::already_declared_module); + return res; + } + for ( auto & mod : req ) { + if ( libGroup.findModule(mod.moduleName) ) continue; + auto depProgram = parseDaScript(mod.fileName, mod.moduleName, access, logs, libGroup, true, true, policies); + if ( !depProgram ) continue; + policies.threadlock_context |= depProgram->options.getBoolOption("threadlock_context", false); + if ( depProgram->failed() ) return depProgram; + if ( depProgram->thisModule->name.empty() ) { + depProgram->library.renameModule(depProgram->thisModule.get(), mod.moduleName); + depProgram->thisModule->wasParsedNameless = true; + } + depProgram->thisModule->fileName = mod.fileName; + depProgram->thisModule->fromExtraDependency = mod.extraDepModule; + addNewModules(libGroup, depProgram); + } + return parseDaScriptNoInfer(fileName, modName, access, logs, libGroup, policies.export_all, false, policies); + } + ProgramPtr compileDaScript ( const string & fileName, const FileAccessPtr & access, TextWriter & logs, diff --git a/src/builtin/module_builtin_ast.cpp b/src/builtin/module_builtin_ast.cpp index 33be9db689..27d4c97ef9 100644 --- a/src/builtin/module_builtin_ast.cpp +++ b/src/builtin/module_builtin_ast.cpp @@ -1255,6 +1255,36 @@ namespace das { } } +#if !DAS_NO_FILEIO + void rtti_builtin_parse_file ( char * fileName, smart_ptr access, ModuleGroup* module_group, const CodeOfPolicies & cop, + const TBlock,const string> & block, Context * context, LineInfoArg * at ) { + TextWriter issues; + if ( !access ) access = make_smart(); + auto program = parseDaScriptWithPrerequisits(fileName, access, issues, *module_group, cop); + if ( program ) { + for ( auto & err : program->errors ) { + issues << reportError(err.at, err.what, err.extra, err.fixme, err.cerr); + } + string istr = issues.str(); + vec4f args[3] = { + cast::from(!program->failed()), + cast>::from(program), + cast::from(&istr) + }; + daScriptEnvironment::getBound()->g_Program = program; + context->invoke(block, args, nullptr, at); + daScriptEnvironment::getBound()->g_Program.reset(); + } else { + context->throw_error_at(at, "rtti_parse_file internal error, something went wrong"); + } + } +#else + void rtti_builtin_parse_file ( char *, smart_ptr, ModuleGroup*, const CodeOfPolicies &, + const TBlock, const string> &, Context * context, LineInfoArg * at ) { + context->throw_error_at(at, "not supported with DAS_NO_FILEIO"); + } +#endif + #if !DAS_NO_FILEIO void rtti_builtin_compile_file ( char * modName, smart_ptr access, ModuleGroup* module_group, const CodeOfPolicies & cop, const TBlock,const string> & block, Context * context, LineInfoArg * at ) { @@ -1335,6 +1365,9 @@ namespace das { addExtern(*this, lib, "compile_file", SideEffects::modifyExternal, "rtti_builtin_compile_file") ->args({"module_name","fileAccess","moduleGroup","codeOfPolicies","block","context","line"}); + addExtern(*this, lib, "parse_file", + SideEffects::modifyExternal, "rtti_builtin_parse_file") + ->args({"file_name","fileAccess","moduleGroup","codeOfPolicies","block","context","line"}); addExtern(*this, lib, "this_program", SideEffects::accessExternal, "thisProgram") ->arg("context"); diff --git a/src/parser/ds2_parser.cpp b/src/parser/ds2_parser.cpp index 70b8788c8f..0216c72780 100644 --- a/src/parser/ds2_parser.cpp +++ b/src/parser/ds2_parser.cpp @@ -1163,69 +1163,69 @@ static const yytype_int16 yyrline[] = 1853, 1861, 1867, 1868, 1869, 1873, 1874, 1878, 1879, 1883, 1888, 1896, 1903, 1916, 1920, 1923, 1933, 1933, 1933, 1936, 1936, 1936, 1941, 1941, 1941, 1949, 1949, 1949, 1955, 1965, - 1976, 1991, 1994, 1997, 2000, 2006, 2007, 2014, 2025, 2026, - 2027, 2031, 2032, 2033, 2034, 2035, 2039, 2044, 2052, 2053, - 2057, 2064, 2068, 2075, 2076, 2077, 2078, 2079, 2080, 2081, - 2082, 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094, - 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, - 2105, 2106, 2110, 2116, 2123, 2135, 2141, 2149, 2157, 2168, - 2180, 2184, 2191, 2194, 2194, 2194, 2199, 2199, 2199, 2213, - 2217, 2221, 2225, 2231, 2239, 2245, 2253, 2261, 2272, 2281, - 2287, 2295, 2295, 2295, 2302, 2306, 2315, 2323, 2331, 2335, - 2338, 2346, 2347, 2348, 2355, 2356, 2357, 2358, 2359, 2360, - 2361, 2362, 2363, 2364, 2365, 2366, 2367, 2368, 2369, 2370, - 2371, 2372, 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, - 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, - 2396, 2397, 2398, 2399, 2400, 2415, 2424, 2425, 2426, 2427, - 2428, 2429, 2430, 2431, 2432, 2433, 2434, 2435, 2436, 2437, - 2438, 2438, 2438, 2446, 2447, 2448, 2453, 2456, 2456, 2456, - 2459, 2464, 2468, 2468, 2468, 2473, 2480, 2486, 2490, 2490, - 2490, 2495, 2498, 2504, 2504, 2504, 2511, 2516, 2520, 2520, - 2520, 2525, 2528, 2534, 2534, 2534, 2541, 2546, 2547, 2548, - 2549, 2550, 2551, 2552, 2553, 2554, 2556, 2560, 2561, 2566, - 2572, 2578, 2587, 2590, 2593, 2602, 2603, 2604, 2605, 2606, - 2607, 2608, 2612, 2616, 2620, 2624, 2628, 2632, 2636, 2640, - 2644, 2649, 2653, 2658, 2662, 2667, 2674, 2675, 2679, 2680, - 2681, 2685, 2686, 2690, 2691, 2692, 2696, 2697, 2701, 2713, - 2716, 2717, 2721, 2721, 2740, 2739, 2754, 2753, 2770, 2782, - 2791, 2801, 2802, 2803, 2804, 2805, 2809, 2812, 2821, 2822, - 2826, 2829, 2833, 2846, 2855, 2856, 2860, 2863, 2867, 2880, - 2881, 2885, 2891, 2897, 2906, 2909, 2916, 2919, 2925, 2926, - 2927, 2931, 2932, 2936, 2943, 2948, 2957, 2963, 2967, 2978, - 2985, 2994, 2997, 3000, 3007, 3011, 3017, 3029, 3032, 3037, - 3049, 3050, 3054, 3055, 3056, 3060, 3063, 3066, 3066, 3086, - 3089, 3089, 3107, 3112, 3120, 3121, 3125, 3128, 3141, 3158, - 3159, 3160, 3165, 3165, 3191, 3192, 3199, 3212, 3213, 3214, - 3218, 3228, 3231, 3237, 3238, 3242, 3243, 3247, 3248, 3252, - 3254, 3259, 3252, 3275, 3276, 3280, 3281, 3285, 3291, 3292, - 3293, 3294, 3298, 3299, 3300, 3304, 3307, 3313, 3315, 3320, - 3313, 3341, 3348, 3353, 3362, 3368, 3372, 3383, 3384, 3385, - 3386, 3387, 3388, 3389, 3390, 3391, 3392, 3393, 3394, 3395, - 3396, 3397, 3398, 3399, 3400, 3401, 3402, 3403, 3404, 3405, - 3406, 3407, 3408, 3409, 3410, 3411, 3412, 3413, 3414, 3415, - 3416, 3417, 3418, 3419, 3420, 3421, 3422, 3423, 3424, 3425, - 3426, 3427, 3428, 3429, 3430, 3431, 3432, 3436, 3437, 3438, - 3439, 3440, 3441, 3442, 3443, 3447, 3458, 3462, 3469, 3481, - 3488, 3494, 3503, 3508, 3518, 3528, 3538, 3551, 3552, 3553, - 3554, 3555, 3559, 3563, 3563, 3563, 3577, 3578, 3582, 3587, - 3594, 3597, 3600, 3603, 3609, 3612, 3626, 3627, 3631, 3632, - 3633, 3634, 3635, 3635, 3635, 3639, 3644, 3651, 3658, 3658, - 3665, 3665, 3672, 3676, 3680, 3685, 3690, 3695, 3700, 3704, - 3708, 3713, 3717, 3721, 3726, 3726, 3726, 3732, 3739, 3739, - 3739, 3744, 3744, 3744, 3750, 3750, 3750, 3755, 3761, 3761, - 3761, 3766, 3766, 3766, 3775, 3781, 3781, 3781, 3786, 3786, - 3786, 3795, 3801, 3801, 3801, 3806, 3806, 3806, 3815, 3815, - 3815, 3821, 3821, 3821, 3830, 3833, 3844, 3860, 3862, 3867, - 3872, 3860, 3898, 3900, 3905, 3911, 3898, 3937, 3939, 3944, - 3949, 3937, 3990, 3991, 3992, 3993, 3994, 3995, 3996, 4000, - 4001, 4002, 4003, 4004, 4008, 4015, 4022, 4028, 4034, 4041, - 4048, 4054, 4063, 4066, 4072, 4080, 4085, 4092, 4097, 4103, - 4104, 4108, 4109, 4113, 4113, 4113, 4121, 4121, 4121, 4128, - 4128, 4128, 4139, 4139, 4139, 4146, 4146, 4146, 4157, 4163, - 4163, 4163, 4177, 4198, 4198, 4198, 4208, 4208, 4208, 4222, - 4222, 4222, 4236, 4245, 4245, 4245, 4266, 4273, 4273, 4273, - 4283, 4286, 4297, 4303, 4326, 4334, 4356, 4382, 4383, 4387, - 4388, 4393, 4396, 4406 + 1976, 1991, 1994, 1997, 2000, 2006, 2007, 2015, 2027, 2028, + 2029, 2033, 2034, 2035, 2036, 2037, 2041, 2046, 2054, 2055, + 2059, 2066, 2070, 2077, 2078, 2079, 2080, 2081, 2082, 2083, + 2084, 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, + 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106, + 2107, 2108, 2112, 2118, 2125, 2137, 2143, 2151, 2159, 2170, + 2182, 2186, 2193, 2196, 2196, 2196, 2201, 2201, 2201, 2215, + 2219, 2223, 2227, 2233, 2241, 2247, 2255, 2263, 2274, 2283, + 2289, 2297, 2297, 2297, 2304, 2308, 2317, 2325, 2333, 2337, + 2340, 2348, 2349, 2350, 2357, 2358, 2359, 2360, 2361, 2362, + 2363, 2364, 2365, 2366, 2367, 2368, 2369, 2370, 2371, 2372, + 2373, 2374, 2375, 2376, 2377, 2378, 2379, 2380, 2381, 2382, + 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, + 2398, 2399, 2400, 2401, 2402, 2417, 2426, 2427, 2428, 2429, + 2430, 2431, 2432, 2433, 2434, 2435, 2436, 2437, 2438, 2439, + 2440, 2440, 2440, 2448, 2449, 2450, 2455, 2458, 2458, 2458, + 2461, 2466, 2470, 2470, 2470, 2475, 2482, 2488, 2492, 2492, + 2492, 2497, 2500, 2506, 2506, 2506, 2513, 2518, 2522, 2522, + 2522, 2527, 2530, 2536, 2536, 2536, 2543, 2548, 2549, 2550, + 2551, 2552, 2553, 2554, 2555, 2556, 2558, 2562, 2563, 2568, + 2574, 2580, 2589, 2592, 2595, 2604, 2605, 2606, 2607, 2608, + 2609, 2610, 2614, 2618, 2622, 2626, 2630, 2634, 2638, 2642, + 2646, 2651, 2655, 2660, 2664, 2669, 2676, 2677, 2681, 2682, + 2683, 2687, 2688, 2692, 2693, 2694, 2698, 2699, 2703, 2715, + 2718, 2719, 2723, 2723, 2742, 2741, 2756, 2755, 2772, 2784, + 2793, 2803, 2804, 2805, 2806, 2807, 2811, 2814, 2823, 2824, + 2828, 2831, 2835, 2848, 2857, 2858, 2862, 2865, 2869, 2882, + 2883, 2887, 2893, 2899, 2908, 2911, 2918, 2921, 2927, 2928, + 2929, 2933, 2934, 2938, 2945, 2950, 2959, 2965, 2969, 2980, + 2987, 2996, 2999, 3002, 3009, 3013, 3019, 3031, 3034, 3039, + 3051, 3052, 3056, 3057, 3058, 3062, 3065, 3068, 3068, 3088, + 3091, 3091, 3109, 3114, 3122, 3123, 3127, 3130, 3143, 3160, + 3161, 3162, 3167, 3167, 3193, 3194, 3201, 3214, 3215, 3216, + 3220, 3230, 3233, 3239, 3240, 3244, 3245, 3249, 3250, 3254, + 3256, 3261, 3254, 3277, 3278, 3282, 3283, 3287, 3293, 3294, + 3295, 3296, 3300, 3301, 3302, 3306, 3309, 3315, 3317, 3322, + 3315, 3343, 3350, 3355, 3364, 3370, 3374, 3385, 3386, 3387, + 3388, 3389, 3390, 3391, 3392, 3393, 3394, 3395, 3396, 3397, + 3398, 3399, 3400, 3401, 3402, 3403, 3404, 3405, 3406, 3407, + 3408, 3409, 3410, 3411, 3412, 3413, 3414, 3415, 3416, 3417, + 3418, 3419, 3420, 3421, 3422, 3423, 3424, 3425, 3426, 3427, + 3428, 3429, 3430, 3431, 3432, 3433, 3434, 3438, 3439, 3440, + 3441, 3442, 3443, 3444, 3445, 3449, 3460, 3464, 3471, 3483, + 3490, 3496, 3505, 3510, 3520, 3530, 3540, 3553, 3554, 3555, + 3556, 3557, 3561, 3565, 3565, 3565, 3579, 3580, 3584, 3589, + 3596, 3599, 3602, 3605, 3611, 3614, 3628, 3629, 3633, 3634, + 3635, 3636, 3637, 3637, 3637, 3641, 3646, 3653, 3660, 3660, + 3667, 3667, 3674, 3678, 3682, 3687, 3692, 3697, 3702, 3706, + 3710, 3715, 3719, 3723, 3728, 3728, 3728, 3734, 3741, 3741, + 3741, 3746, 3746, 3746, 3752, 3752, 3752, 3757, 3763, 3763, + 3763, 3768, 3768, 3768, 3777, 3783, 3783, 3783, 3788, 3788, + 3788, 3797, 3803, 3803, 3803, 3808, 3808, 3808, 3817, 3817, + 3817, 3823, 3823, 3823, 3832, 3835, 3846, 3862, 3864, 3869, + 3874, 3862, 3900, 3902, 3907, 3913, 3900, 3939, 3941, 3946, + 3951, 3939, 3992, 3993, 3994, 3995, 3996, 3997, 3998, 4002, + 4003, 4004, 4005, 4006, 4010, 4017, 4024, 4030, 4036, 4043, + 4050, 4056, 4065, 4068, 4074, 4082, 4087, 4094, 4099, 4105, + 4106, 4110, 4111, 4115, 4115, 4115, 4123, 4123, 4123, 4130, + 4130, 4130, 4141, 4141, 4141, 4148, 4148, 4148, 4159, 4165, + 4165, 4165, 4179, 4200, 4200, 4200, 4210, 4210, 4210, 4224, + 4224, 4224, 4238, 4247, 4247, 4247, 4268, 4275, 4275, 4275, + 4285, 4288, 4299, 4305, 4328, 4336, 4358, 4384, 4385, 4389, + 4390, 4395, 4398, 4408 }; #endif @@ -8545,6 +8545,7 @@ YYLTYPE yylloc = yyloc_default; auto retE = new ExprReturn(tokAt(scanner,(yylsp[-1])), (yyvsp[0].pExpression)); auto blkE = new ExprBlock(); blkE->at = tokAt(scanner,(yylsp[-1])); + blkE->generated = true; blkE->list.push_back(retE); (yyval.pExpression) = blkE; } @@ -8556,6 +8557,7 @@ YYLTYPE yylloc = yyloc_default; retE->moveSemantics = true; auto blkE = new ExprBlock(); blkE->at = tokAt(scanner,(yylsp[-2])); + blkE->generated = true; blkE->list.push_back(retE); (yyval.pExpression) = blkE; } diff --git a/src/parser/ds2_parser.ypp b/src/parser/ds2_parser.ypp index c366543cca..3d9f8783a5 100644 --- a/src/parser/ds2_parser.ypp +++ b/src/parser/ds2_parser.ypp @@ -2008,6 +2008,7 @@ block_or_simple_block auto retE = new ExprReturn(tokAt(scanner,@loc), $subexpr); auto blkE = new ExprBlock(); blkE->at = tokAt(scanner,@loc); + blkE->generated = true; blkE->list.push_back(retE); $$ = blkE; } @@ -2016,6 +2017,7 @@ block_or_simple_block retE->moveSemantics = true; auto blkE = new ExprBlock(); blkE->at = tokAt(scanner,@loc); + blkE->generated = true; blkE->list.push_back(retE); $$ = blkE; } diff --git a/src/parser/ds_lexer.cpp b/src/parser/ds_lexer.cpp index 191eaed546..b34c2b7838 100644 --- a/src/parser/ds_lexer.cpp +++ b/src/parser/ds_lexer.cpp @@ -1,6 +1,6 @@ -#line 1 "ds_lexer.cpp" +#line 2 "ds_lexer.cpp" -#line 3 "ds_lexer.cpp" +#line 4 "ds_lexer.cpp" #define YY_INT_ALIGNED short int @@ -1353,11 +1353,11 @@ void das_accept_cpp_comment ( vector & crdi, yyscan_t scanner, #define YY_EXTRA_TYPE das::DasParserState * -#line 1356 "ds_lexer.cpp" +#line 1357 "ds_lexer.cpp" #define YY_NO_UNISTD_H 1 /* %option debug */ -#line 1360 "ds_lexer.cpp" +#line 1361 "ds_lexer.cpp" #define INITIAL 0 #define indent 1 @@ -1642,7 +1642,7 @@ YY_DECL #line 77 "ds_lexer.lpp" -#line 1645 "ds_lexer.cpp" +#line 1646 "ds_lexer.cpp" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1785,6 +1785,8 @@ YY_RULE_SETUP #line 127 "ds_lexer.lpp" { yyextra->last_token_end = tokAt(yyscanner,*yylloc_param); + yyextra->last_token_end.last_line = yyextra->last_token_end.line; + yyextra->last_token_end.last_column = yyextra->last_token_end.column; BEGIN(cpp_comment); if ( !yyextra->g_CommentReaders.empty() ) { auto tak = tokAt(yyscanner,*yylloc_param); @@ -1795,7 +1797,7 @@ YY_RULE_SETUP case 8: /* rule 8 can match eol */ YY_RULE_SETUP -#line 135 "ds_lexer.lpp" +#line 137 "ds_lexer.lpp" { BEGIN(normal); unput('\n'); @@ -1806,12 +1808,12 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(cpp_comment): -#line 143 "ds_lexer.lpp" +#line 145 "ds_lexer.lpp" BEGIN(normal); YY_BREAK case 9: YY_RULE_SETUP -#line 144 "ds_lexer.lpp" +#line 146 "ds_lexer.lpp" { if ( !yyextra->g_CommentReaders.empty() ) { auto tak = tokAt(yyscanner,*yylloc_param); @@ -1821,14 +1823,14 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 150 "ds_lexer.lpp" +#line 152 "ds_lexer.lpp" { yyextra->das_c_style_depth ++; } YY_BREAK case 11: YY_RULE_SETUP -#line 153 "ds_lexer.lpp" +#line 155 "ds_lexer.lpp" { yyextra->das_c_style_depth --; if ( yyextra->das_c_style_depth==0 ) { @@ -1846,7 +1848,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 167 "ds_lexer.lpp" +#line 169 "ds_lexer.lpp" { /* skipping comment body */ if ( !yyextra->g_CommentReaders.empty() ) { auto tak = tokAt(yyscanner,*yylloc_param); @@ -1857,7 +1859,7 @@ YY_RULE_SETUP case 13: /* rule 13 can match eol */ YY_RULE_SETUP -#line 173 "ds_lexer.lpp" +#line 175 "ds_lexer.lpp" { /* skipping comment eol */ YYNEWLINE(yyscanner); if ( !yyextra->g_CommentReaders.empty() ) { @@ -1867,14 +1869,14 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(c_comment): -#line 180 "ds_lexer.lpp" +#line 182 "ds_lexer.lpp" { das_yyfatalerror(yylloc_param,yyscanner,"end of file encountered inside c-style comment", CompilationError::exceeds_file); BEGIN(normal); } YY_BREAK case YY_STATE_EOF(reader): -#line 184 "ds_lexer.lpp" +#line 186 "ds_lexer.lpp" { das_yyfatalerror(yylloc_param,yyscanner,"reader constant exceeds file", CompilationError::exceeds_file); BEGIN(normal); @@ -1884,7 +1886,7 @@ case YY_STATE_EOF(reader): case 14: /* rule 14 can match eol */ YY_RULE_SETUP -#line 189 "ds_lexer.lpp" +#line 191 "ds_lexer.lpp" { YYNEWLINE(yyscanner); yylval_param->ch = yytext[0]; @@ -1893,7 +1895,7 @@ YY_RULE_SETUP YY_BREAK case 15: YY_RULE_SETUP -#line 194 "ds_lexer.lpp" +#line 196 "ds_lexer.lpp" { yylval_param->ch = yytext[0]; return STRING_CHARACTER; @@ -1901,7 +1903,7 @@ YY_RULE_SETUP YY_BREAK case 16: YY_RULE_SETUP -#line 198 "ds_lexer.lpp" +#line 200 "ds_lexer.lpp" { // assert(nested_sb==0); BEGIN(normal); @@ -1910,7 +1912,7 @@ YY_RULE_SETUP YY_BREAK case 17: YY_RULE_SETUP -#line 203 "ds_lexer.lpp" +#line 205 "ds_lexer.lpp" { if ( yyextra->das_nested_sb ) { das_yyfatalerror(yylloc_param,yyscanner,"nested string constants are not allowed", CompilationError::invalid_string); @@ -1923,7 +1925,7 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(strb): -#line 213 "ds_lexer.lpp" +#line 215 "ds_lexer.lpp" { das_yyfatalerror(yylloc_param,yyscanner,"string constant exceeds file", CompilationError::exceeds_file); BEGIN(normal); @@ -1932,14 +1934,14 @@ case YY_STATE_EOF(strb): YY_BREAK case 18: YY_RULE_SETUP -#line 218 "ds_lexer.lpp" +#line 220 "ds_lexer.lpp" { return STRING_CHARACTER_ESC; } YY_BREAK case 19: YY_RULE_SETUP -#line 221 "ds_lexer.lpp" +#line 223 "ds_lexer.lpp" { yylval_param->ch = yytext[1]; return STRING_CHARACTER; @@ -1947,13 +1949,13 @@ YY_RULE_SETUP YY_BREAK case 20: YY_RULE_SETUP -#line 225 "ds_lexer.lpp" +#line 227 "ds_lexer.lpp" /* do exactly nothing */ YY_BREAK case 21: /* rule 21 can match eol */ YY_RULE_SETUP -#line 226 "ds_lexer.lpp" +#line 228 "ds_lexer.lpp" { yylval_param->ch = *yytext; YYNEWLINE(yyscanner); @@ -1962,7 +1964,7 @@ YY_RULE_SETUP YY_BREAK case 22: YY_RULE_SETUP -#line 231 "ds_lexer.lpp" +#line 233 "ds_lexer.lpp" { YYTAB(); yylval_param->ch = *yytext; @@ -1971,14 +1973,14 @@ YY_RULE_SETUP YY_BREAK case 23: YY_RULE_SETUP -#line 236 "ds_lexer.lpp" +#line 238 "ds_lexer.lpp" { yylval_param->ch = *yytext; return STRING_CHARACTER; } YY_BREAK case YY_STATE_EOF(strfmt): -#line 240 "ds_lexer.lpp" +#line 242 "ds_lexer.lpp" { das_yyfatalerror(yylloc_param,yyscanner,"string format exceeds file", CompilationError::exceeds_file); BEGIN(normal); @@ -1988,7 +1990,7 @@ case YY_STATE_EOF(strfmt): case 24: /* rule 24 can match eol */ YY_RULE_SETUP -#line 245 "ds_lexer.lpp" +#line 247 "ds_lexer.lpp" { yylval_param->ch = *yytext; YYNEWLINE(yyscanner); @@ -1997,7 +1999,7 @@ YY_RULE_SETUP YY_BREAK case 25: YY_RULE_SETUP -#line 250 "ds_lexer.lpp" +#line 252 "ds_lexer.lpp" { yylval_param->ch = *yytext; return STRING_CHARACTER; @@ -2005,7 +2007,7 @@ YY_RULE_SETUP YY_BREAK case 26: YY_RULE_SETUP -#line 254 "ds_lexer.lpp" +#line 256 "ds_lexer.lpp" { BEGIN(normal); unput('}'); @@ -2016,7 +2018,7 @@ YY_RULE_SETUP YY_BREAK case 27: YY_RULE_SETUP -#line 261 "ds_lexer.lpp" +#line 263 "ds_lexer.lpp" { yylval_param->ch = *yytext; return STRING_CHARACTER; @@ -2025,7 +2027,7 @@ YY_RULE_SETUP case 28: /* rule 28 can match eol */ YY_RULE_SETUP -#line 265 "ds_lexer.lpp" +#line 267 "ds_lexer.lpp" /* skip empty line */ { yyextra->das_current_line_indent = 0; YYNEWLINE(yyscanner); @@ -2033,7 +2035,7 @@ YY_RULE_SETUP YY_BREAK case 29: YY_RULE_SETUP -#line 269 "ds_lexer.lpp" +#line 271 "ds_lexer.lpp" { yyextra->das_current_line_indent++; #ifdef FLEX_DEBUG @@ -2043,7 +2045,7 @@ YY_RULE_SETUP YY_BREAK case 30: YY_RULE_SETUP -#line 275 "ds_lexer.lpp" +#line 277 "ds_lexer.lpp" { yyextra->das_current_line_indent = (yyextra->das_current_line_indent + yyextra->das_tab_size) & ~(yyextra->das_tab_size-1); #ifdef FLEX_DEBUG @@ -2055,7 +2057,7 @@ YY_RULE_SETUP case 31: /* rule 31 can match eol */ YY_RULE_SETUP -#line 282 "ds_lexer.lpp" +#line 284 "ds_lexer.lpp" { yyextra->das_current_line_indent = 0; yyextra->das_need_oxford_comma = true; @@ -2068,7 +2070,7 @@ YY_RULE_SETUP YY_BREAK case 32: YY_RULE_SETUP -#line 291 "ds_lexer.lpp" +#line 293 "ds_lexer.lpp" { unput(*yytext); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT"); @@ -2116,7 +2118,7 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(indent): -#line 336 "ds_lexer.lpp" +#line 338 "ds_lexer.lpp" { if ( yyextra->g_FileAccessStack.size()==1 ) { if ( yyextra->das_indent_level ) { @@ -2125,8 +2127,10 @@ case YY_STATE_EOF(indent): #ifdef FLEX_DEBUG printf("emit }\n"); #endif - yylloc_param->first_line = yylloc_param->last_line; - yylloc_param->first_column = yylloc_param->last_column; + yylloc_param->first_line = yyextra->last_token_end.last_line; + yylloc_param->first_column = yyextra->last_token_end.last_column; + yylloc_param->last_line = yyextra->last_token_end.last_line; + yylloc_param->last_column = yyextra->last_token_end.last_column; return CLOSE_BRACE; } else { return 0; @@ -2141,19 +2145,19 @@ case YY_STATE_EOF(indent): YY_BREAK case 33: YY_RULE_SETUP -#line 358 "ds_lexer.lpp" +#line 362 "ds_lexer.lpp" /* eat the whitespace */ YY_BREAK case 34: YY_RULE_SETUP -#line 359 "ds_lexer.lpp" +#line 363 "ds_lexer.lpp" { YYTAB(); } YY_BREAK case 35: YY_RULE_SETUP -#line 362 "ds_lexer.lpp" +#line 366 "ds_lexer.lpp" { /* got the include file name */ auto cfi = yyextra->g_FileAccessStack.back(); string incFileName = yyextra->g_Access->getIncludeFileName(cfi->name,yytext); @@ -2179,78 +2183,78 @@ YY_RULE_SETUP YY_BREAK case 36: YY_RULE_SETUP -#line 385 "ds_lexer.lpp" +#line 389 "ds_lexer.lpp" BEGIN(include); YY_BREAK case 37: YY_RULE_SETUP -#line 386 "ds_lexer.lpp" +#line 390 "ds_lexer.lpp" return DAS_CAPTURE; YY_BREAK case 38: YY_RULE_SETUP -#line 387 "ds_lexer.lpp" +#line 391 "ds_lexer.lpp" /* yyextra->das_need_oxford_comma = false; */ return DAS_FOR; YY_BREAK case 39: YY_RULE_SETUP -#line 388 "ds_lexer.lpp" +#line 392 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_WHILE; YY_BREAK case 40: YY_RULE_SETUP -#line 389 "ds_lexer.lpp" +#line 393 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_IF; YY_BREAK case 41: YY_RULE_SETUP -#line 390 "ds_lexer.lpp" +#line 394 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_STATIC_IF; YY_BREAK case 42: YY_RULE_SETUP -#line 391 "ds_lexer.lpp" +#line 395 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_ELIF; YY_BREAK case 43: YY_RULE_SETUP -#line 392 "ds_lexer.lpp" +#line 396 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_STATIC_ELIF; YY_BREAK case 44: YY_RULE_SETUP -#line 393 "ds_lexer.lpp" +#line 397 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_ELSE; YY_BREAK case 45: YY_RULE_SETUP -#line 394 "ds_lexer.lpp" +#line 398 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_FINALLY; YY_BREAK case 46: YY_RULE_SETUP -#line 395 "ds_lexer.lpp" +#line 399 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_DEF; YY_BREAK case 47: YY_RULE_SETUP -#line 396 "ds_lexer.lpp" +#line 400 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_WITH; YY_BREAK case 48: YY_RULE_SETUP -#line 397 "ds_lexer.lpp" +#line 401 "ds_lexer.lpp" return DAS_AKA; YY_BREAK case 49: YY_RULE_SETUP -#line 398 "ds_lexer.lpp" +#line 402 "ds_lexer.lpp" return DAS_ASSUME; YY_BREAK case 50: /* rule 50 can match eol */ YY_RULE_SETUP -#line 399 "ds_lexer.lpp" +#line 403 "ds_lexer.lpp" { yyextra->das_need_oxford_comma = false; unput('\n'); @@ -2260,13 +2264,13 @@ YY_RULE_SETUP YY_BREAK case 51: YY_RULE_SETUP -#line 405 "ds_lexer.lpp" +#line 409 "ds_lexer.lpp" return DAS_LET; YY_BREAK case 52: /* rule 52 can match eol */ YY_RULE_SETUP -#line 406 "ds_lexer.lpp" +#line 410 "ds_lexer.lpp" { yyextra->das_need_oxford_comma = false; unput('\n'); @@ -2276,232 +2280,232 @@ YY_RULE_SETUP YY_BREAK case 53: YY_RULE_SETUP -#line 412 "ds_lexer.lpp" +#line 416 "ds_lexer.lpp" return DAS_VAR; YY_BREAK case 54: YY_RULE_SETUP -#line 413 "ds_lexer.lpp" +#line 417 "ds_lexer.lpp" return DAS_UNINITIALIZED; YY_BREAK case 55: YY_RULE_SETUP -#line 414 "ds_lexer.lpp" +#line 418 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_STRUCT; YY_BREAK case 56: YY_RULE_SETUP -#line 415 "ds_lexer.lpp" +#line 419 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_CLASS; YY_BREAK case 57: YY_RULE_SETUP -#line 416 "ds_lexer.lpp" +#line 420 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_ENUM; YY_BREAK case 58: YY_RULE_SETUP -#line 417 "ds_lexer.lpp" +#line 421 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_TRY; YY_BREAK case 59: YY_RULE_SETUP -#line 418 "ds_lexer.lpp" +#line 422 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_CATCH; YY_BREAK case 60: YY_RULE_SETUP -#line 419 "ds_lexer.lpp" +#line 423 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_TYPEDEF; YY_BREAK case 61: YY_RULE_SETUP -#line 420 "ds_lexer.lpp" +#line 424 "ds_lexer.lpp" return DAS_TYPEDECL; YY_BREAK case 62: YY_RULE_SETUP -#line 421 "ds_lexer.lpp" +#line 425 "ds_lexer.lpp" return DAS_LABEL; YY_BREAK case 63: YY_RULE_SETUP -#line 422 "ds_lexer.lpp" +#line 426 "ds_lexer.lpp" return DAS_GOTO; YY_BREAK case 64: YY_RULE_SETUP -#line 423 "ds_lexer.lpp" +#line 427 "ds_lexer.lpp" return DAS_MODULE; YY_BREAK case 65: YY_RULE_SETUP -#line 424 "ds_lexer.lpp" +#line 428 "ds_lexer.lpp" return DAS_PUBLIC; YY_BREAK case 66: YY_RULE_SETUP -#line 425 "ds_lexer.lpp" +#line 429 "ds_lexer.lpp" return DAS_OPTIONS; YY_BREAK case 67: YY_RULE_SETUP -#line 426 "ds_lexer.lpp" +#line 430 "ds_lexer.lpp" return DAS_OPERATOR; YY_BREAK case 68: YY_RULE_SETUP -#line 427 "ds_lexer.lpp" +#line 431 "ds_lexer.lpp" return DAS_REQUIRE; YY_BREAK case 69: YY_RULE_SETUP -#line 428 "ds_lexer.lpp" +#line 432 "ds_lexer.lpp" return DAS_TBLOCK; YY_BREAK case 70: YY_RULE_SETUP -#line 429 "ds_lexer.lpp" +#line 433 "ds_lexer.lpp" return DAS_TFUNCTION; YY_BREAK case 71: YY_RULE_SETUP -#line 430 "ds_lexer.lpp" +#line 434 "ds_lexer.lpp" return DAS_TLAMBDA; YY_BREAK case 72: YY_RULE_SETUP -#line 431 "ds_lexer.lpp" +#line 435 "ds_lexer.lpp" return DAS_GENERATOR; YY_BREAK case 73: YY_RULE_SETUP -#line 432 "ds_lexer.lpp" +#line 436 "ds_lexer.lpp" return DAS_TTUPLE; YY_BREAK case 74: YY_RULE_SETUP -#line 433 "ds_lexer.lpp" +#line 437 "ds_lexer.lpp" return DAS_TVARIANT; YY_BREAK case 75: YY_RULE_SETUP -#line 434 "ds_lexer.lpp" +#line 438 "ds_lexer.lpp" return DAS_CONST; YY_BREAK case 76: YY_RULE_SETUP -#line 435 "ds_lexer.lpp" +#line 439 "ds_lexer.lpp" return DAS_CONTINUE; YY_BREAK case 77: YY_RULE_SETUP -#line 436 "ds_lexer.lpp" +#line 440 "ds_lexer.lpp" return DAS_WHERE; YY_BREAK case 78: YY_RULE_SETUP -#line 437 "ds_lexer.lpp" +#line 441 "ds_lexer.lpp" return DAS_CAST; YY_BREAK case 79: YY_RULE_SETUP -#line 438 "ds_lexer.lpp" +#line 442 "ds_lexer.lpp" return DAS_UPCAST; YY_BREAK case 80: YY_RULE_SETUP -#line 439 "ds_lexer.lpp" +#line 443 "ds_lexer.lpp" return DAS_PASS; YY_BREAK case 81: YY_RULE_SETUP -#line 440 "ds_lexer.lpp" +#line 444 "ds_lexer.lpp" return DAS_REINTERPRET; YY_BREAK case 82: YY_RULE_SETUP -#line 441 "ds_lexer.lpp" +#line 445 "ds_lexer.lpp" return DAS_OVERRIDE; YY_BREAK case 83: YY_RULE_SETUP -#line 442 "ds_lexer.lpp" +#line 446 "ds_lexer.lpp" return DAS_SEALED; YY_BREAK case 84: YY_RULE_SETUP -#line 443 "ds_lexer.lpp" +#line 447 "ds_lexer.lpp" return DAS_TEMPLATE; YY_BREAK case 85: YY_RULE_SETUP -#line 444 "ds_lexer.lpp" +#line 448 "ds_lexer.lpp" return DAS_ABSTRACT; YY_BREAK case 86: YY_RULE_SETUP -#line 445 "ds_lexer.lpp" +#line 449 "ds_lexer.lpp" return DAS_EXPECT; YY_BREAK case 87: YY_RULE_SETUP -#line 446 "ds_lexer.lpp" +#line 450 "ds_lexer.lpp" return DAS_TABLE; YY_BREAK case 88: YY_RULE_SETUP -#line 447 "ds_lexer.lpp" +#line 451 "ds_lexer.lpp" return DAS_ARRAY; YY_BREAK case 89: YY_RULE_SETUP -#line 448 "ds_lexer.lpp" +#line 452 "ds_lexer.lpp" return DAS_FIXED_ARRAY; YY_BREAK case 90: YY_RULE_SETUP -#line 449 "ds_lexer.lpp" +#line 453 "ds_lexer.lpp" return DAS_DEFAULT; YY_BREAK case 91: YY_RULE_SETUP -#line 450 "ds_lexer.lpp" +#line 454 "ds_lexer.lpp" return DAS_ITERATOR; YY_BREAK case 92: YY_RULE_SETUP -#line 451 "ds_lexer.lpp" +#line 455 "ds_lexer.lpp" return DAS_IN; YY_BREAK case 93: YY_RULE_SETUP -#line 452 "ds_lexer.lpp" +#line 456 "ds_lexer.lpp" return DAS_IMPLICIT; YY_BREAK case 94: YY_RULE_SETUP -#line 453 "ds_lexer.lpp" +#line 457 "ds_lexer.lpp" return DAS_EXPLICIT; YY_BREAK case 95: YY_RULE_SETUP -#line 454 "ds_lexer.lpp" +#line 458 "ds_lexer.lpp" return DAS_SHARED; YY_BREAK case 96: YY_RULE_SETUP -#line 455 "ds_lexer.lpp" +#line 459 "ds_lexer.lpp" return DAS_PRIVATE; YY_BREAK case 97: YY_RULE_SETUP -#line 456 "ds_lexer.lpp" +#line 460 "ds_lexer.lpp" return DAS_SMART_PTR; YY_BREAK case 98: YY_RULE_SETUP -#line 457 "ds_lexer.lpp" +#line 461 "ds_lexer.lpp" { unput('('); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT ("); @@ -2510,347 +2514,347 @@ YY_RULE_SETUP YY_BREAK case 99: YY_RULE_SETUP -#line 462 "ds_lexer.lpp" +#line 466 "ds_lexer.lpp" yyextra->das_need_oxford_comma = false; return DAS_UNSAFE; YY_BREAK case 100: YY_RULE_SETUP -#line 463 "ds_lexer.lpp" +#line 467 "ds_lexer.lpp" return DAS_INSCOPE; YY_BREAK case 101: YY_RULE_SETUP -#line 464 "ds_lexer.lpp" +#line 468 "ds_lexer.lpp" return DAS_STATIC; YY_BREAK case 102: YY_RULE_SETUP -#line 465 "ds_lexer.lpp" +#line 469 "ds_lexer.lpp" return DAS_AS; YY_BREAK case 103: YY_RULE_SETUP -#line 466 "ds_lexer.lpp" +#line 470 "ds_lexer.lpp" return DAS_IS; YY_BREAK case 104: YY_RULE_SETUP -#line 467 "ds_lexer.lpp" +#line 471 "ds_lexer.lpp" return DAS_DEREF; YY_BREAK case 105: YY_RULE_SETUP -#line 468 "ds_lexer.lpp" +#line 472 "ds_lexer.lpp" return DAS_ADDR; YY_BREAK case 106: YY_RULE_SETUP -#line 469 "ds_lexer.lpp" +#line 473 "ds_lexer.lpp" return DAS_NULL; YY_BREAK case 107: YY_RULE_SETUP -#line 470 "ds_lexer.lpp" +#line 474 "ds_lexer.lpp" return DAS_RETURN; YY_BREAK case 108: YY_RULE_SETUP -#line 471 "ds_lexer.lpp" +#line 475 "ds_lexer.lpp" return DAS_YIELD; YY_BREAK case 109: YY_RULE_SETUP -#line 472 "ds_lexer.lpp" +#line 476 "ds_lexer.lpp" return DAS_BREAK; YY_BREAK case 110: YY_RULE_SETUP -#line 473 "ds_lexer.lpp" +#line 477 "ds_lexer.lpp" return DAS_TYPEINFO; YY_BREAK case 111: YY_RULE_SETUP -#line 474 "ds_lexer.lpp" +#line 478 "ds_lexer.lpp" return DAS_TYPE; YY_BREAK case 112: YY_RULE_SETUP -#line 475 "ds_lexer.lpp" +#line 479 "ds_lexer.lpp" return DAS_NEWT; YY_BREAK case 113: YY_RULE_SETUP -#line 476 "ds_lexer.lpp" +#line 480 "ds_lexer.lpp" return DAS_DELETE; YY_BREAK case 114: YY_RULE_SETUP -#line 477 "ds_lexer.lpp" +#line 481 "ds_lexer.lpp" return DAS_TRUE; YY_BREAK case 115: YY_RULE_SETUP -#line 478 "ds_lexer.lpp" +#line 482 "ds_lexer.lpp" return DAS_FALSE; YY_BREAK case 116: YY_RULE_SETUP -#line 479 "ds_lexer.lpp" +#line 483 "ds_lexer.lpp" return DAS_TAUTO; YY_BREAK case 117: YY_RULE_SETUP -#line 480 "ds_lexer.lpp" +#line 484 "ds_lexer.lpp" return DAS_TBOOL; YY_BREAK case 118: YY_RULE_SETUP -#line 481 "ds_lexer.lpp" +#line 485 "ds_lexer.lpp" return DAS_TVOID; YY_BREAK case 119: YY_RULE_SETUP -#line 482 "ds_lexer.lpp" +#line 486 "ds_lexer.lpp" return DAS_TSTRING; YY_BREAK case 120: YY_RULE_SETUP -#line 483 "ds_lexer.lpp" +#line 487 "ds_lexer.lpp" return DAS_TRANGE64; YY_BREAK case 121: YY_RULE_SETUP -#line 484 "ds_lexer.lpp" +#line 488 "ds_lexer.lpp" return DAS_TURANGE64; YY_BREAK case 122: YY_RULE_SETUP -#line 485 "ds_lexer.lpp" +#line 489 "ds_lexer.lpp" return DAS_TRANGE; YY_BREAK case 123: YY_RULE_SETUP -#line 486 "ds_lexer.lpp" +#line 490 "ds_lexer.lpp" return DAS_TURANGE; YY_BREAK case 124: YY_RULE_SETUP -#line 487 "ds_lexer.lpp" +#line 491 "ds_lexer.lpp" return DAS_TINT; YY_BREAK case 125: YY_RULE_SETUP -#line 488 "ds_lexer.lpp" +#line 492 "ds_lexer.lpp" return DAS_TINT8; YY_BREAK case 126: YY_RULE_SETUP -#line 489 "ds_lexer.lpp" +#line 493 "ds_lexer.lpp" return DAS_TINT16; YY_BREAK case 127: YY_RULE_SETUP -#line 490 "ds_lexer.lpp" +#line 494 "ds_lexer.lpp" return DAS_TINT64; YY_BREAK case 128: YY_RULE_SETUP -#line 491 "ds_lexer.lpp" +#line 495 "ds_lexer.lpp" return DAS_TINT2; YY_BREAK case 129: YY_RULE_SETUP -#line 492 "ds_lexer.lpp" +#line 496 "ds_lexer.lpp" return DAS_TINT3; YY_BREAK case 130: YY_RULE_SETUP -#line 493 "ds_lexer.lpp" +#line 497 "ds_lexer.lpp" return DAS_TINT4; YY_BREAK case 131: YY_RULE_SETUP -#line 494 "ds_lexer.lpp" +#line 498 "ds_lexer.lpp" return DAS_TUINT; YY_BREAK case 132: YY_RULE_SETUP -#line 495 "ds_lexer.lpp" +#line 499 "ds_lexer.lpp" return DAS_TBITFIELD; YY_BREAK case 133: YY_RULE_SETUP -#line 496 "ds_lexer.lpp" +#line 500 "ds_lexer.lpp" return DAS_TUINT8; YY_BREAK case 134: YY_RULE_SETUP -#line 497 "ds_lexer.lpp" +#line 501 "ds_lexer.lpp" return DAS_TUINT16; YY_BREAK case 135: YY_RULE_SETUP -#line 498 "ds_lexer.lpp" +#line 502 "ds_lexer.lpp" return DAS_TUINT64; YY_BREAK case 136: YY_RULE_SETUP -#line 499 "ds_lexer.lpp" +#line 503 "ds_lexer.lpp" return DAS_TUINT2; YY_BREAK case 137: YY_RULE_SETUP -#line 500 "ds_lexer.lpp" +#line 504 "ds_lexer.lpp" return DAS_TUINT3; YY_BREAK case 138: YY_RULE_SETUP -#line 501 "ds_lexer.lpp" +#line 505 "ds_lexer.lpp" return DAS_TUINT4; YY_BREAK case 139: YY_RULE_SETUP -#line 502 "ds_lexer.lpp" +#line 506 "ds_lexer.lpp" return DAS_TDOUBLE; YY_BREAK case 140: YY_RULE_SETUP -#line 503 "ds_lexer.lpp" +#line 507 "ds_lexer.lpp" return DAS_TFLOAT; YY_BREAK case 141: YY_RULE_SETUP -#line 504 "ds_lexer.lpp" +#line 508 "ds_lexer.lpp" return DAS_TFLOAT2; YY_BREAK case 142: YY_RULE_SETUP -#line 505 "ds_lexer.lpp" +#line 509 "ds_lexer.lpp" return DAS_TFLOAT3; YY_BREAK case 143: YY_RULE_SETUP -#line 506 "ds_lexer.lpp" +#line 510 "ds_lexer.lpp" return DAS_TFLOAT4; YY_BREAK case 144: YY_RULE_SETUP -#line 507 "ds_lexer.lpp" +#line 511 "ds_lexer.lpp" return DAS_TFLOAT16; YY_BREAK case 145: YY_RULE_SETUP -#line 508 "ds_lexer.lpp" +#line 512 "ds_lexer.lpp" return DAS_THALF2; YY_BREAK case 146: YY_RULE_SETUP -#line 509 "ds_lexer.lpp" +#line 513 "ds_lexer.lpp" return DAS_THALF3; YY_BREAK case 147: YY_RULE_SETUP -#line 510 "ds_lexer.lpp" +#line 514 "ds_lexer.lpp" return DAS_THALF4; YY_BREAK case 148: YY_RULE_SETUP -#line 511 "ds_lexer.lpp" +#line 515 "ds_lexer.lpp" return DAS_THALF8; YY_BREAK case 149: YY_RULE_SETUP -#line 512 "ds_lexer.lpp" +#line 516 "ds_lexer.lpp" return DAS_TSHORT2; YY_BREAK case 150: YY_RULE_SETUP -#line 513 "ds_lexer.lpp" +#line 517 "ds_lexer.lpp" return DAS_TSHORT3; YY_BREAK case 151: YY_RULE_SETUP -#line 514 "ds_lexer.lpp" +#line 518 "ds_lexer.lpp" return DAS_TSHORT4; YY_BREAK case 152: YY_RULE_SETUP -#line 515 "ds_lexer.lpp" +#line 519 "ds_lexer.lpp" return DAS_TSHORT8; YY_BREAK case 153: YY_RULE_SETUP -#line 516 "ds_lexer.lpp" +#line 520 "ds_lexer.lpp" return DAS_TUSHORT2; YY_BREAK case 154: YY_RULE_SETUP -#line 517 "ds_lexer.lpp" +#line 521 "ds_lexer.lpp" return DAS_TUSHORT3; YY_BREAK case 155: YY_RULE_SETUP -#line 518 "ds_lexer.lpp" +#line 522 "ds_lexer.lpp" return DAS_TUSHORT4; YY_BREAK case 156: YY_RULE_SETUP -#line 519 "ds_lexer.lpp" +#line 523 "ds_lexer.lpp" return DAS_TUSHORT8; YY_BREAK case 157: YY_RULE_SETUP -#line 520 "ds_lexer.lpp" +#line 524 "ds_lexer.lpp" return DAS_TBYTE2; YY_BREAK case 158: YY_RULE_SETUP -#line 521 "ds_lexer.lpp" +#line 525 "ds_lexer.lpp" return DAS_TBYTE3; YY_BREAK case 159: YY_RULE_SETUP -#line 522 "ds_lexer.lpp" +#line 526 "ds_lexer.lpp" return DAS_TBYTE4; YY_BREAK case 160: YY_RULE_SETUP -#line 523 "ds_lexer.lpp" +#line 527 "ds_lexer.lpp" return DAS_TBYTE8; YY_BREAK case 161: YY_RULE_SETUP -#line 524 "ds_lexer.lpp" +#line 528 "ds_lexer.lpp" return DAS_TBYTE16; YY_BREAK case 162: YY_RULE_SETUP -#line 525 "ds_lexer.lpp" +#line 529 "ds_lexer.lpp" return DAS_TUBYTE2; YY_BREAK case 163: YY_RULE_SETUP -#line 526 "ds_lexer.lpp" +#line 530 "ds_lexer.lpp" return DAS_TUBYTE3; YY_BREAK case 164: YY_RULE_SETUP -#line 527 "ds_lexer.lpp" +#line 531 "ds_lexer.lpp" return DAS_TUBYTE4; YY_BREAK case 165: YY_RULE_SETUP -#line 528 "ds_lexer.lpp" +#line 532 "ds_lexer.lpp" return DAS_TUBYTE8; YY_BREAK case 166: YY_RULE_SETUP -#line 529 "ds_lexer.lpp" +#line 533 "ds_lexer.lpp" return DAS_TUBYTE16; YY_BREAK case 167: YY_RULE_SETUP -#line 530 "ds_lexer.lpp" +#line 534 "ds_lexer.lpp" { auto it = yyextra->das_keywords.find(yytext); if ( it != yyextra->das_keywords.end() ) { @@ -2866,7 +2870,7 @@ YY_RULE_SETUP YY_BREAK case 168: YY_RULE_SETUP -#line 542 "ds_lexer.lpp" +#line 546 "ds_lexer.lpp" { BEGIN(strb); return BEGIN_STRING; @@ -2874,127 +2878,127 @@ YY_RULE_SETUP YY_BREAK case 169: YY_RULE_SETUP -#line 546 "ds_lexer.lpp" +#line 550 "ds_lexer.lpp" yylval_param->ui = 8; return UNSIGNED_INT8; YY_BREAK case 170: YY_RULE_SETUP -#line 547 "ds_lexer.lpp" +#line 551 "ds_lexer.lpp" yylval_param->ui = 9; return UNSIGNED_INT8; YY_BREAK case 171: YY_RULE_SETUP -#line 548 "ds_lexer.lpp" +#line 552 "ds_lexer.lpp" yylval_param->ui = 10; return UNSIGNED_INT8; YY_BREAK case 172: YY_RULE_SETUP -#line 549 "ds_lexer.lpp" +#line 553 "ds_lexer.lpp" yylval_param->ui = 12; return UNSIGNED_INT8; YY_BREAK case 173: YY_RULE_SETUP -#line 550 "ds_lexer.lpp" +#line 554 "ds_lexer.lpp" yylval_param->ui = 13; return UNSIGNED_INT8; YY_BREAK case 174: YY_RULE_SETUP -#line 551 "ds_lexer.lpp" +#line 555 "ds_lexer.lpp" yylval_param->ui = '\\'; return UNSIGNED_INT8; YY_BREAK case 175: YY_RULE_SETUP -#line 552 "ds_lexer.lpp" +#line 556 "ds_lexer.lpp" yylval_param->ui = '\''; return UNSIGNED_INT8; YY_BREAK case 176: YY_RULE_SETUP -#line 553 "ds_lexer.lpp" +#line 557 "ds_lexer.lpp" yylval_param->ui = uint32_t(yytext[1]); return UNSIGNED_INT8; YY_BREAK case 177: YY_RULE_SETUP -#line 555 "ds_lexer.lpp" +#line 559 "ds_lexer.lpp" yylval_param->ui = 8; return UNSIGNED_INTEGER; YY_BREAK case 178: YY_RULE_SETUP -#line 556 "ds_lexer.lpp" +#line 560 "ds_lexer.lpp" yylval_param->ui = 9; return UNSIGNED_INTEGER; YY_BREAK case 179: YY_RULE_SETUP -#line 557 "ds_lexer.lpp" +#line 561 "ds_lexer.lpp" yylval_param->ui = 10; return UNSIGNED_INTEGER; YY_BREAK case 180: YY_RULE_SETUP -#line 558 "ds_lexer.lpp" +#line 562 "ds_lexer.lpp" yylval_param->ui = 12; return UNSIGNED_INTEGER; YY_BREAK case 181: YY_RULE_SETUP -#line 559 "ds_lexer.lpp" +#line 563 "ds_lexer.lpp" yylval_param->ui = 13; return UNSIGNED_INTEGER; YY_BREAK case 182: YY_RULE_SETUP -#line 560 "ds_lexer.lpp" +#line 564 "ds_lexer.lpp" yylval_param->ui = '\\'; return UNSIGNED_INTEGER; YY_BREAK case 183: YY_RULE_SETUP -#line 561 "ds_lexer.lpp" +#line 565 "ds_lexer.lpp" yylval_param->ui = '\''; return UNSIGNED_INTEGER; YY_BREAK case 184: YY_RULE_SETUP -#line 562 "ds_lexer.lpp" +#line 566 "ds_lexer.lpp" yylval_param->ui = uint32_t(yytext[1]); return UNSIGNED_INTEGER; YY_BREAK case 185: YY_RULE_SETUP -#line 564 "ds_lexer.lpp" +#line 568 "ds_lexer.lpp" yylval_param->i = 8; return INTEGER; YY_BREAK case 186: YY_RULE_SETUP -#line 565 "ds_lexer.lpp" +#line 569 "ds_lexer.lpp" yylval_param->i = 9; return INTEGER; YY_BREAK case 187: YY_RULE_SETUP -#line 566 "ds_lexer.lpp" +#line 570 "ds_lexer.lpp" yylval_param->i = 10; return INTEGER; YY_BREAK case 188: YY_RULE_SETUP -#line 567 "ds_lexer.lpp" +#line 571 "ds_lexer.lpp" yylval_param->i = 12; return INTEGER; YY_BREAK case 189: YY_RULE_SETUP -#line 568 "ds_lexer.lpp" +#line 572 "ds_lexer.lpp" yylval_param->i = 13; return INTEGER; YY_BREAK case 190: YY_RULE_SETUP -#line 569 "ds_lexer.lpp" +#line 573 "ds_lexer.lpp" yylval_param->i = '\\'; return INTEGER; YY_BREAK case 191: YY_RULE_SETUP -#line 570 "ds_lexer.lpp" +#line 574 "ds_lexer.lpp" yylval_param->i = '\''; return INTEGER; YY_BREAK case 192: YY_RULE_SETUP -#line 572 "ds_lexer.lpp" +#line 576 "ds_lexer.lpp" yylval_param->i = int32_t(yytext[1]); return INTEGER; YY_BREAK case 193: YY_RULE_SETUP -#line 573 "ds_lexer.lpp" +#line 577 "ds_lexer.lpp" { char temptext[128]; int templength = skip_underscode(yytext,temptext,temptext+sizeof(temptext)); @@ -3009,7 +3013,7 @@ YY_RULE_SETUP YY_BREAK case 194: YY_RULE_SETUP -#line 584 "ds_lexer.lpp" +#line 588 "ds_lexer.lpp" { char temptext[128]; int templength = skip_underscode(yytext,temptext,temptext+sizeof(temptext)); @@ -3024,7 +3028,7 @@ YY_RULE_SETUP YY_BREAK case 195: YY_RULE_SETUP -#line 595 "ds_lexer.lpp" +#line 599 "ds_lexer.lpp" { char temptext[128]; int templength = skip_underscode(yytext,temptext,temptext+sizeof(temptext)); @@ -3041,7 +3045,7 @@ YY_RULE_SETUP YY_BREAK case 196: YY_RULE_SETUP -#line 608 "ds_lexer.lpp" +#line 612 "ds_lexer.lpp" { char temptext[128]; int templength = skip_underscode(yytext,temptext,temptext+sizeof(temptext)); @@ -3056,7 +3060,7 @@ YY_RULE_SETUP YY_BREAK case 197: YY_RULE_SETUP -#line 619 "ds_lexer.lpp" +#line 623 "ds_lexer.lpp" { char temptext[128]; int templength = skip_underscode(yytext,temptext,temptext+sizeof(temptext)); @@ -3075,7 +3079,7 @@ YY_RULE_SETUP YY_BREAK case 198: YY_RULE_SETUP -#line 634 "ds_lexer.lpp" +#line 638 "ds_lexer.lpp" { char temptext[128]; int templength = skip_underscode(yytext,temptext,temptext+sizeof(temptext)); @@ -3090,7 +3094,7 @@ YY_RULE_SETUP YY_BREAK case 199: YY_RULE_SETUP -#line 645 "ds_lexer.lpp" +#line 649 "ds_lexer.lpp" { char temptext[128]; skip_underscode(yytext,temptext,temptext+sizeof(temptext)); @@ -3105,7 +3109,7 @@ YY_RULE_SETUP YY_BREAK case 200: YY_RULE_SETUP -#line 656 "ds_lexer.lpp" +#line 660 "ds_lexer.lpp" { char temptext[128]; skip_underscode(yytext,temptext,temptext+sizeof(temptext)); @@ -3120,7 +3124,7 @@ YY_RULE_SETUP YY_BREAK case 201: YY_RULE_SETUP -#line 667 "ds_lexer.lpp" +#line 671 "ds_lexer.lpp" { char temptext[128]; int templength = skip_underscode(yytext,temptext,temptext+sizeof(temptext)); @@ -3147,7 +3151,7 @@ YY_RULE_SETUP YY_BREAK case 202: YY_RULE_SETUP -#line 690 "ds_lexer.lpp" +#line 694 "ds_lexer.lpp" { char temptext[128]; skip_underscode(yytext,temptext,temptext+sizeof(temptext)); @@ -3162,7 +3166,7 @@ YY_RULE_SETUP YY_BREAK case 203: YY_RULE_SETUP -#line 701 "ds_lexer.lpp" +#line 705 "ds_lexer.lpp" { auto res = fast_float::from_chars(yytext, yytext+strlen(yytext), yylval_param->fd); if ( res.ec == std::errc::result_out_of_range ) { @@ -3175,7 +3179,7 @@ YY_RULE_SETUP YY_BREAK case 204: YY_RULE_SETUP -#line 710 "ds_lexer.lpp" +#line 714 "ds_lexer.lpp" { auto res = fast_float::from_chars(yytext, yytext+strlen(yytext), yylval_param->fd); if ( res.ec == std::errc::result_out_of_range ) { @@ -3189,7 +3193,7 @@ YY_RULE_SETUP YY_BREAK case 205: YY_RULE_SETUP -#line 720 "ds_lexer.lpp" +#line 724 "ds_lexer.lpp" { auto res = fast_float::from_chars(yytext, yytext+strlen(yytext), yylval_param->fd); if ( res.ec == std::errc::result_out_of_range ) { @@ -3202,7 +3206,7 @@ YY_RULE_SETUP YY_BREAK case 206: YY_RULE_SETUP -#line 729 "ds_lexer.lpp" +#line 733 "ds_lexer.lpp" { auto res = fast_float::from_chars(yytext, yytext+strlen(yytext), yylval_param->fd); if ( res.ec == std::errc::result_out_of_range ) { @@ -3215,7 +3219,7 @@ YY_RULE_SETUP YY_BREAK case 207: YY_RULE_SETUP -#line 738 "ds_lexer.lpp" +#line 742 "ds_lexer.lpp" { auto res = fast_float::from_chars(yytext, yytext+strlen(yytext), yylval_param->d); if ( res.ec == std::errc::result_out_of_range ) { @@ -3228,7 +3232,7 @@ YY_RULE_SETUP YY_BREAK case 208: YY_RULE_SETUP -#line 747 "ds_lexer.lpp" +#line 751 "ds_lexer.lpp" { auto res = fast_float::from_chars(yytext, yytext+strlen(yytext), yylval_param->d); if ( res.ec == std::errc::result_out_of_range ) { @@ -3241,7 +3245,7 @@ YY_RULE_SETUP YY_BREAK case 209: YY_RULE_SETUP -#line 756 "ds_lexer.lpp" +#line 760 "ds_lexer.lpp" { auto res = fast_float::from_chars(yytext, yytext+strlen(yytext), yylval_param->d); if ( res.ec == std::errc::result_out_of_range ) { @@ -3254,7 +3258,7 @@ YY_RULE_SETUP YY_BREAK case 210: YY_RULE_SETUP -#line 765 "ds_lexer.lpp" +#line 769 "ds_lexer.lpp" { auto res = fast_float::from_chars(yytext, yytext+strlen(yytext), yylval_param->d); if ( res.ec == std::errc::result_out_of_range ) { @@ -3267,7 +3271,7 @@ YY_RULE_SETUP YY_BREAK case 211: YY_RULE_SETUP -#line 774 "ds_lexer.lpp" +#line 778 "ds_lexer.lpp" { auto res = fast_float::from_chars(yytext, yytext+strlen(yytext), yylval_param->fd); if ( res.ec == std::errc::result_out_of_range ) { @@ -3280,7 +3284,7 @@ YY_RULE_SETUP YY_BREAK case 212: YY_RULE_SETUP -#line 783 "ds_lexer.lpp" +#line 787 "ds_lexer.lpp" { auto res = fast_float::from_chars(yytext, yytext+strlen(yytext), yylval_param->fd); if ( res.ec == std::errc::result_out_of_range ) { @@ -3293,7 +3297,7 @@ YY_RULE_SETUP YY_BREAK case 213: YY_RULE_SETUP -#line 792 "ds_lexer.lpp" +#line 796 "ds_lexer.lpp" { auto res = fast_float::from_chars(yytext, yytext+strlen(yytext), yylval_param->fd); if ( res.ec == std::errc::result_out_of_range ) { @@ -3306,7 +3310,7 @@ YY_RULE_SETUP YY_BREAK case 214: YY_RULE_SETUP -#line 801 "ds_lexer.lpp" +#line 805 "ds_lexer.lpp" { auto res = fast_float::from_chars(yytext, yytext+strlen(yytext), yylval_param->fd); if ( res.ec == std::errc::result_out_of_range ) { @@ -3319,7 +3323,7 @@ YY_RULE_SETUP YY_BREAK case 215: YY_RULE_SETUP -#line 810 "ds_lexer.lpp" +#line 814 "ds_lexer.lpp" { if ( !yyextra->das_nested_parentheses ) { das_yyfatalerror(yylloc_param,yyscanner,"mismatching parentheses", CompilationError::mismatching_parens); @@ -3331,7 +3335,7 @@ YY_RULE_SETUP YY_BREAK case 216: YY_RULE_SETUP -#line 818 "ds_lexer.lpp" +#line 822 "ds_lexer.lpp" { yyextra->das_nested_parentheses ++; return '('; @@ -3339,7 +3343,7 @@ YY_RULE_SETUP YY_BREAK case 217: YY_RULE_SETUP -#line 822 "ds_lexer.lpp" +#line 826 "ds_lexer.lpp" { if ( !yyextra->das_nested_square_braces ) { das_yyfatalerror(yylloc_param,yyscanner,"mismatching square braces", CompilationError::mismatching_parens); @@ -3351,7 +3355,7 @@ YY_RULE_SETUP YY_BREAK case 218: YY_RULE_SETUP -#line 830 "ds_lexer.lpp" +#line 834 "ds_lexer.lpp" { yyextra->das_nested_square_braces ++; return '['; @@ -3359,7 +3363,7 @@ YY_RULE_SETUP YY_BREAK case 219: YY_RULE_SETUP -#line 834 "ds_lexer.lpp" +#line 838 "ds_lexer.lpp" { if ( yyextra->das_nested_sb ) { yyextra->das_nested_sb --; @@ -3381,7 +3385,7 @@ YY_RULE_SETUP YY_BREAK case 220: YY_RULE_SETUP -#line 852 "ds_lexer.lpp" +#line 856 "ds_lexer.lpp" { if ( yyextra->das_nested_sb ) { yyextra->das_nested_sb ++; @@ -3393,28 +3397,28 @@ YY_RULE_SETUP YY_BREAK case 221: YY_RULE_SETUP -#line 860 "ds_lexer.lpp" +#line 864 "ds_lexer.lpp" return COLCOL; YY_BREAK case 222: YY_RULE_SETUP -#line 861 "ds_lexer.lpp" +#line 865 "ds_lexer.lpp" return MTAG_DOTDOTDOT; YY_BREAK case 223: YY_RULE_SETUP -#line 862 "ds_lexer.lpp" +#line 866 "ds_lexer.lpp" return DOTDOT; YY_BREAK case 224: YY_RULE_SETUP -#line 863 "ds_lexer.lpp" +#line 867 "ds_lexer.lpp" return RPIPE; YY_BREAK case 225: /* rule 225 can match eol */ YY_RULE_SETUP -#line 864 "ds_lexer.lpp" +#line 868 "ds_lexer.lpp" { yyextra->last_token_end = tokAt(yyscanner,*yylloc_param); yyextra->last_token_end.column += 2; @@ -3427,7 +3431,7 @@ YY_RULE_SETUP case 226: /* rule 226 can match eol */ YY_RULE_SETUP -#line 873 "ds_lexer.lpp" +#line 877 "ds_lexer.lpp" { yyextra->das_need_oxford_comma = false; unput('\n'); @@ -3439,7 +3443,7 @@ YY_RULE_SETUP case 227: /* rule 227 can match eol */ YY_RULE_SETUP -#line 881 "ds_lexer.lpp" +#line 885 "ds_lexer.lpp" { yyextra->das_need_oxford_comma = false; unput('\n'); @@ -3451,7 +3455,7 @@ YY_RULE_SETUP case 228: /* rule 228 can match eol */ YY_RULE_SETUP -#line 888 "ds_lexer.lpp" +#line 892 "ds_lexer.lpp" { yyextra->das_need_oxford_comma = false; unput('\n'); @@ -3461,7 +3465,7 @@ YY_RULE_SETUP YY_BREAK case 229: YY_RULE_SETUP -#line 894 "ds_lexer.lpp" +#line 898 "ds_lexer.lpp" { unput('$'); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT $"); @@ -3475,7 +3479,7 @@ YY_RULE_SETUP YY_BREAK case 230: YY_RULE_SETUP -#line 904 "ds_lexer.lpp" +#line 908 "ds_lexer.lpp" { unput('@'); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT @"); @@ -3489,7 +3493,7 @@ YY_RULE_SETUP YY_BREAK case 231: YY_RULE_SETUP -#line 914 "ds_lexer.lpp" +#line 918 "ds_lexer.lpp" { unput('@'); unput('@'); @@ -3504,7 +3508,7 @@ YY_RULE_SETUP YY_BREAK case 232: YY_RULE_SETUP -#line 925 "ds_lexer.lpp" +#line 929 "ds_lexer.lpp" { unput('@'); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT @"); @@ -3518,7 +3522,7 @@ YY_RULE_SETUP YY_BREAK case 233: YY_RULE_SETUP -#line 935 "ds_lexer.lpp" +#line 939 "ds_lexer.lpp" { unput('$'); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT $"); @@ -3532,70 +3536,70 @@ YY_RULE_SETUP YY_BREAK case 234: YY_RULE_SETUP -#line 945 "ds_lexer.lpp" +#line 949 "ds_lexer.lpp" return LPIPE; YY_BREAK case 235: YY_RULE_SETUP -#line 946 "ds_lexer.lpp" +#line 950 "ds_lexer.lpp" return MTAG_E; YY_BREAK case 236: /* rule 236 can match eol */ YY_RULE_SETUP -#line 947 "ds_lexer.lpp" +#line 951 "ds_lexer.lpp" unput(yytext[yyleng-1]); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT $"); return MTAG_E; YY_BREAK case 237: /* rule 237 can match eol */ YY_RULE_SETUP -#line 948 "ds_lexer.lpp" +#line 952 "ds_lexer.lpp" unput(yytext[yyleng-1]); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT $"); return MTAG_I; YY_BREAK case 238: /* rule 238 can match eol */ YY_RULE_SETUP -#line 949 "ds_lexer.lpp" +#line 953 "ds_lexer.lpp" unput(yytext[yyleng-1]); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT $"); return MTAG_V; YY_BREAK case 239: /* rule 239 can match eol */ YY_RULE_SETUP -#line 950 "ds_lexer.lpp" +#line 954 "ds_lexer.lpp" unput(yytext[yyleng-1]); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT $"); return MTAG_B; YY_BREAK case 240: /* rule 240 can match eol */ YY_RULE_SETUP -#line 951 "ds_lexer.lpp" +#line 955 "ds_lexer.lpp" unput(yytext[yyleng-1]); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT $"); return MTAG_A; YY_BREAK case 241: /* rule 241 can match eol */ YY_RULE_SETUP -#line 952 "ds_lexer.lpp" +#line 956 "ds_lexer.lpp" unput(yytext[yyleng-1]); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT $"); return MTAG_T; YY_BREAK case 242: /* rule 242 can match eol */ YY_RULE_SETUP -#line 953 "ds_lexer.lpp" +#line 957 "ds_lexer.lpp" unput(yytext[yyleng-1]); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT $"); return MTAG_C; YY_BREAK case 243: /* rule 243 can match eol */ YY_RULE_SETUP -#line 954 "ds_lexer.lpp" +#line 958 "ds_lexer.lpp" unput(yytext[yyleng-1]); YYCOLUMN(yyextra->das_yycolumn--, "UNPUT $"); return MTAG_F; YY_BREAK case 244: YY_RULE_SETUP -#line 955 "ds_lexer.lpp" +#line 959 "ds_lexer.lpp" return QQ; YY_BREAK case 245: YY_RULE_SETUP -#line 956 "ds_lexer.lpp" +#line 960 "ds_lexer.lpp" { yyextra->das_nested_square_braces ++; return QBRA; @@ -3603,127 +3607,127 @@ YY_RULE_SETUP YY_BREAK case 246: YY_RULE_SETUP -#line 960 "ds_lexer.lpp" +#line 964 "ds_lexer.lpp" return QDOT; YY_BREAK case 247: YY_RULE_SETUP -#line 961 "ds_lexer.lpp" +#line 965 "ds_lexer.lpp" return CLONEEQU; YY_BREAK case 248: YY_RULE_SETUP -#line 962 "ds_lexer.lpp" +#line 966 "ds_lexer.lpp" return RARROW; YY_BREAK case 249: YY_RULE_SETUP -#line 963 "ds_lexer.lpp" +#line 967 "ds_lexer.lpp" return LARROW; YY_BREAK case 250: YY_RULE_SETUP -#line 964 "ds_lexer.lpp" +#line 968 "ds_lexer.lpp" return ADDEQU; YY_BREAK case 251: YY_RULE_SETUP -#line 965 "ds_lexer.lpp" +#line 969 "ds_lexer.lpp" return SUBEQU; YY_BREAK case 252: YY_RULE_SETUP -#line 966 "ds_lexer.lpp" +#line 970 "ds_lexer.lpp" return DIVEQU; YY_BREAK case 253: YY_RULE_SETUP -#line 967 "ds_lexer.lpp" +#line 971 "ds_lexer.lpp" return MULEQU; YY_BREAK case 254: YY_RULE_SETUP -#line 968 "ds_lexer.lpp" +#line 972 "ds_lexer.lpp" return MODEQU; YY_BREAK case 255: YY_RULE_SETUP -#line 969 "ds_lexer.lpp" +#line 973 "ds_lexer.lpp" return ANDANDEQU; YY_BREAK case 256: YY_RULE_SETUP -#line 970 "ds_lexer.lpp" +#line 974 "ds_lexer.lpp" return OROREQU; YY_BREAK case 257: YY_RULE_SETUP -#line 971 "ds_lexer.lpp" +#line 975 "ds_lexer.lpp" return XORXOREQU; YY_BREAK case 258: YY_RULE_SETUP -#line 972 "ds_lexer.lpp" +#line 976 "ds_lexer.lpp" return ANDAND; YY_BREAK case 259: YY_RULE_SETUP -#line 973 "ds_lexer.lpp" +#line 977 "ds_lexer.lpp" return OROR; YY_BREAK case 260: YY_RULE_SETUP -#line 974 "ds_lexer.lpp" +#line 978 "ds_lexer.lpp" return XORXOR; YY_BREAK case 261: YY_RULE_SETUP -#line 975 "ds_lexer.lpp" +#line 979 "ds_lexer.lpp" return ANDEQU; YY_BREAK case 262: YY_RULE_SETUP -#line 976 "ds_lexer.lpp" +#line 980 "ds_lexer.lpp" return OREQU; YY_BREAK case 263: YY_RULE_SETUP -#line 977 "ds_lexer.lpp" +#line 981 "ds_lexer.lpp" return XOREQU; YY_BREAK case 264: YY_RULE_SETUP -#line 978 "ds_lexer.lpp" +#line 982 "ds_lexer.lpp" return ADDADD; YY_BREAK case 265: YY_RULE_SETUP -#line 979 "ds_lexer.lpp" +#line 983 "ds_lexer.lpp" return SUBSUB; YY_BREAK case 266: YY_RULE_SETUP -#line 980 "ds_lexer.lpp" +#line 984 "ds_lexer.lpp" return LEEQU; YY_BREAK case 267: YY_RULE_SETUP -#line 981 "ds_lexer.lpp" +#line 985 "ds_lexer.lpp" return GREQU; YY_BREAK case 268: YY_RULE_SETUP -#line 982 "ds_lexer.lpp" +#line 986 "ds_lexer.lpp" return EQUEQU; YY_BREAK case 269: YY_RULE_SETUP -#line 983 "ds_lexer.lpp" +#line 987 "ds_lexer.lpp" return NOTEQU; YY_BREAK case 270: YY_RULE_SETUP -#line 984 "ds_lexer.lpp" +#line 988 "ds_lexer.lpp" { if ( yyextra->das_arrow_depth ) { unput('>'); @@ -3737,7 +3741,7 @@ YY_RULE_SETUP YY_BREAK case 271: YY_RULE_SETUP -#line 994 "ds_lexer.lpp" +#line 998 "ds_lexer.lpp" { if ( yyextra->das_arrow_depth ) { unput('>'); @@ -3750,42 +3754,42 @@ YY_RULE_SETUP YY_BREAK case 272: YY_RULE_SETUP -#line 1003 "ds_lexer.lpp" +#line 1007 "ds_lexer.lpp" return ROTL; YY_BREAK case 273: YY_RULE_SETUP -#line 1004 "ds_lexer.lpp" +#line 1008 "ds_lexer.lpp" return SHL; YY_BREAK case 274: YY_RULE_SETUP -#line 1005 "ds_lexer.lpp" +#line 1009 "ds_lexer.lpp" return SHREQU; YY_BREAK case 275: YY_RULE_SETUP -#line 1006 "ds_lexer.lpp" +#line 1010 "ds_lexer.lpp" return SHLEQU; YY_BREAK case 276: YY_RULE_SETUP -#line 1007 "ds_lexer.lpp" +#line 1011 "ds_lexer.lpp" return ROTREQU; YY_BREAK case 277: YY_RULE_SETUP -#line 1008 "ds_lexer.lpp" +#line 1012 "ds_lexer.lpp" return ROTLEQU; YY_BREAK case 278: YY_RULE_SETUP -#line 1009 "ds_lexer.lpp" +#line 1013 "ds_lexer.lpp" return MAPTO; YY_BREAK case 279: YY_RULE_SETUP -#line 1010 "ds_lexer.lpp" +#line 1014 "ds_lexer.lpp" { if ( yyextra->das_gen2_make_syntax ) { yyextra->das_nested_square_braces ++; @@ -3800,7 +3804,7 @@ YY_RULE_SETUP YY_BREAK case 280: YY_RULE_SETUP -#line 1021 "ds_lexer.lpp" +#line 1025 "ds_lexer.lpp" { if ( yyextra->das_gen2_make_syntax ) { yyextra->das_nested_square_braces ++; @@ -3815,7 +3819,7 @@ YY_RULE_SETUP YY_BREAK case 281: YY_RULE_SETUP -#line 1032 "ds_lexer.lpp" +#line 1036 "ds_lexer.lpp" { if ( yyextra->das_gen2_make_syntax ) { yyextra->das_nested_curly_braces ++; @@ -3830,12 +3834,12 @@ YY_RULE_SETUP YY_BREAK case 282: YY_RULE_SETUP -#line 1043 "ds_lexer.lpp" +#line 1047 "ds_lexer.lpp" /* skip white space */ YY_BREAK case 283: YY_RULE_SETUP -#line 1044 "ds_lexer.lpp" +#line 1048 "ds_lexer.lpp" { YYTAB(); } @@ -3843,7 +3847,7 @@ YY_RULE_SETUP case 284: /* rule 284 can match eol */ YY_RULE_SETUP -#line 1048 "ds_lexer.lpp" +#line 1052 "ds_lexer.lpp" { if ( yyextra->das_nested_curly_braces < 2 ) { das_yyfatalerror(yylloc_param,yyscanner,"mismatching curly braces", CompilationError::mismatching_curly_bracers); @@ -3863,7 +3867,7 @@ YY_RULE_SETUP case 285: /* rule 285 can match eol */ YY_RULE_SETUP -#line 1064 "ds_lexer.lpp" +#line 1068 "ds_lexer.lpp" { if ( !yyextra->das_nested_curly_braces ) { das_yyfatalerror(yylloc_param,yyscanner,"mismatching curly braces", CompilationError::mismatching_curly_bracers); @@ -3888,7 +3892,7 @@ YY_RULE_SETUP case 286: /* rule 286 can match eol */ YY_RULE_SETUP -#line 1085 "ds_lexer.lpp" +#line 1089 "ds_lexer.lpp" { if ( !yyextra->das_nested_curly_braces ) { das_yyfatalerror(yylloc_param,yyscanner,"mismatching curly braces", CompilationError::mismatching_curly_bracers); @@ -3913,7 +3917,7 @@ YY_RULE_SETUP case 287: /* rule 287 can match eol */ YY_RULE_SETUP -#line 1106 "ds_lexer.lpp" +#line 1110 "ds_lexer.lpp" { if ( yyextra->das_nested_square_braces < 2) { das_yyfatalerror(yylloc_param,yyscanner,"mismatching square braces", CompilationError::mismatching_parens); @@ -3934,7 +3938,7 @@ YY_RULE_SETUP case 288: /* rule 288 can match eol */ YY_RULE_SETUP -#line 1123 "ds_lexer.lpp" +#line 1127 "ds_lexer.lpp" { if ( yyextra->das_nested_square_braces < 2) { das_yyfatalerror(yylloc_param,yyscanner,"mismatching square braces", CompilationError::mismatching_parens); @@ -3954,7 +3958,7 @@ YY_RULE_SETUP case 289: /* rule 289 can match eol */ YY_RULE_SETUP -#line 1139 "ds_lexer.lpp" +#line 1143 "ds_lexer.lpp" { YYCOLUMN(yyextra->das_yycolumn = 0, "NEW LINE"); } @@ -3962,10 +3966,13 @@ YY_RULE_SETUP case 290: /* rule 290 can match eol */ YY_RULE_SETUP -#line 1142 "ds_lexer.lpp" +#line 1146 "ds_lexer.lpp" { if (yyextra->last_token_end.line != tokAt(yyscanner,*yylloc_param).line) { - yyextra->last_token_end = tokAt(yyscanner,*yylloc_param); + auto lineEnd = tokAt(yyscanner,*yylloc_param); + lineEnd.last_line = lineEnd.line; + lineEnd.last_column = lineEnd.column; + yyextra->last_token_end = lineEnd; } YYCOLUMN(yyextra->das_yycolumn = 0, "NEW LINE"); das_accept_cpp_comment(yyextra->g_CommentReaders, yyscanner, *yylloc_param, yytext); @@ -3990,9 +3997,15 @@ YY_RULE_SETUP } YY_BREAK case YY_STATE_EOF(normal): -#line 1167 "ds_lexer.lpp" +#line 1174 "ds_lexer.lpp" { if ( yyextra->g_FileAccessStack.size()==1 ) { + if (yyextra->last_token_end.line != tokAt(yyscanner,*yylloc_param).line) { + auto lineEnd = tokAt(yyscanner,*yylloc_param); + lineEnd.line = lineEnd.last_line; + lineEnd.column = lineEnd.last_column; + yyextra->last_token_end = lineEnd; + } YYCOLUMN(yyextra->das_yycolumn = 0,"EOF"); if ( !yyextra->das_nested_parentheses && !yyextra->das_nested_curly_braces && !yyextra->das_nested_square_braces ) { bool ns = (yyextra->das_current_line_indent!=0) && yyextra->das_need_oxford_comma; @@ -4020,15 +4033,15 @@ case YY_STATE_EOF(normal): YY_BREAK case 291: YY_RULE_SETUP -#line 1193 "ds_lexer.lpp" +#line 1206 "ds_lexer.lpp" return *yytext; YY_BREAK case 292: YY_RULE_SETUP -#line 1195 "ds_lexer.lpp" +#line 1208 "ds_lexer.lpp" ECHO; YY_BREAK -#line 4031 "ds_lexer.cpp" +#line 4045 "ds_lexer.cpp" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(include): yyterminate(); @@ -5222,7 +5235,7 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 1195 "ds_lexer.lpp" +#line 1208 "ds_lexer.lpp" void das_strfmt ( yyscan_t yyscanner ) { diff --git a/src/parser/ds_lexer.lpp b/src/parser/ds_lexer.lpp index 2fa44060c6..004d129757 100644 --- a/src/parser/ds_lexer.lpp +++ b/src/parser/ds_lexer.lpp @@ -126,6 +126,8 @@ void das_accept_cpp_comment ( vector & crdi, yyscan_t scanner, } "\/\/" { yyextra->last_token_end = tokAt(yyscanner,*yylloc_param); + yyextra->last_token_end.last_line = yyextra->last_token_end.line; + yyextra->last_token_end.last_column = yyextra->last_token_end.column; BEGIN(cpp_comment); if ( !yyextra->g_CommentReaders.empty() ) { auto tak = tokAt(yyscanner,*yylloc_param); @@ -341,8 +343,10 @@ void das_accept_cpp_comment ( vector & crdi, yyscan_t scanner, #ifdef FLEX_DEBUG printf("emit }\n"); #endif - yylloc_param->first_line = yylloc_param->last_line; - yylloc_param->first_column = yylloc_param->last_column; + yylloc_param->first_line = yyextra->last_token_end.last_line; + yylloc_param->first_column = yyextra->last_token_end.last_column; + yylloc_param->last_line = yyextra->last_token_end.last_line; + yylloc_param->last_column = yyextra->last_token_end.last_column; return CLOSE_BRACE; } else { return 0; @@ -1141,7 +1145,10 @@ void das_accept_cpp_comment ( vector & crdi, yyscan_t scanner, } (\/\/.*)*\n { if (yyextra->last_token_end.line != tokAt(yyscanner,*yylloc_param).line) { - yyextra->last_token_end = tokAt(yyscanner,*yylloc_param); + auto lineEnd = tokAt(yyscanner,*yylloc_param); + lineEnd.last_line = lineEnd.line; + lineEnd.last_column = lineEnd.column; + yyextra->last_token_end = lineEnd; } YYCOLUMN(yyextra->das_yycolumn = 0, "NEW LINE"); das_accept_cpp_comment(yyextra->g_CommentReaders, yyscanner, *yylloc_param, yytext); @@ -1166,6 +1173,12 @@ void das_accept_cpp_comment ( vector & crdi, yyscan_t scanner, } <> { if ( yyextra->g_FileAccessStack.size()==1 ) { + if (yyextra->last_token_end.line != tokAt(yyscanner,*yylloc_param).line) { + auto lineEnd = tokAt(yyscanner,*yylloc_param); + lineEnd.line = lineEnd.last_line; + lineEnd.column = lineEnd.last_column; + yyextra->last_token_end = lineEnd; + } YYCOLUMN(yyextra->das_yycolumn = 0,"EOF"); if ( !yyextra->das_nested_parentheses && !yyextra->das_nested_curly_braces && !yyextra->das_nested_square_braces ) { bool ns = (yyextra->das_current_line_indent!=0) && yyextra->das_need_oxford_comma; diff --git a/src/parser/ds_parser.cpp b/src/parser/ds_parser.cpp index a54011e39b..9fae4c6670 100644 --- a/src/parser/ds_parser.cpp +++ b/src/parser/ds_parser.cpp @@ -1142,67 +1142,67 @@ static const yytype_int16 yyrline[] = 1757, 1763, 1769, 1775, 1784, 1793, 1802, 1814, 1817, 1823, 1823, 1823, 1826, 1826, 1826, 1831, 1831, 1831, 1839, 1839, 1839, 1845, 1855, 1866, 1879, 1889, 1900, 1915, 1918, 1924, - 1925, 1932, 1943, 1944, 1945, 1949, 1950, 1951, 1952, 1953, - 1957, 1962, 1970, 1971, 1972, 1976, 1981, 1988, 1995, 1995, - 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2015, 2016, - 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, - 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2037, 2038, 2039, - 2040, 2045, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, - 2054, 2055, 2056, 2057, 2058, 2059, 2060, 2061, 2066, 2072, - 2083, 2089, 2100, 2104, 2111, 2114, 2114, 2114, 2119, 2119, - 2119, 2133, 2137, 2141, 2147, 2155, 2163, 2169, 2177, 2177, - 2177, 2184, 2188, 2197, 2205, 2213, 2217, 2220, 2226, 2227, - 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2235, 2236, 2237, - 2238, 2239, 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, - 2248, 2249, 2250, 2251, 2252, 2253, 2254, 2255, 2256, 2257, - 2258, 2259, 2260, 2261, 2267, 2268, 2269, 2270, 2271, 2286, - 2295, 2296, 2297, 2298, 2299, 2300, 2301, 2302, 2303, 2304, - 2305, 2306, 2309, 2312, 2313, 2316, 2316, 2316, 2319, 2324, - 2328, 2332, 2332, 2332, 2337, 2340, 2344, 2344, 2344, 2349, - 2352, 2353, 2354, 2355, 2356, 2357, 2358, 2359, 2360, 2362, - 2366, 2367, 2372, 2376, 2377, 2378, 2379, 2380, 2381, 2382, - 2386, 2390, 2394, 2398, 2402, 2406, 2410, 2414, 2418, 2425, - 2426, 2427, 2431, 2432, 2433, 2437, 2438, 2442, 2443, 2444, - 2448, 2449, 2453, 2464, 2467, 2470, 2470, 2474, 2474, 2493, - 2492, 2508, 2507, 2521, 2530, 2542, 2551, 2561, 2562, 2563, - 2564, 2565, 2569, 2572, 2581, 2582, 2586, 2589, 2592, 2607, - 2616, 2617, 2621, 2624, 2627, 2640, 2641, 2645, 2651, 2657, - 2666, 2669, 2676, 2679, 2685, 2686, 2687, 2691, 2692, 2696, - 2703, 2708, 2717, 2723, 2727, 2738, 2742, 2748, 2754, 2763, - 2775, 2778, 2781, 2781, 2801, 2802, 2806, 2807, 2808, 2812, - 2815, 2815, 2834, 2837, 2840, 2855, 2874, 2875, 2876, 2881, - 2881, 2907, 2908, 2912, 2913, 2913, 2917, 2918, 2919, 2923, - 2933, 2938, 2933, 2950, 2955, 2950, 2970, 2971, 2975, 2976, - 2980, 2986, 2987, 2988, 2989, 2993, 2994, 2995, 2999, 3002, - 3008, 3013, 3008, 3033, 3040, 3045, 3054, 3060, 3064, 3075, - 3076, 3077, 3078, 3079, 3080, 3081, 3082, 3083, 3084, 3085, - 3086, 3087, 3088, 3089, 3090, 3091, 3092, 3093, 3094, 3095, - 3096, 3097, 3098, 3099, 3100, 3101, 3102, 3103, 3104, 3105, - 3106, 3107, 3108, 3109, 3110, 3111, 3112, 3113, 3114, 3115, - 3116, 3117, 3118, 3119, 3120, 3121, 3122, 3123, 3124, 3128, - 3129, 3130, 3131, 3132, 3133, 3134, 3135, 3139, 3150, 3154, - 3161, 3173, 3180, 3186, 3195, 3200, 3203, 3213, 3226, 3227, - 3228, 3229, 3230, 3234, 3238, 3238, 3238, 3252, 3253, 3257, - 3262, 3269, 3272, 3278, 3279, 3280, 3281, 3282, 3292, 3295, - 3295, 3295, 3299, 3304, 3311, 3311, 3318, 3322, 3326, 3331, - 3336, 3341, 3346, 3350, 3354, 3359, 3363, 3367, 3372, 3372, - 3372, 3378, 3385, 3385, 3385, 3390, 3390, 3390, 3396, 3396, - 3396, 3401, 3407, 3407, 3407, 3412, 3412, 3412, 3421, 3427, - 3427, 3427, 3432, 3432, 3432, 3441, 3447, 3447, 3447, 3452, - 3452, 3452, 3461, 3461, 3461, 3467, 3467, 3467, 3476, 3479, - 3490, 3506, 3506, 3511, 3516, 3506, 3541, 3541, 3546, 3552, - 3541, 3577, 3577, 3582, 3587, 3577, 3627, 3628, 3629, 3630, - 3631, 3635, 3642, 3649, 3655, 3661, 3668, 3675, 3681, 3690, - 3693, 3699, 3707, 3712, 3719, 3724, 3731, 3736, 3742, 3743, - 3747, 3748, 3753, 3754, 3758, 3759, 3763, 3764, 3768, 3769, - 3770, 3774, 3775, 3776, 3780, 3781, 3785, 3791, 3798, 3806, - 3813, 3821, 3830, 3830, 3830, 3838, 3838, 3838, 3845, 3845, - 3845, 3856, 3856, 3856, 3867, 3870, 3876, 3890, 3896, 3902, - 3908, 3908, 3908, 3922, 3927, 3934, 3955, 3960, 3967, 3967, - 3967, 3977, 3977, 3977, 3991, 3991, 3991, 4005, 4014, 4014, - 4014, 4035, 4042, 4042, 4042, 4052, 4057, 4064, 4067, 4073, - 4092, 4104, 4112, 4134, 4160, 4161, 4165, 4166, 4171, 4174, - 4177, 4180, 4183, 4186 + 1925, 1933, 1945, 1946, 1947, 1951, 1952, 1953, 1954, 1955, + 1959, 1964, 1972, 1973, 1974, 1978, 1983, 1990, 1997, 1997, + 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2017, 2018, + 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, + 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2039, 2040, 2041, + 2042, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, + 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2068, 2074, + 2085, 2091, 2102, 2106, 2113, 2116, 2116, 2116, 2121, 2121, + 2121, 2135, 2139, 2143, 2149, 2157, 2165, 2171, 2179, 2179, + 2179, 2186, 2190, 2199, 2207, 2215, 2219, 2222, 2228, 2229, + 2230, 2231, 2232, 2233, 2234, 2235, 2236, 2237, 2238, 2239, + 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249, + 2250, 2251, 2252, 2253, 2254, 2255, 2256, 2257, 2258, 2259, + 2260, 2261, 2262, 2263, 2269, 2270, 2271, 2272, 2273, 2288, + 2297, 2298, 2299, 2300, 2301, 2302, 2303, 2304, 2305, 2306, + 2307, 2308, 2311, 2314, 2315, 2318, 2318, 2318, 2321, 2326, + 2330, 2334, 2334, 2334, 2339, 2342, 2346, 2346, 2346, 2351, + 2354, 2355, 2356, 2357, 2358, 2359, 2360, 2361, 2362, 2364, + 2368, 2369, 2374, 2378, 2379, 2380, 2381, 2382, 2383, 2384, + 2388, 2392, 2396, 2400, 2404, 2408, 2412, 2416, 2420, 2427, + 2428, 2429, 2433, 2434, 2435, 2439, 2440, 2444, 2445, 2446, + 2450, 2451, 2455, 2466, 2469, 2472, 2472, 2476, 2476, 2495, + 2494, 2510, 2509, 2523, 2532, 2544, 2553, 2563, 2564, 2565, + 2566, 2567, 2571, 2574, 2583, 2584, 2588, 2591, 2594, 2609, + 2618, 2619, 2623, 2626, 2629, 2642, 2643, 2647, 2653, 2659, + 2668, 2671, 2678, 2681, 2687, 2688, 2689, 2693, 2694, 2698, + 2705, 2710, 2719, 2725, 2729, 2740, 2744, 2750, 2756, 2765, + 2777, 2780, 2783, 2783, 2803, 2804, 2808, 2809, 2810, 2814, + 2817, 2817, 2836, 2839, 2842, 2857, 2876, 2877, 2878, 2883, + 2883, 2909, 2910, 2914, 2915, 2915, 2919, 2920, 2921, 2925, + 2935, 2940, 2935, 2952, 2957, 2952, 2972, 2973, 2977, 2978, + 2982, 2988, 2989, 2990, 2991, 2995, 2996, 2997, 3001, 3004, + 3010, 3015, 3010, 3035, 3042, 3047, 3056, 3062, 3066, 3077, + 3078, 3079, 3080, 3081, 3082, 3083, 3084, 3085, 3086, 3087, + 3088, 3089, 3090, 3091, 3092, 3093, 3094, 3095, 3096, 3097, + 3098, 3099, 3100, 3101, 3102, 3103, 3104, 3105, 3106, 3107, + 3108, 3109, 3110, 3111, 3112, 3113, 3114, 3115, 3116, 3117, + 3118, 3119, 3120, 3121, 3122, 3123, 3124, 3125, 3126, 3130, + 3131, 3132, 3133, 3134, 3135, 3136, 3137, 3141, 3152, 3156, + 3163, 3175, 3182, 3188, 3197, 3202, 3205, 3215, 3228, 3229, + 3230, 3231, 3232, 3236, 3240, 3240, 3240, 3254, 3255, 3259, + 3264, 3271, 3274, 3280, 3281, 3282, 3283, 3284, 3294, 3297, + 3297, 3297, 3301, 3306, 3313, 3313, 3320, 3324, 3328, 3333, + 3338, 3343, 3348, 3352, 3356, 3361, 3365, 3369, 3374, 3374, + 3374, 3380, 3387, 3387, 3387, 3392, 3392, 3392, 3398, 3398, + 3398, 3403, 3409, 3409, 3409, 3414, 3414, 3414, 3423, 3429, + 3429, 3429, 3434, 3434, 3434, 3443, 3449, 3449, 3449, 3454, + 3454, 3454, 3463, 3463, 3463, 3469, 3469, 3469, 3478, 3481, + 3492, 3508, 3508, 3513, 3518, 3508, 3543, 3543, 3548, 3554, + 3543, 3579, 3579, 3584, 3589, 3579, 3629, 3630, 3631, 3632, + 3633, 3637, 3644, 3651, 3657, 3663, 3670, 3677, 3683, 3692, + 3695, 3701, 3709, 3714, 3721, 3726, 3733, 3738, 3744, 3745, + 3749, 3750, 3755, 3756, 3760, 3761, 3765, 3766, 3770, 3771, + 3772, 3776, 3777, 3778, 3782, 3783, 3787, 3793, 3800, 3808, + 3815, 3823, 3832, 3832, 3832, 3840, 3840, 3840, 3847, 3847, + 3847, 3858, 3858, 3858, 3869, 3872, 3878, 3892, 3898, 3904, + 3910, 3910, 3910, 3924, 3929, 3936, 3957, 3962, 3969, 3969, + 3969, 3979, 3979, 3979, 3993, 3993, 3993, 4007, 4016, 4016, + 4016, 4037, 4044, 4044, 4044, 4054, 4059, 4066, 4069, 4075, + 4094, 4106, 4114, 4136, 4162, 4163, 4167, 4168, 4173, 4176, + 4179, 4182, 4185, 4188 }; #endif @@ -9175,6 +9175,7 @@ YYLTYPE yylloc = yyloc_default; auto retE = new ExprReturn(tokAt(scanner,(yylsp[-1])), (yyvsp[0].pExpression)); auto blkE = new ExprBlock(); blkE->at = tokAt(scanner,(yylsp[-1])); + blkE->generated = true; blkE->list.push_back(retE); (yyval.pExpression) = blkE; } @@ -9186,6 +9187,7 @@ YYLTYPE yylloc = yyloc_default; retE->moveSemantics = true; auto blkE = new ExprBlock(); blkE->at = tokAt(scanner,(yylsp[-2])); + blkE->generated = true; blkE->list.push_back(retE); (yyval.pExpression) = blkE; } diff --git a/src/parser/ds_parser.ypp b/src/parser/ds_parser.ypp index 01be767313..26f7ba56ad 100644 --- a/src/parser/ds_parser.ypp +++ b/src/parser/ds_parser.ypp @@ -1926,6 +1926,7 @@ block_or_simple_block auto retE = new ExprReturn(tokAt(scanner,@loc), $subexpr); auto blkE = new ExprBlock(); blkE->at = tokAt(scanner,@loc); + blkE->generated = true; blkE->list.push_back(retE); $$ = blkE; } @@ -1934,6 +1935,7 @@ block_or_simple_block retE->moveSemantics = true; auto blkE = new ExprBlock(); blkE->at = tokAt(scanner,@loc); + blkE->generated = true; blkE->list.push_back(retE); $$ = blkE; } diff --git a/src/parser/lex.yy.h b/src/parser/lex.yy.h index c452a3da5d..ce9c002162 100644 --- a/src/parser/lex.yy.h +++ b/src/parser/lex.yy.h @@ -2,9 +2,9 @@ #define das_yyHEADER_H 1 #define das_yyIN_HEADER 1 -#line 5 "lex.yy.h" +#line 6 "lex.yy.h" -#line 7 "lex.yy.h" +#line 8 "lex.yy.h" #define YY_INT_ALIGNED short int @@ -720,9 +720,9 @@ extern int yylex \ #undef yyTABLES_NAME #endif -#line 1195 "ds_lexer.lpp" +#line 1208 "ds_lexer.lpp" -#line 726 "lex.yy.h" +#line 727 "lex.yy.h" #undef das_yyIN_HEADER #endif /* das_yyHEADER_H */ diff --git a/src/parser/parser_impl.cpp b/src/parser/parser_impl.cpp index c638bea200..33f4b5300b 100644 --- a/src/parser/parser_impl.cpp +++ b/src/parser/parser_impl.cpp @@ -1422,6 +1422,7 @@ namespace das { ExprBlock * ast_wrapInBlock ( Expression * expr ) { auto block = new ExprBlock(); block->at = expr->at; + block->generated = true; block->list.push_back(expr); return block; } diff --git a/tests/ast/_fixture_parse_file_gen1.das b/tests/ast/_fixture_parse_file_gen1.das new file mode 100644 index 0000000000..68df722a82 --- /dev/null +++ b/tests/ast/_fixture_parse_file_gen1.das @@ -0,0 +1,13 @@ +options gen2 = false + +[safe_when_uninitialized] +struct Foo + a : int = 5 + b : float = 3.0 + +def make_them() + var s = [[Foo a=1, b=2.0]] + var arr = [[auto 1; 2; 3]] + var tup = [[auto 4, 5]] + var tab = {{ 1 => "a"; 2 => "b" }} + return s.a + arr[0] + tup._0 + length(tab) diff --git a/tests/ast/test_lineinfo_ranges.das b/tests/ast/test_lineinfo_ranges.das index b8ca6586a4..7fb4a746a0 100644 --- a/tests/ast/test_lineinfo_ranges.das +++ b/tests/ast/test_lineinfo_ranges.das @@ -126,3 +126,73 @@ def test_lineinfo_ranges(t : T?) { } } } + + +//! The last line of a file may carry no newline. The lexer records where a line of code ends when +//! it consumes that newline, so a block closed by end of file used to end at the line before it. + + +class private SpanCollector : AstVisitor { + spans : array + + def override preVisitExprBlock(blk : ExprBlock?) { + if (blk.genFlags.generated) return + spans |> push("{int(blk.at.line)}:{int(blk.at.column)}..{int(blk.at.last_line)}:{int(blk.at.last_column)}") + } +} + + +def private gen1_block_spans(path : string; var spans : array) : bool { + var parsed = false + var inscope access <- make_file_access("") + using() $(var mg : ModuleGroup) { + using() $(var cop : CodeOfPolicies) { + cop.ignore_shared_modules = true + cop.export_all = true + cop.version_2_syntax = false + cop.no_optimizations = true + parse_file(path, access, unsafe(addr(mg)), cop) $(ok; program; _issues) { + if (!ok) return + parsed = true + var collector = new SpanCollector() + for_each_function(get_this_module(program), "") $(var fn) { + if (fn.at.fileInfo == null || fn.flags.generated) return + make_visitor(*collector) $(adapter) { + visit(fn, adapter) + } + } + spans |> push_from(collector.spans) + unsafe { + delete collector + } + } + } + } + return parsed +} + + +[test] +def test_lineinfo_ranges_gen1_eof(t : T?) { + t |> run("a v1 block closed by end of file ends at its last statement") @(t : T?) { + let body = "def eof_block(n : int)\n var acc = 0\n for i in range(n)\n acc += i\n return acc" + let nlFile = create_temp_file_result("lineinfo_gen1_nl", ".das") + let eofFile = create_temp_file_result("lineinfo_gen1_eof", ".das") + t |> success(nlFile is value && eofFile is value, "temporary fixtures created") + if (!(nlFile is value && eofFile is value)) return + let nlPath = unsafe(nlFile.value) + let eofPath = unsafe(eofFile.value) + t |> success(fwrite(nlPath, "{body}\n") && fwrite(eofPath, body), "temporary fixtures written") + var nlSpans : array + var eofSpans : array + let nlOk = gen1_block_spans(nlPath, nlSpans) + let eofOk = gen1_block_spans(eofPath, eofSpans) + remove(nlPath) + remove(eofPath) + t |> success(nlOk && eofOk, "both fixtures parsed") + if (!(nlOk && eofOk)) return + t |> equal(join(eofSpans, ", "), join(nlSpans, ", ")) + t |> success(!empty(eofSpans) && eofSpans[0] |> ends_with("..5:14"), + "outer block ends at the last statement ({empty(eofSpans) ? "none" : eofSpans[0]})") + } +} diff --git a/tests/ast/test_parse_file.das b/tests/ast/test_parse_file.das new file mode 100644 index 0000000000..832689c7b4 --- /dev/null +++ b/tests/ast/test_parse_file.das @@ -0,0 +1,180 @@ +options gen2 +options rtti = true +options strict_smart_pointers = false +options no_aot + +require dastest/testing_boost public +require daslib/ast +require daslib/ast_boost +require daslib/rtti +require daslib/fio +require daslib/strings_boost +require strings + +//! `parse_file` hands over the AST as parsed, before infer. Source-rewriting tools need that +//! tree: infer lowers make-syntax, folds constants and inserts generated nodes, none of which +//! map back to a source span. The fixture is v1 syntax, so this also pins that a gen1 parse is +//! reachable from das (version_2_syntax = false). +//! +//! It further pins WHERE the spans are, because a rewriter's anchors depend on it: a make-node's +//! own `at` covers only its 2-char opener (`[[` / `\{\{`), while the enclosing `ExprLet.atInit` +//! reaches past the closer. A change in either is a deliberate decision, not a detail — this +//! test is the tripwire. +//! +//! The AST dies with the program, so every assertion runs INSIDE the parse_file block: an +//! ExpressionPtr kept past it is a dangling gc_node pointer. + +let FIXTURE = "{get_das_root()}/tests/ast/_fixture_parse_file_gen1.das" + + +def private read_lines(file : string) : array { + var lines <- fread(file) |> split("\n") + for (ln in lines) { + if (ln |> ends_with("\r")) { + ln = slice(ln, 0, length(ln) - 1) + } + } + return <- lines +} + +def private text_at(lines : array; line, column, count : int) : string { + if (line < 1 || line > length(lines)) return "" + let ln = lines[line - 1] + if (column < 0 || column + count > length(ln)) return "" + return slice(ln, column, column + count) +} + +def private span_head(lines : array; li : LineInfo; count : int) : string { + return text_at(lines, int(li.line), int(li.column), count) +} + +def private span_tail(lines : array; li : LineInfo; count : int) : string { + return text_at(lines, int(li.last_line), int(li.last_column) - count, count) +} + + +def private collect_inits(var blk : ExprBlock?; var inits : array; + var initEndLine, initEndColumn : array) { + for (stmt in blk.list) { + var letExpr = stmt ?as ExprLet + if (letExpr == null) continue + for (v in letExpr.variables) { + if (v.init == null) continue + inits |> push(v.init) + initEndLine |> push(int(letExpr.atInit.last_line)) + initEndColumn |> push(int(letExpr.atInit.last_column)) + } + } +} + + +def private check_make_nodes(t : T?; var fn : FunctionPtr; lines : array) { + var blk = fn.body ?as ExprBlock + if (blk == null) { + t |> failure("make_them has no block body") + return + } + var inits : array + var initEndLine : array + var initEndColumn : array + collect_inits(blk, inits, initEndLine, initEndColumn) + t |> equal(length(inits), 4, "four initializers in make_them") + if (length(inits) != 4) return + + // [[Foo a=1, b=2.0]] stays a make-struct; `useInitializer` records that no () was written + var msd = inits[0] ?as ExprMakeStruct + t |> success(msd != null, "first init is ExprMakeStruct") + if (msd != null) { + t |> success(!msd.makeStructFlags.useInitializer, "no () in [[Foo ...]] means useInitializer == false") + t |> equal(length(msd.structs), 1, "one instance") + } + + // [[auto 1; 2; 3]] — the v1 spelling is recorded in the tree, so a rewriter does not have + // to consult the source to know which syntax was written + var mka = inits[1] ?as ExprMakeArray + t |> success(mka != null, "second init is ExprMakeArray") + if (mka != null) { + t |> success(!mka.gen2, "v1 make-array carries gen2 == false") + t |> equal(length(mka.values), 3, "three values") + } + + // [[auto 4, 5]] is a one-element make-array holding a make-tuple; infer is what collapses + // that into a bare tuple, so a pre-infer walk has to expect the wrapper + var mkt = inits[2] ?as ExprMakeArray + t |> success(mkt != null, "[[auto 4, 5]] is ExprMakeArray") + if (mkt != null) { + t |> equal(length(mkt.values), 1, "one value") + if (length(mkt.values) == 1) { + t |> success(mkt.values[0] ?as ExprMakeTuple != null, "the value is ExprMakeTuple") + } + } + + // {{ k => v }} is lowered to a to_table_move call over a make-array AT PARSE TIME, so + // make-table detection is call-shaped, not node-shaped + var tabCall = inits[3] ?as ExprCall + t |> success(tabCall != null, "fourth init is ExprCall") + if (tabCall != null) { + t |> success(find(string(tabCall.name), "to_table_move") >= 0, "call is to_table_move, got {tabCall.name}") + t |> equal(length(tabCall.arguments), 1, "one argument") + if (length(tabCall.arguments) == 1) { + t |> success(tabCall.arguments[0] ?as ExprMakeArray != null, "argument is ExprMakeArray") + } + } + + check_make_spans(t, inits, initEndLine, initEndColumn, lines) +} + + +def private check_make_spans(t : T?; inits : array; + initEndLine, initEndColumn : array; lines : array) { + // a make-node's own span is JUST the opener — the closer is nowhere in the tree, which is + // why a rewriter has to scan forward for `]]` / `\}\}` + t |> equal(span_head(lines, inits[0].at, 2), "[[", "make-struct span starts at [[") + t |> equal(span_tail(lines, inits[0].at, 2), "[[", "make-struct span ENDS at [[ too") + t |> equal(span_head(lines, inits[1].at, 2), "[[", "make-array span starts at [[") + t |> equal(span_tail(lines, inits[1].at, 2), "[[", "make-array span ENDS at [[ too") + t |> equal(span_head(lines, inits[3].at, 2), "\{\{", "make-table span starts at \{\{") + + // the enclosing let's atInit is the anchor that does include the closer + t |> equal(text_at(lines, initEndLine[0], initEndColumn[0] - 2, 2), "]]", "atInit ends at ]]") + t |> equal(text_at(lines, initEndLine[1], initEndColumn[1] - 2, 2), "]]", "atInit ends at ]]") + t |> equal(text_at(lines, initEndLine[3], initEndColumn[3] - 2, 2), "\}\}", "atInit ends at \}\}") +} + + +[test] +def test_parse_file_gen1_pre_infer(t : T?) { + t |> run("v1 make-syntax and its spans survive the parse") @(t : T?) { + let lines <- read_lines(FIXTURE) + if (empty(lines)) { + t |> success(false, "could not read {FIXTURE}") + return + } + var seen = false + var inscope access <- make_file_access("") + using() $(var mg : ModuleGroup) { + using() $(var cop : CodeOfPolicies) { + cop.ignore_shared_modules = true + cop.export_all = true + cop.version_2_syntax = false + cop.no_optimizations = true + parse_file(FIXTURE, access, unsafe(addr(mg)), cop) $(ok; program; issues) { + if (!ok) { + t |> success(false, "fixture failed to parse: {issues}") + return + } + for_each_function(get_this_module(program), "") $(var fn) { + // required modules contribute generic instances (builtin's + // to_table_move, which the \{\{...\}\} lowering emits) — only walk + // the fixture's own code + if (fn.at.fileInfo == null || fn.name != "make_them" + || !(fn.at.fileInfo.name |> ends_with("_fixture_parse_file_gen1.das"))) return + seen = true + check_make_nodes(t, fn, lines) + } + } + } + } + t |> success(seen, "make_them was found in the parsed module") + } +} From 180a04701605f2fa9346918529de4e0413c6ff74 Mon Sep 17 00:00:00 2001 From: Churkin Aleksey Date: Tue, 25 Aug 2026 14:44:01 +0300 Subject: [PATCH 3/3] gen1_to_gen2: a v1 -> gen2 converter in daslang Source is immutable bytes. The file is parsed once with infer off, every rewrite is recorded as an edit in ORIGINAL byte offsets, and the edits are applied in a single forward walk. Nesting needs no special handling: a rule only ever edits the delimiters of its own construct, which lie between its children, so a parent's edits and its children's are disjoint ranges and one pass composes them. That is what removes the previous tool's re-parse loop, and with it the reason its grammar fork had to accept mixed gen1+gen2 input. Comment preservation is structural rather than per-rule discipline: untouched bytes are copied verbatim, a deletion whose range holds a comment or a string is refused, gap-collapse rules require a blank gap, a line-edge insertion steps past a block comment, and every conversion is gated on the input's ordered comment sequence equalling the output's. Converted families: make-syntax in every v1 shape, the `[{ }]` / `{{ }}` wrappers and both comprehension spellings, indentation into braces, conditions and for-heads into parentheses, declaration bodies, piped literals, argument annotations, `typeinfo(trait x)`, tuple destructuring, typed make-arrays, enumeration and bitfield values, call-style casts, type-function calls, keyword call macros, multi-value return, `static_if` / `static_elif`, global `let`/`var` blocks, and a continued initializer - which gen2 would otherwise read as a separate unary statement and delete silently. Measured by migrating the historical v1 corpus in place (tests/ at 027cbc2d8^, `.inc` fragments included) and compiling the result: 71 of the 72 files that compile as v1 today convert to gen2 that compiles, none loses a comment. The exception is the spoof-template file, which is skipped by design - its template body is text the parser never sees as code, so no rule can place its braces. `utils/internal/lineinfo-audit` gains `--parse-only` and `--gen1`, which is how the converter's anchors are validated: that tree comes entirely from the parser, so a span violation in it is a real parser bug. A borrowed position in the compiled tree is what lowering does, and is not something to flag away - marking such nodes `generated` quiets the audit at the cost of every other consumer of that flag, lint included. `run_utils_tests` collects the directory, so CI runs the converter's 75 dastest tests; the MCP `convert_to_gen2` tool runs the script through the daslang it was launched with, which is why the `.das` files are installed alongside the other utils. Co-Authored-By: Claude Opus 5 (1M context) --- CLAUDE.md | 2 +- CMakeLists.txt | 6 + ci/smoke_test_bundle.sh | 1 + doc/source/reference/utils.rst | 1 + doc/source/reference/utils/das_fmt.rst | 2 +- doc/source/reference/utils/gen1_to_gen2.rst | 42 ++ doc/source/reference/utils/mcp.rst | 2 +- install/CLAUDE.md | 3 +- skills/das_formatting.md | 2 +- skills/mcp_tools.md | 2 +- utils/CMakeLists.txt | 1 + utils/gen1-to-gen2/README.md | 120 ++++ utils/gen1-to-gen2/comments.das | 201 +++++++ utils/gen1-to-gen2/convert.das | 395 ++++++++++++ utils/gen1-to-gen2/extent.das | 219 +++++++ utils/gen1-to-gen2/main.das | 114 ++++ utils/gen1-to-gen2/offsets.das | 141 +++++ utils/gen1-to-gen2/patch.das | 142 +++++ utils/gen1-to-gen2/rules_decl.das | 217 +++++++ utils/gen1-to-gen2/rules_make.das | 359 +++++++++++ utils/gen1-to-gen2/rules_stmt.das | 565 ++++++++++++++++++ utils/gen1-to-gen2/scan.das | 233 ++++++++ .../tests/_fixture_gen1_basic.das | 11 + .../gen1-to-gen2/tests/_fixture_gen1_decl.das | 22 + .../gen1-to-gen2/tests/_fixture_gen1_stmt.das | 91 +++ .../tests/_fixture_make_syntax.das | 31 + utils/gen1-to-gen2/tests/test_convert.das | 111 ++++ utils/gen1-to-gen2/tests/test_engine.das | 144 +++++ utils/gen1-to-gen2/tests/test_make.das | 110 ++++ utils/gen1-to-gen2/tests/test_shapes.das | 296 +++++++++ utils/gen1-to-gen2/tests/test_stmt.das | 147 +++++ utils/internal/lineinfo-audit/README.md | 8 + utils/internal/lineinfo-audit/main.das | 116 ++-- utils/internal/test-release/utils_phase.das | 3 + utils/mcp/README.md | 2 +- utils/mcp/registry_das.das | 2 +- utils/mcp/tools/convert_to_gen2.das | 18 +- 37 files changed, 3817 insertions(+), 65 deletions(-) create mode 100644 doc/source/reference/utils/gen1_to_gen2.rst create mode 100644 utils/gen1-to-gen2/README.md create mode 100644 utils/gen1-to-gen2/comments.das create mode 100644 utils/gen1-to-gen2/convert.das create mode 100644 utils/gen1-to-gen2/extent.das create mode 100644 utils/gen1-to-gen2/main.das create mode 100644 utils/gen1-to-gen2/offsets.das create mode 100644 utils/gen1-to-gen2/patch.das create mode 100644 utils/gen1-to-gen2/rules_decl.das create mode 100644 utils/gen1-to-gen2/rules_make.das create mode 100644 utils/gen1-to-gen2/rules_stmt.das create mode 100644 utils/gen1-to-gen2/scan.das create mode 100644 utils/gen1-to-gen2/tests/_fixture_gen1_basic.das create mode 100644 utils/gen1-to-gen2/tests/_fixture_gen1_decl.das create mode 100644 utils/gen1-to-gen2/tests/_fixture_gen1_stmt.das create mode 100644 utils/gen1-to-gen2/tests/_fixture_make_syntax.das create mode 100644 utils/gen1-to-gen2/tests/test_convert.das create mode 100644 utils/gen1-to-gen2/tests/test_engine.das create mode 100644 utils/gen1-to-gen2/tests/test_make.das create mode 100644 utils/gen1-to-gen2/tests/test_shapes.das create mode 100644 utils/gen1-to-gen2/tests/test_stmt.das diff --git a/CLAUDE.md b/CLAUDE.md index 8f0d8f6719..fc846aea83 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -126,7 +126,7 @@ Task-specific instructions are split into skill files under `skills/`. You MUST Multiple skill files may apply to one task: creating a new daslib module needs `skills/das_formatting.md`, `skills/daslib_modules.md`, and possibly `skills/internal/documentation_rst.md`. -**Formatter reminder:** format `.das` files with the MCP `format_file` tool (it calls `daslib/das_source_formatter`). NOT `utils/gen1-to-gen2/` - that is the v1->v2 syntax converter, not a formatter. +**Formatter reminder:** format `.das` files with the MCP `format_file` tool (it calls `daslib/das_source_formatter`). NOT `utils/gen1-to-gen2/` - that is the v1->gen2 syntax converter, not a formatter. ### Updating Instructions with New Knowledge diff --git a/CMakeLists.txt b/CMakeLists.txt index 96fd3353ea..564acc8813 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1874,6 +1874,12 @@ install(FILES ${PROJECT_SOURCE_DIR}/utils/aot/main.das DESTINATION utils/aot) # Install fix-lint-errors tool (mechanical lint auto-fixer) install(FILES ${PROJECT_SOURCE_DIR}/utils/fix-lint-errors/main.das DESTINATION utils/fix-lint-errors) +install(DIRECTORY ${PROJECT_SOURCE_DIR}/utils/gen1-to-gen2/ + DESTINATION utils/gen1-to-gen2 + FILES_MATCHING PATTERN "*.das" + PATTERN "tests" EXCLUDE +) + # Install MCP server (stdio transport, no dasHV dependency) # main.das — full server entry point # cpp_main.das — cpp/agnostic-subset entry point diff --git a/ci/smoke_test_bundle.sh b/ci/smoke_test_bundle.sh index 0032af803e..27753f851b 100644 --- a/ci/smoke_test_bundle.sh +++ b/ci/smoke_test_bundle.sh @@ -76,6 +76,7 @@ COMPILE_TESTS=( "daspkg|utils/daspkg/main.das" "detect-dupe|utils/detect-dupe/main.das" "fix-lint-errors|utils/fix-lint-errors/main.das" + "gen1-to-gen2|utils/gen1-to-gen2/main.das" "jobque-timeline|utils/jobque-timeline/main.das" "lint|utils/lint/main.das" "mcp|utils/mcp/main.das" diff --git a/doc/source/reference/utils.rst b/doc/source/reference/utils.rst index c77a708b29..c887332020 100644 --- a/doc/source/reference/utils.rst +++ b/doc/source/reference/utils.rst @@ -18,6 +18,7 @@ built-in leak-detection mechanism. utils/dascov.rst utils/lint.rst utils/das_fmt.rst + utils/gen1_to_gen2.rst utils/fix_lint_errors.rst utils/daspkg.rst utils/benchctl.rst diff --git a/doc/source/reference/utils/das_fmt.rst b/doc/source/reference/utils/das_fmt.rst index 0ef56585d5..86eaa62dde 100644 --- a/doc/source/reference/utils/das_fmt.rst +++ b/doc/source/reference/utils/das_fmt.rst @@ -13,7 +13,7 @@ das-fmt formats daslang source files in place using ``format_file`` tool and the shipped ``pre-commit`` hook. The SDK bundle also carries a prebuilt ``bin/das-fmt.exe``. -Not to be confused with ``gen1_to_gen2``, the gen1→gen2 syntax +Not to be confused with ``gen1-to-gen2``, the gen1→gen2 syntax *converter*. Quick start diff --git a/doc/source/reference/utils/gen1_to_gen2.rst b/doc/source/reference/utils/gen1_to_gen2.rst new file mode 100644 index 0000000000..95f53ee201 --- /dev/null +++ b/doc/source/reference/utils/gen1_to_gen2.rst @@ -0,0 +1,42 @@ +.. _utils_gen1_to_gen2: + +.. index:: + single: Utils; gen1-to-gen2 + single: Utils; v1 to gen2 converter + +=========================================== + gen1-to-gen2 --- v1 to gen2 Converter +=========================================== + +gen1-to-gen2 rewrites a daslang file written in v1 (indentation-delimited) +syntax into gen2 (braces and parentheses). It parses the file with type +inference off, so the tree mirrors the source one to one, collects every +edit as a byte range in the ORIGINAL text, and applies them in a single +pass. Only delimiters move: the code between them is copied verbatim. + +Every comment in the input must appear in the output, in the same order. +An edit that would delete or absorb one is refused, and a file with a +refused edit is reported and left untouched rather than half converted. + +Quick start +=========== + +:: + + daslang utils/gen1-to-gen2/main.das -- -p # print the result + daslang utils/gen1-to-gen2/main.das -- -i # rewrite in place + +Flags: ``-p``/``--print`` (write to stdout), ``-i``/``--inplace``, +``--gen15`` (convert the constructor syntax but keep the indentation and +the ``options gen2 = false`` marker), ``--semicolon`` (terminate the +generated header), ``--verify-compile`` (compile the result before +accepting it), ``--help`` for the rest. + +The exit code is 1 when a file does not parse as v1 or an edit is +refused; nothing is written in either case. A file that is already gen2 +is echoed unchanged, and a file using spoof templates is skipped, since +the template body is text the parser never sees as code. + +.. seealso:: + + :ref:`utils_das_fmt` -- the formatter; it does not change syntax generation diff --git a/doc/source/reference/utils/mcp.rst b/doc/source/reference/utils/mcp.rst index 4423daf2ce..919b1c17c4 100644 --- a/doc/source/reference/utils/mcp.rst +++ b/doc/source/reference/utils/mcp.rst @@ -237,7 +237,7 @@ Code generation and transformation - Format a ``.das`` file using the built-in formatter. * - ``convert_to_gen2`` - Convert a ``.das`` file from gen1 syntax to gen2 using - the ``gen1_to_gen2`` converter. Optional ``inplace`` flag. + the ``gen1-to-gen2`` converter. Optional ``inplace`` flag. * - ``aot`` - Generate AOT (ahead-of-time) C++ code for a ``.das`` file or a single function. Overloaded names return a disambiguation list. diff --git a/install/CLAUDE.md b/install/CLAUDE.md index 1e45bbee5c..bc9a33f818 100644 --- a/install/CLAUDE.md +++ b/install/CLAUDE.md @@ -190,7 +190,7 @@ For path/filename ops use `fio` helpers (`base_name`/`dir_name`/`path_join`/...) ## SDK Directory Layout -- `bin/` - compiler and tool binaries: `daslang`, `daslang-live`, plus prebuilt tool exes (`lint.exe`, `das-fmt.exe`, `daspkg.exe`, `dascov.exe`, `detect-dupe.exe`, `benchctl.exe`, `dastest.exe` - the `.exe` suffix on every platform) and shared-module / tree-sitter libraries on Windows. Each tool also keeps its source form - `bin/daslang utils//main.das`, except das-fmt (`utils/das-fmt/dasfmt.das`) and dastest (`dastest/dastest.das`). +- `bin/` - compiler and tool binaries: `daslang`, `daslang-live`, plus prebuilt tool exes (`lint.exe`, `das-fmt.exe`, `daspkg.exe`, `dascov.exe`, `detect-dupe.exe`, `benchctl.exe`, `dastest.exe` - the `.exe` suffix on every platform) and shared-module / tree-sitter libraries on Windows. Each tool also keeps its source form - `bin/daslang utils//main.das`, except das-fmt (`utils/das-fmt/dasfmt.das`) and dastest (`dastest/dastest.das`). **Name trap:** `utils/gen1-to-gen2/` is the gen1->gen2 syntax *converter*, not a formatter; the formatter is `das-fmt` (MCP `format_file`, `bin/das-fmt.exe`, or `bin/daslang utils/das-fmt/dasfmt.das`) - `lib/`, `include/daScript/` - libraries and C++ headers for embedding - `daslib/` - standard library modules (.das) - `modules/` - optional plugin modules (dasHV, dasGlfw, dasPUGIXML, dasSQLITE, dasAudio, dasLLVM, dasLLAMA, ...) @@ -199,6 +199,7 @@ For path/filename ops use `fio` helpers (`base_name`/`dir_name`/`path_join`/...) - `utils/mcp/`, `utils/lsp/` - MCP and LSP servers for AI coding assistants - `utils/lint/` - lint runner: `bin/daslang utils/lint/main.das -- --quiet` - `utils/das-fmt/` - the formatter script (`dasfmt.das`, wraps `daslib/das_source_formatter`) +- `utils/gen1-to-gen2/` - v1 (indentation) -> gen2 (braces) syntax converter, run as `bin/daslang utils/gen1-to-gen2/main.das -- ` (also the `convert_to_gen2` MCP tool) - `utils/detect-dupe/` - cross-file duplicate-function detector (also the `export_corpus` / `detect_duplicates` MCP tools) - `utils/find-dupe/` - Claude-based judge for detect-dupe reports (needs `ANTHROPIC_API_KEY`; also the `judge_duplicates`/`find_dupe` MCP tools) - `utils/daspkg/`, `utils/dascov/` - package manager; code coverage diff --git a/skills/das_formatting.md b/skills/das_formatting.md index 3e24eab830..4adc187e5e 100644 --- a/skills/das_formatting.md +++ b/skills/das_formatting.md @@ -13,7 +13,7 @@ After creating or modifying any `.das` file that is part of the project (daslib For a module under `modules/` whose files `require` sibling modules (e.g. `require openai/openai_chat`), pass `-load_module ` before `--` so cross-module requires resolve. The formatter only parses, so it works regardless; lint reports `SKIP ... missing prerequisite` for files it can't fully resolve (e.g. examples/tests before the module is registered/installed). -> **Not the converter:** the installed `bin/gen1_to_gen2` binary is the **v1->v2 syntax converter** (flags `-i` / `--tests` / `--semicolon`), not a code formatter. The formatter is the daslang script `utils/das-fmt/dasfmt.das` (flags `--path` / `--verify`) - invoke it through `bin/daslang utils/das-fmt/dasfmt.das -- ...` or the MCP `format_file` tool. +> **Not the converter:** `utils/gen1-to-gen2/main.das` is the **v1->gen2 syntax converter** (flags `-p` / `-i` / `--semicolon` / `--verify`), not a code formatter. The formatter is the daslang script `utils/das-fmt/dasfmt.das` (flags `--path` / `--verify`) - invoke it through `bin/daslang utils/das-fmt/dasfmt.das -- ...` or the MCP `format_file` tool. **What the formatter does and does not do.** It normalizes spacing inside expressions (`if( a>0 )` -> `if (a > 0)`, `print( x )` -> `print(x)`). It does **not** re-indent: a misindented file is rewritten with its indentation untouched and still passes `--verify`, so it also passes the CI format gate. Indent width is taken from the file itself - inferred from the first indented line, or pinned by a file-level `options indenting = N` (clamped 1..8). Getting indentation right is on you; neither the formatter nor CI will catch it. diff --git a/skills/mcp_tools.md b/skills/mcp_tools.md index 7d9aa54edf..842c77ece9 100644 --- a/skills/mcp_tools.md +++ b/skills/mcp_tools.md @@ -19,7 +19,7 @@ The daslang MCP server (`utils/mcp/main.das`) exposes compiler diagnostics, prog | `run_script` | Running scripts via shell and capturing output | | `run_test` | Running dastest via shell and parsing results | | `format_file` | Running the formatter script manually; supports comma-separated list or glob, returns JSON array of results. Comment stripping follows the folder's `.lint_config` `[format]` policy, with no per-call override - `skills/das_formatting.md` | -| `convert_to_gen2` | Running the `gen1_to_gen2` converter manually to convert gen1->gen2 syntax | +| `convert_to_gen2` | Running `utils/gen1-to-gen2/main.das` manually to convert gen1->gen2 syntax | | `goto_definition` | Manually tracing symbol definitions across files | | `type_of` | Manually inspecting expression types | | `list_requires` | Grepping for `require` statements and guessing transitive deps | diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index fb2e9423b6..a5dda03926 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -164,6 +164,7 @@ SET(DAS_UTILS_TO_TEST lint detect-dupe find-dupe/tests + gen1-to-gen2/tests internal/hygiene internal/ast-fuzz internal/requirefix diff --git a/utils/gen1-to-gen2/README.md b/utils/gen1-to-gen2/README.md new file mode 100644 index 0000000000..90ba217863 --- /dev/null +++ b/utils/gen1-to-gen2/README.md @@ -0,0 +1,120 @@ +# gen1-to-gen2 + +Converts daslang v1 syntax to gen2. Replaces the C++ `gen1-to-gen2` binary that lived here, +which carried a fork of the v1 bison grammar. + +``` +daslang utils/gen1-to-gen2/main.das -- -p file.das [-p other.das] [-i] [--semicolon] [--gen15] [--verify] +``` + +- `-p` file to convert, repeatable +- `-i` rewrite in place (default prints to stdout; more than one file needs `-i` or `--verify`) +- `--semicolon` keep the statement-terminating `;` +- `--gen15` stop at gen1.5: make-syntax only, no braces or parens +- `--verify` report what would change, write nothing + +## How it works + +One pass, no re-parsing. + +1. **Read once.** The source is an immutable string plus a line index (`offsets.das`); every + `LineInfo` becomes an absolute byte offset up front, so no step does line/column arithmetic. +2. **Parse with infer off.** `parse_file` (ast module) hands over the tree as parsed: make-syntax + unlowered, generics unresolved, nothing folded or generated, and a file that does not + type-check still yields a tree. +3. **Collect edits.** Each rule in `convert.das` records `(from, to, text)` in *original* + offsets. Rules never write text and never see each other's output. +4. **Apply once.** `patch.das` sorts the edits and emits the result in a single forward walk. + +Nesting needs no special handling. Every rule edits only the delimiters of its own construct, +which lie between its children, so a parent's edits and its children's are disjoint ranges: + +``` +[[Bar a=[[Foo b=2.0]]]] inner: [[ -> Foo( ]] -> ) + outer: [[ -> Bar( ]] -> ) + one pass, four disjoint edits +``` + +An "after X" edit is a zero-length insert at an original offset, so it lands correctly however +much the construct it follows grew or shrank. Two edits that overlap without nesting are refused +and reported rather than merged. Two at the same offset order by rank: inner closer, outer +closer, then statement terminator. + +## Comments are never lost + +A comment is the one thing no tool can regenerate, so preservation is structural, not per-rule +discipline: + +- untouched bytes are copied verbatim - a rule cannot lose a comment by omission +- a `remove` whose range holds a comment or string literal is refused (`patch.das`) +- gap-collapse rules require the gap to be blank (`is_blank`), which is what leaves + `try //a` / `recover //b` alone +- an insertion anchored at a line edge steps past a block comment that ends on a later line + (`line_edge`) +- every conversion is gated on `check_comments_preserved`: the ordered comment sequence of the + input must equal the output's, which catches loss, duplication and reordering at once + +A comment may MOVE to an adjacent anchor when the syntax around it is restructured - the gate +compares the texts, not the positions. + +## Notes on v1 spans + +Measured against the historical v1 corpus (`utils/lineinfo-audit --gen1`): + +- a make-node's `at` covers only its two-character opener (`[[`, `[{`, `{{`); the closer is not + in the tree, so a rule finds it from the enclosing anchor or by scanning +- multi-line v1 spans end one column past the last line - `offsets.das` clamps to the line end +- `{{ k => v }}` is already an unresolved `to_table_move` call at parse time, and + `genFlags.generated` is false on it, so "written by hand" cannot be read off the flag; a rule + verifies the anchor text before it patches +- a `k => v` entry reports its span from the `=>`, not from the key, so the text before the first + value is not always the element type - only the bare `[[ ]]` form can carry one +- a block starts where its header's CODE ends, which a trailing `//` on that line puts AT the + comment: the opening brace goes in FRONT of that anchor, and the closing brace after the + trailing comment of the last statement + +## What converts today + +| family | state | +|---|---| +| make-syntax: `[[Foo ...]]`, `;`-separated instances, `[[Foo]]`, `[[Foo?]]`, `[[Foo#]]`, `[[auto ...]]`, `[[auto[] ...]]`, tuple elements | done | +| `[{ ... }]` and `{{ ... }}` wrappers, both comprehension spellings | done | +| blocks: indentation becomes braces (functions, generics, `if`/`else`, `for`, `while`, `with`, `unsafe`, `try`/`recover`) | done | +| conditions: `if`/`while`/`with` subjects and the `for` head gain parentheses | done | +| declarations: `struct`, `class`, `enum`, `bitfield` bodies; `typedef` blocks split per alias | done | +| `f <|` + an indented body (bare piped block) | done - the block gains the `$()` header gen2 needs | +| typed make-array: `[[int 1, 2]]` -> `fixed_array(...)`, `[{int 1; 2}]` -> `[1, 2]` | done | +| `typeinfo(trait expr)` -> `typeinfo trait(expr)` | done | +| argument annotations: `[[optional]] a` -> `@optional a` | done | +| tuple destructuring: `var [[a, b]]` -> `var (a, b)` | done | +| piped literals: `$ <\| (a, b : int)` and `@ <\|` write themselves, and the `<\|` goes | done | +| enumeration and bitfield values: `Color green` -> `Color.green` | done | +| casts: `reinterpret x` -> `reinterpret(x)` | done | +| type functions: `take(1, 2)` -> `take(type, 1, 2)` | done | +| multi-value return: `return 1, "2"` -> `return (1, "2")` | done | +| `static_if cond` -> `static_if (cond)` | done | +| spoof templates (`%spoof_template~`) | **skipped** - the template body is text the parser never sees as code, so no rule can place its braces; the file is reported and left alone | +| a multi-line arithmetic RHS | **not yet** - gen2 needs it parenthesised, or the continuation lines are separate statements | +| EOL semicolons, capture lists | **not yet** | + +Measured by migrating the whole historical v1 corpus in place (the 104 `.das` files under +`tests/` at `027cbc2d8^`, `.inc` fragments included) and compiling the result as gen2. Of those, +72 compile as v1 with today's compiler - the rest are deliberately-failing `failed_*` fixtures +and files the current compiler rejects for reasons that predate any conversion. **71 of those 72 +convert to gen2 that compiles, and none loses a comment.** The one exception is the spoof-template +file, which is skipped by design. + +An `.inc` is converted as its own file and gets no `options gen2` header - it is spliced into a +module that already carries one. + +## Layout + +| file | what | +|---|---| +| `offsets.das` | source as bytes: line index, `LineInfo` -> offset, span text, indent | +| `comments.das` | comment and string-literal ranges, blank-gap test, line edge | +| `patch.das` | the edit set: record, sort, apply, refuse; the conservation gate | +| `convert.das` | the rules, and `convert_file` | +| `main.das` | CLI | +| `test_engine.das` | offsets, lexical scan, edit composition | +| `test_convert.das` | end-to-end over `_fixture_gen1_basic.das` | diff --git a/utils/gen1-to-gen2/comments.das b/utils/gen1-to-gen2/comments.das new file mode 100644 index 0000000000..1d44c01d50 --- /dev/null +++ b/utils/gen1-to-gen2/comments.das @@ -0,0 +1,201 @@ +options gen2 +options indenting = 4 + +require math +require strings +require offsets + + +struct public Span { + //! A byte range [from, to) in the source. + from : int + to : int +} + + +struct public Lexical { + //! Comment and string-literal ranges of one source, in ascending order. + comments : array + strings : array +} + + +def private is_at(bytes : array const#; i : int; a, b : int) : bool { + return i + 1 < length(bytes) && bytes[i] == uint8(a) && bytes[i + 1] == uint8(b) +} + +def private end_of_quoted(bytes : array const#; start : int; quote : int) : int { + var i = start + 1 + while (i < length(bytes)) { + if (bytes[i] == uint8('\\')) { + i += 2 + continue + } + if (bytes[i] == uint8(quote)) return i + 1 + i++ + } + return length(bytes) +} + + +def public scan_lexical(src : Source) : Lexical { + //! Finds every comment and string/character literal in `src`. + //! + //! Character literals are tracked because `'"'` would otherwise open a phantom string, and + //! string literals are tracked because `"/* not a comment */"` would otherwise open one. + var lex : Lexical + peek_data(src.text) $(bytes) { + var i = 0 + while (i < length(bytes)) { + if (is_at(bytes, i, '/', '/')) { + var e = i + 2 + while (e < length(bytes) && bytes[e] != uint8('\n')) { + e++ + } + if (e > i + 2 && bytes[e - 1] == uint8('\r')) { + e-- + } + lex.comments |> push(Span(from = i, to = e)) + i = e + } elif (is_at(bytes, i, '/', '*')) { + var e = i + 2 + while (e < length(bytes) && !is_at(bytes, e, '*', '/')) { + e++ + } + e = min(e + 2, length(bytes)) + lex.comments |> push(Span(from = i, to = e)) + i = e + } elif (bytes[i] == uint8('"') || bytes[i] == uint8('\'')) { + let e = end_of_quoted(bytes, i, int(bytes[i])) + lex.strings |> push(Span(from = i, to = e)) + i = e + } else { + i++ + } + } + } + return <- lex +} + + +def private overlaps(spans : array; from, to : int) : bool { + for (s in spans) { + if (s.from >= to) break + if (s.to > from) return true + } + return false +} + + +def public has_comment_or_string(lex : Lexical; from, to : int) : bool { + //! True when [from, to) touches any comment or string literal. A deletion must not. + return overlaps(lex.comments, from, to) || overlaps(lex.strings, from, to) +} + + +def public inside_comment(lex : Lexical; offset : int) : int { + //! End offset of the comment containing `offset`, or `offset` when it is outside one. + //! + //! An insertion anchored at a line edge can otherwise land inside a block comment that + //! spans lines, splitting it. + for (c in lex.comments) { + if (c.from > offset) break + if (offset > c.from && offset < c.to) return c.to + } + return offset +} + + +def public comment_texts(src : Source; lex : Lexical) : array { + //! The comment texts in source order — the sequence the conservation gate compares. + return <- [for (c in lex.comments); text_of(src, c.from, c.to)] +} + + +def public line_edge(src : Source; lex : Lexical; offset : int) : int { + //! Where a statement-trailing insertion goes: end of `offset`'s line, before the newline and + //! any trailing whitespace. + //! + //! A trailing `//` comment pulls the edge in front of it — text appended after one would be + //! swallowed by it. A block comment does not: `def f()/**/ \{` is where the brace belongs, + //! and a block comment that runs past the line pushes the edge to where it closes. + let ln = line_at(src, offset) + var e = line_end(src, ln) + let pushed = inside_comment(lex, e) + if (pushed != e) { + return pushed + } + let lineStart = line_begin(src, ln) + for (c in lex.comments) { + if (c.from >= e) break + if (c.from >= lineStart && c.to >= e && text_of(src, c.from, c.from + 2) == "//") { + e = c.from + break + } + } + let b = line_begin(src, ln) + peek_data(src.text) $(bytes) { + while (e > b) { + let c = int(bytes[e - 1]) + if (c != ' ' && c != '\t' && c != '\r') break + e-- + } + } + return e +} + + +def public blank_or_comments(src : Source; lex : Lexical; from, to : int) : bool { + //! True when [from, to) holds nothing but whitespace and whole comments. + //! + //! This is what may sit between a block's last statement and the end of its line, and the + //! closing brace goes after it — a `}` in front of a trailing `//` would be swallowed by it. + //! A comment that starts inside the range and ends past it fails, so the brace never lands + //! in the middle of a block comment. + var ok = true + peek_data(src.text) $(bytes) { + var i = max(from, 0) + let stop = min(to, length(bytes)) + while (i < stop) { + var jumped = false + for (c in lex.comments) { + if (c.from > i) break + if (c.from == i) { + if (c.to > stop) { + ok = false + } else { + i = c.to + jumped = true + } + break + } + } + if (!ok) break + if (jumped) continue + let ch = int(bytes[i]) + if (ch != ' ' && ch != '\t' && ch != '\r' && ch != '\n') { + ok = false + break + } + i++ + } + } + return ok +} + + +def public is_blank(src : Source; from, to : int) : bool { + //! True when [from, to) holds nothing but whitespace — the gap-collapse guard. A gap + //! holding a comment fails this, which is what keeps the comment where the author put it. + var blank = true + peek_data(src.text) $(bytes) { + for (i in range(max(from, 0), min(to, length(bytes)))) { + let c = int(bytes[i]) + if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { + blank = false + break + } + } + } + return blank +} diff --git a/utils/gen1-to-gen2/convert.das b/utils/gen1-to-gen2/convert.das new file mode 100644 index 0000000000..6c93ec1382 --- /dev/null +++ b/utils/gen1-to-gen2/convert.das @@ -0,0 +1,395 @@ +options gen2 +options indenting = 4 + +require daslib/ast +require daslib/rtti +require daslib/fio +require strings +require daslib/strings_boost +require offsets +require comments +require scan +require patch +require rules_make +require rules_stmt +require rules_decl + + +struct public ConvertOptions { + //! What the caller asked for. + v2 : bool = true //!< gen2 syntax (braces, parens); false stops at gen1.5 + semicolon : bool = false //!< keep the statement-terminating `;` + verify_compile : bool = false //!< compile the result as gen2 before handing it back + project : string //!< .das_project whose mount points the file's `require`s need +} + + +//! Offset of the file's `options gen2` statement, or -1. +//! +//! The compiler's own detector (`detectGen2Syntax`) scans the WHOLE file for the first one +//! outside a comment or a string, so a marker on line 12 counts exactly as much as one on +//! line 1 - and a rewriter that only looks at line 1 will contradict it. +def public gen2_marker(src : Source; lex : Lexical) : int { + return find_token(src, lex, 0, "options gen2") +} + + +def private rule_gen2_header(src : Source; lex : Lexical; file : string; opt : ConvertOptions; + var set : EditSet) { + if (file |> ends_with(".inc") || !opt.v2) return + let header = opt.semicolon ? "options gen2;" : "options gen2" + let marker = gen2_marker(src, lex) + if (marker >= 0) { + let line = line_at(src, marker) + let text = text_of(src, line_begin(src, line), line_end(src, line)) |> strip + if (text |> starts_with("options gen2 = false")) { + set |> replace(line_begin(src, line), line_end(src, line), header, "gen2-header") + } + return + } + set |> insert(0, "{header}{src.eol}", "gen2-header") +} + + +class ConvertVisitor : AstVisitor { + @do_not_delete src : Source const? + @do_not_delete lex : Lexical const? + edits : EditSet + file : string + opt = ConvertOptions() + wrapped : table + braced : table + dotted : table + + def override preVisitExprCall(expr : ExprCall?) { + if (opt.v2) { + rule_piped_make((*src), (*lex), expr, edits) + } + let open = rule_move_wrapper((*src), (*lex), expr, edits) + if (open >= 0) { + wrapped |> insert(open, true) + } + if (opt.v2) { + rule_type_function_call((*src), (*lex), expr, edits) + } + } + + def override preVisitExprMakeStruct(expr : ExprMakeStruct?) { + rule_make_struct((*src), (*lex), expr, is_wrapped(expr.at), edits) + } + + def override preVisitExprMakeArray(expr : ExprMakeArray?) { + rule_make_array((*src), (*lex), expr, is_wrapped(expr.at), edits) + } + + def override preVisitExprArrayComprehension(expr : ExprArrayComprehension?) { + rule_comprehension((*src), (*lex), expr, edits) + } + + def override preVisitExprCallMacro(expr : ExprCallMacro?) { + if (opt.v2) { + rule_call_macro_parens((*src), (*lex), expr, edits) + } + for (arg in expr.arguments) { + visit_owned(arg) + } + } + + def visit_owned(expr : ExpressionPtr) { + var sub = new ConvertVisitor(src = src, lex = lex, file = file, opt = opt) + make_visitor(*sub) $(adapter) { + visit(expr, adapter) + } + edits.edits |> push_from(sub.edits.edits) + edits.refused |> push_from(sub.edits.refused) + unsafe { + delete sub + } + } + + def override preVisitExprBlock(expr : ExprBlock?) { + if (!opt.v2 || expr.genFlags.generated) return + let key = span_begin((*src), expr.at) + if (key_exists(braced, key)) return + braced |> insert(key, true) + rule_block_braces((*src), (*lex), expr, edits) + for (arg in expr.arguments) { + rule_argument_annotation((*src), (*lex), arg.at, edits) + } + } + + def override preVisitExprCast(expr : ExprCast?) { + if (!opt.v2) return + rule_cast_parens((*src), (*lex), expr, edits) + } + + def override preVisitExprReturn(expr : ExprReturn?) { + if (!opt.v2) return + rule_return_tuple((*src), (*lex), expr, edits) + } + + def override preVisitExprConstEnumeration(expr : ExprConstEnumeration?) { + dot_constant(expr.at, expr.genFlags.generated) + } + + def override preVisitExprConstBitfield(expr : ExprConstBitfield?) { + dot_constant(expr.at, expr.genFlags.generated) + } + + def dot_constant(at : LineInfo; generated : bool) { + if (!opt.v2) return + let key = span_begin((*src), at) + if (key_exists(dotted, key)) return + dotted |> insert(key, true) + rule_enum_dot((*src), (*lex), at, generated, edits) + } + + def override preVisitExprLet(expr : ExprLet?) { + if (!opt.v2) return + rule_let_tuple((*src), (*lex), expr, edits) + rule_multiline_init((*src), (*lex), expr, edits) + } + + def override preVisitExprTypeInfo(expr : ExprTypeInfo?) { + if (!opt.v2) return + rule_typeinfo((*src), (*lex), expr, edits) + } + + def override preVisitExprIfThenElse(expr : ExprIfThenElse?) { + if (!opt.v2) return + rule_if_parens((*src), (*lex), expr, edits) + glue_else(expr) + } + + def override preVisitExprWhile(expr : ExprWhile?) { + if (!opt.v2) return + rule_while_parens((*src), (*lex), expr, edits) + } + + def override preVisitExprWith(expr : ExprWith?) { + if (!opt.v2) return + rule_with_parens((*src), (*lex), expr, edits) + } + + def override preVisitExprFor(expr : ExprFor?) { + if (!opt.v2) return + rule_for_parens((*src), (*lex), expr, edits) + } + + def override preVisitExprTryCatch(expr : ExprTryCatch?) { + if (!opt.v2 || expr.try_block == null || expr.catch_block == null) return + rule_glue_keyword((*src), block_close_at((*src), (*lex), expr.try_block.at), + span_begin((*src), expr.catch_block.at), "recover", is_braced((*src), expr.catch_block.at), edits) + } + + def glue_else(expr : ExprIfThenElse?) { + if (expr.if_true == null || expr.if_false == null) return + rule_glue_keyword((*src), block_close_at((*src), (*lex), expr.if_true.at), + span_begin((*src), expr.if_false.at), "else", is_braced((*src), expr.if_false.at), edits) + } + + def is_wrapped(at : LineInfo) : bool { + return wrapped ?[span_begin((*src), at)] ?? false + } +} + + +def private visit_once(var v : ConvertVisitor?; var fn : FunctionPtr; file : string; + var walked : table) { + if (fn.flags.builtIn || fn.flags.generated || !same_file(fn.at, file)) return + let key = "{int(fn.at.line)}:{int(fn.at.column)}" + if (key_exists(walked, key)) return + walked |> insert(key, true) + make_visitor(*v) $(adapter) { + visit(fn, adapter) + } +} + + +def private same_file(at : LineInfo; file : string) : bool { + if (at.fileInfo == null) return false + return normalize(string(at.fileInfo.name)) |> replace("\\", "/") == normalize(file) |> replace("\\", "/") +} + + +def private collect_declaration_edits(src : Source; lex : Lexical; var program : ProgramPtr; + file : string; var set : EditSet) { + for_each_structure(get_this_module(program)) $(var st) { + if (!same_file(st.at, file)) return + rule_decl_braces(src, lex, span_begin(src, st.at), set, true) + } + for_each_enumeration(get_this_module(program)) $(var en) { + if (!same_file(en.at, file)) return + rule_decl_braces(src, lex, span_begin(src, en.at), set, true) + } + var globalBlocks : table + for_each_global(get_this_module(program)) $(var gvar) { + if (!same_file(gvar.at, file)) return + let hdr = global_block_header(src, lex, span_begin(src, gvar.at)) + if (hdr >= 0 && !key_exists(globalBlocks, hdr)) { + globalBlocks |> insert(hdr, true) + rule_decl_braces(src, lex, hdr, set) + } + } + var typedefBlocks : table + for_each_typedef(get_this_module(program)) $(_name; var td) { + if (!same_file(td.at, file)) return + let at = span_begin(src, td.at) + rule_decl_braces(src, lex, at, set) + let hdr = typedef_block_header(src, lex, at) + if (hdr >= 0 && !key_exists(typedefBlocks, hdr)) { + typedefBlocks |> insert(hdr, true) + rule_typedef_block(src, lex, hdr, set) + } + } +} + + +def public collect_edits(src : Source; lex : Lexical; var program : ProgramPtr; file : string; + opt : ConvertOptions; var set : EditSet) { + //! Records every conversion for one file. Order of calls does not matter: edits are sorted + //! by offset when applied, and two rules that would fight over one range are refused there. + rule_gen2_header(src, lex, file, opt, set) + + var v = new ConvertVisitor() + unsafe { + v.src = addr(src) + v.lex = addr(lex) + } + v.file = file + v.opt = opt + var walked : table + for_each_generic(get_this_module(program), "") $(var fn) { + visit_once(v, fn, file, walked) + } + for_each_function(get_this_module(program), "") $(var fn) { + visit_once(v, fn, file, walked) + } + for_each_global(get_this_module(program)) $(var gvar) { + if (gvar.init == null || !same_file(gvar.at, file)) return + make_visitor(*v) $(adapter) { + visit(gvar.init, adapter) + } + } + if (opt.v2) { + collect_declaration_edits(src, lex, program, file, set) + } + set.edits |> push_from(v.edits.edits) + set.refused |> push_from(v.edits.refused) + unsafe { + delete v + } +} + + +struct public FileResult { + //! What one file's conversion produced: the text, plus why it was left alone. + file : string + changed : bool + skipped : string + failed : string + refused : array + output : string +} + + +def public compiles_as_gen2(near : string; text : string; var issues_out : string&; project : string = "") : bool { + //! Compiles converted text as gen2 — the check that the rewrite produced real daslang. + //! + //! It goes through a file beside the original rather than through `compile`, because the + //! text-only entry gets no module group and would report daslib's own generics as missing. + //! The scratch file is removed either way. + let probe = "{dir_name(near)}/.gen2_verify_{base_name(near)}" + if (!fwrite(probe, text)) { + issues_out = "could not write {probe}" + return false + } + var ok_out = false + var inscope access <- make_file_access(project) + using() $(var mg : ModuleGroup) { + using() $(var cop : CodeOfPolicies) { + cop.ignore_shared_modules = true + cop.export_all = true + cop.version_2_syntax = true + cop.no_optimizations = true + compile_file(probe, access, unsafe(addr(mg)), cop) $(ok; _program; issues) { + ok_out = ok + issues_out = string(issues) + } + } + } + remove(probe) + return ok_out +} + + +def public convert_file(file : string; opt : ConvertOptions) : FileResult { + //! Converts one file and returns the result; writes nothing. + var res = FileResult(file = file) + let text = fread(file) + if (empty(text)) { + res.skipped = "empty or unreadable" + return <- res + } + let src = make_source(text) + let lex <- scan_lexical(src) + let marker = gen2_marker(src, lex) + if (marker >= 0) { + let mline = line_at(src, marker) + if (!(text_of(src, line_begin(src, mline), line_end(src, mline)) |> strip + |> starts_with("options gen2 = false"))) { + res.skipped = "already gen2" + res.output = text + return <- res + } + } + if (text |> find("%spoof_template~") >= 0) { + res.skipped = "contains spoof templates" + res.output = text + return <- res + } + var set : EditSet + var collected = false + var inscope access <- make_file_access(opt.project) + using() $(var mg : ModuleGroup) { + using() $(var cop : CodeOfPolicies) { + cop.ignore_shared_modules = true + cop.export_all = true + cop.version_2_syntax = false + cop.no_optimizations = true + parse_file(file, access, unsafe(addr(mg)), cop) $(ok; program; issues) { + if (!ok) { + res.failed = empty(string(issues)) ? "parse failed" : string(issues) + return + } + collect_edits(src, lex, program, file, opt, set) + collected = true + } + } + } + if (!collected) { + if (empty(res.failed)) { + res.failed = "parse failed" + } + return <- res + } + res.output = apply(src, lex, set) + res.refused <- set.refused + let conserved = check_comments_preserved(text, res.output) + if (!conserved.ok) { + res.failed = "comment conservation: {conserved.detail}" + res.output = text + return <- res + } + res.changed = res.output != text + if (opt.verify_compile && res.changed) { + var issues = "" + if (!compiles_as_gen2(file, res.output, issues, opt.project)) { + if (issues |> find("missing prerequisite") < 0 && issues |> find("not found") < 0) { + res.failed = "converted output does not compile: {issues}" + res.output = text + } + } + } + return <- res +} diff --git a/utils/gen1-to-gen2/extent.das b/utils/gen1-to-gen2/extent.das new file mode 100644 index 0000000000..c70a59b0b1 --- /dev/null +++ b/utils/gen1-to-gen2/extent.das @@ -0,0 +1,219 @@ +options gen2 +options indenting = 4 +options rtti = true +options strict_smart_pointers = false + +require daslib/ast +require daslib/ast_boost +require math +require strings +require daslib/strings_boost +require offsets +require comments +require scan + + +struct public Extent { + from : int + to : int + ok : bool +} + + +class private ExtentVisitor : AstVisitor { + @do_not_delete src : Source const? + @do_not_delete lex : Lexical const? + from : int = 0 + to : int = 0 + seen : bool = false + + def take(at : LineInfo) { + if (at.fileInfo == null) return + let a = span_begin((*src), at) + let b = span_end((*src), at) + if (b <= a) return + if (!seen) { + from = a + to = b + seen = true + return + } + from = min(from, a) + to = max(to, b) + } + + def override preVisitExpression(expr : ExpressionPtr) { + take(expr.at) + } + + def override preVisitExprCall(expr : ExprCall?) { + take(expr.at) + take(expr.atEnclosure) + } + + def override preVisitExprLooksLikeCall(expr : ExprLooksLikeCall?) { + take(expr.at) + take(expr.atEnclosure) + } + + def override preVisitExprStringBuilder(expr : ExprStringBuilder?) { + take(expr.at) + let litFrom = span_begin((*src), expr.at) + for (str in (*lex).strings) { + if (str.from > litFrom) break + if (str.to > litFrom && str.to > to) { + to = str.to + } + } + } + + def override preVisitExprField(expr : ExprField?) { + take(expr.at) + take(expr.atField) + } + + def reach_field(at : LineInfo) { + let e = ident_after((*src), span_end((*src), at)) + if (e > to) { + to = e + } + } + + def override preVisitExprIsVariant(expr : ExprIsVariant?) { + take(expr.at) + reach_field(expr.at) + } + + def override preVisitExprAsVariant(expr : ExprAsVariant?) { + take(expr.at) + reach_field(expr.at) + } + + def override preVisitExprSafeAsVariant(expr : ExprSafeAsVariant?) { + take(expr.at) + reach_field(expr.at) + } + + def override preVisitExprTypeInfo(expr : ExprTypeInfo?) { + take(expr.at) + let after = span_end((*src), expr.at) + let lp = find_token((*src), (*lex), after, "(") + if (lp < 0 || text_of((*src), after, lp) |> find("\n") >= 0) return + let rp = paren_close((*src), (*lex), lp) + if (rp >= 0) { + to = max(to, rp + 1) + } + } + + def take_make_closer(at : LineInfo) { + let open = span_begin((*src), at) + let two = text_of((*src), open, open + 2) + let one = text_of((*src), open, open + 1) + var closer = -1 + if (two == "[[") { + closer = find_closer((*src), (*lex), open + 2, "]]") + if (closer >= 0) { closer += 2 } + } elif (two == "[\{") { + closer = find_closer((*src), (*lex), open + 2, "\}]") + if (closer >= 0) { closer += 2 } + } elif (two == "\{\{") { + closer = find_closer((*src), (*lex), open + 2, "\}\}") + if (closer >= 0) { closer += 2 } + } elif (one == "[") { + closer = group_close((*src), (*lex), open, "[", "]") + if (closer >= 0) { closer++ } + } elif (one == "\{") { + closer = group_close((*src), (*lex), open, "\{", "\}") + if (closer >= 0) { closer++ } + } + if (closer > to) { + to = closer + } + } + + def override preVisitExprMakeArray(expr : ExprMakeArray?) { + take(expr.at) + take_make_closer(expr.at) + } + + def override preVisitExprMakeStruct(expr : ExprMakeStruct?) { + take(expr.at) + take_make_closer(expr.at) + } + + def override visitExprAt(var expr : ExprAt?) : ExpressionPtr { + let ie = extent_of((*src), (*lex), expr.index) + if (!ie.ok) return expr + let closer = find_token((*src), (*lex), ie.to, "]") + if (closer >= 0) { + to = max(to, closer + 1) + } + return expr + } +} + + +class private BlockFinder : AstVisitor { + found : bool = false + + def override preVisitExprBlock(expr : ExprBlock?) { + found = true + } +} + + +def public contains_block(expr : ExpressionPtr) : bool { + //! True when the expression carries a block of its own - a piped `$ [es] (...)` body, a + //! lambda. Its lines are that block's statements, not continuations of the expression. + if (expr == null) return false + var v = new BlockFinder() + make_visitor(*v) $(adapter) { + visit(expr, adapter) + } + let found = v.found + unsafe { + delete v + } + return found +} + + +def private ident_after(src : Source; from : int) : int { + var i = from + var e = from + peek_data(src.text) $(bytes) { + let n = length(bytes) + while (i < n) { + let c = int(bytes[i]) + if (c != ' ' && c != '\t') break + i++ + } + var j = i + while (j < n) { + let c = int(bytes[j]) + if (!is_alpha(c) && !is_number(c) && c != '_') break + j++ + } + e = j > i ? j : from + } + return e +} + + +def public extent_of(src : Source; lex : Lexical; expr : ExpressionPtr) : Extent { + //! The source range an expression covers, anchors unioned over the whole subtree. + if (expr == null) return Extent(ok = false) + var v = new ExtentVisitor() + unsafe { + v.src = addr(src) + v.lex = addr(lex) + } + make_visitor(*v) $(adapter) { + visit(expr, adapter) + } + let result = Extent(from = v.from, to = v.to, ok = v.seen) + unsafe { + delete v + } + return result +} diff --git a/utils/gen1-to-gen2/main.das b/utils/gen1-to-gen2/main.das new file mode 100644 index 0000000000..3bd422c429 --- /dev/null +++ b/utils/gen1-to-gen2/main.das @@ -0,0 +1,114 @@ +options gen2 +options indenting = 4 +options rtti = true +options strict_smart_pointers = false + +require daslib/clargs +require daslib/ast +require daslib/rtti +require daslib/fio +require convert + +//! v1 -> gen2 syntax converter. +//! +//! Reads the file once, parses it with infer off (the tree still mirrors the source), collects +//! every rewrite as an edit in original byte offsets, and applies them in a single forward walk. +//! Nothing is re-parsed and no offset is ever adjusted, so a file is converted in one pass. +//! +//! A comment is the one thing no tool can regenerate, so the output is rejected outright if its +//! comment sequence differs from the input's. + +[CommandLineArgs] +struct Config { + @clarg_short = "p" + @clarg_doc = "File(s) to convert. Repeatable." + path : array + + @clarg_short = "i" + @clarg_doc = "Rewrite the file in place (default: print to stdout)" + inplace : bool + + @clarg_doc = "Keep the statement-terminating ';'" + semicolon : bool + + @clarg_name = "gen15" + @clarg_doc = "Convert to gen1.5 only: make-syntax, no braces or parens" + gen15 : bool + + @clarg_doc = "Report what a run would change, write nothing" + verify : bool + + @clarg_doc = ".das_project whose mount points the converted file's `require`s need" + project : string + + @clarg_name = "verify-compile" + @clarg_doc = "Compile the converted text as gen2 and fail the file if it does not" + verify_compile : bool + + @clarg_short = "?" + @clarg_name = "show-help" + @clarg_doc = "Show this help and exit" + help : bool +} + + +[export] +def main : int { + var args_r <- parse_args(type) + if (args_r |> is_err) { + to_log(LOG_ERROR, "error: {args_r |> unwrap_err}\n\n") + print_help(get_command_info(type), "gen1-to-gen2") + return 1 + } + var cfg <- args_r |> move_unwrap + if (cfg.help || empty(cfg.path)) { + print_help(get_command_info(type), "gen1-to-gen2") + return cfg.help ? 0 : 1 + } + if (length(cfg.path) > 1 && !cfg.inplace && !cfg.verify) { + to_log(LOG_ERROR, "error: more than one file needs --inplace or --verify\n") + return 1 + } + + let opt = ConvertOptions(v2 = !cfg.gen15, semicolon = cfg.semicolon, + verify_compile = cfg.verify_compile, project = cfg.project) + var rc = 0 + var n_changed = 0 + for (file in cfg.path) { + let res <- convert_file(file, opt) + for (r in res.refused) { + to_log(LOG_ERROR, "{file}: refused {r}\n") + } + if (!empty(res.failed) || !empty(res.refused)) { + if (!empty(res.failed)) { + to_log(LOG_ERROR, "{file}: {res.failed}\n") + } + rc = 1 + continue + } + if (!empty(res.skipped)) { + to_log(LOG_INFO, "{file}: skipped ({res.skipped})\n") + if (!cfg.verify && !cfg.inplace) { + print("{res.output}") + } + continue + } + if (res.changed) { + n_changed++ + } + if (cfg.verify) { + to_log(LOG_INFO, "{file}: {res.changed ? "would change" : "unchanged"}\n") + } elif (cfg.inplace) { + if (res.changed) { + fwrite(file, res.output) + to_log(LOG_INFO, "{file}: converted\n") + } + } else { + print("{res.output}") + } + } + if (cfg.verify) { + to_log(LOG_INFO, "{n_changed} of {length(cfg.path)} file(s) would change\n") + } + return rc +} diff --git a/utils/gen1-to-gen2/offsets.das b/utils/gen1-to-gen2/offsets.das new file mode 100644 index 0000000000..152844d62f --- /dev/null +++ b/utils/gen1-to-gen2/offsets.das @@ -0,0 +1,141 @@ +options gen2 +options indenting = 4 + +require daslib/rtti +require math +require strings + +//! Source text addressed by absolute byte offset. +//! +//! Every span in this tool is an offset pair into ONE immutable source string. `LineInfo` +//! (1-based line, 0-based byte column, end-exclusive) is converted once, up front, so no +//! analysis step ever does line/column arithmetic — and no offset is ever adjusted, because +//! nothing is written until the whole patch set is built. + +struct public Source { + //! An immutable source text plus its line index. + text : string + lineStart : array + size : int = 0 + eol : string = "\n" +} + + +def public make_source(text : string) : Source { + //! Builds the line index for `text`. O(n), once per file. + var src = Source(text = text, size = length(text)) + src.lineStart |> push(0) + peek_data(text) $(bytes) { + for (i in range(length(bytes))) { + if (bytes[i] == uint8('\n')) { + if (i > 0 && bytes[i - 1] == uint8('\r')) { + src.eol = "\r\n" + } + src.lineStart |> push(i + 1) + } + } + } + return <- src +} + + +def public line_count(src : Source) : int { + //! Number of lines in the source. + return length(src.lineStart) +} + + +def public line_begin(src : Source; line : int) : int { + //! Offset of the first byte of `line` (1-based). Clamped to the source. + if (line < 1) return 0 + if (line > length(src.lineStart)) return src.size + return src.lineStart[line - 1] +} + + +def public line_end(src : Source; line : int) : int { + //! Offset one past the last byte of `line`, excluding the newline. Clamped. + if (line < 1) return 0 + if (line >= length(src.lineStart)) return src.size + var e = src.lineStart[line] - 1 + if (e > 0 && e <= src.size) { + peek_data(src.text) $(bytes) { + if (e - 1 < length(bytes) && bytes[e - 1] == uint8('\r')) { + e-- + } + } + } + return max(e, 0) +} + + +def public offset_of(src : Source; line, column : int) : int { + //! Absolute offset of a (1-based line, 0-based byte column) position. + //! + //! Columns are clamped to the line's end: v1 block spans routinely report one column past + //! the last line's end (the lexer's synthesized statement terminator), and a rewriter must + //! not address past the text it was handed. + let b = line_begin(src, line) + let e = line_end(src, line) + let p = b + max(column, 0) + return min(p, e) +} + + +def public span_begin(src : Source; at : LineInfo) : int { + //! Start offset of `at`. + return offset_of(src, int(at.line), int(at.column)) +} + + +def public span_end(src : Source; at : LineInfo) : int { + //! End offset of `at` (exclusive). + return offset_of(src, int(at.last_line), int(at.last_column)) +} + + +def public text_of(src : Source; from, to : int) : string { + //! The source bytes in [from, to). Empty when the range is degenerate. + let a = clamp(from, 0, src.size) + let b = clamp(to, a, src.size) + return a == b ? "" : slice(src.text, a, b) +} + + +def public text_at(src : Source; at : LineInfo) : string { + //! The source bytes covered by `at`. + return text_of(src, span_begin(src, at), span_end(src, at)) +} + + +def public indent_of(src : Source; offset : int) : int { + //! Width of the leading whitespace on the line containing `offset`, tabs counted as one. + let ln = line_at(src, offset) + let b = line_begin(src, ln) + let e = line_end(src, ln) + var n = 0 + peek_data(src.text) $(bytes) { + for (i in range(b, e)) { + if (bytes[i] != uint8(' ') && bytes[i] != uint8('\t')) break + n++ + } + } + return n +} + + +def public line_at(src : Source; offset : int) : int { + //! 1-based line containing `offset`. Binary search over the line index. + if (offset <= 0) return 1 + var lo = 0 + var hi = length(src.lineStart) - 1 + while (lo < hi) { + let mid = (lo + hi + 1) / 2 + if (src.lineStart[mid] <= offset) { + lo = mid + } else { + hi = mid - 1 + } + } + return lo + 1 +} diff --git a/utils/gen1-to-gen2/patch.das b/utils/gen1-to-gen2/patch.das new file mode 100644 index 0000000000..b9e75caf59 --- /dev/null +++ b/utils/gen1-to-gen2/patch.das @@ -0,0 +1,142 @@ +options gen2 +options indenting = 4 + +require strings +require offsets +require comments + + +enum public EditKind { + //! What an edit does to its range — the engine checks each kind differently. + INSERT //!< zero-length: text goes in at `from` + REPLACE //!< [from, to) becomes `text`; may carry comments through in `text` + DELETE //!< [from, to) goes away; refused if it holds a comment or string +} + +struct public Edit { + //! One rewrite in original coordinates. + from : int + to : int + text : string + kind : EditKind = EditKind.INSERT + rank : int = RANK_CLOSE_INNER + rule : string + origin : int = -1 +} + +let public RANK_CLOSE_INNER = 0 +let public RANK_CLOSE_OUTER = 10 +let public RANK_BLOCK_OPEN = 15 +let public RANK_TERMINATOR = 20 + +struct public EditSet { + //! Edits plus whatever the engine refused, with the reason. + edits : array + refused : array +} + + +def private push_edit(var set : EditSet; e : Edit) { + for (x in set.edits) { + if (x.from == e.from && x.to == e.to && x.kind == e.kind && x.rank == e.rank + && x.origin == e.origin && x.rule == e.rule && x.text == e.text) return + } + set.edits |> push(e) +} + + +def public insert(var set : EditSet; at : int; text : string; rule : string; + rank : int = RANK_CLOSE_INNER; origin : int = -1) { + //! Records "put `text` at `at`". Independent of how much the surrounding text grows. + //! + //! `origin` is the start of the construct being closed; two closers landing on one offset + //! use it to nest correctly. + set |> push_edit(Edit(from = at, to = at, text = text, kind = EditKind.INSERT, rank = rank, + rule = rule, origin = origin)) +} + + +def public replace(var set : EditSet; from, to : int; text : string; rule : string; rank : int = RANK_CLOSE_INNER) { + //! Records "[from, to) becomes `text`". Use for rearrangement: the comments of the old + //! range have to reappear in `text`, and the conservation gate checks that they do. + set |> push_edit(Edit(from = from, to = to, text = text, kind = EditKind.REPLACE, rank = rank, rule = rule)) +} + + +def public remove(var set : EditSet; from, to : int; rule : string; rank : int = RANK_CLOSE_INNER) { + //! Records "[from, to) goes away". Only for delimiter and keyword tokens — `apply` refuses + //! a deletion that would take a comment or a string literal with it. + set |> push_edit(Edit(from = from, to = to, text = "", kind = EditKind.DELETE, rank = rank, rule = rule)) +} + + +def private before(a, b : Edit) : bool { + if (a.from != b.from) return a.from < b.from + let aInsert = a.to == a.from + let bInsert = b.to == b.from + if (aInsert != bInsert) return aInsert + if (a.to != b.to) return a.to > b.to + if (a.rank != b.rank) return a.rank < b.rank + return a.origin > b.origin +} + + +def public apply(src : Source; lex : Lexical; var set : EditSet) : string { + //! Emits the rewritten source: one forward walk over the original, substituting edits. + //! + //! Two edits that overlap without nesting are a contradiction, not something to merge — + //! the later one is refused and reported. A deletion that holds a comment is refused the + //! same way, so a rule can never lose a comment by widening its range. + var ordered <- [for (e in set.edits); e] + sort(ordered) $(a, b) => before(a, b) + + return build_string() $(writer) { + var cursor = 0 + var prev = "" + for (e in ordered) { + if (e.from < cursor) { + set.refused |> push("{e.rule}: edit at {e.from}..{e.to} overlaps an earlier edit {prev} (cursor {cursor})") + continue + } + if (e.kind == EditKind.DELETE && has_comment_or_string(lex, e.from, e.to)) { + set.refused |> push("{e.rule}: deletion of {e.from}..{e.to} would remove a comment or string") + continue + } + writer |> write(text_of(src, cursor, e.from)) + writer |> write(e.text) + cursor = e.to + prev = "{e.rule}[{e.from}..{e.to}]" + } + writer |> write(text_of(src, cursor, src.size)) + } +} + + +struct public Conservation { + //! Result of the comment-conservation gate. + ok : bool + detail : string +} + + +def public check_comments_preserved(before_text, after_text : string) : Conservation { + //! Every comment of the input must appear in the output, in the same order, once each. + //! + //! This is a release gate rather than a diagnostic: a comment is the one thing no tool can + //! regenerate. It catches loss, duplication (a rule emitting a range twice) and reordering + //! in a single comparison. Comments may MOVE to an adjacent anchor — the text is compared, + //! not the position. + let src_before = make_source(before_text) + let src_after = make_source(after_text) + let was <- comment_texts(src_before, scan_lexical(src_before)) + let now <- comment_texts(src_after, scan_lexical(src_after)) + if (length(was) != length(now)) { + return Conservation(ok = false, detail = "comment count {length(was)} -> {length(now)}") + } + for (i in range(length(was))) { + if (was[i] != now[i]) { + return Conservation(ok = false, detail = "comment {i + 1} changed: '{was[i]}' -> '{now[i]}'") + } + } + return Conservation(ok = true, detail = "") +} diff --git a/utils/gen1-to-gen2/rules_decl.das b/utils/gen1-to-gen2/rules_decl.das new file mode 100644 index 0000000000..a00e4e6575 --- /dev/null +++ b/utils/gen1-to-gen2/rules_decl.das @@ -0,0 +1,217 @@ +options gen2 +options indenting = 4 + +require daslib/ast +require strings +require daslib/strings_boost +require offsets +require comments +require scan +require patch + + +def private body_last_line(src : Source; lex : Lexical; headerLine, headerIndent : int) : int { + var last = -1 + var ln = headerLine + 1 + while (ln <= line_count(src)) { + if (!line_has_code(src, lex, ln)) { + ln++ + continue + } + if (indent_of(src, line_begin(src, ln)) <= headerIndent) break + last = ln + ln++ + } + return last +} + + +def private braced_body_follows(src : Source; headerLine : int) : bool { + var ln = headerLine + 1 + while (ln <= line_count(src)) { + let b = line_begin(src, ln) + let e = line_end(src, ln) + if (is_blank(src, b, e)) { + ln++ + continue + } + let first = b + indent_of(src, b) + return text_of(src, first, first + 1) == "\{" + } + return false +} + + +def public rule_decl_braces(src : Source; lex : Lexical; headerOffset : int; var set : EditSet; + bodyless : bool = false) { + //! Wraps an indent-delimited declaration body in braces. + //! + //! Declines when the header line already carries a `{`, so a file that is half converted + //! (or was always gen2) is left alone. `bodyless` says the declaration needs a body in gen2 + //! even when v1 wrote none - a struct or an enum, but not a typedef. + let headerLine = line_at(src, headerOffset) + let headerEnd = line_end(src, headerLine) + if (text_of(src, line_begin(src, headerLine), headerEnd) |> find("\{") >= 0) return + let headerIndent = indent_of(src, line_begin(src, headerLine)) + let last = body_last_line(src, lex, headerLine, headerIndent) + if (last < 0) { + if (bodyless && !braced_body_follows(src, headerLine)) { + set |> insert(line_edge(src, lex, headerOffset), " \{\}", "decl-empty", + RANK_BLOCK_OPEN, headerOffset) + } + return + } + let brace = line_edge(src, lex, headerOffset) + set |> insert(brace, " \{", "decl-open", RANK_BLOCK_OPEN, headerOffset) + set |> insert(line_end(src, last), "{src.eol}{repeat(" ", headerIndent)}\}", "decl-close", + RANK_CLOSE_OUTER, headerOffset) +} + + +def private is_global_header(text : string) : bool { + var first = true + var ok = false + for (w in text |> replace("\t", " ") |> split(" ")) { + if (w |> empty) continue + if (first) { + if (w != "let" && w != "var") return false + first = false + ok = true + } elif (w != "shared" && w != "public" && w != "private") { + return false + } + } + return ok +} + + +def public global_block_header(src : Source; lex : Lexical; varOffset : int) : int { + //! Offset of the bare `let`/`var` line heading the block that `varOffset` belongs to, or -1. + //! + //! A global's `at` is its NAME, so `let x = 1` finds the keyword on its own line: only a + //! header that declares nothing of its own opens an indented block. + let varLine = line_at(src, varOffset) + let varIndent = indent_of(src, line_begin(src, varLine)) + var ln = varLine - 1 + while (ln >= 1) { + let b = line_begin(src, ln) + let e = line_end(src, ln) + if (is_blank(src, b, e)) { + ln-- + continue + } + if (indent_of(src, b) >= varIndent) { + ln-- + continue + } + return is_global_header(text_of(src, b, line_edge(src, lex, b)) |> strip) ? b : -1 + } + return -1 +} + + +def public typedef_block_header(src : Source; lex : Lexical; aliasOffset : int) : int { + //! Offset of the bare `typedef` line heading the block that `aliasOffset` belongs to, or -1. + //! + //! The tree records only the aliased TYPE, so the header is found by walking back over the + //! block's own lines — the first shallower line above them is the header or nothing is. + let aliasLine = line_at(src, aliasOffset) + let aliasIndent = indent_of(src, line_begin(src, aliasLine)) + var ln = aliasLine - 1 + while (ln >= 1) { + let b = line_begin(src, ln) + let e = line_end(src, ln) + if (is_blank(src, b, e)) { + ln-- + continue + } + if (indent_of(src, b) >= aliasIndent) { + ln-- + continue + } + return text_of(src, b, line_edge(src, lex, b)) |> strip == "typedef" ? b : -1 + } + return -1 +} + + +def public rule_typedef_block(src : Source; lex : Lexical; headerOffset : int; var set : EditSet) { + //! `typedef` + indented `A = B` lines becomes one `typedef A = B` per line. + //! + //! The bare `typedef` line goes away, which is a deletion — so a comment parked on it makes + //! the engine refuse the edit and the block is left as it is. + let headerLine = line_at(src, headerOffset) + let headerStart = line_begin(src, headerLine) + let headerText = text_of(src, headerStart, line_edge(src, lex, headerStart)) |> strip + if (headerText != "typedef") return + let headerIndent = indent_of(src, headerStart) + let last = body_last_line(src, lex, headerLine, headerIndent) + if (last < 0) return + set |> remove(headerStart, line_begin(src, headerLine + 1), "typedef-header") + for (ln in range(headerLine + 1, last + 1)) { + let b = line_begin(src, ln) + let e = line_end(src, ln) + if (is_blank(src, b, e)) continue + let firstChar = b + indent_of(src, b) + set |> replace(b, firstChar, "{repeat(" ", headerIndent)}typedef ", "typedef-line") + } +} + + +def private skip_back_blank(src : Source; from : int) : int { + var i = from + peek_data(src.text) $(bytes) { + while (i > 0) { + let c = int(bytes[i - 1]) + if (c != ' ' && c != '\t' && c != '\r' && c != '\n') break + i-- + } + } + return i +} + + +def private find_back(src : Source; lex : Lexical; from : int; token : string) : int { + let n = length(token) + var found = -1 + peek_data(src.text) $(bytes) { + peek_data(token) $(needle) { + var i = from - n + while (i >= 0) { + var hit = true + for (k in range(n)) { + if (bytes[i + k] != needle[k]) { + hit = false + break + } + } + if (hit && !has_comment_or_string(lex, i, i + n)) { + found = i + break + } + i-- + } + } + } + return found +} + + +def public rule_argument_annotation(src : Source; lex : Lexical; at : LineInfo; var set : EditSet) { + //! `[[optional]] var i : int?` -> `@optional var i : int?`. + var i = span_begin(src, at) + if (i <= 0) return + i = skip_back_blank(src, i) + if (i >= 3 && text_of(src, i - 3, i) == "var") { + i = skip_back_blank(src, i - 3) + } + if (i < 2 || text_of(src, i - 2, i) != "]]") return + let close = i - 2 + let open = find_back(src, lex, close, "[[") + if (open < 0) return + let body = text_of(src, open + 2, close) + if (empty(body |> strip) || has_comment_or_string(lex, open, close + 2)) return + let glued = text_of(src, close + 2, close + 3) + let pad = (glued == "" || glued == " " || glued == "\t" || glued == "\r" || glued == "\n") ? "" : " " + set |> replace(open, close + 2, "@{body}{pad}", "argument-annotation") +} diff --git a/utils/gen1-to-gen2/rules_make.das b/utils/gen1-to-gen2/rules_make.das new file mode 100644 index 0000000000..78173aa5f2 --- /dev/null +++ b/utils/gen1-to-gen2/rules_make.das @@ -0,0 +1,359 @@ +options gen2 +options indenting = 4 + +require daslib/ast +require math +require strings +require daslib/strings_boost +require offsets +require comments +require extent +require patch +require scan + + +struct private TypeParts { + text : string + lead : string + trail : string + ok : bool +} + + +def private split_type(src : Source; lex : Lexical; msd : ExprMakeStruct?; limit : int) : TypeParts { + var parts = TypeParts(ok = false) + let open = span_begin(src, msd.at) + let typeStart = span_begin(src, msd.makeType.at) + if (typeStart < open + 2 || typeStart >= limit) return parts + let typeEnd = end_of_type_token(src, typeStart, limit) + if (typeEnd <= typeStart) return parts + parts.text = text_of(src, typeStart, typeEnd) + parts.lead = text_of(src, open + 2, typeStart) + var rest = text_of(src, typeEnd, limit) + if (msd.makeStructFlags.useInitializer) { + let lp = find_token(src, lex, typeEnd, "(") + let rp = lp >= 0 ? find_token(src, lex, lp + 1, ")") : -1 + if (lp >= 0 && rp > lp && rp < limit) { + parts.lead += text_of(src, typeEnd, lp) + text_of(src, lp + 1, rp) + rest = text_of(src, rp + 1, limit) + } + } + parts.trail = rest + parts.ok = true + return parts +} + + +def private instance_range(src : Source; lex : Lexical; st : MakeStruct?; var from, to : int&) : bool { + var seen = false + for (fld in *st) { + if (!seen) { + from = span_begin(src, fld.at) + seen = true + } + let ext = fld.value != null ? extent_of(src, lex, fld.value) : Extent(ok = false) + to = ext.ok ? ext.to : (fld.value != null ? span_end(src, fld.value.at) : span_end(src, fld.at)) + } + return seen +} + + +def private call_name(typeText : string) : string { + return typeText |> ends_with("#") ? "struct<{typeText}>" : typeText +} + + +def public rule_make_struct(src : Source; lex : Lexical; msd : ExprMakeStruct?; wrapped : bool; + var set : EditSet) { + //! `[[Foo ...]]` in every shape the v1 grammar allows. + //! + //! `wrapped` means the node sits inside `[{ ... }]`, whose own rule owns the brackets: this + //! one then emits only the instance list, so `[{Foo a=1; a=2}]` becomes `[Foo(a=1), Foo(a=2)]` + //! rather than a nested `fixed_array`. + let open = span_begin(src, msd.at) + let opener = text_of(src, open, open + 2) + if (opener != "[[" && !(wrapped && opener == "[\{")) return + let closer = find_closer(src, lex, open + 2, wrapped ? "\}]" : "]]") + if (closer < 0) { + set.refused |> push("make-struct at {open}: no matching closer") + return + } + let nInstances = length(msd.structs) + let editFrom = wrapped ? open + 2 : open + + if (nInstances == 0) { + let parts = split_type(src, lex, msd, closer) + if (!parts.ok) { + set.refused |> push("make-struct at {open}: type spelling not found") + return + } + if (!wrapped && msd.makeType != null && parts.text |> ends_with("?")) { + set |> replace(open, closer + 2, "default<{parts.text}>{parts.lead}{parts.trail}", "make-struct-ptr") + return + } + set |> replace(editFrom, wrapped ? closer : closer + 2, + "{parts.lead}{call_name(parts.text)}({parts.trail})", "make-struct-empty") + return + } + + var firstFrom = 0 + var firstTo = 0 + if (!instance_range(src, lex, msd.structs[0], firstFrom, firstTo)) { + set.refused |> push("make-struct at {open}: first instance has no fields") + return + } + let parts = split_type(src, lex, msd, firstFrom) + if (!parts.ok) { + set.refused |> push("make-struct at {open}: type spelling not found") + return + } + let body = "{parts.lead}{call_name(parts.text)}({parts.trail}" + let head = (nInstances > 1 && !wrapped) ? "fixed_array({body}" : body + set |> replace(editFrom, firstFrom, head, "make-struct-open") + + var prevTo = firstTo + for (i in range(1, nInstances)) { + var from = 0 + var to = 0 + if (!instance_range(src, lex, msd.structs[i], from, to)) { + set.refused |> push("make-struct at {open}: instance {i} has no fields") + return + } + let semi = find_token(src, lex, prevTo, ";") + if (semi < 0 || semi >= from) { + set.refused |> push("make-struct at {open}: no ';' between instances") + return + } + set |> replace(semi, semi + 1, "), {call_name(parts.text)}(", "make-struct-next") + prevTo = to + } + if (wrapped) { + set |> insert(closer, ")", "make-struct-close") + return + } + set |> replace(closer, closer + 2, nInstances > 1 ? "))" : ")", "make-struct-close", RANK_CLOSE_OUTER) +} + + +def private is_make_tuple(e : ExpressionPtr) : bool { + return e.__rtti == "ExprMakeTuple" +} + + +def public rule_make_array(src : Source; lex : Lexical; mka : ExprMakeArray?; wrapped : bool; + var set : EditSet) { + //! `[[auto 1; 2]]` -> `fixed_array(1, 2)`, and the one-value tuple form `[[auto 1, 2]]`. + //! + //! The gen2 spelling of a make-array is a call, so the `;` separators become `,`. A single + //! value that is itself a tuple is the `[[auto a, b]]` form, which is just parentheses. + if (mka.gen2) return + let open = span_begin(src, mka.at) + let opener = text_of(src, open, open + 2) + if (opener != "[[" && !wrapped) return + let closerText = opener == "[\{" ? "\}]" : (opener == "\{\{" ? "\}\}" : "]]") + let closer = find_closer(src, lex, open + 2, closerText) + if (closer < 0) { + set.refused |> push("make-array at {open}: no matching closer") + return + } + let editFrom = wrapped ? open + 2 : open + let n = length(mka.values) + let firstAt = n > 0 ? span_begin(src, mka.values[0].at) : closer + let leadType = lead_type_text(src, lex, open + 2, firstAt) + let typed = opener != "\{\{" && !empty(leadType) && !(leadType |> starts_with("auto")) + let head = typed ? typed_head(src, lex, open, firstAt) : TypedHead() + if (typed && !head.ok) { + set.refused |> push("make-array at {open}: element type spelling not found") + return + } + if (n == 0) { + if (wrapped) return + set |> replace(open, closer + 2, "fixed_array({text_of(src, open + 2, closer)})", "make-array-empty") + return + } + let firstFrom = span_begin(src, mka.values[0].at) + let single_tuple = n == 1 && is_make_tuple(mka.values[0]) + let lead = lead_text(src, lex, open + 2, firstFrom) + if (wrapped) { + set |> replace(editFrom, firstFrom, typed ? head.gap : lead, "make-array-open") + } elif (typed) { + set |> replace(open, firstFrom, "fixed_array<{head.text}>({head.gap}", "make-array-open") + } else { + set |> replace(open, firstFrom, single_tuple ? "{lead}(" : "fixed_array({lead}", "make-array-open") + } + let ends <- separators(src, lex, mka, closer, set) + if (!(single_tuple && !wrapped) && opener != "\{\{") { + tuple_parens(src, mka, ends, set) + } + drop_trailing_separator(src, closer, set) + if (!wrapped) { + set |> replace(closer, closer + 2, ")", "make-array-close", RANK_CLOSE_OUTER) + } +} + + +def private lead_text(src : Source; lex : Lexical; from, to : int) : string { + let raw = text_of(src, from, to) + let autoAt = find_token(src, lex, from, "auto") + if (autoAt < 0 || autoAt >= to) return raw + let autoEnd = end_of_type_token(src, autoAt, to) + return text_of(src, from, autoAt) + text_of(src, autoEnd, to) +} + + +struct private TypedHead { + text : string + gap : string + ok : bool +} + + +def private typed_head(src : Source; lex : Lexical; open, firstAt : int) : TypedHead { + let typeStart = skip_blank_and_comments(src, lex, open + 2, firstAt) + let typeEnd = end_of_type_token(src, typeStart, firstAt) + if (typeEnd <= typeStart) return TypedHead(ok = false) + return TypedHead(text = text_of(src, typeStart, typeEnd), + gap = text_of(src, open + 2, typeStart) + text_of(src, typeEnd, firstAt), ok = true) +} + + +def private skip_blank_and_comments(src : Source; lex : Lexical; from, to : int) : int { + var i = max(from, 0) + while (i < to) { + var jumped = false + for (c in lex.comments) { + if (c.from > i) break + if (c.from == i && c.to <= to) { + i = c.to + jumped = true + break + } + } + if (jumped) continue + let ch = text_of(src, i, i + 1) + if (ch != " " && ch != "\t" && ch != "\r" && ch != "\n") return i + i++ + } + return to +} + + +def private lead_type_text(src : Source; lex : Lexical; from, to : int) : string { + return build_string() $(writer) { + var i = max(from, 0) + while (i < to) { + var jumped = false + for (c in lex.comments) { + if (c.from > i) break + if (c.from == i && c.to <= to) { + i = c.to + jumped = true + break + } + } + if (jumped) continue + let ch = text_of(src, i, i + 1) + if (ch != " " && ch != "\t" && ch != "\r" && ch != "\n") { + writer |> write(ch) + } + i++ + } + } +} + + +def private separators(src : Source; lex : Lexical; mka : ExprMakeArray?; closer : int; + var set : EditSet) : array { + let n = length(mka.values) + var ends : array + ends |> reserve(n) + for (i in range(1, n)) { + let prev = extent_of(src, lex, mka.values[i - 1]) + let semi = find_token(src, lex, prev.ok ? prev.to : span_end(src, mka.values[i - 1].at), ";") + let valFrom = span_begin(src, mka.values[i].at) + if (semi >= 0 && semi < valFrom) { + set |> replace(semi, semi + 1, ",", "make-array-sep") + } + ends |> push(semi >= 0 && semi < valFrom ? semi : valFrom) + } + ends |> push(closer) + return <- ends +} + + +def private drop_trailing_separator(src : Source; closer : int; var set : EditSet) { + var tail = closer + peek_data(src.text) $(bytes) { + while (tail > 0) { + let c = int(bytes[tail - 1]) + if (c != ' ' && c != '\t' && c != '\r' && c != '\n') break + tail-- + } + } + if (tail > 0 && text_of(src, tail - 1, tail) == ";") { + set |> remove(tail - 1, tail, "make-array-trailing-sep") + } +} + + +def private tuple_parens(src : Source; mka : ExprMakeArray?; ends : array; var set : EditSet) { + for (i in range(0, length(mka.values))) { + if (!is_make_tuple(mka.values[i])) continue + let valFrom = span_begin(src, mka.values[i].at) + if (text_of(src, valFrom, valFrom + 1) == "(") continue + set |> insert(valFrom, "(", "make-array-tuple-open") + set |> insert(ends[i], ")", "make-array-tuple-close") + } +} + + +def public rule_move_wrapper(src : Source; lex : Lexical; call : ExprCall?; var set : EditSet) : int { + //! `[{ ... }]` and `\{\{ ... \}\}` — the v1 array-of and table-of forms. + //! + //! The parser has already turned them into `to_array_move` / `to_table_move` around the + //! make-node, so the wrapper rewrites the brackets (`[{` -> `[`, `\}]` -> `]`) and the + //! make-node inside emits only its elements. Returns the opener offset it claimed, or -1. + if (call.name != "to_array_move" && call.name != "to_table_move") return -1 + let open = span_begin(src, call.at) + let opener = text_of(src, open, open + 2) + if (opener != "[\{" && opener != "\{\{") return -1 + let isTable = opener == "\{\{" + let closer = find_closer(src, lex, open + 2, isTable ? "\}\}" : "\}]") + if (closer < 0) { + set.refused |> push("make-wrapper at {open}: no matching closer") + return -1 + } + set |> replace(open, open + 2, isTable ? "\{" : "[", "make-wrapper-open") + set |> replace(closer, closer + 2, isTable ? "\}" : "]", "make-wrapper-close", RANK_CLOSE_OUTER) + return open +} + + +def public rule_comprehension(src : Source; lex : Lexical; cmp : ExprArrayComprehension?; var set : EditSet) { + //! `[{for x in r; e; where c}]` -> `[for x in r; e; where c]`; the two generator spellings + //! `[[for ...]]` and `\{\{for ...\}\}` -> `[iterator for ...]`. + //! + //! Only the brackets change; everything between them is the author's text, copied verbatim. + let forAt = span_begin(src, cmp.at) + var open = -1 + for (back in range(1, 8)) { + let cand = forAt - back - 1 + if (cand < 0) break + let two = text_of(src, cand, cand + 2) + if (two == "[\{" || two == "[[" || two == "\{\{") { + open = cand + break + } + } + if (open < 0) return + let opener = text_of(src, open, open + 2) + let closerText = opener == "[[" ? "]]" : (opener == "[\{" ? "\}]" : "\}\}") + let closer = find_closer(src, lex, open + 2, closerText) + if (closer < 0) { + set.refused |> push("comprehension at {open}: no matching closer") + return + } + let isGenerator = opener != "[\{" + set |> replace(open, open + 2, isGenerator ? "[iterator " : "[", "comprehension-open") + set |> replace(closer, closer + 2, "]", "comprehension-close", RANK_CLOSE_OUTER) +} diff --git a/utils/gen1-to-gen2/rules_stmt.das b/utils/gen1-to-gen2/rules_stmt.das new file mode 100644 index 0000000000..f9789dadc0 --- /dev/null +++ b/utils/gen1-to-gen2/rules_stmt.das @@ -0,0 +1,565 @@ +options gen2 +options indenting = 4 + +require daslib/ast +require math +require strings +require daslib/strings_boost +require offsets +require comments +require patch +require scan +require extent + + +def public is_braced(src : Source; at : LineInfo) : bool { + let b = span_begin(src, at) + return text_of(src, b, b + 1) == "\{" || text_of(src, skip_blank(src, b, b + 4), skip_blank(src, b, b + 4) + 1) == "\{" +} + + +def private block_end(src : Source; lex : Lexical; reported, start : int) : int { + var e = reported + var ln = line_at(src, e) + while (ln > 1 && is_blank(src, line_begin(src, ln), e)) { + ln-- + e = line_end(src, ln) + if (e <= start) break + } + let eol = line_end(src, line_at(src, e)) + return (eol > e && blank_or_comments(src, lex, e, eol)) ? eol : e +} + + +def public block_close_at(src : Source; lex : Lexical; at : LineInfo) : int { + //! Where a block's closing brace goes, and therefore where the gap to an `else` / `recover` + //! that follows it starts. A block the author already braced keeps its own end: its `\}` is + //! in the source, and a comment after that one is placed where they put it. + let reported = span_end(src, at) + if (is_braced(src, at)) return reported + return block_end(src, lex, reported, span_begin(src, at)) +} + + +struct private LiteralPipe { + at : int = -1 + hasParams : bool + ok : bool +} + + +def private group_open_before(src : Source; lex : Lexical; from : int; + closer, opener : string) : int { + var depth = 0 + var found = -1 + var cl = 0 + var op = 0 + peek_data(closer) $(cb) { + cl = !empty(cb) ? int(cb[0]) : 0 + } + peek_data(opener) $(ob) { + op = !empty(ob) ? int(ob[0]) : 0 + } + peek_data(src.text) $(bytes) { + var i = min(from, length(bytes) - 1) + while (i >= 0) { + if (!has_comment_or_string(lex, i, i + 1)) { + let ch = int(bytes[i]) + if (ch == cl) { + depth++ + } elif (ch == op) { + depth-- + if (depth == 0) { + found = i + break + } + } + } + i-- + } + } + return found +} + + +def private paren_open_before(src : Source; lex : Lexical; from : int) : int { + return group_open_before(src, lex, from, ")", "(") +} + + +def private literal_pipe(src : Source; lex : Lexical; start : int) : LiteralPipe { + var i = skip_back_blank(src, start) + if (i > 0 && text_of(src, i - 1, i) != ")") { + var idStart = i + peek_data(src.text) $(bytes) { + while (idStart > 0) { + let c = int(bytes[idStart - 1]) + if (!is_alpha(c) && !is_number(c) && c != '_' && c != '?' && c != '#') break + idStart-- + } + } + let colon = skip_back_blank(src, idStart) + if (idStart < i && colon > 0 && text_of(src, colon - 1, colon) == ":") { + i = skip_back_blank(src, colon - 1) + } + } + var params = false + while (i > 0) { + let ch = text_of(src, i - 1, i) + if (ch == ")") { + let lp = paren_open_before(src, lex, i - 1) + if (lp < 0) return LiteralPipe(ok = false) + params = true + i = skip_back_blank(src, lp) + } elif (ch == "]") { + let lb = group_open_before(src, lex, i - 1, "]", "[") + if (lb < 0) return LiteralPipe(ok = false) + i = skip_back_blank(src, lb) + } else { + let k = skip_back_ident(src, i) + if (k == i) break + i = skip_back_blank(src, k) + } + } + if (i < 2 || text_of(src, i - 2, i) != "<|") return LiteralPipe(ok = false) + let j = skip_back_blank(src, i - 2) + if (j < 1) return LiteralPipe(ok = false) + let owner = text_of(src, j - 1, j) + if (owner != "$" && owner != "@") return LiteralPipe(ok = false) + return LiteralPipe(at = i - 2, hasParams = params, ok = true) +} + + +def private skip_back_ident(src : Source; from : int) : int { + var i = from + peek_data(src.text) $(bytes) { + while (i > 0) { + let c = int(bytes[i - 1]) + if (!is_alpha(c) && !is_number(c) && c != 95) break + i-- + } + } + return i +} + + +def private skip_back_blank(src : Source; from : int) : int { + var i = from + peek_data(src.text) $(bytes) { + while (i > 0) { + let c = int(bytes[i - 1]) + if (c != ' ' && c != '\t' && c != '\r' && c != '\n') break + i-- + } + } + return i +} + + +def public rule_block_braces(src : Source; lex : Lexical; blk : ExprBlock?; var set : EditSet) { + //! Wraps an indent-delimited block in braces. + //! + //! Blocks that already carry braces (gen2 code, lambda bodies) are left alone, and so is a + //! one-line block whose span never leaves its header line. + if (blk.genFlags.generated) return + let start = span_begin(src, blk.at) + if (is_braced(src, blk.at)) { + let braced_pipe = literal_pipe(src, lex, start) + if (braced_pipe.ok) { + set |> remove(skip_back_blank(src, braced_pipe.at), braced_pipe.at + 2, "literal-pipe") + } + return + } + let stop = block_close_at(src, lex, blk.at) + if (stop <= start) return + let headerLine = line_at(src, start) + if (line_at(src, stop) == headerLine) return + let brace = line_edge(src, lex, start) + if (brace < start && !is_blank(src, brace, start)) return + let indent = indent_of(src, line_begin(src, headerLine)) + let piped = literal_pipe(src, lex, start) + if (piped.ok) { + set |> remove(skip_back_blank(src, piped.at), piped.at + 2, "literal-pipe") + if (!piped.hasParams) { + set |> insert(brace, "()", "literal-pipe-params", RANK_CLOSE_INNER, start) + } + set |> insert(brace, " \{", "block-open", RANK_BLOCK_OPEN, start) + } else { + let bare_pipe = preceded_by(src, brace, "<|") + set |> insert(brace, bare_pipe ? " $() \{" : " \{", "block-open", RANK_BLOCK_OPEN, start) + } + set |> insert(stop, "{src.eol}{repeat(" ", indent)}\}", "block-close", RANK_CLOSE_OUTER, start) +} + + +def public preceded_by(src : Source; from : int; word : string) : bool { + var i = from + peek_data(src.text) $(bytes) { + while (i > 0) { + let c = int(bytes[i - 1]) + if (c == ' ' || c == '\t' || c == '\r' || c == '\n') { + i-- + continue + } + if (c != '/' || i < 2 || int(bytes[i - 2]) != '*') break + var j = i - 2 + while (j >= 2 && !(int(bytes[j - 2]) == '/' && int(bytes[j - 1]) == '*')) { + j-- + } + if (j < 2) break + i = j - 2 + } + } + let n = length(word) + return i >= n && text_of(src, i - n, i) == word +} + + +def private wrap_expr(src : Source; lex : Lexical; at : LineInfo; expr : ExpressionPtr; + keyword : string; rule : string; var set : EditSet) { + if (!keyword_at(src, at, keyword)) return + let ext = extent_of(src, lex, expr) + if (!ext.ok) return + let head = expr_head_before(src, lex, ext.from) + wrap_in_parens(src, lex, open_paren_before(src, lex, head, ext.to), ext.to, rule, set) +} + + +def private expr_head_before(src : Source; lex : Lexical; from : int) : int { + var i = from + while (i > 0) { + let k = skip_back_ident(src, i) + if (k != i) { + i = k + continue + } + let ch = text_of(src, i - 1, i) + if (ch == "." || ch == "[") { + i-- + } elif (ch == "]") { + let lb = group_open_before(src, lex, i - 1, "]", "[") + if (lb < 0) return i + i = lb + } else { + break + } + } + return i +} + + +def private keyword_at(src : Source; at : LineInfo; keyword : string) : bool { + let from = span_begin(src, at) + return text_of(src, from, from + length(keyword)) == keyword +} + + +def private open_paren_before(src : Source; lex : Lexical; from, to : int) : int { + var start = from + while (start > 0) { + var prev = start + peek_data(src.text) $(bytes) { + while (prev > 0) { + let c = int(bytes[prev - 1]) + if (c != ' ' && c != '\t' && c != '\r' && c != '\n') break + prev-- + } + } + if (prev <= 0 || text_of(src, prev - 1, prev) != "(") break + let close = paren_close(src, lex, prev - 1) + if (close < 0 || close >= to) break + start = prev - 1 + } + return start +} + + +def private wrap_return(src : Source; lex : Lexical; from, to : int; var set : EditSet) { + wrap_in_parens(src, lex, from, to, "return-tuple", set, RANK_CLOSE_INNER) +} + + +def private wrap_in_parens(src : Source; lex : Lexical; from, to : int; rule : string; + var set : EditSet; closeRank : int = RANK_CLOSE_OUTER) { + if (to <= from || (text_of(src, from, from + 1) == "(" && paren_close(src, lex, from) == to - 1)) return + set |> insert(from, "(", "{rule}-open") + set |> insert(to, ")", "{rule}-close", closeRank) +} + + +def private if_keyword(src : Source; expr : ExprIfThenElse?) : string { + if (keyword_at(src, expr.at, "static_elif")) return "static_elif" + if (keyword_at(src, expr.at, "static_if")) return "static_if" + return keyword_at(src, expr.at, "elif") ? "elif" : "if" +} + + +def public rule_if_parens(src : Source; lex : Lexical; expr : ExprIfThenElse?; var set : EditSet) { + //! `if cond` -> `if (cond)`. + if (expr.genFlags.generated || expr.cond == null) return + wrap_expr(src, lex, expr.at, expr.cond, if_keyword(src, expr), "if-cond", set) +} + + +def public rule_while_parens(src : Source; lex : Lexical; expr : ExprWhile?; var set : EditSet) { + //! `while cond` -> `while (cond)`. + if (expr.genFlags.generated || expr.cond == null) return + wrap_expr(src, lex, expr.at, expr.cond, "while", "while-cond", set) +} + + +def public rule_with_parens(src : Source; lex : Lexical; expr : ExprWith?; var set : EditSet) { + //! `with obj` -> `with (obj)`. + if (expr.genFlags.generated || expr._with == null) return + wrap_expr(src, lex, expr.at, expr._with, "with", "with-subject", set) +} + + +def public rule_for_parens(src : Source; lex : Lexical; expr : ExprFor?; var set : EditSet) { + //! `for x in xs` -> `for (x in xs)`. + //! + //! The head runs from the first iterator name to the end of the last source; both ends come + //! from the tree (`iteratorsAt`, `sources`), so nothing has to be searched for. + if (expr.genFlags.generated || empty(expr.iteratorsAt) || empty(expr.sources)) return + var from = span_begin(src, expr.iteratorsAt[0]) + if (!preceded_by(src, from, "for")) { + let kw = span_begin(src, expr.at) + if (text_of(src, kw, kw + 3) != "for") return + from = skip_blank(src, kw + 3, line_end(src, line_at(src, kw))) + if (from <= kw + 3) return + } + var to = from + for (s in expr.sources) { + let ext = extent_of(src, lex, s) + if (ext.ok) { + to = max(to, ext.to) + } + } + if (to <= from && expr.body != null) { + to = line_edge(src, lex, span_begin(src, expr.body.at)) + } + wrap_in_parens(src, lex, from, to, "for-head", set) +} + + +def public rule_glue_keyword(src : Source; fromEnd, toStart : int; keyword : string; + nextBraced : bool; var set : EditSet) { + //! Pulls `} else {` (or `recover`, `finally`) onto one line. + //! + //! Only when the gap between the two blocks holds nothing but that keyword: a comment in + //! there is somebody's note about the branch, and moving it is worse than leaving the + //! formatting alone. + if (toStart <= fromEnd) return + let gap = text_of(src, fromEnd, toStart) + if (gap |> strip != keyword) return + if (nextBraced) { + set |> replace(fromEnd, toStart, " {keyword} ", "glue-{keyword}", RANK_TERMINATOR) + return + } + set |> replace(fromEnd, skip_back_blank(src, toStart), " {keyword}", + "glue-{keyword}", RANK_TERMINATOR) +} + + +def public rule_call_macro_parens(src : Source; lex : Lexical; call : ExprCallMacro?; + var set : EditSet) { + //! `match x` + an indented block -> `match(x) \{ ... \}`. + //! + //! A call macro registered as a keyword (`match`, `static_match`) takes its subject bare in + //! v1; gen2 spells the call, so the subject needs the parentheses a condition would get. + if (call.genFlags.generated || empty(call.arguments)) return + let at = span_begin(src, call.at) + let name = string(call.name) + let after = at + length(name) + if (text_of(src, at, after) != name || text_of(src, after, after + 1) == "(") return + let ext = extent_of(src, lex, call.arguments[0]) + if (!ext.ok || ext.from <= after || !is_blank(src, after, ext.from)) return + set |> replace(after, ext.from, "(", "call-macro-open") + set |> insert(ext.to, ")", "call-macro-close", RANK_CLOSE_INNER) +} + + +def public rule_typeinfo(src : Source; lex : Lexical; expr : ExprTypeInfo?; var set : EditSet) { + //! v1 `typeinfo(trait expr)` -> gen2 `typeinfo trait(expr)`. + //! + //! The trait name moves out of the parentheses; the closing one is already where gen2 wants + //! it, so only the opener and the gap after the trait change. + if (expr.genFlags.generated) return + let at = span_begin(src, expr.at) + if (text_of(src, at, at + 8) != "typeinfo") return + let lp = find_token(src, lex, at + 8, "(") + if (lp < 0 || !(text_of(src, at + 8, lp) |> strip |> empty)) return + let traitFrom = skip_blank(src, lp + 1, lp + 32) + var traitTo = traitFrom + peek_data(src.text) $(bytes) { + while (traitTo < length(bytes)) { + let c = int(bytes[traitTo]) + if (!is_alpha(c) && !is_number(c) && c != '_') break + traitTo++ + } + } + if (traitTo <= traitFrom) return + set |> replace(lp, lp + 1, " ", "typeinfo-open") + let argFrom = skip_blank(src, traitTo, paren_close(src, lex, lp)) + if (argFrom > traitTo && is_blank(src, traitTo, argFrom)) { + set |> replace(traitTo, argFrom, "(", "typeinfo-trait") + return + } + set |> insert(traitTo, "(", "typeinfo-trait") +} + + +def public rule_let_tuple(src : Source; lex : Lexical; expr : ExprLet?; var set : EditSet) { + //! v1 tuple destructuring `var [[a, b]] = t` -> gen2 `var (a, b) = t`. + //! + //! The brackets are not a make-node here — they name the variables being bound — so no + //! make rule claims them and this one owns both ends. + if (expr.genFlags.generated) return + let at = span_begin(src, expr.at) + let keyword = text_of(src, at, at + 3) + if (keyword != "var" && keyword != "let") return + let bracket = skip_blank(src, at + 3, at + 35) + if (text_of(src, bracket, bracket + 2) != "[[") return + let closer = find_closer(src, lex, bracket + 2, "]]") + if (closer < 0) return + set |> replace(bracket, bracket + 2, "(", "let-tuple-open") + set |> replace(closer, closer + 2, ")", "let-tuple-close", RANK_CLOSE_OUTER) +} + + +def public rule_enum_dot(src : Source; lex : Lexical; at : LineInfo; generated : bool; + var set : EditSet) { + //! v1 names an enumeration or bitfield value `Color green`; gen2 writes `Color.green`. + //! + //! The node anchors on the VALUE, so the type name is the identifier before it and the gap + //! between them is what becomes the dot. + if (generated) return + let valStart = span_begin(src, at) + if (valStart <= 0) return + var typeEnd = valStart + peek_data(src.text) $(bytes) { + while (typeEnd > 0) { + let c = int(bytes[typeEnd - 1]) + if (c != ' ' && c != '\t' && c != '\r' && c != '\n') break + typeEnd-- + } + } + if (typeEnd == valStart || text_of(src, typeEnd - 1, typeEnd) == "." + || has_comment_or_string(lex, typeEnd, valStart)) return + set |> replace(typeEnd, valStart, ".", "enum-dot") +} + + +def public rule_type_function_call(src : Source; lex : Lexical; expr : ExprCall?; var set : EditSet) { + //! v1 calls a `[type_function]` as `take(1, 2)`; gen2 passes the type as an argument: + //! `take(type, 1, 2)`. + if (expr.genFlags.generated || empty(expr.arguments) + || expr.arguments[0].__rtti != "ExprTypeDecl") return + let nameEnd = span_end(src, expr.at) + let lt = find_token(src, lex, nameEnd, "<") + if (lt < 0 || !is_blank(src, nameEnd, lt)) return + let gt = find_token(src, lex, span_end(src, expr.arguments[0].at), ">") + if (gt < 0) return + let lp = find_token(src, lex, gt + 1, "(") + if (lp < 0 || !is_blank(src, gt + 1, lp)) return + set |> replace(lt, lt + 1, "(type<", "type-function-open") + let more = length(expr.arguments) > 1 + set |> replace(gt, lp + 1, more ? ">, " : ">", "type-function-args") +} + + +def public rule_piped_make(src : Source; lex : Lexical; call : ExprCall?; var set : EditSet) { + //! `\{a, b\} |> f(x)` -> `f(\{a, b\}, x)`. + //! + //! gen2 takes no make-literal on the left of a pipe. The parser has already lowered the pipe + //! into the call, so the rewrite is to spell the call the way the tree already reads it. + if (call.genFlags.generated || empty(call.arguments)) return + let mk = span_begin(src, call.arguments[0].at) + if (text_of(src, mk, mk + 1) != "\{") return + let name = span_begin(src, call.at) + let nameEnd = span_end(src, call.at) + if (name <= mk) return + let close = brace_close(src, lex, mk) + if (close < 0 || close >= name || text_of(src, close + 1, name) |> strip != "|>") return + let lp = find_token(src, lex, nameEnd, "(") + if (lp < 0 || !is_blank(src, nameEnd, lp)) return + set |> insert(mk, "{text_of(src, name, nameEnd)}(", "piped-make-name") + set |> replace(close + 1, lp + 1, length(call.arguments) > 1 ? ", " : "", "piped-make-pipe") +} + + +def public rule_return_tuple(src : Source; lex : Lexical; expr : ExprReturn?; var set : EditSet) { + //! v1 returns several values bare — `return 1, "2", 3.0`; gen2 wants the tuple written as one. + if (expr.genFlags.generated || expr.subexpr == null + || expr.subexpr.__rtti != "ExprMakeTuple") return + let ext = extent_of(src, lex, expr.subexpr) + if (!ext.ok) return + wrap_return(src, lex, ext.from, ext.to, set) +} + + +def private angle_close(src : Source; lex : Lexical; from : int) : int { + var depth = 0 + var i = from + while (i < src.size) { + if (!has_comment_or_string(lex, i, i + 1)) { + let ch = text_of(src, i, i + 1) + if (ch == "<") { + depth++ + } elif (ch == ">") { + depth-- + if (depth == 0) return i + } + } + i++ + } + return -1 +} + + +def public rule_cast_parens(src : Source; lex : Lexical; expr : ExprCast?; var set : EditSet) { + //! v1 writes `reinterpret a.b`; gen2 casts are call-style — `reinterpret(a.b)`. + if (expr.genFlags.generated || expr.subexpr == null) return + let lt = find_token(src, lex, span_end(src, expr.at), "<") + if (lt < 0 || !is_blank(src, span_end(src, expr.at), lt)) return + let gt = angle_close(src, lex, lt) + if (gt < 0) return + let ext = extent_of(src, lex, expr.subexpr) + if (!ext.ok || ext.from <= gt + || (is_blank(src, gt + 1, ext.from) && text_of(src, gt + 1, gt + 2) == "(")) return + if (ext.from > gt + 1 && is_blank(src, gt + 1, ext.from)) { + set |> replace(gt + 1, ext.from, "(", "cast-open") + } else { + set |> insert(gt + 1, "(", "cast-open") + } + set |> insert(ext.to, ")", "cast-close", RANK_CLOSE_INNER) +} + + +def private continues_with_operator(src : Source; lex : Lexical; from, to : int) : bool { + var line = line_at(src, from) + 1 + let last = line_at(src, to - 1) + while (line <= last) { + let b = skip_blank(src, line_begin(src, line), line_end(src, line)) + if (b >= from && b < to && !has_comment_or_string(lex, b, b + 1)) { + let c = text_of(src, b, b + 1) + if (c == "+" || c == "-" || c == "*" || c == "/" || c == "%" || c == "|" || c == "&" + || c == "^" || c == "<" || c == ">" || c == "=" || c == "?") return true + } + line++ + } + return false +} + + +def public rule_multiline_init(src : Source; lex : Lexical; expr : ExprLet?; var set : EditSet) { + //! `let x = 1` + a continuation line `+ 2` -> `let x = (1 + 2)`, spelled across the same lines. + if (expr.genFlags.generated || empty(expr.variables)) return + for (v in expr.variables) { + if (v.init == null) continue + let ext = extent_of(src, lex, v.init) + if (!ext.ok || contains_block(v.init) + || !continues_with_operator(src, lex, ext.from, ext.to)) continue + wrap_in_parens(src, lex, ext.from, ext.to, "multiline-init", set, RANK_CLOSE_INNER) + } +} diff --git a/utils/gen1-to-gen2/scan.das b/utils/gen1-to-gen2/scan.das new file mode 100644 index 0000000000..79b0f75653 --- /dev/null +++ b/utils/gen1-to-gen2/scan.das @@ -0,0 +1,233 @@ +options gen2 +options indenting = 4 + +require math +require strings +require offsets +require comments + + +def private skip_lexical(lex : Lexical; pos : int) : int { + for (c in lex.comments) { + if (c.from <= pos && pos < c.to) return c.to + } + for (s in lex.strings) { + if (s.from <= pos && pos < s.to) return s.to + } + return pos +} + + +def public group_close(src : Source; lex : Lexical; from : int; opener, closer : string) : int { + //! Offset of the one-byte `closer` matching the `opener` at `from`, or -1. A delimiter inside + //! a comment or a string literal does not count. + var depth = 0 + var found = -1 + var op = 0 + var cl = 0 + peek_data(opener) $(ob) { + op = !empty(ob) ? int(ob[0]) : 0 + } + peek_data(closer) $(cb) { + cl = !empty(cb) ? int(cb[0]) : 0 + } + peek_data(src.text) $(bytes) { + var i = from + let n = length(bytes) + while (i < n) { + let skipped = skip_lexical(lex, i) + if (skipped != i) { + i = skipped + continue + } + let ch = int(bytes[i]) + if (ch == op) { + depth++ + } elif (ch == cl) { + depth-- + if (depth == 0) { + found = i + break + } + } + i++ + } + } + return found +} + + +def public brace_close(src : Source; lex : Lexical; from : int) : int { + //! Offset of the `\}` that matches the `\{` at `from`, or -1. + return group_close(src, lex, from, "\{", "\}") +} + + +def public paren_close(src : Source; lex : Lexical; from : int) : int { + //! Offset of the `)` that matches the `(` at `from`, or -1. + return group_close(src, lex, from, "(", ")") +} + + +def public find_token(src : Source; lex : Lexical; from : int; token : string) : int { + //! Offset of the next `token` at or after `from`, ignoring comments and string literals. + //! Returns -1 when it is not there. + let n = length(token) + if (n == 0) return -1 + var i = max(from, 0) + var found = -1 + peek_data(src.text) $(bytes) { + peek_data(token) $(needle) { + while (i + n <= length(bytes)) { + let skipped = skip_lexical(lex, i) + if (skipped != i) { + i = skipped + continue + } + var hit = true + for (k in range(n)) { + if (bytes[i + k] != needle[k]) { + hit = false + break + } + } + if (hit) { + found = i + break + } + i++ + } + } + } + return found +} + + +def public find_closer(src : Source; lex : Lexical; from : int; closer : string) : int { + //! Offset of the construct's own closer, skipping over nested make-constructs. + //! + //! `[[Bar a=[[Foo b=1]]]]` — the outer closer is not the first `]]` after the last field, + //! it is the one that matches at depth zero. A single `[` or `(` inside the body counts + //! too: in `[[Foo a=arr[0]]]` the index's `]` would otherwise pair with the closer's first + //! byte and cut the construct one character short. + var depth = 0 + var sub = 0 + var i = max(from, 0) + var found = -1 + var want0 = 0 + var want1 = 0 + peek_data(closer) $(cb) { + if (length(cb) >= 2) { + want0 = int(cb[0]) + want1 = int(cb[1]) + } + } + peek_data(src.text) $(bytes) { + while (i + 1 < length(bytes)) { + let skipped = skip_lexical(lex, i) + if (skipped != i) { + i = skipped + continue + } + let a = int(bytes[i]) + let b = int(bytes[i + 1]) + let opens = (a == '[' && (b == '[' || b == '{')) || (a == '{' && b == '{') + if (opens) { + depth++ + i += 2 + continue + } + if (a == '[' || a == '(') { + sub++ + i++ + continue + } + if (sub > 0 && (a == ']' || a == ')')) { + sub-- + i++ + continue + } + let closes = (a == ']' && b == ']') || (a == '}' && (b == ']' || b == '}')) + if (closes) { + if (depth == 0) { + found = (a == want0 && b == want1) ? i : -1 + break + } + depth-- + i += 2 + continue + } + i++ + } + } + return found +} + + +def public line_has_code(src : Source; lex : Lexical; line : int) : bool { + //! False when the line carries nothing but whitespace and comment text. + //! + //! v1 delimits a body by indentation, and a comment does not end one - not even a banner + //! written at column 0 between two methods of a class. + let b = line_begin(src, line) + let e = line_end(src, line) + var i = skip_blank(src, b, e) + while (i < e) { + var jumped = false + for (c in lex.comments) { + if (c.from > i) break + if (c.to > i) { + i = c.to + jumped = true + break + } + } + if (!jumped) return true + i = skip_blank(src, i, e) + } + return false +} + + +def public skip_blank(src : Source; from, to : int) : int { + //! First non-whitespace offset in [from, to), or `to`. + var i = max(from, 0) + peek_data(src.text) $(bytes) { + let e = min(to, length(bytes)) + while (i < e) { + let c = int(bytes[i]) + if (c != ' ' && c != '\t' && c != '\r' && c != '\n') break + i++ + } + } + return i +} + + +def public end_of_type_token(src : Source; from, limit : int) : int { + //! End of the type spelling that starts at `from`. + //! + //! `TypeDecl.at` covers only the base name, so `[[Foo?]]` reports `Foo` and the `?` has to + //! be picked up from the text. Angle brackets are counted, so `tuple` stays one + //! token. + var i = max(from, 0) + var angle = 0 + peek_data(src.text) $(bytes) { + let e = min(limit, length(bytes)) + while (i < e) { + let c = int(bytes[i]) + if (c == '<') { + angle++ + } elif (c == '>') { + if (angle == 0) break + angle-- + } elif (angle == 0) { + let word = (is_alpha(c) || is_number(c) + || c == '_' || c == '?' || c == '#' || c == ':' || c == '[' || c == ']' || c == '&') + if (!word) break + } + i++ + } + } + return i +} diff --git a/utils/gen1-to-gen2/tests/_fixture_gen1_basic.das b/utils/gen1-to-gen2/tests/_fixture_gen1_basic.das new file mode 100644 index 0000000000..8ead50c78f --- /dev/null +++ b/utils/gen1-to-gen2/tests/_fixture_gen1_basic.das @@ -0,0 +1,11 @@ +options gen2 = false + +// a header comment, which the conversion must not move or lose + +[safe_when_uninitialized] +struct Foo + a : int = 5 + +def make_it() + var s = [[Foo /*keep*/ a=1]] + return s.a diff --git a/utils/gen1-to-gen2/tests/_fixture_gen1_decl.das b/utils/gen1-to-gen2/tests/_fixture_gen1_decl.das new file mode 100644 index 0000000000..3892a97965 --- /dev/null +++ b/utils/gen1-to-gen2/tests/_fixture_gen1_decl.das @@ -0,0 +1,22 @@ +options gen2 = false + +typedef + IntAlias = int + StrAlias = string + +enum Color + red + green + +bitfield Flags + one + two + +struct Point + x : int = 1 + y : float = 2.0 + +class Shape + kind : int = 0 + def area() : int + return kind diff --git a/utils/gen1-to-gen2/tests/_fixture_gen1_stmt.das b/utils/gen1-to-gen2/tests/_fixture_gen1_stmt.das new file mode 100644 index 0000000000..2530f7f18b --- /dev/null +++ b/utils/gen1-to-gen2/tests/_fixture_gen1_stmt.das @@ -0,0 +1,91 @@ +options gen2 = false + +def classify(n : int) + var total = 0 + for i in range(n) + if i % 2 == 0 + total += i // counted + else + total -= i + while total > 100 + total -= 10 + return total + +def risky() + try + classify(3) // may fail + recover + return -1 + return 0 + +def commented(n : int) // what this one is for + return n + 1 // and what it gives back + +def take_block(blk : block<> const) + invoke(blk) + +def piped(n : int) + var acc = 0 + take_block <| + acc += n + return acc + +def indexed(a : array>) + var s = 0 + for tt in a[0] + s += tt + return s + +def take_arg(blk : block<(a : int)> const) + invoke(blk, 1) + +def annotated() + take_arg() <| $([[optional]] a : int) + return a + return 0 + +def traits(a : int) + var [[lo, hi]] = (1, 2) + return typeinfo(sizeof a) + lo + hi + +enum Color + red + green + +bitfield Flags2 + one + two + +variant Var1 + i : int + s : string + +struct Holder + b : int + +def spellings(var h : Holder; v : Var1) + let c = Color green + let fl = Flags2 one + var p = 0 + unsafe + p = reinterpret h.b + if v is i && c == Color green + p += int(fl) + return p + +def pair() + return 1, "2" + +def piped_literal() + var blk = $ <| (a, b : int) + return a + b + return invoke(blk, 1, 2) + +let GATE = false + +def more_spellings() + let braced_lambda = @ <| () {} + var sum = 1 + static_if GATE + sum += 1 + return sum diff --git a/utils/gen1-to-gen2/tests/_fixture_make_syntax.das b/utils/gen1-to-gen2/tests/_fixture_make_syntax.das new file mode 100644 index 0000000000..c3c413b15c --- /dev/null +++ b/utils/gen1-to-gen2/tests/_fixture_make_syntax.das @@ -0,0 +1,31 @@ +options gen2 = false + +[safe_when_uninitialized] +struct Foo + a : int = 5 + b : float = 3.0 + +[safe_when_uninitialized] +struct Bar + a : Foo + +def make_them() + var v1 = [[Foo a=1, b=2.0]] + var v2 = [[/*a*/Foo/*b*/ a=1]] + var v3 = [[Foo() a=1; a=2]] + var v4 = [[Foo]] + var v5 = [[auto 1; 2; 3]] + var v6 = [[auto 4, 5]] + var v7 = [[Bar a=[[Foo b=2.0]]]] + var v8 = [[Foo /*c*/ a=1 /*d*/]] + var w1 = {{ 1 => "a"; 2 => "b" }} + var w2 = [{Foo a = 1; a = 2}] + var w3 = [{auto 1; 2; 3}] + var w4 = [{for x in 0..10; x * x; where x % 2 == 0}] + var w5 = [[for x in 0..10; x * x]] + var v9 = [[auto 1, 2; 3, 4]] + var v10 = [[Foo#]] + var v11 = [[auto[] 7]] + var v12 = [[int 1; 2]] + var v13 = [[tuple "a", 1.0; "b", 2.0;]] + return v1.a + v2.a + v3[0].a + v4.a + v5[0] + v6._0 + v7.a.a + v8.a + length(w1) + w2[0].a + w3[0] + w4[0] + v9[0]._0 + v10.a + v11[0] + v12[0] + length(v13) diff --git a/utils/gen1-to-gen2/tests/test_convert.das b/utils/gen1-to-gen2/tests/test_convert.das new file mode 100644 index 0000000000..cd3b8a41a5 --- /dev/null +++ b/utils/gen1-to-gen2/tests/test_convert.das @@ -0,0 +1,111 @@ +options gen2 +options indenting = 4 +options rtti = true +options strict_smart_pointers = false + +require dastest/testing_boost public +require daslib/ast +require daslib/fio +require strings +require daslib/strings_boost +require ../patch.das +require ../convert.das + +//! End-to-end: read a v1 file, parse it with infer off, apply the edit set, and hand back text +//! whose comments are provably intact. + +let FIXTURE = "{get_das_root()}/utils/gen1-to-gen2/tests/_fixture_gen1_basic.das" + + +let STMT_FIXTURE = "{get_das_root()}/utils/gen1-to-gen2/tests/_fixture_gen1_stmt.das" + + +//! gen1.5 keeps the indentation, so its output has to stay v1 - the gen2 twin of this check +//! (`compiles_as_gen2`) would reject it for the braces it deliberately did not add. +def private compiles_as_gen1(near : string; text : string; var issues_out : string&) : bool { + let probe = "{dir_name(near)}/.gen15_verify_{base_name(near)}" + if (!fwrite(probe, text)) { + issues_out = "could not write {probe}" + return false + } + var ok_out = false + var inscope access <- make_file_access("") + using() $(var mg : ModuleGroup) { + using() $(var cop : CodeOfPolicies) { + cop.ignore_shared_modules = true + cop.export_all = true + cop.version_2_syntax = false + cop.no_optimizations = true + compile_file(probe, access, unsafe(addr(mg)), cop) $(ok; _program; issues) { + ok_out = ok + issues_out = string(issues) + } + } + } + remove(probe) + return ok_out +} + + +[test] +def test_convert_pipeline(t : T?) { + t |> run("a v1 file gains the gen2 header and keeps every comment") @(t : T?) { + let res <- convert_file(FIXTURE, ConvertOptions(v2 = true)) + t |> equal(res.failed, "", "no failure") + t |> equal(res.skipped, "", "not skipped") + t |> equal(length(res.refused), 0, "no refused edits") + t |> success(res.changed, "the file changed") + t |> success(res.output |> starts_with("options gen2\n"), "the opt-out marker became the header") + let original = fread(FIXTURE) + t |> success(res.output |> find("var s = Foo( /*keep*/ a=1)") >= 0, "make-syntax converted") + t |> success(res.output |> find("// a header comment") >= 0, "prose comment untouched") + t |> success(check_comments_preserved(original, res.output).ok, "comments conserved") + } + + t |> run("--semicolon terminates the header too") @(t : T?) { + let res <- convert_file(FIXTURE, ConvertOptions(v2 = true, semicolon = true)) + t |> success(res.output |> starts_with("options gen2;\n"), "header carries the ';'") + } + + t |> run("gen1.5 converts make-syntax but leaves the marker alone") @(t : T?) { + let res <- convert_file(FIXTURE, ConvertOptions(v2 = false)) + t |> success(res.output |> starts_with("options gen2 = false"), "still opted out of gen2") + t |> success(res.output |> find("var s = Foo( /*keep*/ a=1)") >= 0, "make-syntax still converted") + } + + t |> run("gen1.5 output still compiles as v1") @(t : T?) { + for (f in [FIXTURE, STMT_FIXTURE]) { + let res <- convert_file(f, ConvertOptions(v2 = false)) + t |> equal(res.failed, "", "{f} converted") + var issues = "" + t |> success(compiles_as_gen1(f, res.output, issues), "compiles as v1: {issues}") + } + } + + t |> run("an already-gen2 file is left alone byte for byte") @(t : T?) { + let self = "{get_das_root()}/utils/gen1-to-gen2/tests/test_convert.das" + let res <- convert_file(self, ConvertOptions(v2 = true)) + t |> equal(res.skipped, "already gen2", "skipped as already converted") + t |> success(!res.changed, "unchanged") + t |> equal(res.output, fread(self), "output is the input") + } +} + + +[test] +def test_crlf_input(t : T?) { + t |> run("a CRLF file converts to the LF result with CRLF endings") @(t : T?) { + for (f in [FIXTURE, STMT_FIXTURE]) { + let lf <- convert_file(f, ConvertOptions(v2 = true)) + let crlfPath = "{dir_name(f)}/.crlf_{base_name(f)}" + let crlfText = fread(f) |> replace("\r\n", "\n") |> replace("\n", "\r\n") + t |> success(fwrite(crlfPath, crlfText), "wrote the CRLF twin of {f}") + let crlf <- convert_file(crlfPath, ConvertOptions(v2 = true)) + remove(crlfPath) + t |> equal(crlf.failed, "", "{f} converted") + t |> equal(length(crlf.refused), 0, "no refused edits") + t |> success(check_comments_preserved(crlfText, crlf.output).ok, "comments conserved") + t |> equal(crlf.output, lf.output |> replace("\n", "\r\n"), "same conversion, CRLF endings") + } + } +} diff --git a/utils/gen1-to-gen2/tests/test_engine.das b/utils/gen1-to-gen2/tests/test_engine.das new file mode 100644 index 0000000000..44b2779793 --- /dev/null +++ b/utils/gen1-to-gen2/tests/test_engine.das @@ -0,0 +1,144 @@ +options gen2 +options indenting = 4 + +require dastest/testing_boost public +require ../offsets.das +require ../comments.das +require ../patch.das + +//! Engine tests: offsets, the comment/string scan, and the edit set. +//! +//! The cases that matter are the ones the design turns on — an edit inside a construct plus an +//! edit around it, two edits at one offset, and a deletion that would eat a comment. + + +def private rewrite(text : string; var set : EditSet) : string { + let src = make_source(text) + return apply(src, scan_lexical(src), set) +} + + +[test] +def test_offsets(t : T?) { + t |> run("line index and span clamping") @(t : T?) { + let src = make_source("abc\ndefgh\n\nxy") + t |> equal(line_count(src), 4, "four lines") + t |> equal(line_begin(src, 2), 4, "line 2 starts at 4") + t |> equal(line_end(src, 2), 9, "line 2 ends at 9") + t |> equal(line_at(src, 6), 2, "offset 6 is on line 2") + t |> equal(line_at(src, 10), 3, "offset 10 is the empty line 3") + t |> equal(line_at(src, 11), 4, "offset 11 is on line 4") + t |> equal(text_of(src, 4, 9), "defgh", "text of line 2") + t |> equal(offset_of(src, 2, 99), 9, "column past end clamps to the line end") + t |> equal(text_of(src, 4, 999), "defgh\n\nxy", "range past end clamps") + t |> equal(indent_of(src, 1), 0, "no indent") + t |> equal(indent_of(make_source(" x"), 4), 4, "four spaces") + } +} + + +[test] +def test_lexical_scan(t : T?) { + t |> run("comments and literals, including the traps") @(t : T?) { + let src = make_source("a /*b*/ c // d\ne \"/*not*/\" f '\"' g") + let lex <- scan_lexical(src) + let cs <- comment_texts(src, lex) + t |> equal(length(cs), 2, "two comments") + if (length(cs) == 2) { + t |> equal(cs[0], "/*b*/", "block comment") + t |> equal(cs[1], "// d", "line comment runs to the newline") + } + t |> equal(length(lex.strings), 2, "two literals: the string and the char") + } + + t |> run("deletion guards") @(t : T?) { + let src = make_source("x = [[Foo /*keep*/ a=1]]") + let lex <- scan_lexical(src) + t |> success(has_comment_or_string(lex, 4, 24), "the whole make-expr holds a comment") + t |> success(!has_comment_or_string(lex, 4, 6), "the [[ token alone does not") + t |> success(is_blank(src, 3, 4), "the gap before [[ is blank") + t |> success(!is_blank(src, 9, 19), "a gap holding a comment is not blank") + } + + t |> run("line edge steps past a block comment") @(t : T?) { + let src = make_source("let a = 5 /* tail\ncontinues */\nlet b = 6") + let lex <- scan_lexical(src) + t |> equal(line_edge(src, lex, 0), 30, "edge is after the comment closes") + let plain = make_source("let a = 5 \n") + let plainLex <- scan_lexical(plain) + t |> equal(line_edge(plain, plainLex, 0), 9, "trailing whitespace is not part of the edge") + } +} + + +[test] +def test_edits(t : T?) { + t |> run("inner and outer edits compose in one pass") @(t : T?) { + let text = "[[Bar a=[[Foo b=2]]]]" + var set : EditSet + set |> replace(8, 14, "Foo(", "inner-open") + set |> replace(17, 19, ")", "inner-close") + set |> replace(0, 6, "Bar(", "outer-open") + set |> replace(19, 21, ")", "outer-close", RANK_CLOSE_OUTER) + t |> equal(rewrite(text, set), "Bar(a=Foo(b=2))", "nested rewrite") + t |> equal(length(set.refused), 0, "nothing refused") + } + + t |> run("a zero-length insert lands however much the inside grew") @(t : T?) { + let text = "let x = [[auto 1]]" + var set : EditSet + set |> replace(8, 10, "fixed_array(", "open") + set |> replace(16, 18, ")", "close") + set |> insert(18, ";", "terminator", RANK_TERMINATOR) + t |> equal(rewrite(text, set), "let x = fixed_array(auto 1);", "insert after a grown construct") + } + + t |> run("same offset resolves by rank") @(t : T?) { + var set : EditSet + set |> insert(3, ";", "terminator", RANK_TERMINATOR) + set |> insert(3, ")", "close-outer", RANK_CLOSE_OUTER) + set |> insert(3, "]", "close-inner", RANK_CLOSE_INNER) + t |> equal(rewrite("abc", set), "abc]);", "inner closes first, terminator last") + } + + t |> run("an insert at a replaced offset lands inside it") @(t : T?) { + var set : EditSet + set |> replace(0, 2, "[", "wrapper-open") + set |> insert(9, ")", "call-close") + set |> replace(9, 11, "]", "wrapper-close", RANK_CLOSE_OUTER) + t |> equal(rewrite("[\{Foo a=1\}]", set), "[Foo a=1)]", "the ')' precedes the ']'") + t |> equal(length(set.refused), 0, "neither edit is refused") + } + + t |> run("overlapping edits are refused, not merged") @(t : T?) { + var set : EditSet + set |> replace(0, 5, "A", "first") + set |> replace(3, 8, "B", "second") + t |> equal(rewrite("0123456789", set), "A56789", "the second edit is dropped") + t |> equal(length(set.refused), 1, "and reported") + } + + t |> run("a deletion that would eat a comment is refused") @(t : T?) { + let text = "f() <| /*why*/ 1" + var set : EditSet + set |> remove(4, 15, "pipe-drop") + t |> equal(rewrite(text, set), text, "text unchanged") + t |> equal(length(set.refused), 1, "refusal reported") + var ok : EditSet + ok |> remove(4, 7, "pipe-drop") + t |> equal(rewrite(text, ok), "f() /*why*/ 1", "deleting just the token is fine") + t |> equal(length(ok.refused), 0, "no refusal") + } +} + + +[test] +def test_comment_conservation(t : T?) { + t |> run("the gate catches loss, duplication and reordering") @(t : T?) { + let was = "/*a*/ x /*b*/" + t |> success(check_comments_preserved(was, "/*a*/ y(/*b*/)").ok, "moved comments pass") + t |> success(!check_comments_preserved(was, "/*a*/ y").ok, "a lost comment fails") + t |> success(!check_comments_preserved(was, "/*a*/ /*a*/ /*b*/").ok, "a duplicated comment fails") + t |> success(!check_comments_preserved(was, "/*b*/ x /*a*/").ok, "reordered comments fail") + } +} diff --git a/utils/gen1-to-gen2/tests/test_make.das b/utils/gen1-to-gen2/tests/test_make.das new file mode 100644 index 0000000000..fdcc040067 --- /dev/null +++ b/utils/gen1-to-gen2/tests/test_make.das @@ -0,0 +1,110 @@ +options gen2 +options indenting = 4 +options rtti = true +options strict_smart_pointers = false + +require dastest/testing_boost public +require daslib/fio +require strings +require daslib/strings_boost +require ../patch.das +require ../convert.das + +//! Make-syntax conversion, on the shapes the v1 grammar allows. +//! +//! The expectations are byte-exact, including where comments land: a comment written before the +//! type stays before it, one written after the type lands after the `(`, and one written inside +//! a `Foo()` initializer joins the leading run — there is nowhere else for it to go once the +//! parens are gone. + +let FIXTURE = "{get_das_root()}/utils/gen1-to-gen2/tests/_fixture_make_syntax.das" + + +def private converted() : string { + let res <- convert_file(FIXTURE, ConvertOptions(v2 = true)) + return res.output +} + + +def private body_line(text : string; needle : string) : string { + for (ln in text |> split("\n")) { + if (ln |> find(needle) >= 0) return ln |> strip + } + return "<{needle} not found>" +} + + +[test] +def test_make_struct(t : T?) { + t |> run("every v1 make-struct shape") @(t : T?) { + let out = converted() + t |> equal(body_line(out, "v1 ="), "var v1 = Foo( a=1, b=2.0)", "fields become call arguments") + t |> equal(body_line(out, "v2 ="), "var v2 = /*a*/Foo(/*b*/ a=1)", "comments keep their side of the type") + t |> equal(body_line(out, "v3 ="), "var v3 = fixed_array(Foo( a=1), Foo( a=2))", + "';' between instances becomes a second call") + t |> equal(body_line(out, "v4 ="), "var v4 = Foo()", "no fields at all") + t |> equal(body_line(out, "v8 ="), "var v8 = Foo( /*c*/ a=1 /*d*/)", "interior comments ride along") + } + + t |> run("nested make-structs compose in one pass") @(t : T?) { + t |> equal(body_line(converted(), "v7 ="), "var v7 = Bar( a=Foo( b=2.0))", "inner and outer") + } +} + + +[test] +def test_make_array(t : T?) { + t |> run("array and tuple forms") @(t : T?) { + let out = converted() + t |> equal(body_line(out, "v5 ="), "var v5 = fixed_array( 1, 2, 3)", "';' separators become ','") + t |> equal(body_line(out, "v6 ="), "var v6 = (4, 5)", "a single tuple value is just parens") + t |> equal(body_line(out, "v9 ="), "var v9 = fixed_array( (1, 2), (3, 4))", "an array of tuples") + t |> equal(body_line(out, "v10 ="), "var v10 = struct()", "a temporary struct is constructed by name") + t |> equal(body_line(out, "v11 ="), "var v11 = fixed_array( 7)", "the dimension goes with the `auto`") + } + + t |> run("an element type moves outside the call") @(t : T?) { + let out = converted() + t |> equal(body_line(out, "v12 ="), "var v12 = fixed_array( 1, 2)", "a typed make-array") + t |> equal(body_line(out, "v13 ="), + "var v13 = fixed_array>( (\"a\", 1.0), (\"b\", 2.0))", + "a typed array of tuples, trailing separator dropped") + } +} + + +[test] +def test_make_wrappers(t : T?) { + t |> run("the array-of and table-of bracket forms") @(t : T?) { + let out = converted() + t |> equal(body_line(out, "w1 ="), "var w1 = \{ 1 => \"a\", 2 => \"b\" \}", "table literal") + t |> equal(body_line(out, "w2 ="), "var w2 = [Foo( a = 1), Foo( a = 2)]", "array of structs") + t |> equal(body_line(out, "w3 ="), "var w3 = [ 1, 2, 3]", "array of values") + } + + t |> run("comprehensions keep their body; brackets and for-head change") @(t : T?) { + let out = converted() + t |> equal(body_line(out, "w4 ="), "var w4 = [for (x in 0..10); x * x; where x % 2 == 0]", "array form") + t |> equal(body_line(out, "w5 ="), "var w5 = [iterator for (x in 0..10); x * x]", "generator form") + } +} + + +[test] +def test_make_compiles(t : T?) { + t |> run("the converted make-syntax compiles as gen2") @(t : T?) { + var issues = "" + t |> success(compiles_as_gen2(FIXTURE, converted(), issues), "compiles: {issues}") + } +} + + +[test] +def test_make_comments_conserved(t : T?) { + t |> run("no comment is lost by any make rule") @(t : T?) { + let res <- convert_file(FIXTURE, ConvertOptions(v2 = true)) + t |> equal(res.failed, "", "conversion did not fail the conservation gate") + t |> equal(length(res.refused), 0, "no rule was refused") + t |> success(check_comments_preserved(fread(FIXTURE), res.output).ok, "comments conserved") + } +} diff --git a/utils/gen1-to-gen2/tests/test_shapes.das b/utils/gen1-to-gen2/tests/test_shapes.das new file mode 100644 index 0000000000..6564ac3a18 --- /dev/null +++ b/utils/gen1-to-gen2/tests/test_shapes.das @@ -0,0 +1,296 @@ +options gen2 +options indenting = 4 +options rtti = true +options strict_smart_pointers = false + +require dastest/testing_boost public +require daslib/fio +require strings +require daslib/strings_boost +require ../convert.das + +//! v1 spellings whose rewrite is not a delimiter substitution. +//! +//! Each of these came back from converting a game's script tree in place: the output either did +//! not parse or lost a brace. They are written to temporary files rather than to a checked-in +//! fixture, because the formatter rewrites most of them on sight. + +struct private Shape { + name : string + source : string +} + + +def private has(text, needle : string) : bool { + return text |> find(needle) >= 0 +} + + +def private convert_shape(t : T?; shape : Shape; var out : string&) : bool { + let temp = create_temp_file_result(shape.name, ".das") + t |> success(temp is value, "{shape.name}: temporary fixture created") + if (!(temp is value)) return false + let path = unsafe(temp.value) + if (!(t |> success(fwrite(path, shape.source), "{shape.name}: temporary fixture written"))) { + remove(path) + return false + } + let res <- convert_file(path, ConvertOptions(v2 = true)) + out = res.output + t |> success(empty(res.refused), "{shape.name}: no edit refused") + var issues = "" + let ok = compiles_as_gen2(path, res.output, issues) + t |> success(ok, "{shape.name}: compiles as gen2: {issues}") + remove(path) + return ok +} + + +[test] +def test_else_with_trailing_comment(t : T?) { + t |> run("a comment after `else` leaves room for the brace") @(t : T?) { + var out = "" + convert_shape(t, Shape(name = "else_comment", source = + "options gen2 = false\noptions indenting = 4\n\n" + + "def f(a : int) : int\n if a > 0\n return 1\n" + + " else // which branch this is\n return 2\n return 3\n"), out) + t |> success(has(out, "\} else \{ // which branch this is"), + "the brace goes in front of the comment, not after it") + } +} + + +[test] +def test_global_let_block(t : T?) { + t |> run("a bare `let` heading a block of globals takes braces") @(t : T?) { + var out = "" + convert_shape(t, Shape(name = "global_let", source = + "options gen2 = false\noptions indenting = 4\n\n" + + "let\n A = 1\n B = 2\n\n" + + "var private\n C = 3\n\n" + + "var // the header carries a comment of its own\n E = 5\n\n" + + "let D = 4\n\ndef f\n return A + B + C + D + E\n"), out) + t |> success(has(out, "let \{"), "a `let` block opens") + t |> success(has(out, "var private \{"), "a modifier stays on the header") + t |> success(has(out, "var \{ // the header carries a comment of its own"), + "a header comment does not stop the brace") + t |> success(has(out, "let D = 4") && !has(out, "let D = 4 \{"), + "a `let` that declares its own variable is not a block") + } +} + + +[test] +def test_typeinfo_condition(t : T?) { + t |> run("a `typeinfo` condition reaches past its trait") @(t : T?) { + var out = "" + convert_shape(t, Shape(name = "typeinfo_cond", source = + "options gen2 = false\noptions indenting = 4\n\n" + + "def gen(a : auto(TT))\n static_if typeinfo is_string(type)\n" + + " return 1\n return 0\n"), out) + t |> success(has(out, "static_if (typeinfo is_string(type)) \{"), + "the whole typeinfo expression is the condition") + } +} + + +[test] +def test_call_macro_body(t : T?) { + t |> run("a quoted body is converted like any other block") @(t : T?) { + var out = "" + convert_shape(t, Shape(name = "qmacro_body", source = + "options gen2 = false\noptions indenting = 4\noptions rtti\n\n" + + "require daslib/ast_boost\nrequire daslib/templates_boost\n\n" + + "def make_it\n return <- qmacro_block() <|\n if true\n" + + " print(\"x\")\n"), out) + t |> success(has(out, "if (true) \{"), "the quoted body gets its braces") + } +} + + +[test] +def test_piped_make_literal(t : T?) { + t |> run("a make-literal at the head of a pipe becomes an argument") @(t : T?) { + var out = "" + convert_shape(t, Shape(name = "piped_make", source = + "options gen2 = false\noptions indenting = 4\n\n" + + "def has_it(w : string)\n return \{\"a\", \"b\"\} |> key_exists(w)\n\n" + + "def count_it\n return \{\"a\", \"b\"\} |> length()\n\n" + + "def keep(a : array; w : int)\n return a |> find_index(w)\n"), out) + t |> success(has(out, "return key_exists(\{\"a\", \"b\"\}, w)"), + "the literal moves into the argument list") + t |> success(has(out, "return length(\{\"a\", \"b\"\})"), + "a call with no other argument needs no comma") + t |> success(has(out, "return a |> find_index(w)"), + "a pipe that is not headed by a literal is left alone") + } +} + + +[test] +def test_stacked_block_closers(t : T?) { + t |> run("blocks that end on one line each keep their brace") @(t : T?) { + var out = "" + let ok = convert_shape(t, Shape(name = "stacked_closers", source = + "options gen2 = false\noptions indenting = 4\n\n" + + "def f(a : array; n : int)\n if n > 0\n for i in a\n" + + " if i > 0\n print(\"\{i\}\")\n return\n"), out) + t |> success(ok, "the stacked closers balance") + } +} + + +[test] +def test_indexed_condition(t : T?) { + t |> run("a condition anchored on its index is not wrapped from there") @(t : T?) { + var out = "" + convert_shape(t, Shape(name = "indexed_cond", source = + "options gen2 = false\noptions indenting = 4\n\n" + + "struct Rec\n node : int\n\n" + + "def f(arr : array; m : int)\n" + + " if ((arr[0].node == m &&\n arr[0].node == m) ||\n m > 3)\n" + + " return true\n return false\n"), out) + t |> success(!has(out, "[("), "no parenthesis opens inside the brackets") + } +} + + +[test] +def test_for_head_from_keyword(t : T?) { + t |> run("the for head starts after the keyword, not at the first iterator") @(t : T?) { + var out = "" + convert_shape(t, Shape(name = "for_head", source = + "options gen2 = false\noptions indenting = 4\n\n" + + "def f(a : array; b : array)\n for x, y in a, b\n" + + " print(\"\{x\}\{y\}\")\n"), out) + t |> success(has(out, "for (x, y in a, b) \{"), "both iterators are inside the head") + } +} + + +[test] +def test_literal_header_forms(t : T?) { + t |> run("a capture list or an annotation still belongs to the literal") @(t : T?) { + var out = "" + convert_shape(t, Shape(name = "literal_header", source = + "options gen2 = false\noptions indenting = 4\n\n" + + "def f\n var templ = \"t\"\n" + + " let c <- @ <| capture(<- templ) (reid : int)\n print(\"\{reid\}\")\n" + + " let d <- $ <| [unused_argument(w)] (w : int)\n return 1\n" + + " invoke(c, 1)\n return invoke(d, 1)\n"), out) + t |> success(!has(out, "<|"), "the pipe goes away in both forms") + } +} + + +[test] +def test_multiline_initializer(t : T?) { + t |> run("a block in an initializer is not a continued expression") @(t : T?) { + var out = "" + convert_shape(t, Shape(name = "multiline_init", source = + "options gen2 = false\noptions indenting = 4\n\n" + + "def f\n" + + " let a <- @ <| (eid : int)\n // what this one does\n" + + " print(\"\{eid\}\")\n" + + " invoke(a, 1)\n"), out) + t |> success(!has(out, "(eid : int)("), "the lambda is not wrapped in parentheses") + } +} + +[test] +def test_bodyless_declaration(t : T?) { + t |> run("a declaration with no body still gets one") @(t : T?) { + var out = "" + convert_shape(t, Shape(name = "bodyless_decl", source = + "options gen2 = false\noptions indenting = 4\n\n" + + "struct Empty\n\nstruct WithBody\n a : int\n\n" + + "struct AlreadyBraced \{\}\n\nstruct BracedNextLine\n\{\}\n\n" + + "typedef\n Alias = int\n"), out) + t |> success(has(out, "struct Empty \{\}"), "an empty struct gets an empty body") + t |> success(!has(out, "struct BracedNextLine \{\}"), + "braces already on the next line are a body") + t |> success(has(out, "struct WithBody \{"), "a struct with a body is unaffected") + t |> success(has(out, "typedef Alias = int") && !has(out, "typedef Alias = int \{\}"), + "a typedef has no body to give") + } +} + +[test] +def test_match_subject(t : T?) { + t |> run("a call macro spelled as a keyword parenthesises its subject") @(t : T?) { + var out = "" + convert_shape(t, Shape(name = "match_subject", source = + "options gen2 = false\noptions indenting = 4\n\nrequire daslib/match\n\n" + + "def pick(v : int) : float\n match v\n if 1\n return 0.75\n" + + " if _\n return 1.3\n return 0.0\n"), out) + t |> success(has(out, "match(v) \{"), "the subject takes parentheses") + } +} + + +[test] +def test_comment_does_not_end_a_body(t : T?) { + t |> run("a comment between methods does not close the class") @(t : T?) { + var out = "" + convert_shape(t, Shape(name = "comment_banner", source = + "options gen2 = false\noptions indenting = 4\n\n" + + "class Canvas\n origin : float2\n\n def reset\n" + + " origin = float2(0.0, 0.0)\n\n\n" + + "// *** a banner at column 0 ***\n\n" + + " def setOrigin(o : float2)\n origin = o\n"), out) + t |> success(has(out, " \}\n\}"), "the class closes after the last method") + } +} + + +[test] +def test_make_literal_closer(t : T?) { + t |> run("a make-literal reaches past its closing bracket") @(t : T?) { + var out = "" + convert_shape(t, Shape(name = "make_closer", source = + "options gen2 = false\noptions indenting = 4\n\n" + + "def f(n : int)\n for k in [n - 1, n + 1]\n print(\"\{k\}\")\n"), out) + t |> success(has(out, "for (k in [n - 1, n + 1]) \{"), "the head closes after the bracket") + } +} + + +[test] +def test_static_elif(t : T?) { + t |> run("static_elif takes parentheses like static_if") @(t : T?) { + var out = "" + convert_shape(t, Shape(name = "static_elif", source = + "options gen2 = false\noptions indenting = 4\n\n" + + "def gen(value : auto(TT))\n" + + " static_if typeinfo is_string(type)\n return 1\n" + + " static_elif typeinfo is_array(type)\n return 2\n return 0\n"), out) + t |> success(has(out, "static_elif (typeinfo is_array(type)) \{"), + "the elif form is a condition too") + } +} + + +[test] +def test_closer_and_generators(t : T?) { + t |> run("an index next to the closer is not the closer") @(t : T?) { + var out = "" + if (convert_shape(t, Shape(name = "index_before_closer", source = + "options gen2 = false\n\nstruct Foo\n a : int\n\n" + + "def f(arr : array)\n var v = [[Foo a=arr[0]]]\n return v.a\n"), out)) { + t |> success(has(out, "Foo( a=arr[0])"), "the whole index survives ({out})") + } + } + + t |> run("both generator spellings stay generators") @(t : T?) { + var out = "" + if (convert_shape(t, Shape(name = "generator_spellings", source = + "options gen2 = false\n\ndef g()\n" + + " var c <- \{\{for x in range(3); x*2\}\}\n" + + " var d <- \{\{for x in range(3); x => x*2\}\}\n" + + " var e <- [\{for x in range(3); x*2\}]\n return length(e)\n"), out)) { + t |> success(has(out, "var c <- [iterator for (x in range(3)); x*2]"), "no-arrow stays an iterator") + t |> success(has(out, "var d <- [iterator for (x in range(3)); x => x*2]"), "arrow stays an iterator") + t |> success(has(out, "var e <- [for (x in range(3)); x*2]"), "the array spelling stays an array") + } + } +} diff --git a/utils/gen1-to-gen2/tests/test_stmt.das b/utils/gen1-to-gen2/tests/test_stmt.das new file mode 100644 index 0000000000..a6da52148b --- /dev/null +++ b/utils/gen1-to-gen2/tests/test_stmt.das @@ -0,0 +1,147 @@ +options gen2 +options indenting = 4 +options rtti = true +options strict_smart_pointers = false + +require dastest/testing_boost public +require daslib/fio +require strings +require daslib/strings_boost +require ../patch.das +require ../convert.das + +//! Statement and declaration conversion: indentation becomes braces, conditions gain +//! parentheses, and the result has to compile as gen2 — which is the only check that really +//! says the rewrite worked. + +let STMT = "{get_das_root()}/utils/gen1-to-gen2/tests/_fixture_gen1_stmt.das" +let DECL = "{get_das_root()}/utils/gen1-to-gen2/tests/_fixture_gen1_decl.das" + + +def private convert(file : string) : string { + let res <- convert_file(file, ConvertOptions(v2 = true)) + return res.output +} + + +def private has(text, needle : string) : bool { + return text |> find(needle) >= 0 +} + + +[test] +def test_statement_braces(t : T?) { + t |> run("blocks, conditions and the else/recover joins") @(t : T?) { + let out = convert(STMT) + t |> success(has(out, "def classify(n : int) \{"), "function body opens on the header line") + t |> success(has(out, "for (i in range(n)) \{"), "for head is parenthesised whole") + t |> success(has(out, "if (i % 2 == 0) \{"), "a condition is its subtree, not its operator") + t |> success(has(out, "total += i // counted\n \} else \{"), + "else joins past a trailing comment") + t |> success(has(out, "while (total > 100) \{"), "while condition") + t |> success(has(out, "classify(3) // may fail\n \} recover \{"), + "recover joins past a trailing comment") + t |> success(has(out, "def commented(n : int) \{ // what this one is for"), + "a commented header still gets its brace") + t |> success(has(out, "return n + 1 // and what it gives back\n\}"), + "the closing brace clears a trailing comment") + t |> success(has(out, "take_block <| $() \{"), "a bare piped block gains its block header") + t |> success(has(out, "for (tt in a[0]) \{"), "an indexed for source is wrapped whole") + t |> success(has(out, "$(@optional a : int)"), "an argument annotation becomes `@name`") + t |> success(has(out, "var (lo, hi) = (1, 2)"), "tuple destructuring drops the make brackets") + t |> success(has(out, "typeinfo sizeof(a)"), "the typeinfo trait moves out of the parens") + t |> success(has(out, "let c = Color.green"), "an enumeration value takes the dot") + t |> success(has(out, "let fl = Flags2.one"), "so does a bitfield value") + t |> success(has(out, "reinterpret(h.b)"), "a cast becomes call-style") + t |> success(has(out, "if (v is i && c == Color.green) \{"), + "a variant test reaches past its field name") + t |> success(has(out, "return (1, \"2\")"), "a multi-value return is one tuple") + t |> success(has(out, "var blk = $ (a, b : int) \{"), "a piped literal drops the pipe") + t |> success(has(out, "let braced_lambda = @ () \{\}"), "a braced literal drops the pipe too") + t |> success(has(out, "static_if (GATE) \{"), "static_if takes parentheses") + } + + t |> run("the converted statements compile as gen2") @(t : T?) { + var issues = "" + t |> success(compiles_as_gen2(STMT, convert(STMT), issues), "compiles: {issues}") + } +} + + +//! Shapes only v1 spells, and only in a file the formatter never rewrites: they are written +//! to a temporary file rather than kept in a checked-in fixture. + +[test] +def test_v1_only_shapes(t : T?) { + t |> run("a comment where whitespace would be keeps the keyword's head") @(t : T?) { + let temp = create_temp_file_result("commented_head", ".das") + t |> success(temp is value, "temporary fixture created") + if (!(temp is value)) return + let path = unsafe(temp.value) + t |> success(fwrite(path, "options gen2 = false\n\ndef f(n : int)\n var acc = 0\n" + + " for/*i*/i in range(n)\n if/*c*/i % 2 == 0\n acc += i\n return acc\n"), + "temporary fixture written") + let res <- convert_file(path, ConvertOptions(v2 = true)) + remove(path) + t |> success(has(res.output, "for/*i*/(i in range(n)) \{"), "the for head is parenthesised") + t |> success(has(res.output, "if/*c*/(i % 2 == 0) \{"), "and so is the if subject") + } + t |> run("a type function takes its type as an argument") @(t : T?) { + let temp = create_temp_file_result("type_function", ".das") + t |> success(temp is value, "temporary fixture created") + if (!(temp is value)) return + let path = unsafe(temp.value) + t |> success(fwrite(path, "options gen2 = false\n\n[type_function]\n" + + "def take_t ( a : auto(TT); a1, a2 : int )\n return typeinfo(sizeof type) + a1 + a2\n\n" + + "def f()\n return take_t(1, 2)\n"), "temporary fixture written") + let res <- convert_file(path, ConvertOptions(v2 = true)) + remove(path) + t |> success(has(res.output, "take_t(type, 1, 2)"), + "the type moves into the argument list ({res.output})") + } + t |> run("a continued initializer keeps its lines in one expression") @(t : T?) { + let temp = create_temp_file_result("continued_init", ".das") + t |> success(temp is value, "temporary fixture created") + if (!(temp is value)) return + let path = unsafe(temp.value) + t |> success(fwrite(path, "def main() \{\n let x = 1\n+\n2;\n\}\n"), "temporary fixture written") + let res <- convert_file(path, ConvertOptions(v2 = true)) + remove(path) + t |> success(res.output |> find("let x = (1\n+\n2);") >= 0, + "the whole expression is parenthesised ({res.output})") + } +} + + +[test] +def test_declaration_braces(t : T?) { + t |> run("declaration bodies") @(t : T?) { + let out = convert(DECL) + t |> success(has(out, "enum Color \{"), "enum body") + t |> success(has(out, "bitfield Flags \{"), "bitfield body") + t |> success(has(out, "struct Point \{"), "struct body") + t |> success(has(out, "class Shape \{"), "class body") + t |> success(has(out, "def area() : int \{"), "a method body is braced once, not twice") + t |> success(has(out, "typedef IntAlias = int"), "first alias") + t |> success(has(out, "typedef StrAlias = string"), "second alias") + t |> success(!has(out, "typedef\n"), "the bare header line is gone") + } + + t |> run("the converted declarations compile as gen2") @(t : T?) { + var issues = "" + t |> success(compiles_as_gen2(DECL, convert(DECL), issues), "compiles: {issues}") + } +} + + +[test] +def test_statements_keep_comments(t : T?) { + t |> run("no comment is lost converting statements or declarations") @(t : T?) { + for (f in [STMT, DECL]) { + let res <- convert_file(f, ConvertOptions(v2 = true)) + t |> equal(res.failed, "", "{f} converted") + t |> equal(length(res.refused), 0, "{f}: no refused edits") + t |> success(check_comments_preserved(fread(f), res.output).ok, "{f}: comments conserved") + } + } +} diff --git a/utils/internal/lineinfo-audit/README.md b/utils/internal/lineinfo-audit/README.md index ff38464fd9..26bb827800 100644 --- a/utils/internal/lineinfo-audit/README.md +++ b/utils/internal/lineinfo-audit/README.md @@ -6,6 +6,7 @@ lint auto-fix, extract-method/refactoring in the VSCode plugin, LSP features. ``` daslang utils/internal/lineinfo-audit/main.das -- -p tests -p daslib [-s 5] [--max-files N] [-v] [--fails] + [--parse-only] [--gen1] ``` Compiles each file (`no_optimizations`, full macro pipeline), walks every @@ -20,6 +21,13 @@ non-generated user function, and checks each node against the source: | `block` | `ExprBlock` starts at `{` and ends at `}` | | `enclosure` | call `atEnclosure` ends at `)` | +## Modes + +`--parse-only` audits the pre-infer tree (`parse_file`) instead of the compiled one. `--gen1` +additionally parses as v1 syntax (`version_2_syntax = false`) and implies `--parse-only`; it is +how a v1 to gen2 converter's anchors get validated. Two checks soften in `--gen1`: an indent +block carries no braces to check, and a `[[` / `[{` / `{{` make-literal anchors on its bracket. + ## Coordinate conventions (probed ground truth) Lines are 1-based, columns 0-based byte offsets, ranges end-exclusive. Most diff --git a/utils/internal/lineinfo-audit/main.das b/utils/internal/lineinfo-audit/main.das index 0064b773e7..4c047416b6 100644 --- a/utils/internal/lineinfo-audit/main.das +++ b/utils/internal/lineinfo-audit/main.das @@ -32,6 +32,13 @@ struct Config { @clarg_doc = "List files that failed to compile" fails : bool + @clarg_name = "parse-only" + @clarg_doc = "Audit the pre-infer tree (parse_file) instead of the compiled one — what source-rewriting tools see" + parse_only : bool + + @clarg_doc = "Parse as v1 syntax (version_2_syntax = false); implies --parse-only" + gen1 : bool + @clarg_short = "?" @clarg_name = "show-help" @clarg_doc = "Show this help and exit" @@ -130,6 +137,7 @@ struct Violation { class AuditVisitor : AstVisitor { src_lines : array file_norm : string + gen1_mode : bool = false fn_generated : bool = true fn_decl_valid : bool = false fn_decl_l0 : int @@ -235,9 +243,8 @@ class AuditVisitor : AstVisitor { } def override preVisitExprVar(expr : ExprVar?) { - if (expr.genFlags.generated || !same_file(expr.at)) return let nm = string(expr.name) - if (nm |> starts_with("__")) return // compiler-internal temps + if (expr.genFlags.generated || !same_file(expr.at) || nm |> starts_with("__")) return let actual = text_at(expr.at) if (actual |> starts_with(" starts_with(" starts_with(" starts_with("" || tok == ".") return check_anchor("ExprField", expr.atField, string(expr.name)) } @@ -311,6 +319,7 @@ class AuditVisitor : AstVisitor { if (same_file(v.at) && !(v.name |> starts_with("__"))) { let vnm = string(v.name) let vtext = text_at(v.at) + if (vtext |> find(",") >= 0) continue // segment match covers aka-mangled names if (!name_segment_matches(vnm, vtext)) { report("anchor", "LetVariable", vnm, vtext, v.at) @@ -418,6 +427,7 @@ class AuditVisitor : AstVisitor { let lc = int(blk.at.last_column) if (l < 1 || ll < 1) return let opener = first_char(blk.at) + if (gen1_mode && opener != "\{") return let end_ln = line_of(ll) let closer = (lc >= 1 && lc <= length(end_ln)) ? slice(end_ln, lc - 1, lc) : "" if (opener != "\{" || closer != "\}") { @@ -438,7 +448,7 @@ class AuditVisitor : AstVisitor { // leaves the folded const anchored on the folded expression's range — // only structurally-broken ranges are reportable here def check_const_range(node : string; expr : ExpressionPtr) { - if (expr.genFlags.generated || !same_file(expr.at)) return + if (expr.genFlags.generated || !same_file(expr.at) || expr is ExprConstString) return let actual = text_at(expr.at) if (actual == "") { report("anchor", node, "single-token literal", "{int(expr.at.line)}:{int(expr.at.column)}..{int(expr.at.last_line)}:{int(expr.at.last_column)}", expr.at) @@ -494,7 +504,41 @@ def visit_one(func : FunctionPtr; var v : AuditVisitor?; } -def audit_file(file : string; verbose : bool; +def private audit_program(program : ProgramPtr; file : string; src_lines : array; gen1 : bool; + var counts : table; + var samples : table>; + max_samples : int; + var n_violations : int&) { + let file_norm = normalize_path(file) + var v = new AuditVisitor() + v.src_lines := src_lines + v.file_norm = file_norm + v.gen1_mode = gen1 + var seen_fn : table + for_each_generic(get_this_module(program), "") $(func) { + visit_one(func, v, seen_fn, file_norm) + } + for_each_function(get_this_module(program), "") $(func) { + visit_one(func, v, seen_fn, file_norm) + } + for (viol in v.out) { + let key = "{viol.check}/{viol.node}" + if (key_exists(counts, key)) { + counts[key] = counts[key] + 1 + } else { + counts |> insert(key, 1) + } + n_violations++ + if (length(samples[key]) < max_samples) { + samples[key] |> push("{viol.file}:{viol.line}:{viol.column} expected {viol.expected} got {viol.actual}") + } + } + unsafe { + delete v + } +} + +def audit_file(file : string; verbose, parse_only, gen1 : bool; var counts : table; var samples : table>; max_samples : int; @@ -512,42 +556,29 @@ def audit_file(file : string; verbose : bool; using() $(var cop : CodeOfPolicies) { cop.ignore_shared_modules = true cop.export_all = true - cop.version_2_syntax = true + cop.version_2_syntax = !gen1 cop.no_optimizations = true - compile_file(file, access, unsafe(addr(mg)), cop) $(ok; program; issues) { - if (!ok) { - ok_compile = false - if (verbose) { - to_log(LOG_ERROR, "FAIL {file}\n {issues}\n") + if (parse_only || gen1) { + parse_file(file, access, unsafe(addr(mg)), cop) $(ok; program; issues) { + if (!ok) { + ok_compile = false + if (verbose) { + to_log(LOG_ERROR, "FAIL {file}\n {issues}\n") + } + return } - return - } - let thisMod = get_this_module(program) - let file_norm = normalize_path(file) - var v = new AuditVisitor() - v.src_lines := src_lines - v.file_norm = file_norm - var seen_fn : table - for_each_generic(thisMod, "") $(func) { - visit_one(func, v, seen_fn, file_norm) + audit_program(program, file, src_lines, gen1, counts, samples, max_samples, n_violations) } - for_each_function(thisMod, "") $(func) { - visit_one(func, v, seen_fn, file_norm) - } - for (viol in v.out) { - let key = "{viol.check}/{viol.node}" - if (key_exists(counts, key)) { - counts[key] = counts[key] + 1 - } else { - counts |> insert(key, 1) - } - n_violations++ - if (length(samples[key]) < max_samples) { - samples[key] |> push("{viol.file}:{viol.line}:{viol.column} expected {viol.expected} got {viol.actual}") + } else { + compile_file(file, access, unsafe(addr(mg)), cop) $(ok; program; issues) { + if (!ok) { + ok_compile = false + if (verbose) { + to_log(LOG_ERROR, "FAIL {file}\n {issues}\n") + } + return } - } - unsafe { - delete v + audit_program(program, file, src_lines, gen1, counts, samples, max_samples, n_violations) } } } @@ -591,7 +622,8 @@ def main() : int { var n_skip = 0 var n_violations = 0 var failed_files : array - to_log(LOG_INFO, "auditing {length(files)} file(s)...\n") + let mode = cfg.gen1 ? "parse-only, v1 syntax" : (cfg.parse_only ? "parse-only" : "compiled") + to_log(LOG_INFO, "auditing {length(files)} file(s) [{mode}]...\n") for (i in range(length(files))) { let file = files[i] if (has_expect_directive(file)) { @@ -601,7 +633,7 @@ def main() : int { if (cfg.verbose) { to_log(LOG_INFO, "[{i + 1}/{length(files)}] {file}\n") } - if (audit_file(file, cfg.verbose, counts, samples, cfg.samples, n_violations)) { + if (audit_file(file, cfg.verbose, cfg.parse_only, cfg.gen1, counts, samples, cfg.samples, n_violations)) { n_ok++ } else { n_fail++ diff --git a/utils/internal/test-release/utils_phase.das b/utils/internal/test-release/utils_phase.das index 7e4beeeb46..2c2bb4f3fd 100644 --- a/utils/internal/test-release/utils_phase.das +++ b/utils/internal/test-release/utils_phase.das @@ -39,6 +39,9 @@ def public utils_checks() : array { // the exe form must be able to compile a test at all: an -exe tool bakes its build machine's native paths ToolCheck(name = "dastest.exe/common-suite", argv <- ["@EXE:dastest@", "--test", "utils/common/tests"], want := DASTEST_OK, forbid := DASTEST_EMPTY, timeout = 300.0), + ToolCheck(name = "gen1-to-gen2/convert", + argv <- ["@EXE:daslang@", "utils/gen1-to-gen2/main.das", "--", "-p", "utils/mcp/tests/_fixture_gen1.das"], + want <- ["options gen2", "struct Point \{"]), // --- lint / format over the shipped daslib (the tree is at zero, and stays so) ----- ToolCheck(name = "lint.exe/help", argv <- ["@EXE:lint@", "--help"], want <- ["Unified lint checker for daslang files."]), ToolCheck(name = "lint.exe/daslib", argv <- ["@EXE:lint@", "daslib"], diff --git a/utils/mcp/README.md b/utils/mcp/README.md index cf2b2e899d..99d0a2d741 100644 --- a/utils/mcp/README.md +++ b/utils/mcp/README.md @@ -20,7 +20,7 @@ A [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) server that e | `find_symbol` | Cross-module symbol search (functions, generics, structs, handled types, enums, globals, typedefs/aliases, fields). Case-insensitive substring by default; `=query` for exact match | | `list_requires` | Compile a `.das` file and list all `require` dependencies (direct and transitive), with source file paths and builtin annotations. Optional `json` for structured output | | `list_module_api` | List all functions, types, enums, and globals exported by a builtin or daslib module (e.g. `math`, `strings`, `fio`, `daslib/json`). Optional `compact` mode for large modules | -| `convert_to_gen2` | Convert a `.das` file from gen1 (indentation-based) syntax to gen2 (braces/parentheses) using the `gen1_to_gen2` converter. Optional `inplace` flag to modify the file directly | +| `convert_to_gen2` | Convert a `.das` file from gen1 (indentation-based) syntax to gen2 (braces/parentheses) using the `utils/gen1-to-gen2` converter. Optional `inplace` flag to modify the file directly | | `goto_definition` | Given a cursor position (file, line, column), resolve the definition of the symbol under the cursor. Returns location, kind (variable/function/field/builtin/struct/enum/typedef), and source snippet. Optional `no_opt` to preserve pre-optimization AST | | `type_of` | Given a cursor position (file, line, column), return the resolved type of the expression under the cursor. Shows all expressions at position from innermost to outermost. Optional `no_opt` | | `find_references` | Find all references to the symbol under the cursor (function calls, variable uses, field accesses, type refs, enum/bitfield values, aliases). Works from both usage and declaration sites. Scope: `file` (default) or `all` (all loaded modules). Optional `no_opt` | diff --git a/utils/mcp/registry_das.das b/utils/mcp/registry_das.das index 45f811261b..b370bf5487 100644 --- a/utils/mcp/registry_das.das +++ b/utils/mcp/registry_das.das @@ -196,7 +196,7 @@ def build_das_tools(var reg : array) { // nolint:STYLE038 — flat tool reg |> emplace(ToolDef( tool <- make_tool( "convert_to_gen2", - "Convert a daslang source file from v1 (indentation-based) syntax to gen2 (braces, parentheses) syntax using the gen1_to_gen2 converter. Returns converted code or writes in place.", + "Convert a daslang source file from v1 (indentation-based) syntax to gen2 (braces, parentheses) syntax using the gen1-to-gen2 converter. Returns converted code or writes in place.", { "file" => PropertySchema(_type = "string", description = "Path to the .das file to convert"), "inplace" => PropertySchema(_type = "string", description = "If 'true', overwrite the file in place. Otherwise return converted code to stdout.") diff --git a/utils/mcp/tools/convert_to_gen2.das b/utils/mcp/tools/convert_to_gen2.das index 15127b416a..5239943efe 100644 --- a/utils/mcp/tools/convert_to_gen2.das +++ b/utils/mcp/tools/convert_to_gen2.das @@ -2,16 +2,6 @@ options gen2 require common public -// Strip the "input file=..." diagnostic line gen1_to_gen2 prints to stdout -def strip_converter_header(output : string) : string { - if (starts_with(output, "input file=")) { - let nl = find(output, "\n") - if (nl >= 0) return slice(output, nl + 1) - return "" - } - return output -} - def do_convert_to_gen2(file : string; inplace : bool) : string { if (empty(file)) return make_tool_result("missing 'file' argument", true) // check file exists @@ -24,12 +14,11 @@ def do_convert_to_gen2(file : string; inplace : bool) : string { if (!file_ok) return make_tool_result("file not found: {file}", true) let args <- get_command_line_arguments() if (empty(args)) return make_tool_result("Cannot determine executable path", true) - // the gen1_to_gen2 converter lives next to daslang.exe + // the converter is a daslang script in the tree, run through this same daslang let exe = args[0] - let exe_dir = dir_name(exe) - let fmt_exe = "{exe_dir}/gen1_to_gen2" + let converter = "{get_das_root()}/utils/gen1-to-gen2/main.das" let inplace_flag = inplace ? " -i" : "" - let cmd = "{fmt_exe} -v2{inplace_flag} {file}" + let cmd = "{exe} \"{converter}\" -- -p \"{file}\"{inplace_flag}" var output : string let exit_code = unsafe(popen(cmd) $(f) { if (f == null) { @@ -43,7 +32,6 @@ def do_convert_to_gen2(file : string; inplace : bool) : string { } } ) - output = strip_converter_header(output) if (exit_code != 0) return make_tool_result("Conversion failed (exit code {exit_code}):\n{output}", true) if (inplace) return make_tool_result("Converted {file} to gen2 syntax in place") return make_tool_result(output)