Skip to content

Commit

Permalink
Parser refactor (part 1) (#143)
Browse files Browse the repository at this point in the history
* LaTeXParser now uses Result

* CI passing?

* nullables are now errors

* Eliminate a nullability error

* WIP refactor in progress

* Finished porting AtomForCommand over

* Stop Commands should be able to be ported now

* Ported Stop Commands

* Trie

* Moved commands up

* Be more linent w.r.t. slow VMs

* See the time

* Now we optimize it

* Trie optimized

* Optimizations again

* Trie removal

* Generalized trie

* Trie iterate

* \atopwithdelims

* Correct implementation of \rm and friends

* Fix test

* Fixed \sqrt[3}

* Fix \TeX

* Using the trie

* Optimize trie lookup

* Update dotnet

* Simplify Result

* Fix comments

* Add comment range tests

* Apply suggestions from code review

Co-authored-by: FoggyFinder <[email protected]>

* Document a bit

* Rename kern -> skip

* Revert AngouriUpdate

* Fix types

* remove unused methods prior to reviewing ProxyAdder

* hygiene: remove "add" optional function inside BiDictionary (breaks build)

* builds

* simplify

* remove some unused BiDictionary methods and fix implementations of remaining methods

* remove unused MultiDictionary

* remove commented code

* Add doc and TODO about doc

* further BiDictionary simplification

* finished reviewing bidictionary

* correct RemoveByFirst

* correct RemoveByFirst

* Fix BiDictionary initialization (messy; awaiting LaTeXCommandDictionary documentation for further cleanup)

* fix BiDictionary initialization

* fix bidicitonary initializastion

* remove class constraint on TFirst

* Remove unused LaTeXCommandDictionary properties

* prune and document LaTeXCommandDictionary

* Remove Trie

* remove Trie pt 2

* Fix casing as ReadOnlySpan.StartsWithInvariant seems to be case insentitive

* document asymmetric RemoveByFirst/Second approach

* Add dictionary remove tests

* revert latexsettings.cs

* revert latexsettings

* rename added

* Document LaTeXCommandDictionary

* restore a test

* tweaks

* tweaks

* tweaks

* tweaks

* Remove CopyTo as it is not used and BiDictionary doesn't implement ICollection

* Added an unused method but this is bad practice

* stringcomparison.ordinal to fix test

* another ordinal

* "AliasBiDictionary"

* Fix a method reference

* Find longest non-command

* tidy concatenation

* Use (string Command, TValue Value)

* apply automatic refactor

* remove i

* Simplify SortedSet

* fix build

* shorten

* local functions

* Update CSharpMath/Structures/Dictionary.cs

Co-authored-by: Hadrian Tang <[email protected]>

* string

* suppressmessage

* csharp syntax

* Update justification

* Use more documentation tags

* Update test description

* Clarify words

* Apply suggested change

Co-authored-by: FoggyFinder <[email protected]>

Co-authored-by: FoggyFinder <[email protected]>
Co-authored-by: Charles Roddie <[email protected]>
Co-authored-by: Charles Roddie <[email protected]>
  • Loading branch information
4 people authored Jul 22, 2020
1 parent d835e93 commit ab9f87c
Show file tree
Hide file tree
Showing 61 changed files with 1,998 additions and 2,006 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Test all projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.201'
dotnet-version: '3.1.301'
- name: Setup JDK # Needed to run ANTLR for AngouriMath
uses: actions/setup-java@v1
with:
Expand Down
73 changes: 0 additions & 73 deletions CSharpMath.CoreTests/BiDictionaryTests.cs

This file was deleted.

37 changes: 37 additions & 0 deletions CSharpMath.CoreTests/DictionaryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Xunit;
using CSharpMath.Structures;

namespace CSharpMath.CoreTests {
public class DictionaryTests {
private AliasBiDictionary<string, int> InitTestDict() {
return new AliasBiDictionary<string, int>{
{ "0", 0 },
{ "zero", 0 },
{ "1", 1 }
};
}
[Theory]
[InlineData("0", 2, 2, true)]
[InlineData("zero", 2, 2, true)]
[InlineData("1", 2, 1, true)]
[InlineData("2", 3, 2, false)]
public void TestRemoveByFirst(string remove, int expectedFTS, int expectedSTF, bool expectedRemoved) {
var bd = InitTestDict();
var removed = bd.RemoveByFirst(remove);
Assert.Equal(expectedFTS, bd.FirstToSecond.Count);
Assert.Equal(expectedSTF, bd.SecondToFirst.Count);
Assert.Equal(expectedRemoved, removed);
}
[Theory]
[InlineData(0, 1, 1, true)]
[InlineData(1, 2, 1, true)]
[InlineData(2, 3, 2, false)]
public void TestRemoveBySecond(int remove, int expectedFTS, int expectedSTF, bool expectedRemoved) {
var bd = InitTestDict();
var removed = bd.RemoveBySecond(remove);
Assert.Equal(expectedFTS, bd.FirstToSecond.Count);
Assert.Equal(expectedSTF, bd.SecondToFirst.Count);
Assert.Equal(expectedRemoved, removed);
}
}
}
Loading

0 comments on commit ab9f87c

Please sign in to comment.