From ff4a07d375aca8920aa11964be7f8a899ef5ee3a Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Thu, 26 Sep 2024 19:20:26 -0400 Subject: [PATCH 01/18] Fix parsing issues with trcover when started not in Generated-* directory. --- src/trcover/Model.cs | 27 ++++++++++++++-------- src/trcover/Properties/launchSettings.json | 4 ++-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/trcover/Model.cs b/src/trcover/Model.cs index 04b6c24aa..d735dac59 100644 --- a/src/trcover/Model.cs +++ b/src/trcover/Model.cs @@ -1122,17 +1122,26 @@ public override Digraph> VisitTokensSpec(ANTLRv4Parse public void ComputeModel(string dll_path, Antlr4.Runtime.Parser pp, Antlr4.Runtime.Lexer ll, ITokenStream tt) { - // Go up directory, find all *.g4, parse. + // Repeatedly, search directory for .g4's. + // If there are aren't any, go up one directory and try again. + // Once .g4's found, parse them and return. if (!dll_path.EndsWith("/")) dll_path += "/"; - var path = dll_path + "../../.."; + var path = dll_path; path = Path.GetFullPath(path); - Directory.SetCurrentDirectory(path); - path = Directory.GetCurrentDirectory(); - var grammar_files = new TrashGlobbing.Glob(path) - .RegexContents(".*[.]g4") - .Where(f => f is FileInfo && !f.Attributes.HasFlag(FileAttributes.Directory)) - .Select(f => f.FullName.Replace('\\', '/')) - .ToList(); + List grammar_files; + for (;;) + { + var old_path = Directory.GetCurrentDirectory(); + Directory.SetCurrentDirectory(path); + grammar_files = new TrashGlobbing.Glob(path) + .RegexContents(".*[.]g4") + .Where(f => f is FileInfo && !f.Attributes.HasFlag(FileAttributes.Directory)) + .Select(f => f.FullName.Replace('\\', '/')) + .ToList(); + Directory.SetCurrentDirectory(old_path); + if (grammar_files.Any()) break; + path = path + "../"; + } foreach (var gfile in grammar_files) { ParseGrammar(gfile, pp, ll, tt); diff --git a/src/trcover/Properties/launchSettings.json b/src/trcover/Properties/launchSettings.json index c0b53906b..0df34c592 100644 --- a/src/trcover/Properties/launchSettings.json +++ b/src/trcover/Properties/launchSettings.json @@ -2,8 +2,8 @@ "profiles": { "trcover": { "commandName": "Project", - "commandLineArgs": "../examples/fun.compute_20.ptx", - "workingDirectory": "c:\\msys64\\home\\Kenne\\issues\\g4-3702\\asm\\ptx\\ptx-isa-2.1\\Generated-CSharp-large" + "commandLineArgs": "examples/iri.abnf examples/postal.abnf examples/rfc5322.abnf", + "workingDirectory": "C:\\msys64\\home\\Kenne\\issues\\g4-abnf-readme\\abnf" } } } \ No newline at end of file From d75cbb7ead497a125bbb63c58f747a4559ea4bcf Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Fri, 27 Sep 2024 06:49:19 -0400 Subject: [PATCH 02/18] Bump. --- .config/dotnet-tools.json | 60 ++++++++++++------------ _scripts/set-version.sh | 6 +-- src/tragl/readme.md | 2 +- src/tragl/tragl.csproj | 2 +- src/tranalyze/readme.md | 2 +- src/tranalyze/tranalyze.csproj | 2 +- src/trcaret/readme.md | 2 +- src/trcaret/trcaret.csproj | 2 +- src/trclonereplace/readme.md | 2 +- src/trclonereplace/trclonereplace.csproj | 2 +- src/trcombine/readme.md | 2 +- src/trcombine/trcombine.csproj | 2 +- src/trconvert/readme.md | 2 +- src/trconvert/trconvert.csproj | 2 +- src/trcover/readme.md | 2 +- src/trcover/trcover.csproj | 2 +- src/trdot/readme.md | 2 +- src/trdot/trdot.csproj | 2 +- src/trenum/readme.md | 2 +- src/trenum/trenum.csproj | 2 +- src/trfirst/readme.md | 2 +- src/trfirst/trfirst.csproj | 2 +- src/trfold/readme.md | 2 +- src/trfold/trfold.csproj | 2 +- src/trfoldlit/readme.md | 2 +- src/trfoldlit/trfoldlit.csproj | 2 +- src/trformat/readme.md | 2 +- src/trformat/trformat.csproj | 2 +- src/trgen/Command.cs | 2 +- src/trgen/readme.md | 2 +- src/trgen/trgen.csproj | 2 +- src/trgenvsc/readme.md | 2 +- src/trgenvsc/trgenvsc.csproj | 2 +- src/trglob/readme.md | 2 +- src/trglob/trglob.csproj | 2 +- src/trgroup/readme.md | 2 +- src/trgroup/trgroup.csproj | 2 +- src/triconv/readme.md | 2 +- src/triconv/triconv.csproj | 2 +- src/tritext/readme.md | 2 +- src/tritext/tritext.csproj | 2 +- src/trjson/readme.md | 2 +- src/trjson/trjson.csproj | 2 +- src/trkleene/readme.md | 2 +- src/trkleene/trkleene.csproj | 2 +- src/trparse/readme.md | 2 +- src/trparse/trparse.csproj | 2 +- src/trperf/readme.md | 2 +- src/trperf/trperf.csproj | 2 +- src/trpiggy/readme.md | 2 +- src/trpiggy/trpiggy.csproj | 2 +- src/trquery/readme.md | 2 +- src/trquery/trquery.csproj | 2 +- src/trrename/readme.md | 2 +- src/trrename/trrename.csproj | 2 +- src/trrr/readme.md | 2 +- src/trrr/trrr.csproj | 2 +- src/trrup/readme.md | 2 +- src/trrup/trrup.csproj | 2 +- src/trsem/readme.md | 2 +- src/trsem/trsem.csproj | 2 +- src/trsort/readme.md | 2 +- src/trsort/trsort.csproj | 2 +- src/trsplit/readme.md | 2 +- src/trsplit/trsplit.csproj | 2 +- src/trsponge/readme.md | 2 +- src/trsponge/trsponge.csproj | 2 +- src/trst/readme.md | 2 +- src/trst/trst.csproj | 2 +- src/trtext/readme.md | 2 +- src/trtext/trtext.csproj | 2 +- src/trthompson/readme.md | 2 +- src/trthompson/trthompson.csproj | 2 +- src/trtokens/readme.md | 2 +- src/trtokens/trtokens.csproj | 2 +- src/trtree/readme.md | 2 +- src/trtree/trtree.csproj | 2 +- src/trull/readme.md | 2 +- src/trull/trull.csproj | 2 +- src/trunfold/readme.md | 2 +- src/trunfold/trunfold.csproj | 2 +- src/trungroup/readme.md | 2 +- src/trungroup/trungroup.csproj | 2 +- src/trwdog/readme.md | 2 +- src/trwdog/trwdog.csproj | 2 +- src/trxgrep/readme.md | 2 +- src/trxgrep/trxgrep.csproj | 2 +- src/trxml/readme.md | 2 +- src/trxml/trxml.csproj | 2 +- src/trxml2/asdfasdf2 | 48 ------------------- src/trxml2/readme.md | 2 +- src/trxml2/trxml2.csproj | 2 +- 92 files changed, 122 insertions(+), 170 deletions(-) delete mode 100644 src/trxml2/asdfasdf2 diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index fe5da43d5..4e745101a 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,210 +3,210 @@ "isRoot": true, "tools": { "tranalyze": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "tranalyze" ], "rollForward": false }, "trcaret": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trcaret" ], "rollForward": false }, "trclonereplace": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trclonereplace" ], "rollForward": false }, "trcombine": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trcombine" ], "rollForward": false }, "trconvert": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trconvert" ], "rollForward": false }, "trcover": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trcover" ], "rollForward": false }, "trdot": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trdot" ], "rollForward": false }, "trfoldlit": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trfoldlit" ], "rollForward": false }, "trgen": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trgen" ], "rollForward": false }, "trgenvsc": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trgenvsc" ], "rollForward": false }, "trglob": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trglob" ], "rollForward": false }, "triconv": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "triconv" ], "rollForward": false }, "tritext": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "tritext" ], "rollForward": false }, "trjson": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trjson" ], "rollForward": false }, "trparse": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trparse" ], "rollForward": false }, "trperf": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trperf" ], "rollForward": false }, "trquery": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trquery" ], "rollForward": false }, "trrename": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trrename" ], "rollForward": false }, "trsort": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trsort" ], "rollForward": false }, "trsplit": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trsplit" ], "rollForward": false }, "trsponge": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trsponge" ], "rollForward": false }, "trtext": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trtext" ], "rollForward": false }, "trtokens": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trtokens" ], "rollForward": false }, "trtree": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trtree" ], "rollForward": false }, "trunfold": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trunfold" ], "rollForward": false }, "trungroup": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trungroup" ], "rollForward": false }, "trwdog": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trwdog" ], "rollForward": false }, "trxgrep": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trxgrep" ], "rollForward": false }, "trxml": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trxml" ], "rollForward": false }, "trxml2": { - "version": "0.23.6", + "version": "0.23.7", "commands": [ "trxml2" ], diff --git a/_scripts/set-version.sh b/_scripts/set-version.sh index 50e7c82be..60727c2a9 100644 --- a/_scripts/set-version.sh +++ b/_scripts/set-version.sh @@ -1,5 +1,5 @@ #!/usr/bin/bash -version="0.23.6" +version="0.23.7" cd src directories=`find . -maxdepth 1 -type d -name "tr*"` cwd=`pwd` @@ -41,7 +41,7 @@ do mv asdfasdf *.csproj rm -f asdfasdf2 touch readme.md - cat readme.md | sed -e 's%^0[.][0-9]*[.][0-9]*.*$'"%$version"' Fix trgen for combined grammars. Add regression testing of trgen and all targets%' > asdfasdf2 + cat readme.md | sed -e 's%^0[.][0-9]*[.][0-9]*.*$'"%$version"' Fixed trcover when started outside of Generated directory.%' > asdfasdf2 mv asdfasdf2 readme.md cd .. done @@ -78,7 +78,7 @@ do mv asdfasdf *.csproj rm -f asdfasdf2 touch readme.md - cat readme.md | sed -e 's%^0[.][0-9]*[.][0-9]*.*$'"%$version"' Fix trgen for combined grammars. Add regression testing of trgen and all targets%' > asdfasdf2 + cat readme.md | sed -e 's%^0[.][0-9]*[.][0-9]*.*$'"%$version"' Fixed trcover when started outside of Generated directory.%' > asdfasdf2 mv asdfasdf2 readme.md cd .. done diff --git a/src/tragl/readme.md b/src/tragl/readme.md index 4eee388c4..22be79fbe 100644 --- a/src/tragl/readme.md +++ b/src/tragl/readme.md @@ -19,7 +19,7 @@ This tool is part of Trash, Transformations for Antlr Shell. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/tragl/tragl.csproj b/src/tragl/tragl.csproj index e27c17183..bd0110459 100644 --- a/src/tragl/tragl.csproj +++ b/src/tragl/tragl.csproj @@ -19,7 +19,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/tragl git diff --git a/src/tranalyze/readme.md b/src/tranalyze/readme.md index 8a19fe202..63ace29a0 100644 --- a/src/tranalyze/readme.md +++ b/src/tranalyze/readme.md @@ -65,7 +65,7 @@ _Output_ ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/tranalyze/tranalyze.csproj b/src/tranalyze/tranalyze.csproj index 50b3ef71d..5a006b836 100644 --- a/src/tranalyze/tranalyze.csproj +++ b/src/tranalyze/tranalyze.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/tranalyze git diff --git a/src/trcaret/readme.md b/src/trcaret/readme.md index e02f6b748..f5f290251 100644 --- a/src/trcaret/readme.md +++ b/src/trcaret/readme.md @@ -18,7 +18,7 @@ Reads a tree from stdin and prints lines and caret marks. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trcaret/trcaret.csproj b/src/trcaret/trcaret.csproj index b44776ef5..49d884532 100644 --- a/src/trcaret/trcaret.csproj +++ b/src/trcaret/trcaret.csproj @@ -19,7 +19,7 @@ This program is part of the Trash toolkit. true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trcaret git diff --git a/src/trclonereplace/readme.md b/src/trclonereplace/readme.md index 8fbb4590c..340c1da3c 100644 --- a/src/trclonereplace/readme.md +++ b/src/trclonereplace/readme.md @@ -19,7 +19,7 @@ Clone, rename, and replace symbols in a grammar to optimize full stack fallbacks ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trclonereplace/trclonereplace.csproj b/src/trclonereplace/trclonereplace.csproj index 87644b7f2..f43489a13 100644 --- a/src/trclonereplace/trclonereplace.csproj +++ b/src/trclonereplace/trclonereplace.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trclonereplace git diff --git a/src/trcombine/readme.md b/src/trcombine/readme.md index af5b70055..82e4aa438 100644 --- a/src/trcombine/readme.md +++ b/src/trcombine/readme.md @@ -103,7 +103,7 @@ The original grammars are left unchanged. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trcombine/trcombine.csproj b/src/trcombine/trcombine.csproj index 57b6e4ab5..de7556ffd 100644 --- a/src/trcombine/trcombine.csproj +++ b/src/trcombine/trcombine.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trcombine git diff --git a/src/trconvert/readme.md b/src/trconvert/readme.md index 26e4a65f5..0941f2be0 100644 --- a/src/trconvert/readme.md +++ b/src/trconvert/readme.md @@ -93,7 +93,7 @@ _Output_ ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trconvert/trconvert.csproj b/src/trconvert/trconvert.csproj index a00ec6722..3fadd207b 100644 --- a/src/trconvert/trconvert.csproj +++ b/src/trconvert/trconvert.csproj @@ -18,7 +18,7 @@ syntax. This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trconvert git diff --git a/src/trcover/readme.md b/src/trcover/readme.md index d13deceba..449df8ab0 100644 --- a/src/trcover/readme.md +++ b/src/trcover/readme.md @@ -24,7 +24,7 @@ a grammar. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trcover/trcover.csproj b/src/trcover/trcover.csproj index ec8feac2a..13127b3de 100644 --- a/src/trcover/trcover.csproj +++ b/src/trcover/trcover.csproj @@ -18,7 +18,7 @@ for the entire grammar. This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trcover git diff --git a/src/trdot/readme.md b/src/trdot/readme.md index 9d25eca09..4ed334505 100644 --- a/src/trdot/readme.md +++ b/src/trdot/readme.md @@ -63,7 +63,7 @@ The output will be: ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trdot/trdot.csproj b/src/trdot/trdot.csproj index cdb3dd8e8..f09848e82 100644 --- a/src/trdot/trdot.csproj +++ b/src/trdot/trdot.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit. true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trdot git diff --git a/src/trenum/readme.md b/src/trenum/readme.md index 32666cf18..004714166 100644 --- a/src/trenum/readme.md +++ b/src/trenum/readme.md @@ -8,7 +8,7 @@ ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trenum/trenum.csproj b/src/trenum/trenum.csproj index efd71f0ef..06463e647 100644 --- a/src/trenum/trenum.csproj +++ b/src/trenum/trenum.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit. true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trull git diff --git a/src/trfirst/readme.md b/src/trfirst/readme.md index 63d832bd7..0e825ba4d 100644 --- a/src/trfirst/readme.md +++ b/src/trfirst/readme.md @@ -24,7 +24,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trfirst/trfirst.csproj b/src/trfirst/trfirst.csproj index f062adf82..6e9408109 100644 --- a/src/trfirst/trfirst.csproj +++ b/src/trfirst/trfirst.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trfirst git diff --git a/src/trfold/readme.md b/src/trfold/readme.md index 9c07ce78f..3173c3d85 100644 --- a/src/trfold/readme.md +++ b/src/trfold/readme.md @@ -26,7 +26,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trfold/trfold.csproj b/src/trfold/trfold.csproj index f88c1f53d..308f0d3dd 100644 --- a/src/trfold/trfold.csproj +++ b/src/trfold/trfold.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trfold git diff --git a/src/trfoldlit/readme.md b/src/trfoldlit/readme.md index eea08ad89..7283c6b17 100644 --- a/src/trfoldlit/readme.md +++ b/src/trfoldlit/readme.md @@ -65,7 +65,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trfoldlit/trfoldlit.csproj b/src/trfoldlit/trfoldlit.csproj index 86047fb2f..f501d8aa2 100644 --- a/src/trfoldlit/trfoldlit.csproj +++ b/src/trfoldlit/trfoldlit.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trfoldlit git diff --git a/src/trformat/readme.md b/src/trformat/readme.md index 83a8fc766..af7808407 100644 --- a/src/trformat/readme.md +++ b/src/trformat/readme.md @@ -18,7 +18,7 @@ Format of grammar using machine learning. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trformat/trformat.csproj b/src/trformat/trformat.csproj index d35183d1d..8a263ce4e 100644 --- a/src/trformat/trformat.csproj +++ b/src/trformat/trformat.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trformat git diff --git a/src/trgen/Command.cs b/src/trgen/Command.cs index 161f94575..913d9345c 100644 --- a/src/trgen/Command.cs +++ b/src/trgen/Command.cs @@ -507,7 +507,7 @@ private void ModifyWithGrammarParse(Config config) } } - public static string version = "0.23.6"; + public static string version = "0.23.7"; // For maven-generated code. public List failed_modules = new List(); diff --git a/src/trgen/readme.md b/src/trgen/readme.md index 5e006e27f..5e0bd5349 100644 --- a/src/trgen/readme.md +++ b/src/trgen/readme.md @@ -49,7 +49,7 @@ simplify and eliminate bugs created when adding new grammars. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trgen/trgen.csproj b/src/trgen/trgen.csproj index 7160ea71d..95aa8f2ec 100644 --- a/src/trgen/trgen.csproj +++ b/src/trgen/trgen.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trgen git diff --git a/src/trgenvsc/readme.md b/src/trgenvsc/readme.md index 82db01f5a..4a2efbfab 100644 --- a/src/trgenvsc/readme.md +++ b/src/trgenvsc/readme.md @@ -30,7 +30,7 @@ the XPath patterns to match certain parse trees. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trgenvsc/trgenvsc.csproj b/src/trgenvsc/trgenvsc.csproj index 723d86bdd..42df12916 100644 --- a/src/trgenvsc/trgenvsc.csproj +++ b/src/trgenvsc/trgenvsc.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trgenvsc git diff --git a/src/trglob/readme.md b/src/trglob/readme.md index 995bcff89..9c46b078f 100644 --- a/src/trglob/readme.md +++ b/src/trglob/readme.md @@ -17,7 +17,7 @@ Expand a glob string into file names. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trglob/trglob.csproj b/src/trglob/trglob.csproj index 9da14199b..5a7987360 100644 --- a/src/trglob/trglob.csproj +++ b/src/trglob/trglob.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trglob git diff --git a/src/trgroup/readme.md b/src/trgroup/readme.md index 085ec9023..35da84921 100644 --- a/src/trgroup/readme.md +++ b/src/trgroup/readme.md @@ -56,7 +56,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trgroup/trgroup.csproj b/src/trgroup/trgroup.csproj index f25ae1c64..86a65d636 100644 --- a/src/trgroup/trgroup.csproj +++ b/src/trgroup/trgroup.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trgroup git diff --git a/src/triconv/readme.md b/src/triconv/readme.md index e30153313..4d005e7f6 100644 --- a/src/triconv/readme.md +++ b/src/triconv/readme.md @@ -20,7 +20,7 @@ unicode. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/triconv/triconv.csproj b/src/triconv/triconv.csproj index c257ff8ae..8aa0edf76 100644 --- a/src/triconv/triconv.csproj +++ b/src/triconv/triconv.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trxml2 git diff --git a/src/tritext/readme.md b/src/tritext/readme.md index 36b3003e2..0095f54b8 100644 --- a/src/tritext/readme.md +++ b/src/tritext/readme.md @@ -18,7 +18,7 @@ Get strings from a PDF file using IText. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/tritext/tritext.csproj b/src/tritext/tritext.csproj index 3e99cd6a3..57ba5e266 100644 --- a/src/tritext/tritext.csproj +++ b/src/tritext/tritext.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit. true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/tritext git diff --git a/src/trjson/readme.md b/src/trjson/readme.md index 1e2110e32..4f0d2b4ac 100644 --- a/src/trjson/readme.md +++ b/src/trjson/readme.md @@ -18,7 +18,7 @@ Read a parse tree from stdin and write a JSON represenation of it. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trjson/trjson.csproj b/src/trjson/trjson.csproj index ccf0a13d1..7e2f91ac6 100644 --- a/src/trjson/trjson.csproj +++ b/src/trjson/trjson.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit. true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trjson git diff --git a/src/trkleene/readme.md b/src/trkleene/readme.md index 8bc854602..7dc09b980 100644 --- a/src/trkleene/readme.md +++ b/src/trkleene/readme.md @@ -38,7 +38,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trkleene/trkleene.csproj b/src/trkleene/trkleene.csproj index 23385358e..2c77e6771 100644 --- a/src/trkleene/trkleene.csproj +++ b/src/trkleene/trkleene.csproj @@ -19,7 +19,7 @@ This program is part of the Trash toolkit. true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trkleene git diff --git a/src/trparse/readme.md b/src/trparse/readme.md index 3755e4b60..f8ec5cc8d 100644 --- a/src/trparse/readme.md +++ b/src/trparse/readme.md @@ -50,7 +50,7 @@ the `--type` command-line option: ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trparse/trparse.csproj b/src/trparse/trparse.csproj index 778074c79..c923419b4 100644 --- a/src/trparse/trparse.csproj +++ b/src/trparse/trparse.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trparse git diff --git a/src/trperf/readme.md b/src/trperf/readme.md index 6cbbd5bb6..1750a9520 100644 --- a/src/trperf/readme.md +++ b/src/trperf/readme.md @@ -41,7 +41,7 @@ be in a trgen-generated parser directory, or use the -p option. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trperf/trperf.csproj b/src/trperf/trperf.csproj index 77409a525..d6c11c755 100644 --- a/src/trperf/trperf.csproj +++ b/src/trperf/trperf.csproj @@ -19,7 +19,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trperf git diff --git a/src/trpiggy/readme.md b/src/trpiggy/readme.md index 15172a240..2c1279047 100644 --- a/src/trpiggy/readme.md +++ b/src/trpiggy/readme.md @@ -63,7 +63,7 @@ Output: ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trpiggy/trpiggy.csproj b/src/trpiggy/trpiggy.csproj index 7eb654caa..070cd3a62 100644 --- a/src/trpiggy/trpiggy.csproj +++ b/src/trpiggy/trpiggy.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trpiggy git diff --git a/src/trquery/readme.md b/src/trquery/readme.md index acedb35c5..e7cde0c21 100644 --- a/src/trquery/readme.md +++ b/src/trquery/readme.md @@ -47,7 +47,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trquery/trquery.csproj b/src/trquery/trquery.csproj index 11e5d6b43..7e78ccd24 100644 --- a/src/trquery/trquery.csproj +++ b/src/trquery/trquery.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trquery git diff --git a/src/trrename/readme.md b/src/trrename/readme.md index f265108c4..f1146298f 100644 --- a/src/trrename/readme.md +++ b/src/trrename/readme.md @@ -27,7 +27,7 @@ make sure to enclose the argument as it contains semi-colons. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trrename/trrename.csproj b/src/trrename/trrename.csproj index 15178d988..30cf3a5ad 100644 --- a/src/trrename/trrename.csproj +++ b/src/trrename/trrename.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trrename git diff --git a/src/trrr/readme.md b/src/trrr/readme.md index 85ef79f46..c129f42e1 100644 --- a/src/trrr/readme.md +++ b/src/trrr/readme.md @@ -14,7 +14,7 @@ ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trrr/trrr.csproj b/src/trrr/trrr.csproj index 4a92c586f..63aef8fd5 100644 --- a/src/trrr/trrr.csproj +++ b/src/trrr/trrr.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trrr git diff --git a/src/trrup/readme.md b/src/trrup/readme.md index 663f4d10c..3ec93bf53 100644 --- a/src/trrup/readme.md +++ b/src/trrup/readme.md @@ -42,7 +42,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trrup/trrup.csproj b/src/trrup/trrup.csproj index 060ce0f40..f7c743aa7 100644 --- a/src/trrup/trrup.csproj +++ b/src/trrup/trrup.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trrup git diff --git a/src/trsem/readme.md b/src/trsem/readme.md index 74173e02c..258c82d48 100644 --- a/src/trsem/readme.md +++ b/src/trsem/readme.md @@ -18,7 +18,7 @@ Read a static semantics spec file and generate code. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trsem/trsem.csproj b/src/trsem/trsem.csproj index 723449a96..906fc1c45 100644 --- a/src/trsem/trsem.csproj +++ b/src/trsem/trsem.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trsem git diff --git a/src/trsort/readme.md b/src/trsort/readme.md index 5cf546906..9e6356116 100644 --- a/src/trsort/readme.md +++ b/src/trsort/readme.md @@ -37,7 +37,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trsort/trsort.csproj b/src/trsort/trsort.csproj index 7312b2b72..0d565a946 100644 --- a/src/trsort/trsort.csproj +++ b/src/trsort/trsort.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trsort git diff --git a/src/trsplit/readme.md b/src/trsplit/readme.md index 067d849d1..853d4e15f 100644 --- a/src/trsplit/readme.md +++ b/src/trsplit/readme.md @@ -45,7 +45,7 @@ modified. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trsplit/trsplit.csproj b/src/trsplit/trsplit.csproj index e28feb977..feb93805c 100644 --- a/src/trsplit/trsplit.csproj +++ b/src/trsplit/trsplit.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trsplit git diff --git a/src/trsponge/readme.md b/src/trsponge/readme.md index 17de57bae..63490c166 100644 --- a/src/trsponge/readme.md +++ b/src/trsponge/readme.md @@ -19,7 +19,7 @@ results to file(s). ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trsponge/trsponge.csproj b/src/trsponge/trsponge.csproj index 3350dd8ba..cd2677dbb 100644 --- a/src/trsponge/trsponge.csproj +++ b/src/trsponge/trsponge.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trsponge git diff --git a/src/trst/readme.md b/src/trst/readme.md index 2d54efabc..4e9d384b5 100644 --- a/src/trst/readme.md +++ b/src/trst/readme.md @@ -18,7 +18,7 @@ Output tree using the Antlr runtime ToStringTree(). ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trst/trst.csproj b/src/trst/trst.csproj index 74e1094b2..08ad1ccb3 100644 --- a/src/trst/trst.csproj +++ b/src/trst/trst.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit. true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trst git diff --git a/src/trtext/readme.md b/src/trtext/readme.md index fa492b565..fb56e77bf 100644 --- a/src/trtext/readme.md +++ b/src/trtext/readme.md @@ -19,7 +19,7 @@ specified, the line number range for the tree is printed. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trtext/trtext.csproj b/src/trtext/trtext.csproj index 23eeed941..5e90597b0 100644 --- a/src/trtext/trtext.csproj +++ b/src/trtext/trtext.csproj @@ -19,7 +19,7 @@ This program is part of the Trash toolkit. true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trtext git diff --git a/src/trthompson/readme.md b/src/trthompson/readme.md index 1c0768edf..31e731061 100644 --- a/src/trthompson/readme.md +++ b/src/trthompson/readme.md @@ -12,7 +12,7 @@ ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trthompson/trthompson.csproj b/src/trthompson/trthompson.csproj index 40f6202c9..0e83b35b2 100644 --- a/src/trthompson/trthompson.csproj +++ b/src/trthompson/trthompson.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit. true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trthompson git diff --git a/src/trtokens/readme.md b/src/trtokens/readme.md index 46b8cd478..65eb62218 100644 --- a/src/trtokens/readme.md +++ b/src/trtokens/readme.md @@ -52,7 +52,7 @@ Output: ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trtokens/trtokens.csproj b/src/trtokens/trtokens.csproj index 8bfe7c8ce..ea1d6fb1a 100644 --- a/src/trtokens/trtokens.csproj +++ b/src/trtokens/trtokens.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trtokens git diff --git a/src/trtree/readme.md b/src/trtree/readme.md index 8e1615dec..aa26789cc 100644 --- a/src/trtree/readme.md +++ b/src/trtree/readme.md @@ -18,7 +18,7 @@ Reads a tree from stdin and prints the tree as an indented node list. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trtree/trtree.csproj b/src/trtree/trtree.csproj index 40a373ba3..f5bd27c43 100644 --- a/src/trtree/trtree.csproj +++ b/src/trtree/trtree.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit. true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trtree git diff --git a/src/trull/readme.md b/src/trull/readme.md index 7fa24ccb5..87885de10 100644 --- a/src/trull/readme.md +++ b/src/trull/readme.md @@ -63,7 +63,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trull/trull.csproj b/src/trull/trull.csproj index 6b4d75cdf..9f0df4218 100644 --- a/src/trull/trull.csproj +++ b/src/trull/trull.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit. true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trull git diff --git a/src/trunfold/readme.md b/src/trunfold/readme.md index 8d0d36f02..b4047e670 100644 --- a/src/trunfold/readme.md +++ b/src/trunfold/readme.md @@ -51,7 +51,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trunfold/trunfold.csproj b/src/trunfold/trunfold.csproj index 337d83c84..b60ccbac7 100644 --- a/src/trunfold/trunfold.csproj +++ b/src/trunfold/trunfold.csproj @@ -18,7 +18,7 @@ in the parse tree. This program is part of the Trash toolkit. true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trunfold git diff --git a/src/trungroup/readme.md b/src/trungroup/readme.md index 8caed2d21..763c6dc3c 100644 --- a/src/trungroup/readme.md +++ b/src/trungroup/readme.md @@ -24,7 +24,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trungroup/trungroup.csproj b/src/trungroup/trungroup.csproj index 7d70636aa..7f80edd94 100644 --- a/src/trungroup/trungroup.csproj +++ b/src/trungroup/trungroup.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trungroup git diff --git a/src/trwdog/readme.md b/src/trwdog/readme.md index e234faee8..a651bb0cc 100644 --- a/src/trwdog/readme.md +++ b/src/trwdog/readme.md @@ -18,7 +18,7 @@ Execute a command with a watchdog timer. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trwdog/trwdog.csproj b/src/trwdog/trwdog.csproj index fb3d42d76..f80676167 100644 --- a/src/trwdog/trwdog.csproj +++ b/src/trwdog/trwdog.csproj @@ -19,7 +19,7 @@ This program is part of the Trash toolkit. true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trwdog git diff --git a/src/trxgrep/readme.md b/src/trxgrep/readme.md index ca5d6112f..848197dc9 100644 --- a/src/trxgrep/readme.md +++ b/src/trxgrep/readme.md @@ -24,7 +24,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trxgrep/trxgrep.csproj b/src/trxgrep/trxgrep.csproj index 900853189..409584e59 100644 --- a/src/trxgrep/trxgrep.csproj +++ b/src/trxgrep/trxgrep.csproj @@ -18,7 +18,7 @@ This program is part of the Trash toolkit. true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trxgrep git diff --git a/src/trxml/readme.md b/src/trxml/readme.md index b8a14c9a6..61545ea50 100644 --- a/src/trxml/readme.md +++ b/src/trxml/readme.md @@ -18,7 +18,7 @@ Read a tree from stdin and write an XML represenation of it. ## Current version -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trxml/trxml.csproj b/src/trxml/trxml.csproj index 321e182ad..df637e907 100644 --- a/src/trxml/trxml.csproj +++ b/src/trxml/trxml.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trxml git diff --git a/src/trxml2/asdfasdf2 b/src/trxml2/asdfasdf2 deleted file mode 100644 index 93f69dbfd..000000000 --- a/src/trxml2/asdfasdf2 +++ /dev/null @@ -1,48 +0,0 @@ -# trxml2 - -## Summary - -Print an enumeration of all paths in a parse tree to leaves - -## Description - -Read an xml file and enumerate all paths to elements in xpath syntax. - -## Usage - - trxml2 - -## Examples - - cat desc.xml | trxml2 - -## Current version - -0.23.6 Fix trgen for combined grammars. Add regression testing of trgen and all targets - -## License - -The MIT License - -Copyright (c) 2024 Ken Domino - -Permission is hereby granted, free of charge, -to any person obtaining a copy of this software and -associated documentation files (the "Software"), to -deal in the Software without restriction, including -without limitation the rights to use, copy, modify, -merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom -the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/trxml2/readme.md b/src/trxml2/readme.md index 1ddaae664..b29b30ad0 100644 --- a/src/trxml2/readme.md +++ b/src/trxml2/readme.md @@ -18,7 +18,7 @@ Read an xml file and enumerate all paths to elements in xpath syntax. ## Current version -0.23.6 Add --ambig option to trparse. Add file names to trtree. Add new output styles for trtree. Update packages for trgenvsc templates. +0.23.7 Fixed trcover when started outside of Generated directory. ## License diff --git a/src/trxml2/trxml2.csproj b/src/trxml2/trxml2.csproj index 92ce3b950..3e5186f71 100644 --- a/src/trxml2/trxml2.csproj +++ b/src/trxml2/trxml2.csproj @@ -17,7 +17,7 @@ This program is part of the Trash toolkit.]]> true portable true - 0.23.6 + 0.23.7 https://github.com/kaby76/Trash/tree/main/src/trxml2 git From c41d9e1da49aef3255b353f2c4572d5785bc409a Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Sun, 6 Oct 2024 11:09:15 -0400 Subject: [PATCH 03/18] Adding in "b" trgen test, and refined code to get parser/lexer grammar tuples. --- _tests/grammars-v4/b/BLexer.g4 | 355 ++++++++++++++++++++ _tests/grammars-v4/b/BParser.g4 | 391 +++++++++++++++++++++++ _tests/grammars-v4/b/RulesGrammar.g4 | 52 +++ _tests/grammars-v4/b/RulesLexer.g4 | 53 +++ _tests/grammars-v4/b/desc.xml | 4 + src/trgen/Command.cs | 52 ++- src/trgen/Properties/launchSettings.json | 4 +- 7 files changed, 895 insertions(+), 16 deletions(-) create mode 100644 _tests/grammars-v4/b/BLexer.g4 create mode 100644 _tests/grammars-v4/b/BParser.g4 create mode 100644 _tests/grammars-v4/b/RulesGrammar.g4 create mode 100644 _tests/grammars-v4/b/RulesLexer.g4 create mode 100644 _tests/grammars-v4/b/desc.xml diff --git a/_tests/grammars-v4/b/BLexer.g4 b/_tests/grammars-v4/b/BLexer.g4 new file mode 100644 index 000000000..267128ae2 --- /dev/null +++ b/_tests/grammars-v4/b/BLexer.g4 @@ -0,0 +1,355 @@ +lexer grammar BLexer; + +@lexer::members { +public boolean systemGrammar = false; + +private boolean pragmaMode = false; +} + + +fragment DIGIT: ('0'..'9'); +fragment HEX_DIGIT: DIGIT | [a-fA-F]; +fragment LETTER: [a-zA-Z]; + +Number + : ('1'..'9') DIGIT+ + | DIGIT + ; + +Real_Number: Number '.' Number ; + +HEX_LITERAL: '0x' HEX_DIGIT+; + +MACHINE: 'MACHINE' ; +MODEL: 'MODEL'; +SYSTEM: 'SYSTEM' {systemGrammar}?; +REFINEMENT: 'REFINEMENT'; +IMPLEMENTATION: 'IMPLEMENTATION'; +REFINES: 'REFINES'; +END: 'END' ; +INITIALISATION: 'INITIALISATION'; +OPERATIONS: 'OPERATIONS' | 'EVENTS'; +LOCAL_OPERATIONS: 'LOCAL_OPERATIONS'; +VALUES: 'VALUES'; + + +// clauses +DEFINITIONS: 'DEFINITIONS'; +CONSTANTS: 'CONSTANTS'; +ABSTRACT_CONSTANTS: 'ABSTRACT_CONSTANTS'; +CONCRETE_CONSTANTS: 'CONCRETE_CONSTANTS'; +VARIABLES: 'VARIABLES'; +ABSTRACT_VARIABLES: 'ABSTRACT_VARIABLES'; +CONCRETE_VARIABLES: 'CONCRETE_VARIABLES'; + +// predicate clauses +CONSTRAINTS: 'CONSTRAINTS'; +PROPERTIES: 'PROPERTIES'; +INVARIANT: 'INVARIANT'; +ASSERTIONS: 'ASSERTIONS'; +// reference clauses +SEES: 'SEES'; +USES: 'USES'; +INCLUDES: 'INCLUDES'; +EXTENDS: 'EXTENDS'; +IMPORTS: 'IMPORTS'; +PROMOTES: 'PROMOTES'; + +SETS: 'SETS'; + +BEGIN: 'BEGIN'; +SKIP_SUB: 'skip'; +IF: 'IF'; +ELSIF: 'ELSIF'; +THEN: 'THEN'; +ELSE: 'ELSE'; +PRE: 'PRE'; +ASSERT: 'ASSERT'; +CHOICE: 'CHOICE'; +SUBSTITUTION_OR: 'OR'; +SELECT: 'SELECT'; +WHEN: 'WHEN'; +CASE: 'CASE'; +OF: 'OF'; +EITHER: 'EITHER'; +ANY: 'ANY'; +WHERE: 'WHERE'; +LET: 'LET'; +BE: 'BE'; +IN: 'IN'; +VAR: 'VAR'; +WHILE: 'WHILE'; +VARIANT: 'VARIANT'; +DO: 'DO'; + +FOR_ANY: '!' | '\u2200'; +EXITS: '#' | '\u2203'; +LAMBDA: '%' | '\u03bb'; +OUTPUT_PARAMETERS: '<--' | '\u2190'; +DOUBLE_EQUAL: EQUAL EQUAL; +ASSIGN: ':='; +DOUBLE_COLON: '::' | ':' '\u2208' ; /* becomes_element_of */ +EQUIVALENCE: '<=>' | '\u21d4'; +IMPLIES: EQUAL GREATER | '\u21d2'; +LEFT_BRACE: '{'; +RIGHT_BRACE: '}'; +LEFT_PAR: '('; +RIGHT_PAR: ')'; +LEFT_BRACKET: '['; +RIGHT_BRACKET: ']'; +MINUS: '-' | '\u2212'; +SET_SUBTRACTION: '\\'; +PLUS: '+'; // | '\u002b'; +SINGLE_QUOTE: '\''; +TILDE: '~' | '∼' | '⁻' '¹';// 0x207b 0xb9;'\u223c'; +DOT: '.'; +SEMICOLON: ';'; +VERTICAL_BAR: '|'; +DOUBLE_VERTICAL_BAR: '||' | '\u2225'; +COMMA: ','; +REC: 'rec'; +STRUCT: 'struct'; + +//predicate prefix operators +NOT: 'not' | '\u00ac'; +BOOl_CAST: 'bool'; + +// predicate infix operators +AND: '&'; +OR: 'or'; + +//expression_p125 +SET_RELATION: '<->' | '↔';//'\u2194'; +PARTIAL_FUNCTION: '+->'| '⇸';//'\u21f8'; +TOTAL_FUNCTION: '-->' | '→' | MINUS MINUS GREATER; //'\u2192'; +TOTAL_INJECTION: '>->' | '↣'; //'\u21a3'; +PARTIAL_INJECTION: '>+>' | '⤔'; //'\u2914'; +TOTAL_SURJECTION: '-->>' | '↠'; //'\u21a0'; +PARTIAL_SURJECTION: '+->>' | '⤀'; //'\u2900'; +TOTAL_BIJECTION: '>->>' | '⤖'; //'\u2916'; +PARTIAL_BIJECTION: '>+>>' ; + +// Extensions +TOTAL_RELATION: '<<->'; +SURJECTION_RELATION: '<->>' ; //surjection_relation = lt minus gt gt | 0xe101; +TOTAL_SURJECTION_RELATION: '<<->>'; //{normal} total_surjection_relation = lt lt minus gt gt | 0xe102; + +// expression infix operators P160 +OVERWRITE_RELATION: '<+'; +DIRECT_PRODUCT: '><'| '⊗' ; //'\u2297'; ? +CONCAT: '^'; +DOMAIN_RESTRICTION: '<|'; +DOMAIN_SUBSTRACTION: '<<|'; +RANGE_RESTRICTION: '|>'; +RANGE_SUBSTRATION: '|>>'; +INSERT_FRONT: '->'| '\u21fe'; +INSERT_TAIL: '<-' | '\u21fd'; + +INTERSECTION: '/\\' | '\u2229'; +RESTRICT_FRONT: '/|\\' | '\u2191'; +RESTRICT_TAIL: '\\|/' | '\u2193'; +MAPLET: '|->' | '\u21a6'; +UNION: '\\/' | '\u222a'; + + +DOLLAR_ZERO: '$0'; + +UNDERSCORE: '_'; + +//expression infix operators + +MULT: '*'; +DIVIDE: '/'; + +MOD: 'mod'; +POWER_OF: '**'; +INTERVAL: '..' | '\u2025'; + +// predicate infix opertors +EQUAL: '='; // '\u003d' +NOT_EQUAL: '/=' | '\u2260'; +COLON: ':' ; +ELEMENT_OF: '\u2208'; +INCLUSION: '<:' | '\u2286'; +STRICT_INCLUSION: '<<:' | '\u2282'; +NON_INCLUSION: '/<:' | '\u2288'; +STRICT_NON_INCLUSION: '/<<:' | '\u2284'; +NOT_BELONGING: '/:' | '\u2209'; +LESS: '<'; // '\u003c'; +LESS_EQUAL: LESS EQUAL | '\u2264'; +GREATER: '>'; // '\u003e'; +GREATER_EQUAL: GREATER EQUAL | '\u2265'; + +TRUE: 'TRUE'; +FALSE: 'FALSE'; + +BTRUE: 'btrue'; +BFALSE: 'bfalse'; + + + +// expression prefix operators with one parameter + +GENERALIZED_UNION: 'union' | '⋃';//'\u22c3'; +GENERALIZED_INTER: 'inter' | '∩';//'\u2229'; + +BTREE: 'btree'; +CARD: 'card'; +CLOSURE: 'closure'; +CLOSURE1: 'closure1'; +CONC: 'conc'; +DOM: 'dom'; +FIRST: 'first'; +FNC: 'fnc'; +FRONT: 'front'; +ID: 'id'; +INFIX: 'infix'; +ISEQ: 'iseq'; +ISEQ1: 'iseq1' ; // add 'iseq'0x8321 ? +LAST: 'last'; +LEFT: 'left'; +MAX: 'max'; +MIN: 'min'; +MIRROR: 'mirror'; +PERM: 'perm'; +POSTFIX: 'postfix'; +POW: 'POW'; +POW1: 'POW1'; +FIN: 'FIN'; +FIN1: 'FIN1'; +PREFIX: 'prefix'; +RAN: 'ran'; +REL: 'rel'; +REV: 'rev'; +RIGHT: 'right'; +SEQ: 'seq'; +SEQ1: 'seq1'; // add | 'seq'0x8321 ? +SIZET: 'sizet'; +SIZE: 'size'; +SONS: 'sons'; +TAIL: 'tail'; +TOP: 'top'; +TREE: 'tree'; + +// expression prefix operators with two parameters +CONST: 'const'; +FATHER: 'father'; +PRJ1: 'prj1'; +PRJ2: 'prj2'; +RANK: 'rank'; +SUBTREE: 'subtree'; +ARITY: 'arity'; +ITERATE: 'iterate'; + +// expression prefix operators with three parameters +SON: 'son'; + +// expression prefix operators with a variable list of parameters +BIN: 'bin'; + +//keyword operators +NATURAL: 'NATURAL' | '\u2115'; +NATURAL1: 'NATURAL1' | '\u2115' '\u0031' | '\u2115' '\u2081'; +NAT: 'NAT'; +NAT1: 'NAT1'; +INT: 'INT'; +INTEGER: 'INTEGER' | '\u2124'; +MAXINT: 'MAXINT'; +MININT: 'MININT'; +REAL: 'REAL' | '\u214F'; +BOOL: 'BOOL'; +STRING: 'STRING'; +PRED: 'pred'; +SUCC: 'succ'; + + +//special +SIGMA: 'SIGMA' | '∑'; //0x2211; +PI: 'PI' | '∏'; //0x220f; +QUANTIFIED_UNION: 'UNION'; +QUANTIFIED_INTER: 'INTER'; +QUANTIFIED_SET: 'SET'; + + + +fragment TSQ: '\'\'\''; +fragment SQ: '\''; + +StringLiteral + : '"' SignleStringCharacters? '"' + | TSQ MultiLineStringCharacters? TSQ + ; +fragment +SignleStringCharacters + : SingleLineStringCharacter+ + ; + +fragment +SingleLineStringCharacter + : ~["\n] + | '\\' '"' + ; + +fragment +MultiLineStringCharacters + : MultiLineStringCharacter+ + | MultiLineStringCharacter+ SQ SQ + | MultiLineStringCharacter+ SQ + ; + +fragment +MultiLineStringCharacter + : ~['] + | SQ ~['] + | SQ SQ ~['] + | '\\' SQ + ; + +// other + + +EXPRESSION_KEYWORD: '#EXPRESSION'; +PREDICATE_KEYWORD: '#PREDICATE'; +SUBSTITUTION_KEYWORD: '#SUBSTITUTION'; +FORMULA_KEYWORD: '#FORMULA'; +OPPATTERN_KEYWORD: '#OPPATTERN'; +MACHINECLAUSE: '#MACHINECLAUSE'; + + + +PRAGMA_SYMBOLIC: 'symbolic' {pragmaMode}?; + +IDENTIFIER + : LETTER (LETTER | DIGIT | '_')* + ; + + +NOT_REACHABLE: 'NOT_REACHABLE'; + +PRAGMA_START: '/*@' {pragmaMode=true;} -> skip ; +PRAGMA_STOP: '*/' {pragmaMode}? {pragmaMode=false;} -> skip ; + +COMMENT + : '/*' (~[@] .*?)? '*/' -> skip + ; + +LINE_COMMENT + : '//' ~[\r\n]* -> skip + ; + +WS: [ \t\r\n]+ -> skip; + + + +//---------------------- PRAGMA_MODE ------------------------------- +//mode PRAGMA_MODE; + +//PRAGMA_STOP: '*/' -> popMode, skip ; + + + +//PRAGMA_WS: [ \t\r\n]+ -> skip; + +//PRAGMA_UNIT: 'unit' -> skip; +//PRAGMA_LABEL: 'label' -> channel(PRAGMA_CHANNEL); +//PRAGMA_ID_OR_STRING: LETTER (LETTER | DIGIT | '_')* -> channel(PRAGMA_CHANNEL) ; diff --git a/_tests/grammars-v4/b/BParser.g4 b/_tests/grammars-v4/b/BParser.g4 new file mode 100644 index 000000000..d9d3cce8c --- /dev/null +++ b/_tests/grammars-v4/b/BParser.g4 @@ -0,0 +1,391 @@ +parser grammar BParser; + +options { tokenVocab=BLexer; } + +//import Blexer; +//options { tokenVocab=Blexer; } // this is currently not supported by gradle + +start + : parse_unit EOF # ParseUnit + ; + +parse_unit + : machine_x # MachineParserUnit + | definition_clause # DefinitionParseUnit + | FORMULA_KEYWORD formula # FormulaParseUnit + | EXPRESSION_KEYWORD expression # ExpressionParseUnit + | PREDICATE_KEYWORD predicate # PredicateParseUnit + | SUBSTITUTION_KEYWORD substitution # SubstitutionParseUnit + | OPPATTERN_KEYWORD operation_pattern # OpPatternParseUnit + | MACHINECLAUSE machine_clause # MachineClauseParseUnit + ; + + +operation_pattern + : name=composed_identifier + ('(' parameter_list+=op_pattern_param (COMMA parameter_list+=op_pattern_param)* ')')? # OpPattern + ; + +op_pattern_param + : expression_in_par # OpPatternExpression + | UNDERSCORE # OpPatternUnderscore + ; + + +machine_x + : variant=(MACHINE|MODEL|SYSTEM) machine_header (clauses+=machine_clause)* END # Machine + | REFINEMENT machine_header REFINES identifier (clauses+=machine_clause)* END # Refinement + | IMPLEMENTATION machine_header REFINES identifier (clauses+=machine_clause)* END # Implementation + ; + +machine_header + : name=IDENTIFIER ('(' parameter_list=identifier_list ')')? + ; + +machine_clause + : definition_clause # DefinitionClauseIndirection + | name=(CONSTRAINTS|PROPERTIES|INVARIANT) pred=predicate # PredicateClause + | name=(INCLUDES|EXTENDS|IMPORTS) instances+=machine_instantiation + (COMMA instances+=machine_instantiation)* # InstanceClause + | name=(SEES|USES|PROMOTES) + composed_identifier_list # ReferenceClause + | name=(CONSTANTS|ABSTRACT_CONSTANTS|CONCRETE_CONSTANTS| + VARIABLES|ABSTRACT_VARIABLES|CONCRETE_VARIABLES) + identifier_list # DeclarationClause + | INITIALISATION substitution # InitialisationClause + | name=(OPERATIONS|LOCAL_OPERATIONS) + ops+=operation (SEMICOLON ops+=operation)* # OperationsClause + | VALUES idents+=IDENTIFIER EQUAL exprs+=expression + (SEMICOLON idents+=IDENTIFIER EQUAL exprs+=expression)* # ValuesClause + | ASSERTIONS preds+=predicate (SEMICOLON pred+=predicate)* # AssertionClause + | SETS set_definition (SEMICOLON set_definition)* # SetsClause + ; + +definition_clause + : DEFINITIONS defs+=definition (SEMICOLON defs+=definition)* SEMICOLON? # DefinitionClause + ; + +machine_instantiation + : (prefix=IDENTIFIER DOT)? name=IDENTIFIER ( '(' exprs+=expression (',' exprs+=expression)* ')' )? + ; + +set_definition + : IDENTIFIER # DeferredSet + | IDENTIFIER EQUAL LEFT_BRACE identifier_list RIGHT_BRACE # EnumeratedSet + ; + +operation + : (output=identifier_list OUTPUT_PARAMETERS )? IDENTIFIER ('(' parameters=identifier_list ')')? EQUAL substitution # BOperation + ; + +composed_identifier_list + : idents+=composed_identifier (',' idents+=composed_identifier)* + ; + +quantified_variables_list + : identifier_list + | LEFT_PAR identifier_list RIGHT_PAR + ; + +identifier_list + : idents+=IDENTIFIER (',' idents+=IDENTIFIER)* + ; + +definition + : name=IDENTIFIER ('(' parameters=identifier_list ')')? DOUBLE_EQUAL formula # OrdinaryDefinition + | StringLiteral # DefinitionFile + ; + +formula + : composed_identifier ('(' expression_list ')')? # FormulaAmbiguousCall + | expression #FormulaExpression + | predicate #FormulaPredicate + | substitution #FormulaSubstitution + ; + +//******************* Substitutions **************************** + //| left=substitution operator=(SEMICOLON | DOUBLE_VERTICAL_BAR) right=substitution #SubstitutionCompositionOrParallel //P20 +substitution + : subs+=substitution_l1 ( operators+=(SEMICOLON | DOUBLE_VERTICAL_BAR) subs+=substitution_l1)+ # SubstitutionList //p40 + | substitution_l1 # SubstitutionNextL1 + ; + +substitution_l1 + : BEGIN substitution END #SubstitutionBlock + | SKIP_SUB #SubstitutionSkip + | keyword=(PRE|ASSERT) predicate THEN substitution END #ConditionSubstitution + | CHOICE substitution (SUBSTITUTION_OR substitution)* END #ChoiceSubstitution + | SELECT pred=predicate THEN sub=substitution + (WHEN when_pred+=predicate THEN when_sub+=substitution)* + (ELSE else_sub=substitution)? END #SelectSubstitution + | CASE expr=expression OF EITHER either=expression_list THEN sub=substitution + (SUBSTITUTION_OR or_exprs+=expression_list THEN or_subs+=substitution)+ + (ELSE else_sub=substitution)? END END #CaseSubstitution + | ANY identifier_list WHERE predicate THEN substitution END #AnySubstitution + | LET identifier_list BE predicate IN substitution END #LetSubstitution + | identifier_list DOUBLE_COLON expression #BecomesElementOfSubstitution + | identifier_list (ELEMENT_OF|COLON) LEFT_PAR predicate RIGHT_PAR #BecomesSuchThatSubstitution + | VAR identifier_list IN substitution END #VarSubstitution + | IF pred=predicate THEN thenSub=substitution + (ELSIF elsifPred+=predicate THEN elsifSub+=substitution)* + (ELSE elseSub=substitution)? END #IfSubstitution + | WHILE condition=predicate DO substitution INVARIANT invariant=predicate + VARIANT variant=expression END #WhileSubstitution + | identifier_or_function_or_record (',' identifier_or_function_or_record)* + ':=' expression_list #AssignSubstitution + | composed_identifier ('(' expression_list ')')? #SubstitutionIdentifierCall + | output=identifier_list OUTPUT_PARAMETERS composed_identifier ('(' expression_list ')')? #SubstitutionOperationCall + | substitution_extension_point # SubstitutionNextExtensionPoint + ; + +substitution_extension_point + : NOT_REACHABLE # SubstitutionExtensionPoint + ; + +identifier_or_function_or_record + : IDENTIFIER # AssignSingleIdentifier + | name=IDENTIFIER ('(' argument_lists+=expression_list ')' )+ # AssignFunctionIdentifier + | name=IDENTIFIER (SINGLE_QUOTE attributes+=IDENTIFIER)+ # AssignRecordIdentifier + ; + +expression_in_par_list + : '(' exprs+=expression_in_par (',' exprs+=expression_in_par)* ')' + ; + +expression_list + : exprs+=expression (',' exprs+=expression)* + ; + +predicate + : left=predicate_p40 (operator=IMPLIES right=predicate_p40) # Implication //p30 + | predicate_p40 # PredicateP30Next + ; + +predicate_p40 + : terms+=predicate_atomic ( operators+=(AND|OR) terms+=predicate_atomic)+ # AndOrList //p40 + | predicate_atomic # PredicateP40Next + ; + +predicate_atomic + : '(' predicate ')' # PredicateParenthesis + | keyword=(BTRUE|BFALSE) # PredicateKeyword + | composed_identifier ('(' arguments+=expression (',' arguments+=expression)* ')')? # PredicateIdentifierCall + | IF conditionPred=predicate THEN thenPred=predicate + ELSE elsePred=predicate END # PredicateIf + | LET identifier_list BE pred1=predicate IN pred2=predicate END # PredicateLet + | NOT '(' predicate ')' # PredicateNot + | operator=(FOR_ANY|EXITS) quantified_variables_list + DOT LEFT_PAR predicate RIGHT_PAR # QuantifiedPredicate + | left=expression + predicate_expression_operator + right=expression # PredicateBinExpression + | left=predicate_atomic operator=EQUIVALENCE right=predicate_atomic # PredicateBinPredicateOperator //p60 + | LEFT_BRACKET identifier_list ASSIGN expression_list RIGHT_BRACKET predicate_atomic # WeakestPreconditionPredicate + | predicate_extension_point # PredicateNextExtensionPoint + ; + +predicate_extension_point + : NOT_REACHABLE + ; + + +predicate_expression_operator + : operator= + ( EQUAL + | ELEMENT_OF + | COLON + | INCLUSION + | STRICT_INCLUSION + | NON_INCLUSION + | STRICT_NON_INCLUSION + | NOT_EQUAL + | NOT_BELONGING + | LESS_EQUAL + | LESS + | GREATER_EQUAL + | GREATER + ) + ; + + +expression_in_par + : left=expression_in_par operator=(SEMICOLON | DOUBLE_VERTICAL_BAR) + right=expression_in_par # CompositionOrParallelProduct //p20 + | expression # ExpressionInParNext + ; + +expression + : Number # Number + | Real_Number # RealNumber + | HEX_LITERAL # HexDigit + | value=(TRUE|FALSE) # BooleanValue + | StringLiteral # String + | LEFT_PAR expression_in_par RIGHT_PAR # Parenthesis + | LEFT_PAR expression_in_par (COMMA expression_in_par)+ RIGHT_PAR # Tuple + | LEFT_BRACE expression_list RIGHT_BRACE # SetEnumeration + | LEFT_BRACE RIGHT_BRACE # EmptySet + | LESS GREATER # EmptySequence + | LEFT_BRACKET RIGHT_BRACKET # EmptySequence + | LEFT_BRACKET expression_list RIGHT_BRACKET # SequenceEnumeration + | operator=(REC|STRUCT) LEFT_PAR entries+=rec_entry + (COMMA entries+=rec_entry)* RIGHT_PAR # Record + | composed_identifier DOLLAR_ZERO # PrimedIdentifierExpression + | composed_identifier # ExpressionIdentifier + | BOOl_CAST '(' predicate ')' # BoolCastExpression + | expression_prefix_operator '(' expr=expression_in_par ')' # ExpressionPrefixOperator + | expression_prefix_operator_2_args + '(' expr1=expression_in_par ',' expr2=expression_in_par ')' # ExpressionPrefixOperator2Args + | expression_keyword # ExpressionKeyword //e.g. NATURAL,.. + | PRAGMA_SYMBOLIC? LAMBDA quantified_variables_list + DOT LEFT_PAR predicate VERTICAL_BAR expression_in_par RIGHT_PAR # LambdaExpression + | operator=(QUANTIFIED_UNION|QUANTIFIED_INTER|SIGMA|PI) quantified_variables_list + DOT LEFT_PAR predicate VERTICAL_BAR expression_in_par RIGHT_PAR # QuantifiedExpression + | QUANTIFIED_SET quantified_variables_list DOT LEFT_PAR predicate RIGHT_PAR # QuantifiedSet + | '{' identifier_list VERTICAL_BAR predicate '}' # SetComprehension + + // extensions + | LET identifier_list BE predicate IN expression_in_par END # LetExpression + | IF predicate THEN expr1=expression_in_par ELSE expr2=expression_in_par END # IfExpression + // operators with precedences + | expression SINGLE_QUOTE identifier # RecordFieldAccess //precedence? + | left=expression LEFT_BRACKET right=expression_in_par RIGHT_BRACKET # ImageExpression + | expression TILDE # ReverseExpression //p230 + | function=expression '(' arguments+=expression_in_par + (',' arguments+=expression_in_par)* ')' # ExpressionFunctionCall //? + | MINUS expression # UnaryMinus //P210 + | left=expression operator=POWER_OF right=expression # BinOperator //p200 + | left=expression operator=(MULT|DIVIDE|MOD) right=expression # BinOperator //p190 + | left=expression operator=(PLUS|MINUS|SET_SUBTRACTION) right=expression # BinOperator //p180 + | left=expression operator=INTERVAL right=expression # BinOperator //p170 + | left=expression expressionOperatorP160 right=expression # BinOperatorP160 //p160 + | left=expression expression_bin_operator_p125 right=expression # ExpressionBinOperatorP125 //p125 + | expression_extension_point # ExpressionNextExtensionPoint + ; + +expression_extension_point + : NOT_REACHABLE + ; + +rec_entry + : identifier COLON expression_in_par + ; + +expression_bin_operator_p125 + : operator= + ( SET_RELATION + | PARTIAL_FUNCTION + | TOTAL_FUNCTION + | TOTAL_INJECTION + | PARTIAL_INJECTION + | TOTAL_SURJECTION + | PARTIAL_SURJECTION + | TOTAL_BIJECTION + | PARTIAL_BIJECTION + | TOTAL_RELATION + | SURJECTION_RELATION + | TOTAL_SURJECTION_RELATION + ) + ; + +expression_prefix_operator + : operator=( + GENERALIZED_UNION + | GENERALIZED_INTER + | BTREE + | CARD + | CLOSURE + | CLOSURE1 + | CONC + | DOM + | FIRST + | FNC + | FRONT + | ID + | INFIX + | ISEQ + | ISEQ1 + | LAST + | LEFT + | MAX + | MIN + | MIRROR + | PERM + | POSTFIX + | PRED + | POW + | POW1 + | FIN + | FIN1 + | PREFIX + | RAN + | REL + | REV + | RIGHT + | SEQ + | SEQ1 + | SIZE + | SIZET + | SONS + | SUCC + | TAIL + | TOP + | TREE + ) + ; + +expression_prefix_operator_2_args + :operator=(CONST + | FATHER + | PRJ1 + | PRJ2 + | RANK + | SUBTREE + | ARITY + | ITERATE + ) + ; + +expression_keyword + : operator=(NATURAL + | NATURAL1 + | NAT + | NAT1 + | INT + | INTEGER + | BOOL + | STRING + | MAXINT + | MININT + | REAL + ) + ; + + +expressionOperatorP160 + : operator=( + OVERWRITE_RELATION + | DIRECT_PRODUCT + | CONCAT + | DOMAIN_RESTRICTION + | DOMAIN_SUBSTRACTION + | RANGE_RESTRICTION + | RANGE_SUBSTRATION + | INSERT_FRONT + | INSERT_TAIL + | UNION + | INTERSECTION + | RESTRICT_FRONT + | RESTRICT_TAIL + | MAPLET + ) + ; + + + +composed_identifier + : IDENTIFIER ('.' IDENTIFIER)* + ; + +identifier + : IDENTIFIER + ; diff --git a/_tests/grammars-v4/b/RulesGrammar.g4 b/_tests/grammars-v4/b/RulesGrammar.g4 new file mode 100644 index 000000000..a8352391c --- /dev/null +++ b/_tests/grammars-v4/b/RulesGrammar.g4 @@ -0,0 +1,52 @@ +parser grammar RulesGrammar; + +import BParser; + +options { + tokenVocab=RulesLexer; +} + + +start + : parse_unit EOF # ParseUnit + ; + +machine_x + : variant=(MACHINE|RULES_MACHINE) machine_header (clauses+=machine_clause)* END # Machine + | REFINEMENT machine_header REFINES identifier (clauses+=machine_clause)* END # Refinement + | IMPLEMENTATION machine_header REFINES identifier (clauses+=machine_clause)* END # Implementation + ; + +operation + : (output=identifier_list OUTPUT_PARAMETERS )? IDENTIFIER ('(' parameters=identifier_list ')')? EQUAL substitution # BOperation + | keyword=(RULE|COMPUTATION) IDENTIFIER operation_attributes* BODY substitution END # RuleComputationOperation + | FUNCTION (return_values=identifier_list OUTPUT_PARAMETERS)? IDENTIFIER ('(' parameters=identifier_list ')') ? operation_attributes* BODY substitution END # FunctionOperation + ; + + +operation_attributes + : keyword=(DEPENDS_ON_RULE|DEPENDS_ON_COMPUTATION) identifier_list # DependsOnAttribute + | keyword=ERROR_TYPES Number # ErrorTypesAttribute + | keyword=(RULEID|CLASSIFICATION) expression # ExpressionAttribute + | keyword=TAGS expression_list # TagsAttribute + | keyword=(PRECONDITION|ACTIVATION) predicate # PredicateAttribute + ; + +substitution_extension_point + : RULE_FORALL identifier_list WHERE where_pred=predicate EXPECT expect_pred=predicate + (ERROR_TYPE Number)? COUNTEREXAMPLE expression_in_par END # RuleForAllSubstitution + | RULE_ANY identifier_list WHERE predicate (ERROR_TYPE Number)? COUNTEREXAMPLE expression_in_par END # RuleAnySubstitution + | FOR IDENTIFIER IN expression_in_par DO substitution END # ForLoopSubstitution + | RULE_FAIL '(' expression_list ')' # RuleFailSubstitution + | DEFINE IDENTIFIER TYPE type_expr=expression_in_par + (DUMMY_VALUE dummy_expr=expression_in_par)? VALUE value_expr=expression_in_par END # DefineSubstitution + ; + +predicate_extension_point + : keyword=(SUCCEEDED_RULE|SUCCEEDED_RULE_ERROR_TYPE|FAILED_RULE|FAILED_RULE_ERROR_TYPE + |NOT_CHECKED_RULE|DISABLED_RULE) '(' expression_list ')' # PredicateOperator + ; + +expression_extension_point + : keyword=(STRING_FORMAT|GET_RULE_COUNTEREXAMPLES) '(' expression_list ')' # ExpressionOperator + ; diff --git a/_tests/grammars-v4/b/RulesLexer.g4 b/_tests/grammars-v4/b/RulesLexer.g4 new file mode 100644 index 000000000..a753db791 --- /dev/null +++ b/_tests/grammars-v4/b/RulesLexer.g4 @@ -0,0 +1,53 @@ +lexer grammar RulesLexer; + + + +/*@lexer::members { +public static final int PRAGMA_MODE = 1; +}*/ + +import BLexer; + +/* +options { + tokenVocab=BLexer; +}*/ + + +RULES_MACHINE: 'RULES_MACHINE'; +RULE: 'RULE' ; +COMPUTATION: 'COMPUTATION'; +FUNCTION: 'FUNCTION'; + +DEPENDS_ON_RULE: 'DEPENDS_ON_RULE'; +DEPENDS_ON_COMPUTATION: 'DEPENDS_ON_COMPUTATION'; +ERROR_TYPES: 'ERROR_TYPES'; +RULEID: 'RULEID'; +CLASSIFICATION: 'CLASSIFICATION'; +TAGS: 'TAGS'; +PRECONDITION: 'PRECONDITION'; +ACTIVATION: 'ACTIVATION'; + +BODY: 'BODY'; +IN: 'IN'; +RULE_FORALL: 'RULE_FORALL'; +RULE_ANY: 'RULE_ANY'; +FOR: 'FOR'; +EXPECT: 'EXPECT'; +COUNTEREXAMPLE: 'COUNTEREXAMPLE'; +ERROR_TYPE: 'ERROR_TYPE'; +RULE_FAIL: 'RULE_FAIL'; +DEFINE: 'DEFINE'; +TYPE: 'TYPE'; +DUMMY_VALUE: 'DUMMY_VALUE'; +VALUE: 'VALUE'; + +SUCCEEDED_RULE: 'SUCCEEDED_RULE'; +SUCCEEDED_RULE_ERROR_TYPE: 'SUCCEEDED_RULE_ERROR_TYPE'; +FAILED_RULE: 'FAILED_RULE'; +FAILED_RULE_ERROR_TYPE: 'FAILED_RULE_ERROR_TYPE'; +NOT_CHECKED_RULE: 'NOT_CHECKED_RULE'; +DISABLED_RULE: 'DISABLED_RULE'; + +STRING_FORMAT: 'STRING_FORMAT'; +GET_RULE_COUNTEREXAMPLES: 'GET_RULE_COUNTEREXAMPLES'; diff --git a/_tests/grammars-v4/b/desc.xml b/_tests/grammars-v4/b/desc.xml new file mode 100644 index 000000000..f1f3998b0 --- /dev/null +++ b/_tests/grammars-v4/b/desc.xml @@ -0,0 +1,4 @@ + + + Java + diff --git a/src/trgen/Command.cs b/src/trgen/Command.cs index 913d9345c..880b528e8 100644 --- a/src/trgen/Command.cs +++ b/src/trgen/Command.cs @@ -345,10 +345,11 @@ private void ModifyWithGrammarParse(Config config) // Note, we can't do that by name because some grammars, like // grammars-v4/r, won't build that way. // Use Trash compiler to get dependencies. - ComputeSort(test); + var dependency_graph = ComputeSort(test); - // Pick top-level grammars. - if (test.grammar_name == null) + // Pick top-level parser grammar. + GrammarTuple top_level_parser_grammar = null; + if(test.grammar_name == null) { var all = test.tool_grammar_tuples .Where(t => t.WhatType == GrammarTuple.Type.Parser && t.IsTopLevel).ToList(); @@ -360,6 +361,8 @@ private void ModifyWithGrammarParse(Config config) { throw new Exception("Can't figure out the grammar name."); } + + top_level_parser_grammar = all.First(); Regex r = new Regex("^(.*)Parser$"); var name = all.First().GrammarName; if (name != null) test.grammar_name = r.Replace(name, "$1"); @@ -368,10 +371,36 @@ private void ModifyWithGrammarParse(Config config) { throw new Exception("Can't figure out the grammar name."); } - test.tool_grammar_tuples = test.tool_grammar_tuples - .Where(t => t.GrammarName == test.grammar_name - || t.GrammarName == test.grammar_name + "Parser" - || t.GrammarName == test.grammar_name + "Lexer").ToList(); + // Pick top-level lexer grammar. + GrammarTuple top_level_lexer_grammar = null; + { + var all_lexers = + test.tool_grammar_tuples.Where( + t => t.WhatType == GrammarTuple.Type.Lexer && t.IsTopLevel).ToList(); + var all = all_lexers.Where(t => + { + if (dependency_graph.Edges.Where( + e => e.From == top_level_parser_grammar.GrammarName + && e.To == t.GrammarName).Any()) + return true; + else return false; + }).ToList(); + + if (!all.Any()) + { + throw new Exception("Can't figure out the grammar name."); + } + if (all.Count > 1) + { + throw new Exception("Can't figure out the grammar name."); + } + top_level_lexer_grammar = all.First(); + } + // Pick all top-level grammars, which are passed through Antlr Tool. + test.tool_grammar_tuples = new List(); + if (top_level_lexer_grammar.GrammarName != top_level_parser_grammar.GrammarName) + test.tool_grammar_tuples.Add(top_level_lexer_grammar); + test.tool_grammar_tuples.Add(top_level_parser_grammar); if (test.start_rule == null) { var b = test.tool_grammar_tuples @@ -458,23 +487,17 @@ private void ModifyWithGrammarParse(Config config) if (!t.IsTopLevel) continue; if (t.WhatType == GrammarTuple.Type.Parser) { - if (test.grammar_name == t.GrammarName || test.grammar_name + "Parser" == t.GrammarName) - { test.fully_qualified_parser_name = t.GrammarAutomName; test.fully_qualified_go_parser_name = t.GrammarGoNewName; parser_src_grammar_file_name = t.GrammarFileName; test.parser_grammar_file_name = parser_src_grammar_file_name; - } } else if (t.WhatType == GrammarTuple.Type.Lexer) { - if (test.grammar_name == t.GrammarName || test.grammar_name + "Lexer" == t.GrammarName) - { test.fully_qualified_lexer_name = t.GrammarAutomName; test.fully_qualified_go_lexer_name = t.GrammarGoNewName; lexer_src_grammar_file_name = t.GrammarFileName; test.lexer_grammar_file_name = lexer_src_grammar_file_name; - } } else if (t.WhatType == GrammarTuple.Type.Combined) { @@ -1658,7 +1681,7 @@ public static string Localize(LineTranslationType encoding, string code) return code; } - void ComputeSort(Test test) + Digraph ComputeSort(Test test) { Digraph graph = new Digraph(); // Add vertices. @@ -1721,6 +1744,7 @@ void ComputeSort(Test test) List order = sort.Topological_sort(); order.Reverse(); test.tool_grammar_tuples.Sort(new GrammarOrderCompare(order)); + return graph; } string FixedName(string from, Config config, Test test) diff --git a/src/trgen/Properties/launchSettings.json b/src/trgen/Properties/launchSettings.json index adfd48450..34bf0209c 100644 --- a/src/trgen/Properties/launchSettings.json +++ b/src/trgen/Properties/launchSettings.json @@ -2,8 +2,8 @@ "profiles": { "dotnet-antlr": { "commandName": "Project", - "commandLineArgs": "-t Antlr4ng", - "workingDirectory": "C:\\msys64\\home\\Kenne\\issues\\g4-current\\kotlin\\kotlin-formal" + "commandLineArgs": "-t Java", + "workingDirectory": "C:\\msys64\\home\\Kenne\\antlr-parser\\src\\main\\antlr\\files" } } } \ No newline at end of file From bd82dca5d0509f7e2ab3244dacb69d68a95bdd21 Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Sun, 6 Oct 2024 12:14:29 -0400 Subject: [PATCH 04/18] Add in check to trgen version to see why it is failing. --- _tests/basic-trees/test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/_tests/basic-trees/test.sh b/_tests/basic-trees/test.sh index 05367df9d..589bb5483 100644 --- a/_tests/basic-trees/test.sh +++ b/_tests/basic-trees/test.sh @@ -12,6 +12,7 @@ echo "$where" # Test. rm -rf Generated-CSharp +dotnet trgen -- --version dotnet trgen -- -t CSharp pushd Generated-CSharp make From 7b6f09b7b6bcd97d010c0916d087602d43d2ef7a Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Sun, 6 Oct 2024 12:37:10 -0400 Subject: [PATCH 05/18] Apparently, dotnet changed the syntax of how to run a local tool! --- _tests/basic-trees/test.sh | 4 ++-- _tests/delabel/test.sh | 2 +- _tests/delete/test.sh | 6 +++--- _tests/grammars-v4/test.sh | 2 +- _tests/insert/test.sh | 2 +- _tests/trcombine/test.sh | 6 +++--- _tests/trconvert/antlr2/save.test.sh | 2 +- _tests/trfoldlit/test.sh | 2 +- _tests/trgen-targets/test.sh | 2 +- _tests/trxml/test.sh | 4 ++-- _tests/xgrep/test.sh | 4 ++-- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/_tests/basic-trees/test.sh b/_tests/basic-trees/test.sh index 589bb5483..7355bd53b 100644 --- a/_tests/basic-trees/test.sh +++ b/_tests/basic-trees/test.sh @@ -12,8 +12,8 @@ echo "$where" # Test. rm -rf Generated-CSharp -dotnet trgen -- --version -dotnet trgen -- -t CSharp +dotnet trgen --version +dotnet trgen -t CSharp pushd Generated-CSharp make popd diff --git a/_tests/delabel/test.sh b/_tests/delabel/test.sh index 14c2b8ec5..0d401a165 100644 --- a/_tests/delabel/test.sh +++ b/_tests/delabel/test.sh @@ -17,7 +17,7 @@ do echo $i extension="${i##*.}" filename="${i%.*}" - dotnet trparse -- $i | dotnet trquery -- -c Generated/g4-scripts/delabel.xq | dotnet trsponge -- -c -o "Generated" + dotnet trparse $i | dotnet trquery -c Generated/g4-scripts/delabel.xq | dotnet trsponge -c -o "Generated" done rm -rf Generated/g4-scripts diff -r Gold Generated diff --git a/_tests/delete/test.sh b/_tests/delete/test.sh index 39e02f58b..a2157ae7a 100644 --- a/_tests/delete/test.sh +++ b/_tests/delete/test.sh @@ -12,9 +12,9 @@ rm -rf Generated mkdir Generated # Test. -dotnet trparse -- Expression.g4 | dotnet trquery -- delete '//parserRuleSpec[RULE_REF/text()="a"]' > o.pt -cat o.pt | dotnet trsponge -- -c -o Generated -cat o.pt | dotnet trtree -- > Generated/delete.tree +dotnet trparse Expression.g4 | dotnet trquery delete '//parserRuleSpec[RULE_REF/text()="a"]' > o.pt +cat o.pt | dotnet trsponge -c -o Generated +cat o.pt | dotnet trtree > Generated/delete.tree rm o.pt # Diff. diff --git a/_tests/grammars-v4/test.sh b/_tests/grammars-v4/test.sh index 3cf70731f..5512db6c6 100644 --- a/_tests/grammars-v4/test.sh +++ b/_tests/grammars-v4/test.sh @@ -8,7 +8,7 @@ do pushd $dirname for target in Antlr4ng Cpp CSharp Dart Go Java JavaScript Python3 TypeScript do - dotnet trgen -- -t $target + dotnet trgen -t $target # If a target is not available, exit code should zero, but Generated directory won't exist. if [ ! -d Generated-$target ] then diff --git a/_tests/insert/test.sh b/_tests/insert/test.sh index d9d9d5c0e..078db821a 100644 --- a/_tests/insert/test.sh +++ b/_tests/insert/test.sh @@ -12,7 +12,7 @@ rm -rf Generated mkdir Generated # Test. -dotnet trparse -- Expression.g4 | dotnet trquery -- 'insert //lexerRuleSpec/TOKEN_REF[text()="INT"] "fragment "' | dotnet trsponge -- -c -o Generated +dotnet trparse Expression.g4 | dotnet trquery 'insert //lexerRuleSpec/TOKEN_REF[text()="INT"] "fragment "' | dotnet trsponge -c -o Generated # Diff. for i in "$where/Generated/*" diff --git a/_tests/trcombine/test.sh b/_tests/trcombine/test.sh index b262e7a46..3a693a539 100644 --- a/_tests/trcombine/test.sh +++ b/_tests/trcombine/test.sh @@ -11,10 +11,10 @@ cd "$where" # Test. rm -rf Generated -dotnet trparse -- Arithmetic.g4 > o1.pt +dotnet trparse Arithmetic.g4 > o1.pt cat o1.pt | dotnet trsplit > o2.pt -cat o2.pt | dotnet trsponge -- -c -o Generated -dotnet trparse -- Generated/* | dotnet trcombine > o3.pt +cat o2.pt | dotnet trsponge -c -o Generated +dotnet trparse Generated/* | dotnet trcombine > o3.pt cat o3.pt | dotnet trtext > Generated/Arithmetic.g4 # Diff. diff --git a/_tests/trconvert/antlr2/save.test.sh b/_tests/trconvert/antlr2/save.test.sh index eb9c77d19..283d8bf3e 100644 --- a/_tests/trconvert/antlr2/save.test.sh +++ b/_tests/trconvert/antlr2/save.test.sh @@ -7,7 +7,7 @@ do echo $i extension="${i##*.}" filename="${i%.*}" - dotnet trparse -- $i -t antlr2 | dotnet trconvert | dotnet trsponge -- -c -o "$where/Generated" + dotnet trparse $i -t antlr2 | dotnet trconvert | dotnet trsponge -c -o "$where/Generated" done rm -f "$where"/Generated/*.txt2 diff -r "$where/Gold" "$where/Generated" diff --git a/_tests/trfoldlit/test.sh b/_tests/trfoldlit/test.sh index 51c87944e..f76e6ddfe 100644 --- a/_tests/trfoldlit/test.sh +++ b/_tests/trfoldlit/test.sh @@ -16,7 +16,7 @@ rm -rf Generated mkdir Generated # Test. -dotnet trparse -- Expression.g4 | dotnet trfoldlit | dotnet trsponge -- -c -o Generated +dotnet trparse Expression.g4 | dotnet trfoldlit | dotnet trsponge -c -o Generated # Diff. # Diff. diff --git a/_tests/trgen-targets/test.sh b/_tests/trgen-targets/test.sh index 0d45314c0..b82bb84ba 100644 --- a/_tests/trgen-targets/test.sh +++ b/_tests/trgen-targets/test.sh @@ -10,7 +10,7 @@ echo "$where" for target in Antlr4ng CSharp Cpp Dart Java JavaScript Python3 TypeScript Go do - dotnet trgen -- -t $target + dotnet trgen -t $target pushd Generated-$target make bash run.sh -input '1+2' diff --git a/_tests/trxml/test.sh b/_tests/trxml/test.sh index 93c79f691..f2b84c39d 100644 --- a/_tests/trxml/test.sh +++ b/_tests/trxml/test.sh @@ -3,11 +3,11 @@ export MSYS2_ARG_CONV_EXCL="*" where=`dirname -- "$0"` cd "$where" rm -rf Generated-CSharp -dotnet trgen -- -t CSharp --arithmetic +dotnet trgen -t CSharp --arithmetic cd Generated-CSharp dotnet restore Test.csproj dotnet build Test.csproj -dotnet trparse -- -i "1+2" | dotnet trxml > ../output +dotnet trparse -i "1+2" | dotnet trxml > ../output cd .. rm -rf Generated-CSharp/ dos2unix output diff --git a/_tests/xgrep/test.sh b/_tests/xgrep/test.sh index 059cbb5fd..3b73c8cd9 100644 --- a/_tests/xgrep/test.sh +++ b/_tests/xgrep/test.sh @@ -10,10 +10,10 @@ cd "$where" where=`pwd` rm -rf Generated-CSharp -dotnet trgen -- -t CSharp +dotnet trgen -t CSharp cd Generated-CSharp make -echo "1 + 2 + 3" | dotnet trparse | dotnet trquery -- grep ' //INT' | dotnet trtree > ../output +echo "1 + 2 + 3" | dotnet trparse | dotnet trquery grep ' //INT' | dotnet trtree > ../output cd .. #rm -rf Generated-CSharp From 145e16041c175c8fbcf689cfbeb7e82b17e636ae Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Sun, 6 Oct 2024 12:44:06 -0400 Subject: [PATCH 06/18] Fix install script: "--" no longer works! --- _scripts/install-local.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_scripts/install-local.sh b/_scripts/install-local.sh index 370d289cb..89b1127aa 100644 --- a/_scripts/install-local.sh +++ b/_scripts/install-local.sh @@ -16,6 +16,6 @@ do pushd $d tool=$d dotnet tool install $tool - dotnet $tool -- --version + dotnet $tool --version popd done From 94f6ad9b9bc3af1ea71f71f1321111bc12f20439 Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Sun, 6 Oct 2024 13:18:46 -0400 Subject: [PATCH 07/18] Update test. --- _tests/all-tests.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/_tests/all-tests.sh b/_tests/all-tests.sh index e6e01129d..158413d62 100644 --- a/_tests/all-tests.sh +++ b/_tests/all-tests.sh @@ -10,13 +10,17 @@ echo Tests in Trash: $tests failed=() for i in $tests do - bash $i + dir=`dirname $i` + fn=`basename $i` + pushd $dir + bash $fn result=$? if [ "$result" != 0 ] then echo Failed $i failed+=( $i ) fi + popd done if (( ${#failed[@]} != 0 )) then From 854a80a7dcc74984257e4f9de0f08126ae795f1f Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Sun, 6 Oct 2024 13:23:23 -0400 Subject: [PATCH 08/18] Turn on debugging. --- _tests/all-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_tests/all-tests.sh b/_tests/all-tests.sh index 158413d62..833f896c2 100644 --- a/_tests/all-tests.sh +++ b/_tests/all-tests.sh @@ -1,7 +1,7 @@ #!/bin/bash #set +e -#set -x +set -x export TERM=xterm-mono export MSYS2_ARG_CONV_EXCL="*" where=`dirname -- "$0"` From 7b3d422661395cb16d294916354999c3500ae171 Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Mon, 7 Oct 2024 10:00:14 -0400 Subject: [PATCH 09/18] Update dependency analysis of grammars. --- src/trgen/Command.cs | 25 ++++++++++++++++++++++++ src/trgen/Properties/launchSettings.json | 4 ++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/trgen/Command.cs b/src/trgen/Command.cs index 880b528e8..ded18edef 100644 --- a/src/trgen/Command.cs +++ b/src/trgen/Command.cs @@ -1693,6 +1693,7 @@ Digraph ComputeSort(Test test) // Add edges. foreach (var t in test.tool_grammar_tuples) { + // Look at grammar file contents to draw dependencies out. var v = t.GrammarName; var parsing_result_set = t.ParsingResultSet; org.eclipse.wst.xml.xpath2.processor.Engine engine = @@ -1701,6 +1702,7 @@ Digraph ComputeSort(Test test) using (ParseTreeEditing.UnvParseTreeDOM.AntlrDynamicContext dynamicContext = ate.Try(parsing_result_set.Nodes, parsing_result_set.Parser)) { + // Add an edge from the current grammar to "imported" grammar. var foo = engine.parseExpression( @"//delegateGrammars/delegateGrammar[not(ASSIGN)]/identifier/(RULE_REF | TOKEN_REF)/text()", new StaticContextBuilder()).evaluate(dynamicContext, @@ -1712,6 +1714,8 @@ Digraph ComputeSort(Test test) DirectedEdge e = new DirectedEdge() { From = v, To = f }; graph.AddEdge(e); } + + // Add an edge from the parser to lexer grammar if explicit. var bar = engine.parseExpression( @"//option[identifier/RULE_REF/text() = 'tokenVocab']/optionValue/identifier/(RULE_REF | TOKEN_REF)/text()", new StaticContextBuilder()).evaluate(dynamicContext, @@ -1725,8 +1729,29 @@ Digraph ComputeSort(Test test) // Make sure to mark lexer grammar as "top level". test.tool_grammar_tuples.Where(t => t.GrammarName == f).First().IsTopLevel = true; } + + // If there is no explicit "tokenVocab" statement, add in edge + // from this *parser grammar* to *lexer grammar*. + if (t.WhatType == GrammarTuple.Type.Parser) + { + var find = new Regex("Parser$").Replace(t.GrammarName, "Lexer"); + var to = test.tool_grammar_tuples.Where(l => + { + if (l.WhatType == GrammarTuple.Type.Lexer && + find == l.GrammarName) return true; + return false; + }); + foreach (var x in to) + { + DirectedEdge e = new DirectedEdge() { From = v, To = x.GrammarName }; + graph.AddEdge(e); + // Make sure to mark lexer grammar as "top level". + x.IsTopLevel = true; + } + } } } + // Mark all grammars that have no edges "in" are top level. var subset = graph.Vertices.ToList(); foreach (var n in subset) diff --git a/src/trgen/Properties/launchSettings.json b/src/trgen/Properties/launchSettings.json index 34bf0209c..e670a399e 100644 --- a/src/trgen/Properties/launchSettings.json +++ b/src/trgen/Properties/launchSettings.json @@ -2,8 +2,8 @@ "profiles": { "dotnet-antlr": { "commandName": "Project", - "commandLineArgs": "-t Java", - "workingDirectory": "C:\\msys64\\home\\Kenne\\antlr-parser\\src\\main\\antlr\\files" + "commandLineArgs": "-t CSharp", + "workingDirectory": "C:\\Users\\Kenne\\Documents\\GitHub\\Trash\\_tests\\basic-trees" } } } \ No newline at end of file From 80490b60e7ff409ef5373e4eae820c1b4e3a3836 Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Mon, 7 Oct 2024 14:42:33 -0400 Subject: [PATCH 10/18] Fix crash. --- src/trgen/Command.cs | 24 +++++++++++++++++++++++- src/trgen/Properties/launchSettings.json | 4 ++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/trgen/Command.cs b/src/trgen/Command.cs index ded18edef..e4ef661f3 100644 --- a/src/trgen/Command.cs +++ b/src/trgen/Command.cs @@ -349,6 +349,8 @@ private void ModifyWithGrammarParse(Config config) // Pick top-level parser grammar. GrammarTuple top_level_parser_grammar = null; + + if(test.grammar_name == null) { var all = test.tool_grammar_tuples @@ -361,7 +363,6 @@ private void ModifyWithGrammarParse(Config config) { throw new Exception("Can't figure out the grammar name."); } - top_level_parser_grammar = all.First(); Regex r = new Regex("^(.*)Parser$"); var name = all.First().GrammarName; @@ -371,6 +372,26 @@ private void ModifyWithGrammarParse(Config config) { throw new Exception("Can't figure out the grammar name."); } + + // Find top-level parser tuple if not set yet. + if (top_level_parser_grammar == null) + { + var all = test.tool_grammar_tuples + .Where(t => t.WhatType == GrammarTuple.Type.Parser + && t.IsTopLevel + && (t.GrammarName == test.grammar_name + || t.GrammarName == test.grammar_name+"Parser")).ToList(); + if (!all.Any()) + { + throw new Exception("Can't figure out the grammar name."); + } + if (all.Count > 1) + { + throw new Exception("Can't figure out the grammar name."); + } + top_level_parser_grammar = all.First(); + } + // Pick top-level lexer grammar. GrammarTuple top_level_lexer_grammar = null; { @@ -396,6 +417,7 @@ private void ModifyWithGrammarParse(Config config) } top_level_lexer_grammar = all.First(); } + // Pick all top-level grammars, which are passed through Antlr Tool. test.tool_grammar_tuples = new List(); if (top_level_lexer_grammar.GrammarName != top_level_parser_grammar.GrammarName) diff --git a/src/trgen/Properties/launchSettings.json b/src/trgen/Properties/launchSettings.json index e670a399e..7dc48784d 100644 --- a/src/trgen/Properties/launchSettings.json +++ b/src/trgen/Properties/launchSettings.json @@ -2,8 +2,8 @@ "profiles": { "dotnet-antlr": { "commandName": "Project", - "commandLineArgs": "-t CSharp", - "workingDirectory": "C:\\Users\\Kenne\\Documents\\GitHub\\Trash\\_tests\\basic-trees" + "commandLineArgs": "-t Antlr4ng", + "workingDirectory": "C:\\Users\\Kenne\\Documents\\GitHub\\Trash\\_tests\\grammars-v4\\glsl" } } } \ No newline at end of file From 19b3021f32434ec348c704b9e8f44428ecccd5ee Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Tue, 8 Oct 2024 06:39:01 -0400 Subject: [PATCH 11/18] Fix and add in csharp grammar since it also failed the Java target. --- .../csharp/CSharp/CSharpLexerBase.cs | 113 ++ .../csharp/CSharp/CSharpParserBase.cs | 27 + .../csharp/CSharp/CSharpPreprocessorParser.g4 | 48 + .../CSharp/CSharpPreprocessorParserBase.cs | 210 +++ _tests/grammars-v4/csharp/CSharpLexer.g4 | 1058 +++++++++++++ _tests/grammars-v4/csharp/CSharpParser.g4 | 1309 +++++++++++++++++ .../csharp/CSharpPreprocessorParser.g4 | 48 + .../csharp/Java/CSharpLexerBase.java | 103 ++ .../csharp/Java/CSharpParserBase.java | 22 + .../Java/CSharpPreprocessorParserBase.java | 203 +++ _tests/grammars-v4/csharp/README.md | 43 + _tests/grammars-v4/csharp/desc.xml | 6 + .../csharp/examples/AllInOneNoPreprocessor.cs | 1072 ++++++++++++++ .../grammars-v4/csharp/examples/C2430-ok.cs | 4 + _tests/grammars-v4/csharp/examples/C2430.cs | 6 + .../grammars-v4/csharp/examples/Multiple.cs | 7 + .../csharp/examples/Multiple.cs.errors | 1 + .../examples/MultiplicativeExprsInArgList.cs | 6 + .../csharp/examples/issue-2612.txt | 8 + .../csharp/examples/issue-2612.txt.errors | 1 + .../csharp/not-ready-examples/AllInOne.cs | 1100 ++++++++++++++ _tests/grammars-v4/csharp/pom.xml | 58 + src/trgen/Command.cs | 10 +- src/trgen/Properties/launchSettings.json | 4 +- 24 files changed, 5460 insertions(+), 7 deletions(-) create mode 100644 _tests/grammars-v4/csharp/CSharp/CSharpLexerBase.cs create mode 100644 _tests/grammars-v4/csharp/CSharp/CSharpParserBase.cs create mode 100644 _tests/grammars-v4/csharp/CSharp/CSharpPreprocessorParser.g4 create mode 100644 _tests/grammars-v4/csharp/CSharp/CSharpPreprocessorParserBase.cs create mode 100644 _tests/grammars-v4/csharp/CSharpLexer.g4 create mode 100644 _tests/grammars-v4/csharp/CSharpParser.g4 create mode 100644 _tests/grammars-v4/csharp/CSharpPreprocessorParser.g4 create mode 100644 _tests/grammars-v4/csharp/Java/CSharpLexerBase.java create mode 100644 _tests/grammars-v4/csharp/Java/CSharpParserBase.java create mode 100644 _tests/grammars-v4/csharp/Java/CSharpPreprocessorParserBase.java create mode 100644 _tests/grammars-v4/csharp/README.md create mode 100644 _tests/grammars-v4/csharp/desc.xml create mode 100644 _tests/grammars-v4/csharp/examples/AllInOneNoPreprocessor.cs create mode 100644 _tests/grammars-v4/csharp/examples/C2430-ok.cs create mode 100644 _tests/grammars-v4/csharp/examples/C2430.cs create mode 100644 _tests/grammars-v4/csharp/examples/Multiple.cs create mode 100644 _tests/grammars-v4/csharp/examples/Multiple.cs.errors create mode 100644 _tests/grammars-v4/csharp/examples/MultiplicativeExprsInArgList.cs create mode 100644 _tests/grammars-v4/csharp/examples/issue-2612.txt create mode 100644 _tests/grammars-v4/csharp/examples/issue-2612.txt.errors create mode 100644 _tests/grammars-v4/csharp/not-ready-examples/AllInOne.cs create mode 100644 _tests/grammars-v4/csharp/pom.xml diff --git a/_tests/grammars-v4/csharp/CSharp/CSharpLexerBase.cs b/_tests/grammars-v4/csharp/CSharp/CSharpLexerBase.cs new file mode 100644 index 000000000..028efd5b7 --- /dev/null +++ b/_tests/grammars-v4/csharp/CSharp/CSharpLexerBase.cs @@ -0,0 +1,113 @@ +using Antlr4.Runtime; +using System.Collections.Generic; +using System; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; + +public abstract class CSharpLexerBase : Lexer +{ + public CSharpLexerBase(ICharStream input) + : base(input) + { + _input = input; + } + + public CSharpLexerBase(ICharStream input, TextWriter output, TextWriter errorOutput) + : base(input, output, errorOutput) + { + _input = input; + } + + private ICharStream _input; + protected int interpolatedStringLevel; + protected Stack interpolatedVerbatiums = new Stack(); + protected Stack curlyLevels = new Stack(); + protected bool verbatium; + + protected void OnInterpolatedRegularStringStart() + { + interpolatedStringLevel++; + interpolatedVerbatiums.Push(false); + verbatium = false; + } + + protected void OnInterpolatedVerbatiumStringStart() + { + interpolatedStringLevel++; + interpolatedVerbatiums.Push(true); + verbatium = true; + } + + protected void OnOpenBrace() + { + if (interpolatedStringLevel > 0) + { + curlyLevels.Push(curlyLevels.Pop() + 1); + } + } + + protected void OnCloseBrace() + { + if (interpolatedStringLevel > 0) + { + curlyLevels.Push(curlyLevels.Pop() - 1); + if (curlyLevels.Peek() == 0) + { + curlyLevels.Pop(); + Skip(); + PopMode(); + } + } + } + + protected void OnColon() + { + + if (interpolatedStringLevel > 0) + { + int ind = 1; + bool switchToFormatString = true; + while ((char)_input.LA(ind) != '}') + { + if (_input.LA(ind) == ':' || _input.LA(ind) == ')') + { + switchToFormatString = false; + break; + } + ind++; + } + if (switchToFormatString) + { + this.Mode(CSharpLexer.INTERPOLATION_FORMAT); + } + } + } + + protected void OpenBraceInside() + { + curlyLevels.Push(1); + } + + protected void OnDoubleQuoteInside() + { + interpolatedStringLevel--; + interpolatedVerbatiums.Pop(); + verbatium = (interpolatedVerbatiums.Count() > 0 ? interpolatedVerbatiums.Peek() : false); + } + + protected void OnCloseBraceInside() + { + curlyLevels.Pop(); + } + + protected bool IsRegularCharInside() + { + return !verbatium; + } + + protected bool IsVerbatiumDoubleQuoteInside() + { + return verbatium; + } +} diff --git a/_tests/grammars-v4/csharp/CSharp/CSharpParserBase.cs b/_tests/grammars-v4/csharp/CSharp/CSharpParserBase.cs new file mode 100644 index 000000000..776debefa --- /dev/null +++ b/_tests/grammars-v4/csharp/CSharp/CSharpParserBase.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Antlr4.Runtime; + +public abstract class CSharpParserBase : Parser +{ + protected CSharpParserBase(ITokenStream input) + : base(input) + { + } + + protected CSharpParserBase(ITokenStream input, TextWriter output, TextWriter errorOutput) + : base(input, output, errorOutput) + { + } + + protected bool IsLocalVariableDeclaration() + { + var local_var_decl = this.Context as CSharpParser.Local_variable_declarationContext; + if (local_var_decl == null) return true; + var local_variable_type = local_var_decl.local_variable_type(); + if (local_variable_type == null) return true; + if (local_variable_type.GetText() == "var") return false; + return true; + } +} diff --git a/_tests/grammars-v4/csharp/CSharp/CSharpPreprocessorParser.g4 b/_tests/grammars-v4/csharp/CSharp/CSharpPreprocessorParser.g4 new file mode 100644 index 000000000..4339e71a5 --- /dev/null +++ b/_tests/grammars-v4/csharp/CSharp/CSharpPreprocessorParser.g4 @@ -0,0 +1,48 @@ +// Eclipse Public License - v 1.0, http://www.eclipse.org/legal/epl-v10.html +// Copyright (c) 2013, Christian Wulf (chwchw@gmx.de) +// Copyright (c) 2016-2017, Ivan Kochurkin (kvanttt@gmail.com), Positive Technologies. + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + +parser grammar CSharpPreprocessorParser; + +options { + tokenVocab = CSharpLexer; + superClass = CSharpPreprocessorParserBase; +} + +preprocessor_directive + returns[bool value] + : DEFINE CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.OnPreprocessorDirectiveDefine(); } # preprocessorDeclaration + | UNDEF CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.OnPreprocessorDirectiveUndef(); } # preprocessorDeclaration + | IF expr = preprocessor_expression directive_new_line_or_sharp { this.OnPreprocessorDirectiveIf(); } # preprocessorConditional + | ELIF expr = preprocessor_expression directive_new_line_or_sharp { this.OnPreprocessorDirectiveElif(); } # preprocessorConditional + | ELSE directive_new_line_or_sharp { this.OnPreprocessorDirectiveElse(); } # preprocessorConditional + | ENDIF directive_new_line_or_sharp { this.OnPreprocessorDirectiveEndif(); } # preprocessorConditional + | LINE (DIGITS STRING? | DEFAULT | DIRECTIVE_HIDDEN) directive_new_line_or_sharp { this.OnPreprocessorDirectiveLine(); } # preprocessorLine + | ERROR TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveError(); } # preprocessorDiagnostic + | WARNING TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveWarning(); } # preprocessorDiagnostic + | REGION TEXT? directive_new_line_or_sharp { this.OnPreprocessorDirectiveRegion(); } # preprocessorRegion + | ENDREGION TEXT? directive_new_line_or_sharp { this.OnPreprocessorDirectiveEndregion(); } # preprocessorRegion + | PRAGMA TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectivePragma(); } # preprocessorPragma + | NULLABLE TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveNullable(); } # preprocessorNullable + ; + +directive_new_line_or_sharp + : DIRECTIVE_NEW_LINE + | EOF + ; + +preprocessor_expression + returns[string value] + : TRUE { this.OnPreprocessorExpressionTrue(); } + | FALSE { this.OnPreprocessorExpressionFalse(); } + | CONDITIONAL_SYMBOL { this.OnPreprocessorExpressionConditionalSymbol(); } + | OPEN_PARENS expr = preprocessor_expression CLOSE_PARENS { this.OnPreprocessorExpressionConditionalOpenParens(); } + | BANG expr = preprocessor_expression { this.OnPreprocessorExpressionConditionalBang(); } + | expr1 = preprocessor_expression OP_EQ expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalEq(); } + | expr1 = preprocessor_expression OP_NE expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalNe(); } + | expr1 = preprocessor_expression OP_AND expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalAnd(); } + | expr1 = preprocessor_expression OP_OR expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalOr(); } + ; \ No newline at end of file diff --git a/_tests/grammars-v4/csharp/CSharp/CSharpPreprocessorParserBase.cs b/_tests/grammars-v4/csharp/CSharp/CSharpPreprocessorParserBase.cs new file mode 100644 index 000000000..36c9b7a37 --- /dev/null +++ b/_tests/grammars-v4/csharp/CSharp/CSharpPreprocessorParserBase.cs @@ -0,0 +1,210 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Antlr4.Runtime; + +public abstract class CSharpPreprocessorParserBase : Parser +{ + protected CSharpPreprocessorParserBase(ITokenStream input) + : base(input) + { + conditions.Push(true); + ConditionalSymbols.Add("DEBUG"); + } + + protected CSharpPreprocessorParserBase(ITokenStream input, TextWriter output, TextWriter errorOutput) + : base(input, output, errorOutput) + { + conditions.Push(true); + ConditionalSymbols.Add("DEBUG"); + } + + Stack conditions = new Stack(); + public HashSet ConditionalSymbols = new HashSet(); + + protected bool AllConditions() + { + foreach (bool condition in conditions) + { + if (!condition) + return false; + } + return true; + } + + protected void OnPreprocessorDirectiveDefine() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.PreprocessorDeclarationContext; + ConditionalSymbols.Add(d.CONDITIONAL_SYMBOL().GetText()); + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectiveUndef() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.PreprocessorDeclarationContext; + ConditionalSymbols.Remove(d.CONDITIONAL_SYMBOL().GetText()); + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectiveIf() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.PreprocessorConditionalContext; + d.value = d.expr.value.Equals("true") && AllConditions(); + conditions.Push(d.expr.value.Equals("true")); + } + + protected void OnPreprocessorDirectiveElif() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.PreprocessorConditionalContext; + if (!conditions.Peek()) + { + conditions.Pop(); + d.value = d.expr.value.Equals("true") && AllConditions(); + conditions.Push(d.expr.value.Equals("true")); + } + else + { + d.value = false; + } + } + + protected void OnPreprocessorDirectiveElse() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.PreprocessorConditionalContext; + if (!conditions.Peek()) + { + conditions.Pop(); + d.value = true && AllConditions(); + conditions.Push(true); + } + else + { + d.value = false; + } + } + + protected void OnPreprocessorDirectiveEndif() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.PreprocessorConditionalContext; + conditions.Pop(); + d.value = conditions.Peek(); + } + + protected void OnPreprocessorDirectiveLine() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.PreprocessorLineContext; + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectiveError() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.PreprocessorDiagnosticContext; + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectiveWarning() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.PreprocessorDiagnosticContext; + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectiveRegion() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.PreprocessorRegionContext; + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectiveEndregion() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.PreprocessorRegionContext; + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectivePragma() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.PreprocessorPragmaContext; + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectiveNullable() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.PreprocessorNullableContext; + d.value = AllConditions(); + } + + protected void OnPreprocessorExpressionTrue() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.Preprocessor_expressionContext; + d.value = "true"; + } + + protected void OnPreprocessorExpressionFalse() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.Preprocessor_expressionContext; + d.value = "false"; + } + + protected void OnPreprocessorExpressionConditionalSymbol() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.Preprocessor_expressionContext; + d.value = ConditionalSymbols.Contains(d.CONDITIONAL_SYMBOL().GetText()) ? "true" : "false"; + } + + protected void OnPreprocessorExpressionConditionalOpenParens() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.Preprocessor_expressionContext; + d.value = d.expr.value; + } + + protected void OnPreprocessorExpressionConditionalBang() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.Preprocessor_expressionContext; + d.value = d.expr.value.Equals("true") ? "false" : "true"; + } + + protected void OnPreprocessorExpressionConditionalEq() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.Preprocessor_expressionContext; + d.value = (d.expr1.value == d.expr2.value ? "true" : "false"); + } + + protected void OnPreprocessorExpressionConditionalNe() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.Preprocessor_expressionContext; + d.value = (d.expr1.value != d.expr2.value ? "true" : "false"); + } + + protected void OnPreprocessorExpressionConditionalAnd() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.Preprocessor_expressionContext; + d.value = (d.expr1.value.Equals("true") && d.expr2.value.Equals("true") ? "true" : "false"); + } + + protected void OnPreprocessorExpressionConditionalOr() + { + ParserRuleContext c = this.Context; + var d = c as CSharpPreprocessorParser.Preprocessor_expressionContext; + d.value = (d.expr1.value.Equals("true") || d.expr2.value.Equals("true") ? "true" : "false"); + } +} diff --git a/_tests/grammars-v4/csharp/CSharpLexer.g4 b/_tests/grammars-v4/csharp/CSharpLexer.g4 new file mode 100644 index 000000000..10cdbc336 --- /dev/null +++ b/_tests/grammars-v4/csharp/CSharpLexer.g4 @@ -0,0 +1,1058 @@ +// Eclipse Public License - v 1.0, http://www.eclipse.org/legal/epl-v10.html +// Copyright (c) 2013, Christian Wulf (chwchw@gmx.de) +// Copyright (c) 2016-2017, Ivan Kochurkin (kvanttt@gmail.com), Positive Technologies. + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + +lexer grammar CSharpLexer; + +channels { + COMMENTS_CHANNEL, + DIRECTIVE +} + +options { + superClass = CSharpLexerBase; +} + +BYTE_ORDER_MARK: '\u00EF\u00BB\u00BF'; + +SINGLE_LINE_DOC_COMMENT : '///' InputCharacter* -> channel(COMMENTS_CHANNEL); +EMPTY_DELIMITED_DOC_COMMENT : '/***/' -> channel(COMMENTS_CHANNEL); +DELIMITED_DOC_COMMENT : '/**' ~'/' .*? '*/' -> channel(COMMENTS_CHANNEL); +SINGLE_LINE_COMMENT : '//' InputCharacter* -> channel(COMMENTS_CHANNEL); +DELIMITED_COMMENT : '/*' .*? '*/' -> channel(COMMENTS_CHANNEL); +WHITESPACES : (Whitespace | NewLine)+ -> channel(HIDDEN); +SHARP : '#' -> mode(DIRECTIVE_MODE), skip; + +ABSTRACT : 'abstract'; +ADD : 'add'; +ALIAS : 'alias'; +ARGLIST : '__arglist'; +AS : 'as'; +ASCENDING : 'ascending'; +ASYNC : 'async'; +AWAIT : 'await'; +BASE : 'base'; +BOOL : 'bool'; +BREAK : 'break'; +BY : 'by'; +BYTE : 'byte'; +CASE : 'case'; +CATCH : 'catch'; +CHAR : 'char'; +CHECKED : 'checked'; +CLASS : 'class'; +CONST : 'const'; +CONTINUE : 'continue'; +DECIMAL : 'decimal'; +DEFAULT : 'default'; +DELEGATE : 'delegate'; +DESCENDING : 'descending'; +DO : 'do'; +DOUBLE : 'double'; +DYNAMIC : 'dynamic'; +ELSE : 'else'; +ENUM : 'enum'; +EQUALS : 'equals'; +EVENT : 'event'; +EXPLICIT : 'explicit'; +EXTERN : 'extern'; +FALSE : 'false'; +FINALLY : 'finally'; +FIXED : 'fixed'; +FLOAT : 'float'; +FOR : 'for'; +FOREACH : 'foreach'; +FROM : 'from'; +GET : 'get'; +GOTO : 'goto'; +GROUP : 'group'; +IF : 'if'; +IMPLICIT : 'implicit'; +IN : 'in'; +INT : 'int'; +INTERFACE : 'interface'; +INTERNAL : 'internal'; +INTO : 'into'; +IS : 'is'; +JOIN : 'join'; +LET : 'let'; +LOCK : 'lock'; +LONG : 'long'; +NAMEOF : 'nameof'; +NAMESPACE : 'namespace'; +NEW : 'new'; +NULL_ : 'null'; +OBJECT : 'object'; +ON : 'on'; +OPERATOR : 'operator'; +ORDERBY : 'orderby'; +OUT : 'out'; +OVERRIDE : 'override'; +PARAMS : 'params'; +PARTIAL : 'partial'; +PRIVATE : 'private'; +PROTECTED : 'protected'; +PUBLIC : 'public'; +READONLY : 'readonly'; +REF : 'ref'; +REMOVE : 'remove'; +RETURN : 'return'; +SBYTE : 'sbyte'; +SEALED : 'sealed'; +SELECT : 'select'; +SET : 'set'; +SHORT : 'short'; +SIZEOF : 'sizeof'; +STACKALLOC : 'stackalloc'; +STATIC : 'static'; +STRING : 'string'; +STRUCT : 'struct'; +SWITCH : 'switch'; +THIS : 'this'; +THROW : 'throw'; +TRUE : 'true'; +TRY : 'try'; +TYPEOF : 'typeof'; +UINT : 'uint'; +ULONG : 'ulong'; +UNCHECKED : 'unchecked'; +UNMANAGED : 'unmanaged'; +UNSAFE : 'unsafe'; +USHORT : 'ushort'; +USING : 'using'; +VAR : 'var'; +VIRTUAL : 'virtual'; +VOID : 'void'; +VOLATILE : 'volatile'; +WHEN : 'when'; +WHERE : 'where'; +WHILE : 'while'; +YIELD : 'yield'; + +//B.1.6 Identifiers +// must be defined after all keywords so the first branch (Available_identifier) does not match keywords +// https://msdn.microsoft.com/en-us/library/aa664670(v=vs.71).aspx +IDENTIFIER: '@'? IdentifierOrKeyword; + +//B.1.8 Literals +// 0.Equals() would be parsed as an invalid real (1. branch) causing a lexer error +LITERAL_ACCESS : [0-9] ('_'* [0-9])* IntegerTypeSuffix? '.' '@'? IdentifierOrKeyword; +INTEGER_LITERAL : [0-9] ('_'* [0-9])* IntegerTypeSuffix?; +HEX_INTEGER_LITERAL : '0' [xX] ('_'* HexDigit)+ IntegerTypeSuffix?; +BIN_INTEGER_LITERAL : '0' [bB] ('_'* [01])+ IntegerTypeSuffix?; +REAL_LITERAL: + ([0-9] ('_'* [0-9])*)? '.' [0-9] ('_'* [0-9])* ExponentPart? [FfDdMm]? + | [0-9] ('_'* [0-9])* ([FfDdMm] | ExponentPart [FfDdMm]?) +; + +CHARACTER_LITERAL : '\'' (~['\\\r\n\u0085\u2028\u2029] | CommonCharacter) '\''; +REGULAR_STRING : '"' (~["\\\r\n\u0085\u2028\u2029] | CommonCharacter)* '"'; +VERBATIUM_STRING : '@"' (~'"' | '""')* '"'; +INTERPOLATED_REGULAR_STRING_START: + '$"' { this.OnInterpolatedRegularStringStart(); } -> pushMode(INTERPOLATION_STRING) +; +INTERPOLATED_VERBATIUM_STRING_START: + '$@"' { this.OnInterpolatedVerbatiumStringStart(); } -> pushMode(INTERPOLATION_STRING) +; + +//B.1.9 Operators And Punctuators +OPEN_BRACE : '{' { this.OnOpenBrace(); }; +CLOSE_BRACE : '}' { this.OnCloseBrace(); }; +OPEN_BRACKET : '['; +CLOSE_BRACKET : ']'; +OPEN_PARENS : '('; +CLOSE_PARENS : ')'; +DOT : '.'; +COMMA : ','; +COLON : ':' { this.OnColon(); }; +SEMICOLON : ';'; +PLUS : '+'; +MINUS : '-'; +STAR : '*'; +DIV : '/'; +PERCENT : '%'; +AMP : '&'; +BITWISE_OR : '|'; +CARET : '^'; +BANG : '!'; +TILDE : '~'; +ASSIGNMENT : '='; +LT : '<'; +GT : '>'; +INTERR : '?'; +DOUBLE_COLON : '::'; +OP_COALESCING : '??'; +OP_INC : '++'; +OP_DEC : '--'; +OP_AND : '&&'; +OP_OR : '||'; +OP_PTR : '->'; +OP_EQ : '=='; +OP_NE : '!='; +OP_LE : '<='; +OP_GE : '>='; +OP_ADD_ASSIGNMENT : '+='; +OP_SUB_ASSIGNMENT : '-='; +OP_MULT_ASSIGNMENT : '*='; +OP_DIV_ASSIGNMENT : '/='; +OP_MOD_ASSIGNMENT : '%='; +OP_AND_ASSIGNMENT : '&='; +OP_OR_ASSIGNMENT : '|='; +OP_XOR_ASSIGNMENT : '^='; +OP_LEFT_SHIFT : '<<'; +OP_LEFT_SHIFT_ASSIGNMENT : '<<='; +OP_COALESCING_ASSIGNMENT : '??='; +OP_RANGE : '..'; + +// https://msdn.microsoft.com/en-us/library/dn961160.aspx +mode INTERPOLATION_STRING; + +DOUBLE_CURLY_INSIDE : '{{'; +OPEN_BRACE_INSIDE : '{' { this.OpenBraceInside(); } -> skip, pushMode(DEFAULT_MODE); +REGULAR_CHAR_INSIDE : { this.IsRegularCharInside() }? SimpleEscapeSequence; +VERBATIUM_DOUBLE_QUOTE_INSIDE : { this.IsVerbatiumDoubleQuoteInside() }? '""'; +DOUBLE_QUOTE_INSIDE : '"' { this.OnDoubleQuoteInside(); } -> popMode; +REGULAR_STRING_INSIDE : { this.IsRegularCharInside() }? ~('{' | '\\' | '"')+; +VERBATIUM_INSIDE_STRING : { this.IsVerbatiumDoubleQuoteInside() }? ~('{' | '"')+; + +mode INTERPOLATION_FORMAT; + +DOUBLE_CURLY_CLOSE_INSIDE : '}}' -> type(FORMAT_STRING); +CLOSE_BRACE_INSIDE : '}' { this.OnCloseBraceInside(); } -> skip, popMode; +FORMAT_STRING : ~'}'+; + +mode DIRECTIVE_MODE; + +DIRECTIVE_WHITESPACES : Whitespace+ -> channel(HIDDEN); +DIGITS : [0-9]+ -> channel(DIRECTIVE); +DIRECTIVE_TRUE : 'true' -> channel(DIRECTIVE), type(TRUE); +DIRECTIVE_FALSE : 'false' -> channel(DIRECTIVE), type(FALSE); +DEFINE : 'define' -> channel(DIRECTIVE); +UNDEF : 'undef' -> channel(DIRECTIVE); +DIRECTIVE_IF : 'if' -> channel(DIRECTIVE), type(IF); +ELIF : 'elif' -> channel(DIRECTIVE); +DIRECTIVE_ELSE : 'else' -> channel(DIRECTIVE), type(ELSE); +ENDIF : 'endif' -> channel(DIRECTIVE); +LINE : 'line' -> channel(DIRECTIVE); +ERROR : 'error' Whitespace+ -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); +WARNING : 'warning' Whitespace+ -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); +REGION : 'region' Whitespace* -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); +ENDREGION : 'endregion' Whitespace* -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); +PRAGMA : 'pragma' Whitespace+ -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); +NULLABLE : 'nullable' Whitespace+ -> channel(DIRECTIVE), mode(DIRECTIVE_TEXT); +DIRECTIVE_DEFAULT : 'default' -> channel(DIRECTIVE), type(DEFAULT); +DIRECTIVE_HIDDEN : 'hidden' -> channel(DIRECTIVE); +DIRECTIVE_OPEN_PARENS : '(' -> channel(DIRECTIVE), type(OPEN_PARENS); +DIRECTIVE_CLOSE_PARENS : ')' -> channel(DIRECTIVE), type(CLOSE_PARENS); +DIRECTIVE_BANG : '!' -> channel(DIRECTIVE), type(BANG); +DIRECTIVE_OP_EQ : '==' -> channel(DIRECTIVE), type(OP_EQ); +DIRECTIVE_OP_NE : '!=' -> channel(DIRECTIVE), type(OP_NE); +DIRECTIVE_OP_AND : '&&' -> channel(DIRECTIVE), type(OP_AND); +DIRECTIVE_OP_OR : '||' -> channel(DIRECTIVE), type(OP_OR); +DIRECTIVE_STRING: + '"' ~('"' | [\r\n\u0085\u2028\u2029])* '"' -> channel(DIRECTIVE), type(STRING) +; +CONDITIONAL_SYMBOL: IdentifierOrKeyword -> channel(DIRECTIVE); +DIRECTIVE_SINGLE_LINE_COMMENT: + '//' ~[\r\n\u0085\u2028\u2029]* -> channel(COMMENTS_CHANNEL), type(SINGLE_LINE_COMMENT) +; +DIRECTIVE_NEW_LINE: NewLine -> channel(DIRECTIVE), mode(DEFAULT_MODE); + +mode DIRECTIVE_TEXT; + +TEXT : ~[\r\n\u0085\u2028\u2029]+ -> channel(DIRECTIVE); +TEXT_NEW_LINE : NewLine -> channel(DIRECTIVE), type(DIRECTIVE_NEW_LINE), mode(DEFAULT_MODE); + +// Fragments + +fragment InputCharacter: ~[\r\n\u0085\u2028\u2029]; + +fragment NewLineCharacter: + '\u000D' //'' + | '\u000A' //'' + | '\u0085' //'' + | '\u2028' //'' + | '\u2029' //'' +; + +fragment IntegerTypeSuffix : [lL]? [uU] | [uU]? [lL]; +fragment ExponentPart : [eE] ('+' | '-')? [0-9] ('_'* [0-9])*; + +fragment CommonCharacter: SimpleEscapeSequence | HexEscapeSequence | UnicodeEscapeSequence; + +fragment SimpleEscapeSequence: + '\\\'' + | '\\"' + | '\\\\' + | '\\0' + | '\\a' + | '\\b' + | '\\f' + | '\\n' + | '\\r' + | '\\t' + | '\\v' +; + +fragment HexEscapeSequence: + '\\x' HexDigit + | '\\x' HexDigit HexDigit + | '\\x' HexDigit HexDigit HexDigit + | '\\x' HexDigit HexDigit HexDigit HexDigit +; + +fragment NewLine: + '\r\n' + | '\r' + | '\n' + | '\u0085' // ' + | '\u2028' //'' + | '\u2029' //'' +; + +fragment Whitespace: + UnicodeClassZS //'' + | '\u0009' //'' + | '\u000B' //'' + | '\u000C' //'
' +; + +fragment UnicodeClassZS: + '\u0020' // SPACE + | '\u00A0' // NO_BREAK SPACE + | '\u1680' // OGHAM SPACE MARK + | '\u180E' // MONGOLIAN VOWEL SEPARATOR + | '\u2000' // EN QUAD + | '\u2001' // EM QUAD + | '\u2002' // EN SPACE + | '\u2003' // EM SPACE + | '\u2004' // THREE_PER_EM SPACE + | '\u2005' // FOUR_PER_EM SPACE + | '\u2006' // SIX_PER_EM SPACE + | '\u2008' // PUNCTUATION SPACE + | '\u2009' // THIN SPACE + | '\u200A' // HAIR SPACE + | '\u202F' // NARROW NO_BREAK SPACE + | '\u3000' // IDEOGRAPHIC SPACE + | '\u205F' // MEDIUM MATHEMATICAL SPACE +; + +fragment IdentifierOrKeyword: IdentifierStartCharacter IdentifierPartCharacter*; + +fragment IdentifierStartCharacter: LetterCharacter | '_'; + +fragment IdentifierPartCharacter: + LetterCharacter + | DecimalDigitCharacter + | ConnectingCharacter + | CombiningCharacter + | FormattingCharacter +; + +//'' +// WARNING: ignores UnicodeEscapeSequence +fragment LetterCharacter: + UnicodeClassLU + | UnicodeClassLL + | UnicodeClassLT + | UnicodeClassLM + | UnicodeClassLO + | UnicodeClassNL + | UnicodeEscapeSequence +; + +//'' +// WARNING: ignores UnicodeEscapeSequence +fragment DecimalDigitCharacter: UnicodeClassND | UnicodeEscapeSequence; + +//'' +// WARNING: ignores UnicodeEscapeSequence +fragment ConnectingCharacter: UnicodeClassPC | UnicodeEscapeSequence; + +//'' +// WARNING: ignores UnicodeEscapeSequence +fragment CombiningCharacter: UnicodeClassMN | UnicodeClassMC | UnicodeEscapeSequence; + +//'' +// WARNING: ignores UnicodeEscapeSequence +fragment FormattingCharacter: UnicodeClassCF | UnicodeEscapeSequence; + +//B.1.5 Unicode Character Escape Sequences +fragment UnicodeEscapeSequence: + '\\u' HexDigit HexDigit HexDigit HexDigit + | '\\U' HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit +; + +fragment HexDigit: [0-9] | [A-F] | [a-f]; + +// Unicode character classes +fragment UnicodeClassLU: + '\u0041' ..'\u005a' + | '\u00c0' ..'\u00d6' + | '\u00d8' ..'\u00de' + | '\u0100' ..'\u0136' + | '\u0139' ..'\u0147' + | '\u014a' ..'\u0178' + | '\u0179' ..'\u017d' + | '\u0181' ..'\u0182' + | '\u0184' ..'\u0186' + | '\u0187' ..'\u0189' + | '\u018a' ..'\u018b' + | '\u018e' ..'\u0191' + | '\u0193' ..'\u0194' + | '\u0196' ..'\u0198' + | '\u019c' ..'\u019d' + | '\u019f' ..'\u01a0' + | '\u01a2' ..'\u01a6' + | '\u01a7' ..'\u01a9' + | '\u01ac' ..'\u01ae' + | '\u01af' ..'\u01b1' + | '\u01b2' ..'\u01b3' + | '\u01b5' ..'\u01b7' + | '\u01b8' ..'\u01bc' + | '\u01c4' ..'\u01cd' + | '\u01cf' ..'\u01db' + | '\u01de' ..'\u01ee' + | '\u01f1' ..'\u01f4' + | '\u01f6' ..'\u01f8' + | '\u01fa' ..'\u0232' + | '\u023a' ..'\u023b' + | '\u023d' ..'\u023e' + | '\u0241' ..'\u0243' + | '\u0244' ..'\u0246' + | '\u0248' ..'\u024e' + | '\u0370' ..'\u0372' + | '\u0376' ..'\u037f' + | '\u0386' ..'\u0388' + | '\u0389' ..'\u038a' + | '\u038c' ..'\u038e' + | '\u038f' ..'\u0391' + | '\u0392' ..'\u03a1' + | '\u03a3' ..'\u03ab' + | '\u03cf' ..'\u03d2' + | '\u03d3' ..'\u03d4' + | '\u03d8' ..'\u03ee' + | '\u03f4' ..'\u03f7' + | '\u03f9' ..'\u03fa' + | '\u03fd' ..'\u042f' + | '\u0460' ..'\u0480' + | '\u048a' ..'\u04c0' + | '\u04c1' ..'\u04cd' + | '\u04d0' ..'\u052e' + | '\u0531' ..'\u0556' + | '\u10a0' ..'\u10c5' + | '\u10c7' ..'\u10cd' + | '\u1e00' ..'\u1e94' + | '\u1e9e' ..'\u1efe' + | '\u1f08' ..'\u1f0f' + | '\u1f18' ..'\u1f1d' + | '\u1f28' ..'\u1f2f' + | '\u1f38' ..'\u1f3f' + | '\u1f48' ..'\u1f4d' + | '\u1f59' ..'\u1f5f' + | '\u1f68' ..'\u1f6f' + | '\u1fb8' ..'\u1fbb' + | '\u1fc8' ..'\u1fcb' + | '\u1fd8' ..'\u1fdb' + | '\u1fe8' ..'\u1fec' + | '\u1ff8' ..'\u1ffb' + | '\u2102' ..'\u2107' + | '\u210b' ..'\u210d' + | '\u2110' ..'\u2112' + | '\u2115' ..'\u2119' + | '\u211a' ..'\u211d' + | '\u2124' ..'\u212a' + | '\u212b' ..'\u212d' + | '\u2130' ..'\u2133' + | '\u213e' ..'\u213f' + | '\u2145' ..'\u2183' + | '\u2c00' ..'\u2c2e' + | '\u2c60' ..'\u2c62' + | '\u2c63' ..'\u2c64' + | '\u2c67' ..'\u2c6d' + | '\u2c6e' ..'\u2c70' + | '\u2c72' ..'\u2c75' + | '\u2c7e' ..'\u2c80' + | '\u2c82' ..'\u2ce2' + | '\u2ceb' ..'\u2ced' + | '\u2cf2' ..'\ua640' + | '\ua642' ..'\ua66c' + | '\ua680' ..'\ua69a' + | '\ua722' ..'\ua72e' + | '\ua732' ..'\ua76e' + | '\ua779' ..'\ua77d' + | '\ua77e' ..'\ua786' + | '\ua78b' ..'\ua78d' + | '\ua790' ..'\ua792' + | '\ua796' ..'\ua7aa' + | '\ua7ab' ..'\ua7ad' + | '\ua7b0' ..'\ua7b1' + | '\uff21' ..'\uff3a' +; + +fragment UnicodeClassLL: + '\u0061' ..'\u007A' + | '\u00b5' ..'\u00df' + | '\u00e0' ..'\u00f6' + | '\u00f8' ..'\u00ff' + | '\u0101' ..'\u0137' + | '\u0138' ..'\u0148' + | '\u0149' ..'\u0177' + | '\u017a' ..'\u017e' + | '\u017f' ..'\u0180' + | '\u0183' ..'\u0185' + | '\u0188' ..'\u018c' + | '\u018d' ..'\u0192' + | '\u0195' ..'\u0199' + | '\u019a' ..'\u019b' + | '\u019e' ..'\u01a1' + | '\u01a3' ..'\u01a5' + | '\u01a8' ..'\u01aa' + | '\u01ab' ..'\u01ad' + | '\u01b0' ..'\u01b4' + | '\u01b6' ..'\u01b9' + | '\u01ba' ..'\u01bd' + | '\u01be' ..'\u01bf' + | '\u01c6' ..'\u01cc' + | '\u01ce' ..'\u01dc' + | '\u01dd' ..'\u01ef' + | '\u01f0' ..'\u01f3' + | '\u01f5' ..'\u01f9' + | '\u01fb' ..'\u0233' + | '\u0234' ..'\u0239' + | '\u023c' ..'\u023f' + | '\u0240' ..'\u0242' + | '\u0247' ..'\u024f' + | '\u0250' ..'\u0293' + | '\u0295' ..'\u02af' + | '\u0371' ..'\u0373' + | '\u0377' ..'\u037b' + | '\u037c' ..'\u037d' + | '\u0390' ..'\u03ac' + | '\u03ad' ..'\u03ce' + | '\u03d0' ..'\u03d1' + | '\u03d5' ..'\u03d7' + | '\u03d9' ..'\u03ef' + | '\u03f0' ..'\u03f3' + | '\u03f5' ..'\u03fb' + | '\u03fc' ..'\u0430' + | '\u0431' ..'\u045f' + | '\u0461' ..'\u0481' + | '\u048b' ..'\u04bf' + | '\u04c2' ..'\u04ce' + | '\u04cf' ..'\u052f' + | '\u0561' ..'\u0587' + | '\u1d00' ..'\u1d2b' + | '\u1d6b' ..'\u1d77' + | '\u1d79' ..'\u1d9a' + | '\u1e01' ..'\u1e95' + | '\u1e96' ..'\u1e9d' + | '\u1e9f' ..'\u1eff' + | '\u1f00' ..'\u1f07' + | '\u1f10' ..'\u1f15' + | '\u1f20' ..'\u1f27' + | '\u1f30' ..'\u1f37' + | '\u1f40' ..'\u1f45' + | '\u1f50' ..'\u1f57' + | '\u1f60' ..'\u1f67' + | '\u1f70' ..'\u1f7d' + | '\u1f80' ..'\u1f87' + | '\u1f90' ..'\u1f97' + | '\u1fa0' ..'\u1fa7' + | '\u1fb0' ..'\u1fb4' + | '\u1fb6' ..'\u1fb7' + | '\u1fbe' ..'\u1fc2' + | '\u1fc3' ..'\u1fc4' + | '\u1fc6' ..'\u1fc7' + | '\u1fd0' ..'\u1fd3' + | '\u1fd6' ..'\u1fd7' + | '\u1fe0' ..'\u1fe7' + | '\u1ff2' ..'\u1ff4' + | '\u1ff6' ..'\u1ff7' + | '\u210a' ..'\u210e' + | '\u210f' ..'\u2113' + | '\u212f' ..'\u2139' + | '\u213c' ..'\u213d' + | '\u2146' ..'\u2149' + | '\u214e' ..'\u2184' + | '\u2c30' ..'\u2c5e' + | '\u2c61' ..'\u2c65' + | '\u2c66' ..'\u2c6c' + | '\u2c71' ..'\u2c73' + | '\u2c74' ..'\u2c76' + | '\u2c77' ..'\u2c7b' + | '\u2c81' ..'\u2ce3' + | '\u2ce4' ..'\u2cec' + | '\u2cee' ..'\u2cf3' + | '\u2d00' ..'\u2d25' + | '\u2d27' ..'\u2d2d' + | '\ua641' ..'\ua66d' + | '\ua681' ..'\ua69b' + | '\ua723' ..'\ua72f' + | '\ua730' ..'\ua731' + | '\ua733' ..'\ua771' + | '\ua772' ..'\ua778' + | '\ua77a' ..'\ua77c' + | '\ua77f' ..'\ua787' + | '\ua78c' ..'\ua78e' + | '\ua791' ..'\ua793' + | '\ua794' ..'\ua795' + | '\ua797' ..'\ua7a9' + | '\ua7fa' ..'\uab30' + | '\uab31' ..'\uab5a' + | '\uab64' ..'\uab65' + | '\ufb00' ..'\ufb06' + | '\ufb13' ..'\ufb17' + | '\uff41' ..'\uff5a' +; + +fragment UnicodeClassLT: + '\u01c5' ..'\u01cb' + | '\u01f2' ..'\u1f88' + | '\u1f89' ..'\u1f8f' + | '\u1f98' ..'\u1f9f' + | '\u1fa8' ..'\u1faf' + | '\u1fbc' ..'\u1fcc' + | '\u1ffc' ..'\u1ffc' +; + +fragment UnicodeClassLM: + '\u02b0' ..'\u02c1' + | '\u02c6' ..'\u02d1' + | '\u02e0' ..'\u02e4' + | '\u02ec' ..'\u02ee' + | '\u0374' ..'\u037a' + | '\u0559' ..'\u0640' + | '\u06e5' ..'\u06e6' + | '\u07f4' ..'\u07f5' + | '\u07fa' ..'\u081a' + | '\u0824' ..'\u0828' + | '\u0971' ..'\u0e46' + | '\u0ec6' ..'\u10fc' + | '\u17d7' ..'\u1843' + | '\u1aa7' ..'\u1c78' + | '\u1c79' ..'\u1c7d' + | '\u1d2c' ..'\u1d6a' + | '\u1d78' ..'\u1d9b' + | '\u1d9c' ..'\u1dbf' + | '\u2071' ..'\u207f' + | '\u2090' ..'\u209c' + | '\u2c7c' ..'\u2c7d' + | '\u2d6f' ..'\u2e2f' + | '\u3005' ..'\u3031' + | '\u3032' ..'\u3035' + | '\u303b' ..'\u309d' + | '\u309e' ..'\u30fc' + | '\u30fd' ..'\u30fe' + | '\ua015' ..'\ua4f8' + | '\ua4f9' ..'\ua4fd' + | '\ua60c' ..'\ua67f' + | '\ua69c' ..'\ua69d' + | '\ua717' ..'\ua71f' + | '\ua770' ..'\ua788' + | '\ua7f8' ..'\ua7f9' + | '\ua9cf' ..'\ua9e6' + | '\uaa70' ..'\uaadd' + | '\uaaf3' ..'\uaaf4' + | '\uab5c' ..'\uab5f' + | '\uff70' ..'\uff9e' + | '\uff9f' ..'\uff9f' +; + +fragment UnicodeClassLO: + '\u00aa' ..'\u00ba' + | '\u01bb' ..'\u01c0' + | '\u01c1' ..'\u01c3' + | '\u0294' ..'\u05d0' + | '\u05d1' ..'\u05ea' + | '\u05f0' ..'\u05f2' + | '\u0620' ..'\u063f' + | '\u0641' ..'\u064a' + | '\u066e' ..'\u066f' + | '\u0671' ..'\u06d3' + | '\u06d5' ..'\u06ee' + | '\u06ef' ..'\u06fa' + | '\u06fb' ..'\u06fc' + | '\u06ff' ..'\u0710' + | '\u0712' ..'\u072f' + | '\u074d' ..'\u07a5' + | '\u07b1' ..'\u07ca' + | '\u07cb' ..'\u07ea' + | '\u0800' ..'\u0815' + | '\u0840' ..'\u0858' + | '\u08a0' ..'\u08b2' + | '\u0904' ..'\u0939' + | '\u093d' ..'\u0950' + | '\u0958' ..'\u0961' + | '\u0972' ..'\u0980' + | '\u0985' ..'\u098c' + | '\u098f' ..'\u0990' + | '\u0993' ..'\u09a8' + | '\u09aa' ..'\u09b0' + | '\u09b2' ..'\u09b6' + | '\u09b7' ..'\u09b9' + | '\u09bd' ..'\u09ce' + | '\u09dc' ..'\u09dd' + | '\u09df' ..'\u09e1' + | '\u09f0' ..'\u09f1' + | '\u0a05' ..'\u0a0a' + | '\u0a0f' ..'\u0a10' + | '\u0a13' ..'\u0a28' + | '\u0a2a' ..'\u0a30' + | '\u0a32' ..'\u0a33' + | '\u0a35' ..'\u0a36' + | '\u0a38' ..'\u0a39' + | '\u0a59' ..'\u0a5c' + | '\u0a5e' ..'\u0a72' + | '\u0a73' ..'\u0a74' + | '\u0a85' ..'\u0a8d' + | '\u0a8f' ..'\u0a91' + | '\u0a93' ..'\u0aa8' + | '\u0aaa' ..'\u0ab0' + | '\u0ab2' ..'\u0ab3' + | '\u0ab5' ..'\u0ab9' + | '\u0abd' ..'\u0ad0' + | '\u0ae0' ..'\u0ae1' + | '\u0b05' ..'\u0b0c' + | '\u0b0f' ..'\u0b10' + | '\u0b13' ..'\u0b28' + | '\u0b2a' ..'\u0b30' + | '\u0b32' ..'\u0b33' + | '\u0b35' ..'\u0b39' + | '\u0b3d' ..'\u0b5c' + | '\u0b5d' ..'\u0b5f' + | '\u0b60' ..'\u0b61' + | '\u0b71' ..'\u0b83' + | '\u0b85' ..'\u0b8a' + | '\u0b8e' ..'\u0b90' + | '\u0b92' ..'\u0b95' + | '\u0b99' ..'\u0b9a' + | '\u0b9c' ..'\u0b9e' + | '\u0b9f' ..'\u0ba3' + | '\u0ba4' ..'\u0ba8' + | '\u0ba9' ..'\u0baa' + | '\u0bae' ..'\u0bb9' + | '\u0bd0' ..'\u0c05' + | '\u0c06' ..'\u0c0c' + | '\u0c0e' ..'\u0c10' + | '\u0c12' ..'\u0c28' + | '\u0c2a' ..'\u0c39' + | '\u0c3d' ..'\u0c58' + | '\u0c59' ..'\u0c60' + | '\u0c61' ..'\u0c85' + | '\u0c86' ..'\u0c8c' + | '\u0c8e' ..'\u0c90' + | '\u0c92' ..'\u0ca8' + | '\u0caa' ..'\u0cb3' + | '\u0cb5' ..'\u0cb9' + | '\u0cbd' ..'\u0cde' + | '\u0ce0' ..'\u0ce1' + | '\u0cf1' ..'\u0cf2' + | '\u0d05' ..'\u0d0c' + | '\u0d0e' ..'\u0d10' + | '\u0d12' ..'\u0d3a' + | '\u0d3d' ..'\u0d4e' + | '\u0d60' ..'\u0d61' + | '\u0d7a' ..'\u0d7f' + | '\u0d85' ..'\u0d96' + | '\u0d9a' ..'\u0db1' + | '\u0db3' ..'\u0dbb' + | '\u0dbd' ..'\u0dc0' + | '\u0dc1' ..'\u0dc6' + | '\u0e01' ..'\u0e30' + | '\u0e32' ..'\u0e33' + | '\u0e40' ..'\u0e45' + | '\u0e81' ..'\u0e82' + | '\u0e84' ..'\u0e87' + | '\u0e88' ..'\u0e8a' + | '\u0e8d' ..'\u0e94' + | '\u0e95' ..'\u0e97' + | '\u0e99' ..'\u0e9f' + | '\u0ea1' ..'\u0ea3' + | '\u0ea5' ..'\u0ea7' + | '\u0eaa' ..'\u0eab' + | '\u0ead' ..'\u0eb0' + | '\u0eb2' ..'\u0eb3' + | '\u0ebd' ..'\u0ec0' + | '\u0ec1' ..'\u0ec4' + | '\u0edc' ..'\u0edf' + | '\u0f00' ..'\u0f40' + | '\u0f41' ..'\u0f47' + | '\u0f49' ..'\u0f6c' + | '\u0f88' ..'\u0f8c' + | '\u1000' ..'\u102a' + | '\u103f' ..'\u1050' + | '\u1051' ..'\u1055' + | '\u105a' ..'\u105d' + | '\u1061' ..'\u1065' + | '\u1066' ..'\u106e' + | '\u106f' ..'\u1070' + | '\u1075' ..'\u1081' + | '\u108e' ..'\u10d0' + | '\u10d1' ..'\u10fa' + | '\u10fd' ..'\u1248' + | '\u124a' ..'\u124d' + | '\u1250' ..'\u1256' + | '\u1258' ..'\u125a' + | '\u125b' ..'\u125d' + | '\u1260' ..'\u1288' + | '\u128a' ..'\u128d' + | '\u1290' ..'\u12b0' + | '\u12b2' ..'\u12b5' + | '\u12b8' ..'\u12be' + | '\u12c0' ..'\u12c2' + | '\u12c3' ..'\u12c5' + | '\u12c8' ..'\u12d6' + | '\u12d8' ..'\u1310' + | '\u1312' ..'\u1315' + | '\u1318' ..'\u135a' + | '\u1380' ..'\u138f' + | '\u13a0' ..'\u13f4' + | '\u1401' ..'\u166c' + | '\u166f' ..'\u167f' + | '\u1681' ..'\u169a' + | '\u16a0' ..'\u16ea' + | '\u16f1' ..'\u16f8' + | '\u1700' ..'\u170c' + | '\u170e' ..'\u1711' + | '\u1720' ..'\u1731' + | '\u1740' ..'\u1751' + | '\u1760' ..'\u176c' + | '\u176e' ..'\u1770' + | '\u1780' ..'\u17b3' + | '\u17dc' ..'\u1820' + | '\u1821' ..'\u1842' + | '\u1844' ..'\u1877' + | '\u1880' ..'\u18a8' + | '\u18aa' ..'\u18b0' + | '\u18b1' ..'\u18f5' + | '\u1900' ..'\u191e' + | '\u1950' ..'\u196d' + | '\u1970' ..'\u1974' + | '\u1980' ..'\u19ab' + | '\u19c1' ..'\u19c7' + | '\u1a00' ..'\u1a16' + | '\u1a20' ..'\u1a54' + | '\u1b05' ..'\u1b33' + | '\u1b45' ..'\u1b4b' + | '\u1b83' ..'\u1ba0' + | '\u1bae' ..'\u1baf' + | '\u1bba' ..'\u1be5' + | '\u1c00' ..'\u1c23' + | '\u1c4d' ..'\u1c4f' + | '\u1c5a' ..'\u1c77' + | '\u1ce9' ..'\u1cec' + | '\u1cee' ..'\u1cf1' + | '\u1cf5' ..'\u1cf6' + | '\u2135' ..'\u2138' + | '\u2d30' ..'\u2d67' + | '\u2d80' ..'\u2d96' + | '\u2da0' ..'\u2da6' + | '\u2da8' ..'\u2dae' + | '\u2db0' ..'\u2db6' + | '\u2db8' ..'\u2dbe' + | '\u2dc0' ..'\u2dc6' + | '\u2dc8' ..'\u2dce' + | '\u2dd0' ..'\u2dd6' + | '\u2dd8' ..'\u2dde' + | '\u3006' ..'\u303c' + | '\u3041' ..'\u3096' + | '\u309f' ..'\u30a1' + | '\u30a2' ..'\u30fa' + | '\u30ff' ..'\u3105' + | '\u3106' ..'\u312d' + | '\u3131' ..'\u318e' + | '\u31a0' ..'\u31ba' + | '\u31f0' ..'\u31ff' + | '\u3400' ..'\u4db5' + | '\u4e00' ..'\u9fcc' + | '\ua000' ..'\ua014' + | '\ua016' ..'\ua48c' + | '\ua4d0' ..'\ua4f7' + | '\ua500' ..'\ua60b' + | '\ua610' ..'\ua61f' + | '\ua62a' ..'\ua62b' + | '\ua66e' ..'\ua6a0' + | '\ua6a1' ..'\ua6e5' + | '\ua7f7' ..'\ua7fb' + | '\ua7fc' ..'\ua801' + | '\ua803' ..'\ua805' + | '\ua807' ..'\ua80a' + | '\ua80c' ..'\ua822' + | '\ua840' ..'\ua873' + | '\ua882' ..'\ua8b3' + | '\ua8f2' ..'\ua8f7' + | '\ua8fb' ..'\ua90a' + | '\ua90b' ..'\ua925' + | '\ua930' ..'\ua946' + | '\ua960' ..'\ua97c' + | '\ua984' ..'\ua9b2' + | '\ua9e0' ..'\ua9e4' + | '\ua9e7' ..'\ua9ef' + | '\ua9fa' ..'\ua9fe' + | '\uaa00' ..'\uaa28' + | '\uaa40' ..'\uaa42' + | '\uaa44' ..'\uaa4b' + | '\uaa60' ..'\uaa6f' + | '\uaa71' ..'\uaa76' + | '\uaa7a' ..'\uaa7e' + | '\uaa7f' ..'\uaaaf' + | '\uaab1' ..'\uaab5' + | '\uaab6' ..'\uaab9' + | '\uaaba' ..'\uaabd' + | '\uaac0' ..'\uaac2' + | '\uaadb' ..'\uaadc' + | '\uaae0' ..'\uaaea' + | '\uaaf2' ..'\uab01' + | '\uab02' ..'\uab06' + | '\uab09' ..'\uab0e' + | '\uab11' ..'\uab16' + | '\uab20' ..'\uab26' + | '\uab28' ..'\uab2e' + | '\uabc0' ..'\uabe2' + | '\uac00' ..'\ud7a3' + | '\ud7b0' ..'\ud7c6' + | '\ud7cb' ..'\ud7fb' + | '\uf900' ..'\ufa6d' + | '\ufa70' ..'\ufad9' + | '\ufb1d' ..'\ufb1f' + | '\ufb20' ..'\ufb28' + | '\ufb2a' ..'\ufb36' + | '\ufb38' ..'\ufb3c' + | '\ufb3e' ..'\ufb40' + | '\ufb41' ..'\ufb43' + | '\ufb44' ..'\ufb46' + | '\ufb47' ..'\ufbb1' + | '\ufbd3' ..'\ufd3d' + | '\ufd50' ..'\ufd8f' + | '\ufd92' ..'\ufdc7' + | '\ufdf0' ..'\ufdfb' + | '\ufe70' ..'\ufe74' + | '\ufe76' ..'\ufefc' + | '\uff66' ..'\uff6f' + | '\uff71' ..'\uff9d' + | '\uffa0' ..'\uffbe' + | '\uffc2' ..'\uffc7' + | '\uffca' ..'\uffcf' + | '\uffd2' ..'\uffd7' + | '\uffda' ..'\uffdc' +; + +fragment UnicodeClassNL: + '\u16EE' // RUNIC ARLAUG SYMBOL + | '\u16EF' // RUNIC TVIMADUR SYMBOL + | '\u16F0' // RUNIC BELGTHOR SYMBOL + | '\u2160' // ROMAN NUMERAL ONE + | '\u2161' // ROMAN NUMERAL TWO + | '\u2162' // ROMAN NUMERAL THREE + | '\u2163' // ROMAN NUMERAL FOUR + | '\u2164' // ROMAN NUMERAL FIVE + | '\u2165' // ROMAN NUMERAL SIX + | '\u2166' // ROMAN NUMERAL SEVEN + | '\u2167' // ROMAN NUMERAL EIGHT + | '\u2168' // ROMAN NUMERAL NINE + | '\u2169' // ROMAN NUMERAL TEN + | '\u216A' // ROMAN NUMERAL ELEVEN + | '\u216B' // ROMAN NUMERAL TWELVE + | '\u216C' // ROMAN NUMERAL FIFTY + | '\u216D' // ROMAN NUMERAL ONE HUNDRED + | '\u216E' // ROMAN NUMERAL FIVE HUNDRED + | '\u216F' // ROMAN NUMERAL ONE THOUSAND +; + +fragment UnicodeClassMN: + '\u0300' // COMBINING GRAVE ACCENT + | '\u0301' // COMBINING ACUTE ACCENT + | '\u0302' // COMBINING CIRCUMFLEX ACCENT + | '\u0303' // COMBINING TILDE + | '\u0304' // COMBINING MACRON + | '\u0305' // COMBINING OVERLINE + | '\u0306' // COMBINING BREVE + | '\u0307' // COMBINING DOT ABOVE + | '\u0308' // COMBINING DIAERESIS + | '\u0309' // COMBINING HOOK ABOVE + | '\u030A' // COMBINING RING ABOVE + | '\u030B' // COMBINING DOUBLE ACUTE ACCENT + | '\u030C' // COMBINING CARON + | '\u030D' // COMBINING VERTICAL LINE ABOVE + | '\u030E' // COMBINING DOUBLE VERTICAL LINE ABOVE + | '\u030F' // COMBINING DOUBLE GRAVE ACCENT + | '\u0310' // COMBINING CANDRABINDU +; + +fragment UnicodeClassMC: + '\u0903' // DEVANAGARI SIGN VISARGA + | '\u093E' // DEVANAGARI VOWEL SIGN AA + | '\u093F' // DEVANAGARI VOWEL SIGN I + | '\u0940' // DEVANAGARI VOWEL SIGN II + | '\u0949' // DEVANAGARI VOWEL SIGN CANDRA O + | '\u094A' // DEVANAGARI VOWEL SIGN SHORT O + | '\u094B' // DEVANAGARI VOWEL SIGN O + | '\u094C' // DEVANAGARI VOWEL SIGN AU +; + +fragment UnicodeClassCF: + '\u00AD' // SOFT HYPHEN + | '\u0600' // ARABIC NUMBER SIGN + | '\u0601' // ARABIC SIGN SANAH + | '\u0602' // ARABIC FOOTNOTE MARKER + | '\u0603' // ARABIC SIGN SAFHA + | '\u06DD' // ARABIC END OF AYAH +; + +fragment UnicodeClassPC: + '\u005F' // LOW LINE + | '\u203F' // UNDERTIE + | '\u2040' // CHARACTER TIE + | '\u2054' // INVERTED UNDERTIE + | '\uFE33' // PRESENTATION FORM FOR VERTICAL LOW LINE + | '\uFE34' // PRESENTATION FORM FOR VERTICAL WAVY LOW LINE + | '\uFE4D' // DASHED LOW LINE + | '\uFE4E' // CENTRELINE LOW LINE + | '\uFE4F' // WAVY LOW LINE + | '\uFF3F' // FULLWIDTH LOW LINE +; + +fragment UnicodeClassND: + '\u0030' ..'\u0039' + | '\u0660' ..'\u0669' + | '\u06f0' ..'\u06f9' + | '\u07c0' ..'\u07c9' + | '\u0966' ..'\u096f' + | '\u09e6' ..'\u09ef' + | '\u0a66' ..'\u0a6f' + | '\u0ae6' ..'\u0aef' + | '\u0b66' ..'\u0b6f' + | '\u0be6' ..'\u0bef' + | '\u0c66' ..'\u0c6f' + | '\u0ce6' ..'\u0cef' + | '\u0d66' ..'\u0d6f' + | '\u0de6' ..'\u0def' + | '\u0e50' ..'\u0e59' + | '\u0ed0' ..'\u0ed9' + | '\u0f20' ..'\u0f29' + | '\u1040' ..'\u1049' + | '\u1090' ..'\u1099' + | '\u17e0' ..'\u17e9' + | '\u1810' ..'\u1819' + | '\u1946' ..'\u194f' + | '\u19d0' ..'\u19d9' + | '\u1a80' ..'\u1a89' + | '\u1a90' ..'\u1a99' + | '\u1b50' ..'\u1b59' + | '\u1bb0' ..'\u1bb9' + | '\u1c40' ..'\u1c49' + | '\u1c50' ..'\u1c59' + | '\ua620' ..'\ua629' + | '\ua8d0' ..'\ua8d9' + | '\ua900' ..'\ua909' + | '\ua9d0' ..'\ua9d9' + | '\ua9f0' ..'\ua9f9' + | '\uaa50' ..'\uaa59' + | '\uabf0' ..'\uabf9' + | '\uff10' ..'\uff19' +; \ No newline at end of file diff --git a/_tests/grammars-v4/csharp/CSharpParser.g4 b/_tests/grammars-v4/csharp/CSharpParser.g4 new file mode 100644 index 000000000..ec37fb295 --- /dev/null +++ b/_tests/grammars-v4/csharp/CSharpParser.g4 @@ -0,0 +1,1309 @@ +// Eclipse Public License - v 1.0, http://www.eclipse.org/legal/epl-v10.html +// Copyright (c) 2013, Christian Wulf (chwchw@gmx.de) +// Copyright (c) 2016-2017, Ivan Kochurkin (kvanttt@gmail.com), Positive Technologies. + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + +parser grammar CSharpParser; + +options { + tokenVocab = CSharpLexer; + superClass = CSharpParserBase; +} + +// entry point +compilation_unit + : BYTE_ORDER_MARK? extern_alias_directives? using_directives? global_attribute_section* namespace_member_declarations? EOF + ; + +//B.2 Syntactic grammar + +//B.2.1 Basic concepts + +namespace_or_type_name + : (identifier type_argument_list? | qualified_alias_member) ( + '.' identifier type_argument_list? + )* + ; + +//B.2.2 Types +type_ + : base_type ('?' | rank_specifier | '*')* + ; + +base_type + : simple_type + | class_type // represents types: enum, class, interface, delegate, type_parameter + | VOID '*' + | tuple_type + ; + +tuple_type + : '(' tuple_element (',' tuple_element)+ ')' + ; + +tuple_element + : type_ identifier? + ; + +simple_type + : numeric_type + | BOOL + ; + +numeric_type + : integral_type + | floating_point_type + | DECIMAL + ; + +integral_type + : SBYTE + | BYTE + | SHORT + | USHORT + | INT + | UINT + | LONG + | ULONG + | CHAR + ; + +floating_point_type + : FLOAT + | DOUBLE + ; + +/** namespace_or_type_name, OBJECT, STRING */ +class_type + : namespace_or_type_name + | OBJECT + | DYNAMIC + | STRING + ; + +type_argument_list + : '<' type_ (',' type_)* '>' + ; + +//B.2.4 Expressions +argument_list + : argument (',' argument)* + ; + +argument + : (identifier ':')? refout = (REF | OUT | IN)? (expression | (VAR | type_) expression) + ; + +expression + : assignment + | non_assignment_expression + | REF non_assignment_expression + ; + +non_assignment_expression + : lambda_expression + | query_expression + | conditional_expression + ; + +assignment + : unary_expression assignment_operator expression + | unary_expression '??=' throwable_expression + ; + +assignment_operator + : '=' + | '+=' + | '-=' + | '*=' + | '/=' + | '%=' + | '&=' + | '|=' + | '^=' + | '<<=' + | right_shift_assignment + ; + +conditional_expression + : null_coalescing_expression ('?' throwable_expression ':' throwable_expression)? + ; + +null_coalescing_expression + : conditional_or_expression ('??' (null_coalescing_expression | throw_expression))? + ; + +conditional_or_expression + : conditional_and_expression (OP_OR conditional_and_expression)* + ; + +conditional_and_expression + : inclusive_or_expression (OP_AND inclusive_or_expression)* + ; + +inclusive_or_expression + : exclusive_or_expression ('|' exclusive_or_expression)* + ; + +exclusive_or_expression + : and_expression ('^' and_expression)* + ; + +and_expression + : equality_expression ('&' equality_expression)* + ; + +equality_expression + : relational_expression ((OP_EQ | OP_NE) relational_expression)* + ; + +relational_expression + : shift_expression (('<' | '>' | '<=' | '>=') shift_expression | IS isType | AS type_)* + ; + +shift_expression + : additive_expression (('<<' | right_shift) additive_expression)* + ; + +additive_expression + : multiplicative_expression (('+' | '-') multiplicative_expression)* + ; + +multiplicative_expression + : switch_expression (('*' | '/' | '%') switch_expression)* + ; + +switch_expression + : range_expression ('switch' '{' (switch_expression_arms ','?)? '}')? + ; + +switch_expression_arms + : switch_expression_arm (',' switch_expression_arm)* + ; + +switch_expression_arm + : expression case_guard? right_arrow throwable_expression + ; + +range_expression + : unary_expression + | unary_expression? OP_RANGE unary_expression? + ; + +// https://msdn.microsoft.com/library/6a71f45d(v=vs.110).aspx +unary_expression + : cast_expression + | primary_expression + | '+' unary_expression + | '-' unary_expression + | BANG unary_expression + | '~' unary_expression + | '++' unary_expression + | '--' unary_expression + | AWAIT unary_expression // C# 5 + | '&' unary_expression + | '*' unary_expression + | '^' unary_expression // C# 8 ranges + ; + +cast_expression + : OPEN_PARENS type_ CLOSE_PARENS unary_expression + ; + +primary_expression // Null-conditional operators C# 6: https://msdn.microsoft.com/en-us/library/dn986595.aspx + : pe = primary_expression_start '!'? bracket_expression* '!'? ( + (member_access | method_invocation | '++' | '--' | '->' identifier) '!'? bracket_expression* '!'? + )* + ; + +primary_expression_start + : literal # literalExpression + | identifier type_argument_list? # simpleNameExpression + | OPEN_PARENS expression CLOSE_PARENS # parenthesisExpressions + | predefined_type # memberAccessExpression + | qualified_alias_member # memberAccessExpression + | LITERAL_ACCESS # literalAccessExpression + | THIS # thisReferenceExpression + | BASE ('.' identifier type_argument_list? | '[' expression_list ']') # baseAccessExpression + | NEW ( + type_ ( + object_creation_expression + | object_or_collection_initializer + | '[' expression_list ']' rank_specifier* array_initializer? + | rank_specifier+ array_initializer + ) + | anonymous_object_initializer + | rank_specifier array_initializer + ) # objectCreationExpression + | OPEN_PARENS argument ( ',' argument)+ CLOSE_PARENS # tupleExpression + | TYPEOF OPEN_PARENS (unbound_type_name | type_ | VOID) CLOSE_PARENS # typeofExpression + | CHECKED OPEN_PARENS expression CLOSE_PARENS # checkedExpression + | UNCHECKED OPEN_PARENS expression CLOSE_PARENS # uncheckedExpression + | DEFAULT (OPEN_PARENS type_ CLOSE_PARENS)? # defaultValueExpression + | ASYNC? DELEGATE (OPEN_PARENS explicit_anonymous_function_parameter_list? CLOSE_PARENS)? block # anonymousMethodExpression + | SIZEOF OPEN_PARENS type_ CLOSE_PARENS # sizeofExpression + // C# 6: https://msdn.microsoft.com/en-us/library/dn986596.aspx + | NAMEOF OPEN_PARENS (identifier '.')* identifier CLOSE_PARENS # nameofExpression + ; + +throwable_expression + : expression + | throw_expression + ; + +throw_expression + : THROW expression + ; + +member_access + : '?'? '.' identifier type_argument_list? + ; + +bracket_expression + : '?'? '[' indexer_argument (',' indexer_argument)* ']' + ; + +indexer_argument + : (identifier ':')? expression + ; + +predefined_type + : BOOL + | BYTE + | CHAR + | DECIMAL + | DOUBLE + | FLOAT + | INT + | LONG + | OBJECT + | SBYTE + | SHORT + | STRING + | UINT + | ULONG + | USHORT + ; + +expression_list + : expression (',' expression)* + ; + +object_or_collection_initializer + : object_initializer + | collection_initializer + ; + +object_initializer + : OPEN_BRACE (member_initializer_list ','?)? CLOSE_BRACE + ; + +member_initializer_list + : member_initializer (',' member_initializer)* + ; + +member_initializer + : (identifier | '[' expression ']') '=' initializer_value // C# 6 + ; + +initializer_value + : expression + | object_or_collection_initializer + ; + +collection_initializer + : OPEN_BRACE element_initializer (',' element_initializer)* ','? CLOSE_BRACE + ; + +element_initializer + : non_assignment_expression + | OPEN_BRACE expression_list CLOSE_BRACE + ; + +anonymous_object_initializer + : OPEN_BRACE (member_declarator_list ','?)? CLOSE_BRACE + ; + +member_declarator_list + : member_declarator (',' member_declarator)* + ; + +member_declarator + : primary_expression + | identifier '=' expression + ; + +unbound_type_name + : identifier (generic_dimension_specifier? | '::' identifier generic_dimension_specifier?) ( + '.' identifier generic_dimension_specifier? + )* + ; + +generic_dimension_specifier + : '<' ','* '>' + ; + +isType + : base_type (rank_specifier | '*')* '?'? isTypePatternArms? identifier? + ; + +isTypePatternArms + : '{' isTypePatternArm (',' isTypePatternArm)* '}' + ; + +isTypePatternArm + : identifier ':' expression + ; + +lambda_expression + : ASYNC? anonymous_function_signature right_arrow anonymous_function_body + ; + +anonymous_function_signature + : OPEN_PARENS CLOSE_PARENS + | OPEN_PARENS explicit_anonymous_function_parameter_list CLOSE_PARENS + | OPEN_PARENS implicit_anonymous_function_parameter_list CLOSE_PARENS + | identifier + ; + +explicit_anonymous_function_parameter_list + : explicit_anonymous_function_parameter (',' explicit_anonymous_function_parameter)* + ; + +explicit_anonymous_function_parameter + : refout = (REF | OUT | IN)? type_ identifier + ; + +implicit_anonymous_function_parameter_list + : identifier (',' identifier)* + ; + +anonymous_function_body + : throwable_expression + | block + ; + +query_expression + : from_clause query_body + ; + +from_clause + : FROM type_? identifier IN expression + ; + +query_body + : query_body_clause* select_or_group_clause query_continuation? + ; + +query_body_clause + : from_clause + | let_clause + | where_clause + | combined_join_clause + | orderby_clause + ; + +let_clause + : LET identifier '=' expression + ; + +where_clause + : WHERE expression + ; + +combined_join_clause + : JOIN type_? identifier IN expression ON expression EQUALS expression (INTO identifier)? + ; + +orderby_clause + : ORDERBY ordering (',' ordering)* + ; + +ordering + : expression dir = (ASCENDING | DESCENDING)? + ; + +select_or_group_clause + : SELECT expression + | GROUP expression BY expression + ; + +query_continuation + : INTO identifier query_body + ; + +//B.2.5 Statements +statement + : labeled_Statement + | declarationStatement + | embedded_statement + ; + +declarationStatement + : local_variable_declaration ';' + | local_constant_declaration ';' + | local_function_declaration + ; + +local_function_declaration + : local_function_header local_function_body + ; + +local_function_header + : local_function_modifiers? return_type identifier type_parameter_list? OPEN_PARENS formal_parameter_list? CLOSE_PARENS + type_parameter_constraints_clauses? + ; + +local_function_modifiers + : (ASYNC | UNSAFE) STATIC? + | STATIC (ASYNC | UNSAFE) + ; + +local_function_body + : block + | right_arrow throwable_expression ';' + ; + +labeled_Statement + : identifier ':' statement + ; + +embedded_statement + : block + | simple_embedded_statement + ; + +simple_embedded_statement + : ';' # theEmptyStatement + | expression ';' # expressionStatement + + // selection statements + | IF OPEN_PARENS expression CLOSE_PARENS if_body (ELSE if_body)? # ifStatement + | SWITCH OPEN_PARENS expression CLOSE_PARENS OPEN_BRACE switch_section* CLOSE_BRACE # switchStatement + + // iteration statements + | WHILE OPEN_PARENS expression CLOSE_PARENS embedded_statement # whileStatement + | DO embedded_statement WHILE OPEN_PARENS expression CLOSE_PARENS ';' # doStatement + | FOR OPEN_PARENS for_initializer? ';' expression? ';' for_iterator? CLOSE_PARENS embedded_statement # forStatement + | AWAIT? FOREACH OPEN_PARENS local_variable_type identifier IN expression CLOSE_PARENS embedded_statement # foreachStatement + + // jump statements + | BREAK ';' # breakStatement + | CONTINUE ';' # continueStatement + | GOTO (identifier | CASE expression | DEFAULT) ';' # gotoStatement + | RETURN expression? ';' # returnStatement + | THROW expression? ';' # throwStatement + | TRY block (catch_clauses finally_clause? | finally_clause) # tryStatement + | CHECKED block # checkedStatement + | UNCHECKED block # uncheckedStatement + | LOCK OPEN_PARENS expression CLOSE_PARENS embedded_statement # lockStatement + | USING OPEN_PARENS resource_acquisition CLOSE_PARENS embedded_statement # usingStatement + | YIELD (RETURN expression | BREAK) ';' # yieldStatement + + // unsafe statements + | UNSAFE block # unsafeStatement + | FIXED OPEN_PARENS pointer_type fixed_pointer_declarators CLOSE_PARENS embedded_statement # fixedStatement + ; + +block + : OPEN_BRACE statement_list? CLOSE_BRACE + ; + +local_variable_declaration + : (USING | REF | REF READONLY)? local_variable_type local_variable_declarator ( + ',' local_variable_declarator { this.IsLocalVariableDeclaration() }? + )* + | FIXED pointer_type fixed_pointer_declarators + ; + +local_variable_type + : VAR + | type_ + ; + +local_variable_declarator + : identifier ('=' REF? local_variable_initializer)? + ; + +local_variable_initializer + : expression + | array_initializer + | stackalloc_initializer + ; + +local_constant_declaration + : CONST type_ constant_declarators + ; + +if_body + : block + | simple_embedded_statement + ; + +switch_section + : switch_label+ statement_list + ; + +switch_label + : CASE expression case_guard? ':' + | DEFAULT ':' + ; + +case_guard + : WHEN expression + ; + +statement_list + : statement+ + ; + +for_initializer + : local_variable_declaration + | expression (',' expression)* + ; + +for_iterator + : expression (',' expression)* + ; + +catch_clauses + : specific_catch_clause specific_catch_clause* general_catch_clause? + | general_catch_clause + ; + +specific_catch_clause + : CATCH OPEN_PARENS class_type identifier? CLOSE_PARENS exception_filter? block + ; + +general_catch_clause + : CATCH exception_filter? block + ; + +exception_filter // C# 6 + : WHEN OPEN_PARENS expression CLOSE_PARENS + ; + +finally_clause + : FINALLY block + ; + +resource_acquisition + : local_variable_declaration + | expression + ; + +//B.2.6 Namespaces; +namespace_declaration + : NAMESPACE qi = qualified_identifier namespace_body ';'? + ; + +qualified_identifier + : identifier ('.' identifier)* + ; + +namespace_body + : OPEN_BRACE extern_alias_directives? using_directives? namespace_member_declarations? CLOSE_BRACE + ; + +extern_alias_directives + : extern_alias_directive+ + ; + +extern_alias_directive + : EXTERN ALIAS identifier ';' + ; + +using_directives + : using_directive+ + ; + +using_directive + : USING identifier '=' namespace_or_type_name ';' # usingAliasDirective + | USING namespace_or_type_name ';' # usingNamespaceDirective + // C# 6: https://msdn.microsoft.com/en-us/library/ms228593.aspx + | USING STATIC namespace_or_type_name ';' # usingStaticDirective + ; + +namespace_member_declarations + : namespace_member_declaration+ + ; + +namespace_member_declaration + : namespace_declaration + | type_declaration + ; + +type_declaration + : attributes? all_member_modifiers? ( + class_definition + | struct_definition + | interface_definition + | enum_definition + | delegate_definition + ) + ; + +qualified_alias_member + : identifier '::' identifier type_argument_list? + ; + +//B.2.7 Classes; +type_parameter_list + : '<' type_parameter (',' type_parameter)* '>' + ; + +type_parameter + : attributes? identifier + ; + +class_base + : ':' class_type (',' namespace_or_type_name)* + ; + +interface_type_list + : namespace_or_type_name (',' namespace_or_type_name)* + ; + +type_parameter_constraints_clauses + : type_parameter_constraints_clause+ + ; + +type_parameter_constraints_clause + : WHERE identifier ':' type_parameter_constraints + ; + +type_parameter_constraints + : constructor_constraint + | primary_constraint (',' secondary_constraints)? (',' constructor_constraint)? + ; + +primary_constraint + : class_type + | CLASS '?'? + | STRUCT + | UNMANAGED + ; + +// namespace_or_type_name includes identifier +secondary_constraints + : namespace_or_type_name (',' namespace_or_type_name)* + ; + +constructor_constraint + : NEW OPEN_PARENS CLOSE_PARENS + ; + +class_body + : OPEN_BRACE class_member_declarations? CLOSE_BRACE + ; + +class_member_declarations + : class_member_declaration+ + ; + +class_member_declaration + : attributes? all_member_modifiers? (common_member_declaration | destructor_definition) + ; + +all_member_modifiers + : all_member_modifier+ + ; + +all_member_modifier + : NEW + | PUBLIC + | PROTECTED + | INTERNAL + | PRIVATE + | READONLY + | VOLATILE + | VIRTUAL + | SEALED + | OVERRIDE + | ABSTRACT + | STATIC + | UNSAFE + | EXTERN + | PARTIAL + | ASYNC // C# 5 + ; + +// represents the intersection of struct_member_declaration and class_member_declaration +common_member_declaration + : constant_declaration + | typed_member_declaration + | event_declaration + | conversion_operator_declarator (body | right_arrow throwable_expression ';') // C# 6 + | constructor_declaration + | VOID method_declaration + | class_definition + | struct_definition + | interface_definition + | enum_definition + | delegate_definition + ; + +typed_member_declaration + : (REF | READONLY REF | REF READONLY)? type_ ( + namespace_or_type_name '.' indexer_declaration + | method_declaration + | property_declaration + | indexer_declaration + | operator_declaration + | field_declaration + ) + ; + +constant_declarators + : constant_declarator (',' constant_declarator)* + ; + +constant_declarator + : identifier '=' expression + ; + +variable_declarators + : variable_declarator (',' variable_declarator)* + ; + +variable_declarator + : identifier ('=' variable_initializer)? + ; + +variable_initializer + : expression + | array_initializer + ; + +return_type + : type_ + | VOID + ; + +member_name + : namespace_or_type_name + ; + +method_body + : block + | ';' + ; + +formal_parameter_list + : parameter_array + | fixed_parameters (',' parameter_array)? + ; + +fixed_parameters + : fixed_parameter (',' fixed_parameter)* + ; + +fixed_parameter + : attributes? parameter_modifier? arg_declaration + | ARGLIST + ; + +parameter_modifier + : REF + | OUT + | IN + | REF THIS + | IN THIS + | THIS + ; + +parameter_array + : attributes? PARAMS array_type identifier + ; + +accessor_declarations + : attrs = attributes? mods = accessor_modifier? ( + GET accessor_body set_accessor_declaration? + | SET accessor_body get_accessor_declaration? + ) + ; + +get_accessor_declaration + : attributes? accessor_modifier? GET accessor_body + ; + +set_accessor_declaration + : attributes? accessor_modifier? SET accessor_body + ; + +accessor_modifier + : PROTECTED + | INTERNAL + | PRIVATE + | PROTECTED INTERNAL + | INTERNAL PROTECTED + ; + +accessor_body + : block + | ';' + ; + +event_accessor_declarations + : attributes? (ADD block remove_accessor_declaration | REMOVE block add_accessor_declaration) + ; + +add_accessor_declaration + : attributes? ADD block + ; + +remove_accessor_declaration + : attributes? REMOVE block + ; + +overloadable_operator + : '+' + | '-' + | BANG + | '~' + | '++' + | '--' + | TRUE + | FALSE + | '*' + | '/' + | '%' + | '&' + | '|' + | '^' + | '<<' + | right_shift + | OP_EQ + | OP_NE + | '>' + | '<' + | '>=' + | '<=' + ; + +conversion_operator_declarator + : (IMPLICIT | EXPLICIT) OPERATOR type_ OPEN_PARENS arg_declaration CLOSE_PARENS + ; + +constructor_initializer + : ':' (BASE | THIS) OPEN_PARENS argument_list? CLOSE_PARENS + ; + +body + : block + | ';' + ; + +//B.2.8 Structs +struct_interfaces + : ':' interface_type_list + ; + +struct_body + : OPEN_BRACE struct_member_declaration* CLOSE_BRACE + ; + +struct_member_declaration + : attributes? all_member_modifiers? ( + common_member_declaration + | FIXED type_ fixed_size_buffer_declarator+ ';' + ) + ; + +//B.2.9 Arrays +array_type + : base_type (('*' | '?')* rank_specifier)+ + ; + +rank_specifier + : '[' ','* ']' + ; + +array_initializer + : OPEN_BRACE (variable_initializer (',' variable_initializer)* ','?)? CLOSE_BRACE + ; + +//B.2.10 Interfaces +variant_type_parameter_list + : '<' variant_type_parameter (',' variant_type_parameter)* '>' + ; + +variant_type_parameter + : attributes? variance_annotation? identifier + ; + +variance_annotation + : IN + | OUT + ; + +interface_base + : ':' interface_type_list + ; + +interface_body // ignored in csharp 8 + : OPEN_BRACE interface_member_declaration* CLOSE_BRACE + ; + +interface_member_declaration + : attributes? NEW? ( + UNSAFE? (REF | REF READONLY | READONLY REF)? type_ ( + identifier type_parameter_list? OPEN_PARENS formal_parameter_list? CLOSE_PARENS type_parameter_constraints_clauses? ';' + | identifier OPEN_BRACE interface_accessors CLOSE_BRACE + | THIS '[' formal_parameter_list ']' OPEN_BRACE interface_accessors CLOSE_BRACE + ) + | UNSAFE? VOID identifier type_parameter_list? OPEN_PARENS formal_parameter_list? CLOSE_PARENS type_parameter_constraints_clauses? ';' + | EVENT type_ identifier ';' + ) + ; + +interface_accessors + : attributes? (GET ';' (attributes? SET ';')? | SET ';' (attributes? GET ';')?) + ; + +//B.2.11 Enums +enum_base + : ':' type_ + ; + +enum_body + : OPEN_BRACE (enum_member_declaration (',' enum_member_declaration)* ','?)? CLOSE_BRACE + ; + +enum_member_declaration + : attributes? identifier ('=' expression)? + ; + +//B.2.12 Delegates + +//B.2.13 Attributes +global_attribute_section + : '[' global_attribute_target ':' attribute_list ','? ']' + ; + +global_attribute_target + : keyword + | identifier + ; + +attributes + : attribute_section+ + ; + +attribute_section + : '[' (attribute_target ':')? attribute_list ','? ']' + ; + +attribute_target + : keyword + | identifier + ; + +attribute_list + : attribute (',' attribute)* + ; + +attribute + : namespace_or_type_name ( + OPEN_PARENS (attribute_argument (',' attribute_argument)*)? CLOSE_PARENS + )? + ; + +attribute_argument + : (identifier ':')? expression + ; + +//B.3 Grammar extensions for unsafe code +pointer_type + : (simple_type | class_type) (rank_specifier | '?')* '*' + | VOID '*' + ; + +fixed_pointer_declarators + : fixed_pointer_declarator (',' fixed_pointer_declarator)* + ; + +fixed_pointer_declarator + : identifier '=' fixed_pointer_initializer + ; + +fixed_pointer_initializer + : '&'? expression + | stackalloc_initializer + ; + +fixed_size_buffer_declarator + : identifier '[' expression ']' + ; + +stackalloc_initializer + : STACKALLOC type_ '[' expression ']' + | STACKALLOC type_? '[' expression? ']' OPEN_BRACE expression (',' expression)* ','? CLOSE_BRACE + ; + +right_arrow + : first = '=' second = '>' {$first.index + 1 == $second.index}? // Nothing between the tokens? + ; + +right_shift + : first = '>' second = '>' {$first.index + 1 == $second.index}? // Nothing between the tokens? + ; + +right_shift_assignment + : first = '>' second = '>=' {$first.index + 1 == $second.index}? // Nothing between the tokens? + ; + +literal + : boolean_literal + | string_literal + | INTEGER_LITERAL + | HEX_INTEGER_LITERAL + | BIN_INTEGER_LITERAL + | REAL_LITERAL + | CHARACTER_LITERAL + | NULL_ + ; + +boolean_literal + : TRUE + | FALSE + ; + +string_literal + : interpolated_regular_string + | interpolated_verbatium_string + | REGULAR_STRING + | VERBATIUM_STRING + ; + +interpolated_regular_string + : INTERPOLATED_REGULAR_STRING_START interpolated_regular_string_part* DOUBLE_QUOTE_INSIDE + ; + +interpolated_verbatium_string + : INTERPOLATED_VERBATIUM_STRING_START interpolated_verbatium_string_part* DOUBLE_QUOTE_INSIDE + ; + +interpolated_regular_string_part + : interpolated_string_expression + | DOUBLE_CURLY_INSIDE + | REGULAR_CHAR_INSIDE + | REGULAR_STRING_INSIDE + ; + +interpolated_verbatium_string_part + : interpolated_string_expression + | DOUBLE_CURLY_INSIDE + | VERBATIUM_DOUBLE_QUOTE_INSIDE + | VERBATIUM_INSIDE_STRING + ; + +interpolated_string_expression + : expression (',' expression)* (':' FORMAT_STRING+)? + ; + +//B.1.7 Keywords +keyword + : ABSTRACT + | AS + | BASE + | BOOL + | BREAK + | BYTE + | CASE + | CATCH + | CHAR + | CHECKED + | CLASS + | CONST + | CONTINUE + | DECIMAL + | DEFAULT + | DELEGATE + | DO + | DOUBLE + | ELSE + | ENUM + | EVENT + | EXPLICIT + | EXTERN + | FALSE + | FINALLY + | FIXED + | FLOAT + | FOR + | FOREACH + | GOTO + | IF + | IMPLICIT + | IN + | INT + | INTERFACE + | INTERNAL + | IS + | LOCK + | LONG + | NAMESPACE + | NEW + | NULL_ + | OBJECT + | OPERATOR + | OUT + | OVERRIDE + | PARAMS + | PRIVATE + | PROTECTED + | PUBLIC + | READONLY + | REF + | RETURN + | SBYTE + | SEALED + | SHORT + | SIZEOF + | STACKALLOC + | STATIC + | STRING + | STRUCT + | SWITCH + | THIS + | THROW + | TRUE + | TRY + | TYPEOF + | UINT + | ULONG + | UNCHECKED + | UNMANAGED + | UNSAFE + | USHORT + | USING + | VIRTUAL + | VOID + | VOLATILE + | WHILE + ; + +// -------------------- extra rules for modularization -------------------------------- + +class_definition + : CLASS identifier type_parameter_list? class_base? type_parameter_constraints_clauses? class_body ';'? + ; + +struct_definition + : (READONLY | REF)? STRUCT identifier type_parameter_list? struct_interfaces? type_parameter_constraints_clauses? struct_body ';'? + ; + +interface_definition + : INTERFACE identifier variant_type_parameter_list? interface_base? type_parameter_constraints_clauses? class_body ';'? + ; + +enum_definition + : ENUM identifier enum_base? enum_body ';'? + ; + +delegate_definition + : DELEGATE return_type identifier variant_type_parameter_list? OPEN_PARENS formal_parameter_list? CLOSE_PARENS type_parameter_constraints_clauses? + ';' + ; + +event_declaration + : EVENT type_ ( + variable_declarators ';' + | member_name OPEN_BRACE event_accessor_declarations CLOSE_BRACE + ) + ; + +field_declaration + : variable_declarators ';' + ; + +property_declaration // Property initializer & lambda in properties C# 6 + : member_name ( + OPEN_BRACE accessor_declarations CLOSE_BRACE ('=' variable_initializer ';')? + | right_arrow throwable_expression ';' + ) + ; + +constant_declaration + : CONST type_ constant_declarators ';' + ; + +indexer_declaration // lamdas from C# 6 + : THIS '[' formal_parameter_list ']' ( + OPEN_BRACE accessor_declarations CLOSE_BRACE + | right_arrow throwable_expression ';' + ) + ; + +destructor_definition + : '~' identifier OPEN_PARENS CLOSE_PARENS body + ; + +constructor_declaration + : identifier OPEN_PARENS formal_parameter_list? CLOSE_PARENS constructor_initializer? body + ; + +method_declaration // lamdas from C# 6 + : method_member_name type_parameter_list? OPEN_PARENS formal_parameter_list? CLOSE_PARENS type_parameter_constraints_clauses? ( + method_body + | right_arrow throwable_expression ';' + ) + ; + +method_member_name + : (identifier | identifier '::' identifier) (type_argument_list? '.' identifier)* + ; + +operator_declaration // lamdas form C# 6 + : OPERATOR overloadable_operator OPEN_PARENS IN? arg_declaration (',' IN? arg_declaration)? CLOSE_PARENS ( + body + | right_arrow throwable_expression ';' + ) + ; + +arg_declaration + : type_ identifier ('=' expression)? + ; + +method_invocation + : OPEN_PARENS argument_list? CLOSE_PARENS + ; + +object_creation_expression + : OPEN_PARENS argument_list? CLOSE_PARENS object_or_collection_initializer? + ; + +identifier + : IDENTIFIER + | ADD + | ALIAS + | ARGLIST + | ASCENDING + | ASYNC + | AWAIT + | BY + | DESCENDING + | DYNAMIC + | EQUALS + | FROM + | GET + | GROUP + | INTO + | JOIN + | LET + | NAMEOF + | ON + | ORDERBY + | PARTIAL + | REMOVE + | SELECT + | SET + | UNMANAGED + | VAR + | WHEN + | WHERE + | YIELD + ; \ No newline at end of file diff --git a/_tests/grammars-v4/csharp/CSharpPreprocessorParser.g4 b/_tests/grammars-v4/csharp/CSharpPreprocessorParser.g4 new file mode 100644 index 000000000..1127f2b11 --- /dev/null +++ b/_tests/grammars-v4/csharp/CSharpPreprocessorParser.g4 @@ -0,0 +1,48 @@ +// Eclipse Public License - v 1.0, http://www.eclipse.org/legal/epl-v10.html +// Copyright (c) 2013, Christian Wulf (chwchw@gmx.de) +// Copyright (c) 2016-2017, Ivan Kochurkin (kvanttt@gmail.com), Positive Technologies. + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + +parser grammar CSharpPreprocessorParser; + +options { + tokenVocab = CSharpLexer; + superClass = CSharpPreprocessorParserBase; +} + +preprocessor_directive + returns[Boolean value] + : DEFINE CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.OnPreprocessorDirectiveDefine(); } # preprocessorDeclaration + | UNDEF CONDITIONAL_SYMBOL directive_new_line_or_sharp { this.OnPreprocessorDirectiveUndef(); } # preprocessorDeclaration + | IF expr = preprocessor_expression directive_new_line_or_sharp { this.OnPreprocessorDirectiveIf(); } # preprocessorConditional + | ELIF expr = preprocessor_expression directive_new_line_or_sharp { this.OnPreprocessorDirectiveElif(); } # preprocessorConditional + | ELSE directive_new_line_or_sharp { this.OnPreprocessorDirectiveElse(); } # preprocessorConditional + | ENDIF directive_new_line_or_sharp { this.OnPreprocessorDirectiveEndif(); } # preprocessorConditional + | LINE (DIGITS STRING? | DEFAULT | DIRECTIVE_HIDDEN) directive_new_line_or_sharp { this.OnPreprocessorDirectiveLine(); } # preprocessorLine + | ERROR TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveError(); } # preprocessorDiagnostic + | WARNING TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveWarning(); } # preprocessorDiagnostic + | REGION TEXT? directive_new_line_or_sharp { this.OnPreprocessorDirectiveRegion(); } # preprocessorRegion + | ENDREGION TEXT? directive_new_line_or_sharp { this.OnPreprocessorDirectiveEndregion(); } # preprocessorRegion + | PRAGMA TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectivePragma(); } # preprocessorPragma + | NULLABLE TEXT directive_new_line_or_sharp { this.OnPreprocessorDirectiveNullable(); } # preprocessorNullable + ; + +directive_new_line_or_sharp + : DIRECTIVE_NEW_LINE + | EOF + ; + +preprocessor_expression + returns[String value] + : TRUE { this.OnPreprocessorExpressionTrue(); } + | FALSE { this.OnPreprocessorExpressionFalse(); } + | CONDITIONAL_SYMBOL { this.OnPreprocessorExpressionConditionalSymbol(); } + | OPEN_PARENS expr = preprocessor_expression CLOSE_PARENS { this.OnPreprocessorExpressionConditionalOpenParens(); } + | BANG expr = preprocessor_expression { this.OnPreprocessorExpressionConditionalBang(); } + | expr1 = preprocessor_expression OP_EQ expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalEq(); } + | expr1 = preprocessor_expression OP_NE expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalNe(); } + | expr1 = preprocessor_expression OP_AND expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalAnd(); } + | expr1 = preprocessor_expression OP_OR expr2 = preprocessor_expression { this.OnPreprocessorExpressionConditionalOr(); } + ; \ No newline at end of file diff --git a/_tests/grammars-v4/csharp/Java/CSharpLexerBase.java b/_tests/grammars-v4/csharp/Java/CSharpLexerBase.java new file mode 100644 index 000000000..4c3bd75a6 --- /dev/null +++ b/_tests/grammars-v4/csharp/Java/CSharpLexerBase.java @@ -0,0 +1,103 @@ +import org.antlr.v4.runtime.*; +import java.util.ArrayDeque; +import java.util.Deque; + +abstract class CSharpLexerBase extends Lexer +{ + protected CSharpLexerBase(CharStream input) + { + super(input); + } + + protected int interpolatedStringLevel; + protected final Deque interpolatedVerbatiums = new ArrayDeque<>(); + protected final Deque curlyLevels = new ArrayDeque<>(); + protected boolean verbatium; + + protected void OnInterpolatedRegularStringStart() + { + interpolatedStringLevel++; + interpolatedVerbatiums.push(false); + verbatium = false; + } + + protected void OnInterpolatedVerbatiumStringStart() + { + interpolatedStringLevel++; + interpolatedVerbatiums.push(true); + verbatium = true; + } + + protected void OnOpenBrace() + { + if (interpolatedStringLevel > 0) + { + curlyLevels.push(curlyLevels.pop() + 1); + } + } + + protected void OnCloseBrace() + { + + if (interpolatedStringLevel > 0) + { + curlyLevels.push(curlyLevels.pop() - 1); + if (curlyLevels.peek() == 0) + { + curlyLevels.pop(); + skip(); + popMode(); + } + } + } + + protected void OnColon() + { + + if (interpolatedStringLevel > 0) + { + int ind = 1; + boolean switchToFormatString = true; + while ((char)_input.LA(ind) != '}') + { + if (_input.LA(ind) == ':' || _input.LA(ind) == ')') + { + switchToFormatString = false; + break; + } + ind++; + } + if (switchToFormatString) + { + mode(CSharpLexer.INTERPOLATION_FORMAT); + } + } + } + + protected void OpenBraceInside() + { + curlyLevels.push(1); + } + + protected void OnDoubleQuoteInside() + { + interpolatedStringLevel--; + interpolatedVerbatiums.pop(); + verbatium = (interpolatedVerbatiums.size() > 0 ? interpolatedVerbatiums.peek() : false); + } + + protected void OnCloseBraceInside() + { + curlyLevels.pop(); + } + + protected boolean IsRegularCharInside() + { + return !verbatium; + } + + protected boolean IsVerbatiumDoubleQuoteInside() + { + return verbatium; + } +} diff --git a/_tests/grammars-v4/csharp/Java/CSharpParserBase.java b/_tests/grammars-v4/csharp/Java/CSharpParserBase.java new file mode 100644 index 000000000..a534475f5 --- /dev/null +++ b/_tests/grammars-v4/csharp/Java/CSharpParserBase.java @@ -0,0 +1,22 @@ +import org.antlr.v4.runtime.*; + +public abstract class CSharpParserBase extends Parser +{ + protected CSharpParserBase(TokenStream input) + { + super(input); + } + + protected boolean IsLocalVariableDeclaration() + { + if (!(this._ctx instanceof CSharpParser.Local_variable_declarationContext)) { + return false; + } + CSharpParser.Local_variable_declarationContext local_var_decl = (CSharpParser.Local_variable_declarationContext)this._ctx; + if (local_var_decl == null) return true; + CSharpParser.Local_variable_typeContext local_variable_type = local_var_decl.local_variable_type(); + if (local_variable_type == null) return true; + if (local_variable_type.getText().equals("var")) return false; + return true; + } +} diff --git a/_tests/grammars-v4/csharp/Java/CSharpPreprocessorParserBase.java b/_tests/grammars-v4/csharp/Java/CSharpPreprocessorParserBase.java new file mode 100644 index 000000000..eb6bca395 --- /dev/null +++ b/_tests/grammars-v4/csharp/Java/CSharpPreprocessorParserBase.java @@ -0,0 +1,203 @@ +import org.antlr.v4.runtime.*; +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.HashSet; + +abstract class CSharpPreprocessorParserBase extends Parser +{ + protected CSharpPreprocessorParserBase(TokenStream input) + { + super(input); + conditions.push(true); + ConditionalSymbols.add("DEBUG"); + } + + private final Deque conditions = new ArrayDeque<>(); + public HashSet ConditionalSymbols = new HashSet(); + + protected Boolean AllConditions() + { + for(Boolean condition: conditions) + { + if (!condition) + return false; + } + return true; + } + + protected void OnPreprocessorDirectiveDefine() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.PreprocessorDeclarationContext d = (CSharpPreprocessorParser.PreprocessorDeclarationContext)c; + ConditionalSymbols.add(d.CONDITIONAL_SYMBOL().getText()); + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectiveUndef() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.PreprocessorDeclarationContext d = (CSharpPreprocessorParser.PreprocessorDeclarationContext)c; + ConditionalSymbols.remove(d.CONDITIONAL_SYMBOL().getText()); + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectiveIf() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.PreprocessorConditionalContext d = (CSharpPreprocessorParser.PreprocessorConditionalContext)c; + d.value = d.expr.value.equals("true") && AllConditions(); + conditions.push(d.expr.value.equals("true")); + } + + protected void OnPreprocessorDirectiveElif() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.PreprocessorConditionalContext d = (CSharpPreprocessorParser.PreprocessorConditionalContext)c; + if (!conditions.peek()) + { + conditions.pop(); + d.value = d.expr.value.equals("true") && AllConditions(); + conditions.push(d.expr.value.equals("true")); + } + else + { + d.value = false; + } + } + + protected void OnPreprocessorDirectiveElse() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.PreprocessorConditionalContext d = (CSharpPreprocessorParser.PreprocessorConditionalContext)c; + if (!conditions.peek()) + { + conditions.pop(); + d.value = true && AllConditions(); + conditions.push(true); + } + else + { + d.value = false; + } + } + + protected void OnPreprocessorDirectiveEndif() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.PreprocessorConditionalContext d = (CSharpPreprocessorParser.PreprocessorConditionalContext)c; + conditions.pop(); + d.value = conditions.peek(); + } + + protected void OnPreprocessorDirectiveLine() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.PreprocessorLineContext d = (CSharpPreprocessorParser.PreprocessorLineContext)c; + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectiveError() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.PreprocessorDiagnosticContext d = (CSharpPreprocessorParser.PreprocessorDiagnosticContext)c; + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectiveWarning() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.PreprocessorDiagnosticContext d = (CSharpPreprocessorParser.PreprocessorDiagnosticContext)c; + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectiveRegion() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.PreprocessorRegionContext d = (CSharpPreprocessorParser.PreprocessorRegionContext)c; + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectiveEndregion() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.PreprocessorRegionContext d = (CSharpPreprocessorParser.PreprocessorRegionContext)c; + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectivePragma() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.PreprocessorPragmaContext d = (CSharpPreprocessorParser.PreprocessorPragmaContext)c; + d.value = AllConditions(); + } + + protected void OnPreprocessorDirectiveNullable() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.PreprocessorNullableContext d = (CSharpPreprocessorParser.PreprocessorNullableContext)c; + d.value = AllConditions(); + } + + protected void OnPreprocessorExpressionTrue() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.Preprocessor_expressionContext d = (CSharpPreprocessorParser.Preprocessor_expressionContext)c; + d.value = "true"; + } + + protected void OnPreprocessorExpressionFalse() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.Preprocessor_expressionContext d = (CSharpPreprocessorParser.Preprocessor_expressionContext)c; + d.value = "false"; + } + + protected void OnPreprocessorExpressionConditionalSymbol() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.Preprocessor_expressionContext d = (CSharpPreprocessorParser.Preprocessor_expressionContext)c; + d.value = ConditionalSymbols.contains(d.CONDITIONAL_SYMBOL().getText()) ? "true" : "false"; + } + + protected void OnPreprocessorExpressionConditionalOpenParens() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.Preprocessor_expressionContext d = (CSharpPreprocessorParser.Preprocessor_expressionContext)c; + d.value = d.expr.value; + } + + protected void OnPreprocessorExpressionConditionalBang() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.Preprocessor_expressionContext d = (CSharpPreprocessorParser.Preprocessor_expressionContext)c; + d.value = d.expr.value.equals("true") ? "false" : "true"; + } + + protected void OnPreprocessorExpressionConditionalEq() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.Preprocessor_expressionContext d = (CSharpPreprocessorParser.Preprocessor_expressionContext)c; + d.value = (d.expr1.value == d.expr2.value ? "true" : "false"); + } + + protected void OnPreprocessorExpressionConditionalNe() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.Preprocessor_expressionContext d = (CSharpPreprocessorParser.Preprocessor_expressionContext)c; + d.value = (d.expr1.value != d.expr2.value ? "true" : "false"); + } + + protected void OnPreprocessorExpressionConditionalAnd() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.Preprocessor_expressionContext d = (CSharpPreprocessorParser.Preprocessor_expressionContext)c; + d.value = (d.expr1.value.equals("true") && d.expr2.value.equals("true") ? "true" : "false"); + } + + protected void OnPreprocessorExpressionConditionalOr() + { + ParserRuleContext c = this._ctx; + CSharpPreprocessorParser.Preprocessor_expressionContext d = (CSharpPreprocessorParser.Preprocessor_expressionContext)c; + d.value = (d.expr1.value.equals("true") || d.expr2.value.equals("true") ? "true" : "false"); + } +} diff --git a/_tests/grammars-v4/csharp/README.md b/_tests/grammars-v4/csharp/README.md new file mode 100644 index 000000000..dbfbadb5c --- /dev/null +++ b/_tests/grammars-v4/csharp/README.md @@ -0,0 +1,43 @@ +## Summary + +C# grammar with full support of +[C# 6 features](https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6) and below. +CSharpLexer.g4 and CSharpPreprocessor.g4 are runtime dependent (contains specific actions), +because of directive preprocessors and string interpolation (these things make grammar context-sensitive). +C# and Java versions supported. But CSharpParser.g4 is runtime independent. +This ANTLR 4 C# grammar is based on the C# ANTLR 3 grammar from +[ChristianWulf/CSharpGrammar](https://github.com/ChristianWulf/CSharpGrammar). + +## Using + +Due to uncompiled code can be placed after such preprocessor directives: +```CSharp +#if SILVERLIGHT && WINDOWS_PHONE || DEBUG || foo == true +// Some code +#endif +``` +at first stage it's necessary to calculate whether condition satisfied in directive. +This step performed by runtime code in gist: +[CSharpAntlrParser](https://gist.github.com/KvanTTT/d95579de257531a3cc15). + +## Testing + +I put into repository **AllInOne.cs** file (from Roslyn) with most common syntax and also +I tested this grammar on the following most popular .NET projects: +* [Roslyn-1.1.1](https://github.com/dotnet/roslyn). +* [Corefx-1.0.0-rc2](https://github.com/dotnet/corefx). +* [EntityFramework-7.0.0-rc1](https://github.com/aspnet/EntityFramework). +* [aspnet-mvc-6.0.0-rc1](https://github.com/aspnet/Mvc). +* [ImageProcessor-2.3.0](https://github.com/JimBobSquarePants/ImageProcessor). +* [Newtonsoft.Json-8.0.2](https://github.com/JamesNK/Newtonsoft.Json). + +There are some problems with deep recursion ([TestData.g.cs in CoreFx](https://github.com/dotnet/corefx/blob/master/src/Common/tests/System/Xml/XmlCoreTest/TestData.g.cs)), +unicode chars +([sjis.cs in Roslyn](https://github.com/dotnet/roslyn/blob/master/src/Compilers/Test/Resources/Core/Encoding/sjis.cs)) +and preprocessor directives. + +ANTLR parser from this grammar approximately ~5-7 slowly than Roslyn parser. + +## License + +[Eclipse Public License - v 1.0](http://www.eclipse.org/legal/epl-v10.html) diff --git a/_tests/grammars-v4/csharp/desc.xml b/_tests/grammars-v4/csharp/desc.xml new file mode 100644 index 000000000..ee18933e8 --- /dev/null +++ b/_tests/grammars-v4/csharp/desc.xml @@ -0,0 +1,6 @@ + + + CSharp;Java + CSharp + examples/**/*.cs + \ No newline at end of file diff --git a/_tests/grammars-v4/csharp/examples/AllInOneNoPreprocessor.cs b/_tests/grammars-v4/csharp/examples/AllInOneNoPreprocessor.cs new file mode 100644 index 000000000..d2b816d3b --- /dev/null +++ b/_tests/grammars-v4/csharp/examples/AllInOneNoPreprocessor.cs @@ -0,0 +1,1072 @@ +extern alias Foo; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using M = System.Math; + +using ConsoleApplication2.Test; + +/**/ +/* the previous comment is an empty delimited comment and not a document comment */ +/** this is a document comment */ +// this one is a single line comment + +using X = int1; +using Y = ABC.X; + +using static System.Math; +using static System.DayOfWeek; +using static System.Linq.Enumerable; + +[assembly: System.Copyright(@"(C)"" + +2009")] +[module: System.Copyright("\n\t\u0123(C) \"2009" + "\u0123")] + +class TopLevelType : IDisposable +{ + void IDisposable.Dispose() { } +} + +namespace My +{ + using A.B; + + interface CoContra { } + delegate void CoContra2<[System.Obsolete()] out T, in K> () where T : struct; + + public unsafe partial class A : C, I + { + [DllImport("kernel32", SetLastError = true)] + static extern bool CreateDirectory(string name, SecurityAttribute sa); + + private const int global = int.MinValue - 1; + + static A() + { + } + + [method: Obsolete] + public A([param: Obsolete] int foo) : + base(1) + { + L: + { + int i = sizeof(int); + ++i; + var s1 = $"x {1 , -2 :d}"; + var s2 = $@"x {1 , -2 :d}"; + } + + + Console.WriteLine(export.iefSupplied.command); + + const int? local = int.MaxValue; + const Guid? local0 = new Guid(r.ToString()); + + var привет = local; + var мир = local; + int local3 = 0, local4 = 1; + local3 = local4 = 1; + var local5 = null as Action ?? null; + var local6 = local5 is Action; + + var u = 1u; + var U = 1U; + long hex = 0xBADC0DE, Hex = 0XDEADBEEF, l = -1L, L = 1L, l2 = 2l; + ulong ul = 1ul, Ul = 1Ul, uL = 1uL, UL = 1UL, + lu = 1lu, Lu = 1Lu, lU = 1lU, LU = 1LU; + int minInt32Value = -2147483648; + int minInt64Value = -9223372036854775808L; + + bool @bool; + byte @byte; + char @char = 'c', \u0066 = '\u0066', hexchar = '\x0130', hexchar2 = (char)0xBAD; + string \U00000065 = "\U00000065"; + decimal @decimal = 1.44M; + @decimal = 1.2m; + dynamic @dynamic; + double @double = M.PI; + @double = 1d; + @double = 1D; + @double = -1.2e3; + float @float = 1.2f; + @float = 1.44F; + int @int = local ?? -1; + long @long; + object @object; + sbyte @sbyte; + short @short; + string @string = @"""/*"; + uint @uint; + ulong @ulong; + ushort @ushort; + + dynamic dynamic = local5; + var add = 0; + var alias = 0; + var arglist = 0; + var ascending = 0; + var async = 0; + var await = 0; + var by = 0; + var descending = 0; + var dynamic = 0; + var equals = 0; + var from = 0; + var get = 0; + var group = 0; + var into = 0; + var join = 0; + var let = 0; + var nameof = 0; + var on = 0; + var orderby = 0; + var partial = 0; + var remove = 0; + var select = 0; + var set = 0; + var var = 0; + var when = 0; + var where = 0; + var yield = 0; + var __ = 0; + where = yield = 0; + + if (i > 0) + { + return; + } + else if (i == 0) + { + throw new Exception(); + } + var o1 = new MyObject(); + var o2 = new MyObject(var); + var o3 = new MyObject { A = i }; + var o4 = new MyObject(@dynamic) + { + A = 0, + B = 0, + C = 0 + }; + var o5 = new { A = 0 }; + var dictionaryInitializer = new Dictionary + { + {1, ""}, + {2, "a"} + }; + float[] a = new float[] + { + 0f, + 1.1f + }; + int[, ,] cube = { { { 111, 112, }, { 121, 122 } }, { { 211, 212 }, { 221, 222 } } }; + int[][] jagged = { { 111 }, { 121, 122 } }; + int[][,] arr = new int[5][,]; // as opposed to new int[][5,5] + arr[0] = new int[5,5]; // as opposed to arr[0,0] = new int[5]; + arr[0][0,0] = 47; + int[] arrayTypeInference = new[] { 0, 1, }; + switch (3) { } + switch (i) + { + case 0: + case 1: + { + goto case 2; + } + case 2 + 3: + { + goto default; + break; + } + default: + { + return; + } + } + while (i < 10) + { + ++i; + if (true) continue; + break; + } + do + { + ++i; + if (true) continue; + break; + } + while (i < 10); + for (int j = 0; j < 100; ++j) + { + for(;;) + { + for (int i = 0, j = 0; i < length; i++, j++) { } + if (true) continue; + break; + } + } + label: + goto label; + label2: ; + foreach (var i in Items()) + { + if (i == 7) + return; + else + continue; + } + checked + { + checked(++i); + } + unchecked + { + unchecked(++i); + } + lock (sync) + process(); + using (var v = BeginScope()) + using (A a = new A()) + using (A a = new A(), b = new A()) + using (BeginScope()) + return; + yield return this.items[3]; + yield break; + fixed (int* p = stackalloc int[100], q = &y) + { + *intref = 1; + } + fixed (int* p = stackalloc int[100]) + { + *intref = 1; + } + unsafe + { + int* p = null; + } + try + { + throw null; + } + catch (System.AccessViolationException av) + { + throw av; + } + catch (Exception) + { + throw; + } + finally + { + try { } catch { } + } + var anonymous = + { + A = 1, + B = 2, + C = 3, + }; + var query = from c in customers + let d = c + where d != null + join c1 in customers on c1.GetHashCode() equals c.GetHashCode() + join c1 in customers on c1.GetHashCode() equals c.GetHashCode() into e + group c by c.Country + into g + orderby g.Count() ascending + orderby g.Key descending + select new { Country = g.Key, CustCount = g.Count() }; + query = from c in customers + select c into d + select d; + } + ~A() + { + } + private readonly int f1; + [Obsolete] + [NonExisting] + [Foo::NonExisting(var, 5)] + [CLSCompliant(false)] + [Obsolete, System.NonSerialized, NonSerialized, CLSCompliant(true || false & true)] + private volatile int f2; + [return: Obsolete] + [method: Obsolete] + public void Handler(object value) + { + } + public int m(T t) + where T : class, new() + { + base.m(t); + return 1; + } + public string P + { + get + { + return "A"; + } + set; + } + public abstract string P + { + get; + } + public abstract int this[int index] + { + protected internal get; + internal protected set; + } + [method: Obsolete] + [field: Obsolete] + [event: Obsolete] + public readonly event Event E; + [event: Test] + public event Action E1 + { + [Obsolete] + add { value = value; } + [Obsolete] + [return: Obsolete] + remove { E += Handler; E -= Handler; } + } + public static A operator +(A first, A second) + { + Delegate handler = new Delegate(Handler); + return first.Add(second); + } + [method: Obsolete] + [return: Obsolete] + public static bool operator true(A a) + { + return true; + } + public static bool operator false(A a) + { + return false; + } + class C + { + } + } + public struct S : I + { + public S() + { + } + private int f1; + [Obsolete("Use Script instead", error: false)] + private volatile int f2; + public abstract int m(T t) + where T : struct + { + return 1; + } + public string P + { + get + { + int value = 0; + return "A"; + } + set; + } + public abstract string P + { + get; + } + public abstract int this[int index] + { + get; + internal protected set; + } + public event Event E; + public static A operator +(A first, A second) + { + return first.Add(second); + } + fixed int field[10]; + class C + { + } + } + public interface I + { + void A(int value); + string Value + { + get; + set; + } + unsafe void UpdateSignatureByHashingContent([In]byte* buffer, int size); + } + [type: Flags] + public enum E + { + A, + B = A, + C = 2 + A, + D, + } + + public delegate void Delegate(object P); + namespace Test + { + using System; + using System.Collections; + public class Список + { + public static IEnumerable Power(int number, int exponent) + { + Список Список = new Список(); + Список.Main(); + int counter = (0 + 0); + int אתר = 0; + while (++counter++ < --exponent--) + { + result = result * number + +number+++++number; + yield return result; + } + } + static void Main() + { + foreach (int i in Power(2, 8)) + { + Console.Write("{0} ", i); + } + } + async void Wait() + { + await System.Threading.Tasks.Task.Delay(0); + } + void AsyncAnonymous() // C # 5 feature + { + var task = Task.Factory.StartNew(async () => + { + return await new WebClient().DownloadStringTaskAsync("http://example.com"); + }); + } + } + } +} + +namespace ConsoleApplication1 +{ + namespace RecursiveGenericBaseType + { + class A : B, A> where T : A + { + protected virtual A M() { } + protected abstract B, A> N() { } + static B, A> O() { } + } + + sealed class B : A> + { + protected override A M() { } + protected sealed override B, A> N() { } + new static A O() { } + } + } + + namespace Boo + { + public class Bar where T : IComparable + { + public T f; + public class Foo : IEnumerable + { + public void Method(K k, T t, U u) + where K : IList, IList, IList + where V : IList + { + A a; + M(A(5)); + } + }; + }; + }; + + class Test + { + void Bar3() + { + var x = new Boo.Bar.Foo(); + x.Method(" ", 5, new object()); + + var q = from i in new int[] { 1, 2, 3, 4 } + where i > 5 + select i; + } + + public static implicit operator Test(string s) + { + return new ConsoleApplication1.Test(); + } + public static explicit operator Test(string s = "") + { + return new Test(); + } + + public int foo = 5; + void Bar2() + { + foo = 6; + this.Foo = 5.GetType(); Test t = "sss"; + } + + public event EventHandler MyEvent = delegate { }; + + void Blah() + { + int i = 5; + int? j = 6; + + Expression> e = () => i; + Expression> e2 = b => () => { return; }; + Func f = async delegate (bool a) + { + return await !a; + }; + Func f2 = (a, b) => 0; + f2 = (int a, int b) => 1; + Action a = Blah; + f2 = () => {}; + f2 = () => {;}; + } + + delegate Recursive Recursive(Recursive r); + delegate Recursive Recursive(Recursive r); + + public Type Foo + { + [Obsolete("Name", error = false)] + get + { + var result = typeof(IEnumerable); + var t = typeof(int?) == typeof(Nullable); + t = typeof(IEnumerable); + return typeof(IEnumerable<>); + } + set + { + var t = typeof(System.Int32); + t.ToString(); + t = value; + } + } + + public void Constants() + { + int i = 1 + 2 + 3 + 5; + global::System.String s = "a" + (System.String)"a" + "a" + "a" + "a" + "A"; + } + + public void ConstructedType() + { + List i = null; + int c = i.Count; + } + } +} + +namespace Comments.XmlComments.UndocumentedKeywords +{ + /// + /// Whatever + /// + /// + /// // + /// /* */ + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + class /*///*/C + { + void M(T t, U u) + { + // comment + /* *** / */ + /* // + */ + /*s*///comment + // /***/ + /*s*/int /*s*/intValue = 0; + intValue = intValue /*s*/+ 1; + string strValue = /*s*/"hello"; + /*s*/MyClass c = new MyClass(); + string verbatimStr = /*s*/@"\\\\"; + } + } + + //General Test F. Type a very long class name, verify colorization happens correctly only upto the correct size (118324) + class TestClassXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/*Scen8*/{ } + + class TestClassXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX22/*Scen9*/{ } + + class yield + { + void Foo(__arglist) + { + C c = null; + c.M(5, default(U)); + TypedReference tr = __makeref(c); + Type t = __reftype(tr); + int j = __refvalue(tr, int); + Params(a: t, b: t); + Params(ref c, out c); + } + void Params(ref dynamic a, out dynamic b, params dynamic[] c) {} + void Params(out dynamic a = 2, ref dynamic c = default(dynamic), params dynamic[][] c) {} + + public override string ToString() { return base.ToString(); } + + public partial void OnError(); + + public partial void method() + { + int?[] a = new int?[5];/*[] bug*/ // YES [] + int[] var = { 1, 2, 3, 4, 5 };/*,;*/ + int i = a[i];/*[]*/ + Foo f = new Foo();/*<> ()*/ + f.method();/*().*/ + i = i + i - i * i / i % i & i | i ^ i;/*+ - * / % & | ^*/ + bool b = true & false | true ^ false;/*& | ^*/ + b = !b;/*!*/ + i = ~i;/*~i*/ + b = i < i && i > i;/*< && >*/ + int? ii = 5;/*? bug*/ // NO ? + int f = true ? 1 : 0;/*? :*/ // YES : + i++;/*++*/ + i--;/*--*/ + b = true && false || true;/*&& ||*/ + i << 5;/*<<*/ + i >> 5;/*>>*/ + b = i == i && i != i && i <= i && i >= i;/*= == && != <= >=*/ + i += 5.0;/*+=*/ + i -= i;/*-=*/ + i *= i;/**=*/ + i /= i;/*/=*/ + i %= i;/*%=*/ + i &= i;/*&=*/ + i |= i;/*|=*/ + i ^= i;/*^=*/ + i <<= i;/*<<=*/ + i >>= i;/*>>=*/ + object s = x => x + 1;/*=>*/ + double d = .3; + Point point; + unsafe + { + Point* p = &point;/** &*/ + p->x = 10;/*->*/ + } + IO::BinaryReader br = null; + x[i: 1] = 3; + x[i: 1, j: 5] = "str"; + } + + struct Point { public int X; public int Y; public void ThisAccess() { this = this; } } + } + + // From here:https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6 + class CSharp6Features + { + // Initializers for auto-properties + public string First { get; set; } = "Jane"; + public string Last { get; set; } = "Doe"; + + // Getter-only auto-properties + public string Third { get; } = "Jane"; + public string Fourth { get; } = "Doe"; + + // Expression bodies on method-like members + public Point Move(int dx, int dy) => new Point(x + dx, y + dy); + public static Complex operator +(Complex a, Complex b) => a.Add(b); + public static implicit operator string(Person p) => p.First + " " + p.Last; + public void Print() => Console.WriteLine(First + " " + Last); + + // Expression bodies on property-like function members + public string Name => First + " " + Last; + public int this[long id] => id; + + async void Test() + { + // Using static + WriteLine(Sqrt(3*3 + 4*4)); + WriteLine(Friday - Monday); + var range = Range(5, 17); // Ok: not extension + var even = range.Where(i => i % 2 == 0); // Ok + + // Null-conditional operators + int? length = customers?.Length; // null if customers is null + Customer first = customers?[0]; // null if customers is null + int length = customers?.Length ?? 0; // 0 if customers is null + int? first = customers?[0]?.Orders?.Count(); + PropertyChanged?.Invoke(this, args); + + // String interpolation + string s = $"{p.Name, 20} is {p.Age:D3} year{{s}} old #"; + s = $"{p.Name} is \"{p.Age} year{(p.Age == 1 ? "" : "s")} old"; + s = $"{(p.Age == 2 ? $"{new Person { } }" : "")}"; + s = $@"\{p.Name} + ""\"; + s = $"Color [ R={func(b: 3):#0.##}, G={G:#0.##}, B={B:#0.##}, A={A:#0.##} ]"; + + // nameof expressions + if (x == null) + throw new ArgumentNullException(nameof(x)); + WriteLine(nameof(person.Address.ZipCode)); // prints "ZipCode" + + // Index initializers + var numbers = new Dictionary { + [7] = "seven", + [9] = "nine", + [13] = "thirteen" + }; + + // Exception filters + try {} + catch (MyException e) when (myfilter(e)) + { } + + // Await in catch and finally blocks + Resource res = null; + try + { + res = await Resource.OpenAsync(); // You could do this. + } + catch(ResourceException e) + { + await Resource.LogAsync(res, e); // Now you can do this … + } + finally + { + if (res != null) + await res.CloseAsync(); // … and this. + } + } + } +} + +class CSharp70 +{ + void PatternMatching(string arg, int b) + { + switch (arg) + { + case "A" when b > 50: + case "B" when b < 50: + default: + break; + } + + (A D, E H) = e; + + if (x?.y?.z is Type value2) + { + // code using value + } + + if (expr is Type v) { Hello(); } + } + + public static async Task LocalFunctions(string[] args) + { + string Hello2(int i) + { + return args[i]; + } + + async Task Hello(T i) => await Task.FromResult(args[i]); + await Hello(1); + } + + public static void OutVar(string[] args) + { + int.TryParse(Hello(1), out var item); + int.TryParse(Hello(1), out int item); + } + + public void ThrowExpression() + { + var result = nullableResult ?? throw new NullReferenceException(); + } + + public void BinaryLiterals() + { + int nineteen = 0b10011; + } + + public void DigitSeparators() + { + int bin = 0b1001_1010_0001_0100; + int hex = 0x1b_a0_44_fe; + int dec = 33_554_432; + int weird = 1_2__3___4____5_____6______7_______8________9; + double real = 1_000.111_1e-1_000; + } +} + +class CSharp71 +{ + void DefaultWithoutTypeName(string content = default) + { + DefaultWithoutTypeName(default); + } + + void TupleRecognize(int a, (int, int) b, (int, int, int)? c) + { + var result = list.Select(c => (c.f1, f3: c.f2)).Where(t => t.f2 == 1); + } +} + +class CSharp72 +{ + readonly struct ReadonlyRef1 + { + Func s = (in int x) => x; + ref TValue this[in TKey index] => null; + public static Vector3 operator+(in Vector3 x, in Vector3 y) => null; + + static readonly ref Vector3 M1_Trace() + { + // OK + ref readonly var r1 = ref M1(); + + // Not valid. Need an LValue + ref readonly Vector3 r2 = ref default(Vector3); + + // Not valid. r1 is readonly. + Mutate(ref r1); + + // OK. + Print(in r1); + + // OK. + return ref r1; + } + } + + ref struct ReadonlyRef2 + { + ref readonly Guid Test(in Vector3 v1, in Vector3 v2) + { + // not OK!! + v1 = default(Vector3); + + // not OK!! + v1.X = 0; + + // not OK!! + foo(ref v1.X); + + return ref (arr != null ? ref arr[0]: ref otherArr[0]); + + Span span = stackalloc int[1]; + + // OK + return new Vector3(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z); + } + + ref T Choice(bool condition, ref T consequence, ref T alternative) + { + if (condition) + { + return ref consequence; + } + else + { + return ref alternative; + } + } + } + + public void DoSomething(bool isEmployed, string personName, int personAge) { } + + public void NonTrailingNamedArguments() + { + DoSomething(isEmployed:true, name, age); // currently CS1738, but would become legal + DoSomething(true, personName:name, age); // currently CS1738, but would become legal + DoSomething(name, isEmployed:true, age); // remains illegal + DoSomething(name, age, isEmployed:true); // remains illegal + DoSomething(true, personAge:age, personName:name); // already legal + } + + public void ConditionalRef() + { + ref var r = ref (arr != null ? ref arr[0]: ref otherArr[0]); + } + + public void LeadingSeparator() + { + var res = 0 + + 123 // permitted in C# 1.0 and later + + 1_2_3 // permitted in C# 7.0 and later + + 0x1_2_3 // permitted in C# 7.0 and later + + 0b101 // binary literals added in C# 7.0 + + 0b1_0_1 // permitted in C# 7.0 and later + + // in C# 7.2, _ is permitted after the `0x` or `0b` + + 0x_1_2 // permitted in C# 7.2 and later + + 0b_1_0_1 // permitted in C# 7.2 and later + ; + } +} + +class CSharp73 +{ + void Blittable(T value) where T : unmanaged + { + var unmanaged = 666; + } + + unsafe struct IndexingMovableFixed + { + public fixed int myFixedField[10]; + } + + static IndexingMovableFixed s; + + public unsafe void IndexingMovableFixedFields() + { + int* ptr = s.myFixedField; + int t = s.myFixedField[5]; + } + + public void PatternBasedFixed() + { + fixed(byte* ptr = byteArray) + { + // ptr is a native pointer to the first element of the array + // byteArray is protected from being moved/collected by the GC for the duration of this block + } + } + + public void StackallocArrayInitializer() + { + Span a = stackalloc int[3]; // currently allowed + Span a = stackalloc int[3] { 1, 2, 3 }; + Span a = stackalloc int[] { 1, 2, 3 }; + Span a = stackalloc[] { 1, 2, 3 }; + } + + public void TupleEquality() + { + (int, (int, int)) t1, t2; + var res = t1 == (1, (2, 3)); + } +} + +namespace CSharp80 +{ + class CSharp80ExceptInterfaceDefaultImplement + { + void ReferenceNullable() + { + var? x = E; + x!.ToString(); + string? wtf = null; + int?[]? hello; + } + + void Patterns() + { + if (o is string { Length: 5 } s) Do(); + + return lang.CountOfTokens switch + { + 1 => 100, + 2 => 200, + _ => throw new global::System.Exception() + }; + + var newState = (GetState(), action, hasKey) switch + { + (DoorState.Closed, Action.Open, _) => DoorState.Opened, + (DoorState.Opened, Action.Close, _) => DoorState.Closed, + (DoorState.Closed, Action.Lock, true) => DoorState.Locked, + (DoorState.Locked, Action.Unlock, true) => DoorState.Closed, + (var state, _, _) => state + }; + } + + async Task AsyncStreams() + { + await foreach (var item in asyncEnumerables) + { + } + } + + void Ranges() + { + var thirdItem = list[2]; // list[2] + var lastItem = list[^1]; // list[Index.CreateFromEnd(1)] + var multiDimensional = list[3, ^2]; // list[3, Index.CreateFromEnd(2)] + + var slice1 = list[2..^3]; // list[Range.Create(2, Index.CreateFromEnd(3))] + var slice2 = list[..^3]; // list[Range.ToEnd(Index.CreateFromEnd(3))] + var slice3 = list[2..]; // list[Range.FromStart(2)] + var slice4 = list[..]; // list[Range.All] + var multiDimensional = list[1..2, ..]; // list[Range.Create(1, 2), Range.All] + } + + void UsingDeclarators() + { + using var item = new FileStream("./.f"); + fixed char* ch = "hell"; + item.Dispose(); // no! + } + + void StaticLocalFunction() + { + static unsafe void Func1() {} + static unsafe void Func1() {} + async static void Func2() {} + static async void Func2() {} + } + + void NullCoalescingAssignment() + { + var item = a ??= b ??= c ??= d ??= throw new Exception(); + } + + public readonly float Hello() + { + return 0.1f; + } + } + + interface IA + { + void M() { WriteLine("IA.M"); } + } + + interface IA + { + void M() { WriteLine("IA.M"); } + } + + interface IB : IA + { + override void IA.M() { WriteLine("IB.M"); } // explicitly named + } + + interface IC : IA + { + override void M() { WriteLine("IC.M"); } // implicitly named + } +} diff --git a/_tests/grammars-v4/csharp/examples/C2430-ok.cs b/_tests/grammars-v4/csharp/examples/C2430-ok.cs new file mode 100644 index 000000000..e03cb73a6 --- /dev/null +++ b/_tests/grammars-v4/csharp/examples/C2430-ok.cs @@ -0,0 +1,4 @@ + +class foo +{ +} diff --git a/_tests/grammars-v4/csharp/examples/C2430.cs b/_tests/grammars-v4/csharp/examples/C2430.cs new file mode 100644 index 000000000..f2dead6d4 --- /dev/null +++ b/_tests/grammars-v4/csharp/examples/C2430.cs @@ -0,0 +1,6 @@ + +#region connection_f + +class foo +{ +} diff --git a/_tests/grammars-v4/csharp/examples/Multiple.cs b/_tests/grammars-v4/csharp/examples/Multiple.cs new file mode 100644 index 000000000..2df2e577e --- /dev/null +++ b/_tests/grammars-v4/csharp/examples/Multiple.cs @@ -0,0 +1,7 @@ +class Multiple +{ + void Foo() + { + var a = 3, b = 2; + } +} diff --git a/_tests/grammars-v4/csharp/examples/Multiple.cs.errors b/_tests/grammars-v4/csharp/examples/Multiple.cs.errors new file mode 100644 index 000000000..da4c7e22f --- /dev/null +++ b/_tests/grammars-v4/csharp/examples/Multiple.cs.errors @@ -0,0 +1 @@ +line 5:18 rule local_variable_declaration failed predicate: { this.IsLocalVariableDeclaration() }? diff --git a/_tests/grammars-v4/csharp/examples/MultiplicativeExprsInArgList.cs b/_tests/grammars-v4/csharp/examples/MultiplicativeExprsInArgList.cs new file mode 100644 index 000000000..86dc3c818 --- /dev/null +++ b/_tests/grammars-v4/csharp/examples/MultiplicativeExprsInArgList.cs @@ -0,0 +1,6 @@ +public class ClassName { + Constructor MethodName(Object a, String b, int c) { + var avgSum = Math.Sqrt(Math.Pow(x[i] - x[j], 2) + Math.Pow(y[i] - y[j], 2)); + return new Constructor(field, a.b, a.b + c.d, e.f.g + h); + } +} diff --git a/_tests/grammars-v4/csharp/examples/issue-2612.txt b/_tests/grammars-v4/csharp/examples/issue-2612.txt new file mode 100644 index 000000000..0cb449d29 --- /dev/null +++ b/_tests/grammars-v4/csharp/examples/issue-2612.txt @@ -0,0 +1,8 @@ +class A{ + void a() { + int[] nums = {1, 3, 5, 7}; + for (int num : nums){ + b(num); + } + } +} diff --git a/_tests/grammars-v4/csharp/examples/issue-2612.txt.errors b/_tests/grammars-v4/csharp/examples/issue-2612.txt.errors new file mode 100644 index 000000000..6832b6cae --- /dev/null +++ b/_tests/grammars-v4/csharp/examples/issue-2612.txt.errors @@ -0,0 +1 @@ +line 4:17 mismatched input ':' expecting {'add', 'alias', '__arglist', 'ascending', 'async', 'await', 'by', 'descending', 'dynamic', 'equals', 'from', 'get', 'group', 'into', 'join', 'let', 'nameof', 'on', 'orderby', 'partial', 'remove', 'select', 'set', 'unmanaged', 'var', 'when', 'where', 'yield', IDENTIFIER, '[', '*', '?'} diff --git a/_tests/grammars-v4/csharp/not-ready-examples/AllInOne.cs b/_tests/grammars-v4/csharp/not-ready-examples/AllInOne.cs new file mode 100644 index 000000000..5dea27e24 --- /dev/null +++ b/_tests/grammars-v4/csharp/not-ready-examples/AllInOne.cs @@ -0,0 +1,1100 @@ +#error Error message +#warning Warning message +#pragma warning disable 414, 3021 +#pragma warning restore 3021 +#pragma checksum "file.txt" "{00000000-0000-0000-0000-000000000000}" "2453" +#define foo // Comment in directive +#if foo +#else +#endif +#undef foo + +extern alias Foo; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using M = System.Math; + +#if DEBUG || TRACE +using System.Diagnostics; +#elif SILVERLIGHT && WINDOWS_PHONE || DEBUG || foo == true || foo != false +using System.Diagnostics; +#else +using System.Diagnostics; +#endif + +#region Region + + #region more +using ConsoleApplication2.Test; + #endregion +using X = int1; +using Y = ABC.X; + +using static System.Math; +using static System.DayOfWeek; +using static System.Linq.Enumerable; + +#endregion + +[assembly: System.Copyright(@"(C)"" + +2009")] +[module: System.Copyright("\n\t\u0123(C) \"2009" + "\u0123")] + +class TopLevelType : IDisposable +{ + void IDisposable.Dispose() { } +} + +namespace My +{ + using A.B; + + interface CoContra { } + delegate void CoContra2<[System.Obsolete()] out T, in K> () where T : struct; + + public unsafe partial class A : C, I + { + [DllImport("kernel32", SetLastError = true)] + static extern bool CreateDirectory(string name, SecurityAttribute sa); + + private const int global = int.MinValue - 1; + + static A() + { + } + + [method: Obsolete] + public A([param: Obsolete] int foo) : + base(1) + { + L: + { + int i = sizeof(int); + ++i; + var s1 = $"x {1 , -2 :d}"; + var s2 = $@"x {1 , -2 :d}"; + } + +#if DEBUG + Console.WriteLine(export.iefSupplied.command); +#endif + const int? local = int.MaxValue; + const Guid? local0 = new Guid(r.ToString()); + + var привет = local; + var мир = local; + var local3 = 0, local4 = 1; + local3 = local4 = 1; + var local5 = null as Action ?? null; + var local6 = local5 is Action; + + var u = 1u; + var U = 1U; + long hex = 0xBADC0DE, Hex = 0XDEADBEEF, l = -1L, L = 1L, l2 = 2l; + ulong ul = 1ul, Ul = 1Ul, uL = 1uL, UL = 1UL, + lu = 1lu, Lu = 1Lu, lU = 1lU, LU = 1LU; + int minInt32Value = -2147483648; + int minInt64Value = -9223372036854775808L; + + bool @bool; + byte @byte; + char @char = 'c', \u0066 = '\u0066', hexchar = '\x0130', hexchar2 = (char)0xBAD; + string \U00000065 = "\U00000065"; + decimal @decimal = 1.44M; + @decimal = 1.2m; + dynamic @dynamic; + double @double = M.PI; + @double = 1d; + @double = 1D; + @double = -1.2e3; + float @float = 1.2f; + @float = 1.44F; + int @int = local ?? -1; + long @long; + object @object; + sbyte @sbyte; + short @short; + string @string = @"""/*"; + uint @uint; + ulong @ulong; + ushort @ushort; + + dynamic dynamic = local5; + var add = 0; + var alias = 0; + var arglist = 0; + var ascending = 0; + var async = 0; + var await = 0; + var by = 0; + var descending = 0; + var dynamic = 0; + var equals = 0; + var from = 0; + var get = 0; + var group = 0; + var into = 0; + var join = 0; + var let = 0; + var nameof = 0; + var on = 0; + var orderby = 0; + var partial = 0; + var remove = 0; + var select = 0; + var set = 0; + var when = 0; + var where = 0; + var yield = 0; + var __ = 0; + where = yield = 0; + + if (i > 0) + { + return; + } + else if (i == 0) + { + throw new Exception(); + } + var o1 = new MyObject(); + var o2 = new MyObject(var); + var o3 = new MyObject { A = i }; + var o4 = new MyObject(@dynamic) + { + A = 0, + B = 0, + C = 0 + }; + var o5 = new { A = 0 }; + var dictionaryInitializer = new Dictionary + { + {1, ""}, + {2, "a"} + }; + float[] a = new float[] + { + 0f, + 1.1f + }; + int[, ,] cube = { { { 111, 112, }, { 121, 122 } }, { { 211, 212 }, { 221, 222 } } }; + int[][] jagged = { { 111 }, { 121, 122 } }; + int[][,] arr = new int[5][,]; // as opposed to new int[][5,5] + arr[0] = new int[5,5]; // as opposed to arr[0,0] = new int[5]; + arr[0][0,0] = 47; + int[] arrayTypeInference = new[] { 0, 1, }; + switch (3) { } + switch (i) + { + case 0: + case 1: + { + goto case 2; + } + case 2 + 3: + { + goto default; + break; + } + default: + { + return; + } + } + while (i < 10) + { + ++i; + if (true) continue; + break; + } + do + { + ++i; + if (true) continue; + break; + } + while (i < 10); + for (int j = 0; j < 100; ++j) + { + for(;;) + { + for (int i = 0, j = 0; i < length; i++, j++) { } + if (true) continue; + break; + } + } + label: + goto label; + label2: ; + foreach (var i in Items()) + { + if (i == 7) + return; + else + continue; + } + checked + { + checked(++i); + } + unchecked + { + unchecked(++i); + } + lock (sync) + process(); + using (var v = BeginScope()) + using (A a = new A()) + using (A a = new A(), b = new A()) + using (BeginScope()) + return; + yield return this.items[3]; + yield break; + fixed (int* p = stackalloc int[100], q = &y) + { + *intref = 1; + } + fixed (int* p = stackalloc int[100]) + { + *intref = 1; + } + unsafe + { + int* p = null; + } + try + { + throw null; + } + catch (System.AccessViolationException av) + { + throw av; + } + catch (Exception) + { + throw; + } + finally + { + try { } catch { } + } + var anonymous = + { + A = 1, + B = 2, + C = 3, + }; + var query = from c in customers + let d = c + where d != null + join c1 in customers on c1.GetHashCode() equals c.GetHashCode() + join c1 in customers on c1.GetHashCode() equals c.GetHashCode() into e + group c by c.Country + into g + orderby g.Count() ascending + orderby g.Key descending + select new { Country = g.Key, CustCount = g.Count() }; + query = from c in customers + select c into d + select d; + } + ~A() + { + } + private readonly int f1; + [Obsolete] + [NonExisting] + [Foo::NonExisting(var, 5)] + [CLSCompliant(false)] + [Obsolete, System.NonSerialized, NonSerialized, CLSCompliant(true || false & true)] + private volatile int f2; + [return: Obsolete] + [method: Obsolete] + public void Handler(object value) + { + } + public int m(T t) + where T : class, new() + { + base.m(t); + return 1; + } + public string P + { + get + { + return "A"; + } + set; + } + public abstract string P + { + get; + } + public abstract int this[int index] + { + protected internal get; + internal protected set; + } + [method: Obsolete] + [field: Obsolete] + [event: Obsolete] + public readonly event Event E; + [event: Test] + public event Action E1 + { + [Obsolete] + add { value = value; } + [Obsolete] + [return: Obsolete] + remove { E += Handler; E -= Handler; } + } + public static A operator +(A first, A second) + { + Delegate handler = new Delegate(Handler); + return first.Add(second); + } + [method: Obsolete] + [return: Obsolete] + public static bool operator true(A a) + { + return true; + } + public static bool operator false(A a) + { + return false; + } + class C + { + } + } + public struct S : I + { + public S() + { + } + private int f1; + [Obsolete("Use Script instead", error: false)] + private volatile int f2; + public abstract int m(T t) + where T : struct + { + return 1; + } + public string P + { + get + { + int value = 0; + return "A"; + } + set; + } + public abstract string P + { + get; + } + public abstract int this[int index] + { + get; + internal protected set; + } + public event Event E; + public static A operator +(A first, A second) + { + return first.Add(second); + } + fixed int field[10]; + class C + { + } + } + public interface I + { + void A(int value); + string Value + { + get; + set; + } + unsafe void UpdateSignatureByHashingContent([In]byte* buffer, int size); + } + [type: Flags] + public enum E + { + A, + B = A, + C = 2 + A, +#if DEBUG + D, + } +#else + E, + } +#endif + + + public delegate void Delegate(object P); + namespace Test + { + using System; + using System.Collections; + public class Список + { + public static IEnumerable Power(int number, int exponent) + { + Список Список = new Список(); + Список.Main(); + int counter = (0 + 0); + int אתר = 0; + while (++counter++ < --exponent--) + { + result = result * number + +number+++++number; + yield return result; + } + } + static void Main() + { + foreach (int i in Power(2, 8)) + { + Console.Write("{0} ", i); + } + } + async void Wait() + { + await System.Threading.Tasks.Task.Delay(0); + } + void AsyncAnonymous() // C # 5 feature + { + var task = Task.Factory.StartNew(async () => + { + return await new WebClient().DownloadStringTaskAsync("http://example.com"); + }); + } + } + } +} + +namespace ConsoleApplication1 +{ + namespace RecursiveGenericBaseType + { + class A : B, A> where T : A + { + protected virtual A M() { } + protected abstract B, A> N() { } + static B, A> O() { } + } + + sealed class B : A> + { + protected override A M() { } + protected sealed override B, A> N() { } + new static A O() { } + } + } + + namespace Boo + { + public class Bar where T : IComparable + { + public T f; + public class Foo : IEnumerable + { + public void Method(K k, T t, U u) + where K : IList, IList, IList + where V : IList + { + A a; + M(A(5)); + } + }; + }; + }; + + class Test + { + void Bar3() + { + var x = new Boo.Bar.Foo(); + x.Method(" ", 5, new object()); + + var q = from i in new int[] { 1, 2, 3, 4 } + where i > 5 + select i; + } + + public static implicit operator Test(string s) + { + return new ConsoleApplication1.Test(); + } + public static explicit operator Test(string s = "") + { + return new Test(); + } + + public int foo = 5; + void Bar2() + { + foo = 6; + this.Foo = 5.GetType(); Test t = "sss"; + } + + public event EventHandler MyEvent = delegate { }; + + void Blah() + { + int i = 5; + int? j = 6; + + Expression> e = () => i; + Expression> e2 = b => () => { return; }; + Func f = async delegate (bool a) + { + return await !a; + }; + Func f2 = (a, b) => 0; + f2 = (int a, int b) => 1; + Action a = Blah; + f2 = () => {}; + f2 = () => {;}; + } + + delegate Recursive Recursive(Recursive r); + delegate Recursive Recursive(Recursive r); + + public Type Foo + { + [Obsolete("Name", error = false)] + get + { + var result = typeof(IEnumerable); + var t = typeof(int?) == typeof(Nullable); + t = typeof(IEnumerable); + return typeof(IEnumerable<>); + } + set + { + var t = typeof(System.Int32); + t.ToString(); + t = value; + } + } + + public void Constants() + { + int i = 1 + 2 + 3 + 5; + global::System.String s = "a" + (System.String)"a" + "a" + "a" + "a" + "A"; + } + + public void ConstructedType() + { + List i = null; + int c = i.Count; + } + } +} + +namespace Comments.XmlComments.UndocumentedKeywords +{ + /// + /// Whatever + /// + /// + /// // + /// /* */ + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + class /*///*/C + { + void M(T t, U u) + { + // comment + /* *** / */ + /* // + */ + /*s*///comment + // /***/ + /*s*/int /*s*/intValue = 0; + intValue = intValue /*s*/+ 1; + string strValue = /*s*/"hello"; + /*s*/MyClass c = new MyClass(); + string verbatimStr = /*s*/@"\\\\"; + } + } + + //General Test F. Type a very long class name, verify colorization happens correctly only upto the correct size (118324) + class TestClassXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/*Scen8*/{ } + + class TestClassXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX22/*Scen9*/{ } + + class yield + { + void Foo(__arglist) + { + C c = null; + c.M(5, default(U)); + TypedReference tr = __makeref(c); + Type t = __reftype(tr); + int j = __refvalue(tr, int); + Params(a: t, b: t); + Params(ref c, out c); + } + void Params(ref dynamic a, out dynamic b, params dynamic[] c) {} + void Params(out dynamic a = 2, ref dynamic c = default(dynamic), params dynamic[][] c) {} + + public override string ToString() { return base.ToString(); } + + public partial void OnError(); + + public partial void method() + { + int?[] a = new int?[5];/*[] bug*/ // YES [] + int[] var = { 1, 2, 3, 4, 5 };/*,;*/ + int i = a[i];/*[]*/ + Foo f = new Foo();/*<> ()*/ + f.method();/*().*/ + i = i + i - i * i / i % i & i | i ^ i;/*+ - * / % & | ^*/ + bool b = true & false | true ^ false;/*& | ^*/ + b = !b;/*!*/ + i = ~i;/*~i*/ + b = i < i && i > i;/*< && >*/ + int? ii = 5;/*? bug*/ // NO ? + int f = true ? 1 : 0;/*? :*/ // YES : + i++;/*++*/ + i--;/*--*/ + b = true && false || true;/*&& ||*/ + i << 5;/*<<*/ + i >> 5;/*>>*/ + b = i == i && i != i && i <= i && i >= i;/*= == && != <= >=*/ + i += 5.0;/*+=*/ + i -= i;/*-=*/ + i *= i;/**=*/ + i /= i;/*/=*/ + i %= i;/*%=*/ + i &= i;/*&=*/ + i |= i;/*|=*/ + i ^= i;/*^=*/ + i <<= i;/*<<=*/ + i >>= i;/*>>=*/ + object s = x => x + 1;/*=>*/ + double d = .3; + Point point; + unsafe + { + Point* p = &point;/** &*/ + p->x = 10;/*->*/ + } + IO::BinaryReader br = null; + x[i: 1] = 3; + x[i: 1, j: 5] = "str"; + } + + struct Point { public int X; public int Y; public void ThisAccess() { this = this; } } + } + + // From here:https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6 + class CSharp6Features + { + // Initializers for auto-properties + public string First { get; set; } = "Jane"; + public string Last { get; set; } = "Doe"; + + // Getter-only auto-properties + public string Third { get; } = "Jane"; + public string Fourth { get; } = "Doe"; + + // Expression bodies on method-like members + public Point Move(int dx, int dy) => new Point(x + dx, y + dy); + public static Complex operator +(Complex a, Complex b) => a.Add(b); + public static implicit operator string(Person p) => p.First + " " + p.Last; + public void Print() => Console.WriteLine(First + " " + Last); + + // Expression bodies on property-like function members + public string Name => First + " " + Last; + public int this[long id] => id; + + async void Test() + { + // Using static + WriteLine(Sqrt(3*3 + 4*4)); + WriteLine(Friday - Monday); + var range = Range(5, 17); // Ok: not extension + var even = range.Where(i => i % 2 == 0); // Ok + + // Null-conditional operators + int? length = customers?.Length; // null if customers is null + Customer first = customers?[0]; // null if customers is null + int length = customers?.Length ?? 0; // 0 if customers is null + int? first = customers?[0]?.Orders?.Count(); + PropertyChanged?.Invoke(this, args); + + // String interpolation + string s = $"{p.Name, 20} is {p.Age:D3} year{{s}} old #"; + s = $"{p.Name} is \"{p.Age} year{(p.Age == 1 ? "" : "s")} old"; + s = $"{(p.Age == 2 ? $"{new Person { } }" : "")}"; + s = $@"\{p.Name} + ""\"; + s = $"Color [ R={func(b: 3):#0.##}, G={G:#0.##}, B={B:#0.##}, A={A:#0.##} ]"; + + // nameof expressions + if (x == null) + throw new ArgumentNullException(nameof(x)); + WriteLine(nameof(person.Address.ZipCode)); // prints "ZipCode" + + // Index initializers + var numbers = new Dictionary { + [7] = "seven", + [9] = "nine", + [13] = "thirteen" + }; + + // Exception filters + try {} + catch (MyException e) when (myfilter(e)) + { } + + // Await in catch and finally blocks + Resource res = null; + try + { + res = await Resource.OpenAsync(); // You could do this. + } + catch(ResourceException e) + { + await Resource.LogAsync(res, e); // Now you can do this … + } + finally + { + if (res != null) + await res.CloseAsync(); // … and this. + } + } + } +} +#line 6 +#line 2 "test.cs" +#line default +#line hidden + +class CSharp70 +{ + void PatternMatching(string arg, int b) + { + switch (arg) + { + case "A" when b > 50: + case "B" when b < 50: + default: + break; + } + + (A D, E H) = e; + + if (x?.y?.z is Type value2) + { + // code using value + } + + if (expr is Type v) { Hello(); } + } + + public static async Task LocalFunctions(string[] args) + { + string Hello2(int i) + { + return args[i]; + } + + async Task Hello(T i) => await Task.FromResult(args[i]); + await Hello(1); + } + + public static void OutVar(string[] args) + { + int.TryParse(Hello(1), out var item); + int.TryParse(Hello(1), out int item); + } + + public void ThrowExpression() + { + var result = nullableResult ?? throw new NullReferenceException(); + } + + public void BinaryLiterals() + { + int nineteen = 0b10011; + } + + public void DigitSeparators() + { + int bin = 0b1001_1010_0001_0100; + int hex = 0x1b_a0_44_fe; + int dec = 33_554_432; + int weird = 1_2__3___4____5_____6______7_______8________9; + double real = 1_000.111_1e-1_000; + } +} + +class CSharp71 +{ + void DefaultWithoutTypeName(string content = default) + { + DefaultWithoutTypeName(default); + } + + void TupleRecognize(int a, (int, int) b, (int, int, int)? c) + { + var result = list.Select(c => (c.f1, f3: c.f2)).Where(t => t.f2 == 1); + } +} + +class CSharp72 +{ + readonly struct ReadonlyRef1 + { + Func s = (in int x) => x; + ref TValue this[in TKey index] => null; + public static Vector3 operator+(in Vector3 x, in Vector3 y) => null; + + static readonly ref Vector3 M1_Trace() + { + // OK + ref readonly var r1 = ref M1(); + + // Not valid. Need an LValue + ref readonly Vector3 r2 = ref default(Vector3); + + // Not valid. r1 is readonly. + Mutate(ref r1); + + // OK. + Print(in r1); + + // OK. + return ref r1; + } + } + + ref struct ReadonlyRef2 + { + ref readonly Guid Test(in Vector3 v1, in Vector3 v2) + { + // not OK!! + v1 = default(Vector3); + + // not OK!! + v1.X = 0; + + // not OK!! + foo(ref v1.X); + + return ref (arr != null ? ref arr[0]: ref otherArr[0]); + + Span span = stackalloc int[1]; + + // OK + return new Vector3(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z); + } + + ref T Choice(bool condition, ref T consequence, ref T alternative) + { + if (condition) + { + return ref consequence; + } + else + { + return ref alternative; + } + } + } + + public void DoSomething(bool isEmployed, string personName, int personAge) { } + + public void NonTrailingNamedArguments() + { + DoSomething(isEmployed:true, name, age); // currently CS1738, but would become legal + DoSomething(true, personName:name, age); // currently CS1738, but would become legal + DoSomething(name, isEmployed:true, age); // remains illegal + DoSomething(name, age, isEmployed:true); // remains illegal + DoSomething(true, personAge:age, personName:name); // already legal + } + + public void ConditionalRef() + { + ref var r = ref (arr != null ? ref arr[0]: ref otherArr[0]); + } + + public void LeadingSeparator() + { + var res = 0 + + 123 // permitted in C# 1.0 and later + + 1_2_3 // permitted in C# 7.0 and later + + 0x1_2_3 // permitted in C# 7.0 and later + + 0b101 // binary literals added in C# 7.0 + + 0b1_0_1 // permitted in C# 7.0 and later + + // in C# 7.2, _ is permitted after the `0x` or `0b` + + 0x_1_2 // permitted in C# 7.2 and later + + 0b_1_0_1 // permitted in C# 7.2 and later + ; + } +} + +class CSharp73 +{ + void Blittable(T value) where T : unmanaged + { + var unmanaged = 666; + } + + unsafe struct IndexingMovableFixed + { + public fixed int myFixedField[10]; + } + + static IndexingMovableFixed s; + + public unsafe void IndexingMovableFixedFields() + { + int* ptr = s.myFixedField; + int t = s.myFixedField[5]; + } + + public void PatternBasedFixed() + { + fixed(byte* ptr = byteArray) + { + // ptr is a native pointer to the first element of the array + // byteArray is protected from being moved/collected by the GC for the duration of this block + } + } + + public void StackallocArrayInitializer() + { + Span a = stackalloc int[3]; // currently allowed + Span a = stackalloc int[3] { 1, 2, 3 }; + Span a = stackalloc int[] { 1, 2, 3 }; + Span a = stackalloc[] { 1, 2, 3 }; + } + + public void TupleEquality() + { + (int, (int, int)) t1, t2; + var res = t1 == (1, (2, 3)); + } +} + +namespace CSharp80 +{ + class CSharp80ExceptInterfaceDefaultImplement + { + void ReferenceNullable() + { + var? x = E; + x!.ToString(); + string? wtf = null; + int?[]? hello; + } + + void Patterns() + { + if (o is string { Length: 5 } s) Do(); + + return lang.CountOfTokens switch + { + 1 => 100, + 2 => 200, + _ => throw new global::System.Exception() + }; + + var newState = (GetState(), action, hasKey) switch + { + (DoorState.Closed, Action.Open, _) => DoorState.Opened, + (DoorState.Opened, Action.Close, _) => DoorState.Closed, + (DoorState.Closed, Action.Lock, true) => DoorState.Locked, + (DoorState.Locked, Action.Unlock, true) => DoorState.Closed, + (var state, _, _) => state + }; + } + + async Task AsyncStreams() + { + await foreach (var item in asyncEnumerables) + { + } + } + + void Ranges() + { + var thirdItem = list[2]; // list[2] + var lastItem = list[^1]; // list[Index.CreateFromEnd(1)] + var multiDimensional = list[3, ^2]; // list[3, Index.CreateFromEnd(2)] + + var slice1 = list[2..^3]; // list[Range.Create(2, Index.CreateFromEnd(3))] + var slice2 = list[..^3]; // list[Range.ToEnd(Index.CreateFromEnd(3))] + var slice3 = list[2..]; // list[Range.FromStart(2)] + var slice4 = list[..]; // list[Range.All] + var multiDimensional = list[1..2, ..]; // list[Range.Create(1, 2), Range.All] + } + + void UsingDeclarators() + { + using var item = new FileStream("./.f"); + fixed char* ch = "hell"; + item.Dispose(); // no! + } + + void StaticLocalFunction() + { + static unsafe void Func1() {} + static unsafe void Func1() {} + async static void Func2() {} + static async void Func2() {} + } + + void NullCoalescingAssignment() + { + var item = a ??= b ??= c ??= d ??= throw new Exception(); + } + + public readonly float Hello() + { + return 0.1f; + } + } + + interface IA + { + void M() { WriteLine("IA.M"); } + } + + interface IA + { + void M() { WriteLine("IA.M"); } + } + + interface IB : IA + { + override void IA.M() { WriteLine("IB.M"); } // explicitly named + } + + interface IC : IA + { + override void M() { WriteLine("IC.M"); } // implicitly named + } +} \ No newline at end of file diff --git a/_tests/grammars-v4/csharp/pom.xml b/_tests/grammars-v4/csharp/pom.xml new file mode 100644 index 000000000..b3e488c86 --- /dev/null +++ b/_tests/grammars-v4/csharp/pom.xml @@ -0,0 +1,58 @@ + + 4.0.0 + csharp + jar + C# grammar + + org.antlr.grammars + grammarsv4 + 1.0-SNAPSHOT + + + + + org.antlr + antlr4-maven-plugin + ${antlr.version} + + ${basedir} + + CSharpLexer.g4 + CSharpPreprocessorParser.g4 + CSharpParser.g4 + + true + true + + + + + antlr4 + + + + + + com.khubla.antlr + antlr4test-maven-plugin + ${antlr4test-maven-plugin.version} + + false + false + compilation_unit + CSharp + + examples/ + + + + + test + + + + + + + diff --git a/src/trgen/Command.cs b/src/trgen/Command.cs index e4ef661f3..8507e158f 100644 --- a/src/trgen/Command.cs +++ b/src/trgen/Command.cs @@ -418,11 +418,11 @@ private void ModifyWithGrammarParse(Config config) top_level_lexer_grammar = all.First(); } - // Pick all top-level grammars, which are passed through Antlr Tool. - test.tool_grammar_tuples = new List(); - if (top_level_lexer_grammar.GrammarName != top_level_parser_grammar.GrammarName) - test.tool_grammar_tuples.Add(top_level_lexer_grammar); - test.tool_grammar_tuples.Add(top_level_parser_grammar); + // Pick from all top-level grammars, + // the grammars that are tested. Other top level grammars + // are still processed by the Antlr Tool but not tested + // for parsing, e.g., grammars-v4/csharp. + if (test.start_rule == null) { var b = test.tool_grammar_tuples diff --git a/src/trgen/Properties/launchSettings.json b/src/trgen/Properties/launchSettings.json index 7dc48784d..232b36dab 100644 --- a/src/trgen/Properties/launchSettings.json +++ b/src/trgen/Properties/launchSettings.json @@ -2,8 +2,8 @@ "profiles": { "dotnet-antlr": { "commandName": "Project", - "commandLineArgs": "-t Antlr4ng", - "workingDirectory": "C:\\Users\\Kenne\\Documents\\GitHub\\Trash\\_tests\\grammars-v4\\glsl" + "commandLineArgs": "-t Java", + "workingDirectory": "C:\\msys64\\home\\Kenne\\issues\\g4-test-for-ambiguity\\csharp" } } } \ No newline at end of file From c3a413dff99ea3ba2f50576eced739ffe735b622 Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Tue, 8 Oct 2024 07:12:09 -0400 Subject: [PATCH 12/18] Fix clean and install. --- _scripts/install-local.sh | 2 +- _scripts/uninstall-local.sh | 1 + makefile | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/_scripts/install-local.sh b/_scripts/install-local.sh index 89b1127aa..963d2a837 100644 --- a/_scripts/install-local.sh +++ b/_scripts/install-local.sh @@ -1,6 +1,6 @@ #!/usr/bin/bash set -x -dotnet new tool-manifest +dotnet new tool-manifest --force cd src dirs=`find . -name net8.0 | fgrep 'bin/Release' | fgrep -v Generated | grep '^./tr' | fgrep -v publish | sort -u` for i in $dirs diff --git a/_scripts/uninstall-local.sh b/_scripts/uninstall-local.sh index 6a2a59b50..5ad6f24ae 100644 --- a/_scripts/uninstall-local.sh +++ b/_scripts/uninstall-local.sh @@ -18,3 +18,4 @@ do dotnet tool uninstall $tool popd done +dotnet nuget locals all --clear diff --git a/makefile b/makefile index 0b4dd19ea..004062326 100644 --- a/makefile +++ b/makefile @@ -14,6 +14,7 @@ clean: -find . -name obj -type d -exec rm -rf '{}' ';' 2> /dev/null -find . -name bin -type d -exec rm -rf '{}' ';' 2> /dev/null -cd _tests; find . -name Generated -type d -exec rm -rf '{}' ';' 2> /dev/null + -dotnet nuget locals all --clear publish: bash _scripts/publish.sh From 436c9764513a3b6f7888e94fafbf969e8962b62a Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Tue, 8 Oct 2024 09:53:31 -0400 Subject: [PATCH 13/18] Since the top level parser and lexer were already picked, update other variables from that. --- src/trgen/Command.cs | 43 ++++++++++--------------------------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/src/trgen/Command.cs b/src/trgen/Command.cs index 8507e158f..dd0e9f59b 100644 --- a/src/trgen/Command.cs +++ b/src/trgen/Command.cs @@ -394,6 +394,7 @@ private void ModifyWithGrammarParse(Config config) // Pick top-level lexer grammar. GrammarTuple top_level_lexer_grammar = null; + { var all_lexers = test.tool_grammar_tuples.Where( @@ -504,39 +505,15 @@ private void ModifyWithGrammarParse(Config config) // Antlr tool, and the other to test the generated parser. string parser_src_grammar_file_name = null; string lexer_src_grammar_file_name = null; - foreach (var t in test.tool_grammar_tuples) - { - if (!t.IsTopLevel) continue; - if (t.WhatType == GrammarTuple.Type.Parser) - { - test.fully_qualified_parser_name = t.GrammarAutomName; - test.fully_qualified_go_parser_name = t.GrammarGoNewName; - parser_src_grammar_file_name = t.GrammarFileName; - test.parser_grammar_file_name = parser_src_grammar_file_name; - } - else if (t.WhatType == GrammarTuple.Type.Lexer) - { - test.fully_qualified_lexer_name = t.GrammarAutomName; - test.fully_qualified_go_lexer_name = t.GrammarGoNewName; - lexer_src_grammar_file_name = t.GrammarFileName; - test.lexer_grammar_file_name = lexer_src_grammar_file_name; - } - else if (t.WhatType == GrammarTuple.Type.Combined) - { - throw new Exception("Should not execute!"); - if (test.grammar_name == t.GrammarName) - { - test.fully_qualified_parser_name = t.GrammarAutomName + "Parser"; - test.fully_qualified_go_parser_name = t.GrammarGoNewName + "Parser"; - parser_src_grammar_file_name = test.fully_qualified_parser_name; - test.fully_qualified_lexer_name = t.GrammarAutomName + "Lexer"; - test.fully_qualified_go_lexer_name = t.GrammarGoNewName + "Lexer"; - lexer_src_grammar_file_name = test.fully_qualified_lexer_name; - test.lexer_grammar_file_name = lexer_src_grammar_file_name; - test.parser_grammar_file_name = parser_src_grammar_file_name; - } - } - } + + test.fully_qualified_parser_name = top_level_parser_grammar.GrammarAutomName; + test.fully_qualified_go_parser_name = top_level_parser_grammar.GrammarGoNewName; + parser_src_grammar_file_name = top_level_parser_grammar.GrammarFileName; + test.parser_grammar_file_name = parser_src_grammar_file_name; + test.fully_qualified_lexer_name = top_level_lexer_grammar.GrammarAutomName; + test.fully_qualified_go_lexer_name = top_level_lexer_grammar.GrammarGoNewName; + lexer_src_grammar_file_name = top_level_lexer_grammar.GrammarFileName; + test.lexer_grammar_file_name = lexer_src_grammar_file_name; // Where the parser generated code lives. test.tool_src_grammar_files = new HashSet() From 580ce658b569e665206361f39e9e237461f5c626 Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Tue, 8 Oct 2024 20:03:27 -0400 Subject: [PATCH 14/18] Double-minus not required, and not recognized. --- src/trgen/templates/Antlr4ng/st.perf.sh | 4 +- src/trgen/templates/Antlr4ng/st.test.ps1 | 8 +-- src/trgen/templates/Antlr4ng/st.test.sh | 6 +-- src/trgen/templates/CSharp/st.perf.sh | 4 +- .../templates/CSharp/st.test-ambiguity.sh | 49 +++++++++++++++++++ src/trgen/templates/CSharp/st.test-cover.sh | 6 +-- src/trgen/templates/CSharp/st.test.ps1 | 8 +-- src/trgen/templates/CSharp/st.test.sh | 8 +-- src/trgen/templates/Cpp/st.perf.sh | 4 +- src/trgen/templates/Cpp/st.test.ps1 | 8 +-- src/trgen/templates/Cpp/st.test.sh | 8 +-- src/trgen/templates/Dart/st.perf.sh | 2 +- src/trgen/templates/Dart/st.test.ps1 | 8 +-- src/trgen/templates/Dart/st.test.sh | 8 +-- src/trgen/templates/Go/st.perf.sh | 4 +- src/trgen/templates/Go/st.test.ps1 | 8 +-- src/trgen/templates/Go/st.test.sh | 8 +-- src/trgen/templates/Java/st.perf.sh | 4 +- src/trgen/templates/Java/st.test.ps1 | 8 +-- src/trgen/templates/Java/st.test.sh | 8 +-- .../templates/JavaScript/st.package.json | 2 +- src/trgen/templates/JavaScript/st.perf.sh | 4 +- src/trgen/templates/JavaScript/st.test.ps1 | 8 +-- src/trgen/templates/JavaScript/st.test.sh | 8 +-- src/trgen/templates/PHP/st.perf.sh | 4 +- src/trgen/templates/PHP/st.test.ps1 | 8 +-- src/trgen/templates/PHP/st.test.sh | 8 +-- src/trgen/templates/Python3/st.perf.sh | 4 +- src/trgen/templates/Python3/st.test.ps1 | 8 +-- src/trgen/templates/Python3/st.test.sh | 8 +-- src/trgen/templates/TypeScript/st.perf.sh | 4 +- src/trgen/templates/TypeScript/st.test.ps1 | 8 +-- src/trgen/templates/TypeScript/st.test.sh | 8 +-- 33 files changed, 151 insertions(+), 102 deletions(-) create mode 100644 src/trgen/templates/CSharp/st.test-ambiguity.sh diff --git a/src/trgen/templates/Antlr4ng/st.perf.sh b/src/trgen/templates/Antlr4ng/st.perf.sh index cd825ec64..04fe12965 100644 --- a/src/trgen/templates/Antlr4ng/st.perf.sh +++ b/src/trgen/templates/Antlr4ng/st.perf.sh @@ -6,12 +6,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) diff --git a/src/trgen/templates/Antlr4ng/st.test.ps1 b/src/trgen/templates/Antlr4ng/st.test.ps1 index d3f263827..8b47f2dbb 100644 --- a/src/trgen/templates/Antlr4ng/st.test.ps1 +++ b/src/trgen/templates/Antlr4ng/st.test.ps1 @@ -10,7 +10,7 @@ if (Test-Path -Path "tests.txt" -PathType Leaf) { Remove-Item "tests.txt" } $files = New-Object System.Collections.Generic.List[string] -$allFiles = $(& dotnet trglob -- "$Tests" ; $last = $LASTEXITCODE ) +$allFiles = $(& dotnet trglob "$Tests" ; $last = $LASTEXITCODE ) foreach ($file in $allFiles) { $ext = $file | Split-Path -Extension if (Test-Path $file -PathType Container) { @@ -20,7 +20,7 @@ foreach ($file in $allFiles) { } elseif ($ext -eq ".tree") { continue } else { - $(& dotnet triconv -- -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null + $(& dotnet triconv -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null if ($last -ne 0) { continue @@ -40,10 +40,10 @@ if (-not(Test-Path -Path "tests.txt" -PathType Leaf)) { # Parse all input files. # Individual parsing. -Get-Content "tests.txt" | ForEach-Object { dotnet trwdog -- pwsh -command "npx tsx Test.js -q -tee -tree $_" *>> parse.txt } +Get-Content "tests.txt" | ForEach-Object { dotnet trwdog pwsh -command "npx tsx Test.js -q -tee -tree $_" *>> parse.txt } # Group parsing. -get-content "tests.txt" | dotnet trwdog -- pwsh -command "npx tsx Test.js -q -x -tee -tree" *> parse.txt +get-content "tests.txt" | dotnet trwdog pwsh -command "npx tsx Test.js -q -x -tee -tree" *> parse.txt $status=$LASTEXITCODE diff --git a/src/trgen/templates/Antlr4ng/st.test.sh b/src/trgen/templates/Antlr4ng/st.test.sh index c4cb4c720..101b39657 100644 --- a/src/trgen/templates/Antlr4ng/st.test.sh +++ b/src/trgen/templates/Antlr4ng/st.test.sh @@ -9,7 +9,7 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do @@ -36,7 +36,7 @@ fi rm -f parse.txt for f in ${files[*]} do - dotnet trwdog -- sh -c "npx tsx Test.js -q -tee -tree $f" >> parse.txt 2>&1 + dotnet trwdog sh -c "npx tsx Test.js -q -tee -tree $f" >> parse.txt 2>&1 xxx="$?" if [ "$xxx" -ne 0 ] then @@ -45,7 +45,7 @@ do done # Group parsing. -echo "${files[*]}" | dotnet trwdog -- sh -c "npx tsx Test.js -q -x -tee -tree" > parse.txt 2>&1 +echo "${files[*]}" | dotnet trwdog sh -c "npx tsx Test.js -q -x -tee -tree" > parse.txt 2>&1 status="$?" diff --git a/src/trgen/templates/CSharp/st.perf.sh b/src/trgen/templates/CSharp/st.perf.sh index 610d8e625..2efdfbd4a 100644 --- a/src/trgen/templates/CSharp/st.perf.sh +++ b/src/trgen/templates/CSharp/st.perf.sh @@ -6,12 +6,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) diff --git a/src/trgen/templates/CSharp/st.test-ambiguity.sh b/src/trgen/templates/CSharp/st.test-ambiguity.sh new file mode 100644 index 000000000..2fe446b67 --- /dev/null +++ b/src/trgen/templates/CSharp/st.test-ambiguity.sh @@ -0,0 +1,49 @@ +# Generated from trgen + +SAVEIFS=$IFS +IFS=$(echo -en "\n\b") + +# Get a list of test files from the test directory. Do not include any +# .errors or .tree files. Pay close attention to remove only file names +# that end with the suffix .errors or .tree. +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` +files=() +for f in $files2 +do + if [ -d "$f" ]; then continue; fi + dotnet triconv -f utf-8 $f > /dev/null 2>&1 + if [ "$?" = "0" ] + then + files+=( $f ) + fi +done + +# People often specify a test file directory, but sometimes no +# tests are provided. Git won't check in an empty directory. +# Test if there are no test files. +if [ ${#files[@]} -eq 0 ] +then + echo "No test cases provided." + exit 0 +fi + +# Parse all input files. + +# Individual parsing: NOT SUPPORTED! + +# Group parsing. +echo "${files[*]}" | dotnet trwdog dotnet trperf -x -c ar | grep -v '^0' | awk '{print $2}' | sort -u +status=$? + + +# trwdog returns 255 if it cannot spawn the process. This could happen +# if the environment for running the program does not exist, or the +# program did not build. +if [ "$status" = "255" ] +then + echo "Test failed." + exit 1 +fi + +rm -f $old/updated.txt $old/new_errors2.txt $old/new_errors.txt +exit 0 diff --git a/src/trgen/templates/CSharp/st.test-cover.sh b/src/trgen/templates/CSharp/st.test-cover.sh index 518b9dff1..e455c90be 100644 --- a/src/trgen/templates/CSharp/st.test-cover.sh +++ b/src/trgen/templates/CSharp/st.test-cover.sh @@ -6,12 +6,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) @@ -32,7 +32,7 @@ fi # Individual parsing: NOT SUPPORTED! # Group parsing. -echo "${files[*]}" | dotnet trwdog -- dotnet trcover -- -x +echo "${files[*]}" | dotnet trwdog dotnet trcover -x status=$? diff --git a/src/trgen/templates/CSharp/st.test.ps1 b/src/trgen/templates/CSharp/st.test.ps1 index ad64a9357..2eda70c71 100644 --- a/src/trgen/templates/CSharp/st.test.ps1 +++ b/src/trgen/templates/CSharp/st.test.ps1 @@ -10,7 +10,7 @@ if (Test-Path -Path "tests.txt" -PathType Leaf) { Remove-Item "tests.txt" } $files = New-Object System.Collections.Generic.List[string] -$allFiles = $(& dotnet trglob -- "$Tests" ; $last = $LASTEXITCODE ) +$allFiles = $(& dotnet trglob "$Tests" ; $last = $LASTEXITCODE ) foreach ($file in $allFiles) { $ext = $file | Split-Path -Extension if (Test-Path $file -PathType Container) { @@ -20,7 +20,7 @@ foreach ($file in $allFiles) { } elseif ($ext -eq ".tree") { continue } else { - $(& dotnet triconv -- -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null + $(& dotnet triconv -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null if ($last -ne 0) { continue @@ -40,10 +40,10 @@ if (-not(Test-Path -Path "tests.txt" -PathType Leaf)) { # Parse all input files. # Individual parsing. -Get-Content "tests.txt" | ForEach-Object { dotnet trwdog -- ./bin/Debug/net8.0/Test.exeTest -q -tee -tree $_ *>> parse.txt } +Get-Content "tests.txt" | ForEach-Object { dotnet trwdog ./bin/Debug/net8.0/Test.exeTest -q -tee -tree $_ *>> parse.txt } # Group parsing. -get-content "tests.txt" | dotnet trwdog -- ./bin/Debug/net8.0/Test.exeTest -q -x -tee -tree *> parse.txt +get-content "tests.txt" | dotnet trwdog ./bin/Debug/net8.0/Test.exeTest -q -x -tee -tree *> parse.txt $status = $LASTEXITCODE diff --git a/src/trgen/templates/CSharp/st.test.sh b/src/trgen/templates/CSharp/st.test.sh index cc4f1aaef..b7cd9a3c2 100644 --- a/src/trgen/templates/CSharp/st.test.sh +++ b/src/trgen/templates/CSharp/st.test.sh @@ -9,12 +9,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) @@ -36,7 +36,7 @@ fi rm -f parse.txt for f in ${files[*]} do - dotnet trwdog -- ./bin/Debug/net8.0/Test.exeTest -q -tee -tree $f >> parse.txt 2>&1 + dotnet trwdog ./bin/Debug/net8.0/Test.exeTest -q -tee -tree $f >> parse.txt 2>&1 xxx="$?" if [ "$xxx" -ne 0 ] then @@ -45,7 +45,7 @@ do done # Group parsing. -echo "${files[*]}" | dotnet trwdog -- ./bin/Debug/net8.0/Test.exeTest -q -x -tee -tree > parse.txt 2>&1 +echo "${files[*]}" | dotnet trwdog ./bin/Debug/net8.0/Test.exeTest -q -x -tee -tree > parse.txt 2>&1 status=$? diff --git a/src/trgen/templates/Cpp/st.perf.sh b/src/trgen/templates/Cpp/st.perf.sh index b6c834659..e20ea1023 100644 --- a/src/trgen/templates/Cpp/st.perf.sh +++ b/src/trgen/templates/Cpp/st.perf.sh @@ -6,12 +6,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) diff --git a/src/trgen/templates/Cpp/st.test.ps1 b/src/trgen/templates/Cpp/st.test.ps1 index 4221bc201..80e51a05c 100644 --- a/src/trgen/templates/Cpp/st.test.ps1 +++ b/src/trgen/templates/Cpp/st.test.ps1 @@ -10,7 +10,7 @@ if (Test-Path -Path "tests.txt" -PathType Leaf) { Remove-Item "tests.txt" } $files = New-Object System.Collections.Generic.List[string] -$allFiles = $(& dotnet trglob -- "$Tests" ; $last = $LASTEXITCODE ) +$allFiles = $(& dotnet trglob "$Tests" ; $last = $LASTEXITCODE ) foreach ($file in $allFiles) { $ext = $file | Split-Path -Extension if (Test-Path $file -PathType Container) { @@ -20,7 +20,7 @@ foreach ($file in $allFiles) { } elseif ($ext -eq ".tree") { continue } else { - $(& dotnet triconv -- -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null + $(& dotnet triconv -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null if ($last -ne 0) { continue @@ -40,10 +40,10 @@ if (-not(Test-Path -Path "tests.txt" -PathType Leaf)) { # Parse all input files. # Individual parsing. -Get-Content "tests.txt" | ForEach-Object { dotnet trwdog -- ./build/Release/ -q -tee -tree $_ *>> parse.txt } +Get-Content "tests.txt" | ForEach-Object { dotnet trwdog ./build/Release/ -q -tee -tree $_ *>> parse.txt } # Group parsing. -get-content "tests.txt" | dotnet trwdog -- ./build/Release/ -q -x -tee -tree *> parse.txt +get-content "tests.txt" | dotnet trwdog ./build/Release/ -q -x -tee -tree *> parse.txt $status = $LASTEXITCODE diff --git a/src/trgen/templates/Cpp/st.test.sh b/src/trgen/templates/Cpp/st.test.sh index 1dc656802..69bcfb709 100644 --- a/src/trgen/templates/Cpp/st.test.sh +++ b/src/trgen/templates/Cpp/st.test.sh @@ -9,12 +9,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) @@ -36,7 +36,7 @@ fi rm -f parse.txt for f in ${files[*]} do - dotnet trwdog -- ./build/Release/ -q -tee -tree $f >> parse.txt + dotnet trwdog ./build/Release/ -q -tee -tree $f >> parse.txt xxx="$?" if [ "$xxx" -ne 0 ] then @@ -45,7 +45,7 @@ do done # Group parsing. -echo "${files[*]}" | dotnet trwdog -- ./build/Release/ -q -x -tee -tree > parse.txt 2>&1 +echo "${files[*]}" | dotnet trwdog ./build/Release/ -q -x -tee -tree > parse.txt 2>&1 status="$?" diff --git a/src/trgen/templates/Dart/st.perf.sh b/src/trgen/templates/Dart/st.perf.sh index 10e24bee7..f35662077 100644 --- a/src/trgen/templates/Dart/st.perf.sh +++ b/src/trgen/templates/Dart/st.perf.sh @@ -6,7 +6,7 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do diff --git a/src/trgen/templates/Dart/st.test.ps1 b/src/trgen/templates/Dart/st.test.ps1 index 8a602b6c0..7dc389328 100644 --- a/src/trgen/templates/Dart/st.test.ps1 +++ b/src/trgen/templates/Dart/st.test.ps1 @@ -10,7 +10,7 @@ if (Test-Path -Path "tests.txt" -PathType Leaf) { Remove-Item "tests.txt" } $files = New-Object System.Collections.Generic.List[string] -$allFiles = $(& dotnet trglob -- "$Tests" ; $last = $LASTEXITCODE ) +$allFiles = $(& dotnet trglob "$Tests" ; $last = $LASTEXITCODE ) foreach ($file in $allFiles) { $ext = $file | Split-Path -Extension if (Test-Path $file -PathType Container) { @@ -20,7 +20,7 @@ foreach ($file in $allFiles) { } elseif ($ext -eq ".tree") { continue } else { - $(& dotnet triconv -- -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null + $(& dotnet triconv -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null if ($last -ne 0) { continue @@ -40,10 +40,10 @@ if (-not(Test-Path -Path "tests.txt" -PathType Leaf)) { # Parse all input files. # Individual parsing. -Get-Content "tests.txt" | ForEach-Object { dotnet trwdog -- ./Test.exe -q -tee -tree $_ *>> parse.txt } +Get-Content "tests.txt" | ForEach-Object { dotnet trwdog ./Test.exe -q -tee -tree $_ *>> parse.txt } # Group parsing. -get-content "tests.txt" | dotnet trwdog -- ./Test.exe -q -x -tee -tree *> parse.txt +get-content "tests.txt" | dotnet trwdog ./Test.exe -q -x -tee -tree *> parse.txt $status = $LASTEXITCODE diff --git a/src/trgen/templates/Dart/st.test.sh b/src/trgen/templates/Dart/st.test.sh index 1cc792a40..6f366ecc3 100644 --- a/src/trgen/templates/Dart/st.test.sh +++ b/src/trgen/templates/Dart/st.test.sh @@ -9,12 +9,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) @@ -36,7 +36,7 @@ fi rm -f parse.txt for f in ${files[*]} do - dotnet trwdog -- ./Test.exe -q -tee -tree $f >> parse.txt + dotnet trwdog ./Test.exe -q -tee -tree $f >> parse.txt xxx="$?" if [ "$xxx" -ne 0 ] then @@ -45,7 +45,7 @@ do done # Group parsing. -echo "${files[*]}" | dotnet trwdog -- ./Test.exe -q -x -tee -tree > parse.txt 2>&1 +echo "${files[*]}" | dotnet trwdog ./Test.exe -q -x -tee -tree > parse.txt 2>&1 status=$? diff --git a/src/trgen/templates/Go/st.perf.sh b/src/trgen/templates/Go/st.perf.sh index 54dc17fa2..e87b094d2 100644 --- a/src/trgen/templates/Go/st.perf.sh +++ b/src/trgen/templates/Go/st.perf.sh @@ -6,12 +6,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) diff --git a/src/trgen/templates/Go/st.test.ps1 b/src/trgen/templates/Go/st.test.ps1 index 368a0cf1c..733b847ae 100644 --- a/src/trgen/templates/Go/st.test.ps1 +++ b/src/trgen/templates/Go/st.test.ps1 @@ -10,7 +10,7 @@ if (Test-Path -Path "tests.txt" -PathType Leaf) { Remove-Item "tests.txt" } $files = New-Object System.Collections.Generic.List[string] -$allFiles = $(& dotnet trglob -- "$Tests" ; $last = $LASTEXITCODE ) +$allFiles = $(& dotnet trglob "$Tests" ; $last = $LASTEXITCODE ) foreach ($file in $allFiles) { $ext = $file | Split-Path -Extension if (Test-Path $file -PathType Container) { @@ -20,7 +20,7 @@ foreach ($file in $allFiles) { } elseif ($ext -eq ".tree") { continue } else { - $(& dotnet triconv -- -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null + $(& dotnet triconv -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null if ($last -ne 0) { continue @@ -40,10 +40,10 @@ if (-not(Test-Path -Path "tests.txt" -PathType Leaf)) { # Parse all input files. # Individual parsing. -Get-Content "tests.txt" | ForEach-Object { dotnet trwdog -- ./Test.exeTest -q -tee -tree $_ *>> parse.txt } +Get-Content "tests.txt" | ForEach-Object { dotnet trwdog ./Test.exeTest -q -tee -tree $_ *>> parse.txt } # Group parsing. -get-content "tests.txt" | dotnet trwdog -- ./Test.exeTest -q -x -tee -tree *> parse.txt +get-content "tests.txt" | dotnet trwdog ./Test.exeTest -q -x -tee -tree *> parse.txt $status = $LASTEXITCODE diff --git a/src/trgen/templates/Go/st.test.sh b/src/trgen/templates/Go/st.test.sh index 42c5dc56b..cadc1c136 100644 --- a/src/trgen/templates/Go/st.test.sh +++ b/src/trgen/templates/Go/st.test.sh @@ -9,12 +9,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) @@ -36,7 +36,7 @@ fi rm -f parse.txt for f in ${files[*]} do - dotnet trwdog -- ./Test.exeTest -q -tee -tree $f >> parse.txt 2>&1 + dotnet trwdog ./Test.exeTest -q -tee -tree $f >> parse.txt 2>&1 xxx="$?" if [ "$xxx" -ne 0 ] then @@ -45,7 +45,7 @@ do done # Group parsing. -echo "${files[*]}" | dotnet trwdog -- ./Test.exeTest -q -x -tee -tree > parse.txt 2>&1 +echo "${files[*]}" | dotnet trwdog ./Test.exeTest -q -x -tee -tree > parse.txt 2>&1 status=$? diff --git a/src/trgen/templates/Java/st.perf.sh b/src/trgen/templates/Java/st.perf.sh index 1055bfcb3..d561946be 100644 --- a/src/trgen/templates/Java/st.perf.sh +++ b/src/trgen/templates/Java/st.perf.sh @@ -6,12 +6,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) diff --git a/src/trgen/templates/Java/st.test.ps1 b/src/trgen/templates/Java/st.test.ps1 index 650c50c6c..218d31de0 100644 --- a/src/trgen/templates/Java/st.test.ps1 +++ b/src/trgen/templates/Java/st.test.ps1 @@ -10,7 +10,7 @@ if (Test-Path -Path "tests.txt" -PathType Leaf) { Remove-Item "tests.txt" } $files = New-Object System.Collections.Generic.List[string] -$allFiles = $(& dotnet trglob -- "$Tests" ; $last = $LASTEXITCODE ) +$allFiles = $(& dotnet trglob "$Tests" ; $last = $LASTEXITCODE ) foreach ($file in $allFiles) { $ext = $file | Split-Path -Extension if (Test-Path $file -PathType Container) { @@ -20,7 +20,7 @@ foreach ($file in $allFiles) { } elseif ($ext -eq ".tree") { continue } else { - $(& dotnet triconv -- -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null + $(& dotnet triconv -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null if ($last -ne 0) { continue @@ -42,10 +42,10 @@ $version = Select-String -Path "build.sh" -Pattern "version=" | ForEach-Object { $JAR = python -c "import os; from pathlib import Path; print(os.path.join(Path.home(), '.m2', 'repository', 'org', 'antlr', 'antlr4', '$version', ('antlr4-' + '$version' + '-complete.jar')))" # Individual parsing. -Get-Content "tests.txt" | ForEach-Object { dotnet trwdog -- java -cp "$JAR;:." Test -q -tee -tree *>> parse.txt } +Get-Content "tests.txt" | ForEach-Object { dotnet trwdog java -cp "$JAR;:." Test -q -tee -tree *>> parse.txt } # Group parsing. -get-content "tests.txt" | dotnet trwdog -- java -cp "${JAR};:." Test -q -x -tee -tree *> parse.txt +get-content "tests.txt" | dotnet trwdog java -cp "${JAR};:." Test -q -x -tee -tree *> parse.txt $status = $LASTEXITCODE diff --git a/src/trgen/templates/Java/st.test.sh b/src/trgen/templates/Java/st.test.sh index f30887e53..6b5ba5d75 100644 --- a/src/trgen/templates/Java/st.test.sh +++ b/src/trgen/templates/Java/st.test.sh @@ -9,12 +9,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) @@ -39,7 +39,7 @@ CLASSPATH="$JAR\;:." rm -f parse.txt for f in ${files[*]} do - dotnet trwdog -- java -classpath "$CLASSPATH" Test -q -tee -tree $f >> parse.txt 2>&1 + dotnet trwdog java -classpath "$CLASSPATH" Test -q -tee -tree $f >> parse.txt 2>&1 xxx="$?" if [ "$xxx" -ne 0 ] then @@ -48,7 +48,7 @@ do done # Group parsing. -echo "${files[*]}" | dotnet trwdog -- java -classpath "$CLASSPATH" Test -q -x -tee -tree > parse.txt 2>&1 +echo "${files[*]}" | dotnet trwdog java -classpath "$CLASSPATH" Test -q -x -tee -tree > parse.txt 2>&1 status=$? diff --git a/src/trgen/templates/JavaScript/st.package.json b/src/trgen/templates/JavaScript/st.package.json index e61f7f35d..6534da5b0 100644 --- a/src/trgen/templates/JavaScript/st.package.json +++ b/src/trgen/templates/JavaScript/st.package.json @@ -9,7 +9,7 @@ "author": "", "license": "ISC", "dependencies": { - "antlr4": "4.13.1", + "antlr4": "4.13.2", "fs-extra": "^11.1.0", "timer-node": "^5.0.6", "typescript-string-operations": "^1.4.1" diff --git a/src/trgen/templates/JavaScript/st.perf.sh b/src/trgen/templates/JavaScript/st.perf.sh index 070c39141..548dbff66 100644 --- a/src/trgen/templates/JavaScript/st.perf.sh +++ b/src/trgen/templates/JavaScript/st.perf.sh @@ -6,12 +6,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) diff --git a/src/trgen/templates/JavaScript/st.test.ps1 b/src/trgen/templates/JavaScript/st.test.ps1 index c2d410de7..4ff0f9061 100644 --- a/src/trgen/templates/JavaScript/st.test.ps1 +++ b/src/trgen/templates/JavaScript/st.test.ps1 @@ -10,7 +10,7 @@ if (Test-Path -Path "tests.txt" -PathType Leaf) { Remove-Item "tests.txt" } $files = New-Object System.Collections.Generic.List[string] -$allFiles = $(& dotnet trglob -- "$Tests" ; $last = $LASTEXITCODE ) +$allFiles = $(& dotnet trglob "$Tests" ; $last = $LASTEXITCODE ) foreach ($file in $allFiles) { $ext = $file | Split-Path -Extension if (Test-Path $file -PathType Container) { @@ -20,7 +20,7 @@ foreach ($file in $allFiles) { } elseif ($ext -eq ".tree") { continue } else { - $(& dotnet triconv -- -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null + $(& dotnet triconv -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null if ($last -ne 0) { continue @@ -40,10 +40,10 @@ if (-not(Test-Path -Path "tests.txt" -PathType Leaf)) { # Parse all input files. # Individual parsing. -Get-Content "tests.txt" | ForEach-Object { dotnet trwdog -- node Test.js -q -tee -tree $_ *>> parse.txt } +Get-Content "tests.txt" | ForEach-Object { dotnet trwdog node Test.js -q -tee -tree $_ *>> parse.txt } # Group parsing. -get-content "tests.txt" | dotnet trwdog -- node Test.js -q -x -tee -tree *> parse.txt +get-content "tests.txt" | dotnet trwdog node Test.js -q -x -tee -tree *> parse.txt $status = $LASTEXITCODE diff --git a/src/trgen/templates/JavaScript/st.test.sh b/src/trgen/templates/JavaScript/st.test.sh index 92194bf68..6f0e54760 100644 --- a/src/trgen/templates/JavaScript/st.test.sh +++ b/src/trgen/templates/JavaScript/st.test.sh @@ -9,12 +9,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) @@ -36,7 +36,7 @@ fi rm -f parse.txt for f in ${files[*]} do - dotnet trwdog -- node Test.js -q -tee -tree $f >> parse.txt 2>&1 + dotnet trwdog node Test.js -q -tee -tree $f >> parse.txt 2>&1 xxx="$?" if [ "$xxx" -ne 0 ] then @@ -45,7 +45,7 @@ do done # Group parsing. -echo "${files[*]}" | dotnet trwdog -- node Test.js -q -x -tee -tree > parse.txt 2>&1 +echo "${files[*]}" | dotnet trwdog node Test.js -q -x -tee -tree > parse.txt 2>&1 status=$? diff --git a/src/trgen/templates/PHP/st.perf.sh b/src/trgen/templates/PHP/st.perf.sh index a62bc0022..5985518aa 100644 --- a/src/trgen/templates/PHP/st.perf.sh +++ b/src/trgen/templates/PHP/st.perf.sh @@ -6,12 +6,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' -type f | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' -type f | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) diff --git a/src/trgen/templates/PHP/st.test.ps1 b/src/trgen/templates/PHP/st.test.ps1 index 1baddff2a..a11c66199 100644 --- a/src/trgen/templates/PHP/st.test.ps1 +++ b/src/trgen/templates/PHP/st.test.ps1 @@ -10,7 +10,7 @@ if (Test-Path -Path "tests.txt" -PathType Leaf) { Remove-Item "tests.txt" } $files = New-Object System.Collections.Generic.List[string] -$allFiles = $(& dotnet trglob -- "$Tests" ; $last = $LASTEXITCODE ) +$allFiles = $(& dotnet trglob "$Tests" ; $last = $LASTEXITCODE ) foreach ($file in $allFiles) { $ext = $file | Split-Path -Extension if (Test-Path $file -PathType Container) { @@ -20,7 +20,7 @@ foreach ($file in $allFiles) { } elseif ($ext -eq ".tree") { continue } else { - $(& dotnet triconv -- -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null + $(& dotnet triconv -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null if ($last -ne 0) { continue @@ -40,10 +40,10 @@ if (-not(Test-Path -Path "tests.txt" -PathType Leaf)) { # Parse all input files. # Individual parsing. -Get-Content "tests.txt" | ForEach-Object { dotnet trwdog -- php -d memory_limit=1G Test.php -q -tee -tree $_ *>> parse.txt } +Get-Content "tests.txt" | ForEach-Object { dotnet trwdog php -d memory_limit=1G Test.php -q -tee -tree $_ *>> parse.txt } # Group parsing. -get-content "tests.txt" | dotnet trwdog -- php -d memory_limit=1G Test.php -q -x -tee -tree *> parse.txt +get-content "tests.txt" | dotnet trwdog php -d memory_limit=1G Test.php -q -x -tee -tree *> parse.txt $status = $LASTEXITCODE diff --git a/src/trgen/templates/PHP/st.test.sh b/src/trgen/templates/PHP/st.test.sh index c78c6b521..0b60544ae 100644 --- a/src/trgen/templates/PHP/st.test.sh +++ b/src/trgen/templates/PHP/st.test.sh @@ -9,12 +9,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) @@ -36,7 +36,7 @@ fi rm -f parse.txt for f in ${files[*]} do - dotnet trwdog -- php -d memory_limit=1G Test.php -q -tee -tree $f >> parse.txt 2>&1 + dotnet trwdog php -d memory_limit=1G Test.php -q -tee -tree $f >> parse.txt 2>&1 xxx="$?" if [ "$xxx" -ne 0 ] then @@ -45,7 +45,7 @@ do done # Group parsing. -echo "${files[*]}" | dotnet trwdog -- php -d memory_limit=1G Test.php -q -x -tee -tree > parse.txt 2>&1 +echo "${files[*]}" | dotnet trwdog php -d memory_limit=1G Test.php -q -x -tee -tree > parse.txt 2>&1 status=$? diff --git a/src/trgen/templates/Python3/st.perf.sh b/src/trgen/templates/Python3/st.perf.sh index e988aae66..838b40cc6 100644 --- a/src/trgen/templates/Python3/st.perf.sh +++ b/src/trgen/templates/Python3/st.perf.sh @@ -6,12 +6,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) diff --git a/src/trgen/templates/Python3/st.test.ps1 b/src/trgen/templates/Python3/st.test.ps1 index e90afbbc4..74189fb76 100644 --- a/src/trgen/templates/Python3/st.test.ps1 +++ b/src/trgen/templates/Python3/st.test.ps1 @@ -10,7 +10,7 @@ if (Test-Path -Path "tests.txt" -PathType Leaf) { Remove-Item "tests.txt" } $files = New-Object System.Collections.Generic.List[string] -$allFiles = $(& dotnet trglob -- "$Tests" ; $last = $LASTEXITCODE ) +$allFiles = $(& dotnet trglob "$Tests" ; $last = $LASTEXITCODE ) foreach ($file in $allFiles) { $ext = $file | Split-Path -Extension if (Test-Path $file -PathType Container) { @@ -20,7 +20,7 @@ foreach ($file in $allFiles) { } elseif ($ext -eq ".tree") { continue } else { - $(& dotnet triconv -- -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null + $(& dotnet triconv -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null if ($last -ne 0) { continue @@ -40,10 +40,10 @@ if (-not(Test-Path -Path "tests.txt" -PathType Leaf)) { # Parse all input files. # Individual parsing. -Get-Content "tests.txt" | ForEach-Object { dotnet trwdog -- python3 Test.py -q -tee -tree $_ *>> parse.txt } +Get-Content "tests.txt" | ForEach-Object { dotnet trwdog python3 Test.py -q -tee -tree $_ *>> parse.txt } # Group parsing. -get-content "tests.txt" | dotnet trwdog -- python3 Test.py -q -x -tee -tree *> parse.txt +get-content "tests.txt" | dotnet trwdog python3 Test.py -q -x -tee -tree *> parse.txt $status = $LASTEXITCODE diff --git a/src/trgen/templates/Python3/st.test.sh b/src/trgen/templates/Python3/st.test.sh index ca573cbfc..8a5661c69 100644 --- a/src/trgen/templates/Python3/st.test.sh +++ b/src/trgen/templates/Python3/st.test.sh @@ -9,12 +9,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) @@ -36,7 +36,7 @@ fi rm -f parse.txt for f in ${files[*]} do - dotnet trwdog -- python3 Test.py -q -tee -tree $f >> parse.txt 2>&1 + dotnet trwdog python3 Test.py -q -tee -tree $f >> parse.txt 2>&1 xxx="$?" if [ "$xxx" -ne 0 ] then @@ -45,7 +45,7 @@ do done # Group parsing. -echo "${files[*]}" | dotnet trwdog -- python3 Test.py -q -x -tee -tree > parse.txt 2>&1 +echo "${files[*]}" | dotnet trwdog python3 Test.py -q -x -tee -tree > parse.txt 2>&1 status=$? diff --git a/src/trgen/templates/TypeScript/st.perf.sh b/src/trgen/templates/TypeScript/st.perf.sh index cd825ec64..04fe12965 100644 --- a/src/trgen/templates/TypeScript/st.perf.sh +++ b/src/trgen/templates/TypeScript/st.perf.sh @@ -6,12 +6,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) diff --git a/src/trgen/templates/TypeScript/st.test.ps1 b/src/trgen/templates/TypeScript/st.test.ps1 index ac086c857..ca3502171 100644 --- a/src/trgen/templates/TypeScript/st.test.ps1 +++ b/src/trgen/templates/TypeScript/st.test.ps1 @@ -10,7 +10,7 @@ if (Test-Path -Path "tests.txt" -PathType Leaf) { Remove-Item "tests.txt" } $files = New-Object System.Collections.Generic.List[string] -$allFiles = $(& dotnet trglob -- "$Tests" ; $last = $LASTEXITCODE ) +$allFiles = $(& dotnet trglob "$Tests" ; $last = $LASTEXITCODE ) foreach ($file in $allFiles) { $ext = $file | Split-Path -Extension if (Test-Path $file -PathType Container) { @@ -20,7 +20,7 @@ foreach ($file in $allFiles) { } elseif ($ext -eq ".tree") { continue } else { - $(& dotnet triconv -- -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null + $(& dotnet triconv -f utf-8 $file ; $last = $LASTEXITCODE ) | Out-Null if ($last -ne 0) { continue @@ -40,10 +40,10 @@ if (-not(Test-Path -Path "tests.txt" -PathType Leaf)) { # Parse all input files. # Individual parsing. -Get-Content "tests.txt" | ForEach-Object { dotnet trwdog -- pwsh -command "npx tsx Test.js -q -tee -tree $_" *>> parse.txt } +Get-Content "tests.txt" | ForEach-Object { dotnet trwdog pwsh -command "npx tsx Test.js -q -tee -tree $_" *>> parse.txt } # Group parsing. -get-content "tests.txt" | dotnet trwdog -- pwsh -command "npx tsx Test.js -q -x -tee -tree" *> parse.txt +get-content "tests.txt" | dotnet trwdog pwsh -command "npx tsx Test.js -q -x -tee -tree" *> parse.txt $status=$LASTEXITCODE diff --git a/src/trgen/templates/TypeScript/st.test.sh b/src/trgen/templates/TypeScript/st.test.sh index c4cb4c720..3dc90fdb8 100644 --- a/src/trgen/templates/TypeScript/st.test.sh +++ b/src/trgen/templates/TypeScript/st.test.sh @@ -9,12 +9,12 @@ IFS=$(echo -en "\n\b") # Get a list of test files from the test directory. Do not include any # .errors or .tree files. Pay close attention to remove only file names # that end with the suffix .errors or .tree. -files2=`dotnet trglob -- '../' | grep -v '.errors$' | grep -v '.tree$'` +files2=`dotnet trglob '../' | grep -v '.errors$' | grep -v '.tree$'` files=() for f in $files2 do if [ -d "$f" ]; then continue; fi - dotnet triconv -- -f utf-8 $f > /dev/null 2>&1 + dotnet triconv -f utf-8 $f > /dev/null 2>&1 if [ "$?" = "0" ] then files+=( $f ) @@ -36,7 +36,7 @@ fi rm -f parse.txt for f in ${files[*]} do - dotnet trwdog -- sh -c "npx tsx Test.js -q -tee -tree $f" >> parse.txt 2>&1 + dotnet trwdog sh -c "npx tsx Test.js -q -tee -tree $f" >> parse.txt 2>&1 xxx="$?" if [ "$xxx" -ne 0 ] then @@ -45,7 +45,7 @@ do done # Group parsing. -echo "${files[*]}" | dotnet trwdog -- sh -c "npx tsx Test.js -q -x -tee -tree" > parse.txt 2>&1 +echo "${files[*]}" | dotnet trwdog sh -c "npx tsx Test.js -q -x -tee -tree" > parse.txt 2>&1 status="$?" From 4ef8bbca5ac415fb59e3032733ee7750dc90505c Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Wed, 9 Oct 2024 10:16:14 -0400 Subject: [PATCH 15/18] Update readmes for release. --- _scripts/publish.sh | 2 +- _scripts/set-version.sh | 4 ++-- src/tragl/readme.md | 2 +- src/tranalyze/readme.md | 2 +- src/trcaret/readme.md | 2 +- src/trclonereplace/readme.md | 2 +- src/trcombine/readme.md | 2 +- src/trconvert/readme.md | 2 +- src/trcover/readme.md | 2 +- src/trdot/readme.md | 2 +- src/trenum/readme.md | 2 +- src/trfirst/readme.md | 2 +- src/trfold/readme.md | 2 +- src/trfoldlit/readme.md | 2 +- src/trformat/readme.md | 2 +- src/trgen/readme.md | 2 +- src/trgenvsc/readme.md | 2 +- src/trglob/readme.md | 2 +- src/trgroup/readme.md | 2 +- src/triconv/readme.md | 2 +- src/tritext/readme.md | 2 +- src/trjson/readme.md | 2 +- src/trkleene/readme.md | 2 +- src/trparse/readme.md | 2 +- src/trperf/readme.md | 2 +- src/trpiggy/readme.md | 2 +- src/trquery/readme.md | 2 +- src/trrename/readme.md | 2 +- src/trrr/readme.md | 2 +- src/trrup/readme.md | 2 +- src/trsem/readme.md | 2 +- src/trsort/readme.md | 2 +- src/trsplit/readme.md | 2 +- src/trsponge/readme.md | 2 +- src/trst/readme.md | 2 +- src/trtext/readme.md | 2 +- src/trthompson/readme.md | 2 +- src/trtokens/readme.md | 2 +- src/trtree/readme.md | 2 +- src/trull/readme.md | 2 +- src/trunfold/readme.md | 2 +- src/trungroup/readme.md | 2 +- src/trwdog/readme.md | 2 +- src/trxgrep/readme.md | 2 +- src/trxml/readme.md | 2 +- src/trxml2/readme.md | 2 +- 46 files changed, 47 insertions(+), 47 deletions(-) diff --git a/_scripts/publish.sh b/_scripts/publish.sh index df8cd5024..2d7868986 100644 --- a/_scripts/publish.sh +++ b/_scripts/publish.sh @@ -1,5 +1,5 @@ #!/usr/bin/bash -version=0.23.6 +version=0.23.7 cd src exes=`find . -name 'tr*.exe' | grep -v publish` for i in $exes diff --git a/_scripts/set-version.sh b/_scripts/set-version.sh index 60727c2a9..acb5189ca 100644 --- a/_scripts/set-version.sh +++ b/_scripts/set-version.sh @@ -41,7 +41,7 @@ do mv asdfasdf *.csproj rm -f asdfasdf2 touch readme.md - cat readme.md | sed -e 's%^0[.][0-9]*[.][0-9]*.*$'"%$version"' Fixed trcover when started outside of Generated directory.%' > asdfasdf2 + cat readme.md | sed -e 's%^0[.][0-9]*[.][0-9]*.*$'"%$version"' Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen.%' > asdfasdf2 mv asdfasdf2 readme.md cd .. done @@ -78,7 +78,7 @@ do mv asdfasdf *.csproj rm -f asdfasdf2 touch readme.md - cat readme.md | sed -e 's%^0[.][0-9]*[.][0-9]*.*$'"%$version"' Fixed trcover when started outside of Generated directory.%' > asdfasdf2 + cat readme.md | sed -e 's%^0[.][0-9]*[.][0-9]*.*$'"%$version"' Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen.%' > asdfasdf2 mv asdfasdf2 readme.md cd .. done diff --git a/src/tragl/readme.md b/src/tragl/readme.md index 22be79fbe..97de16926 100644 --- a/src/tragl/readme.md +++ b/src/tragl/readme.md @@ -19,7 +19,7 @@ This tool is part of Trash, Transformations for Antlr Shell. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/tranalyze/readme.md b/src/tranalyze/readme.md index 63ace29a0..245f410a4 100644 --- a/src/tranalyze/readme.md +++ b/src/tranalyze/readme.md @@ -65,7 +65,7 @@ _Output_ ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trcaret/readme.md b/src/trcaret/readme.md index f5f290251..d487e37df 100644 --- a/src/trcaret/readme.md +++ b/src/trcaret/readme.md @@ -18,7 +18,7 @@ Reads a tree from stdin and prints lines and caret marks. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trclonereplace/readme.md b/src/trclonereplace/readme.md index 340c1da3c..eb9934ffa 100644 --- a/src/trclonereplace/readme.md +++ b/src/trclonereplace/readme.md @@ -19,7 +19,7 @@ Clone, rename, and replace symbols in a grammar to optimize full stack fallbacks ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trcombine/readme.md b/src/trcombine/readme.md index 82e4aa438..2f2fa9af1 100644 --- a/src/trcombine/readme.md +++ b/src/trcombine/readme.md @@ -103,7 +103,7 @@ The original grammars are left unchanged. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trconvert/readme.md b/src/trconvert/readme.md index 0941f2be0..60cfb5cf6 100644 --- a/src/trconvert/readme.md +++ b/src/trconvert/readme.md @@ -93,7 +93,7 @@ _Output_ ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trcover/readme.md b/src/trcover/readme.md index 449df8ab0..f9e765aa9 100644 --- a/src/trcover/readme.md +++ b/src/trcover/readme.md @@ -24,7 +24,7 @@ a grammar. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trdot/readme.md b/src/trdot/readme.md index 4ed334505..90974193a 100644 --- a/src/trdot/readme.md +++ b/src/trdot/readme.md @@ -63,7 +63,7 @@ The output will be: ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trenum/readme.md b/src/trenum/readme.md index 004714166..d45f06092 100644 --- a/src/trenum/readme.md +++ b/src/trenum/readme.md @@ -8,7 +8,7 @@ ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trfirst/readme.md b/src/trfirst/readme.md index 0e825ba4d..dfb5e9025 100644 --- a/src/trfirst/readme.md +++ b/src/trfirst/readme.md @@ -24,7 +24,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trfold/readme.md b/src/trfold/readme.md index 3173c3d85..57778dbf2 100644 --- a/src/trfold/readme.md +++ b/src/trfold/readme.md @@ -26,7 +26,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trfoldlit/readme.md b/src/trfoldlit/readme.md index 7283c6b17..8d718a751 100644 --- a/src/trfoldlit/readme.md +++ b/src/trfoldlit/readme.md @@ -65,7 +65,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trformat/readme.md b/src/trformat/readme.md index af7808407..6f4cf4348 100644 --- a/src/trformat/readme.md +++ b/src/trformat/readme.md @@ -18,7 +18,7 @@ Format of grammar using machine learning. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trgen/readme.md b/src/trgen/readme.md index 5e0bd5349..9d5632e24 100644 --- a/src/trgen/readme.md +++ b/src/trgen/readme.md @@ -49,7 +49,7 @@ simplify and eliminate bugs created when adding new grammars. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trgenvsc/readme.md b/src/trgenvsc/readme.md index 4a2efbfab..11ea53dab 100644 --- a/src/trgenvsc/readme.md +++ b/src/trgenvsc/readme.md @@ -30,7 +30,7 @@ the XPath patterns to match certain parse trees. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trglob/readme.md b/src/trglob/readme.md index 9c46b078f..3f4408742 100644 --- a/src/trglob/readme.md +++ b/src/trglob/readme.md @@ -17,7 +17,7 @@ Expand a glob string into file names. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trgroup/readme.md b/src/trgroup/readme.md index 35da84921..667871a75 100644 --- a/src/trgroup/readme.md +++ b/src/trgroup/readme.md @@ -56,7 +56,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/triconv/readme.md b/src/triconv/readme.md index 4d005e7f6..32f8b0c81 100644 --- a/src/triconv/readme.md +++ b/src/triconv/readme.md @@ -20,7 +20,7 @@ unicode. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/tritext/readme.md b/src/tritext/readme.md index 0095f54b8..ebbe5eca1 100644 --- a/src/tritext/readme.md +++ b/src/tritext/readme.md @@ -18,7 +18,7 @@ Get strings from a PDF file using IText. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trjson/readme.md b/src/trjson/readme.md index 4f0d2b4ac..9297f7345 100644 --- a/src/trjson/readme.md +++ b/src/trjson/readme.md @@ -18,7 +18,7 @@ Read a parse tree from stdin and write a JSON represenation of it. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trkleene/readme.md b/src/trkleene/readme.md index 7dc09b980..7e792feea 100644 --- a/src/trkleene/readme.md +++ b/src/trkleene/readme.md @@ -38,7 +38,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trparse/readme.md b/src/trparse/readme.md index f8ec5cc8d..07c0b5a17 100644 --- a/src/trparse/readme.md +++ b/src/trparse/readme.md @@ -50,7 +50,7 @@ the `--type` command-line option: ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trperf/readme.md b/src/trperf/readme.md index 1750a9520..016ac89ec 100644 --- a/src/trperf/readme.md +++ b/src/trperf/readme.md @@ -41,7 +41,7 @@ be in a trgen-generated parser directory, or use the -p option. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trpiggy/readme.md b/src/trpiggy/readme.md index 2c1279047..f9cda6346 100644 --- a/src/trpiggy/readme.md +++ b/src/trpiggy/readme.md @@ -63,7 +63,7 @@ Output: ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trquery/readme.md b/src/trquery/readme.md index e7cde0c21..d5f3512aa 100644 --- a/src/trquery/readme.md +++ b/src/trquery/readme.md @@ -47,7 +47,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trrename/readme.md b/src/trrename/readme.md index f1146298f..8249eb858 100644 --- a/src/trrename/readme.md +++ b/src/trrename/readme.md @@ -27,7 +27,7 @@ make sure to enclose the argument as it contains semi-colons. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trrr/readme.md b/src/trrr/readme.md index c129f42e1..483ae547b 100644 --- a/src/trrr/readme.md +++ b/src/trrr/readme.md @@ -14,7 +14,7 @@ ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trrup/readme.md b/src/trrup/readme.md index 3ec93bf53..b80930537 100644 --- a/src/trrup/readme.md +++ b/src/trrup/readme.md @@ -42,7 +42,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trsem/readme.md b/src/trsem/readme.md index 258c82d48..6a88c8568 100644 --- a/src/trsem/readme.md +++ b/src/trsem/readme.md @@ -18,7 +18,7 @@ Read a static semantics spec file and generate code. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trsort/readme.md b/src/trsort/readme.md index 9e6356116..836761dd3 100644 --- a/src/trsort/readme.md +++ b/src/trsort/readme.md @@ -37,7 +37,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trsplit/readme.md b/src/trsplit/readme.md index 853d4e15f..6cdf911e4 100644 --- a/src/trsplit/readme.md +++ b/src/trsplit/readme.md @@ -45,7 +45,7 @@ modified. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trsponge/readme.md b/src/trsponge/readme.md index 63490c166..879c3d487 100644 --- a/src/trsponge/readme.md +++ b/src/trsponge/readme.md @@ -19,7 +19,7 @@ results to file(s). ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trst/readme.md b/src/trst/readme.md index 4e9d384b5..715360a3d 100644 --- a/src/trst/readme.md +++ b/src/trst/readme.md @@ -18,7 +18,7 @@ Output tree using the Antlr runtime ToStringTree(). ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trtext/readme.md b/src/trtext/readme.md index fb56e77bf..90003156f 100644 --- a/src/trtext/readme.md +++ b/src/trtext/readme.md @@ -19,7 +19,7 @@ specified, the line number range for the tree is printed. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trthompson/readme.md b/src/trthompson/readme.md index 31e731061..8e80603ee 100644 --- a/src/trthompson/readme.md +++ b/src/trthompson/readme.md @@ -12,7 +12,7 @@ ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trtokens/readme.md b/src/trtokens/readme.md index 65eb62218..0423523bd 100644 --- a/src/trtokens/readme.md +++ b/src/trtokens/readme.md @@ -52,7 +52,7 @@ Output: ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trtree/readme.md b/src/trtree/readme.md index aa26789cc..34f80eb24 100644 --- a/src/trtree/readme.md +++ b/src/trtree/readme.md @@ -18,7 +18,7 @@ Reads a tree from stdin and prints the tree as an indented node list. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trull/readme.md b/src/trull/readme.md index 87885de10..da085becd 100644 --- a/src/trull/readme.md +++ b/src/trull/readme.md @@ -63,7 +63,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trunfold/readme.md b/src/trunfold/readme.md index b4047e670..b7f91794e 100644 --- a/src/trunfold/readme.md +++ b/src/trunfold/readme.md @@ -51,7 +51,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trungroup/readme.md b/src/trungroup/readme.md index 763c6dc3c..0434fa833 100644 --- a/src/trungroup/readme.md +++ b/src/trungroup/readme.md @@ -24,7 +24,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trwdog/readme.md b/src/trwdog/readme.md index a651bb0cc..82e40efba 100644 --- a/src/trwdog/readme.md +++ b/src/trwdog/readme.md @@ -18,7 +18,7 @@ Execute a command with a watchdog timer. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trxgrep/readme.md b/src/trxgrep/readme.md index 848197dc9..e8473e89e 100644 --- a/src/trxgrep/readme.md +++ b/src/trxgrep/readme.md @@ -24,7 +24,7 @@ XPaths, type _export MSYS2_ARG_CONV_EXCL="*"_, then execute your command. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trxml/readme.md b/src/trxml/readme.md index 61545ea50..8afa3d238 100644 --- a/src/trxml/readme.md +++ b/src/trxml/readme.md @@ -18,7 +18,7 @@ Read a tree from stdin and write an XML represenation of it. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License diff --git a/src/trxml2/readme.md b/src/trxml2/readme.md index b29b30ad0..055f5aa70 100644 --- a/src/trxml2/readme.md +++ b/src/trxml2/readme.md @@ -18,7 +18,7 @@ Read an xml file and enumerate all paths to elements in xpath syntax. ## Current version -0.23.7 Fixed trcover when started outside of Generated directory. +0.23.7 Fixed trcover when started outside of Generated directory. Fixed analysis of grammars in trgen. ## License From d12659af52e99f8bc105142de3fa8bdef8b97d5e Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Wed, 9 Oct 2024 14:51:56 -0400 Subject: [PATCH 16/18] Find out what is wrong with dotnet-setup. --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 43d37c5fa..02f76eba2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,6 +37,9 @@ jobs: run: | echo ${{ steps.setup-php.outputs.php-version }} php --version + - name: Prep Dotnet + run: | + sudo ls -l /usr/share/dotnet - name: Install Dotnet uses: actions/setup-dotnet@v4.0.1 with: From 1d72a4c88bd7da82fe6bee9caef1897422adf1f1 Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Wed, 9 Oct 2024 14:54:25 -0400 Subject: [PATCH 17/18] Try again. --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 02f76eba2..f57161f53 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,6 +39,8 @@ jobs: php --version - name: Prep Dotnet run: | + sudo ls -l /usr + sudo ls -l /usr/share sudo ls -l /usr/share/dotnet - name: Install Dotnet uses: actions/setup-dotnet@v4.0.1 From 9e7de819428f02e2535878ed311f5c12c1c810b0 Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Wed, 9 Oct 2024 14:56:27 -0400 Subject: [PATCH 18/18] Again. --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f57161f53..291294128 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,9 +39,8 @@ jobs: php --version - name: Prep Dotnet run: | - sudo ls -l /usr - sudo ls -l /usr/share - sudo ls -l /usr/share/dotnet + sudo mkdir /usr/share/dotnet + sudo chmod 777 /usr/share/dotnet - name: Install Dotnet uses: actions/setup-dotnet@v4.0.1 with: