From 2a877f2b9050eac2689cb7618f74a54d250c4424 Mon Sep 17 00:00:00 2001 From: Daniil Zaikin Date: Wed, 19 Jun 2024 00:16:08 +1000 Subject: [PATCH 01/13] fix ppj bugs --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 25cd78b..e617356 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,5 @@ Caprica/INSTALL.vcxproj.filters Caprica/cmake_install.cmake x64/ +/out/install/x64-Debug/bin +/CMakeSettings.json From 9596687af99f7c4824b3ab2d5444db0e5dab88e1 Mon Sep 17 00:00:00 2001 From: Daniil Zaikin Date: Wed, 19 Jun 2024 00:16:38 +1000 Subject: [PATCH 02/13] guh --- Caprica/common/CapricaInputFile.cpp | 2 +- Caprica/papyrus/PapyrusCompilationContext.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Caprica/common/CapricaInputFile.cpp b/Caprica/common/CapricaInputFile.cpp index abaa368..bf683dc 100644 --- a/Caprica/common/CapricaInputFile.cpp +++ b/Caprica/common/CapricaInputFile.cpp @@ -140,7 +140,7 @@ PCompInputFile::PCompInputFile(const std::filesystem::path& _path, bool isFolder, const std::filesystem::path& _cwd) : IInputFile(_path, noRecurse, _cwd) { - isFolder = isFolder; + this->isFolder = isFolder; } bool PCompInputFile::resolve() { diff --git a/Caprica/papyrus/PapyrusCompilationContext.cpp b/Caprica/papyrus/PapyrusCompilationContext.cpp index 493b97e..a184183 100644 --- a/Caprica/papyrus/PapyrusCompilationContext.cpp +++ b/Caprica/papyrus/PapyrusCompilationContext.cpp @@ -126,7 +126,8 @@ std::string_view findScriptName(const std::string_view& data, const std::string_ next = data.size() - 1; auto line = data.substr(last, next - last); auto begin = line.find_first_not_of(" \t"); - if (strnicmp(line.substr(begin, startstring.size()).data(), startstring.data(), startstring.size()) == 0) { + auto startSize = startstring.size(); + if (line.size() > startSize && strnicmp(line.substr(begin, startSize).data(), startstring.data(), startSize) == 0) { auto first = line.find_first_not_of(" \t", startstring.size() + begin); return line.substr(first, line.find_first_of(" \t", first) - first); } From 4d48bc711c86d04701eaa86d52141bb4f78a5ec3 Mon Sep 17 00:00:00 2001 From: Daniil Zaikin Date: Fri, 13 Sep 2024 16:13:59 +1000 Subject: [PATCH 03/13] change skyrim-allow-unknown-events-on-non-native-class default value to true, as all other strict checks are disabled by default --- Caprica/main_options.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Caprica/main_options.cpp b/Caprica/main_options.cpp index 5347c94..06efd91 100644 --- a/Caprica/main_options.cpp +++ b/Caprica/main_options.cpp @@ -206,7 +206,7 @@ bool parseCommandLineArguments(int argc, char* argv[], caprica::CapricaJobManage "Ensure values returned from BetaOnly and DebugOnly functions don't escape, as that will cause invalid code generation.") ("disable-implicit-conversion-from-none", po::bool_switch()->default_value(false), "Disable implicit conversion from None in most situations where the use of None likely wasn't the author's intention.") - ("skyrim-allow-unknown-events-on-non-native-class", po::value(&conf::Skyrim::skyrimAllowUnknownEventsOnNonNativeClass)->default_value(false), + ("skyrim-allow-unknown-events-on-non-native-class", po::value(&conf::Skyrim::skyrimAllowUnknownEventsOnNonNativeClass)->default_value(true), "Allow unknown events to be defined on non-native classes. This is encountered with some scripts in the base game having Events that are not present on ObjectReference."); po::options_description skyrimCompatibilityDesc("Skyrim compatibility (default true with '--game=skyrim')"); From df605170d3f991b71c4e22cd6b61097e4a33079d Mon Sep 17 00:00:00 2001 From: Daniil Zaikin Date: Fri, 13 Sep 2024 20:03:27 +1000 Subject: [PATCH 04/13] add cmakepresets and improve build script --- .github/workflows/build.yml | 35 ++++------------ CMakePresets.json | 82 +++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 26 deletions(-) create mode 100644 CMakePresets.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4f6b546..1a21ef1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,6 @@ env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Release PROJECT_NAME: Caprica - CMAKE_ARGS: "-DCHAMPOLLION_USE_STATIC_RUNTIME:BOOL=TRUE -DENABLE_STATIC_RUNTIME:BOOL=TRUE -DCMAKE_INSTALL_PREFIX:STRING=build/extern -DVCPKG_TARGET_TRIPLET:STRING=x64-windows-static -DCMAKE_TOOLCHAIN_FILE:STRING=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" jobs: build: @@ -23,32 +22,16 @@ jobs: steps: - uses: actions/checkout@v3 - - - name: Setup vcpkg - working-directory: c:/ - run: | - git clone https://github.com/microsoft/vcpkg.git - cd vcpkg - bootstrap-vcpkg.bat - vcpkg.exe integrate install + - uses: lukka/get-cmake@latest - - name: Cache vcpkg packages - uses: actions/cache@v3 - with: - path: ${{github.workspace}}/build/vcpkg_installed - key: ${{ runner.os }}-vcpkg-${{ hashFiles('${{github.workspace}}/vcpkg.json') }} - restore-keys: | - ${{ runner.os }}-vcpkg-${{ hashFiles('${{github.workspace}}/vcpkg.json') }} - ${{ runner.os }}-vcpkg- - - - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCAPRICA_USE_STATIC_RUNTIME:BOOL=TRUE -DENABLE_STATIC_RUNTIME:BOOL=TRUE -DCMAKE_INSTALL_PREFIX:STRING=build/extern -DVCPKG_TARGET_TRIPLET:STRING=x64-windows-static -DCMAKE_TOOLCHAIN_FILE:STRING=C:/vcpkg/scripts/buildsystems/vcpkg.cmake + - name: Setup vcpkg (without building packages) + uses: lukka/run-vcpkg@v11 - - name: Build - # Build your program with the given configuration - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + - name: Run CMake in accordance with CMakePreset.json and run vcpkg + uses: lukka/run-cmake@v10 + with: + buildPreset: "release-msvc" + buildPresetAdditionalArgs: "['--config Release']" - name: Upload a Build Artifact uses: actions/upload-artifact@v3.1.2 @@ -56,7 +39,7 @@ jobs: # Artifact name name: ${{ env.PROJECT_NAME }} # A file, directory or wildcard pattern that describes what to upload - path: build/Caprica/Release/Caprica.exe + path: build/extern/Caprica/Caprica.exe # The desired behavior if no files are found using the provided path. retention-days: 90 diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..9e3b418 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,82 @@ +{ + "version": 8, + "cmakeMinimumRequired": { + "major": 3, + "minor": 21, + "patch": 0 + }, + "configurePresets": [ + { + "name": "base", + "hidden": true, + "cacheVariables": { + "CAPRICA_USE_STATIC_RUNTIME": { + "type": "BOOL", + "value": "TRUE" + }, + "ENABLE_STATIC_RUNTIME": { + "type": "BOOL", + "value": "TRUE" + }, + "CMAKE_CXX_FLAGS": "$env{CPP_COMPILER}" + } + }, + { + "name": "vcpkg", + "hidden": true, + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "VCPKG_TARGET_TRIPLET": "x64-windows-static" + } + }, + { + "name": "x64", + "hidden": true, + "architecture": { + "value": "x64", + "strategy": "external" + } + }, + { + "name": "msvc", + "hidden": true, + "environment": { + "CPP_COMPILER": "/permissive- /Zc:preprocessor /EHsc $penv{CXXFLAGS}" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "intelliSenseMode": "windows-msvc-x64", + "enableMicrosoftCodeAnalysis": true, + "enableClangTidyCodeAnalysis": true + } + } + }, + { + "name": "build-release-msvc", + "inherits": [ + "base", + "vcpkg", + "x64", + "msvc" + ], + "displayName": "Release", + "description": "Optimized release Build.", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/extern", + "cacheVariables": { + "CMAKE_BUILD_TYPE": { + "type": "STRING", + "value": "RelWithDebInfo" + } + } + } + ], + "buildPresets": [ + { + "name": "release-msvc", + "displayName": "Release (MSVC)", + "configurePreset": "build-release-msvc", + "description": "Optimized release Build." + } + ] +} \ No newline at end of file From 598d4c44cbf49c12405482c8f9d41bfd75c08651 Mon Sep 17 00:00:00 2001 From: Daniil Zaikin Date: Fri, 13 Sep 2024 20:12:57 +1000 Subject: [PATCH 05/13] adjust run-cmake --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1a21ef1..d5af157 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,8 +30,9 @@ jobs: - name: Run CMake in accordance with CMakePreset.json and run vcpkg uses: lukka/run-cmake@v10 with: - buildPreset: "release-msvc" - buildPresetAdditionalArgs: "['--config Release']" + cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' + configurePreset: release-msvc + configurePresetAdditionalArgs: "['-DCMAKE_TOOLCHAIN_FILE:STRING=C:/vcpkg/scripts/buildsystems/vcpkg.cmake']" - name: Upload a Build Artifact uses: actions/upload-artifact@v3.1.2 From 3598e51170dae7edb8d69e7da155677e5f2e69e1 Mon Sep 17 00:00:00 2001 From: Daniil Zaikin Date: Fri, 13 Sep 2024 20:17:57 +1000 Subject: [PATCH 06/13] bring vcpkg-configuration out into new file --- vcpkg-configuration.json | 21 +++++++++++++++++++++ vcpkg.json | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 vcpkg-configuration.json diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 0000000..32e63b2 --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,21 @@ +{ + "default-registry": { + "kind": "git", + "repository": "https://github.com/Microsoft/vcpkg", + "baseline": "4cb4a5c5ddcb9de0c83c85837ee6974c8333f032" + }, + "registries": [ + { + "kind": "git", + "repository": "https://github.com/microsoft/vcpkg", + "baseline": "7ef729383ab801504035a4445b6dbca18c8865c8", + "packages": [ "boost-modular-build-helper" ] + }, + { + "kind": "git", + "repository": "https://github.com/microsoft/vcpkg", + "baseline": "caa7579a1c48e2ca770f6ccf98cb03db95642631", + "packages": [ "boost*", "boost-*" ] + } + ] +} \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json index c9e449e..55cb3d8 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -10,27 +10,6 @@ "dependencies": [ "boost-container" ], - "vcpkg-configuration": { - "default-registry": { - "kind": "git", - "repository": "https://github.com/Microsoft/vcpkg", - "baseline": "4cb4a5c5ddcb9de0c83c85837ee6974c8333f032" - }, - "registries": [ - { - "kind": "git", - "repository": "https://github.com/microsoft/vcpkg", - "baseline": "7ef729383ab801504035a4445b6dbca18c8865c8", - "packages": [ "boost-modular-build-helper" ] - }, - { - "kind": "git", - "repository": "https://github.com/microsoft/vcpkg", - "baseline": "caa7579a1c48e2ca770f6ccf98cb03db95642631", - "packages": [ "boost*", "boost-*" ] - } - ] - }, "features": { "standalone": { "description": "Build as a standalone program", From 2c4045913b003a645c828fccc1d34b855fbfa437 Mon Sep 17 00:00:00 2001 From: Daniil Zaikin Date: Fri, 13 Sep 2024 20:40:58 +1000 Subject: [PATCH 07/13] adjusts name --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d5af157..dae567e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,8 +31,9 @@ jobs: uses: lukka/run-cmake@v10 with: cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' - configurePreset: release-msvc + configurePreset: build-release-msvc configurePresetAdditionalArgs: "['-DCMAKE_TOOLCHAIN_FILE:STRING=C:/vcpkg/scripts/buildsystems/vcpkg.cmake']" + buildPreset: release-msvc - name: Upload a Build Artifact uses: actions/upload-artifact@v3.1.2 From e8578b62da5f396ebdeaaf785495dd6799ac6e08 Mon Sep 17 00:00:00 2001 From: Daniil Zaikin Date: Fri, 13 Sep 2024 21:21:18 +1000 Subject: [PATCH 08/13] swap the two around to see what the runner thinks --- .github/workflows/build.yml | 2 -- vcpkg-configuration.json | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dae567e..f4fa612 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,9 +30,7 @@ jobs: - name: Run CMake in accordance with CMakePreset.json and run vcpkg uses: lukka/run-cmake@v10 with: - cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' configurePreset: build-release-msvc - configurePresetAdditionalArgs: "['-DCMAKE_TOOLCHAIN_FILE:STRING=C:/vcpkg/scripts/buildsystems/vcpkg.cmake']" buildPreset: release-msvc - name: Upload a Build Artifact diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index 32e63b2..b066b4f 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -8,14 +8,14 @@ { "kind": "git", "repository": "https://github.com/microsoft/vcpkg", - "baseline": "7ef729383ab801504035a4445b6dbca18c8865c8", - "packages": [ "boost-modular-build-helper" ] + "baseline": "caa7579a1c48e2ca770f6ccf98cb03db95642631", + "packages": [ "boost*", "boost-*" ] }, { "kind": "git", "repository": "https://github.com/microsoft/vcpkg", - "baseline": "caa7579a1c48e2ca770f6ccf98cb03db95642631", - "packages": [ "boost*", "boost-*" ] + "baseline": "7ef729383ab801504035a4445b6dbca18c8865c8", + "packages": [ "boost-modular-build-helper" ] } ] } \ No newline at end of file From f1b543505fee42b153c89bba2043df70124f2ffb Mon Sep 17 00:00:00 2001 From: Daniil Zaikin Date: Fri, 13 Sep 2024 21:32:14 +1000 Subject: [PATCH 09/13] updates vcpkg to allow wildcards --- vcpkg-configuration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index b066b4f..3202704 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -2,7 +2,7 @@ "default-registry": { "kind": "git", "repository": "https://github.com/Microsoft/vcpkg", - "baseline": "4cb4a5c5ddcb9de0c83c85837ee6974c8333f032" + "baseline": "f14984af3738e69f197bf0e647a8dca12de92996" }, "registries": [ { From e1ded9ad3cb6403312a2586a51f38d5965ffab0c Mon Sep 17 00:00:00 2001 From: Daniil Zaikin Date: Fri, 13 Sep 2024 21:46:36 +1000 Subject: [PATCH 10/13] bump vcpkg to latest --- vcpkg-configuration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index 3202704..2bc6e84 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -2,7 +2,7 @@ "default-registry": { "kind": "git", "repository": "https://github.com/Microsoft/vcpkg", - "baseline": "f14984af3738e69f197bf0e647a8dca12de92996" + "baseline": "3508985146f1b1d248c67ead13f8f54be5b4f5da" }, "registries": [ { From 4f4f90348d8c0daf0648378336a3098609527f2d Mon Sep 17 00:00:00 2001 From: Daniil Zaikin Date: Fri, 13 Sep 2024 22:05:25 +1000 Subject: [PATCH 11/13] brings fmt back to the past --- vcpkg-configuration.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index 2bc6e84..e06199a 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -16,6 +16,12 @@ "repository": "https://github.com/microsoft/vcpkg", "baseline": "7ef729383ab801504035a4445b6dbca18c8865c8", "packages": [ "boost-modular-build-helper" ] + }, + { + "kind": "git", + "repository": "https://github.com/microsoft/vcpkg", + "baseline": "4cb4a5c5ddcb9de0c83c85837ee6974c8333f032", + "packages": [ "fmt" ] } ] } \ No newline at end of file From 18f5f92baea322ee8d3107b3d939b36f08de561b Mon Sep 17 00:00:00 2001 From: Daniil Zaikin Date: Sun, 22 Sep 2024 17:34:18 +1000 Subject: [PATCH 12/13] implement basic functionality to occasionally parse keywords as identifiers --- CMakePresets.json | 24 ++++++++++++++++++++++++ Caprica/common/CapricaReportingContext.h | 7 +++++++ Caprica/main_options.cpp | 4 ++++ Caprica/papyrus/parser/PapyrusLexer.cpp | 19 +++++++++++++++++++ Caprica/papyrus/parser/PapyrusLexer.h | 1 + Caprica/papyrus/parser/PapyrusParser.cpp | 22 +++++++++++++++++++++- Caprica/papyrus/parser/PapyrusParser.h | 1 + 7 files changed, 77 insertions(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index 9e3b418..9f1a3b0 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -69,6 +69,24 @@ "value": "RelWithDebInfo" } } + }, + { + "name": "build-debug-msvc", + "inherits": [ + "base", + "vcpkg", + "x64", + "msvc" + ], + "displayName": "Debug", + "description": "Debug build for testing.", + "binaryDir": "${sourceDir}/build/debug", + "cacheVariables": { + "CMAKE_BUILD_TYPE": { + "type": "STRING", + "value": "Debug" + } + } } ], "buildPresets": [ @@ -77,6 +95,12 @@ "displayName": "Release (MSVC)", "configurePreset": "build-release-msvc", "description": "Optimized release Build." + }, + { + "name": "debug-msvc", + "displayName": "Debug (MSVC)", + "configurePreset": "build-debug-msvc", + "description": "Debug build for local testing." } ] } \ No newline at end of file diff --git a/Caprica/common/CapricaReportingContext.h b/Caprica/common/CapricaReportingContext.h index 22deaec..c7f9425 100644 --- a/Caprica/common/CapricaReportingContext.h +++ b/Caprica/common/CapricaReportingContext.h @@ -133,6 +133,13 @@ struct CapricaReportingContext final { identifier_ref, parentName) + // Not a base game warning, but some ubiquitous libraries fall prey to this. + DEFINE_WARNING_A1(1006, + Strict_Keyword_Identifiers, + "'{}' is a keyword (e.g. Int, Function) but is used as an identifier.", + identifier_ref, + idName) + // Warnings 2000-2199 are for engine imposed limitations. DEFINE_WARNING_A2(2001, diff --git a/Caprica/main_options.cpp b/Caprica/main_options.cpp index 06efd91..8240165 100644 --- a/Caprica/main_options.cpp +++ b/Caprica/main_options.cpp @@ -206,6 +206,8 @@ bool parseCommandLineArguments(int argc, char* argv[], caprica::CapricaJobManage "Ensure values returned from BetaOnly and DebugOnly functions don't escape, as that will cause invalid code generation.") ("disable-implicit-conversion-from-none", po::bool_switch()->default_value(false), "Disable implicit conversion from None in most situations where the use of None likely wasn't the author's intention.") + ("disable-keywords-as-identifiers", po::bool_switch()->default_value(false), + "Disable the ability to use some keywords (e.g. Switch, Parent) as identifiers in select cases.") ("skyrim-allow-unknown-events-on-non-native-class", po::value(&conf::Skyrim::skyrimAllowUnknownEventsOnNonNativeClass)->default_value(true), "Allow unknown events to be defined on non-native classes. This is encountered with some scripts in the base game having Events that are not present on ObjectReference."); @@ -560,6 +562,8 @@ bool parseCommandLineArguments(int argc, char* argv[], caprica::CapricaJobManage conf::Warnings::warningsToHandleAsErrors.insert(1002); } else if (vm["disable-implicit-conversion-from-none"].as()) { conf::Warnings::warningsToHandleAsErrors.insert(1003); + } else if (vm["disable-keywords-as-identifiers"].as()) { + conf::Warnings::warningsToHandleAsErrors.insert(1006); } if (vm.count("disable-warning")) { diff --git a/Caprica/papyrus/parser/PapyrusLexer.cpp b/Caprica/papyrus/parser/PapyrusLexer.cpp index 7f26afe..134acbe 100644 --- a/Caprica/papyrus/parser/PapyrusLexer.cpp +++ b/Caprica/papyrus/parser/PapyrusLexer.cpp @@ -236,6 +236,25 @@ static const caseless_unordered_identifier_ref_map languageExtensions { "to", TokenType::kTo }, }; +// keywords which can never pass as identifiers +static const std::unordered_set nonIdentifiersSet { + TokenType::kAuto, + TokenType::kAutoReadOnly, + TokenType::kBool, + TokenType::kConst, + TokenType::kFalse, + TokenType::kFloat, + TokenType::kInt, + TokenType::kNone, + TokenType::kString, + TokenType::kStruct, + TokenType::kVar, +}; + +const bool keywordCanBeIdentifier(TokenType tp) { + return keywordIsInGame(tp, conf::Papyrus::game, true) && nonIdentifiersSet.find(tp) == nonIdentifiersSet.end(); +} + ALWAYS_INLINE static bool isAsciiAlphaNumeric(int c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); diff --git a/Caprica/papyrus/parser/PapyrusLexer.h b/Caprica/papyrus/parser/PapyrusLexer.h index 222abe2..db4e623 100644 --- a/Caprica/papyrus/parser/PapyrusLexer.h +++ b/Caprica/papyrus/parser/PapyrusLexer.h @@ -141,6 +141,7 @@ constexpr TokenType STARFIELD_MAX_KEYWORD = TokenType::kTryGuard; constexpr bool keywordIsLanguageExtension(TokenType tp) { return tp >= TokenType::kBreak && tp <= TokenType::kTo; } +const bool keywordCanBeIdentifier(TokenType tp); constexpr bool keywordIsInGame(TokenType tp, GameID game, bool includeExtensions = false) { if (includeExtensions && keywordIsLanguageExtension(tp)) return true; diff --git a/Caprica/papyrus/parser/PapyrusParser.cpp b/Caprica/papyrus/parser/PapyrusParser.cpp index 48874a0..3962908 100644 --- a/Caprica/papyrus/parser/PapyrusParser.cpp +++ b/Caprica/papyrus/parser/PapyrusParser.cpp @@ -540,7 +540,7 @@ PapyrusFunction* PapyrusParser::parseFunction( auto param = alloc->make(cur.location, func->parameters.size(), expectConsumePapyrusType()); - param->name = expectConsumeIdentRef(); + param->name = expectConsumeKeywordOrIdentRef(); if (maybeConsume(TokenType::Equal)) param->defaultValue = expectConsumePapyrusValue(); func->parameters.push_back(param); @@ -1176,6 +1176,26 @@ expressions::PapyrusExpression* PapyrusParser::parseFuncOrIdExpression(PapyrusFu } } +identifier_ref PapyrusParser::expectConsumeKeywordOrIdentRef() { + if (!keywordCanBeIdentifier(cur.type)) { + reportingContext.fatal(cur.location, + "Syntax error! Expected valid identifier, got '{}'.", + cur.prettyString()); + } + + identifier_ref finalId; + + if (cur.type != TokenType::Identifier) { + const identifier_ref typeIdentifier = identifier_ref(PapyrusLexer::Token::prettyTokenType(cur.type)); + reportingContext.warning_W1006_Strict_Keyword_Identifiers(cur.location, typeIdentifier); + finalId = typeIdentifier; + } else { + finalId = cur.val.s; + } + consume(); + return finalId; +} + PapyrusType PapyrusParser::expectConsumePapyrusType() { PapyrusType tp = PapyrusType::Default(); switch (cur.type) { diff --git a/Caprica/papyrus/parser/PapyrusParser.h b/Caprica/papyrus/parser/PapyrusParser.h index deb021a..24ccc2f 100644 --- a/Caprica/papyrus/parser/PapyrusParser.h +++ b/Caprica/papyrus/parser/PapyrusParser.h @@ -48,6 +48,7 @@ struct PapyrusParser final : private PapyrusLexer { PapyrusType expectConsumePapyrusType(); PapyrusValue expectConsumePapyrusValue(); + identifier_ref expectConsumeKeywordOrIdentRef(); PapyrusUserFlags maybeConsumeUserFlags(CapricaUserFlagsDefinition::ValidLocations location); ALWAYS_INLINE From 27adcde1c5567bf94a8eefef28147ff130e2886a Mon Sep 17 00:00:00 2001 From: Dan Zaikin <89231080+XxX-Daniil-underscore-Zaikin-XxX@users.noreply.github.com> Date: Wed, 4 Jun 2025 21:09:13 +1000 Subject: [PATCH 13/13] update deprecated GH actions --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f4fa612..67564a6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: buildPreset: release-msvc - name: Upload a Build Artifact - uses: actions/upload-artifact@v3.1.2 + uses: actions/upload-artifact@v4 with: # Artifact name name: ${{ env.PROJECT_NAME }} @@ -52,7 +52,7 @@ jobs: needs: build steps: - name: Download artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ${{ env.PROJECT_NAME }} path: artifacts/${{ env.PROJECT_NAME }}