From 45287e250a7c359519cf197c2578e4f9e0159878 Mon Sep 17 00:00:00 2001 From: Smaug123 Date: Mon, 22 Jan 2024 21:42:25 +0000 Subject: [PATCH] Split out into an example --- {PrattParser => PrattParser.Example}/Domain.fs | 2 +- .../Example.fs | 3 ++- {PrattParser => PrattParser.Example}/Lexer.fs | 2 +- PrattParser.Example/PrattParser.Example.fsproj | 18 ++++++++++++++++++ PrattParser.Test/PrattParser.Test.fsproj | 1 + PrattParser.Test/TestLexer.fs | 2 +- PrattParser.Test/TestParser.fs | 1 + PrattParser.sln | 6 ++++++ PrattParser/Parser.fs | 7 ++++++- PrattParser/PrattParser.fsproj | 3 --- 10 files changed, 37 insertions(+), 8 deletions(-) rename {PrattParser => PrattParser.Example}/Domain.fs (98%) rename {PrattParser => PrattParser.Example}/Example.fs (98%) rename {PrattParser => PrattParser.Example}/Lexer.fs (98%) create mode 100644 PrattParser.Example/PrattParser.Example.fsproj diff --git a/PrattParser/Domain.fs b/PrattParser.Example/Domain.fs similarity index 98% rename from PrattParser/Domain.fs rename to PrattParser.Example/Domain.fs index 682b698..924e81e 100644 --- a/PrattParser/Domain.fs +++ b/PrattParser.Example/Domain.fs @@ -1,4 +1,4 @@ -namespace PrattParser +namespace ParseExample [] type Expr = diff --git a/PrattParser/Example.fs b/PrattParser.Example/Example.fs similarity index 98% rename from PrattParser/Example.fs rename to PrattParser.Example/Example.fs index 48a6751..f6476dc 100644 --- a/PrattParser/Example.fs +++ b/PrattParser.Example/Example.fs @@ -1,7 +1,8 @@ -namespace PrattParser +namespace ParseExample open System open System.Globalization +open PrattParser [] module Example = diff --git a/PrattParser/Lexer.fs b/PrattParser.Example/Lexer.fs similarity index 98% rename from PrattParser/Lexer.fs rename to PrattParser.Example/Lexer.fs index b4399b5..07d0f46 100644 --- a/PrattParser/Lexer.fs +++ b/PrattParser.Example/Lexer.fs @@ -1,4 +1,4 @@ -namespace PrattParser +namespace ParseExample [] module Lexer = diff --git a/PrattParser.Example/PrattParser.Example.fsproj b/PrattParser.Example/PrattParser.Example.fsproj new file mode 100644 index 0000000..949f1ba --- /dev/null +++ b/PrattParser.Example/PrattParser.Example.fsproj @@ -0,0 +1,18 @@ + + + + net8.0 + true + + + + + + + + + + + + + diff --git a/PrattParser.Test/PrattParser.Test.fsproj b/PrattParser.Test/PrattParser.Test.fsproj index 6107ade..c26efaf 100644 --- a/PrattParser.Test/PrattParser.Test.fsproj +++ b/PrattParser.Test/PrattParser.Test.fsproj @@ -22,6 +22,7 @@ + diff --git a/PrattParser.Test/TestLexer.fs b/PrattParser.Test/TestLexer.fs index 827e862..edf3ed8 100644 --- a/PrattParser.Test/TestLexer.fs +++ b/PrattParser.Test/TestLexer.fs @@ -1,6 +1,6 @@ namespace PrattParser.Test -open PrattParser +open ParseExample open NUnit.Framework open FsUnitTyped diff --git a/PrattParser.Test/TestParser.fs b/PrattParser.Test/TestParser.fs index 529b75b..1d5bdd1 100644 --- a/PrattParser.Test/TestParser.fs +++ b/PrattParser.Test/TestParser.fs @@ -1,5 +1,6 @@ namespace PrattParser.Test +open ParseExample open PrattParser open NUnit.Framework open FsUnitTyped diff --git a/PrattParser.sln b/PrattParser.sln index 3289edb..7004847 100644 --- a/PrattParser.sln +++ b/PrattParser.sln @@ -4,6 +4,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "PrattParser", "PrattParser\ EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "PrattParser.Test", "PrattParser.Test\PrattParser.Test.fsproj", "{7317F801-6AB2-4C33-B6B2-DCB006880B42}" EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "PrattParser.Example", "PrattParser.Example\PrattParser.Example.fsproj", "{95FEFE34-6A1C-4546-8B39-77A97C7F7A82}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -18,5 +20,9 @@ Global {7317F801-6AB2-4C33-B6B2-DCB006880B42}.Debug|Any CPU.Build.0 = Debug|Any CPU {7317F801-6AB2-4C33-B6B2-DCB006880B42}.Release|Any CPU.ActiveCfg = Release|Any CPU {7317F801-6AB2-4C33-B6B2-DCB006880B42}.Release|Any CPU.Build.0 = Release|Any CPU + {95FEFE34-6A1C-4546-8B39-77A97C7F7A82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {95FEFE34-6A1C-4546-8B39-77A97C7F7A82}.Debug|Any CPU.Build.0 = Debug|Any CPU + {95FEFE34-6A1C-4546-8B39-77A97C7F7A82}.Release|Any CPU.ActiveCfg = Release|Any CPU + {95FEFE34-6A1C-4546-8B39-77A97C7F7A82}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/PrattParser/Parser.fs b/PrattParser/Parser.fs index d6de9a6..f7a61df 100644 --- a/PrattParser/Parser.fs +++ b/PrattParser/Parser.fs @@ -252,4 +252,9 @@ module Parser = go lhs rest - let parse parser inputString tokens = parseInner parser inputString tokens 0 + let parse<'tokenTag, 'token, 'expr when 'tokenTag : comparison> + (parser : Parser<'tokenTag, 'token, 'expr>) + (inputString : string) + (tokens : 'token list) + = + parseInner parser inputString tokens 0 diff --git a/PrattParser/PrattParser.fsproj b/PrattParser/PrattParser.fsproj index 6acd119..c461129 100644 --- a/PrattParser/PrattParser.fsproj +++ b/PrattParser/PrattParser.fsproj @@ -6,10 +6,7 @@ - - -