From 0d24fd1ecccbe9fa0cea3dd5da88720082f5760c Mon Sep 17 00:00:00 2001 From: Jacob Parker Date: Sun, 31 May 2020 18:44:08 +0100 Subject: [PATCH] . --- README.md | 12 ++++++------ bsconfig.json | 6 +++--- package.json | 2 +- src/AST/AST_ReduceMap.re | 2 +- src/AST/AST_Types.re | 6 +++--- src/Mml/Mml_Units.re | 9 +++++---- src/Value/Value.re | 2 +- src/Value/Value_Builders.re | 2 +- src/Value/Value_NumberParser.re | 2 +- src/Value/Value_Types.re | 4 ++-- src/__tests__/ValueNumbers.re | 14 +++++++------- src/__tests__/ValueTest.re | 4 ++-- yarn.lock | 12 ++++++------ 13 files changed, 39 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 74826b6..d7b7275 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Sciline Editor +# TechniCalc Editor -Represents a math AST that can be converted to both MathML and an AST for Sciline Calculator +Represents a math AST that can be converted to both MathML and an AST for TechniCalc Calculator ## AST Representation @@ -85,7 +85,7 @@ There is additionally a superscript element, `` `Superscript1 ``, which accepts □ -However, in the case we are converting to MathML or a Sciline Calculator AST, and the superscript immediately precedes an element that accepts a superscript (the element is suffixed with an `S`), they are merged together, much like ligatures in fonts. If an element does not accept a superscript, it is left unaltered +However, in the case we are converting to MathML or a TechniCalc Calculator AST, and the superscript immediately precedes an element that accepts a superscript (the element is suffixed with an `S`), they are merged together, much like ligatures in fonts. If an element does not accept a superscript, it is left unaltered 1 □ → 1 @@ -111,9 +111,9 @@ Some elements have special insertion and deletion logic. For example, if you ins The superscript encoding leads to a really natural eding experience. If you have one digit raised to a power, you could insert another digit between the the first and the superscript to move the superscript. You could also put brackets between, and the superscript is still maintained -### Convertion to MathML and Sciline Calculator AST +### Convertion to MathML and TechniCalc Calculator AST -For converting to either MathML or a Sciline Calculator AST, we first do a transformation to a node-based AST. For example, The fraction example above transforms to +For converting to either MathML or a TechniCalc Calculator AST, we first do a transformation to a node-based AST. For example, The fraction example above transforms to ```reason type node('t) = `Frac({ fracNum: node('t), den: node('t), superscript: option(node('t)) }) @@ -140,7 +140,7 @@ A side note is that we never fully construct a node-based AST, as the reduction ### Indices -Every element of the elements array is addressable by a single index. This index is imporant for MathML, so we know where to put the cursor; and also in the conversion to a Sciline Calculator AST, as if there is a parsing error, we need to return the index +Every element of the elements array is addressable by a single index. This index is imporant for MathML, so we know where to put the cursor; and also in the conversion to a TechniCalc Calculator AST, as if there is a parsing error, we need to return the index To handle this, the `~reduce` and `~map` functions are the start (`i`) and end index of the node (`i'`) diff --git a/bsconfig.json b/bsconfig.json index 58abe17..8d3eb75 100644 --- a/bsconfig.json +++ b/bsconfig.json @@ -1,5 +1,5 @@ { - "name": "sciline-editor", + "name": "technicalc-editor", "version": "0.1.0", "sources": { "dir": "src", @@ -10,10 +10,10 @@ "in-source": true }, "suffix": ".bs.js", - "bs-dependencies": ["sciline-calculator"], + "bs-dependencies": ["technicalc-calculator"], "warnings": { "error": "+101" }, - "namespace": true, + "namespace": "TechniCalcEditor", "refmt": 3 } diff --git a/package.json b/package.json index d3f3e58..697becf 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "bs-platform": "^8.0.0-dev.1", "esm": "^3.2.22", "jest": "^24.9.0", - "sciline-calculator": "https://github.com/jacobp100/sciline-calculator" + "technicalc-calculator": "https://github.com/jacobp100/technicalc-calculator" }, "dependencies": {} } diff --git a/src/AST/AST_ReduceMap.re b/src/AST/AST_ReduceMap.re index a60fff2..db560bd 100755 --- a/src/AST/AST_ReduceMap.re +++ b/src/AST/AST_ReduceMap.re @@ -7,7 +7,7 @@ type atom('a) = { superscript: option(superscript('a)), }; type customAtom('a) = { - customAtomValue: ScilineCalculator.Encoding.encoding, + customAtomValue: TechniCalcCalculator.Encoding.encoding, mml: string, superscript: option(superscript('a)), }; diff --git a/src/AST/AST_Types.re b/src/AST/AST_Types.re index 0f7ea7c..5bc4cd8 100755 --- a/src/AST/AST_Types.re +++ b/src/AST/AST_Types.re @@ -20,11 +20,11 @@ type func = | Im | Gamma; type unitConversion = { - fromUnits: ScilineCalculator.Unit_Types.units, - toUnits: ScilineCalculator.Unit_Types.units, + fromUnits: TechniCalcCalculator.Unit_Types.units, + toUnits: TechniCalcCalculator.Unit_Types.units, }; type customAtom = { - value: ScilineCalculator.Encoding.encoding, + value: TechniCalcCalculator.Encoding.encoding, mml: string, }; type table = { diff --git a/src/Mml/Mml_Units.re b/src/Mml/Mml_Units.re index 252fde8..9c5ca10 100644 --- a/src/Mml/Mml_Units.re +++ b/src/Mml/Mml_Units.re @@ -1,4 +1,4 @@ -let unitMmlSymbol = (unit: ScilineCalculator.Unit_Types.unitType) => +let unitMmlSymbol = (unit: TechniCalcCalculator.Unit_Types.unitType) => switch (unit) { /* Time */ | Second => "s" @@ -114,14 +114,15 @@ let unitMmlSymbol = (unit: ScilineCalculator.Unit_Types.unitType) => | Fahrenheit => "°F" }; -let unitToMml = (unit: ScilineCalculator.Unit_Types.unitType) => +let unitToMml = (unit: TechniCalcCalculator.Unit_Types.unitType) => switch (unit) { /* Work around :( */ | Angstrom => "A" | _ => "" ++ unitMmlSymbol(unit) ++ "" }; -let unitPowerToMml = ((unit, power): ScilineCalculator.Unit_Types.unitPower) => +let unitPowerToMml = + ((unit, power): TechniCalcCalculator.Unit_Types.unitPower) => switch (power) { | 1 => unitToMml(unit) | _ => @@ -129,7 +130,7 @@ let unitPowerToMml = ((unit, power): ScilineCalculator.Unit_Types.unitPower) => "" ++ unitToMml(unit) ++ powerMml ++ ""; }; -let unitPowersToMml = (units: ScilineCalculator.Unit_Types.units) => { +let unitPowersToMml = (units: TechniCalcCalculator.Unit_Types.units) => { let unitsMmlList = Belt.Array.map(units, unitPowerToMml)->Belt.List.fromArray; String.concat("", unitsMmlList); diff --git a/src/Value/Value.re b/src/Value/Value.re index 6a08f3a..ea3b636 100755 --- a/src/Value/Value.re +++ b/src/Value/Value.re @@ -1,6 +1,6 @@ open AST_ReduceMap; -module AST = ScilineCalculator.AST_Types; +module AST = TechniCalcCalculator.AST_Types; let parse = (elements: array(AST_Types.t)) => { let error = ref(None); diff --git a/src/Value/Value_Builders.re b/src/Value/Value_Builders.re index 1584dab..21cc211 100755 --- a/src/Value/Value_Builders.re +++ b/src/Value/Value_Builders.re @@ -2,7 +2,7 @@ open AST_ReduceMap; open AST_Types; open Value_Types; -module AST = ScilineCalculator.AST_Types; +module AST = TechniCalcCalculator.AST_Types; let withSuperscript = (value, superscript) => switch (superscript) { diff --git a/src/Value/Value_NumberParser.re b/src/Value/Value_NumberParser.re index b46f53d..870ee10 100755 --- a/src/Value/Value_NumberParser.re +++ b/src/Value/Value_NumberParser.re @@ -1,7 +1,7 @@ open AST_ReduceMap; open Value_Types; -module AST = ScilineCalculator.AST_Types; +module AST = TechniCalcCalculator.AST_Types; let numberIsValidForBase = (base, atomNucleus) => switch (base, atomNucleus) { diff --git a/src/Value/Value_Types.re b/src/Value/Value_Types.re index c1337bb..7710e4c 100755 --- a/src/Value/Value_Types.re +++ b/src/Value/Value_Types.re @@ -1,6 +1,6 @@ open AST_ReduceMap; -type node = ScilineCalculator.AST_Types.t; +type node = TechniCalcCalculator.AST_Types.t; type funcitionLike = | GenericFunction(AST_Types.func) @@ -11,4 +11,4 @@ type funcitionLike = type partialNode = | Resolved(node) | Unresolved(t(node), int) - | UnresolvedFunction(funcitionLike, int); + | UnresolvedFunction(funcitionLike, int); \ No newline at end of file diff --git a/src/__tests__/ValueNumbers.re b/src/__tests__/ValueNumbers.re index 6cd49c4..c96c0e9 100644 --- a/src/__tests__/ValueNumbers.re +++ b/src/__tests__/ValueNumbers.re @@ -2,12 +2,12 @@ open Jest; let parseEval = v => switch (Value.parse(v)) { - | `Ok(v) => Some(ScilineCalculator.AST.eval(v)) + | `Ok(v) => Some(TechniCalcCalculator.AST.eval(v)) | _ => None }; -let ofInt = ScilineCalculator.Types.ofInt; -let ofString = ScilineCalculator.Types.ofString; +let ofInt = TechniCalcCalculator.Types.ofInt; +let ofString = TechniCalcCalculator.Types.ofString; test("Parses numbers", (.) => { parseEval([|`DigitS("1"), `DigitS("2"), `DigitS("3")|]) @@ -104,7 +104,7 @@ test("Parses magnitudes", (.) => { }); test("Parses imaginary units", (.) => { - let mulI = ScilineCalculator.Value.(mul(i)); + let mulI = TechniCalcCalculator.Value.(mul(i)); parseEval([|`DigitS("2"), `ImaginaryUnitS|]) ->expect @@ -154,9 +154,9 @@ test("Parses imaginary units", (.) => { }); test("Angles", (.) => { - let pi = ScilineCalculator.Value.pi; - let mul = ScilineCalculator.Value.mul; - let div = ScilineCalculator.Value.div; + let pi = TechniCalcCalculator.Value.pi; + let mul = TechniCalcCalculator.Value.mul; + let div = TechniCalcCalculator.Value.div; parseEval([|`DigitS("1"), `Degree|]) ->expect diff --git a/src/__tests__/ValueTest.re b/src/__tests__/ValueTest.re index 9ba8f39..f630d8f 100644 --- a/src/__tests__/ValueTest.re +++ b/src/__tests__/ValueTest.re @@ -3,11 +3,11 @@ open AST_Types; let parseEval = v => switch (Value.parse(v)) { - | `Ok(v) => Some(ScilineCalculator.AST.eval(v)) + | `Ok(v) => Some(TechniCalcCalculator.AST.eval(v)) | _ => None }; -let ofString = ScilineCalculator.Types.ofString; +let ofString = TechniCalcCalculator.Types.ofString; test("Parses with bodmas", (.) => { parseEval([|`DigitS("1"), `Sub, `DigitS("2"), `Add, `DigitS("3")|]) diff --git a/yarn.lock b/yarn.lock index 6c1b8e3..893bc74 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3481,12 +3481,6 @@ sax@^1.2.4: resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== -"sciline-calculator@https://github.com/jacobp100/sciline-calculator": - version "0.1.0" - resolved "https://github.com/jacobp100/sciline-calculator#45610d2656405c93fd2833ddda406588378f97d0" - dependencies: - decimal.js "^10.2.0" - "semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" @@ -3773,6 +3767,12 @@ symbol-tree@^3.2.2: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== +"technicalc-calculator@https://github.com/jacobp100/technicalc-calculator": + version "0.1.0" + resolved "https://github.com/jacobp100/technicalc-calculator#9a32c3c71414db707428d8f84050c03cbb3f948e" + dependencies: + decimal.js "^10.2.0" + test-exclude@^5.2.3: version "5.2.3" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.2.3.tgz#c3d3e1e311eb7ee405e092dac10aefd09091eac0"