From 6912da7663057b9a6ddfc34635da1ebe17bc1fa9 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Sat, 5 Sep 2020 08:06:08 +1000 Subject: [PATCH 01/16] Dev version bump --- src/Sprache/Sprache.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sprache/Sprache.csproj b/src/Sprache/Sprache.csproj index f4699a4..b1d2f0f 100644 --- a/src/Sprache/Sprache.csproj +++ b/src/Sprache/Sprache.csproj @@ -1,10 +1,10 @@ - + Sprache is a simple, lightweight library for constructing parsers directly in C# code. Copyright Sprache Contributors 2017 Sprache - 2.3.1 + 2.3.2 Nicholas Blumhardt;Contributors sl5;net35;net40;net45;netstandard1.0;netstandard2.0;netstandard2.1 true From 09dbc8ac1d73b9c0576059eaec7d2c1706c1067c Mon Sep 17 00:00:00 2001 From: magicandre1981 Date: Fri, 2 Oct 2020 14:32:18 +0200 Subject: [PATCH 02/16] possible fix for Issue 162 --- src/Sprache/Sprache.csproj | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Sprache/Sprache.csproj b/src/Sprache/Sprache.csproj index b1d2f0f..1fc7a8a 100644 --- a/src/Sprache/Sprache.csproj +++ b/src/Sprache/Sprache.csproj @@ -63,15 +63,7 @@ v4.5 - - - - - - - - - + From f5c6af617952d9473f88e0f027e0145a8d5a29a3 Mon Sep 17 00:00:00 2001 From: Andrey Leskov Date: Sat, 31 Oct 2020 14:30:28 +0800 Subject: [PATCH 03/16] Add link to Justin Pealing guide --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 06e433f..18059b1 100755 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ The best place to start is [this introductory article](http://nblumhardt.com/201 * [Parsing comma-separated values (CSV) into lists of strings](https://github.com/sprache/Sprache/blob/master/test/Sprache.Tests/Scenarios/CsvTests.cs) **Tutorials** explaining Sprache: - + * Overview of Sprache methods, [long guide by Justing Pealing](https://justinpealing.me.uk/post/2020-03-11-sprache1-chars/) * A great [CodeProject article by Alexey Yakovlev ](http://www.codeproject.com/Articles/795056/Sprache-Calc-building-yet-another-expression-evalu) (and [in Russian](http://habrahabr.ru/post/228037/)) * Mike Hadlow's example of [parsing connection strings](http://mikehadlow.blogspot.com.au/2012/09/parsing-connection-string-with-sprache.html) * Alexey Golub's article on [monadic parser combinators](https://tyrrrz.me/blog/monadic-parser-combinators) that shows how to build a JSON parser using Sprache From 57ff0bf06ad22ea112319615dbac063696c05789 Mon Sep 17 00:00:00 2001 From: MagicAndre1981 Date: Tue, 29 Jun 2021 08:58:32 +0200 Subject: [PATCH 04/16] removed old TargetFrameworks ( sl5;net35;net40;net45;netstandard1.0 ) from csproj --- src/Sprache/Sprache.csproj | 55 +------------------------------------- 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/src/Sprache/Sprache.csproj b/src/Sprache/Sprache.csproj index 1fc7a8a..c0ef204 100644 --- a/src/Sprache/Sprache.csproj +++ b/src/Sprache/Sprache.csproj @@ -6,7 +6,7 @@ Sprache 2.3.2 Nicholas Blumhardt;Contributors - sl5;net35;net40;net45;netstandard1.0;netstandard2.0;netstandard2.1 + netstandard2.0;netstandard2.1;net5.0 true Sprache Sprache @@ -18,57 +18,4 @@ https://github.com/sprache/Sprache - - - - - - - - - - - - - - - - - - - - - - - - $(DefineConstants);STRING_IS_ENUMERABLE;STRING_JOIN_ENUMERABLE - .NETFramework - v4.5 - - - - $(DefineConstants);STRING_IS_ENUMERABLE - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client - - - - $(DefineConstants);STRING_JOIN_ENUMERABLE - true - - - - $(DefineConstants);STRING_IS_ENUMERABLE;STRING_JOIN_ENUMERABLE - true - .NETFramework - v4.5 - - - - - - - - - - From c36e5d6e39e6d076569508e774bc14c051fa14d8 Mon Sep 17 00:00:00 2001 From: MagicAndre1981 Date: Tue, 29 Jun 2021 09:17:59 +0200 Subject: [PATCH 05/16] added DefineConstants --- src/Sprache/Sprache.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Sprache/Sprache.csproj b/src/Sprache/Sprache.csproj index c0ef204..bd75a8e 100644 --- a/src/Sprache/Sprache.csproj +++ b/src/Sprache/Sprache.csproj @@ -7,6 +7,7 @@ 2.3.2 Nicholas Blumhardt;Contributors netstandard2.0;netstandard2.1;net5.0 + $(DefineConstants);STRING_IS_ENUMERABLE;STRING_JOIN_ENUMERABLE true Sprache Sprache From a80194050c21803abf4ee27d4d8c85a50265541e Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 6 Jul 2021 08:40:11 +1000 Subject: [PATCH 06/16] Dependency changes -> major version bump --- src/Sprache/Sprache.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sprache/Sprache.csproj b/src/Sprache/Sprache.csproj index bd75a8e..8cbad54 100644 --- a/src/Sprache/Sprache.csproj +++ b/src/Sprache/Sprache.csproj @@ -4,7 +4,7 @@ Sprache is a simple, lightweight library for constructing parsers directly in C# code. Copyright Sprache Contributors 2017 Sprache - 2.3.2 + 3.0.0 Nicholas Blumhardt;Contributors netstandard2.0;netstandard2.1;net5.0 $(DefineConstants);STRING_IS_ENUMERABLE;STRING_JOIN_ENUMERABLE From f6a7a2ab1536abd02b5f9f9d2c2553b830591a2d Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 6 Jul 2021 09:05:45 +1000 Subject: [PATCH 07/16] Project, packaging, dependency updates --- .idea/.idea.Sprache/.idea/.gitignore | 13 ++++++++++++ .idea/.idea.Sprache/.idea/.name | 1 + .idea/.idea.Sprache/.idea/encodings.xml | 4 ++++ .idea/.idea.Sprache/.idea/indexLayout.xml | 8 ++++++++ .idea/.idea.Sprache/.idea/vcs.xml | 6 ++++++ icon.png | Bin 0 -> 8964 bytes .../LinqyCalculator/LinqyCalculator.csproj | 12 +---------- .../Properties/AssemblyInfo.cs | 19 ------------------ .../Properties/AssemblyInfo.cs | 19 ------------------ .../TinyTemplates.Tests.csproj | 17 +++++++--------- .../TinyTemplates/Properties/AssemblyInfo.cs | 19 ------------------ samples/TinyTemplates/TinyTemplates.csproj | 16 +-------------- samples/XmlExample/Properties/AssemblyInfo.cs | 19 ------------------ samples/XmlExample/XmlExample.csproj | 11 +--------- samples/XmlExample/app.config | 3 --- src/Sprache/Sprache.csproj | 16 ++++++++------- test/Sprache.Tests/ParseTests.cs | 2 +- test/Sprache.Tests/Properties/AssemblyInfo.cs | 19 ------------------ test/Sprache.Tests/Sprache.Tests.csproj | 17 +++++++--------- 19 files changed, 59 insertions(+), 162 deletions(-) create mode 100644 .idea/.idea.Sprache/.idea/.gitignore create mode 100644 .idea/.idea.Sprache/.idea/.name create mode 100644 .idea/.idea.Sprache/.idea/encodings.xml create mode 100644 .idea/.idea.Sprache/.idea/indexLayout.xml create mode 100644 .idea/.idea.Sprache/.idea/vcs.xml create mode 100644 icon.png delete mode 100644 samples/LinqyCalculator/Properties/AssemblyInfo.cs delete mode 100644 samples/TinyTemplates.Tests/Properties/AssemblyInfo.cs delete mode 100644 samples/TinyTemplates/Properties/AssemblyInfo.cs delete mode 100644 samples/XmlExample/Properties/AssemblyInfo.cs delete mode 100644 samples/XmlExample/app.config delete mode 100644 test/Sprache.Tests/Properties/AssemblyInfo.cs diff --git a/.idea/.idea.Sprache/.idea/.gitignore b/.idea/.idea.Sprache/.idea/.gitignore new file mode 100644 index 0000000..d8ebb05 --- /dev/null +++ b/.idea/.idea.Sprache/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/contentModel.xml +/modules.xml +/projectSettingsUpdater.xml +/.idea.Sprache.iml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/.idea.Sprache/.idea/.name b/.idea/.idea.Sprache/.idea/.name new file mode 100644 index 0000000..bc4fb0d --- /dev/null +++ b/.idea/.idea.Sprache/.idea/.name @@ -0,0 +1 @@ +Sprache \ No newline at end of file diff --git a/.idea/.idea.Sprache/.idea/encodings.xml b/.idea/.idea.Sprache/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.Sprache/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.Sprache/.idea/indexLayout.xml b/.idea/.idea.Sprache/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.Sprache/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.Sprache/.idea/vcs.xml b/.idea/.idea.Sprache/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/.idea.Sprache/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..d7febe8590e2afd6b219eccbadd8b267358cf435 GIT binary patch literal 8964 zcmdTq_dlFZ(0AvQLoSFKU5MxrB}zo}7DPLz-w~okiQY?aIw?pHL`%5C=`A=tdN0v? z4Wb+&%6s4UKX`w9Kc9V`A7*EEW_D+1XLcv%g^t=S^1I{!0N|E}y0Sh108IYxBLfj2 zx97iR003Nl8p;ZWzL~%0DUx3r`?3Ey$PD-=EqBn}%s!){$N~Aq$k+A)Z0=1q9cpa= zwqEJrBj<-kQ9U5;eh|!k-`(6>U(|4gaiupelb`v8vvnE~wL*lts(yY-6?)Urr@FH2 z*Zk*SpSQQOg6BN+=jFs?hqCsw0`{dBn{KSMtNs079bDB&9A^`_9@IBarUL*{$u$%J zz!oit0xQ?c+bVNj^R zqBjuYaY#wGxwWXhPQ1#Oc@sahZt+mxE!wMJ;fSn9uzm14v zh&xVLUar=n-vJ_s|3e$t5+U0<(U7?^Uxfgi36v#!AoTi-t^dBLX=YL>8vsUN>c~#u zAUx8;KD<7~RZJR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4AY>I{&uKehp%l0K&Zl{F@@9MFFzpn)fE#=|HKA3e!X!Npc zUpbj`k}c)rgJCGv)coHg%mc(Zx}jRh zA=5Y33e7ylv49*W4G8ArC;Q6aat^OshystREE3wZvW@9}GGo^^tnF@6F7;rF!gBS~_X;2phX z^&Ow16`c$T;Iqdx;@tf)W<2YrLk8BDspDzyV1OSTr}t^i(v5EdWd54!EQl^&T{`*# z0SrClgpvs%1tmqm67>IX;l%%?;v?aP9RRqw8F{qjx|{RSlTh6P&`{A)E>%Q?{||;5 B%nbkl literal 0 HcmV?d00001 diff --git a/samples/LinqyCalculator/LinqyCalculator.csproj b/samples/LinqyCalculator/LinqyCalculator.csproj index 80895db..1035b4e 100644 --- a/samples/LinqyCalculator/LinqyCalculator.csproj +++ b/samples/LinqyCalculator/LinqyCalculator.csproj @@ -1,22 +1,12 @@  - net45;netcoreapp3.1 - LinqyCalculator + net5.0 Exe - LinqyCalculator - false - false - false - - - - - diff --git a/samples/LinqyCalculator/Properties/AssemblyInfo.cs b/samples/LinqyCalculator/Properties/AssemblyInfo.cs deleted file mode 100644 index 5a037ad..0000000 --- a/samples/LinqyCalculator/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("LinqyCalculator")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("d7a17f71-dd1e-4cd9-9cc8-66322fd8698e")] diff --git a/samples/TinyTemplates.Tests/Properties/AssemblyInfo.cs b/samples/TinyTemplates.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index b873fb0..0000000 --- a/samples/TinyTemplates.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TinyTemplates.Tests")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("cb505fe2-4188-49d9-9bfd-1d1e213b4423")] diff --git a/samples/TinyTemplates.Tests/TinyTemplates.Tests.csproj b/samples/TinyTemplates.Tests/TinyTemplates.Tests.csproj index f4322a2..6ce32c5 100644 --- a/samples/TinyTemplates.Tests/TinyTemplates.Tests.csproj +++ b/samples/TinyTemplates.Tests/TinyTemplates.Tests.csproj @@ -1,13 +1,7 @@  - net461;netcoreapp3.1 - TinyTemplates.Tests - TinyTemplates.Tests - true - false - false - false + net5.0 @@ -16,9 +10,12 @@ - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/samples/TinyTemplates/Properties/AssemblyInfo.cs b/samples/TinyTemplates/Properties/AssemblyInfo.cs deleted file mode 100644 index 93d6bfd..0000000 --- a/samples/TinyTemplates/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TinyTemplates")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a0410d8d-2d98-4ee4-a177-db31ca493d19")] diff --git a/samples/TinyTemplates/TinyTemplates.csproj b/samples/TinyTemplates/TinyTemplates.csproj index 5b3f4ae..ca86a18 100644 --- a/samples/TinyTemplates/TinyTemplates.csproj +++ b/samples/TinyTemplates/TinyTemplates.csproj @@ -1,25 +1,11 @@  - Copyright Sprache Contributors 2013 - TinyTemplates - 2.0.0 - Nicholas Blumhardt and Contributors - net45;netstandard2.1 - TinyTemplates - TinyTemplates - false - false - false + net5.0 - - - - - diff --git a/samples/XmlExample/Properties/AssemblyInfo.cs b/samples/XmlExample/Properties/AssemblyInfo.cs deleted file mode 100644 index 6782e9d..0000000 --- a/samples/XmlExample/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("XmlExample")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("42f99bdf-5f43-40a6-a713-e84ee845f022")] diff --git a/samples/XmlExample/XmlExample.csproj b/samples/XmlExample/XmlExample.csproj index 81408cd..1035b4e 100644 --- a/samples/XmlExample/XmlExample.csproj +++ b/samples/XmlExample/XmlExample.csproj @@ -1,19 +1,10 @@  - netcoreapp3.1 - XmlExample + net5.0 Exe - XmlExample - false - false - false - - - - diff --git a/samples/XmlExample/app.config b/samples/XmlExample/app.config deleted file mode 100644 index 2f7cce7..0000000 --- a/samples/XmlExample/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/Sprache/Sprache.csproj b/src/Sprache/Sprache.csproj index 8cbad54..0a0963a 100644 --- a/src/Sprache/Sprache.csproj +++ b/src/Sprache/Sprache.csproj @@ -2,21 +2,23 @@ Sprache is a simple, lightweight library for constructing parsers directly in C# code. - Copyright Sprache Contributors 2017 - Sprache + Copyright © Sprache Contributors 3.0.0 - Nicholas Blumhardt;Contributors netstandard2.0;netstandard2.1;net5.0 $(DefineConstants);STRING_IS_ENUMERABLE;STRING_JOIN_ENUMERABLE true - Sprache - Sprache Parser;Parsers - https://avatars1.githubusercontent.com/u/1999078 + icon.png https://github.com/sprache/Sprache - https://github.com/sprache/Sprache/blob/master/licence.txt + Apache-2.0 git https://github.com/sprache/Sprache + + + PreserveNewest + + + diff --git a/test/Sprache.Tests/ParseTests.cs b/test/Sprache.Tests/ParseTests.cs index ea4af56..4ee7931 100644 --- a/test/Sprache.Tests/ParseTests.cs +++ b/test/Sprache.Tests/ParseTests.cs @@ -521,7 +521,7 @@ public void DelimitedWithMinimum() public void DelimitedWithMaximum() { var sequence = Parse.Char('a').DelimitedBy(Parse.Char(','), null, 4); - Assert.Equal(1, sequence.TryParse("a").Value.Count()); + Assert.Single(sequence.TryParse("a").Value); Assert.Equal(3, sequence.TryParse("a,a,a").Value.Count()); Assert.Equal(4, sequence.TryParse("a,a,a,a").Value.Count()); Assert.Equal(4, sequence.TryParse("a,a,a,a,a").Value.Count()); diff --git a/test/Sprache.Tests/Properties/AssemblyInfo.cs b/test/Sprache.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index bee8c97..0000000 --- a/test/Sprache.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Sprache.Tests")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5af7e4ae-efc0-485c-8560-c0785a21d28b")] diff --git a/test/Sprache.Tests/Sprache.Tests.csproj b/test/Sprache.Tests/Sprache.Tests.csproj index 2d868b9..8b8fb50 100644 --- a/test/Sprache.Tests/Sprache.Tests.csproj +++ b/test/Sprache.Tests/Sprache.Tests.csproj @@ -1,13 +1,7 @@  - net461;netcoreapp3.1 - Sprache.Tests - Sprache.Tests - true - false - false - false + net5.0 @@ -15,9 +9,12 @@ - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + From 04554e776689647f68fb8220ea5e381c3986ba61 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 6 Jul 2021 09:06:34 +1000 Subject: [PATCH 08/16] Remove unused 'using' blocks --- samples/LinqyCalculator/Program.cs | 3 --- samples/XmlExample/Program.cs | 1 - src/Sprache/CommentParser.cs | 7 +------ src/Sprache/IComment.cs | 7 +------ src/Sprache/IInput.cs | 2 -- src/Sprache/Properties/AssemblyInfo.cs | 3 +-- src/Sprache/StringExtensions.cs | 4 +--- test/Sprache.Tests/AssertInput.cs | 4 +--- test/Sprache.Tests/AssertParser.cs | 1 - test/Sprache.Tests/DecimalTests.cs | 1 - test/Sprache.Tests/InputTests.cs | 3 --- test/Sprache.Tests/OptionTests.cs | 1 - test/Sprache.Tests/ParseTests.cs | 3 +-- test/Sprache.Tests/PosAwareStr.cs | 7 +------ test/Sprache.Tests/ResultTests.cs | 5 +---- test/Sprache.Tests/Scenarios/AmqpErrorTests.cs | 1 - test/Sprache.Tests/Scenarios/StarDateTest.cs | 3 --- 17 files changed, 8 insertions(+), 48 deletions(-) diff --git a/samples/LinqyCalculator/Program.cs b/samples/LinqyCalculator/Program.cs index af6f289..32aade2 100644 --- a/samples/LinqyCalculator/Program.cs +++ b/samples/LinqyCalculator/Program.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using Sprache; namespace LinqyCalculator diff --git a/samples/XmlExample/Program.cs b/samples/XmlExample/Program.cs index c8e949e..4d2916a 100644 --- a/samples/XmlExample/Program.cs +++ b/samples/XmlExample/Program.cs @@ -4,7 +4,6 @@ using System.Text; using Sprache; using System.IO; -using System.Xml; namespace XmlExample { diff --git a/src/Sprache/CommentParser.cs b/src/Sprache/CommentParser.cs index 72bb8d3..2c003b3 100644 --- a/src/Sprache/CommentParser.cs +++ b/src/Sprache/CommentParser.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Sprache +namespace Sprache { ///

/// Constructs customizable comment parsers. diff --git a/src/Sprache/IComment.cs b/src/Sprache/IComment.cs index f2491c1..039cb47 100644 --- a/src/Sprache/IComment.cs +++ b/src/Sprache/IComment.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Sprache +namespace Sprache { /// /// Represents a customizable comment parser. diff --git a/src/Sprache/IInput.cs b/src/Sprache/IInput.cs index ce57d5e..b6c77c5 100644 --- a/src/Sprache/IInput.cs +++ b/src/Sprache/IInput.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Sprache { diff --git a/src/Sprache/Properties/AssemblyInfo.cs b/src/Sprache/Properties/AssemblyInfo.cs index d7148c6..22470eb 100644 --- a/src/Sprache/Properties/AssemblyInfo.cs +++ b/src/Sprache/Properties/AssemblyInfo.cs @@ -1,4 +1,3 @@ -using System.Reflection; -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Sprache.Tests")] diff --git a/src/Sprache/StringExtensions.cs b/src/Sprache/StringExtensions.cs index 07fe214..7e081eb 100644 --- a/src/Sprache/StringExtensions.cs +++ b/src/Sprache/StringExtensions.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; namespace Sprache { diff --git a/test/Sprache.Tests/AssertInput.cs b/test/Sprache.Tests/AssertInput.cs index d5debd5..5ae4285 100644 --- a/test/Sprache.Tests/AssertInput.cs +++ b/test/Sprache.Tests/AssertInput.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; + namespace Sprache.Tests { static class AssertInput diff --git a/test/Sprache.Tests/AssertParser.cs b/test/Sprache.Tests/AssertParser.cs index 0fc153d..4357dd8 100644 --- a/test/Sprache.Tests/AssertParser.cs +++ b/test/Sprache.Tests/AssertParser.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Sprache; using Xunit; namespace Sprache.Tests diff --git a/test/Sprache.Tests/DecimalTests.cs b/test/Sprache.Tests/DecimalTests.cs index 3df05f4..2b30ba6 100644 --- a/test/Sprache.Tests/DecimalTests.cs +++ b/test/Sprache.Tests/DecimalTests.cs @@ -1,6 +1,5 @@ using System; using System.Globalization; -using System.Threading; using Xunit; namespace Sprache.Tests diff --git a/test/Sprache.Tests/InputTests.cs b/test/Sprache.Tests/InputTests.cs index a256adb..43eb9da 100644 --- a/test/Sprache.Tests/InputTests.cs +++ b/test/Sprache.Tests/InputTests.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using Xunit; namespace Sprache.Tests diff --git a/test/Sprache.Tests/OptionTests.cs b/test/Sprache.Tests/OptionTests.cs index d8634ed..e52fcc5 100644 --- a/test/Sprache.Tests/OptionTests.cs +++ b/test/Sprache.Tests/OptionTests.cs @@ -1,4 +1,3 @@ -using Sprache; using Xunit; namespace Sprache.Tests diff --git a/test/Sprache.Tests/ParseTests.cs b/test/Sprache.Tests/ParseTests.cs index 4ee7931..01108a1 100644 --- a/test/Sprache.Tests/ParseTests.cs +++ b/test/Sprache.Tests/ParseTests.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Xunit; diff --git a/test/Sprache.Tests/PosAwareStr.cs b/test/Sprache.Tests/PosAwareStr.cs index c32d062..c22c76b 100644 --- a/test/Sprache.Tests/PosAwareStr.cs +++ b/test/Sprache.Tests/PosAwareStr.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Sprache.Tests +namespace Sprache.Tests { class PosAwareStr : IPositionAware { diff --git a/test/Sprache.Tests/ResultTests.cs b/test/Sprache.Tests/ResultTests.cs index 772607c..9c30e36 100644 --- a/test/Sprache.Tests/ResultTests.cs +++ b/test/Sprache.Tests/ResultTests.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using Xunit; namespace Sprache.Tests diff --git a/test/Sprache.Tests/Scenarios/AmqpErrorTests.cs b/test/Sprache.Tests/Scenarios/AmqpErrorTests.cs index a3204fb..83e3f7b 100644 --- a/test/Sprache.Tests/Scenarios/AmqpErrorTests.cs +++ b/test/Sprache.Tests/Scenarios/AmqpErrorTests.cs @@ -1,6 +1,5 @@ // ReSharper disable InconsistentNaming -using System; using System.Collections.Generic; using System.Globalization; using System.Linq; diff --git a/test/Sprache.Tests/Scenarios/StarDateTest.cs b/test/Sprache.Tests/Scenarios/StarDateTest.cs index 6d613b0..40c1433 100644 --- a/test/Sprache.Tests/Scenarios/StarDateTest.cs +++ b/test/Sprache.Tests/Scenarios/StarDateTest.cs @@ -1,8 +1,5 @@ using Xunit; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Sprache.Tests.Scenarios { From 652c72e183b08008111173db5a3603a56dc75691 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 6 Jul 2021 09:08:54 +1000 Subject: [PATCH 09/16] Remove unused private set accessors --- src/Sprache/Input.cs | 2 +- src/Sprache/Position.cs | 4 +--- test/Sprache.Tests/Scenarios/AmqpErrorTests.cs | 10 +++++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Sprache/Input.cs b/src/Sprache/Input.cs index 75d8ae9..05e642f 100644 --- a/src/Sprache/Input.cs +++ b/src/Sprache/Input.cs @@ -16,7 +16,7 @@ public class Input : IInput /// /// Gets the list of memos assigned to the instance. /// - public IDictionary Memos { get; private set; } + public IDictionary Memos { get; } /// /// Initializes a new instance of the class. diff --git a/src/Sprache/Position.cs b/src/Sprache/Position.cs index a300dc0..b58285c 100644 --- a/src/Sprache/Position.cs +++ b/src/Sprache/Position.cs @@ -1,4 +1,5 @@ using System; +// ReSharper disable MemberCanBePrivate.Global namespace Sprache { @@ -36,7 +37,6 @@ public static Position FromInput(IInput input) public int Pos { get; - private set; } /// @@ -45,7 +45,6 @@ public int Pos public int Line { get; - private set; } /// @@ -54,7 +53,6 @@ public int Line public int Column { get; - private set; } /// diff --git a/test/Sprache.Tests/Scenarios/AmqpErrorTests.cs b/test/Sprache.Tests/Scenarios/AmqpErrorTests.cs index 83e3f7b..156bb36 100644 --- a/test/Sprache.Tests/Scenarios/AmqpErrorTests.cs +++ b/test/Sprache.Tests/Scenarios/AmqpErrorTests.cs @@ -86,7 +86,7 @@ public class AmqpErrorItem public class AmqpStringItem : AmqpErrorItem { - public string Text { get; private set; } + public string Text { get; } public AmqpStringItem(string text) { @@ -101,8 +101,8 @@ public override string ToString() public class KeyValue : AmqpErrorItem { - public Value Value { get; private set; } - public string Key { get; private set; } + public Value Value { get; } + public string Key { get; } public KeyValue(string key, Value value) { @@ -123,7 +123,7 @@ public class Value public class StringValue : Value { - public string Text { get; private set; } + public string Text { get; } public StringValue(string text) { @@ -138,7 +138,7 @@ public override string ToString() public class IntValue : Value { - public int Value { get; private set; } + public int Value { get; } public IntValue(int value) { From ee302145a574a5d4786a7b8877ecd00bd2b61c8a Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 6 Jul 2021 09:14:57 +1000 Subject: [PATCH 10/16] Minor cleanup --- src/Sprache/Parse.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Sprache/Parse.cs b/src/Sprache/Parse.cs index 9ca958e..d5761fa 100644 --- a/src/Sprache/Parse.cs +++ b/src/Sprache/Parse.cs @@ -2,6 +2,9 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable InconsistentNaming +// ReSharper disable UnusedMember.Global namespace Sprache { @@ -284,7 +287,7 @@ public static Parser> Many(this Parser parser) /// unqualified counterparts. /// /// - /// + /// public static Parser> XMany(this Parser parser) { if (parser == null) throw new ArgumentNullException(nameof(parser)); @@ -389,7 +392,7 @@ public static Parser Ref(Func> reference) if (i.Memos.ContainsKey(p)) { - var pResult = i.Memos[p] as IResult; + var pResult = (IResult)i.Memos[p]; if (pResult.WasSuccessful) return pResult; throw new ParseException(pResult.ToString()); @@ -593,7 +596,7 @@ public static Parser Except(this Parser parser, Parser except) /// public static Parser> Until(this Parser parser, Parser until) { - return parser.Except(until).Many().Then(r => until.Return(r)); + return parser.Except(until).Many().Then(until.Return); } /// @@ -610,7 +613,7 @@ public static Parser Where(this Parser parser, Func predicate) return i => parser(i).IfSuccess(s => predicate(s.Value) ? s : Result.Failure(i, - string.Format("Unexpected {0}.", s.Value), + $"Unexpected {s.Value}.", new string[0])); } @@ -686,9 +689,9 @@ static Parser ChainOperatorRest( if (op == null) throw new ArgumentNullException(nameof(op)); if (operand == null) throw new ArgumentNullException(nameof(operand)); if (apply == null) throw new ArgumentNullException(nameof(apply)); - return or(op.Then(opvalue => + return or(op.Then(opValue => operand.Then(operandValue => - ChainOperatorRest(apply(opvalue, firstOperand, operandValue), op, operand, apply, or))), + ChainOperatorRest(apply(opValue, firstOperand, operandValue), op, operand, apply, or))), Return(firstOperand)); } @@ -742,10 +745,10 @@ static Parser ChainRightOperatorRest( if (op == null) throw new ArgumentNullException(nameof(op)); if (operand == null) throw new ArgumentNullException(nameof(operand)); if (apply == null) throw new ArgumentNullException(nameof(apply)); - return or(op.Then(opvalue => + return or(op.Then(opValue => operand.Then(operandValue => ChainRightOperatorRest(operandValue, op, operand, apply, or)).Then(r => - Return(apply(opvalue, lastOperand, r)))), + Return(apply(opValue, lastOperand, r)))), Return(lastOperand)); } From bbf813908bf8bc2ef936bbc533e72f3821333c14 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 6 Jul 2021 09:35:37 +1000 Subject: [PATCH 11/16] Update publishing key, update main branch --- appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index fe7180a..bf4d6fa 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,7 +3,7 @@ image: Visual Studio 2019 branches: only: - - master + - main - develop pull_requests: @@ -18,8 +18,8 @@ artifacts: deploy: - provider: NuGet api_key: - secure: tCEhrNs1q8bhXiGwKejajsjSyF+/66LwnPge1ntZKrI3mvfDf1Ab8iOrz1IuVRH2 + secure: LOSaZSy3ZL836xUIcCovdIt5kbL/aahbQPl2CvLCWxWaS+YSpKMB/OUAlbgLGp8Z skip_symbols: true artifact: /.*\.nupkg/ on: - branch: /^(master|develop)$/ + branch: /^(main|develop)$/ From 2d6dfa89b7e60bdcf69c14720a3bdfde1fa36111 Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Tue, 6 Jul 2021 09:35:58 +1000 Subject: [PATCH 12/16] Update main branch --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 8239bff..705aa27 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,6 +1,6 @@ $branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL]; $revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; -$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"] +$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"] echo "build: Version suffix is $suffix" From 936ca307c64a943f97037f630e89fb4bd620bbfc Mon Sep 17 00:00:00 2001 From: MagicAndre1981 Date: Tue, 6 Jul 2021 07:34:01 +0200 Subject: [PATCH 13/16] implemented #174: added SourceLink --- src/Sprache/Sprache.csproj | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Sprache/Sprache.csproj b/src/Sprache/Sprache.csproj index 0a0963a..8e998c9 100644 --- a/src/Sprache/Sprache.csproj +++ b/src/Sprache/Sprache.csproj @@ -13,7 +13,20 @@ Apache-2.0 git https://github.com/sprache/Sprache + + true + + + true + + + true + snupkg + + + + From 5139af3b50c4eaf9ca6fa8f2b1354bb4fe64975e Mon Sep 17 00:00:00 2001 From: Nicholas Blumhardt Date: Fri, 30 Jul 2021 15:42:32 +1000 Subject: [PATCH 14/16] Remove comments --- src/Sprache/Sprache.csproj | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Sprache/Sprache.csproj b/src/Sprache/Sprache.csproj index 8e998c9..43e50d7 100644 --- a/src/Sprache/Sprache.csproj +++ b/src/Sprache/Sprache.csproj @@ -13,13 +13,8 @@ Apache-2.0 git https://github.com/sprache/Sprache - true - - true - - true snupkg From 0fc2f4cb86d7a1d0533030b0869ddb1bee273298 Mon Sep 17 00:00:00 2001 From: Marcin Golebiowski Date: Sun, 19 Sep 2021 20:32:37 +0200 Subject: [PATCH 15/16] Improve Parse.Ref --- src/Sprache/Parse.cs | 1 + test/Sprache.Tests/RefTests.cs | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/Sprache.Tests/RefTests.cs diff --git a/src/Sprache/Parse.cs b/src/Sprache/Parse.cs index d5761fa..38a2990 100644 --- a/src/Sprache/Parse.cs +++ b/src/Sprache/Parse.cs @@ -434,6 +434,7 @@ public static Parser Or(this Parser first, Parser second) var fr = first(i); if (!fr.WasSuccessful) { + fr.Remainder.Memos.Clear(); return second(i).IfFailure(sf => DetermineBestError(fr, sf)); } diff --git a/test/Sprache.Tests/RefTests.cs b/test/Sprache.Tests/RefTests.cs new file mode 100644 index 0000000..324731f --- /dev/null +++ b/test/Sprache.Tests/RefTests.cs @@ -0,0 +1,25 @@ +using Xunit; + + +namespace Sprache.Tests +{ + public class RefTests + { + private static Parser ParserSomething = Parse.String("#").Text().Named("something"); + + private static Parser ParserIdentifier = (from a in Parse.String("a") select "a").Named("identifier"); + + private static Parser ParserUnderTest = + (from _0 in Parse.Ref(() => ParserIdentifier) + from _1 in Parse.Ref(() => ParserSomething) + from _2 in Parse.String("_") + select "assignment_1") + .Or(from _0 in Parse.Ref(() => ParserIdentifier) + from _1 in Parse.Ref(() => ParserSomething) + select "assignment_2") + .Or(from _0 in ParserIdentifier select _0); + + [Fact] + public void TestOr() => AssertParser.SucceedsWith(ParserUnderTest, "a=1", o => Assert.Equal("a", o)); + } +} From 0a7bd6f997b29aa1ab9e09b72fd590abd2ae5970 Mon Sep 17 00:00:00 2001 From: Marcin Golebiowski Date: Mon, 20 Sep 2021 21:35:24 +0200 Subject: [PATCH 16/16] Change behavior of Parse.Ref -> throw ParseException only if memo contains info about left recursion --- src/Sprache/Parse.cs | 16 ++-- test/Sprache.Tests/Parse.Ref.Tests.cs | 110 ++++++++++++++++++++++++++ test/Sprache.Tests/ParseTests.cs | 31 -------- test/Sprache.Tests/RefTests.cs | 25 ------ 4 files changed, 120 insertions(+), 62 deletions(-) create mode 100644 test/Sprache.Tests/Parse.Ref.Tests.cs delete mode 100644 test/Sprache.Tests/RefTests.cs diff --git a/src/Sprache/Parse.cs b/src/Sprache/Parse.cs index 38a2990..c36cfff 100644 --- a/src/Sprache/Parse.cs +++ b/src/Sprache/Parse.cs @@ -13,6 +13,11 @@ namespace Sprache /// public static partial class Parse { + /// + /// Message for a failure result when left recursion is detected. + /// + public const string LeftRecursionErrorMessage = "Left recursion in the grammar."; + /// /// TryParse a single character matching 'predicate' /// @@ -393,14 +398,14 @@ public static Parser Ref(Func> reference) if (i.Memos.ContainsKey(p)) { var pResult = (IResult)i.Memos[p]; - if (pResult.WasSuccessful) + if (pResult.WasSuccessful) return pResult; - throw new ParseException(pResult.ToString()); + + if (!pResult.WasSuccessful && pResult.Message == LeftRecursionErrorMessage) + throw new ParseException(pResult.ToString()); } - i.Memos[p] = Result.Failure(i, - "Left recursion in the grammar.", - new string[0]); + i.Memos[p] = Result.Failure(i, LeftRecursionErrorMessage, new string[0]); var result = p(i); i.Memos[p] = result; return result; @@ -434,7 +439,6 @@ public static Parser Or(this Parser first, Parser second) var fr = first(i); if (!fr.WasSuccessful) { - fr.Remainder.Memos.Clear(); return second(i).IfFailure(sf => DetermineBestError(fr, sf)); } diff --git a/test/Sprache.Tests/Parse.Ref.Tests.cs b/test/Sprache.Tests/Parse.Ref.Tests.cs new file mode 100644 index 0000000..533fbaa --- /dev/null +++ b/test/Sprache.Tests/Parse.Ref.Tests.cs @@ -0,0 +1,110 @@ +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Sprache.Tests +{ + public class ParseRefTests + { + private static Parser ParserHash = Parse.String("#").Text().Named("something"); + + private static Parser ParserIdentifier = (from id in Parse.String("id").Text() select id).Named("identifier"); + + private static Parser Parser1UnderTest = + (from _0 in Parse.Ref(() => ParserIdentifier) + from _1 in Parse.Ref(() => ParserHash) + from _2 in Parse.String("_") + select "alternative_1") + .Or(from _0 in Parse.Ref(() => ParserIdentifier) + from _1 in Parse.Ref(() => ParserHash) + select "alternative_2") + .Or(from _0 in ParserIdentifier select _0); + + private static Parser Parser2UnderTest = + (from _0 in Parse.String("a").Text() + from _1 in Parse.Ref(() => Parser2UnderTest) + select _0 + _1) + .Or(from _0 in Parse.String("b").Text() + from _1 in Parse.Ref(() => Parser2UnderTest) + select _0 + _1) + .Or(from _0 in Parse.String("0").Text() select _0); + + private static Parser Parser3UnderTest = + (from _0 in Parse.Ref(() => Parser3UnderTest) + from _1 in Parse.String("a").Text() + select _0 + _1) + .Or(from _0 in Parse.String("b").Text() + from _1 in Parse.Ref(() => Parser3UnderTest) + select _0 + _1) + .Or(from _0 in Parse.String("0").Text() select _0); + + private static Parser Parser4UnderTest = + from _0 in Parse.Ref(() => Parser4UnderTest) + select "simplest left recursion"; + + private static Parser Parser5UnderTest = + (from _0 in Parse.String("_").Text() + from _1 in Parse.Ref(() => Parser5UnderTest) + select _0 + _1) + .Or(from _0 in Parse.String("+").Text() + from _1 in Parse.Ref(() => Parser5UnderTest) + select _0 + _1) + .Or(Parse.Return("")); + + [Fact] + public void MultipleRefs() => AssertParser.SucceedsWith(Parser1UnderTest, "id=1", o => Assert.Equal("id", o)); + + [Fact] + public void RecursiveParserWithoutLeftRecursion() => AssertParser.SucceedsWith(Parser2UnderTest, "ababba0", o => Assert.Equal("ababba0", o)); + + [Fact] + public void RecursiveParserWithLeftRecursion() => Assert.Throws(() => Parser3UnderTest.TryParse("b0")); + + [Fact] + public void SimplestLeftRecursion() => Assert.Throws(() => Parser4UnderTest.TryParse("test")); + + [Fact] + public void EmptyAlternative1() => AssertParser.SucceedsWith(Parser5UnderTest, "_+_+a", o => Assert.Equal("_+_+", o)); + + [Fact] + public void Issue166() + { + var letterA = Parse.Char('a'); + var letterReferenced = Parse.Ref(() => letterA); + var someAlternative = letterReferenced.Or(letterReferenced); + + Assert.False(someAlternative.TryParse("b").WasSuccessful); + } + + static readonly Parser> ASeq = + (from first in Parse.Ref(() => ASeq) + from comma in Parse.Char(',') + from rest in Parse.Char('a').Once() + select first.Concat(rest)) + .Or(Parse.Char('a').Once()); + + [Fact] + public void DetectsLeftRecursion() + { + Assert.Throws(() => ASeq.TryParse("a,a,a")); + } + + static readonly Parser> ABSeq = + (from first in Parse.Ref(() => BASeq) + from rest in Parse.Char('a').Once() + select first.Concat(rest)) + .Or(Parse.Char('a').Once()); + + static readonly Parser> BASeq = + (from first in Parse.Ref(() => ABSeq) + from rest in Parse.Char('b').Once() + select first.Concat(rest)) + .Or(Parse.Char('b').Once()); + + [Fact] + public void DetectsMutualLeftRecursion() + { + Assert.Throws(() => ABSeq.End().TryParse("baba")); + } + } +} diff --git a/test/Sprache.Tests/ParseTests.cs b/test/Sprache.Tests/ParseTests.cs index 01108a1..5336146 100644 --- a/test/Sprache.Tests/ParseTests.cs +++ b/test/Sprache.Tests/ParseTests.cs @@ -144,37 +144,6 @@ public void ParsesString_AsSequenceOfChars() AssertParser.SucceedsWithAll(p, "abc"); } - static readonly Parser> ASeq = - (from first in Parse.Ref(() => ASeq) - from comma in Parse.Char(',') - from rest in Parse.Char('a').Once() - select first.Concat(rest)) - .Or(Parse.Char('a').Once()); - - [Fact] - public void DetectsLeftRecursion() - { - Assert.Throws(() => ASeq.TryParse("a,a,a")); - } - - static readonly Parser> ABSeq = - (from first in Parse.Ref(() => BASeq) - from rest in Parse.Char('a').Once() - select first.Concat(rest)) - .Or(Parse.Char('a').Once()); - - static readonly Parser> BASeq = - (from first in Parse.Ref(() => ABSeq) - from rest in Parse.Char('b').Once() - select first.Concat(rest)) - .Or(Parse.Char('b').Once()); - - [Fact] - public void DetectsMutualLeftRecursion() - { - Assert.Throws(() => ABSeq.End().TryParse("baba")); - } - [Fact] public void WithMany_WhenLastElementFails_FailureReportedAtLastElement() { diff --git a/test/Sprache.Tests/RefTests.cs b/test/Sprache.Tests/RefTests.cs deleted file mode 100644 index 324731f..0000000 --- a/test/Sprache.Tests/RefTests.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Xunit; - - -namespace Sprache.Tests -{ - public class RefTests - { - private static Parser ParserSomething = Parse.String("#").Text().Named("something"); - - private static Parser ParserIdentifier = (from a in Parse.String("a") select "a").Named("identifier"); - - private static Parser ParserUnderTest = - (from _0 in Parse.Ref(() => ParserIdentifier) - from _1 in Parse.Ref(() => ParserSomething) - from _2 in Parse.String("_") - select "assignment_1") - .Or(from _0 in Parse.Ref(() => ParserIdentifier) - from _1 in Parse.Ref(() => ParserSomething) - select "assignment_2") - .Or(from _0 in ParserIdentifier select _0); - - [Fact] - public void TestOr() => AssertParser.SucceedsWith(ParserUnderTest, "a=1", o => Assert.Equal("a", o)); - } -}