├── .all-contributorsrc
├── .gitattributes
├── .github
├── ISSUE_TEMPLATE
│ ├── bug-report.md
│ ├── feature-request.md
│ ├── module-request.md
│ ├── question.md
│ └── something-else.md
├── pull_request_template.md
├── resources
│ ├── DocfxBadge.svg
│ ├── UsingYoakke.svg
│ ├── YoakkeLogo.png
│ ├── YoakkeLogo.svg
│ └── YoakkeLogoAnimated.svg
└── workflows
│ ├── Docfx.yml
│ ├── PublishNightly.yml
│ ├── PublishPackages.yml
│ └── RunTests.yml
├── .gitignore
├── CONTRIBUTING.md
├── Documentation
├── README.md
└── docfx_project
│ ├── .gitignore
│ ├── api
│ ├── .gitignore
│ └── index.md
│ ├── articles
│ ├── fixing-vs-issues.md
│ ├── intro.md
│ ├── lexer.md
│ ├── parser.md
│ ├── reporting.md
│ └── toc.yml
│ ├── docfx.json
│ ├── images
│ └── fixing-vs-issues
│ │ ├── vs-options.png
│ │ ├── vs-sourcegenerator.png
│ │ ├── vs-texteditor.png
│ │ └── vs-tools.png
│ ├── index.md
│ └── toc.yml
├── LICENSE
├── README.md
└── Sources
├── .editorconfig
├── .idea
└── .idea.Yoakke
│ └── .idea
│ ├── .gitignore
│ ├── .name
│ ├── encodings.xml
│ ├── indexLayout.xml
│ └── vcs.xml
├── Benchmarks
└── .gitignore
├── Examples
└── .gitignore
├── Props
├── Benchmark.Build.props
├── Example.Build.props
├── Package.Build.props
├── Shared.Build.props
├── SourceGenerator.Build.props
└── Test.Build.props
├── Shared
├── Benchmarks
│ └── .gitignore
├── Libraries
│ ├── Collections
│ │ ├── Collections.csproj
│ │ ├── Dense
│ │ │ ├── Combiner.cs
│ │ │ ├── DenseMap.cs
│ │ │ ├── DenseSet.cs
│ │ │ ├── ICombiner.cs
│ │ │ ├── IDenseMap.cs
│ │ │ ├── IDenseSet.cs
│ │ │ ├── IReadOnlyDenseMap.cs
│ │ │ └── IReadOnlyDenseSet.cs
│ │ ├── Graphs
│ │ │ └── BreadthFirst.cs
│ │ ├── IDeque.cs
│ │ ├── Internal
│ │ │ └── SortedIntervalList.cs
│ │ ├── Intervals
│ │ │ ├── Bound.cs
│ │ │ ├── BoundComparer.cs
│ │ │ ├── Interval.Factory.cs
│ │ │ ├── Interval.cs
│ │ │ ├── IntervalComparer.cs
│ │ │ ├── IntervalRelation.cs
│ │ │ ├── LowerBound.cs
│ │ │ └── UpperBound.cs
│ │ ├── RingBuffer.cs
│ │ ├── TupleEqualityComparer.cs
│ │ ├── Values
│ │ │ ├── IReadOnlyValueDictionary.cs
│ │ │ ├── IReadOnlyValueList.cs
│ │ │ ├── ReadOnlyValueDictionary.cs
│ │ │ ├── ReadOnlyValueList.cs
│ │ │ └── ValueCollectionExtensions.cs
│ │ └── key.snk
│ ├── Directory.Build.props
│ ├── Polyfill
│ │ ├── DictionaryExtensions.cs
│ │ ├── EnumerableExtensions.cs
│ │ ├── IReadOnlySet.cs
│ │ ├── KeyValuePairExtensions.cs
│ │ ├── Polyfill.csproj
│ │ ├── QueueExtensions.cs
│ │ ├── ReferenceEqualityComparer.cs
│ │ ├── StackExtensions.cs
│ │ ├── StringExtensions.cs
│ │ ├── TypeExtensions.cs
│ │ └── key.snk
│ ├── SourceGenerator.Common
│ │ ├── AssemblyExtensions.cs
│ │ ├── RoslynExtensions
│ │ │ ├── AttributeDataExtensions.cs
│ │ │ ├── AttributeDescriptor.cs
│ │ │ ├── SymbolExtensions.cs
│ │ │ ├── SyntaxExtensions.cs
│ │ │ └── TypeEnclosure.cs
│ │ ├── ScribanExtensions.cs
│ │ ├── SourceGenerator.Common.csproj
│ │ ├── SourceGeneratorExtensions.cs
│ │ └── key.snk
│ └── Streams
│ │ ├── BufferedStream.cs
│ │ ├── EnumerableStream.cs
│ │ ├── FilteredStream.cs
│ │ ├── IPeekableStream.cs
│ │ ├── IStream.cs
│ │ ├── MemoryStream.cs
│ │ ├── PeekStream.cs
│ │ ├── StreamExtensions.cs
│ │ ├── Streams.csproj
│ │ └── key.snk
└── Tests
│ ├── Collections.Tests
│ ├── Collections.Tests.csproj
│ ├── DenseMapTests.cs
│ ├── DenseSetTests.cs
│ ├── IntervalTests.cs
│ ├── RingBufferTests.cs
│ ├── ValueDictionaryTests.cs
│ ├── ValueListTests.cs
│ └── key.snk
│ ├── Directory.Build.props
│ └── Streams.Tests
│ ├── Streams.Tests.csproj
│ ├── StreamsTests.cs
│ └── key.snk
├── SynKit
├── Benchmarks
│ ├── .gitignore
│ ├── Directory.Build.props
│ └── Parser.Benchmarks
│ │ ├── ExpressionBenchmarks.cs
│ │ ├── ExpressionParser.cs
│ │ ├── Parser.Benchmarks.csproj
│ │ ├── Program.cs
│ │ └── Properties
│ │ └── launchSettings.json
├── Examples
│ ├── Automata.Sample
│ │ ├── Automata.Sample.csproj
│ │ ├── Program.cs
│ │ └── key.snk
│ ├── C.Syntax.Sample
│ │ ├── C.Syntax.Sample.csproj
│ │ ├── Program.cs
│ │ └── key.snk
│ ├── Directory.Build.props
│ ├── Lexer.Sample
│ │ ├── Lexer.Sample.csproj
│ │ ├── Program.cs
│ │ └── key.snk
│ ├── Parser.Sample
│ │ ├── Parser.Sample.csproj
│ │ ├── Program.cs
│ │ └── key.snk
│ └── Reporting.Sample
│ │ ├── Program.cs
│ │ ├── Reporting.Sample.csproj
│ │ └── key.snk
├── Libraries
│ ├── Automata
│ │ ├── Automata.csproj
│ │ ├── Dense
│ │ │ ├── DenseDfa.cs
│ │ │ ├── DenseNfa.cs
│ │ │ ├── IDenseDfa.cs
│ │ │ ├── IDenseFiniteAutomaton.cs
│ │ │ ├── IDenseNfa.cs
│ │ │ ├── IReadOnlyDenseDfa.cs
│ │ │ ├── IReadOnlyDenseFiniteAutomaton.cs
│ │ │ └── IReadOnlyDenseNfa.cs
│ │ ├── DfaExtensions.cs
│ │ ├── EpsilonTransition.cs
│ │ ├── IDfa.cs
│ │ ├── IFiniteAutomaton.cs
│ │ ├── INfa.cs
│ │ ├── IReadOnlyDfa.cs
│ │ ├── IReadOnlyFiniteAutomaton.cs
│ │ ├── IReadOnlyNfa.cs
│ │ ├── IStateCombiner.cs
│ │ ├── Internal
│ │ │ ├── DotWriter.cs
│ │ │ ├── EquivalenceTable.cs
│ │ │ ├── ObservableCollection.cs
│ │ │ └── TrivialImpl.cs
│ │ ├── NfaExtensions.cs
│ │ ├── RegExAst
│ │ │ ├── IRegExNode.cs
│ │ │ ├── RegEx.cs
│ │ │ ├── RegExAnyNode.cs
│ │ │ ├── RegExLitNode.cs
│ │ │ ├── RegExNopNode.cs
│ │ │ ├── RegExOptNode.cs
│ │ │ ├── RegExOrNode.cs
│ │ │ ├── RegExRangeNode.cs
│ │ │ ├── RegExRep0Node.cs
│ │ │ ├── RegExRep1Node.cs
│ │ │ ├── RegExRepBetweenNode.cs
│ │ │ └── RegExSeqNode.cs
│ │ ├── Sparse
│ │ │ ├── Dfa.cs
│ │ │ ├── IReadOnlySparseDfa.cs
│ │ │ ├── IReadOnlySparseFiniteAutomaton.cs
│ │ │ ├── IReadOnlySparseNfa.cs
│ │ │ ├── ISparseDfa.cs
│ │ │ ├── ISparseFiniteAutomaton.cs
│ │ │ ├── ISparseNfa.cs
│ │ │ └── Nfa.cs
│ │ ├── StateCombiner.cs
│ │ ├── StateSet.cs
│ │ ├── Transition.cs
│ │ └── key.snk
│ ├── C.Syntax
│ │ ├── C.Syntax.csproj
│ │ ├── CLexer.cs
│ │ ├── CPreProcessor.cs
│ │ ├── CToken.cs
│ │ ├── CTokenType.cs
│ │ ├── IMacro.cs
│ │ ├── IPreProcessor.cs
│ │ ├── MacroElement.cs
│ │ ├── Macros
│ │ │ └── CounterMacro.cs
│ │ ├── PreProcessorExtensions.cs
│ │ ├── UserMacro.cs
│ │ └── key.snk
│ ├── Directory.Build.props
│ ├── Lexer.Generator
│ │ ├── Diagnostics.cs
│ │ ├── InjectedSources
│ │ │ ├── CharSourceAttribute.cs
│ │ │ ├── EndAttribute.cs
│ │ │ ├── ErrorAttribute.cs
│ │ │ ├── IgnoreAttribute.cs
│ │ │ ├── LexerAttribute.cs
│ │ │ ├── RegexAttribute.cs
│ │ │ └── TokenAttribute.cs
│ │ ├── Lexer.Generator.csproj
│ │ ├── LexerSourceGenerator.cs
│ │ ├── Model
│ │ │ ├── LexerModel.cs
│ │ │ └── TokenModel.cs
│ │ ├── RegExParser.cs
│ │ ├── Templates
│ │ │ └── lexer.sbncs
│ │ └── key.snk
│ ├── Lexer
│ │ ├── CharStreamExtensions.cs
│ │ ├── ICharStream.cs
│ │ ├── ILexer.cs
│ │ ├── IToken.Generic.cs
│ │ ├── IToken.cs
│ │ ├── Lexer.csproj
│ │ ├── LexerExtensions.cs
│ │ ├── Regexes.cs
│ │ ├── TextReaderCharStream.cs
│ │ ├── Token.cs
│ │ └── key.snk
│ ├── Parser.Generator
│ │ ├── Ast
│ │ │ ├── BnfAst.Alt.cs
│ │ │ ├── BnfAst.Call.cs
│ │ │ ├── BnfAst.FoldLeft.cs
│ │ │ ├── BnfAst.Group.cs
│ │ │ ├── BnfAst.Literal.cs
│ │ │ ├── BnfAst.MethodCall.cs
│ │ │ ├── BnfAst.Opt.cs
│ │ │ ├── BnfAst.Placeholder.cs
│ │ │ ├── BnfAst.Rep0.cs
│ │ │ ├── BnfAst.Rep1.cs
│ │ │ ├── BnfAst.Seq.cs
│ │ │ ├── BnfAst.Transform.cs
│ │ │ └── BnfAst.cs
│ │ ├── BnfDesugar.cs
│ │ ├── Diagnostics.cs
│ │ ├── InjectedSources
│ │ │ ├── CustomParserAttribute.cs
│ │ │ ├── LeftAttribute.cs
│ │ │ ├── ParserAttribute.cs
│ │ │ ├── RightAttribute.cs
│ │ │ ├── RuleAttribute.cs
│ │ │ └── TokenSourceAttribute.cs
│ │ ├── Model
│ │ │ ├── ParserModel.cs
│ │ │ ├── PrecedenceEntry.cs
│ │ │ ├── Rule.cs
│ │ │ ├── RuleSet.cs
│ │ │ └── TokenKindSet.cs
│ │ ├── Parser.Generator.csproj
│ │ ├── ParserSourceGenerator.cs
│ │ ├── Syntax
│ │ │ ├── BnfLexer.cs
│ │ │ ├── BnfParser.cs
│ │ │ ├── BnfToken.cs
│ │ │ └── BnfTokenType.cs
│ │ ├── Templates
│ │ │ └── parser.sbncs
│ │ ├── TypeNames.cs
│ │ └── key.snk
│ ├── Parser
│ │ ├── Combinator.cs
│ │ ├── ParseError.cs
│ │ ├── ParseErrorElement.cs
│ │ ├── ParseErrorElementDictionary.cs
│ │ ├── ParseOk.cs
│ │ ├── ParseResult.Factory.cs
│ │ ├── ParseResult.cs
│ │ ├── Parser.csproj
│ │ ├── Punctuated.cs
│ │ ├── PunctuatedValue.cs
│ │ └── key.snk
│ ├── Reporting
│ │ ├── Diagnostics.cs
│ │ ├── FootnoteDiagnosticInfo.cs
│ │ ├── IDiagnosticInfo.cs
│ │ ├── Present
│ │ │ ├── ColoredBuffer.cs
│ │ │ ├── ColoredToken.cs
│ │ │ ├── DiagnosticsStyle.cs
│ │ │ ├── IDiagnosticsPresenter.cs
│ │ │ ├── ISyntaxHighlighter.cs
│ │ │ ├── NullSyntaxHighlighter.cs
│ │ │ ├── SyntaxHighlightStyle.cs
│ │ │ ├── TextDiagnosticsPresenter.cs
│ │ │ └── TokenKind.cs
│ │ ├── Reporting.csproj
│ │ ├── Severity.cs
│ │ ├── SourceDiagnosticInfo.cs
│ │ └── key.snk
│ └── Text
│ │ ├── ISourceFile.cs
│ │ ├── Location.cs
│ │ ├── Metrics
│ │ ├── IStringMetric.cs
│ │ ├── LevenshteinDistance.cs
│ │ └── OptimalStringAlignmentDistance.cs
│ │ ├── Position.cs
│ │ ├── Range.cs
│ │ ├── SourceFile.cs
│ │ ├── Text.csproj
│ │ └── key.snk
├── README.md
└── Tests
│ ├── Automata.Tests
│ ├── Automata.Tests.csproj
│ ├── AutomatonTestBase.cs
│ ├── DfaTests.cs
│ ├── EpsilonNfaTests.cs
│ ├── NfaTests.cs
│ └── key.snk
│ ├── C.Syntax.Tests
│ ├── C.Syntax.Tests.csproj
│ ├── CLexerTests.cs
│ ├── CPreProcessorTests.cs
│ └── key.snk
│ ├── Directory.Build.props
│ ├── Lexer.Tests
│ ├── AdvancedLexerGeneratorTests.cs
│ ├── CharStreamTests.cs
│ ├── Issue140Tests.cs
│ ├── Issue17Tests.cs
│ ├── Lexer.Tests.csproj
│ ├── LexerGeneratorTests.cs
│ ├── LexerGeneratorWithoutNamespaceTests.cs
│ ├── RegexesTests.cs
│ ├── TestBase.cs
│ ├── TokenTests.cs
│ └── key.snk
│ ├── Parser.Generator.Tests
│ ├── CodeGenerationTestBase.cs
│ ├── ExpressionParserTests.cs
│ ├── Parser.Generator.Tests.csproj
│ ├── key.snk
│ └── verified
│ │ └── ExpressionParserTests.SimpleMathExpression.verified.txt
│ ├── Parser.Tests
│ ├── CombinatorTests.cs
│ ├── ExpressionParserTests.cs
│ ├── IndirectLeftRecursionTests.cs
│ ├── Issue138Tests.cs
│ ├── Issue17Tests.cs
│ ├── Issue59Tests.cs
│ ├── Issue62Tests.cs
│ ├── LeftRecursionTests.cs
│ ├── ParseErrorTests.cs
│ ├── Parser.Tests.csproj
│ ├── PunctuatedTests.cs
│ └── key.snk
│ ├── Reporting.Tests
│ ├── AssertUtils.cs
│ ├── Reporting.Tests.csproj
│ ├── TextPresenterTests.cs
│ ├── UnfilledTestPresenterTests.cs
│ └── key.snk
│ └── Text.Tests
│ ├── PositionTests.cs
│ ├── RangeTests.cs
│ ├── SourceFileTests.cs
│ ├── StringMetricsTests.cs
│ ├── Text.Tests.csproj
│ └── key.snk
├── Tests
└── .gitignore
├── Tools
├── .gitignore
├── Directory.Build.props
└── NugetMaintainer
│ ├── NugetMaintainer.csproj
│ ├── Program.cs
│ └── key.snk
└── Yoakke.sln
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.png binary
3 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug-report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a bug report to help us fix the issue
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **Which libraries does it affect?**
14 | Which Yoakke modules are you using that causes this problem.
15 |
16 | **To Reproduce**
17 | Steps to reproduce the behavior:
18 | 1. Go to '...'
19 | 2. Click on '....'
20 | 3. Scroll down to '....'
21 | 4. See error
22 |
23 | **Expected behavior**
24 | A clear and concise description of what you expected to happen.
25 |
26 | **Environment (please complete the following information):**
27 | - OS: [e.g. Windows 10]
28 | - .NET version: [e.g. .NET 5]
29 | - Version [e.g. 1.1-preview]
30 |
31 | **Additional context**
32 | Add any other context about the problem here.
33 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature-request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest a feature for an existing module
4 | title: ''
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/module-request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Module request
3 | about: Suggest a new module idea
4 | title: "[MODULE REQUEST]"
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 | **What area would this module cover? Please describe.**
11 | A clear and concise description of what this new model would help in. Ex. I'd like to generate ELF binaries but there's no way to do that yet without involving an external assembler [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen. What would you like to see in the module? How will that fit into the existing ecosystem?
15 |
16 | **Additional context**
17 | Add any other context or screenshots about the feature request here.
18 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Question
3 | about: Ask something that wasn't clarified in the available documents
4 | title: ''
5 | labels: documentation, question
6 | assignees: ''
7 |
8 | ---
9 |
10 | Ask your question here.
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/something-else.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Something else
3 | about: If your issue does not fit into the other categories
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | Please describe your issue thoroughly.
11 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | If this is still work in progress, make sure to mark it as 'Draft'! You can change it back to ready, once you are done.
4 |
5 |
9 |
10 | **Please describe what this PR does, which issue(s) it solves**
11 | If there is no issue created yet, consider opening an issue first. You can link the related issue using a keyword and the issue number, like `Closes #12` or `Fixes #5`.
12 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/.github/resources/YoakkeLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LanguageDev/Yoakke/ccd4ebf30355e451e4c362d594c741303b78cf5f/.github/resources/YoakkeLogo.png
--------------------------------------------------------------------------------
/.github/workflows/Docfx.yml:
--------------------------------------------------------------------------------
1 | name: 'Docfx generation'
2 |
3 | on:
4 | workflow_dispatch:
5 | push:
6 | branches:
7 | - master
8 | paths:
9 | - 'Sources/**'
10 | - 'Documentation/docfx_project/**'
11 |
12 | jobs:
13 | documentation:
14 | runs-on: ubuntu-latest
15 | steps:
16 | - name: Clone the repo
17 | uses: actions/checkout@v2
18 | - name: Setup .NET
19 | uses: actions/setup-dotnet@v1
20 | with:
21 | dotnet-version: '8.0.407'
22 | - name: Run DocFx
23 | uses: nikeee/docfx-action@v1.0.0
24 | with:
25 | args: Documentation/docfx_project/docfx.json
26 | - name: Publish to Github Pages
27 | uses: maxheld83/ghpages@master
28 | env:
29 | BUILD_DIR: Documentation/docfx_project/_site
30 | GH_PAT: ${{ secrets.GH_PAT }}
31 |
--------------------------------------------------------------------------------
/.github/workflows/PublishNightly.yml:
--------------------------------------------------------------------------------
1 | name: 'Publish nightly'
2 |
3 | on:
4 | workflow_dispatch:
5 | schedule:
6 | - cron: '0 2 * * *' # run at 2 AM UTC
7 |
8 | jobs:
9 | check:
10 | continue-on-error: true
11 | runs-on: windows-latest
12 | outputs:
13 | status: ${{ join(steps.*.conclusion) }}
14 | steps:
15 | - id: clone-repo
16 | name: Clone the repo
17 | uses: actions/checkout@v2
18 | - id: commits-happened
19 | name: Check if commits happened in the last 72 hours
20 | run: |
21 | if([string]::IsNullOrWhitespace((git log ${GITHUB_REF##*/} --since="72 hours ago") -join '')) {
22 | Echo "No recent commits, skipping nightly build"
23 | Exit 1
24 | }
25 | deployment:
26 | runs-on: windows-latest
27 | needs: check
28 | if: "!contains(needs.check.outputs.status, 'failure')"
29 | steps:
30 | - name: Clone the repo
31 | uses: actions/checkout@v2
32 | - name: Setup .NET
33 | uses: actions/setup-dotnet@v1
34 | with:
35 | dotnet-version: '8.0.407'
36 | - name: Get current time
37 | uses: 1466587594/get-current-time@v2
38 | id: current-time
39 | with:
40 | format: Y.M.D-H.m.s
41 | - name: Build and package
42 | run: dotnet build Sources/Yoakke.sln --configuration Release /p:VersionPrefix=${{ steps.current-time.outputs.formattedTime }} /p:VersionSuffix=nightly /p:PackageReleaseNotes="Nightly build"
43 | - name: Clean up NuGet.org packages
44 | run: dotnet run --project Sources/Tools/NugetMaintainer/NugetMaintainer.csproj -- --local-root Sources --prefix Yoakke --owner LanguageDev --api-key ${{ secrets.NUGET_TOKEN }} --nightly-suffix nightly --timestamp ${{ steps.current-time.outputs.formattedTime }} --timestamp-format yyyy.M.d-H.m.s- --lookbehind-days 3 --delay-between-requests 15
45 | - name: Upload to NuGet.org
46 | run: dotnet nuget push Sources/**/*${{ steps.current-time.outputs.formattedTime }}-nightly.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json --no-symbols
47 |
--------------------------------------------------------------------------------
/.github/workflows/PublishPackages.yml:
--------------------------------------------------------------------------------
1 | name: 'Publish packages'
2 |
3 | on:
4 | release:
5 | types: [published]
6 |
7 | jobs:
8 | deployment:
9 | runs-on: windows-latest
10 | steps:
11 | - name: Clone the repo
12 | uses: actions/checkout@v2
13 | - name: Setup .NET
14 | uses: actions/setup-dotnet@v1
15 | with:
16 | dotnet-version: '8.0.407'
17 | - name: Build and package
18 | run: dotnet build Sources/Yoakke.sln --configuration Release /p:Version=${{ github.event.release.tag_name }} /p:PackageReleaseNotes="See https://github.com/LanguageDev/Yoakke/releases/tag/${{ github.event.release.tag_name }}"
19 | - name: Upload to GitHub
20 | uses: actions/upload-artifact@v2
21 | with:
22 | name: Yoakke
23 | path: Sources/**/*${{ github.event.release.tag_name }}.nupkg
24 | - name: Upload to NuGet.org
25 | run: dotnet nuget push Sources/**/*${{ github.event.release.tag_name }}.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json --no-symbols true
26 |
--------------------------------------------------------------------------------
/.github/workflows/RunTests.yml:
--------------------------------------------------------------------------------
1 | name: 'Run tests'
2 |
3 | on:
4 | workflow_dispatch:
5 | push:
6 | branches:
7 | - master
8 | paths:
9 | - 'Sources/**'
10 | pull_request:
11 | branches:
12 | - '*'
13 | paths:
14 | - 'Sources/**'
15 |
16 | jobs:
17 | Solution:
18 | runs-on: ${{ matrix.os }}
19 | strategy:
20 | matrix:
21 | os: [windows-latest, ubuntu-latest, macos-latest]
22 | steps:
23 | - name: Clone the repo
24 | uses: actions/checkout@v2
25 | - name: Setup .NET
26 | uses: actions/setup-dotnet@v1
27 | with:
28 | dotnet-version: '8.0.407'
29 | - name: Test
30 | run: |
31 | cd Sources
32 | dotnet test
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | obj
2 | bin
3 | doc
4 | .vs
5 | .vscode
6 | *.filters
7 | *.user
8 | TestResults
9 | CoverageResults
10 | node_modules
11 | *.binlog
12 |
--------------------------------------------------------------------------------
/Documentation/README.md:
--------------------------------------------------------------------------------
1 | # Yoakke Documentation
2 |
3 | The documentation for Yoakke is inside a [DocFX](https://dotnet.github.io/docfx/) project. The API docs is automaticall generated from source code, while the articles are written in the project folder in the [Markdown](https://daringfireball.net/projects/markdown/) format.
4 |
5 | The documentation is published to this repositorys [GitHub Pages](https://languagedev.github.io/Yoakke/).
6 |
--------------------------------------------------------------------------------
/Documentation/docfx_project/.gitignore:
--------------------------------------------------------------------------------
1 | ###############
2 | # folder #
3 | ###############
4 | /**/DROP/
5 | /**/TEMP/
6 | /**/packages/
7 | /**/bin/
8 | /**/obj/
9 | _site
10 |
--------------------------------------------------------------------------------
/Documentation/docfx_project/api/.gitignore:
--------------------------------------------------------------------------------
1 | ###############
2 | # temp file #
3 | ###############
4 | *.yml
5 | .manifest
6 |
--------------------------------------------------------------------------------
/Documentation/docfx_project/api/index.md:
--------------------------------------------------------------------------------
1 | # Yoakke API docs
2 | This is the API documentation for Yoakke generated from source code.
3 |
4 | Ideally, if you want to improve this, please do so in the code doc comments as that will help during development too!
5 |
--------------------------------------------------------------------------------
/Documentation/docfx_project/articles/fixing-vs-issues.md:
--------------------------------------------------------------------------------
1 | # Fixing Visual Studio issues
2 |
3 | When using Visual Studio either as an end-user of Yoakke, or as a library developer, you might encounter an odd issue related to Source Generators:
4 |
5 | There are errors appearing in the Error List but in the Output window the build succeeds, still, Visual Studio refuses to start any application in the project. To fix this, please try the steps below.
6 |
7 | ### 1) First, you should open the `Tools` in the menu bar:
8 |
9 | 
10 |
11 | ### 2) Then, you go to `Options`:
12 |
13 | 
14 |
15 | ### 3) You will find a menu called `Text editor`. You open it, then click on `C#` then `Advanced`:
16 |
17 | 
18 |
19 | ### 4) Make sure the tick box in `Editor Help` called `Enable all features in opened files from source generators` is **ENABLED**:
20 |
21 | 
--------------------------------------------------------------------------------
/Documentation/docfx_project/articles/intro.md:
--------------------------------------------------------------------------------
1 | # Using the Yoakke libraries
2 |
3 | Here your can find small articles and tutorials about how to use different modules of Yoakke.
4 |
--------------------------------------------------------------------------------
/Documentation/docfx_project/articles/toc.yml:
--------------------------------------------------------------------------------
1 | - name: Introduction
2 | href: intro.md
3 | - name: Fixing Visual Studio issues
4 | href: fixing-vs-issues.md
5 | - name: Lexing
6 | href: lexer.md
7 | - name: Parsing
8 | href: parser.md
9 | - name: Error reporting
10 | href: reporting.md
11 |
--------------------------------------------------------------------------------
/Documentation/docfx_project/docfx.json:
--------------------------------------------------------------------------------
1 | {
2 | "metadata": [
3 | {
4 | "src": [
5 | {
6 | "src": "../../",
7 | "files": [
8 | "Sources/**.csproj"
9 | ],
10 | "exclude": [
11 | "**/Examples/**",
12 | "**/Benchmarks/**",
13 | "**/Tests/**",
14 | "**/*.Tests/**",
15 | "**/*.Tests.*/**",
16 | "**/*.Example/**",
17 | "**/*.Sample/**",
18 | "**/*.Benchmarks/**"
19 | ]
20 | }
21 | ],
22 | "dest": "api",
23 | "disableGitFeatures": false,
24 | "disableDefaultFilter": false
25 | }
26 | ],
27 | "build": {
28 | "globalMetadata": {
29 | "_gitContribute": {
30 | "apiSpecFolder": "Documentation/docfx_project/apidoc"
31 | }
32 | },
33 | "content": [
34 | {
35 | "files": [
36 | "api/**.yml",
37 | "api/index.md"
38 | ]
39 | },
40 | {
41 | "files": [
42 | "articles/**.md",
43 | "articles/**/toc.yml",
44 | "toc.yml",
45 | "*.md"
46 | ]
47 | }
48 | ],
49 | "resource": [
50 | {
51 | "files": [
52 | "images/**"
53 | ]
54 | }
55 | ],
56 | "overwrite": [
57 | {
58 | "files": [
59 | "apidoc/**.md"
60 | ],
61 | "exclude": [
62 | "obj/**",
63 | "_site/**"
64 | ]
65 | }
66 | ],
67 | "dest": "_site",
68 | "globalMetadataFiles": [],
69 | "fileMetadataFiles": [],
70 | "template": [
71 | "default"
72 | ],
73 | "postProcessors": [],
74 | "markdownEngineName": "markdig",
75 | "noLangKeyword": false,
76 | "keepFileLink": false,
77 | "cleanupCacheHistory": false,
78 | "disableGitFeatures": false
79 | }
80 | }
--------------------------------------------------------------------------------
/Documentation/docfx_project/images/fixing-vs-issues/vs-options.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LanguageDev/Yoakke/ccd4ebf30355e451e4c362d594c741303b78cf5f/Documentation/docfx_project/images/fixing-vs-issues/vs-options.png
--------------------------------------------------------------------------------
/Documentation/docfx_project/images/fixing-vs-issues/vs-sourcegenerator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LanguageDev/Yoakke/ccd4ebf30355e451e4c362d594c741303b78cf5f/Documentation/docfx_project/images/fixing-vs-issues/vs-sourcegenerator.png
--------------------------------------------------------------------------------
/Documentation/docfx_project/images/fixing-vs-issues/vs-texteditor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LanguageDev/Yoakke/ccd4ebf30355e451e4c362d594c741303b78cf5f/Documentation/docfx_project/images/fixing-vs-issues/vs-texteditor.png
--------------------------------------------------------------------------------
/Documentation/docfx_project/images/fixing-vs-issues/vs-tools.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LanguageDev/Yoakke/ccd4ebf30355e451e4c362d594c741303b78cf5f/Documentation/docfx_project/images/fixing-vs-issues/vs-tools.png
--------------------------------------------------------------------------------
/Documentation/docfx_project/index.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | # The official Yoakke documentation
6 |
7 | This site contains API documentation as well as articles about how to use the different modules.
8 |
9 | Very much work in progress, contributions are welcome!
10 |
--------------------------------------------------------------------------------
/Documentation/docfx_project/toc.yml:
--------------------------------------------------------------------------------
1 | - name: Articles
2 | href: articles/
3 | homepage: articles/intro.md
4 | - name: Api Documentation
5 | href: api/
6 | homepage: api/index.md
7 |
--------------------------------------------------------------------------------
/Sources/.idea/.idea.Yoakke/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Rider ignored files
5 | /projectSettingsUpdater.xml
6 | /modules.xml
7 | /contentModel.xml
8 | /.idea.Yoakke.iml
9 | # Editor-based HTTP Client requests
10 | /httpRequests/
11 | # Datasource local storage ignored files
12 | /dataSources/
13 | /dataSources.local.xml
14 |
--------------------------------------------------------------------------------
/Sources/.idea/.idea.Yoakke/.idea/.name:
--------------------------------------------------------------------------------
1 | Yoakke
--------------------------------------------------------------------------------
/Sources/.idea/.idea.Yoakke/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Sources/.idea/.idea.Yoakke/.idea/indexLayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Sources/.idea/.idea.Yoakke/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Sources/Benchmarks/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LanguageDev/Yoakke/ccd4ebf30355e451e4c362d594c741303b78cf5f/Sources/Benchmarks/.gitignore
--------------------------------------------------------------------------------
/Sources/Examples/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LanguageDev/Yoakke/ccd4ebf30355e451e4c362d594c741303b78cf5f/Sources/Examples/.gitignore
--------------------------------------------------------------------------------
/Sources/Props/Benchmark.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | false
5 |
6 |
7 |
8 |
9 | net8.0
10 | enable
11 | enable
12 | Exe
13 | false
14 | false
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Sources/Props/Example.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | net8.0
7 | Exe
8 | false
9 | false
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Sources/Props/Package.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | netstandard2.0
7 |
8 |
9 |
10 | $(MSBuildProjectDirectory)/bin/doc/Yoakke.$(MSBuildProjectName).xml
11 | Yoakke.$(MSBuildProjectName)
12 | true
13 | Yoakke.$(MSBuildProjectName)
14 | YoakkeLogo.png
15 | LanguageDev team
16 | A collection of .NET libraries to help compiler development.
17 | Apache-2.0
18 | Yoakke, library, framework, infrastructure, lexer, parser, compiler, interpreter
19 | Copyright (c) 2021 LanguageDev team
20 | git
21 | https://github.com/LanguageDev/Yoakke
22 |
23 |
24 |
25 |
26 | True
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Sources/Props/Shared.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | latest
6 | enable
7 |
8 |
9 | latest
10 | 9999
11 |
12 |
13 | Yoakke.$(MSBuildProjectName)
14 | $(MSBuildThisFileDirectory)..\
15 | $(SolutionDir)
16 |
17 |
18 | true
19 | key.snk
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Sources/Props/Test.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | net8.0
7 | false
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 | all
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Sources/Shared/Benchmarks/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LanguageDev/Yoakke/ccd4ebf30355e451e4c362d594c741303b78cf5f/Sources/Shared/Benchmarks/.gitignore
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Collections/Collections.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Collections/Dense/Combiner.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 Yoakke.
2 | // Licensed under the Apache License, Version 2.0.
3 | // Source repository: https://github.com/LanguageDev/Yoakke
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 |
9 | namespace Yoakke.Collections.Dense;
10 |
11 | ///
12 | /// Utilities for s.
13 | ///
14 | /// The type of values to combine.
15 | public static class Combiner
16 | {
17 | private class OverrideCombiner : ICombiner
18 | {
19 | public T Combine(T existing, T added) => added;
20 | }
21 |
22 | private class LambdaCombiner : ICombiner
23 | {
24 | private readonly Combine combine;
25 |
26 | public LambdaCombiner(Combine combine)
27 | {
28 | this.combine = combine;
29 | }
30 |
31 | public T Combine(T existing, T added) => this.combine(existing, added);
32 | }
33 |
34 | ///
35 | /// Combines an existing value with a new one.
36 | ///
37 | /// The existing value.
38 | /// The new value.
39 | /// The new, combined value of the existing and the new one.
40 | public delegate T Combine(T existing, T added);
41 |
42 | ///
43 | /// A default instance, that simply overrides the existing value with the new one.
44 | ///
45 | public static ICombiner Default { get; } = new OverrideCombiner();
46 |
47 | ///
48 | /// Creates a combiner from the given delegate.
49 | ///
50 | /// The delegate to use for combination.
51 | /// The combiner created from .
52 | public static ICombiner Create(Combine combine) => new LambdaCombiner(combine);
53 | }
54 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Collections/Dense/ICombiner.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 Yoakke.
2 | // Licensed under the Apache License, Version 2.0.
3 | // Source repository: https://github.com/LanguageDev/Yoakke
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 |
9 | namespace Yoakke.Collections.Dense;
10 |
11 | ///
12 | /// An object that can combine multiple values into one.
13 | /// Can be used to combine overlapping values in a mapping for example.
14 | ///
15 | /// The type of values to combine.
16 | public interface ICombiner
17 | {
18 | ///
19 | /// Combines an existing value with a new one.
20 | ///
21 | /// The existing value.
22 | /// The new value.
23 | /// The new, combined value of and .
24 | public T Combine(T existing, T added);
25 | }
26 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Collections/Dense/IDenseMap.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 Yoakke.
2 | // Licensed under the Apache License, Version 2.0.
3 | // Source repository: https://github.com/LanguageDev/Yoakke
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 | using Yoakke.Collections.Intervals;
9 |
10 | namespace Yoakke.Collections.Dense;
11 |
12 | ///
13 | /// A mapping interface that stores the contained elements as intervals.
14 | ///
15 | /// The key type.
16 | /// The value type.
17 | public interface IDenseMap : IReadOnlyDenseMap, ICollection, TValue>>
18 | {
19 | ///
20 | /// Adds an element with the provided interval of keys and value to the mapping.
21 | ///
22 | /// The object to use as the keys of the element to add.
23 | /// The object to use as the value of the element to add.
24 | public void Add(Interval keys, TValue value);
25 |
26 | ///
27 | /// Removes the element with the specified interval of keys from the mapping.
28 | ///
29 | /// The keys of the element to remove.
30 | /// True if the element is successfully removed, otherwise false.
31 | /// This method also returns false if no keys were found in the mapping.
32 | public bool Remove(Interval keys);
33 | }
34 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Collections/Graphs/BreadthFirst.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 Yoakke.
2 | // Licensed under the Apache License, Version 2.0.
3 | // Source repository: https://github.com/LanguageDev/Yoakke
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Collections.Generic.Polyfill;
8 | using System.Text;
9 |
10 | namespace Yoakke.Collections.Graphs;
11 |
12 | ///
13 | /// Generic BFS implementation.
14 | ///
15 | public static class BreadthFirst
16 | {
17 | ///
18 | /// Does a breadth-first search.
19 | ///
20 | /// The vertex type.
21 | /// The initial vertex.
22 | /// The function to retrieve the neighbors.
23 | /// The sequence of the visited vertices.
24 | public static IEnumerable Search(TVertex initial, Func> getNeighbors) =>
25 | Search(initial, getNeighbors, EqualityComparer.Default);
26 |
27 | ///
28 | /// Does a breadth-first search.
29 | ///
30 | /// The vertex type.
31 | /// The initial vertex.
32 | /// The function to retrieve the neighbors.
33 | /// The vertex comparer to use.
34 | /// The sequence of the visited vertices.
35 | public static IEnumerable Search(
36 | TVertex initial,
37 | Func> getNeighbors,
38 | IEqualityComparer comparer)
39 | {
40 | var explored = new HashSet(comparer);
41 | var q = new Queue();
42 | q.Enqueue(initial);
43 | while (q.TryDequeue(out var v))
44 | {
45 | yield return v;
46 | foreach (var w in getNeighbors(v))
47 | {
48 | if (explored.Add(w)) q.Enqueue(w);
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Collections/IDeque.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 Yoakke.
2 | // Licensed under the Apache License, Version 2.0.
3 | // Source repository: https://github.com/LanguageDev/Yoakke
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 |
9 | namespace Yoakke.Collections;
10 |
11 | ///
12 | /// A generic double-ended queue interface.
13 | ///
14 | /// The item type.
15 | public interface IDeque : IReadOnlyList, IList
16 | {
17 | ///
18 | /// Adds an item to the front of the queue.
19 | ///
20 | /// The item to add.
21 | public void AddFront(T item);
22 |
23 | ///
24 | /// Adds an item to the back of the queue.
25 | ///
26 | /// The item to add.
27 | public void AddBack(T item);
28 |
29 | ///
30 | /// Removes an item from the front of the queue.
31 | ///
32 | /// The removed item.
33 | public T RemoveFront();
34 |
35 | ///
36 | /// Removes an item from the back of the queue.
37 | ///
38 | /// The removed item.
39 | public T RemoveBack();
40 | }
41 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Collections/Intervals/Bound.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 Yoakke.
2 | // Licensed under the Apache License, Version 2.0.
3 | // Source repository: https://github.com/LanguageDev/Yoakke
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 |
9 | namespace Yoakke.Collections.Intervals;
10 |
11 | ///
12 | /// A common base for interval endpoints.
13 | ///
14 | /// The type of the endpoint value.
15 | public abstract record Bound : IComparable>
16 | {
17 | ///
18 | public int CompareTo(Bound other) => BoundComparer.Default.Compare(this, other);
19 |
20 | ///
21 | public override int GetHashCode() => BoundComparer.Default.GetHashCode(this);
22 | }
23 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Collections/Intervals/Interval.Factory.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 Yoakke.
2 | // Licensed under the Apache License, Version 2.0.
3 | // Source repository: https://github.com/LanguageDev/Yoakke
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 |
9 | namespace Yoakke.Collections.Intervals;
10 |
11 | ///
12 | /// Factory methods and constants for generic intervals.
13 | ///
14 | internal static class Interval
15 | {
16 | ///
17 | /// The valid infinity strings without sign.
18 | ///
19 | internal static readonly IReadOnlyList InfinityStrings = new[]
20 | {
21 | "∞", "oo", "infinity", "infty", string.Empty,
22 | };
23 | }
24 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Collections/TupleEqualityComparer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 Yoakke.
2 | // Licensed under the Apache License, Version 2.0.
3 | // Source repository: https://github.com/LanguageDev/Yoakke
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Text;
8 |
9 | namespace Yoakke.Collections;
10 |
11 | ///
12 | /// A tuple equality comparer with custom element comparers.
13 | ///
14 | /// The first element type.
15 | /// The second element type.
16 | public class TupleEqualityComparer : IEqualityComparer<(T1, T2)>
17 | {
18 | ///
19 | /// The comparer of the first element.
20 | ///
21 | public IEqualityComparer FirstComparer { get; }
22 |
23 | ///
24 | /// The comparer of the second element.
25 | ///
26 | public IEqualityComparer SecondComparer { get; }
27 |
28 | ///
29 | /// Initializes a new instance of the class.
30 | ///
31 | /// The first comparer to use.
32 | /// The second comparer to use.
33 | public TupleEqualityComparer(IEqualityComparer firstComparer, IEqualityComparer secondComparer)
34 | {
35 | this.FirstComparer = firstComparer;
36 | this.SecondComparer = secondComparer;
37 | }
38 |
39 | ///
40 | public bool Equals((T1, T2) x, (T1, T2) y) =>
41 | this.FirstComparer.Equals(x.Item1, y.Item1)
42 | && this.SecondComparer.Equals(x.Item2, y.Item2);
43 |
44 | ///
45 | public int GetHashCode((T1, T2) obj)
46 | {
47 | var h = default(HashCode);
48 | h.Add(obj.Item1, this.FirstComparer);
49 | h.Add(obj.Item2, this.SecondComparer);
50 | return h.ToHashCode();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Collections/Values/IReadOnlyValueDictionary.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 Yoakke.
2 | // Licensed under the Apache License, Version 2.0.
3 | // Source repository: https://github.com/LanguageDev/Yoakke
4 |
5 | using System;
6 | using System.Collections.Generic;
7 |
8 | namespace Yoakke.Collections.Values;
9 |
10 | ///
11 | /// Represents a generic associative container of keys and values that implements value-based equality.
12 | ///
13 | /// The key type.
14 | /// The value type.
15 | public interface IReadOnlyValueDictionary
16 | : IReadOnlyDictionary,
17 | IEquatable>,
18 | IEquatable>
19 | {
20 | }
21 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Collections/Values/IReadOnlyValueList.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 Yoakke.
2 | // Licensed under the Apache License, Version 2.0.
3 | // Source repository: https://github.com/LanguageDev/Yoakke
4 |
5 | using System;
6 | using System.Collections.Generic;
7 |
8 | namespace Yoakke.Collections.Values;
9 |
10 | ///
11 | /// Represents a generic read-only list of elements that implements value-based equality.
12 | ///
13 | /// The type of the elements.
14 | public interface IReadOnlyValueList
15 | : IReadOnlyList,
16 | IEquatable>,
17 | IEquatable>
18 | {
19 | }
20 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Collections/key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LanguageDev/Yoakke/ccd4ebf30355e451e4c362d594c741303b78cf5f/Sources/Shared/Libraries/Collections/key.snk
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Polyfill/DictionaryExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 Yoakke.
2 | // Licensed under the Apache License, Version 2.0.
3 | // Source repository: https://github.com/LanguageDev/Yoakke
4 |
5 | using System.Diagnostics.CodeAnalysis;
6 |
7 | namespace System.Collections.Generic.Polyfill;
8 |
9 | ///
10 | /// Extensions for .
11 | ///
12 | public static class DictionaryExtensions
13 | {
14 | ///
15 | /// Removes the value with the specified key from the , and copies
16 | /// the element to the parameter.
17 | ///
18 | /// The type of the keys in the dictionary.
19 | /// The type of the values in the dictionary.
20 | /// The .
21 | /// The key of the element to remove.
22 | /// The removed element.
23 | /// True if the element is successfully found and removed; otherwise, false.
24 | public static bool Remove(
25 | this Dictionary dictionary,
26 | TKey key,
27 | [MaybeNullWhen(false)] out TValue value)
28 | {
29 | if (dictionary.TryGetValue(key, out value))
30 | {
31 | dictionary.Remove(key);
32 | return true;
33 | }
34 | else
35 | {
36 | return false;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Polyfill/KeyValuePairExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 Yoakke.
2 | // Licensed under the Apache License, Version 2.0.
3 | // Source repository: https://github.com/LanguageDev/Yoakke
4 |
5 | namespace System.Collections.Generic.Polyfill;
6 |
7 | ///
8 | /// Extensions for .
9 | ///
10 | public static class KeyValuePairExtensions
11 | {
12 | ///
13 | /// Deconstructs the current .
14 | ///
15 | /// The type of the key.
16 | /// The type of the value.
17 | /// The to deconstruct.
18 | /// The key of the current .
19 | /// The value of the current .
20 | public static void Deconstruct(this KeyValuePair keyValuePair, out TKey key, out TValue value)
21 | {
22 | key = keyValuePair.Key;
23 | value = keyValuePair.Value;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Polyfill/Polyfill.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Polyfill/QueueExtensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 Yoakke.
2 | // Licensed under the Apache License, Version 2.0.
3 | // Source repository: https://github.com/LanguageDev/Yoakke
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Diagnostics.CodeAnalysis;
8 | using System.Text;
9 |
10 | namespace System.Collections.Generic.Polyfill;
11 |
12 | ///
13 | /// Extensions for .
14 | ///
15 | public static class QueueExtensions
16 | {
17 | ///
18 | /// Removes the object at the beginning of the , and copies it to the
19 | /// parameter.
20 | ///
21 | /// Specifies the type of elements in the queue.
22 | /// The queue to dequeue from.
23 | /// The removed object.
24 | /// True if the object is successfully removed, false if the is empty.
25 | public static bool TryDequeue(this Queue queue, [MaybeNullWhen(false)] out T result)
26 | {
27 | if (queue.Count > 0)
28 | {
29 | result = queue.Dequeue();
30 | return true;
31 | }
32 | else
33 | {
34 | result = default;
35 | return false;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Sources/Shared/Libraries/Polyfill/ReferenceEqualityComparer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 Yoakke.
2 | // Licensed under the Apache License, Version 2.0.
3 | // Source repository: https://github.com/LanguageDev/Yoakke
4 |
5 | using System.Runtime.CompilerServices;
6 |
7 | namespace System.Collections.Generic.Polyfill;
8 |
9 | ///
10 | /// An that uses reference equality ()
11 | /// instead of value equality () when comparing two object instances.
12 | ///
13 | public sealed class ReferenceEqualityComparer : IEqualityComparer