@cortex-js/compute-engine 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compute-engine.esm.js +1304 -987
- package/dist/compute-engine.js +1304 -987
- package/dist/compute-engine.min.esm.js +1304 -987
- package/dist/compute-engine.min.js +1304 -987
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +4 -2
- package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
- package/dist/types/compute-engine/compile.d.ts +9 -2
- package/dist/types/compute-engine/compute-engine.d.ts +8 -7
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +32 -17
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +12 -6
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +30 -20
- package/dist/types/compute-engine/latex-syntax/public.d.ts +90 -47
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +4 -9
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +1 -2
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/domains.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +2 -1
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
- package/dist/types/compute-engine/public.d.ts +4 -1
- package/dist/types/compute-engine/rules.d.ts +1 -1
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/solve.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +5 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** CortexJS Compute Engine 0.
|
|
1
|
+
/** CortexJS Compute Engine 0.14.0 */
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -3744,7 +3744,7 @@ function tokensToString(tokens) {
|
|
|
3744
3744
|
var DEFINITIONS_ALGEBRA = [
|
|
3745
3745
|
{
|
|
3746
3746
|
name: "To",
|
|
3747
|
-
|
|
3747
|
+
latexTrigger: ["\\to"],
|
|
3748
3748
|
kind: "infix",
|
|
3749
3749
|
precedence: 270
|
|
3750
3750
|
// MathML rightwards arrow
|
|
@@ -4006,10 +4006,10 @@ function machineValue(expr) {
|
|
|
4006
4006
|
return null;
|
|
4007
4007
|
if (typeof expr === "number")
|
|
4008
4008
|
return expr;
|
|
4009
|
-
if (isNumberObject(expr))
|
|
4010
|
-
return machineValueOfString(expr.num);
|
|
4011
4009
|
if (typeof expr === "string")
|
|
4012
4010
|
return machineValueOfString(expr);
|
|
4011
|
+
if (isNumberObject(expr))
|
|
4012
|
+
return machineValue(expr.num);
|
|
4013
4013
|
return null;
|
|
4014
4014
|
}
|
|
4015
4015
|
function rationalValue(expr) {
|
|
@@ -4534,7 +4534,7 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4534
4534
|
{ name: "EulerGamma", serialize: "\\gamma" },
|
|
4535
4535
|
{
|
|
4536
4536
|
name: "Degrees",
|
|
4537
|
-
|
|
4537
|
+
latexTrigger: ["\\degree"],
|
|
4538
4538
|
kind: "postfix",
|
|
4539
4539
|
precedence: 880,
|
|
4540
4540
|
parse: (_parser, lhs) => ["Degrees", lhs],
|
|
@@ -4543,74 +4543,82 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4543
4543
|
}
|
|
4544
4544
|
},
|
|
4545
4545
|
{
|
|
4546
|
-
|
|
4546
|
+
latexTrigger: ["\\degree"],
|
|
4547
4547
|
kind: "postfix",
|
|
4548
4548
|
precedence: 880,
|
|
4549
4549
|
parse: (_parser, lhs) => ["Degrees", lhs]
|
|
4550
4550
|
},
|
|
4551
4551
|
{
|
|
4552
|
-
|
|
4552
|
+
latexTrigger: ["^", "<{>", "\\circ", "<}>"],
|
|
4553
4553
|
kind: "postfix",
|
|
4554
4554
|
parse: (_parser, lhs) => ["Degrees", lhs]
|
|
4555
4555
|
},
|
|
4556
4556
|
{
|
|
4557
|
-
|
|
4557
|
+
latexTrigger: ["^", "\\circ"],
|
|
4558
4558
|
kind: "postfix",
|
|
4559
4559
|
parse: (_parser, lhs) => ["Degrees", lhs]
|
|
4560
4560
|
},
|
|
4561
4561
|
{
|
|
4562
|
-
|
|
4562
|
+
latexTrigger: ["\xB0"],
|
|
4563
4563
|
kind: "postfix",
|
|
4564
4564
|
precedence: 880,
|
|
4565
4565
|
parse: (_parser, lhs) => ["Degrees", lhs]
|
|
4566
4566
|
},
|
|
4567
4567
|
{
|
|
4568
|
-
|
|
4568
|
+
latexTrigger: ["\\ang"],
|
|
4569
4569
|
parse: (parser) => {
|
|
4570
4570
|
const arg = parser.parseGroup();
|
|
4571
4571
|
return arg === null ? ["Degrees"] : ["Degrees", arg];
|
|
4572
4572
|
}
|
|
4573
4573
|
},
|
|
4574
4574
|
{
|
|
4575
|
-
|
|
4575
|
+
latexTrigger: ["\\infty"],
|
|
4576
4576
|
parse: { num: "+Infinity" }
|
|
4577
4577
|
},
|
|
4578
4578
|
{
|
|
4579
4579
|
name: "ComplexInfinity",
|
|
4580
|
-
|
|
4580
|
+
latexTrigger: ["\\tilde", "\\infty"],
|
|
4581
4581
|
serialize: "\\tilde\\infty"
|
|
4582
4582
|
},
|
|
4583
4583
|
{
|
|
4584
|
-
|
|
4584
|
+
latexTrigger: ["\\tilde", "<{>", "\\infty", "<}>"],
|
|
4585
4585
|
parse: "ComplexInfinity"
|
|
4586
4586
|
},
|
|
4587
|
-
{ name: "Pi", kind: "symbol",
|
|
4588
|
-
{
|
|
4587
|
+
{ name: "Pi", kind: "symbol", latexTrigger: ["\\pi"] },
|
|
4588
|
+
{ latexTrigger: ["\u03C0"], parse: "Pi" },
|
|
4589
4589
|
{
|
|
4590
4590
|
name: "ExponentialE",
|
|
4591
|
-
|
|
4591
|
+
latexTrigger: ["\\exponentialE"],
|
|
4592
4592
|
parse: "ExponentialE",
|
|
4593
4593
|
serialize: "\\exponentialE"
|
|
4594
4594
|
},
|
|
4595
4595
|
{
|
|
4596
|
-
|
|
4596
|
+
latexTrigger: "\\operatorname{e}",
|
|
4597
|
+
parse: "ExponentialE"
|
|
4598
|
+
},
|
|
4599
|
+
{
|
|
4600
|
+
latexTrigger: "\\mathrm{e}",
|
|
4597
4601
|
parse: "ExponentialE"
|
|
4598
4602
|
},
|
|
4599
4603
|
{
|
|
4600
4604
|
kind: "function",
|
|
4601
|
-
|
|
4605
|
+
identifierTrigger: "exp",
|
|
4602
4606
|
parse: "Exp"
|
|
4603
4607
|
},
|
|
4604
4608
|
{
|
|
4605
|
-
|
|
4609
|
+
latexTrigger: "\\exp",
|
|
4606
4610
|
parse: "Exp"
|
|
4607
4611
|
},
|
|
4608
4612
|
{
|
|
4609
4613
|
name: "ImaginaryUnit",
|
|
4610
|
-
|
|
4614
|
+
latexTrigger: ["\\imaginaryI"]
|
|
4611
4615
|
},
|
|
4612
4616
|
{
|
|
4613
|
-
|
|
4617
|
+
latexTrigger: "\\operatorname{i}",
|
|
4618
|
+
parse: "ImaginaryUnit"
|
|
4619
|
+
},
|
|
4620
|
+
{
|
|
4621
|
+
latexTrigger: "\\mathrm{i}",
|
|
4614
4622
|
parse: "ImaginaryUnit"
|
|
4615
4623
|
},
|
|
4616
4624
|
// Operations
|
|
@@ -4621,18 +4629,18 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4621
4629
|
* replaced with bars */
|
|
4622
4630
|
name: "Abs",
|
|
4623
4631
|
kind: "matchfix",
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
parse: (_parser,
|
|
4632
|
+
openTrigger: "|",
|
|
4633
|
+
closeTrigger: "|",
|
|
4634
|
+
parse: (_parser, body) => isEmptySequence(body) ? null : ["Abs", body]
|
|
4627
4635
|
},
|
|
4628
4636
|
{
|
|
4629
|
-
|
|
4637
|
+
identifierTrigger: "abs",
|
|
4630
4638
|
kind: "function",
|
|
4631
4639
|
parse: "Abs"
|
|
4632
4640
|
},
|
|
4633
4641
|
{
|
|
4634
4642
|
name: "Add",
|
|
4635
|
-
|
|
4643
|
+
latexTrigger: ["+"],
|
|
4636
4644
|
kind: "infix",
|
|
4637
4645
|
associativity: "both",
|
|
4638
4646
|
precedence: 275,
|
|
@@ -4648,7 +4656,7 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4648
4656
|
},
|
|
4649
4657
|
{
|
|
4650
4658
|
kind: "prefix",
|
|
4651
|
-
|
|
4659
|
+
latexTrigger: ["+"],
|
|
4652
4660
|
precedence: 275,
|
|
4653
4661
|
parse: (parser, until) => {
|
|
4654
4662
|
if (until && 275 < until.minPrec)
|
|
@@ -4659,20 +4667,22 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4659
4667
|
{
|
|
4660
4668
|
name: "Ceil",
|
|
4661
4669
|
kind: "matchfix",
|
|
4662
|
-
|
|
4663
|
-
|
|
4670
|
+
openTrigger: "\\lceil",
|
|
4671
|
+
closeTrigger: "\\rceil",
|
|
4672
|
+
parse: (_parser, body) => isEmptySequence(body) ? null : ["Ceil", body]
|
|
4664
4673
|
},
|
|
4665
4674
|
{
|
|
4666
4675
|
kind: "matchfix",
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
parse: (
|
|
4676
|
+
openTrigger: ["\u2308"],
|
|
4677
|
+
closeTrigger: ["\u2309"],
|
|
4678
|
+
parse: (_parser, body) => isEmptySequence(body) ? null : ["Ceil", body]
|
|
4670
4679
|
},
|
|
4671
4680
|
{
|
|
4672
|
-
|
|
4681
|
+
identifierTrigger: "ceil",
|
|
4673
4682
|
kind: "function",
|
|
4674
4683
|
parse: "Ceil"
|
|
4675
4684
|
},
|
|
4685
|
+
{ name: "Chop", identifierTrigger: "chop", kind: "function", parse: "Chop" },
|
|
4676
4686
|
{
|
|
4677
4687
|
name: "Complex",
|
|
4678
4688
|
precedence: 274,
|
|
@@ -4692,7 +4702,7 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4692
4702
|
},
|
|
4693
4703
|
{
|
|
4694
4704
|
name: "Divide",
|
|
4695
|
-
|
|
4705
|
+
latexTrigger: "\\frac",
|
|
4696
4706
|
precedence: 660,
|
|
4697
4707
|
// For \frac specifically, not for \div, etc..
|
|
4698
4708
|
// handles Leibnitz notation for partial derivatives
|
|
@@ -4701,12 +4711,12 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4701
4711
|
},
|
|
4702
4712
|
{
|
|
4703
4713
|
kind: "infix",
|
|
4704
|
-
|
|
4714
|
+
latexTrigger: "\\over",
|
|
4705
4715
|
precedence: 660,
|
|
4706
4716
|
parse: "Divide"
|
|
4707
4717
|
},
|
|
4708
4718
|
{
|
|
4709
|
-
|
|
4719
|
+
latexTrigger: ["\\/"],
|
|
4710
4720
|
kind: "infix",
|
|
4711
4721
|
associativity: "non",
|
|
4712
4722
|
precedence: 660,
|
|
@@ -4716,14 +4726,14 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4716
4726
|
parse: "Divide"
|
|
4717
4727
|
},
|
|
4718
4728
|
{
|
|
4719
|
-
|
|
4729
|
+
latexTrigger: ["/"],
|
|
4720
4730
|
kind: "infix",
|
|
4721
4731
|
associativity: "non",
|
|
4722
4732
|
precedence: 660,
|
|
4723
4733
|
parse: "Divide"
|
|
4724
4734
|
},
|
|
4725
4735
|
{
|
|
4726
|
-
|
|
4736
|
+
latexTrigger: ["\\div"],
|
|
4727
4737
|
kind: "infix",
|
|
4728
4738
|
associativity: "non",
|
|
4729
4739
|
precedence: 660,
|
|
@@ -4741,36 +4751,41 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4741
4751
|
},
|
|
4742
4752
|
{
|
|
4743
4753
|
name: "Factorial",
|
|
4744
|
-
|
|
4754
|
+
latexTrigger: ["!"],
|
|
4745
4755
|
kind: "postfix",
|
|
4746
4756
|
precedence: 810
|
|
4747
4757
|
},
|
|
4748
4758
|
{
|
|
4749
4759
|
name: "Factorial2",
|
|
4750
|
-
|
|
4760
|
+
latexTrigger: ["!", "!"],
|
|
4751
4761
|
kind: "postfix",
|
|
4752
4762
|
precedence: 810
|
|
4753
4763
|
},
|
|
4754
4764
|
{
|
|
4755
4765
|
name: "Floor",
|
|
4756
4766
|
kind: "matchfix",
|
|
4757
|
-
|
|
4758
|
-
|
|
4767
|
+
openTrigger: "\\lfloor",
|
|
4768
|
+
closeTrigger: "\\rfloor",
|
|
4769
|
+
parse: (_parser, body) => isEmptySequence(body) ? null : ["Floor", body]
|
|
4759
4770
|
},
|
|
4760
4771
|
{
|
|
4761
4772
|
kind: "matchfix",
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
parse: (
|
|
4773
|
+
openTrigger: ["\u230A"],
|
|
4774
|
+
closeTrigger: ["\u230B"],
|
|
4775
|
+
parse: (_parser, body) => isEmptySequence(body) ? null : ["Floor", body]
|
|
4765
4776
|
},
|
|
4766
4777
|
{
|
|
4767
|
-
|
|
4778
|
+
identifierTrigger: "floor",
|
|
4768
4779
|
kind: "function",
|
|
4769
4780
|
parse: "Floor"
|
|
4770
4781
|
},
|
|
4782
|
+
{
|
|
4783
|
+
latexTrigger: ["\\Gamma"],
|
|
4784
|
+
parse: "Gamma"
|
|
4785
|
+
},
|
|
4771
4786
|
{
|
|
4772
4787
|
name: "Gcd",
|
|
4773
|
-
|
|
4788
|
+
identifierTrigger: "gcd",
|
|
4774
4789
|
kind: "function"
|
|
4775
4790
|
},
|
|
4776
4791
|
{
|
|
@@ -4779,34 +4794,34 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4779
4794
|
},
|
|
4780
4795
|
{
|
|
4781
4796
|
name: "Lg",
|
|
4782
|
-
|
|
4797
|
+
latexTrigger: ["\\lg"],
|
|
4783
4798
|
serialize: (serializer, expr) => "\\log_{10}" + serializer.wrapArguments(expr),
|
|
4784
4799
|
parse: (parser) => {
|
|
4785
|
-
const
|
|
4786
|
-
if (
|
|
4800
|
+
const args = parser.parseArguments("implicit");
|
|
4801
|
+
if (args === null)
|
|
4787
4802
|
return "Lg";
|
|
4788
|
-
return ["Log", ...
|
|
4803
|
+
return ["Log", ...args, 10];
|
|
4789
4804
|
}
|
|
4790
4805
|
},
|
|
4791
4806
|
{
|
|
4792
4807
|
name: "Lb",
|
|
4793
|
-
|
|
4808
|
+
latexTrigger: "\\lb",
|
|
4794
4809
|
parse: (parser) => {
|
|
4795
|
-
const
|
|
4796
|
-
if (
|
|
4810
|
+
const args = parser.parseArguments("implicit");
|
|
4811
|
+
if (args === null)
|
|
4797
4812
|
return "Log";
|
|
4798
|
-
return ["Log", ...
|
|
4813
|
+
return ["Log", ...args, 2];
|
|
4799
4814
|
}
|
|
4800
4815
|
},
|
|
4801
4816
|
{
|
|
4802
4817
|
name: "Ln",
|
|
4803
|
-
|
|
4818
|
+
latexTrigger: ["\\ln"],
|
|
4804
4819
|
serialize: (serializer, expr) => "\\ln" + serializer.wrapArguments(expr),
|
|
4805
4820
|
parse: (parser) => parseLog("Ln", parser)
|
|
4806
4821
|
},
|
|
4807
4822
|
{
|
|
4808
4823
|
name: "Log",
|
|
4809
|
-
|
|
4824
|
+
latexTrigger: ["\\log"],
|
|
4810
4825
|
parse: (parser) => parseLog("Log", parser),
|
|
4811
4826
|
serialize: (serializer, expr) => {
|
|
4812
4827
|
const base = op2(expr);
|
|
@@ -4822,32 +4837,32 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4822
4837
|
},
|
|
4823
4838
|
{
|
|
4824
4839
|
name: "Lcm",
|
|
4825
|
-
|
|
4840
|
+
identifierTrigger: "lcm",
|
|
4826
4841
|
kind: "function"
|
|
4827
4842
|
},
|
|
4843
|
+
{ name: "Max", identifierTrigger: "max", kind: "function" },
|
|
4844
|
+
{ name: "Min", identifierTrigger: "min", kind: "function" },
|
|
4828
4845
|
{
|
|
4829
4846
|
name: "MinusPlus",
|
|
4830
|
-
|
|
4847
|
+
latexTrigger: ["\\mp"],
|
|
4831
4848
|
kind: "infix",
|
|
4832
4849
|
associativity: "both",
|
|
4833
4850
|
precedence: 270
|
|
4834
4851
|
},
|
|
4835
4852
|
{
|
|
4836
4853
|
name: "Multiply",
|
|
4837
|
-
|
|
4854
|
+
latexTrigger: ["\\times"],
|
|
4838
4855
|
kind: "infix",
|
|
4839
4856
|
associativity: "both",
|
|
4840
4857
|
precedence: 390,
|
|
4841
4858
|
serialize: serializeMultiply
|
|
4842
4859
|
},
|
|
4843
4860
|
{
|
|
4844
|
-
|
|
4861
|
+
latexTrigger: ["\\cdot"],
|
|
4845
4862
|
kind: "infix",
|
|
4846
4863
|
associativity: "both",
|
|
4847
4864
|
precedence: 390,
|
|
4848
4865
|
parse: (parser, lhs, terminator) => {
|
|
4849
|
-
if (terminator && 391 < terminator.minPrec)
|
|
4850
|
-
return null;
|
|
4851
4866
|
const rhs = parser.parseExpression({ ...terminator, minPrec: 392 });
|
|
4852
4867
|
if (rhs === null)
|
|
4853
4868
|
return ["Multiply", lhs, MISSING];
|
|
@@ -4855,13 +4870,11 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4855
4870
|
}
|
|
4856
4871
|
},
|
|
4857
4872
|
{
|
|
4858
|
-
|
|
4873
|
+
latexTrigger: ["*"],
|
|
4859
4874
|
kind: "infix",
|
|
4860
4875
|
associativity: "both",
|
|
4861
4876
|
precedence: 390,
|
|
4862
4877
|
parse: (parser, lhs, terminator) => {
|
|
4863
|
-
if (terminator && 391 < terminator.minPrec)
|
|
4864
|
-
return null;
|
|
4865
4878
|
const rhs = parser.parseExpression({ ...terminator, minPrec: 392 });
|
|
4866
4879
|
if (rhs === null)
|
|
4867
4880
|
return ["Multiply", lhs, MISSING];
|
|
@@ -4870,11 +4883,9 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4870
4883
|
},
|
|
4871
4884
|
{
|
|
4872
4885
|
name: "Negate",
|
|
4873
|
-
|
|
4886
|
+
latexTrigger: ["-"],
|
|
4874
4887
|
kind: "prefix",
|
|
4875
4888
|
parse: (parser, terminator) => {
|
|
4876
|
-
if (terminator && 276 < terminator.minPrec)
|
|
4877
|
-
return null;
|
|
4878
4889
|
const rhs = parser.parseExpression({ ...terminator, minPrec: 400 });
|
|
4879
4890
|
return ["Negate", missingIfEmpty(rhs)];
|
|
4880
4891
|
},
|
|
@@ -4900,8 +4911,8 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4900
4911
|
// /** If the argument is a vector */
|
|
4901
4912
|
/** @todo: domain check */
|
|
4902
4913
|
kind: "matchfix",
|
|
4903
|
-
|
|
4904
|
-
|
|
4914
|
+
openTrigger: "||",
|
|
4915
|
+
closeTrigger: "||",
|
|
4905
4916
|
parse: (_parser, expr) => isEmptySequence(expr) ? null : ["Norm", expr]
|
|
4906
4917
|
},
|
|
4907
4918
|
{
|
|
@@ -4909,12 +4920,13 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4909
4920
|
/** @todo: domain check */
|
|
4910
4921
|
name: "Norm",
|
|
4911
4922
|
kind: "matchfix",
|
|
4912
|
-
|
|
4913
|
-
|
|
4923
|
+
openTrigger: ["\\left", "\\Vert"],
|
|
4924
|
+
closeTrigger: ["\\right", "\\Vert"],
|
|
4925
|
+
parse: (_parser, expr) => isEmptySequence(expr) ? null : ["Norm", expr]
|
|
4914
4926
|
},
|
|
4915
4927
|
{
|
|
4916
4928
|
name: "PlusMinus",
|
|
4917
|
-
|
|
4929
|
+
latexTrigger: ["\\pm"],
|
|
4918
4930
|
kind: "infix",
|
|
4919
4931
|
associativity: "both",
|
|
4920
4932
|
precedence: 270,
|
|
@@ -4933,47 +4945,41 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4933
4945
|
}
|
|
4934
4946
|
},
|
|
4935
4947
|
{
|
|
4936
|
-
|
|
4948
|
+
latexTrigger: ["\\pm"],
|
|
4937
4949
|
kind: "prefix",
|
|
4938
4950
|
precedence: 270,
|
|
4939
4951
|
parse: (parser, terminator) => {
|
|
4940
|
-
if (terminator && 270 < terminator.minPrec)
|
|
4941
|
-
return null;
|
|
4942
4952
|
const rhs = parser.parseExpression({ ...terminator, minPrec: 400 });
|
|
4943
4953
|
return ["PlusMinus", missingIfEmpty(rhs)];
|
|
4944
4954
|
}
|
|
4945
4955
|
},
|
|
4946
4956
|
{
|
|
4947
|
-
|
|
4957
|
+
latexTrigger: ["\\plusmn"],
|
|
4948
4958
|
kind: "infix",
|
|
4949
4959
|
associativity: "both",
|
|
4950
4960
|
precedence: 270,
|
|
4951
4961
|
parse: (parser, lhs, terminator) => {
|
|
4952
|
-
if (270 < terminator.minPrec)
|
|
4953
|
-
return null;
|
|
4954
4962
|
const rhs = parser.parseExpression({ ...terminator, minPrec: 400 });
|
|
4955
4963
|
return ["PlusMinus", lhs, missingIfEmpty(rhs)];
|
|
4956
4964
|
}
|
|
4957
4965
|
},
|
|
4958
4966
|
{
|
|
4959
|
-
|
|
4967
|
+
latexTrigger: ["\\plusmn"],
|
|
4960
4968
|
kind: "prefix",
|
|
4961
4969
|
precedence: 270,
|
|
4962
4970
|
parse: (parser, terminator) => {
|
|
4963
|
-
if (terminator && 270 < terminator.minPrec)
|
|
4964
|
-
return null;
|
|
4965
4971
|
const rhs = parser.parseExpression({ ...terminator, minPrec: 400 });
|
|
4966
4972
|
return ["PlusMinus", missingIfEmpty(rhs)];
|
|
4967
4973
|
}
|
|
4968
4974
|
},
|
|
4969
4975
|
{
|
|
4970
4976
|
name: "Power",
|
|
4971
|
-
|
|
4977
|
+
latexTrigger: ["^"],
|
|
4972
4978
|
kind: "infix",
|
|
4973
4979
|
serialize: serializePower
|
|
4974
4980
|
},
|
|
4975
4981
|
{
|
|
4976
|
-
|
|
4982
|
+
latexTrigger: "\\prod",
|
|
4977
4983
|
precedence: 390,
|
|
4978
4984
|
name: "Product",
|
|
4979
4985
|
parse: parseBigOp("Product", 390),
|
|
@@ -4990,7 +4996,7 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
4990
4996
|
precedence: 660,
|
|
4991
4997
|
serialize: (serializer, expr) => {
|
|
4992
4998
|
if (expr && nops(expr) === 1)
|
|
4993
|
-
return "\\
|
|
4999
|
+
return "\\operatorname{Rational}" + serializer.wrapArguments(expr);
|
|
4994
5000
|
return serializeFraction(serializer, expr);
|
|
4995
5001
|
}
|
|
4996
5002
|
},
|
|
@@ -5000,7 +5006,7 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
5000
5006
|
},
|
|
5001
5007
|
{
|
|
5002
5008
|
name: "Round",
|
|
5003
|
-
|
|
5009
|
+
identifierTrigger: "round",
|
|
5004
5010
|
kind: "function"
|
|
5005
5011
|
},
|
|
5006
5012
|
{
|
|
@@ -5009,7 +5015,7 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
5009
5015
|
serialize: (serializer, expr) => serializer.wrapShort(op(expr, 1)) + "^2"
|
|
5010
5016
|
},
|
|
5011
5017
|
{
|
|
5012
|
-
|
|
5018
|
+
latexTrigger: ["\\sum"],
|
|
5013
5019
|
precedence: 275,
|
|
5014
5020
|
name: "Sum",
|
|
5015
5021
|
parse: parseBigOp("Sum", 275),
|
|
@@ -5018,24 +5024,22 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
5018
5024
|
{
|
|
5019
5025
|
name: "Sign",
|
|
5020
5026
|
// As per ISO 80000-2, "signum" is 'sgn'
|
|
5021
|
-
|
|
5027
|
+
identifierTrigger: "sgn",
|
|
5022
5028
|
kind: "function"
|
|
5023
5029
|
},
|
|
5024
5030
|
{
|
|
5025
5031
|
name: "Sqrt",
|
|
5026
|
-
|
|
5032
|
+
latexTrigger: ["\\sqrt"],
|
|
5027
5033
|
parse: parseRoot,
|
|
5028
5034
|
serialize: serializePower
|
|
5029
5035
|
},
|
|
5030
5036
|
{
|
|
5031
5037
|
name: "Subtract",
|
|
5032
|
-
|
|
5038
|
+
latexTrigger: ["-"],
|
|
5033
5039
|
kind: "infix",
|
|
5034
5040
|
associativity: "both",
|
|
5035
5041
|
precedence: 275,
|
|
5036
5042
|
parse: (parser, lhs, terminator) => {
|
|
5037
|
-
if (276 < terminator.minPrec)
|
|
5038
|
-
return null;
|
|
5039
5043
|
const rhs = parser.parseExpression({ ...terminator, minPrec: 277 });
|
|
5040
5044
|
return ["Subtract", lhs, missingIfEmpty(rhs)];
|
|
5041
5045
|
}
|
|
@@ -5132,16 +5136,16 @@ function parseLog(command, parser) {
|
|
|
5132
5136
|
sub2 = parser.parseStringGroup()?.trim() ?? parser.nextToken();
|
|
5133
5137
|
base = Number.parseFloat(sub2 ?? "10");
|
|
5134
5138
|
}
|
|
5135
|
-
const
|
|
5136
|
-
if (
|
|
5139
|
+
const args = parser.parseArguments("implicit");
|
|
5140
|
+
if (args === null)
|
|
5137
5141
|
return [command];
|
|
5138
5142
|
if (base === 10)
|
|
5139
|
-
return ["Log",
|
|
5143
|
+
return ["Log", args[0]];
|
|
5140
5144
|
if (base === 2)
|
|
5141
|
-
return ["Lb", ...
|
|
5145
|
+
return ["Lb", ...args];
|
|
5142
5146
|
if (sub2 === null)
|
|
5143
|
-
return [command, ...
|
|
5144
|
-
return ["Log", ...
|
|
5147
|
+
return [command, ...args];
|
|
5148
|
+
return ["Log", ...args, sub2];
|
|
5145
5149
|
}
|
|
5146
5150
|
|
|
5147
5151
|
// src/compute-engine/latex-syntax/dictionary/definitions-core.ts
|
|
@@ -5180,7 +5184,7 @@ var DEFINITIONS_CORE = [
|
|
|
5180
5184
|
// Constants
|
|
5181
5185
|
//
|
|
5182
5186
|
{
|
|
5183
|
-
|
|
5187
|
+
latexTrigger: ["\\placeholder"],
|
|
5184
5188
|
kind: "symbol",
|
|
5185
5189
|
parse: (parser) => {
|
|
5186
5190
|
while (parser.match("<space>")) {
|
|
@@ -5199,6 +5203,27 @@ var DEFINITIONS_CORE = [
|
|
|
5199
5203
|
//
|
|
5200
5204
|
// Functions
|
|
5201
5205
|
//
|
|
5206
|
+
{
|
|
5207
|
+
name: "Apply",
|
|
5208
|
+
kind: "function",
|
|
5209
|
+
identifierTrigger: "apply",
|
|
5210
|
+
serialize: (serializer, expr) => serializer.serializeFunction(ops(expr))
|
|
5211
|
+
},
|
|
5212
|
+
{
|
|
5213
|
+
latexTrigger: "\\rhd",
|
|
5214
|
+
kind: "infix",
|
|
5215
|
+
precedence: 20,
|
|
5216
|
+
parse: "Apply"
|
|
5217
|
+
},
|
|
5218
|
+
{
|
|
5219
|
+
latexTrigger: "\\lhd",
|
|
5220
|
+
kind: "infix",
|
|
5221
|
+
precedence: 20,
|
|
5222
|
+
parse: (parser, lhs) => {
|
|
5223
|
+
const rhs = parser.parseExpression({ minPrec: 20 }) ?? "Nothing";
|
|
5224
|
+
return ["Apply", rhs, lhs];
|
|
5225
|
+
}
|
|
5226
|
+
},
|
|
5202
5227
|
{
|
|
5203
5228
|
name: "BaseForm",
|
|
5204
5229
|
serialize: (serializer, expr) => {
|
|
@@ -5264,7 +5289,7 @@ var DEFINITIONS_CORE = [
|
|
|
5264
5289
|
}
|
|
5265
5290
|
},
|
|
5266
5291
|
{
|
|
5267
|
-
|
|
5292
|
+
latexTrigger: ["\\mathtip"],
|
|
5268
5293
|
parse: (parser) => {
|
|
5269
5294
|
const op12 = parser.parseGroup();
|
|
5270
5295
|
const op22 = parser.parseGroup();
|
|
@@ -5272,7 +5297,7 @@ var DEFINITIONS_CORE = [
|
|
|
5272
5297
|
}
|
|
5273
5298
|
},
|
|
5274
5299
|
{
|
|
5275
|
-
|
|
5300
|
+
latexTrigger: ["\\texttip"],
|
|
5276
5301
|
parse: (parser) => {
|
|
5277
5302
|
const op12 = parser.parseGroup();
|
|
5278
5303
|
const op22 = parser.parseGroup();
|
|
@@ -5280,8 +5305,8 @@ var DEFINITIONS_CORE = [
|
|
|
5280
5305
|
}
|
|
5281
5306
|
},
|
|
5282
5307
|
{
|
|
5283
|
-
|
|
5284
|
-
parse: (parser) => parser.parseGroup()
|
|
5308
|
+
latexTrigger: ["\\error"],
|
|
5309
|
+
parse: (parser) => ["Error", parser.parseGroup()]
|
|
5285
5310
|
},
|
|
5286
5311
|
{
|
|
5287
5312
|
name: "Error",
|
|
@@ -5341,10 +5366,10 @@ var DEFINITIONS_CORE = [
|
|
|
5341
5366
|
{
|
|
5342
5367
|
name: "List",
|
|
5343
5368
|
kind: "matchfix",
|
|
5344
|
-
|
|
5345
|
-
|
|
5369
|
+
openTrigger: "[",
|
|
5370
|
+
closeTrigger: "]",
|
|
5346
5371
|
parse: (_parser, body) => {
|
|
5347
|
-
if (body === null)
|
|
5372
|
+
if (body === null || isEmptySequence(body))
|
|
5348
5373
|
return ["List"];
|
|
5349
5374
|
if (head(body) !== "Sequence" && head(body) !== "List")
|
|
5350
5375
|
return ["List", body];
|
|
@@ -5360,11 +5385,11 @@ var DEFINITIONS_CORE = [
|
|
|
5360
5385
|
},
|
|
5361
5386
|
{
|
|
5362
5387
|
kind: "matchfix",
|
|
5363
|
-
|
|
5364
|
-
|
|
5388
|
+
openTrigger: "(",
|
|
5389
|
+
closeTrigger: ")",
|
|
5365
5390
|
parse: (_parser, body) => {
|
|
5366
|
-
if (body === null)
|
|
5367
|
-
return
|
|
5391
|
+
if (body === null || isEmptySequence(body))
|
|
5392
|
+
return ["Sequence"];
|
|
5368
5393
|
if (head(body) === "Sequence" || head(body) === "List") {
|
|
5369
5394
|
if (nops(body) === 0)
|
|
5370
5395
|
return ["Delimiter"];
|
|
@@ -5374,7 +5399,7 @@ var DEFINITIONS_CORE = [
|
|
|
5374
5399
|
}
|
|
5375
5400
|
},
|
|
5376
5401
|
{
|
|
5377
|
-
|
|
5402
|
+
latexTrigger: [","],
|
|
5378
5403
|
kind: "infix",
|
|
5379
5404
|
precedence: 20,
|
|
5380
5405
|
// Unlike the matchfix version of List,
|
|
@@ -5394,7 +5419,7 @@ var DEFINITIONS_CORE = [
|
|
|
5394
5419
|
serialize: serializeOps("")
|
|
5395
5420
|
},
|
|
5396
5421
|
{
|
|
5397
|
-
|
|
5422
|
+
latexTrigger: [";"],
|
|
5398
5423
|
kind: "infix",
|
|
5399
5424
|
precedence: 19,
|
|
5400
5425
|
parse: (parser, lhs, terminator) => {
|
|
@@ -5411,7 +5436,7 @@ var DEFINITIONS_CORE = [
|
|
|
5411
5436
|
},
|
|
5412
5437
|
{
|
|
5413
5438
|
name: "String",
|
|
5414
|
-
|
|
5439
|
+
latexTrigger: ["\\text"],
|
|
5415
5440
|
parse: (scanner) => parseTextRun(scanner),
|
|
5416
5441
|
serialize: (serializer, expr) => {
|
|
5417
5442
|
const args = ops(expr);
|
|
@@ -5426,7 +5451,7 @@ var DEFINITIONS_CORE = [
|
|
|
5426
5451
|
},
|
|
5427
5452
|
{
|
|
5428
5453
|
name: "Subscript",
|
|
5429
|
-
|
|
5454
|
+
latexTrigger: ["_"],
|
|
5430
5455
|
kind: "infix",
|
|
5431
5456
|
serialize: (serializer, expr) => {
|
|
5432
5457
|
if (nops(expr) === 2) {
|
|
@@ -5435,53 +5460,121 @@ var DEFINITIONS_CORE = [
|
|
|
5435
5460
|
return "_{" + serializer.serialize(op(expr, 1)) + "}";
|
|
5436
5461
|
}
|
|
5437
5462
|
},
|
|
5438
|
-
{ name: "Superplus",
|
|
5439
|
-
{ name: "Subplus",
|
|
5440
|
-
{ name: "Superminus",
|
|
5441
|
-
{ name: "Subminus",
|
|
5463
|
+
{ name: "Superplus", latexTrigger: ["^", "+"], kind: "postfix" },
|
|
5464
|
+
{ name: "Subplus", latexTrigger: ["_", "+"], kind: "postfix" },
|
|
5465
|
+
{ name: "Superminus", latexTrigger: ["^", "-"], kind: "postfix" },
|
|
5466
|
+
{ name: "Subminus", latexTrigger: ["_", "-"], kind: "postfix" },
|
|
5442
5467
|
{
|
|
5443
|
-
|
|
5468
|
+
latexTrigger: ["^", "*"],
|
|
5444
5469
|
kind: "postfix",
|
|
5445
5470
|
parse: (_parser, lhs) => ["Superstar", lhs]
|
|
5446
5471
|
},
|
|
5447
5472
|
// @todo: when lhs is a complex number, 'Conjugate'
|
|
5448
5473
|
// { name: 'Conjugate', trigger: ['\\star'], kind: 'infix' },
|
|
5449
|
-
{ name: "Superstar",
|
|
5474
|
+
{ name: "Superstar", latexTrigger: ["^", "\\star"], kind: "postfix" },
|
|
5450
5475
|
{
|
|
5451
|
-
|
|
5476
|
+
latexTrigger: ["_", "*"],
|
|
5452
5477
|
kind: "postfix",
|
|
5453
5478
|
parse: (_parser, lhs) => ["Substar", lhs]
|
|
5454
5479
|
},
|
|
5455
|
-
{ name: "Substar",
|
|
5456
|
-
{ name: "Superdagger",
|
|
5480
|
+
{ name: "Substar", latexTrigger: ["_", "\\star"], kind: "postfix" },
|
|
5481
|
+
{ name: "Superdagger", latexTrigger: ["^", "\\dagger"], kind: "postfix" },
|
|
5457
5482
|
{
|
|
5458
|
-
|
|
5483
|
+
latexTrigger: ["^", "\\dag"],
|
|
5459
5484
|
kind: "postfix",
|
|
5460
5485
|
parse: (_parser, lhs) => ["Superdagger", lhs]
|
|
5461
5486
|
},
|
|
5462
5487
|
{
|
|
5463
5488
|
name: "Prime",
|
|
5464
|
-
|
|
5465
|
-
|
|
5489
|
+
latexTrigger: ["^", "\\prime"],
|
|
5490
|
+
// Note: we don't need a precedence because the trigger is '^'
|
|
5491
|
+
// and '^' (and '_') are treated specially by the parser.
|
|
5492
|
+
kind: "postfix",
|
|
5493
|
+
parse: (parser, lhs) => parsePrime(parser, lhs, 1),
|
|
5494
|
+
serialize: (serializer, expr) => {
|
|
5495
|
+
const n2 = machineValue(op(expr, 2)) ?? 1;
|
|
5496
|
+
const base = serializer.serialize(op(expr, 1));
|
|
5497
|
+
if (n2 === 1)
|
|
5498
|
+
return base + "^\\prime";
|
|
5499
|
+
if (n2 === 2)
|
|
5500
|
+
return base + "^\\doubleprime";
|
|
5501
|
+
if (n2 === 3)
|
|
5502
|
+
return base + "^\\tripleprime";
|
|
5503
|
+
return base + "^{(" + serializer.serialize(op(expr, 2)) + ")}";
|
|
5504
|
+
}
|
|
5505
|
+
},
|
|
5506
|
+
{
|
|
5507
|
+
latexTrigger: "^{\\prime\\prime}",
|
|
5508
|
+
kind: "postfix",
|
|
5509
|
+
parse: (parser, lhs) => parsePrime(parser, lhs, 2)
|
|
5510
|
+
},
|
|
5511
|
+
{
|
|
5512
|
+
latexTrigger: "^{\\prime\\prime\\prime}",
|
|
5513
|
+
kind: "postfix",
|
|
5514
|
+
parse: (parser, lhs) => parsePrime(parser, lhs, 3)
|
|
5515
|
+
},
|
|
5516
|
+
{
|
|
5517
|
+
latexTrigger: ["^", "\\doubleprime"],
|
|
5518
|
+
kind: "postfix",
|
|
5519
|
+
parse: (parser, lhs) => parsePrime(parser, lhs, 2)
|
|
5520
|
+
},
|
|
5521
|
+
{
|
|
5522
|
+
latexTrigger: ["^", "\\tripleprime"],
|
|
5523
|
+
kind: "postfix",
|
|
5524
|
+
parse: (parser, lhs) => parsePrime(parser, lhs, 3)
|
|
5525
|
+
},
|
|
5526
|
+
{
|
|
5527
|
+
latexTrigger: "'",
|
|
5528
|
+
kind: "postfix",
|
|
5529
|
+
precedence: 810,
|
|
5530
|
+
parse: (parser, lhs) => parsePrime(parser, lhs, 1)
|
|
5466
5531
|
},
|
|
5467
5532
|
{
|
|
5468
|
-
|
|
5533
|
+
latexTrigger: "\\prime",
|
|
5469
5534
|
kind: "postfix",
|
|
5470
|
-
|
|
5535
|
+
precedence: 810,
|
|
5536
|
+
parse: (parser, lhs) => parsePrime(parser, lhs, 1)
|
|
5471
5537
|
},
|
|
5472
5538
|
{
|
|
5473
|
-
|
|
5539
|
+
latexTrigger: "\\doubleprime",
|
|
5474
5540
|
kind: "postfix",
|
|
5475
|
-
|
|
5541
|
+
precedence: 810,
|
|
5542
|
+
parse: (parser, lhs) => parsePrime(parser, lhs, 2)
|
|
5543
|
+
},
|
|
5544
|
+
{
|
|
5545
|
+
latexTrigger: "\\tripleprime",
|
|
5546
|
+
kind: "postfix",
|
|
5547
|
+
precedence: 810,
|
|
5548
|
+
parse: (parser, lhs) => parsePrime(parser, lhs, 3)
|
|
5549
|
+
},
|
|
5550
|
+
{
|
|
5551
|
+
latexTrigger: ["^", "<{>", "("],
|
|
5552
|
+
kind: "postfix",
|
|
5553
|
+
parse: (parser, lhs) => {
|
|
5554
|
+
if (!parser.computeEngine?.box(lhs)?.domain.isFunction)
|
|
5555
|
+
return null;
|
|
5556
|
+
const start = parser.index;
|
|
5557
|
+
parser.addBoundary([")"]);
|
|
5558
|
+
const expr = parser.parseExpression();
|
|
5559
|
+
if (!parser.matchBoundary()) {
|
|
5560
|
+
parser.index = start;
|
|
5561
|
+
return null;
|
|
5562
|
+
}
|
|
5563
|
+
if (!parser.match("<}>")) {
|
|
5564
|
+
parser.index = start;
|
|
5565
|
+
return null;
|
|
5566
|
+
}
|
|
5567
|
+
return ["Derivative", lhs, expr];
|
|
5568
|
+
}
|
|
5476
5569
|
},
|
|
5477
5570
|
{
|
|
5478
5571
|
name: "InverseFunction",
|
|
5479
|
-
|
|
5572
|
+
latexTrigger: "^{-1}",
|
|
5480
5573
|
kind: "postfix",
|
|
5481
5574
|
parse: (parser, lhs) => {
|
|
5482
5575
|
if (parser.computeEngine?.box(lhs)?.domain.isFunction)
|
|
5483
5576
|
return ["InverseFunction", lhs];
|
|
5484
|
-
return
|
|
5577
|
+
return ["Power", missingIfEmpty(lhs), -1];
|
|
5485
5578
|
},
|
|
5486
5579
|
serialize: (serializer, expr) => serializer.serialize(op(expr, 1)) + "^{-1}"
|
|
5487
5580
|
},
|
|
@@ -5496,13 +5589,13 @@ var DEFINITIONS_CORE = [
|
|
|
5496
5589
|
return base + "^{\\doubleprime}";
|
|
5497
5590
|
if (degree === 3)
|
|
5498
5591
|
return base + "^{\\tripleprime}";
|
|
5499
|
-
return base + "^{(" +
|
|
5592
|
+
return base + "^{(" + serializer.serialize(op(expr, 2)) + ")}";
|
|
5500
5593
|
}
|
|
5501
5594
|
},
|
|
5502
5595
|
{
|
|
5503
|
-
name: "Which",
|
|
5504
|
-
trigger: "cases",
|
|
5505
5596
|
kind: "environment",
|
|
5597
|
+
name: "Which",
|
|
5598
|
+
identifierTrigger: "cases",
|
|
5506
5599
|
parse: (parser) => {
|
|
5507
5600
|
const tabular = parser.parseTabular();
|
|
5508
5601
|
if (!tabular)
|
|
@@ -5645,11 +5738,26 @@ function errorContextAsLatex(serializer, error) {
|
|
|
5645
5738
|
return serializer.serialize(op(arg, 1));
|
|
5646
5739
|
return serializer.serialize(arg);
|
|
5647
5740
|
}
|
|
5741
|
+
function parsePrime(parser, lhs, order2) {
|
|
5742
|
+
const lhsh = head(lhs);
|
|
5743
|
+
if (lhsh === "Derivative" || lhsh === "Prime") {
|
|
5744
|
+
const n = machineValue(op(lhs, 2)) ?? 1;
|
|
5745
|
+
return [lhsh, missingIfEmpty(op(lhs, 1)), n + order2];
|
|
5746
|
+
}
|
|
5747
|
+
if (parser.computeEngine?.box(lhs)?.domain.isFunction) {
|
|
5748
|
+
if (order2 === 1)
|
|
5749
|
+
return ["Derivative", lhs];
|
|
5750
|
+
return ["Derivative", lhs, order2];
|
|
5751
|
+
}
|
|
5752
|
+
if (order2 === 1)
|
|
5753
|
+
return ["Prime", missingIfEmpty(lhs)];
|
|
5754
|
+
return ["Prime", missingIfEmpty(lhs), order2];
|
|
5755
|
+
}
|
|
5648
5756
|
|
|
5649
5757
|
// src/compute-engine/latex-syntax/dictionary/definitions-inequalities.ts
|
|
5650
5758
|
var DEFINITIONS_INEQUALITIES = [
|
|
5651
5759
|
{
|
|
5652
|
-
|
|
5760
|
+
latexTrigger: ["\\not", "<"],
|
|
5653
5761
|
kind: "infix",
|
|
5654
5762
|
associativity: "right",
|
|
5655
5763
|
precedence: 246,
|
|
@@ -5657,13 +5765,13 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5657
5765
|
},
|
|
5658
5766
|
{
|
|
5659
5767
|
name: "NotLess",
|
|
5660
|
-
|
|
5768
|
+
latexTrigger: ["\\nless"],
|
|
5661
5769
|
kind: "infix",
|
|
5662
5770
|
associativity: "right",
|
|
5663
5771
|
precedence: 246
|
|
5664
5772
|
},
|
|
5665
5773
|
{
|
|
5666
|
-
|
|
5774
|
+
latexTrigger: ["<"],
|
|
5667
5775
|
kind: "infix",
|
|
5668
5776
|
associativity: "right",
|
|
5669
5777
|
precedence: 245,
|
|
@@ -5671,13 +5779,13 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5671
5779
|
},
|
|
5672
5780
|
{
|
|
5673
5781
|
name: "Less",
|
|
5674
|
-
|
|
5782
|
+
latexTrigger: ["\\lt"],
|
|
5675
5783
|
kind: "infix",
|
|
5676
5784
|
associativity: "right",
|
|
5677
5785
|
precedence: 245
|
|
5678
5786
|
},
|
|
5679
5787
|
{
|
|
5680
|
-
|
|
5788
|
+
latexTrigger: ["<", "="],
|
|
5681
5789
|
kind: "infix",
|
|
5682
5790
|
associativity: "right",
|
|
5683
5791
|
precedence: 241,
|
|
@@ -5685,20 +5793,20 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5685
5793
|
},
|
|
5686
5794
|
{
|
|
5687
5795
|
name: "LessEqual",
|
|
5688
|
-
|
|
5796
|
+
latexTrigger: ["\\le"],
|
|
5689
5797
|
kind: "infix",
|
|
5690
5798
|
associativity: "right",
|
|
5691
5799
|
precedence: 241
|
|
5692
5800
|
},
|
|
5693
5801
|
{
|
|
5694
|
-
|
|
5802
|
+
latexTrigger: ["\\leq"],
|
|
5695
5803
|
kind: "infix",
|
|
5696
5804
|
associativity: "right",
|
|
5697
5805
|
precedence: 241,
|
|
5698
5806
|
parse: "LessEqual"
|
|
5699
5807
|
},
|
|
5700
5808
|
{
|
|
5701
|
-
|
|
5809
|
+
latexTrigger: ["\\leqslant"],
|
|
5702
5810
|
kind: "infix",
|
|
5703
5811
|
associativity: "right",
|
|
5704
5812
|
precedence: 265,
|
|
@@ -5707,28 +5815,28 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5707
5815
|
},
|
|
5708
5816
|
{
|
|
5709
5817
|
name: "LessNotEqual",
|
|
5710
|
-
|
|
5818
|
+
latexTrigger: ["\\lneqq"],
|
|
5711
5819
|
kind: "infix",
|
|
5712
5820
|
associativity: "right",
|
|
5713
5821
|
precedence: 260
|
|
5714
5822
|
},
|
|
5715
5823
|
{
|
|
5716
5824
|
name: "NotLessNotEqual",
|
|
5717
|
-
|
|
5825
|
+
latexTrigger: ["\\nleqq"],
|
|
5718
5826
|
kind: "infix",
|
|
5719
5827
|
associativity: "right",
|
|
5720
5828
|
precedence: 260
|
|
5721
5829
|
},
|
|
5722
5830
|
{
|
|
5723
5831
|
name: "LessOverEqual",
|
|
5724
|
-
|
|
5832
|
+
latexTrigger: ["\\leqq"],
|
|
5725
5833
|
kind: "infix",
|
|
5726
5834
|
associativity: "right",
|
|
5727
5835
|
precedence: 265
|
|
5728
5836
|
},
|
|
5729
5837
|
{
|
|
5730
5838
|
name: "GreaterOverEqual",
|
|
5731
|
-
|
|
5839
|
+
latexTrigger: ["\\geqq"],
|
|
5732
5840
|
kind: "infix",
|
|
5733
5841
|
associativity: "right",
|
|
5734
5842
|
precedence: 265,
|
|
@@ -5736,13 +5844,13 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5736
5844
|
},
|
|
5737
5845
|
{
|
|
5738
5846
|
name: "Equal",
|
|
5739
|
-
|
|
5847
|
+
latexTrigger: ["="],
|
|
5740
5848
|
kind: "infix",
|
|
5741
5849
|
associativity: "right",
|
|
5742
5850
|
precedence: 260
|
|
5743
5851
|
},
|
|
5744
5852
|
{
|
|
5745
|
-
|
|
5853
|
+
latexTrigger: ["*", "="],
|
|
5746
5854
|
kind: "infix",
|
|
5747
5855
|
associativity: "right",
|
|
5748
5856
|
precedence: 260,
|
|
@@ -5750,42 +5858,42 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5750
5858
|
},
|
|
5751
5859
|
{
|
|
5752
5860
|
name: "StarEqual",
|
|
5753
|
-
|
|
5861
|
+
latexTrigger: ["\\star", "="],
|
|
5754
5862
|
kind: "infix",
|
|
5755
5863
|
associativity: "right",
|
|
5756
5864
|
precedence: 260
|
|
5757
5865
|
},
|
|
5758
5866
|
{
|
|
5759
5867
|
name: "PlusEqual",
|
|
5760
|
-
|
|
5868
|
+
latexTrigger: ["+", "="],
|
|
5761
5869
|
kind: "infix",
|
|
5762
5870
|
associativity: "right",
|
|
5763
5871
|
precedence: 260
|
|
5764
5872
|
},
|
|
5765
5873
|
{
|
|
5766
5874
|
name: "MinusEqual",
|
|
5767
|
-
|
|
5875
|
+
latexTrigger: ["-", "="],
|
|
5768
5876
|
kind: "infix",
|
|
5769
5877
|
associativity: "right",
|
|
5770
5878
|
precedence: 260
|
|
5771
5879
|
},
|
|
5772
5880
|
{
|
|
5773
5881
|
name: "SlashEqual",
|
|
5774
|
-
|
|
5882
|
+
latexTrigger: ["/", "="],
|
|
5775
5883
|
kind: "infix",
|
|
5776
5884
|
associativity: "right",
|
|
5777
5885
|
precedence: 260
|
|
5778
5886
|
},
|
|
5779
5887
|
{
|
|
5780
5888
|
name: "EqualEqual",
|
|
5781
|
-
|
|
5889
|
+
latexTrigger: ["=", "="],
|
|
5782
5890
|
kind: "infix",
|
|
5783
5891
|
associativity: "right",
|
|
5784
5892
|
precedence: 260
|
|
5785
5893
|
},
|
|
5786
5894
|
{
|
|
5787
5895
|
name: "EqualEqualEqual",
|
|
5788
|
-
|
|
5896
|
+
latexTrigger: ["=", "=", "="],
|
|
5789
5897
|
kind: "infix",
|
|
5790
5898
|
associativity: "right",
|
|
5791
5899
|
precedence: 265
|
|
@@ -5793,7 +5901,7 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5793
5901
|
{
|
|
5794
5902
|
name: "TildeFullEqual",
|
|
5795
5903
|
// MathML: approximately equal to
|
|
5796
|
-
|
|
5904
|
+
latexTrigger: ["\\cong"],
|
|
5797
5905
|
kind: "infix",
|
|
5798
5906
|
associativity: "right",
|
|
5799
5907
|
precedence: 260
|
|
@@ -5801,13 +5909,13 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5801
5909
|
{
|
|
5802
5910
|
name: "NotTildeFullEqual",
|
|
5803
5911
|
// MathML: approximately but not actually equal to
|
|
5804
|
-
|
|
5912
|
+
latexTrigger: ["\\ncong"],
|
|
5805
5913
|
kind: "infix",
|
|
5806
5914
|
associativity: "right",
|
|
5807
5915
|
precedence: 260
|
|
5808
5916
|
},
|
|
5809
5917
|
{
|
|
5810
|
-
|
|
5918
|
+
latexTrigger: [":", "="],
|
|
5811
5919
|
kind: "infix",
|
|
5812
5920
|
associativity: "right",
|
|
5813
5921
|
precedence: 260,
|
|
@@ -5815,7 +5923,7 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5815
5923
|
},
|
|
5816
5924
|
{
|
|
5817
5925
|
name: "Assign",
|
|
5818
|
-
|
|
5926
|
+
latexTrigger: ["\\coloneq"],
|
|
5819
5927
|
kind: "infix",
|
|
5820
5928
|
associativity: "right",
|
|
5821
5929
|
precedence: 260
|
|
@@ -5823,7 +5931,7 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5823
5931
|
{
|
|
5824
5932
|
name: "Approx",
|
|
5825
5933
|
// Note: Mathematica TildeTilde
|
|
5826
|
-
|
|
5934
|
+
latexTrigger: ["\\approx"],
|
|
5827
5935
|
kind: "infix",
|
|
5828
5936
|
associativity: "right",
|
|
5829
5937
|
precedence: 247
|
|
@@ -5831,7 +5939,7 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5831
5939
|
{
|
|
5832
5940
|
name: "NotApprox",
|
|
5833
5941
|
// Note: Mathematica TildeTilde
|
|
5834
|
-
|
|
5942
|
+
latexTrigger: ["\\not", "\\approx"],
|
|
5835
5943
|
kind: "infix",
|
|
5836
5944
|
associativity: "right",
|
|
5837
5945
|
precedence: 247
|
|
@@ -5839,7 +5947,7 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5839
5947
|
{
|
|
5840
5948
|
name: "ApproxEqual",
|
|
5841
5949
|
// Note: Mathematica TildeEqual, MathML: `asymptotically equal to`
|
|
5842
|
-
|
|
5950
|
+
latexTrigger: ["\\approxeq"],
|
|
5843
5951
|
kind: "infix",
|
|
5844
5952
|
associativity: "right",
|
|
5845
5953
|
precedence: 260
|
|
@@ -5847,7 +5955,7 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5847
5955
|
{
|
|
5848
5956
|
name: "NotApproxEqual",
|
|
5849
5957
|
// Note: Mathematica NotTildeEqual
|
|
5850
|
-
|
|
5958
|
+
latexTrigger: ["\\not", "\\approxeq"],
|
|
5851
5959
|
kind: "infix",
|
|
5852
5960
|
// Note: no LaTeX symbol for char U+2249
|
|
5853
5961
|
associativity: "right",
|
|
@@ -5855,14 +5963,14 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5855
5963
|
},
|
|
5856
5964
|
{
|
|
5857
5965
|
name: "NotEqual",
|
|
5858
|
-
|
|
5966
|
+
latexTrigger: ["\\ne"],
|
|
5859
5967
|
kind: "infix",
|
|
5860
5968
|
associativity: "right",
|
|
5861
5969
|
precedence: 255
|
|
5862
5970
|
},
|
|
5863
5971
|
{
|
|
5864
5972
|
name: "Unequal",
|
|
5865
|
-
|
|
5973
|
+
latexTrigger: ["!", "="],
|
|
5866
5974
|
kind: "infix",
|
|
5867
5975
|
associativity: "right",
|
|
5868
5976
|
precedence: 260
|
|
@@ -5870,14 +5978,14 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5870
5978
|
},
|
|
5871
5979
|
{
|
|
5872
5980
|
name: "GreaterEqual",
|
|
5873
|
-
|
|
5981
|
+
latexTrigger: ["\\ge"],
|
|
5874
5982
|
kind: "infix",
|
|
5875
5983
|
associativity: "right",
|
|
5876
5984
|
precedence: 242
|
|
5877
5985
|
// Note: different precendence than `>=` as per MathML
|
|
5878
5986
|
},
|
|
5879
5987
|
{
|
|
5880
|
-
|
|
5988
|
+
latexTrigger: ["\\geq"],
|
|
5881
5989
|
kind: "infix",
|
|
5882
5990
|
associativity: "right",
|
|
5883
5991
|
precedence: 242,
|
|
@@ -5885,14 +5993,14 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5885
5993
|
parse: "GreaterEqual"
|
|
5886
5994
|
},
|
|
5887
5995
|
{
|
|
5888
|
-
|
|
5996
|
+
latexTrigger: [">", "="],
|
|
5889
5997
|
kind: "infix",
|
|
5890
5998
|
associativity: "right",
|
|
5891
5999
|
precedence: 243,
|
|
5892
6000
|
parse: "GreaterEqual"
|
|
5893
6001
|
},
|
|
5894
6002
|
{
|
|
5895
|
-
|
|
6003
|
+
latexTrigger: ["\\geqslant"],
|
|
5896
6004
|
kind: "infix",
|
|
5897
6005
|
associativity: "right",
|
|
5898
6006
|
precedence: 265,
|
|
@@ -5901,20 +6009,20 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5901
6009
|
},
|
|
5902
6010
|
{
|
|
5903
6011
|
name: "GreaterNotEqual",
|
|
5904
|
-
|
|
6012
|
+
latexTrigger: ["\\gneqq"],
|
|
5905
6013
|
kind: "infix",
|
|
5906
6014
|
associativity: "right",
|
|
5907
6015
|
precedence: 260
|
|
5908
6016
|
},
|
|
5909
6017
|
{
|
|
5910
6018
|
name: "NotGreaterNotEqual",
|
|
5911
|
-
|
|
6019
|
+
latexTrigger: ["\\ngeqq"],
|
|
5912
6020
|
kind: "infix",
|
|
5913
6021
|
associativity: "right",
|
|
5914
6022
|
precedence: 260
|
|
5915
6023
|
},
|
|
5916
6024
|
{
|
|
5917
|
-
|
|
6025
|
+
latexTrigger: [">"],
|
|
5918
6026
|
kind: "infix",
|
|
5919
6027
|
associativity: "right",
|
|
5920
6028
|
precedence: 245,
|
|
@@ -5922,20 +6030,20 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5922
6030
|
},
|
|
5923
6031
|
{
|
|
5924
6032
|
name: "Greater",
|
|
5925
|
-
|
|
6033
|
+
latexTrigger: ["\\gt"],
|
|
5926
6034
|
kind: "infix",
|
|
5927
6035
|
associativity: "right",
|
|
5928
6036
|
precedence: 245
|
|
5929
6037
|
},
|
|
5930
6038
|
{
|
|
5931
6039
|
name: "NotGreater",
|
|
5932
|
-
|
|
6040
|
+
latexTrigger: ["\\ngtr"],
|
|
5933
6041
|
kind: "infix",
|
|
5934
6042
|
associativity: "right",
|
|
5935
6043
|
precedence: 244
|
|
5936
6044
|
},
|
|
5937
6045
|
{
|
|
5938
|
-
|
|
6046
|
+
latexTrigger: ["\\not", ">"],
|
|
5939
6047
|
kind: "infix",
|
|
5940
6048
|
associativity: "right",
|
|
5941
6049
|
precedence: 244,
|
|
@@ -5943,7 +6051,7 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5943
6051
|
},
|
|
5944
6052
|
{
|
|
5945
6053
|
name: "RingEqual",
|
|
5946
|
-
|
|
6054
|
+
latexTrigger: ["\\circeq"],
|
|
5947
6055
|
kind: "infix",
|
|
5948
6056
|
associativity: "right",
|
|
5949
6057
|
precedence: 260
|
|
@@ -5951,7 +6059,7 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5951
6059
|
{
|
|
5952
6060
|
name: "TriangleEqual",
|
|
5953
6061
|
// MathML: delta equal to
|
|
5954
|
-
|
|
6062
|
+
latexTrigger: ["\\triangleq"],
|
|
5955
6063
|
kind: "infix",
|
|
5956
6064
|
associativity: "right",
|
|
5957
6065
|
precedence: 260
|
|
@@ -5959,7 +6067,7 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5959
6067
|
{
|
|
5960
6068
|
name: "DotEqual",
|
|
5961
6069
|
// MathML: approaches the limit
|
|
5962
|
-
|
|
6070
|
+
latexTrigger: ["\\doteq"],
|
|
5963
6071
|
kind: "infix",
|
|
5964
6072
|
associativity: "right",
|
|
5965
6073
|
precedence: 265
|
|
@@ -5967,7 +6075,7 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5967
6075
|
{
|
|
5968
6076
|
name: "DotEqualDot",
|
|
5969
6077
|
// MathML: Geometrically equal
|
|
5970
|
-
|
|
6078
|
+
latexTrigger: ["\\doteqdot"],
|
|
5971
6079
|
kind: "infix",
|
|
5972
6080
|
associativity: "right",
|
|
5973
6081
|
precedence: 265
|
|
@@ -5975,7 +6083,7 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5975
6083
|
{
|
|
5976
6084
|
name: "FallingDotEqual",
|
|
5977
6085
|
// MathML: approximately equal to or the image of
|
|
5978
|
-
|
|
6086
|
+
latexTrigger: ["\\fallingdotseq"],
|
|
5979
6087
|
kind: "infix",
|
|
5980
6088
|
associativity: "right",
|
|
5981
6089
|
precedence: 265
|
|
@@ -5983,92 +6091,77 @@ var DEFINITIONS_INEQUALITIES = [
|
|
|
5983
6091
|
{
|
|
5984
6092
|
name: "RisingDotEqual",
|
|
5985
6093
|
// MathML: image of or approximately equal to
|
|
5986
|
-
|
|
6094
|
+
latexTrigger: ["\\fallingdotseq"],
|
|
5987
6095
|
kind: "infix",
|
|
5988
6096
|
associativity: "right",
|
|
5989
6097
|
precedence: 265
|
|
5990
6098
|
},
|
|
5991
6099
|
{
|
|
5992
6100
|
name: "QuestionEqual",
|
|
5993
|
-
|
|
5994
|
-
kind: "infix",
|
|
5995
|
-
associativity: "right",
|
|
5996
|
-
precedence: 260
|
|
5997
|
-
},
|
|
5998
|
-
{
|
|
5999
|
-
name: "Equivalent",
|
|
6000
|
-
// MathML: identical to, Mathematica: Congruent
|
|
6001
|
-
trigger: ["\\equiv"],
|
|
6101
|
+
latexTrigger: ["\\questeq"],
|
|
6002
6102
|
kind: "infix",
|
|
6003
6103
|
associativity: "right",
|
|
6004
6104
|
precedence: 260
|
|
6005
6105
|
},
|
|
6006
|
-
{
|
|
6007
|
-
trigger: ["\\iff"],
|
|
6008
|
-
kind: "infix",
|
|
6009
|
-
parse: "Equivalent",
|
|
6010
|
-
associativity: "right",
|
|
6011
|
-
precedence: 260
|
|
6012
|
-
},
|
|
6013
6106
|
{
|
|
6014
6107
|
name: "MuchLess",
|
|
6015
|
-
|
|
6108
|
+
latexTrigger: ["\\ll"],
|
|
6016
6109
|
kind: "infix",
|
|
6017
6110
|
associativity: "right",
|
|
6018
6111
|
precedence: 260
|
|
6019
6112
|
},
|
|
6020
6113
|
{
|
|
6021
6114
|
name: "MuchGreater",
|
|
6022
|
-
|
|
6115
|
+
latexTrigger: ["\\gg"],
|
|
6023
6116
|
kind: "infix",
|
|
6024
6117
|
associativity: "right",
|
|
6025
6118
|
precedence: 260
|
|
6026
6119
|
},
|
|
6027
6120
|
{
|
|
6028
6121
|
name: "Precedes",
|
|
6029
|
-
|
|
6122
|
+
latexTrigger: ["\\prec"],
|
|
6030
6123
|
kind: "infix",
|
|
6031
6124
|
associativity: "right",
|
|
6032
6125
|
precedence: 260
|
|
6033
6126
|
},
|
|
6034
6127
|
{
|
|
6035
6128
|
name: "Succeeds",
|
|
6036
|
-
|
|
6129
|
+
latexTrigger: ["\\succ"],
|
|
6037
6130
|
kind: "infix",
|
|
6038
6131
|
associativity: "right",
|
|
6039
6132
|
precedence: 260
|
|
6040
6133
|
},
|
|
6041
6134
|
{
|
|
6042
6135
|
name: "PrecedesEqual",
|
|
6043
|
-
|
|
6136
|
+
latexTrigger: ["\\preccurlyeq"],
|
|
6044
6137
|
kind: "infix",
|
|
6045
6138
|
associativity: "right",
|
|
6046
6139
|
precedence: 260
|
|
6047
6140
|
},
|
|
6048
6141
|
{
|
|
6049
6142
|
name: "SucceedsEqual",
|
|
6050
|
-
|
|
6143
|
+
latexTrigger: ["\\curlyeqprec"],
|
|
6051
6144
|
kind: "infix",
|
|
6052
6145
|
associativity: "right",
|
|
6053
6146
|
precedence: 260
|
|
6054
6147
|
},
|
|
6055
6148
|
{
|
|
6056
6149
|
name: "NotPrecedes",
|
|
6057
|
-
|
|
6150
|
+
latexTrigger: ["\\nprec"],
|
|
6058
6151
|
kind: "infix",
|
|
6059
6152
|
associativity: "right",
|
|
6060
6153
|
precedence: 260
|
|
6061
6154
|
},
|
|
6062
6155
|
{
|
|
6063
6156
|
name: "NotSucceeds",
|
|
6064
|
-
|
|
6157
|
+
latexTrigger: ["\\nsucc"],
|
|
6065
6158
|
kind: "infix",
|
|
6066
6159
|
associativity: "right",
|
|
6067
6160
|
precedence: 260
|
|
6068
6161
|
},
|
|
6069
6162
|
{
|
|
6070
6163
|
name: "Between",
|
|
6071
|
-
|
|
6164
|
+
latexTrigger: ["\\between"],
|
|
6072
6165
|
kind: "infix",
|
|
6073
6166
|
associativity: "right",
|
|
6074
6167
|
precedence: 265
|
|
@@ -6080,18 +6173,187 @@ var DEFINITIONS_LOGIC = [
|
|
|
6080
6173
|
// Constants
|
|
6081
6174
|
{
|
|
6082
6175
|
name: "True",
|
|
6083
|
-
|
|
6084
|
-
|
|
6176
|
+
kind: "symbol",
|
|
6177
|
+
latexTrigger: ["\\top"]
|
|
6178
|
+
// ⊤ U+22A4
|
|
6179
|
+
},
|
|
6180
|
+
{
|
|
6181
|
+
kind: "symbol",
|
|
6182
|
+
latexTrigger: "\\mathrm{True}",
|
|
6183
|
+
parse: "True"
|
|
6184
|
+
},
|
|
6185
|
+
{
|
|
6186
|
+
kind: "symbol",
|
|
6187
|
+
latexTrigger: "\\operator{True}",
|
|
6188
|
+
parse: "True"
|
|
6189
|
+
},
|
|
6190
|
+
{
|
|
6191
|
+
kind: "symbol",
|
|
6192
|
+
latexTrigger: "\\mathsf{T}",
|
|
6193
|
+
parse: "True"
|
|
6085
6194
|
},
|
|
6086
6195
|
{
|
|
6087
6196
|
name: "False",
|
|
6088
|
-
|
|
6089
|
-
|
|
6197
|
+
kind: "symbol",
|
|
6198
|
+
latexTrigger: ["\\bot"]
|
|
6199
|
+
// ⊥ U+22A5
|
|
6200
|
+
},
|
|
6201
|
+
{
|
|
6202
|
+
kind: "symbol",
|
|
6203
|
+
latexTrigger: "\\operator{False}",
|
|
6204
|
+
parse: "True"
|
|
6205
|
+
},
|
|
6206
|
+
{
|
|
6207
|
+
kind: "symbol",
|
|
6208
|
+
latexTrigger: "\\mathsf{F}",
|
|
6209
|
+
parse: "True"
|
|
6090
6210
|
},
|
|
6091
6211
|
{
|
|
6092
6212
|
name: "Maybe",
|
|
6093
|
-
|
|
6094
|
-
|
|
6213
|
+
kind: "symbol",
|
|
6214
|
+
latexTrigger: "\\operatorname{Maybe}",
|
|
6215
|
+
serialize: "\\operatorname{Maybe}"
|
|
6216
|
+
},
|
|
6217
|
+
{
|
|
6218
|
+
kind: "symbol",
|
|
6219
|
+
latexTrigger: "\\mathrm{Maybe}",
|
|
6220
|
+
parse: "Maybe"
|
|
6221
|
+
},
|
|
6222
|
+
// Operators
|
|
6223
|
+
{
|
|
6224
|
+
name: "And",
|
|
6225
|
+
kind: "infix",
|
|
6226
|
+
latexTrigger: ["\\land"],
|
|
6227
|
+
precedence: 317
|
|
6228
|
+
// serialize: '\\land',
|
|
6229
|
+
},
|
|
6230
|
+
{ kind: "infix", latexTrigger: ["\\wedge"], parse: "And", precedence: 317 },
|
|
6231
|
+
{ kind: "infix", latexTrigger: "\\&", parse: "And", precedence: 317 },
|
|
6232
|
+
{
|
|
6233
|
+
kind: "infix",
|
|
6234
|
+
latexTrigger: "\\operatorname{and}",
|
|
6235
|
+
parse: "And",
|
|
6236
|
+
precedence: 317
|
|
6237
|
+
},
|
|
6238
|
+
{
|
|
6239
|
+
name: "Or",
|
|
6240
|
+
kind: "infix",
|
|
6241
|
+
latexTrigger: ["\\lor"],
|
|
6242
|
+
precedence: 310
|
|
6243
|
+
},
|
|
6244
|
+
{ kind: "infix", latexTrigger: ["\\vee"], parse: "Or", precedence: 310 },
|
|
6245
|
+
{ kind: "infix", latexTrigger: "\\parallel", parse: "Or", precedence: 310 },
|
|
6246
|
+
{
|
|
6247
|
+
kind: "infix",
|
|
6248
|
+
latexTrigger: "\\operatorname{or}",
|
|
6249
|
+
parse: "And",
|
|
6250
|
+
precedence: 310
|
|
6251
|
+
},
|
|
6252
|
+
{
|
|
6253
|
+
name: "Xor",
|
|
6254
|
+
kind: "infix",
|
|
6255
|
+
latexTrigger: ["\\veebar"],
|
|
6256
|
+
precedence: 315
|
|
6257
|
+
},
|
|
6258
|
+
// Possible alt: \oplus ⊕ U+2295
|
|
6259
|
+
{
|
|
6260
|
+
name: "Not",
|
|
6261
|
+
kind: "prefix",
|
|
6262
|
+
latexTrigger: ["\\lnot"],
|
|
6263
|
+
precedence: 880
|
|
6264
|
+
},
|
|
6265
|
+
{
|
|
6266
|
+
name: "Nand",
|
|
6267
|
+
kind: "infix",
|
|
6268
|
+
latexTrigger: ["\\barwedge"],
|
|
6269
|
+
precedence: 315
|
|
6270
|
+
// serialize: '\\mid',
|
|
6271
|
+
},
|
|
6272
|
+
{
|
|
6273
|
+
name: "Nor",
|
|
6274
|
+
kind: "infix",
|
|
6275
|
+
latexTrigger: ["\u22BD"],
|
|
6276
|
+
// bar vee
|
|
6277
|
+
precedence: 315
|
|
6278
|
+
// serialize: '\\downarrow',
|
|
6279
|
+
},
|
|
6280
|
+
// Functions
|
|
6281
|
+
{
|
|
6282
|
+
kind: "function",
|
|
6283
|
+
identifierTrigger: "and",
|
|
6284
|
+
parse: "And"
|
|
6285
|
+
},
|
|
6286
|
+
{
|
|
6287
|
+
kind: "function",
|
|
6288
|
+
identifierTrigger: "or",
|
|
6289
|
+
parse: "Or"
|
|
6290
|
+
},
|
|
6291
|
+
{
|
|
6292
|
+
kind: "function",
|
|
6293
|
+
identifierTrigger: "not",
|
|
6294
|
+
parse: "Not"
|
|
6295
|
+
},
|
|
6296
|
+
// Relations
|
|
6297
|
+
{
|
|
6298
|
+
name: "Implies",
|
|
6299
|
+
kind: "infix",
|
|
6300
|
+
precedence: 220,
|
|
6301
|
+
associativity: "right",
|
|
6302
|
+
latexTrigger: ["\\implies"],
|
|
6303
|
+
serialize: "\\implies"
|
|
6304
|
+
},
|
|
6305
|
+
{
|
|
6306
|
+
latexTrigger: ["\\Rightarrow"],
|
|
6307
|
+
kind: "infix",
|
|
6308
|
+
precedence: 220,
|
|
6309
|
+
associativity: "right",
|
|
6310
|
+
parse: "Implies"
|
|
6311
|
+
},
|
|
6312
|
+
{
|
|
6313
|
+
name: "Equivalent",
|
|
6314
|
+
// MathML: identical to, Mathematica: Congruent
|
|
6315
|
+
latexTrigger: ["\\iff"],
|
|
6316
|
+
kind: "infix",
|
|
6317
|
+
associativity: "right",
|
|
6318
|
+
precedence: 219
|
|
6319
|
+
},
|
|
6320
|
+
{
|
|
6321
|
+
latexTrigger: ["\\Leftrightarrow"],
|
|
6322
|
+
kind: "infix",
|
|
6323
|
+
associativity: "right",
|
|
6324
|
+
precedence: 219,
|
|
6325
|
+
parse: "Equivalent"
|
|
6326
|
+
},
|
|
6327
|
+
{
|
|
6328
|
+
latexTrigger: ["\\equiv"],
|
|
6329
|
+
kind: "infix",
|
|
6330
|
+
associativity: "right",
|
|
6331
|
+
precedence: 219,
|
|
6332
|
+
parse: "Equivalent"
|
|
6333
|
+
},
|
|
6334
|
+
{
|
|
6335
|
+
name: "Proves",
|
|
6336
|
+
kind: "infix",
|
|
6337
|
+
latexTrigger: ["\\vdash"],
|
|
6338
|
+
precedence: 220,
|
|
6339
|
+
associativity: "right",
|
|
6340
|
+
serialize: "\\vdash"
|
|
6341
|
+
},
|
|
6342
|
+
{
|
|
6343
|
+
name: "Entails",
|
|
6344
|
+
kind: "infix",
|
|
6345
|
+
latexTrigger: ["\\vDash"],
|
|
6346
|
+
precedence: 220,
|
|
6347
|
+
associativity: "right",
|
|
6348
|
+
serialize: "\\vDash"
|
|
6349
|
+
},
|
|
6350
|
+
{
|
|
6351
|
+
name: "Satisfies",
|
|
6352
|
+
kind: "infix",
|
|
6353
|
+
latexTrigger: ["\\models"],
|
|
6354
|
+
precedence: 220,
|
|
6355
|
+
associativity: "right",
|
|
6356
|
+
serialize: "\\models"
|
|
6095
6357
|
}
|
|
6096
6358
|
];
|
|
6097
6359
|
|
|
@@ -6105,72 +6367,73 @@ function parseSingleArg(cmd) {
|
|
|
6105
6367
|
var DEFINITIONS_OTHERS = [
|
|
6106
6368
|
{
|
|
6107
6369
|
name: "Overscript",
|
|
6108
|
-
|
|
6370
|
+
latexTrigger: ["\\overset"],
|
|
6109
6371
|
kind: "infix",
|
|
6110
6372
|
precedence: 700
|
|
6111
6373
|
// @todo: not in MathML
|
|
6112
6374
|
},
|
|
6113
6375
|
{
|
|
6114
6376
|
name: "Underscript",
|
|
6115
|
-
|
|
6377
|
+
latexTrigger: ["\\underset"],
|
|
6116
6378
|
kind: "infix",
|
|
6117
6379
|
precedence: 700
|
|
6118
6380
|
// @todo: not in MathML
|
|
6119
6381
|
},
|
|
6120
6382
|
{
|
|
6121
6383
|
name: "Increment",
|
|
6122
|
-
|
|
6384
|
+
latexTrigger: ["+", "+"],
|
|
6123
6385
|
kind: "postfix",
|
|
6124
6386
|
precedence: 880
|
|
6125
6387
|
},
|
|
6126
6388
|
{
|
|
6127
6389
|
name: "Decrement",
|
|
6128
|
-
|
|
6390
|
+
latexTrigger: ["-", "-"],
|
|
6129
6391
|
kind: "postfix",
|
|
6130
6392
|
precedence: 880
|
|
6131
6393
|
},
|
|
6132
6394
|
{
|
|
6133
6395
|
name: "PreIncrement",
|
|
6134
|
-
|
|
6396
|
+
latexTrigger: ["+", "+"],
|
|
6135
6397
|
kind: "prefix",
|
|
6136
6398
|
precedence: 880
|
|
6137
6399
|
},
|
|
6138
6400
|
{
|
|
6139
6401
|
name: "PreDecrement",
|
|
6140
|
-
|
|
6402
|
+
latexTrigger: ["-", "-"],
|
|
6141
6403
|
kind: "prefix",
|
|
6142
6404
|
precedence: 880
|
|
6143
6405
|
},
|
|
6144
6406
|
{
|
|
6145
6407
|
name: "Ring",
|
|
6146
6408
|
// Aka 'Composition', i.e. function composition
|
|
6147
|
-
|
|
6409
|
+
latexTrigger: ["\\circ"],
|
|
6148
6410
|
kind: "infix",
|
|
6149
6411
|
precedence: 265
|
|
6412
|
+
// @todo: MathML is 950
|
|
6150
6413
|
// @todo: check lhs and rhs are functions
|
|
6151
6414
|
},
|
|
6152
6415
|
{
|
|
6153
6416
|
name: "Transpose",
|
|
6154
|
-
|
|
6417
|
+
latexTrigger: ["^", "T"],
|
|
6155
6418
|
kind: "postfix"
|
|
6156
6419
|
// @todo: if lhs is a list/tensor
|
|
6157
6420
|
},
|
|
6158
6421
|
{
|
|
6159
6422
|
// @todo: if lhs is a list/tensor
|
|
6160
6423
|
name: "ConjugateTranspose",
|
|
6161
|
-
|
|
6424
|
+
latexTrigger: ["^", "H"],
|
|
6162
6425
|
kind: "postfix"
|
|
6163
6426
|
},
|
|
6164
6427
|
{
|
|
6165
6428
|
name: "StringJoin",
|
|
6166
6429
|
// @todo From Mathematica...?
|
|
6167
|
-
|
|
6430
|
+
latexTrigger: ["\\lt", "\\gt"],
|
|
6168
6431
|
kind: "infix",
|
|
6169
6432
|
precedence: 780
|
|
6170
6433
|
},
|
|
6171
6434
|
{
|
|
6172
6435
|
name: "Starstar",
|
|
6173
|
-
|
|
6436
|
+
latexTrigger: ["\\star", "\\star"],
|
|
6174
6437
|
kind: "infix",
|
|
6175
6438
|
precedence: 780
|
|
6176
6439
|
},
|
|
@@ -6180,7 +6443,7 @@ var DEFINITIONS_OTHERS = [
|
|
|
6180
6443
|
// For the Leibniz notation see 'Divide' that handles `∂f/∂x`
|
|
6181
6444
|
name: "PartialDerivative",
|
|
6182
6445
|
// PartialDerivative(expr, {lists of vars}, degree)
|
|
6183
|
-
|
|
6446
|
+
latexTrigger: ["\\partial"],
|
|
6184
6447
|
kind: "prefix",
|
|
6185
6448
|
parse: (parser) => {
|
|
6186
6449
|
let done = false;
|
|
@@ -6203,8 +6466,8 @@ var DEFINITIONS_OTHERS = [
|
|
|
6203
6466
|
return null;
|
|
6204
6467
|
let rhs = parser.parseGroup() ?? "Nothing";
|
|
6205
6468
|
if (rhs !== "Nothing" && !isEmptySequence(rhs)) {
|
|
6206
|
-
const
|
|
6207
|
-
rhs = [rhs, ...
|
|
6469
|
+
const args = parser.parseArguments() ?? ["Nothing"];
|
|
6470
|
+
rhs = [rhs, ...args];
|
|
6208
6471
|
}
|
|
6209
6472
|
return ["PartialDerivative", rhs, sub2, sup];
|
|
6210
6473
|
},
|
|
@@ -6230,128 +6493,128 @@ var DEFINITIONS_OTHERS = [
|
|
|
6230
6493
|
},
|
|
6231
6494
|
{
|
|
6232
6495
|
name: "OverBar",
|
|
6233
|
-
|
|
6496
|
+
latexTrigger: ["\\overline"],
|
|
6234
6497
|
parse: parseSingleArg("OverBar")
|
|
6235
6498
|
},
|
|
6236
6499
|
{
|
|
6237
6500
|
name: "UnderBar",
|
|
6238
|
-
|
|
6501
|
+
latexTrigger: ["\\underline"],
|
|
6239
6502
|
parse: parseSingleArg("UnderBar")
|
|
6240
6503
|
},
|
|
6241
6504
|
{
|
|
6242
6505
|
name: "OverVector",
|
|
6243
|
-
|
|
6506
|
+
latexTrigger: ["\\vec"],
|
|
6244
6507
|
parse: parseSingleArg("OverVector")
|
|
6245
6508
|
},
|
|
6246
6509
|
{
|
|
6247
6510
|
name: "OverTilde",
|
|
6248
|
-
|
|
6511
|
+
latexTrigger: ["\\tilde"],
|
|
6249
6512
|
parse: parseSingleArg("OverTilde")
|
|
6250
6513
|
},
|
|
6251
6514
|
{
|
|
6252
6515
|
name: "OverHat",
|
|
6253
|
-
|
|
6516
|
+
latexTrigger: ["\\hat"],
|
|
6254
6517
|
parse: parseSingleArg("OverHat")
|
|
6255
6518
|
},
|
|
6256
6519
|
{
|
|
6257
6520
|
name: "OverRightArrow",
|
|
6258
|
-
|
|
6521
|
+
latexTrigger: ["\\overrightarrow"],
|
|
6259
6522
|
parse: parseSingleArg("OverRightArrow")
|
|
6260
6523
|
},
|
|
6261
6524
|
{
|
|
6262
6525
|
name: "OverLeftArrow",
|
|
6263
|
-
|
|
6526
|
+
latexTrigger: ["\\overleftarrow"],
|
|
6264
6527
|
parse: parseSingleArg("OverLeftArrow")
|
|
6265
6528
|
},
|
|
6266
6529
|
{
|
|
6267
6530
|
name: "OverRightDoubleArrow",
|
|
6268
|
-
|
|
6531
|
+
latexTrigger: ["\\Overrightarrow"],
|
|
6269
6532
|
parse: parseSingleArg("OverRightDoubleArrow")
|
|
6270
6533
|
},
|
|
6271
6534
|
{
|
|
6272
6535
|
name: "OverLeftHarpoon",
|
|
6273
|
-
|
|
6536
|
+
latexTrigger: ["\\overleftharpoon"],
|
|
6274
6537
|
parse: parseSingleArg("OverLeftHarpoon")
|
|
6275
6538
|
},
|
|
6276
6539
|
{
|
|
6277
6540
|
name: "OverRightHarpoon",
|
|
6278
|
-
|
|
6541
|
+
latexTrigger: ["\\overrightharpoon"],
|
|
6279
6542
|
parse: parseSingleArg("OverRightHarpoon")
|
|
6280
6543
|
},
|
|
6281
6544
|
{
|
|
6282
6545
|
name: "OverLeftRightArrow",
|
|
6283
|
-
|
|
6546
|
+
latexTrigger: ["\\overleftrightarrow"],
|
|
6284
6547
|
parse: parseSingleArg("OverLeftRightArrow")
|
|
6285
6548
|
},
|
|
6286
6549
|
{
|
|
6287
6550
|
name: "OverBrace",
|
|
6288
|
-
|
|
6551
|
+
latexTrigger: ["\\overbrace"],
|
|
6289
6552
|
parse: parseSingleArg("OverBrace")
|
|
6290
6553
|
},
|
|
6291
6554
|
{
|
|
6292
6555
|
name: "OverLineSegment",
|
|
6293
|
-
|
|
6556
|
+
latexTrigger: ["\\overlinesegment"],
|
|
6294
6557
|
parse: parseSingleArg("OverLineSegment")
|
|
6295
6558
|
},
|
|
6296
6559
|
{
|
|
6297
6560
|
name: "OverGroup",
|
|
6298
|
-
|
|
6561
|
+
latexTrigger: ["\\overgroup"],
|
|
6299
6562
|
parse: parseSingleArg("OverGroup")
|
|
6300
6563
|
},
|
|
6301
6564
|
{
|
|
6302
|
-
|
|
6565
|
+
latexTrigger: ["\\displaystyle"],
|
|
6303
6566
|
parse: () => ["Sequence"]
|
|
6304
6567
|
},
|
|
6305
6568
|
{
|
|
6306
|
-
|
|
6569
|
+
latexTrigger: ["\\textstyle"],
|
|
6307
6570
|
parse: () => ["Sequence"]
|
|
6308
6571
|
},
|
|
6309
6572
|
{
|
|
6310
|
-
|
|
6573
|
+
latexTrigger: ["\\scriptstyle"],
|
|
6311
6574
|
parse: () => ["Sequence"]
|
|
6312
6575
|
},
|
|
6313
6576
|
{
|
|
6314
|
-
|
|
6577
|
+
latexTrigger: ["\\scriptscriptstyle"],
|
|
6315
6578
|
parse: () => ["Sequence"]
|
|
6316
6579
|
},
|
|
6317
6580
|
{
|
|
6318
|
-
|
|
6581
|
+
latexTrigger: ["\\tiny"],
|
|
6319
6582
|
parse: () => ["Sequence"]
|
|
6320
6583
|
},
|
|
6321
6584
|
{
|
|
6322
|
-
|
|
6585
|
+
latexTrigger: ["\\scriptsize"],
|
|
6323
6586
|
parse: () => ["Sequence"]
|
|
6324
6587
|
},
|
|
6325
6588
|
{
|
|
6326
|
-
|
|
6589
|
+
latexTrigger: ["\\footnotesize"],
|
|
6327
6590
|
parse: () => ["Sequence"]
|
|
6328
6591
|
},
|
|
6329
6592
|
{
|
|
6330
|
-
|
|
6593
|
+
latexTrigger: ["\\small"],
|
|
6331
6594
|
parse: () => ["Sequence"]
|
|
6332
6595
|
},
|
|
6333
6596
|
{
|
|
6334
|
-
|
|
6597
|
+
latexTrigger: ["\\normalsize"],
|
|
6335
6598
|
parse: () => ["Sequence"]
|
|
6336
6599
|
},
|
|
6337
6600
|
{
|
|
6338
|
-
|
|
6601
|
+
latexTrigger: ["\\large"],
|
|
6339
6602
|
parse: () => ["Sequence"]
|
|
6340
6603
|
},
|
|
6341
6604
|
{
|
|
6342
|
-
|
|
6605
|
+
latexTrigger: ["\\Large"],
|
|
6343
6606
|
parse: () => ["Sequence"]
|
|
6344
6607
|
},
|
|
6345
6608
|
{
|
|
6346
|
-
|
|
6609
|
+
latexTrigger: ["\\LARGE"],
|
|
6347
6610
|
parse: () => ["Sequence"]
|
|
6348
6611
|
},
|
|
6349
6612
|
{
|
|
6350
|
-
|
|
6613
|
+
latexTrigger: ["\\huge"],
|
|
6351
6614
|
parse: () => ["Sequence"]
|
|
6352
6615
|
},
|
|
6353
6616
|
{
|
|
6354
|
-
|
|
6617
|
+
latexTrigger: ["\\Huge"],
|
|
6355
6618
|
parse: () => ["Sequence"]
|
|
6356
6619
|
},
|
|
6357
6620
|
{
|
|
@@ -6393,39 +6656,39 @@ var DEFINITIONS_OTHERS = [
|
|
|
6393
6656
|
}
|
|
6394
6657
|
},
|
|
6395
6658
|
{
|
|
6396
|
-
|
|
6659
|
+
latexTrigger: ["\\!"],
|
|
6397
6660
|
parse: () => ["HorizontalSpacing", -3]
|
|
6398
6661
|
},
|
|
6399
6662
|
{
|
|
6400
|
-
|
|
6663
|
+
latexTrigger: ["\\ "],
|
|
6401
6664
|
parse: () => ["HorizontalSpacing", 6]
|
|
6402
6665
|
},
|
|
6403
6666
|
{
|
|
6404
|
-
|
|
6667
|
+
latexTrigger: ["\\:"],
|
|
6405
6668
|
parse: () => ["HorizontalSpacing", 4]
|
|
6406
6669
|
},
|
|
6407
6670
|
{
|
|
6408
|
-
|
|
6671
|
+
latexTrigger: ["\\enskip"],
|
|
6409
6672
|
parse: () => ["HorizontalSpacing", 9]
|
|
6410
6673
|
},
|
|
6411
6674
|
{
|
|
6412
|
-
|
|
6675
|
+
latexTrigger: ["\\quad"],
|
|
6413
6676
|
parse: () => ["HorizontalSpacing", 18]
|
|
6414
6677
|
},
|
|
6415
6678
|
{
|
|
6416
|
-
|
|
6679
|
+
latexTrigger: ["\\qquad"],
|
|
6417
6680
|
parse: () => ["HorizontalSpacing", 36]
|
|
6418
6681
|
},
|
|
6419
6682
|
{
|
|
6420
|
-
|
|
6683
|
+
latexTrigger: ["\\,"],
|
|
6421
6684
|
parse: () => ["HorizontalSpacing", 3]
|
|
6422
6685
|
},
|
|
6423
6686
|
{
|
|
6424
|
-
|
|
6687
|
+
latexTrigger: ["\\;"],
|
|
6425
6688
|
parse: () => ["HorizontalSpacing", 5]
|
|
6426
6689
|
},
|
|
6427
6690
|
{
|
|
6428
|
-
|
|
6691
|
+
latexTrigger: ["\\enspace"],
|
|
6429
6692
|
parse: () => ["HorizontalSpacing", 9]
|
|
6430
6693
|
},
|
|
6431
6694
|
{
|
|
@@ -6525,146 +6788,146 @@ function parseTrig(op3) {
|
|
|
6525
6788
|
var DEFINITIONS_TRIGONOMETRY = [
|
|
6526
6789
|
{
|
|
6527
6790
|
name: "Arcsin",
|
|
6528
|
-
|
|
6791
|
+
latexTrigger: ["\\arcsin"],
|
|
6529
6792
|
parse: parseTrig("Arcsin")
|
|
6530
6793
|
},
|
|
6531
6794
|
{
|
|
6532
6795
|
name: "Arccos",
|
|
6533
|
-
|
|
6796
|
+
latexTrigger: ["\\arccos"],
|
|
6534
6797
|
parse: parseTrig("Arccos")
|
|
6535
6798
|
},
|
|
6536
6799
|
{
|
|
6537
6800
|
name: "Arctan",
|
|
6538
|
-
|
|
6801
|
+
latexTrigger: ["\\arctan"],
|
|
6539
6802
|
parse: parseTrig("Arctan")
|
|
6540
6803
|
},
|
|
6541
6804
|
{
|
|
6542
|
-
|
|
6805
|
+
latexTrigger: ["\\arctg"],
|
|
6543
6806
|
parse: parseTrig("Arctan")
|
|
6544
6807
|
},
|
|
6545
6808
|
{
|
|
6546
6809
|
name: "Arccot",
|
|
6547
|
-
|
|
6810
|
+
latexTrigger: ["\\arcctg"],
|
|
6548
6811
|
parse: parseTrig("Arccot")
|
|
6549
6812
|
},
|
|
6550
6813
|
{
|
|
6551
6814
|
name: "Arcsec",
|
|
6552
|
-
|
|
6815
|
+
latexTrigger: "arcsec",
|
|
6553
6816
|
parse: parseTrig("Arcsec")
|
|
6554
6817
|
},
|
|
6555
6818
|
{
|
|
6556
6819
|
name: "Arccsc",
|
|
6557
|
-
|
|
6820
|
+
latexTrigger: ["\\arccsc"],
|
|
6558
6821
|
parse: parseTrig("Arccsc")
|
|
6559
6822
|
},
|
|
6560
6823
|
{
|
|
6561
6824
|
name: "Arsinh",
|
|
6562
|
-
|
|
6825
|
+
latexTrigger: ["\\arsinh"],
|
|
6563
6826
|
parse: parseTrig("Arsinh")
|
|
6564
6827
|
},
|
|
6565
6828
|
{
|
|
6566
6829
|
name: "Arcosh",
|
|
6567
|
-
|
|
6830
|
+
latexTrigger: ["\\arcosh"],
|
|
6568
6831
|
parse: parseTrig("Arcosh")
|
|
6569
6832
|
},
|
|
6570
6833
|
{
|
|
6571
6834
|
name: "Artanh",
|
|
6572
|
-
|
|
6835
|
+
latexTrigger: ["\\artanh"],
|
|
6573
6836
|
parse: parseTrig("Artanh")
|
|
6574
6837
|
},
|
|
6575
6838
|
{
|
|
6576
6839
|
name: "Arsech",
|
|
6577
|
-
|
|
6840
|
+
latexTrigger: ["\\arsech"],
|
|
6578
6841
|
parse: parseTrig("Arsech")
|
|
6579
6842
|
},
|
|
6580
6843
|
{
|
|
6581
6844
|
name: "Arcsch",
|
|
6582
|
-
|
|
6845
|
+
latexTrigger: ["\\arcsch"],
|
|
6583
6846
|
parse: parseTrig("Arcsch")
|
|
6584
6847
|
},
|
|
6585
6848
|
{
|
|
6586
6849
|
// Rusian hyperbolic cosine
|
|
6587
|
-
|
|
6850
|
+
latexTrigger: ["\\ch"],
|
|
6588
6851
|
parse: parseTrig("Cosh")
|
|
6589
6852
|
},
|
|
6590
6853
|
{
|
|
6591
6854
|
name: "Cosec",
|
|
6592
|
-
|
|
6855
|
+
latexTrigger: ["\\cosec"],
|
|
6593
6856
|
parse: parseTrig("Cosec")
|
|
6594
6857
|
},
|
|
6595
6858
|
{
|
|
6596
6859
|
name: "Cosh",
|
|
6597
|
-
|
|
6860
|
+
latexTrigger: ["\\cosh"],
|
|
6598
6861
|
parse: parseTrig("Cosh")
|
|
6599
6862
|
},
|
|
6600
6863
|
{
|
|
6601
6864
|
name: "Cot",
|
|
6602
|
-
|
|
6865
|
+
latexTrigger: ["\\cot"],
|
|
6603
6866
|
parse: parseTrig("Cot")
|
|
6604
6867
|
},
|
|
6605
6868
|
{
|
|
6606
|
-
|
|
6869
|
+
latexTrigger: ["\\cotg"],
|
|
6607
6870
|
parse: parseTrig("Cot")
|
|
6608
6871
|
},
|
|
6609
6872
|
{
|
|
6610
6873
|
name: "Coth",
|
|
6611
|
-
|
|
6874
|
+
latexTrigger: ["\\coth"],
|
|
6612
6875
|
parse: parseTrig("Coth")
|
|
6613
6876
|
},
|
|
6614
6877
|
{
|
|
6615
6878
|
name: "Csc",
|
|
6616
|
-
|
|
6879
|
+
latexTrigger: ["\\csc"],
|
|
6617
6880
|
parse: parseTrig("Csc")
|
|
6618
6881
|
},
|
|
6619
6882
|
{
|
|
6620
6883
|
// Rusian cotangent
|
|
6621
|
-
|
|
6884
|
+
latexTrigger: ["\\ctg"],
|
|
6622
6885
|
parse: parseTrig("Cot")
|
|
6623
6886
|
},
|
|
6624
6887
|
{
|
|
6625
|
-
|
|
6888
|
+
latexTrigger: ["\\cth"],
|
|
6626
6889
|
parse: parseTrig("Cotanh")
|
|
6627
6890
|
},
|
|
6628
6891
|
{
|
|
6629
6892
|
name: "Sec",
|
|
6630
|
-
|
|
6893
|
+
latexTrigger: ["\\sec"],
|
|
6631
6894
|
parse: parseTrig("Sec")
|
|
6632
6895
|
},
|
|
6633
6896
|
{
|
|
6634
6897
|
name: "Sinh",
|
|
6635
|
-
|
|
6898
|
+
latexTrigger: ["\\sinh"],
|
|
6636
6899
|
parse: parseTrig("Sinh")
|
|
6637
6900
|
},
|
|
6638
6901
|
{
|
|
6639
|
-
|
|
6902
|
+
latexTrigger: ["\\sh"],
|
|
6640
6903
|
parse: parseTrig("Sinh")
|
|
6641
6904
|
},
|
|
6642
6905
|
{
|
|
6643
6906
|
name: "Tan",
|
|
6644
|
-
|
|
6907
|
+
latexTrigger: ["\\tan"],
|
|
6645
6908
|
parse: parseTrig("Tan")
|
|
6646
6909
|
},
|
|
6647
6910
|
{
|
|
6648
|
-
|
|
6911
|
+
latexTrigger: ["\\tg"],
|
|
6649
6912
|
parse: parseTrig("Tan")
|
|
6650
6913
|
},
|
|
6651
6914
|
{
|
|
6652
6915
|
name: "Tanh",
|
|
6653
|
-
|
|
6916
|
+
latexTrigger: ["\\tanh"],
|
|
6654
6917
|
parse: parseTrig("Tanh")
|
|
6655
6918
|
},
|
|
6656
6919
|
{
|
|
6657
|
-
|
|
6920
|
+
latexTrigger: ["\\th"],
|
|
6658
6921
|
parse: parseTrig("Tanh")
|
|
6659
6922
|
},
|
|
6660
6923
|
{
|
|
6661
6924
|
name: "Cos",
|
|
6662
|
-
|
|
6925
|
+
latexTrigger: ["\\cos"],
|
|
6663
6926
|
parse: parseTrig("Cos")
|
|
6664
6927
|
},
|
|
6665
6928
|
{
|
|
6666
6929
|
name: "Sin",
|
|
6667
|
-
|
|
6930
|
+
latexTrigger: ["\\sin"],
|
|
6668
6931
|
parse: parseTrig("Sin")
|
|
6669
6932
|
}
|
|
6670
6933
|
];
|
|
@@ -6672,77 +6935,77 @@ var DEFINITIONS_TRIGONOMETRY = [
|
|
|
6672
6935
|
// src/compute-engine/latex-syntax/dictionary/definitions-sets.ts
|
|
6673
6936
|
var DEFINITIONS_SETS = [
|
|
6674
6937
|
// Constants
|
|
6675
|
-
{ name: "AlgebraicNumber",
|
|
6676
|
-
{ name: "ComplexNumber",
|
|
6677
|
-
{
|
|
6678
|
-
{ name: "ImaginaryNumber",
|
|
6679
|
-
{ name: "ExtendedComplexNumber",
|
|
6680
|
-
{ name: "EmptySet",
|
|
6681
|
-
{
|
|
6938
|
+
{ name: "AlgebraicNumber", latexTrigger: "\\bar\\Q" },
|
|
6939
|
+
{ name: "ComplexNumber", latexTrigger: ["\\C"] },
|
|
6940
|
+
{ latexTrigger: "\\mathbb{C}", parse: "ComplexNumber" },
|
|
6941
|
+
{ name: "ImaginaryNumber", latexTrigger: ["\\imaginaryI", "\\R"] },
|
|
6942
|
+
{ name: "ExtendedComplexNumber", latexTrigger: ["\\bar", "\\C"] },
|
|
6943
|
+
{ name: "EmptySet", latexTrigger: ["\\emptyset"] },
|
|
6944
|
+
{ latexTrigger: ["\\varnothing"], parse: "EmptySet" },
|
|
6682
6945
|
// Parsing only
|
|
6683
|
-
{ name: "Integer",
|
|
6684
|
-
{
|
|
6685
|
-
{ name: "RationalNumber",
|
|
6686
|
-
{ name: "RealNumber",
|
|
6687
|
-
{
|
|
6688
|
-
{ name: "ExtendedRealNumber",
|
|
6689
|
-
{ name: "TranscendentalNumber",
|
|
6690
|
-
{
|
|
6946
|
+
{ name: "Integer", latexTrigger: ["\\Z"] },
|
|
6947
|
+
{ latexTrigger: "\\mathbb{Z}", parse: "Integer" },
|
|
6948
|
+
{ name: "RationalNumber", latexTrigger: ["\\Q"] },
|
|
6949
|
+
{ name: "RealNumber", latexTrigger: ["\\R"] },
|
|
6950
|
+
{ latexTrigger: "\\mathbb{R}", parse: "RealNumber" },
|
|
6951
|
+
{ name: "ExtendedRealNumber", latexTrigger: ["\\bar", "\\R"] },
|
|
6952
|
+
{ name: "TranscendentalNumber", latexTrigger: "\\R-\\bar\\Q" },
|
|
6953
|
+
{ latexTrigger: "\\R\\backslash\\bar\\Q", parse: "TranscendentalNumber" },
|
|
6691
6954
|
// Real numbers < 0
|
|
6692
|
-
{ name: "NegativeNumber",
|
|
6693
|
-
{
|
|
6694
|
-
{
|
|
6695
|
-
{
|
|
6696
|
-
{
|
|
6955
|
+
{ name: "NegativeNumber", latexTrigger: "\\R^-" },
|
|
6956
|
+
{ latexTrigger: "\\R^{-}", parse: "NegativeNumber" },
|
|
6957
|
+
{ latexTrigger: "\\R_-", parse: "NegativeNumber" },
|
|
6958
|
+
{ latexTrigger: "\\R_{-}", parse: "NegativeNumber" },
|
|
6959
|
+
{ latexTrigger: "\\R^{\\lt}", parse: "NegativeNumber" },
|
|
6697
6960
|
// Real numbers > 0
|
|
6698
|
-
{ name: "PositiveNumber",
|
|
6699
|
-
{
|
|
6700
|
-
{
|
|
6701
|
-
{
|
|
6702
|
-
{
|
|
6961
|
+
{ name: "PositiveNumber", latexTrigger: "\\R^+" },
|
|
6962
|
+
{ latexTrigger: "\\R^{+}", parse: "PositiveNumber" },
|
|
6963
|
+
{ latexTrigger: "\\R_+", parse: "PositiveNumber" },
|
|
6964
|
+
{ latexTrigger: "\\R_{+}", parse: "PositiveNumber" },
|
|
6965
|
+
{ latexTrigger: "\\R^{\\gt}", parse: "PositiveNumber" },
|
|
6703
6966
|
// Real numbers <= 0
|
|
6704
|
-
{ name: "NonPositiveNumber",
|
|
6705
|
-
{
|
|
6706
|
-
{
|
|
6967
|
+
{ name: "NonPositiveNumber", latexTrigger: "\\R^{0-}" },
|
|
6968
|
+
{ latexTrigger: "\\R^{-0}", parse: "NonPositiveNumber" },
|
|
6969
|
+
{ latexTrigger: "\\R^{\\leq}", parse: "NonPositiveNumber" },
|
|
6707
6970
|
// Integers < 0
|
|
6708
|
-
{ name: "NegativeInteger",
|
|
6709
|
-
{
|
|
6710
|
-
{
|
|
6711
|
-
{
|
|
6712
|
-
{
|
|
6713
|
-
{
|
|
6971
|
+
{ name: "NegativeInteger", latexTrigger: "\\Z^-" },
|
|
6972
|
+
{ latexTrigger: "\\Z^-", parse: "NegativeInteger" },
|
|
6973
|
+
{ latexTrigger: "\\Z^{-}", parse: "NegativeInteger" },
|
|
6974
|
+
{ latexTrigger: "\\Z_-", parse: "NegativeInteger" },
|
|
6975
|
+
{ latexTrigger: "\\Z_{-}", parse: "NegativeInteger" },
|
|
6976
|
+
{ latexTrigger: "\\Z^{\\lt}", parse: "NegativeInteger" },
|
|
6714
6977
|
// Integers > 0
|
|
6715
|
-
{ name: "PositiveInteger",
|
|
6716
|
-
{
|
|
6717
|
-
{
|
|
6718
|
-
{
|
|
6719
|
-
{
|
|
6720
|
-
{
|
|
6721
|
-
{
|
|
6722
|
-
{
|
|
6723
|
-
{
|
|
6724
|
-
{
|
|
6725
|
-
{
|
|
6726
|
-
{
|
|
6727
|
-
{
|
|
6728
|
-
{
|
|
6978
|
+
{ name: "PositiveInteger", latexTrigger: "\\Z^+" },
|
|
6979
|
+
{ latexTrigger: "\\Z^{+}", parse: "PositiveInteger" },
|
|
6980
|
+
{ latexTrigger: "\\Z_+", parse: "PositiveInteger" },
|
|
6981
|
+
{ latexTrigger: "\\Z_{+}", parse: "PositiveInteger" },
|
|
6982
|
+
{ latexTrigger: "\\Z^{\\gt}", parse: "PositiveInteger" },
|
|
6983
|
+
{ latexTrigger: "\\Z^{\\gt0}", parse: "PositiveInteger" },
|
|
6984
|
+
{ latexTrigger: "\\N^+", parse: "PositiveInteger" },
|
|
6985
|
+
{ latexTrigger: "\\N^{+}", parse: "PositiveInteger" },
|
|
6986
|
+
{ latexTrigger: "\\N^*", parse: "PositiveInteger" },
|
|
6987
|
+
{ latexTrigger: "\\N^{*}", parse: "PositiveInteger" },
|
|
6988
|
+
{ latexTrigger: "\\N^\\star", parse: "PositiveInteger" },
|
|
6989
|
+
{ latexTrigger: "\\N^{\\star}", parse: "PositiveInteger" },
|
|
6990
|
+
{ latexTrigger: "\\N_1", parse: "PositiveInteger" },
|
|
6991
|
+
{ latexTrigger: "\\N_{1}", parse: "PositiveInteger" },
|
|
6729
6992
|
// https://mathvault.ca/hub/higher-math/math-symbols/algebra-symbols/
|
|
6730
6993
|
// Integers >= 0
|
|
6731
|
-
{ name: "NonNegativeInteger",
|
|
6732
|
-
{
|
|
6733
|
-
{
|
|
6734
|
-
{
|
|
6735
|
-
{
|
|
6736
|
-
{
|
|
6737
|
-
{
|
|
6738
|
-
{
|
|
6994
|
+
{ name: "NonNegativeInteger", latexTrigger: ["\\N"] },
|
|
6995
|
+
{ latexTrigger: "\\Z^{+0}", parse: "NonNegativeInteger" },
|
|
6996
|
+
{ latexTrigger: "\\Z^{\\geq}", parse: "NonNegativeInteger" },
|
|
6997
|
+
{ latexTrigger: "\\Z^{\\geq0}", parse: "NonNegativeInteger" },
|
|
6998
|
+
{ latexTrigger: "\\Z^{0+}", parse: "NonNegativeInteger" },
|
|
6999
|
+
{ latexTrigger: "\\mathbb{N}", parse: "NonNegativeInteger" },
|
|
7000
|
+
{ latexTrigger: "\\N_0", parse: "NonNegativeInteger" },
|
|
7001
|
+
{ latexTrigger: "\\N_{0}", parse: "NonNegativeInteger" },
|
|
6739
7002
|
//
|
|
6740
7003
|
// Set Expressions
|
|
6741
7004
|
//
|
|
6742
7005
|
// @todo: could also have a `CartesianPower` function with a number `rhs`
|
|
6743
7006
|
{
|
|
6744
7007
|
name: "CartesianProduct",
|
|
6745
|
-
|
|
7008
|
+
latexTrigger: ["\\times"],
|
|
6746
7009
|
kind: "infix",
|
|
6747
7010
|
associativity: "right",
|
|
6748
7011
|
// Caution: cartesian product is not associative
|
|
@@ -6764,7 +7027,7 @@ var DEFINITIONS_SETS = [
|
|
|
6764
7027
|
}
|
|
6765
7028
|
},
|
|
6766
7029
|
{
|
|
6767
|
-
|
|
7030
|
+
latexTrigger: ["^", "\\complement"],
|
|
6768
7031
|
kind: "postfix",
|
|
6769
7032
|
parse: (_parser, lhs) => {
|
|
6770
7033
|
return ["Complement", lhs];
|
|
@@ -6774,14 +7037,14 @@ var DEFINITIONS_SETS = [
|
|
|
6774
7037
|
},
|
|
6775
7038
|
{
|
|
6776
7039
|
name: "Complement",
|
|
6777
|
-
|
|
7040
|
+
latexTrigger: ["^", "<{>", "\\complement", "<}>"],
|
|
6778
7041
|
kind: "postfix"
|
|
6779
7042
|
// precedence: 240,
|
|
6780
7043
|
// @todo: serialize for the multiple argument case
|
|
6781
7044
|
},
|
|
6782
7045
|
{
|
|
6783
7046
|
name: "Intersection",
|
|
6784
|
-
|
|
7047
|
+
latexTrigger: ["\\cap"],
|
|
6785
7048
|
kind: "infix",
|
|
6786
7049
|
precedence: 350
|
|
6787
7050
|
},
|
|
@@ -6797,7 +7060,7 @@ var DEFINITIONS_SETS = [
|
|
|
6797
7060
|
},
|
|
6798
7061
|
{
|
|
6799
7062
|
name: "Union",
|
|
6800
|
-
|
|
7063
|
+
latexTrigger: ["\\cup"],
|
|
6801
7064
|
kind: "infix",
|
|
6802
7065
|
precedence: 350
|
|
6803
7066
|
},
|
|
@@ -6816,13 +7079,13 @@ var DEFINITIONS_SETS = [
|
|
|
6816
7079
|
// },
|
|
6817
7080
|
{
|
|
6818
7081
|
name: "SetMinus",
|
|
6819
|
-
|
|
7082
|
+
latexTrigger: ["\\setminus"],
|
|
6820
7083
|
kind: "infix",
|
|
6821
7084
|
precedence: 650
|
|
6822
7085
|
},
|
|
6823
7086
|
{
|
|
6824
7087
|
name: "SymmetricDifference",
|
|
6825
|
-
|
|
7088
|
+
latexTrigger: ["\\triangle"],
|
|
6826
7089
|
// or \\ominus
|
|
6827
7090
|
kind: "infix",
|
|
6828
7091
|
// @todo: parser could check that lhs and rhs are sets
|
|
@@ -6830,7 +7093,7 @@ var DEFINITIONS_SETS = [
|
|
|
6830
7093
|
},
|
|
6831
7094
|
// Predicates/Relations
|
|
6832
7095
|
{
|
|
6833
|
-
|
|
7096
|
+
latexTrigger: ["\\ni"],
|
|
6834
7097
|
kind: "infix",
|
|
6835
7098
|
associativity: "right",
|
|
6836
7099
|
precedence: 160,
|
|
@@ -6842,40 +7105,40 @@ var DEFINITIONS_SETS = [
|
|
|
6842
7105
|
},
|
|
6843
7106
|
{
|
|
6844
7107
|
name: "Element",
|
|
6845
|
-
|
|
7108
|
+
latexTrigger: ["\\in"],
|
|
6846
7109
|
kind: "infix",
|
|
6847
7110
|
precedence: 240
|
|
6848
7111
|
},
|
|
6849
7112
|
{
|
|
6850
7113
|
name: "NotElement",
|
|
6851
|
-
|
|
7114
|
+
latexTrigger: ["\\notin"],
|
|
6852
7115
|
kind: "infix",
|
|
6853
7116
|
precedence: 240
|
|
6854
7117
|
},
|
|
6855
7118
|
{
|
|
6856
7119
|
name: "NotSubset",
|
|
6857
|
-
|
|
7120
|
+
latexTrigger: ["\\nsubset"],
|
|
6858
7121
|
kind: "infix",
|
|
6859
7122
|
associativity: "right",
|
|
6860
7123
|
precedence: 240
|
|
6861
7124
|
},
|
|
6862
7125
|
{
|
|
6863
7126
|
name: "NotSuperset",
|
|
6864
|
-
|
|
7127
|
+
latexTrigger: ["\\nsupset"],
|
|
6865
7128
|
kind: "infix",
|
|
6866
7129
|
associativity: "right",
|
|
6867
7130
|
precedence: 240
|
|
6868
7131
|
},
|
|
6869
7132
|
{
|
|
6870
7133
|
name: "NotSubsetNotEqual",
|
|
6871
|
-
|
|
7134
|
+
latexTrigger: ["\\nsubseteq"],
|
|
6872
7135
|
kind: "infix",
|
|
6873
7136
|
associativity: "right",
|
|
6874
7137
|
precedence: 240
|
|
6875
7138
|
},
|
|
6876
7139
|
{
|
|
6877
7140
|
name: "NotSupersetNotEqual",
|
|
6878
|
-
|
|
7141
|
+
latexTrigger: ["\\nsupseteq"],
|
|
6879
7142
|
kind: "infix",
|
|
6880
7143
|
associativity: "right",
|
|
6881
7144
|
precedence: 240
|
|
@@ -6883,7 +7146,7 @@ var DEFINITIONS_SETS = [
|
|
|
6883
7146
|
{
|
|
6884
7147
|
name: "SquareSubset",
|
|
6885
7148
|
// MathML: square image of
|
|
6886
|
-
|
|
7149
|
+
latexTrigger: ["\\sqsubset"],
|
|
6887
7150
|
kind: "infix",
|
|
6888
7151
|
associativity: "right",
|
|
6889
7152
|
precedence: 265
|
|
@@ -6891,7 +7154,7 @@ var DEFINITIONS_SETS = [
|
|
|
6891
7154
|
{
|
|
6892
7155
|
name: "SquareSubsetEqual",
|
|
6893
7156
|
// MathML: square image of or equal to
|
|
6894
|
-
|
|
7157
|
+
latexTrigger: ["\\sqsubseteq"],
|
|
6895
7158
|
kind: "infix",
|
|
6896
7159
|
associativity: "right",
|
|
6897
7160
|
precedence: 265
|
|
@@ -6899,7 +7162,7 @@ var DEFINITIONS_SETS = [
|
|
|
6899
7162
|
{
|
|
6900
7163
|
name: "SquareSuperset",
|
|
6901
7164
|
// MathML: square original of
|
|
6902
|
-
|
|
7165
|
+
latexTrigger: ["\\sqsupset"],
|
|
6903
7166
|
kind: "infix",
|
|
6904
7167
|
associativity: "right",
|
|
6905
7168
|
precedence: 265
|
|
@@ -6907,27 +7170,27 @@ var DEFINITIONS_SETS = [
|
|
|
6907
7170
|
{
|
|
6908
7171
|
name: "SquareSupersetEqual",
|
|
6909
7172
|
// MathML: square original of or equal
|
|
6910
|
-
|
|
7173
|
+
latexTrigger: ["\\sqsupseteq"],
|
|
6911
7174
|
kind: "infix",
|
|
6912
7175
|
associativity: "right",
|
|
6913
7176
|
precedence: 265
|
|
6914
7177
|
},
|
|
6915
7178
|
{
|
|
6916
7179
|
name: "Subset",
|
|
6917
|
-
|
|
7180
|
+
latexTrigger: ["\\subset"],
|
|
6918
7181
|
kind: "infix",
|
|
6919
7182
|
associativity: "right",
|
|
6920
7183
|
precedence: 240
|
|
6921
7184
|
},
|
|
6922
7185
|
{
|
|
6923
|
-
|
|
7186
|
+
latexTrigger: ["\\subsetneq"],
|
|
6924
7187
|
kind: "infix",
|
|
6925
7188
|
associativity: "right",
|
|
6926
7189
|
precedence: 240,
|
|
6927
7190
|
parse: "Subset"
|
|
6928
7191
|
},
|
|
6929
7192
|
{
|
|
6930
|
-
|
|
7193
|
+
latexTrigger: ["\\varsubsetneqq"],
|
|
6931
7194
|
kind: "infix",
|
|
6932
7195
|
associativity: "right",
|
|
6933
7196
|
precedence: 240,
|
|
@@ -6935,26 +7198,26 @@ var DEFINITIONS_SETS = [
|
|
|
6935
7198
|
},
|
|
6936
7199
|
{
|
|
6937
7200
|
name: "SubsetEqual",
|
|
6938
|
-
|
|
7201
|
+
latexTrigger: ["\\subseteq"],
|
|
6939
7202
|
kind: "infix",
|
|
6940
7203
|
precedence: 240
|
|
6941
7204
|
},
|
|
6942
7205
|
{
|
|
6943
7206
|
name: "Superset",
|
|
6944
|
-
|
|
7207
|
+
latexTrigger: ["\\supset"],
|
|
6945
7208
|
kind: "infix",
|
|
6946
7209
|
associativity: "right",
|
|
6947
7210
|
precedence: 240
|
|
6948
7211
|
},
|
|
6949
7212
|
{
|
|
6950
|
-
|
|
7213
|
+
latexTrigger: ["\\supsetneq"],
|
|
6951
7214
|
kind: "infix",
|
|
6952
7215
|
associativity: "right",
|
|
6953
7216
|
precedence: 240,
|
|
6954
7217
|
parse: "Superset"
|
|
6955
7218
|
},
|
|
6956
7219
|
{
|
|
6957
|
-
|
|
7220
|
+
latexTrigger: ["\\varsupsetneq"],
|
|
6958
7221
|
kind: "infix",
|
|
6959
7222
|
associativity: "right",
|
|
6960
7223
|
precedence: 240,
|
|
@@ -6962,7 +7225,7 @@ var DEFINITIONS_SETS = [
|
|
|
6962
7225
|
},
|
|
6963
7226
|
{
|
|
6964
7227
|
name: "SupersetEqual",
|
|
6965
|
-
|
|
7228
|
+
latexTrigger: ["\\supseteq"],
|
|
6966
7229
|
kind: "infix",
|
|
6967
7230
|
associativity: "right",
|
|
6968
7231
|
precedence: 240
|
|
@@ -7125,6 +7388,8 @@ function parseIntegralBody(parser, n = 1) {
|
|
|
7125
7388
|
condition: () => {
|
|
7126
7389
|
if (parser.matchAll(["\\mathrm", "<{>", "d", "<}>"]))
|
|
7127
7390
|
found = true;
|
|
7391
|
+
else if (parser.matchAll(["\\operatorname", "<{>", "d", "<}>"]))
|
|
7392
|
+
found = true;
|
|
7128
7393
|
return found;
|
|
7129
7394
|
}
|
|
7130
7395
|
});
|
|
@@ -7242,7 +7507,7 @@ function serializeIntegral(command) {
|
|
|
7242
7507
|
command,
|
|
7243
7508
|
"\\!",
|
|
7244
7509
|
serializer.serialize(fn),
|
|
7245
|
-
"\\,\\
|
|
7510
|
+
"\\,\\operatorname{d}",
|
|
7246
7511
|
serializer.serialize(index)
|
|
7247
7512
|
]);
|
|
7248
7513
|
}
|
|
@@ -7260,7 +7525,7 @@ function serializeIntegral(command) {
|
|
|
7260
7525
|
sub2,
|
|
7261
7526
|
"\\!",
|
|
7262
7527
|
serializer.serialize(fn),
|
|
7263
|
-
...index && symbol(index) !== "Nothing" ? ["\\,\\
|
|
7528
|
+
...index && symbol(index) !== "Nothing" ? ["\\,\\operatorname{d}", serializer.serialize(index)] : []
|
|
7264
7529
|
]);
|
|
7265
7530
|
};
|
|
7266
7531
|
}
|
|
@@ -7268,35 +7533,35 @@ var DEFINITIONS_CALCULUS = [
|
|
|
7268
7533
|
{
|
|
7269
7534
|
kind: "expression",
|
|
7270
7535
|
name: "Integrate",
|
|
7271
|
-
|
|
7536
|
+
latexTrigger: ["\\int"],
|
|
7272
7537
|
parse: parseIntegral("Integrate"),
|
|
7273
7538
|
serialize: serializeIntegral("\\int")
|
|
7274
7539
|
},
|
|
7275
7540
|
{
|
|
7276
7541
|
kind: "expression",
|
|
7277
|
-
|
|
7542
|
+
latexTrigger: ["\\iint"],
|
|
7278
7543
|
parse: parseIntegral("Integrate", 2)
|
|
7279
7544
|
},
|
|
7280
7545
|
{
|
|
7281
7546
|
kind: "expression",
|
|
7282
|
-
|
|
7547
|
+
latexTrigger: ["\\iiint"],
|
|
7283
7548
|
parse: parseIntegral("Integrate", 3)
|
|
7284
7549
|
},
|
|
7285
7550
|
{
|
|
7286
7551
|
kind: "expression",
|
|
7287
7552
|
name: "CircularIntegrate",
|
|
7288
|
-
|
|
7553
|
+
latexTrigger: ["\\oint"],
|
|
7289
7554
|
parse: parseIntegral("CircularIntegrate"),
|
|
7290
7555
|
serialize: serializeIntegral("\\oint")
|
|
7291
7556
|
},
|
|
7292
7557
|
{
|
|
7293
7558
|
kind: "expression",
|
|
7294
|
-
|
|
7559
|
+
latexTrigger: ["\\oiint"],
|
|
7295
7560
|
parse: parseIntegral("CircularIntegrate", 2)
|
|
7296
7561
|
},
|
|
7297
7562
|
{
|
|
7298
7563
|
kind: "expression",
|
|
7299
|
-
|
|
7564
|
+
latexTrigger: ["\\oiiint"],
|
|
7300
7565
|
parse: parseIntegral("CircularIntegrate", 3)
|
|
7301
7566
|
}
|
|
7302
7567
|
];
|
|
@@ -7403,14 +7668,14 @@ var DEFINITIONS_SYMBOLS = [
|
|
|
7403
7668
|
return {
|
|
7404
7669
|
kind: "symbol",
|
|
7405
7670
|
name: symbol2,
|
|
7406
|
-
|
|
7671
|
+
latexTrigger: [latex],
|
|
7407
7672
|
parse: symbol2
|
|
7408
7673
|
};
|
|
7409
7674
|
}),
|
|
7410
7675
|
...SYMBOLS.map(([symbol2, _latex, codepoint]) => {
|
|
7411
7676
|
return {
|
|
7412
7677
|
kind: "symbol",
|
|
7413
|
-
|
|
7678
|
+
latexTrigger: [String.fromCodePoint(codepoint)],
|
|
7414
7679
|
parse: symbol2
|
|
7415
7680
|
};
|
|
7416
7681
|
})
|
|
@@ -7434,294 +7699,349 @@ var DEFAULT_DELIMITER = {
|
|
|
7434
7699
|
"\\rfloor": "\\rfloor"
|
|
7435
7700
|
};
|
|
7436
7701
|
function addEntry(result, entry, onError) {
|
|
7437
|
-
const
|
|
7702
|
+
const indexedEntry = makeIndexedEntry(entry, onError);
|
|
7438
7703
|
if (indexedEntry === null)
|
|
7439
7704
|
return;
|
|
7440
7705
|
const kind = "kind" in entry ? entry.kind : "expression";
|
|
7441
|
-
|
|
7706
|
+
const latexTrigger = indexedEntry.latexTrigger;
|
|
7707
|
+
if (typeof latexTrigger === "string")
|
|
7708
|
+
result.lookahead = Math.max(result.lookahead, countTokens(latexTrigger));
|
|
7709
|
+
const tokensTrigger = tokenize(latexTrigger ?? "", []);
|
|
7710
|
+
if (latexTrigger?.[1] === "\\prime")
|
|
7711
|
+
debugger;
|
|
7712
|
+
if (tokensTrigger.length === 2 && /[_^]/.test(tokensTrigger[0]) && tokensTrigger[1] !== "<{>" && kind !== "function" && kind !== "environment" && kind !== "matchfix") {
|
|
7442
7713
|
let parse = entry.parse;
|
|
7443
|
-
if (parse
|
|
7444
|
-
if (kind === "symbol")
|
|
7445
|
-
parse = entry.name;
|
|
7714
|
+
if (!parse && entry.name) {
|
|
7446
7715
|
if (kind === "postfix" || kind === "prefix")
|
|
7447
7716
|
parse = (_parser, expr) => [entry.name, expr];
|
|
7717
|
+
else
|
|
7718
|
+
parse = entry.name;
|
|
7448
7719
|
}
|
|
7449
7720
|
addEntry(
|
|
7450
7721
|
result,
|
|
7451
7722
|
{
|
|
7452
7723
|
...entry,
|
|
7453
7724
|
kind,
|
|
7454
|
-
parse,
|
|
7455
7725
|
name: void 0,
|
|
7456
|
-
|
|
7726
|
+
serialize: void 0,
|
|
7727
|
+
parse,
|
|
7728
|
+
latexTrigger: [tokensTrigger[0], "<{>", tokensTrigger[1], "<}>"]
|
|
7457
7729
|
},
|
|
7458
7730
|
onError
|
|
7459
7731
|
);
|
|
7460
7732
|
}
|
|
7733
|
+
result.defs.push(indexedEntry);
|
|
7461
7734
|
if (indexedEntry.name !== void 0) {
|
|
7462
|
-
if (result.
|
|
7735
|
+
if (result.ids.has(indexedEntry.name)) {
|
|
7463
7736
|
onError({
|
|
7464
7737
|
severity: "warning",
|
|
7465
7738
|
message: [
|
|
7466
7739
|
"invalid-dictionary-entry",
|
|
7467
7740
|
indexedEntry.name,
|
|
7468
|
-
"Duplicate definition. The name must be unique, but
|
|
7469
|
-
]
|
|
7470
|
-
});
|
|
7471
|
-
}
|
|
7472
|
-
result.name.set(indexedEntry.name, indexedEntry);
|
|
7473
|
-
}
|
|
7474
|
-
if (indexedEntry.kind === "matchfix") {
|
|
7475
|
-
result.matchfix.push(indexedEntry);
|
|
7476
|
-
} else if (indexedEntry.kind === "environment") {
|
|
7477
|
-
const triggerString = tokensToString(entry.trigger ?? []);
|
|
7478
|
-
if (result.environment.has(triggerString)) {
|
|
7479
|
-
onError({
|
|
7480
|
-
severity: "warning",
|
|
7481
|
-
message: [
|
|
7482
|
-
"invalid-dictionary-entry",
|
|
7483
|
-
triggerString,
|
|
7484
|
-
"Duplicate environment definition"
|
|
7741
|
+
"Duplicate definition. The name (MathJSON identifier) must be unique, but triggers can be shared by multiple definitions."
|
|
7485
7742
|
]
|
|
7486
7743
|
});
|
|
7487
7744
|
}
|
|
7488
|
-
result.
|
|
7489
|
-
} else if (trigger) {
|
|
7490
|
-
console.assert(entry.trigger);
|
|
7491
|
-
if (indexedEntry.kind === "function") {
|
|
7492
|
-
console.assert(typeof entry.trigger === "string");
|
|
7493
|
-
const fnName = entry.trigger;
|
|
7494
|
-
if (!result.function.has(fnName))
|
|
7495
|
-
result.function.set(fnName, [indexedEntry]);
|
|
7496
|
-
else
|
|
7497
|
-
result.function.set(fnName, [
|
|
7498
|
-
...result.function.get(fnName),
|
|
7499
|
-
indexedEntry
|
|
7500
|
-
]);
|
|
7501
|
-
} else {
|
|
7502
|
-
let triggerString;
|
|
7503
|
-
let tokenCount;
|
|
7504
|
-
if (typeof entry.trigger === "string") {
|
|
7505
|
-
triggerString = entry.trigger;
|
|
7506
|
-
tokenCount = countTokens(triggerString);
|
|
7507
|
-
} else {
|
|
7508
|
-
triggerString = tokensToString(entry.trigger ?? []);
|
|
7509
|
-
tokenCount = entry.trigger.length;
|
|
7510
|
-
}
|
|
7511
|
-
result.lookahead = Math.max(result.lookahead, tokenCount);
|
|
7512
|
-
const kind2 = indexedEntry.kind;
|
|
7513
|
-
if (result[kind2][tokenCount] === void 0)
|
|
7514
|
-
result[kind2][tokenCount] = /* @__PURE__ */ new Map();
|
|
7515
|
-
const list = result[kind2][tokenCount];
|
|
7516
|
-
if (list.has(triggerString))
|
|
7517
|
-
list.get(triggerString).push(indexedEntry);
|
|
7518
|
-
else
|
|
7519
|
-
list.set(triggerString, [indexedEntry]);
|
|
7520
|
-
}
|
|
7745
|
+
result.ids.set(indexedEntry.name, indexedEntry);
|
|
7521
7746
|
}
|
|
7522
7747
|
}
|
|
7523
7748
|
function indexLatexDictionary(dic, onError) {
|
|
7524
7749
|
const result = {
|
|
7525
7750
|
lookahead: 1,
|
|
7526
|
-
|
|
7527
|
-
|
|
7528
|
-
symbol: [],
|
|
7529
|
-
infix: [],
|
|
7530
|
-
prefix: [],
|
|
7531
|
-
postfix: [],
|
|
7532
|
-
function: /* @__PURE__ */ new Map(),
|
|
7533
|
-
environment: /* @__PURE__ */ new Map(),
|
|
7534
|
-
matchfix: []
|
|
7751
|
+
ids: /* @__PURE__ */ new Map(),
|
|
7752
|
+
defs: []
|
|
7535
7753
|
};
|
|
7536
7754
|
for (const entry of dic)
|
|
7537
7755
|
addEntry(result, entry, onError);
|
|
7538
7756
|
return result;
|
|
7539
7757
|
}
|
|
7540
7758
|
function makeIndexedEntry(entry, onError) {
|
|
7541
|
-
if (!
|
|
7542
|
-
return
|
|
7759
|
+
if (!isValidEntry(entry, onError))
|
|
7760
|
+
return null;
|
|
7543
7761
|
const result = {
|
|
7544
|
-
name: entry.name,
|
|
7545
7762
|
kind: "kind" in entry ? entry.kind : "expression"
|
|
7546
7763
|
};
|
|
7764
|
+
let tokensTrigger = null;
|
|
7765
|
+
if ("latexTrigger" in entry) {
|
|
7766
|
+
if (typeof entry.latexTrigger === "string")
|
|
7767
|
+
tokensTrigger = tokenize(entry.latexTrigger, []);
|
|
7768
|
+
else
|
|
7769
|
+
tokensTrigger = entry.latexTrigger;
|
|
7770
|
+
}
|
|
7771
|
+
let idTrigger = null;
|
|
7772
|
+
if ("identifierTrigger" in entry) {
|
|
7773
|
+
idTrigger = entry.identifierTrigger;
|
|
7774
|
+
}
|
|
7775
|
+
if (tokensTrigger !== null)
|
|
7776
|
+
result.latexTrigger = tokensToString(tokensTrigger);
|
|
7777
|
+
if (idTrigger !== null)
|
|
7778
|
+
result.identifierTrigger = idTrigger;
|
|
7779
|
+
if (entry.name) {
|
|
7780
|
+
result.name = entry.name;
|
|
7781
|
+
result.serialize = makeSerializeHandler(entry, tokensTrigger, idTrigger);
|
|
7782
|
+
}
|
|
7547
7783
|
if (result.kind === "matchfix" && isMatchfixEntry(entry)) {
|
|
7548
|
-
result.openDelimiter = entry.
|
|
7549
|
-
result.closeDelimiter = entry.
|
|
7550
|
-
if (typeof entry.serialize === "function")
|
|
7551
|
-
result.serialize = entry.serialize;
|
|
7552
|
-
else {
|
|
7553
|
-
const openDelim = typeof result.openDelimiter === "string" ? DEFAULT_DELIMITER[result.openDelimiter] : tokensToString(result.openDelimiter);
|
|
7554
|
-
const closeDelim = typeof result.closeDelimiter === "string" ? DEFAULT_DELIMITER[result.closeDelimiter] : tokensToString(result.closeDelimiter);
|
|
7555
|
-
result.serialize = (serializer, expr) => joinLatex([openDelim, serializer.serialize(op(expr, 1)), closeDelim]);
|
|
7556
|
-
}
|
|
7557
|
-
if (typeof entry.parse === "function")
|
|
7558
|
-
result.parse = entry.parse;
|
|
7559
|
-
else {
|
|
7560
|
-
console.assert(entry.parse || entry.name);
|
|
7561
|
-
const head2 = entry.parse ?? entry.name;
|
|
7562
|
-
result.parse = (_parser, expr) => [head2, expr];
|
|
7563
|
-
}
|
|
7564
|
-
return [null, result];
|
|
7565
|
-
}
|
|
7566
|
-
if (result.kind === "environment" && isEnvironmentEntry(entry)) {
|
|
7567
|
-
const envName = entry.trigger;
|
|
7568
|
-
result.serialize = entry.serialize ?? ((serializer, expr) => `\\begin{${envName}}${serializer.serialize(
|
|
7569
|
-
op(expr, 1)
|
|
7570
|
-
)}\\end{${envName}}`);
|
|
7571
|
-
result.parse = entry.parse ?? (() => null);
|
|
7572
|
-
return [envName, result];
|
|
7573
|
-
}
|
|
7574
|
-
const trigger = typeof entry.trigger === "string" ? tokenize(entry.trigger, []) : entry.trigger;
|
|
7575
|
-
const triggerString = trigger ? tokensToString(trigger) : "";
|
|
7576
|
-
if (result.kind === "function" && isFunctionEntry(entry)) {
|
|
7577
|
-
result.serialize = entry.serialize;
|
|
7578
|
-
if (triggerString && !entry.serialize) {
|
|
7579
|
-
if (triggerString.startsWith("\\")) {
|
|
7580
|
-
result.serialize = (serializer, expr) => `${triggerString}${serializer.wrapArguments(expr)}`;
|
|
7581
|
-
} else
|
|
7582
|
-
result.serialize = (serializer, expr) => `\\mathrm{${triggerString}}${serializer.wrapArguments(expr)}`;
|
|
7583
|
-
}
|
|
7584
|
-
if (typeof entry.parse === "function")
|
|
7585
|
-
result.parse = entry.parse;
|
|
7586
|
-
else if (typeof entry.parse === "string")
|
|
7587
|
-
result.parse = () => entry.parse;
|
|
7588
|
-
else if (entry.name)
|
|
7589
|
-
result.parse = () => entry.name;
|
|
7590
|
-
return [triggerString, result];
|
|
7591
|
-
}
|
|
7592
|
-
if (result.kind === "expression" && isExpressionEntry(entry)) {
|
|
7593
|
-
result.serialize = entry.serialize ?? triggerString;
|
|
7594
|
-
if (typeof result.serialize === "string") {
|
|
7595
|
-
const serializeStr = result.serialize;
|
|
7596
|
-
result.serialize = (serializer, expr) => {
|
|
7597
|
-
if (!head(expr))
|
|
7598
|
-
return serializeStr;
|
|
7599
|
-
return `${serializeStr}${serializer.wrapArguments(expr)}`;
|
|
7600
|
-
};
|
|
7601
|
-
}
|
|
7602
|
-
{
|
|
7603
|
-
if (typeof entry.parse === "function") {
|
|
7604
|
-
result.parse = entry.parse;
|
|
7605
|
-
} else {
|
|
7606
|
-
const parseResult = entry.parse ?? entry.name;
|
|
7607
|
-
result.parse = () => parseResult;
|
|
7608
|
-
}
|
|
7609
|
-
}
|
|
7610
|
-
return [triggerString, result];
|
|
7784
|
+
result.openDelimiter = entry.openTrigger;
|
|
7785
|
+
result.closeDelimiter = entry.closeTrigger;
|
|
7611
7786
|
}
|
|
7612
|
-
console.assert(
|
|
7613
|
-
typeof entry.trigger !== "string" || entry.parse || trigger.length > 1 || "kind" in entry && entry.kind === "function",
|
|
7614
|
-
`Trigger shortcuts should produce more than one token. Otherwise, not worth using them. (${triggerString})`
|
|
7615
|
-
);
|
|
7616
7787
|
if (result.kind === "symbol" && isSymbolEntry(entry)) {
|
|
7617
7788
|
result.precedence = entry.precedence ?? 1e4;
|
|
7618
7789
|
}
|
|
7619
|
-
if ((result.kind === "
|
|
7620
|
-
if (
|
|
7790
|
+
if ((result.kind === "prefix" || result.kind === "postfix") && (isPrefixEntry(entry) || isPostfixEntry(entry))) {
|
|
7791
|
+
if (tokensTrigger && (tokensTrigger[0] === "^" || tokensTrigger[0] === "_")) {
|
|
7621
7792
|
result.precedence = 720;
|
|
7622
7793
|
console.assert(
|
|
7623
7794
|
entry.precedence === void 0,
|
|
7624
|
-
"'precedence'
|
|
7795
|
+
"'precedence' is fixed and cannot be modified with ^ and _ triggers"
|
|
7625
7796
|
);
|
|
7626
7797
|
} else
|
|
7627
7798
|
result.precedence = entry.precedence ?? 1e4;
|
|
7628
7799
|
}
|
|
7629
7800
|
if (result.kind === "infix" && isInfixEntry(entry)) {
|
|
7630
7801
|
console.assert(
|
|
7631
|
-
!
|
|
7802
|
+
!tokensTrigger || tokensTrigger[0] !== "^" && tokensTrigger[0] !== "_" || !entry.associativity || entry.associativity === "non"
|
|
7632
7803
|
);
|
|
7633
7804
|
result.associativity = entry.associativity ?? "non";
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7805
|
+
result.precedence = entry.precedence ?? 1e4;
|
|
7806
|
+
}
|
|
7807
|
+
const parse = makeParseHandler(entry, tokensTrigger, idTrigger);
|
|
7808
|
+
if (parse)
|
|
7809
|
+
result.parse = parse;
|
|
7810
|
+
return result;
|
|
7811
|
+
}
|
|
7812
|
+
function makeSerializeHandler(entry, latexTrigger, idTrigger) {
|
|
7813
|
+
if (typeof entry.serialize === "function")
|
|
7814
|
+
return entry.serialize;
|
|
7815
|
+
const kind = entry["kind"] ?? "expression";
|
|
7816
|
+
if (kind === "environment") {
|
|
7817
|
+
const envName = entry["identifierTrigger"] ?? entry.name ?? "unknown";
|
|
7818
|
+
return (serializer, expr) => joinLatex([
|
|
7819
|
+
`\\begin{${envName}}`,
|
|
7820
|
+
serializer.serialize(op(expr, 1)),
|
|
7821
|
+
`\\end{${envName}}`
|
|
7822
|
+
]);
|
|
7823
|
+
}
|
|
7824
|
+
if (isMatchfixEntry(entry)) {
|
|
7825
|
+
const openDelim = typeof entry.openTrigger === "string" ? DEFAULT_DELIMITER[entry.openTrigger] : tokensToString(entry["openDelimiter"]);
|
|
7826
|
+
const closeDelim = typeof entry.closeTrigger === "string" ? DEFAULT_DELIMITER[entry.closeTrigger] : tokensToString(entry["closeDelimiter"]);
|
|
7827
|
+
return (serializer, expr) => joinLatex([openDelim, serializer.serialize(op(expr, 1)), closeDelim]);
|
|
7828
|
+
}
|
|
7829
|
+
let latex = entry.serialize;
|
|
7830
|
+
if (latex === void 0 && latexTrigger)
|
|
7831
|
+
latex = tokensToString(latexTrigger);
|
|
7832
|
+
if (latex) {
|
|
7833
|
+
if (kind === "postfix")
|
|
7834
|
+
return (serializer, expr) => joinLatex([serializer.serialize(op(expr, 1)), latex]);
|
|
7835
|
+
if (kind === "prefix")
|
|
7836
|
+
return (serializer, expr) => joinLatex([latex, serializer.serialize(op(expr, 1))]);
|
|
7837
|
+
if (kind === "infix") {
|
|
7838
|
+
return (serializer, expr) => joinLatex(
|
|
7839
|
+
(ops(expr) ?? []).flatMap(
|
|
7840
|
+
(val, i) => i < nops(expr) - 1 ? [serializer.serialize(val), latex] : [serializer.serialize(val)]
|
|
7841
|
+
)
|
|
7842
|
+
);
|
|
7843
|
+
}
|
|
7844
|
+
return (serializer, expr) => head(expr) ? joinLatex([latex, serializer.wrapArguments(expr)]) : latex;
|
|
7845
|
+
}
|
|
7846
|
+
const id = idTrigger ?? entry.name ?? "unknown";
|
|
7847
|
+
if (kind === "postfix")
|
|
7848
|
+
return (serializer, expr) => joinLatex([
|
|
7849
|
+
serializer.serialize(op(expr, 1)),
|
|
7850
|
+
serializer.serializeSymbol(id)
|
|
7851
|
+
]);
|
|
7852
|
+
if (kind === "prefix")
|
|
7853
|
+
return (serializer, expr) => joinLatex([
|
|
7854
|
+
serializer.serializeSymbol(id),
|
|
7855
|
+
serializer.serialize(op(expr, 1))
|
|
7856
|
+
]);
|
|
7857
|
+
if (kind === "infix")
|
|
7858
|
+
return (serializer, expr) => joinLatex([
|
|
7859
|
+
serializer.serialize(op(expr, 1)),
|
|
7860
|
+
serializer.serializeSymbol(id),
|
|
7861
|
+
serializer.serialize(op(expr, 2))
|
|
7862
|
+
]);
|
|
7863
|
+
return (serializer, expr) => head(expr) ? joinLatex([
|
|
7864
|
+
serializer.serializeSymbol(id),
|
|
7865
|
+
serializer.wrapArguments(expr)
|
|
7866
|
+
]) : serializer.serializeSymbol(id);
|
|
7867
|
+
}
|
|
7868
|
+
function makeParseHandler(entry, latexTrigger, idTrigger) {
|
|
7869
|
+
if ("parse" in entry && typeof entry.parse === "function")
|
|
7870
|
+
return entry.parse;
|
|
7871
|
+
const kind = "kind" in entry ? entry.kind : "expression";
|
|
7872
|
+
if (kind === "environment") {
|
|
7873
|
+
const envName = entry.parse ?? idTrigger ?? entry.name;
|
|
7874
|
+
if (envName)
|
|
7875
|
+
return (parser, _until) => {
|
|
7876
|
+
const array = parser.parseTabular();
|
|
7877
|
+
if (array === null)
|
|
7878
|
+
return null;
|
|
7879
|
+
return [envName, ["List", array.map((row) => ["List", ...row])]];
|
|
7880
|
+
};
|
|
7881
|
+
}
|
|
7882
|
+
if (kind === "function") {
|
|
7883
|
+
const fnName = entry.parse ?? idTrigger ?? entry.name;
|
|
7884
|
+
if (fnName)
|
|
7885
|
+
return (parser, until) => {
|
|
7886
|
+
const args = parser.parseArguments("enclosure", until);
|
|
7887
|
+
return args === null ? fnName : [fnName, ...args];
|
|
7888
|
+
};
|
|
7889
|
+
}
|
|
7890
|
+
if (kind === "symbol") {
|
|
7891
|
+
const symName = entry.parse ?? idTrigger ?? entry.name;
|
|
7892
|
+
if (symName)
|
|
7893
|
+
return (_parser, _terminator) => symName;
|
|
7894
|
+
}
|
|
7895
|
+
if (kind === "prefix") {
|
|
7896
|
+
const h = entry.parse ?? idTrigger ?? entry.name;
|
|
7897
|
+
if (h) {
|
|
7898
|
+
const prec = entry["precedence"] ?? 1e4;
|
|
7899
|
+
return (parser, until) => {
|
|
7900
|
+
const rhs = parser.parseExpression({
|
|
7901
|
+
...until ?? [],
|
|
7902
|
+
minPrec: prec
|
|
7903
|
+
});
|
|
7904
|
+
return rhs === null ? null : [h, rhs];
|
|
7905
|
+
};
|
|
7906
|
+
}
|
|
7907
|
+
}
|
|
7908
|
+
if (kind === "postfix") {
|
|
7909
|
+
const h = entry.parse ?? entry.name;
|
|
7910
|
+
if (h)
|
|
7911
|
+
return (_parser, lhs) => lhs === null ? null : [h, lhs];
|
|
7912
|
+
}
|
|
7913
|
+
if (kind === "infix") {
|
|
7914
|
+
if (/[_^]/.test(latexTrigger?.[0] ?? "")) {
|
|
7915
|
+
const h2 = entry.name ?? entry.parse;
|
|
7916
|
+
return (_parser, arg) => [
|
|
7917
|
+
h2,
|
|
7641
7918
|
missingIfEmpty(op(arg, 1)),
|
|
7642
7919
|
missingIfEmpty(op(arg, 2))
|
|
7643
7920
|
];
|
|
7644
|
-
}
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7921
|
+
}
|
|
7922
|
+
const h = entry.parse ?? idTrigger ?? entry.name;
|
|
7923
|
+
const prec = entry["precedence"] ?? 1e4;
|
|
7924
|
+
const associativity = entry["associativity"] ?? "non";
|
|
7925
|
+
if (h)
|
|
7926
|
+
return (parser, lhs, until) => {
|
|
7927
|
+
if (lhs === null)
|
|
7928
|
+
return null;
|
|
7929
|
+
if (prec < until.minPrec)
|
|
7650
7930
|
return null;
|
|
7651
7931
|
const rhs = missingIfEmpty(
|
|
7652
|
-
|
|
7653
|
-
...terminator,
|
|
7654
|
-
minPrec: prec
|
|
7655
|
-
})
|
|
7932
|
+
parser.parseExpression({ ...until, minPrec: prec })
|
|
7656
7933
|
);
|
|
7657
|
-
return typeof
|
|
7934
|
+
return typeof h === "string" ? applyAssociativeOperator(h, lhs, rhs, associativity) : [h, lhs, rhs];
|
|
7935
|
+
};
|
|
7936
|
+
}
|
|
7937
|
+
if (kind === "matchfix") {
|
|
7938
|
+
const h = entry.parse ?? entry.name;
|
|
7939
|
+
if (h)
|
|
7940
|
+
return (_parser, body) => {
|
|
7941
|
+
if (body === null || isEmptySequence(body))
|
|
7942
|
+
return null;
|
|
7943
|
+
return [h, body];
|
|
7658
7944
|
};
|
|
7659
|
-
}
|
|
7660
|
-
} else {
|
|
7661
|
-
if (typeof entry.parse === "function") {
|
|
7662
|
-
result.parse = entry.parse;
|
|
7663
|
-
} else if (entry.parse !== void 0) {
|
|
7664
|
-
console.assert(result.kind === "symbol" || result.kind === "expression");
|
|
7665
|
-
result.parse = () => entry.parse;
|
|
7666
|
-
} else if (entry.parse === void 0 && entry.name !== void 0) {
|
|
7667
|
-
if (result.kind === "postfix") {
|
|
7668
|
-
result.parse = (_parser, lhs) => lhs ? [entry.name, lhs] : null;
|
|
7669
|
-
} else if (result.kind === "prefix") {
|
|
7670
|
-
const prec = result.precedence;
|
|
7671
|
-
console.assert(entry.name);
|
|
7672
|
-
const head2 = entry.name;
|
|
7673
|
-
result.parse = (parser, terminator) => {
|
|
7674
|
-
if (terminator && prec < terminator.minPrec)
|
|
7675
|
-
return null;
|
|
7676
|
-
const rhs = parser.parseExpression({ ...terminator, minPrec: prec });
|
|
7677
|
-
return rhs === null ? null : [head2, rhs];
|
|
7678
|
-
};
|
|
7679
|
-
}
|
|
7680
|
-
}
|
|
7681
|
-
}
|
|
7682
|
-
if (typeof entry.serialize === "function" || typeof entry.serialize === "string") {
|
|
7683
|
-
result.serialize = entry.serialize;
|
|
7684
|
-
} else if (trigger) {
|
|
7685
|
-
if (result.kind === "postfix") {
|
|
7686
|
-
result.serialize = "#1" + triggerString;
|
|
7687
|
-
} else if (result.kind === "prefix") {
|
|
7688
|
-
result.serialize = triggerString + "#1";
|
|
7689
|
-
} else if (result.kind === "infix") {
|
|
7690
|
-
result.serialize = "#1" + triggerString + "#2";
|
|
7691
|
-
} else if (result.kind === "symbol") {
|
|
7692
|
-
result.serialize = triggerString;
|
|
7693
|
-
} else {
|
|
7694
|
-
result.serialize = "";
|
|
7695
|
-
}
|
|
7696
7945
|
}
|
|
7697
|
-
|
|
7946
|
+
if (kind === "expression") {
|
|
7947
|
+
const parseResult = entry.parse ?? idTrigger ?? entry.name;
|
|
7948
|
+
if (parseResult)
|
|
7949
|
+
return () => parseResult;
|
|
7950
|
+
}
|
|
7951
|
+
if ("parse" in entry) {
|
|
7952
|
+
const parseResult = entry.parse;
|
|
7953
|
+
return () => parseResult;
|
|
7954
|
+
}
|
|
7955
|
+
return void 0;
|
|
7698
7956
|
}
|
|
7699
|
-
function
|
|
7700
|
-
|
|
7957
|
+
function isValidEntry(entry, onError) {
|
|
7958
|
+
let subject = entry.name ?? entry["latexTrigger"] ?? entry["identifierTrigger"] ?? entry["openDelimiter"];
|
|
7959
|
+
if (!subject) {
|
|
7960
|
+
try {
|
|
7961
|
+
subject = JSON.stringify(entry);
|
|
7962
|
+
} catch (e) {
|
|
7963
|
+
subject = "???";
|
|
7964
|
+
}
|
|
7965
|
+
}
|
|
7966
|
+
if (Array.isArray(subject))
|
|
7967
|
+
subject = tokensToString(subject);
|
|
7968
|
+
if ("kind" in entry && ![
|
|
7969
|
+
"expression",
|
|
7970
|
+
"symbol",
|
|
7971
|
+
"function",
|
|
7972
|
+
"infix",
|
|
7973
|
+
"postfix",
|
|
7974
|
+
"prefix",
|
|
7975
|
+
"matchfix",
|
|
7976
|
+
"environment"
|
|
7977
|
+
].includes(entry.kind)) {
|
|
7978
|
+
onError({
|
|
7979
|
+
severity: "warning",
|
|
7980
|
+
message: [
|
|
7981
|
+
"invalid-dictionary-entry",
|
|
7982
|
+
subject,
|
|
7983
|
+
`The 'kind' property must be one of 'expression', 'symbol', 'function', 'infix', 'postfix', 'prefix', 'matchfix', 'environment'`
|
|
7984
|
+
]
|
|
7985
|
+
});
|
|
7986
|
+
}
|
|
7701
7987
|
if (entry.serialize !== void 0 && !entry.name) {
|
|
7702
7988
|
onError({
|
|
7703
7989
|
severity: "warning",
|
|
7704
7990
|
message: [
|
|
7705
7991
|
"invalid-dictionary-entry",
|
|
7706
7992
|
subject,
|
|
7707
|
-
`
|
|
7993
|
+
`A 'name' property must be provided if a 'serialize' handler is provided`
|
|
7708
7994
|
]
|
|
7709
7995
|
});
|
|
7710
7996
|
return false;
|
|
7711
7997
|
}
|
|
7998
|
+
if ("identifierTrigger" in entry) {
|
|
7999
|
+
if (typeof entry.identifierTrigger !== "string" || !isValidIdentifier(entry.identifierTrigger)) {
|
|
8000
|
+
onError({
|
|
8001
|
+
severity: "warning",
|
|
8002
|
+
message: [
|
|
8003
|
+
"invalid-dictionary-entry",
|
|
8004
|
+
subject,
|
|
8005
|
+
`The 'identifierTrigger' property must be a valid identifier`
|
|
8006
|
+
]
|
|
8007
|
+
});
|
|
8008
|
+
}
|
|
8009
|
+
}
|
|
8010
|
+
if ("name" in entry) {
|
|
8011
|
+
if (typeof entry.name !== "string") {
|
|
8012
|
+
if (entry.name !== void 0)
|
|
8013
|
+
onError({
|
|
8014
|
+
severity: "warning",
|
|
8015
|
+
message: [
|
|
8016
|
+
"invalid-dictionary-entry",
|
|
8017
|
+
subject,
|
|
8018
|
+
`The 'name' property must be a string`
|
|
8019
|
+
]
|
|
8020
|
+
});
|
|
8021
|
+
} else if (!isValidIdentifier(entry.name)) {
|
|
8022
|
+
onError({
|
|
8023
|
+
severity: "warning",
|
|
8024
|
+
message: [
|
|
8025
|
+
"invalid-dictionary-entry",
|
|
8026
|
+
entry.name,
|
|
8027
|
+
`The 'name' property must be a valid identifier`
|
|
8028
|
+
]
|
|
8029
|
+
});
|
|
8030
|
+
}
|
|
8031
|
+
}
|
|
7712
8032
|
if (isMatchfixEntry(entry)) {
|
|
7713
|
-
if (entry
|
|
8033
|
+
if ("latexTrigger" in entry || "identifierTrigger" in isPrefixEntry) {
|
|
7714
8034
|
onError({
|
|
7715
8035
|
severity: "warning",
|
|
7716
8036
|
message: [
|
|
7717
8037
|
"invalid-dictionary-entry",
|
|
7718
8038
|
subject,
|
|
7719
|
-
`
|
|
8039
|
+
`'matchfix' operators use a 'openDelimiter' and 'closeDelimiter' instead of a 'latexTrigger' or 'identifierTrigger'. `
|
|
7720
8040
|
]
|
|
7721
8041
|
});
|
|
7722
8042
|
return false;
|
|
7723
8043
|
}
|
|
7724
|
-
if (!entry.
|
|
8044
|
+
if (!entry.openTrigger || !entry.closeTrigger) {
|
|
7725
8045
|
onError({
|
|
7726
8046
|
severity: "warning",
|
|
7727
8047
|
message: [
|
|
@@ -7732,7 +8052,7 @@ function entryIsValid(entry, onError) {
|
|
|
7732
8052
|
});
|
|
7733
8053
|
return false;
|
|
7734
8054
|
}
|
|
7735
|
-
if (typeof entry.
|
|
8055
|
+
if (typeof entry.openTrigger !== typeof entry.closeTrigger) {
|
|
7736
8056
|
onError({
|
|
7737
8057
|
severity: "warning",
|
|
7738
8058
|
message: [
|
|
@@ -7745,7 +8065,7 @@ function entryIsValid(entry, onError) {
|
|
|
7745
8065
|
}
|
|
7746
8066
|
}
|
|
7747
8067
|
if (isInfixEntry(entry) || isPostfixEntry(entry) || isPrefixEntry(entry)) {
|
|
7748
|
-
if (Array.isArray(entry.
|
|
8068
|
+
if (Array.isArray(entry.latexTrigger) && (entry.latexTrigger[0] === "_" || entry.latexTrigger[0] === "^") || typeof entry.latexTrigger === "string" && (entry.latexTrigger.startsWith("^") || entry.latexTrigger.startsWith("_"))) {
|
|
7749
8069
|
if (entry.precedence !== void 0 || entry["associativity"] !== void 0) {
|
|
7750
8070
|
onError({
|
|
7751
8071
|
severity: "warning",
|
|
@@ -7781,14 +8101,14 @@ function entryIsValid(entry, onError) {
|
|
|
7781
8101
|
return false;
|
|
7782
8102
|
}
|
|
7783
8103
|
}
|
|
7784
|
-
if (!isMatchfixEntry(entry)) {
|
|
7785
|
-
if (!entry.
|
|
8104
|
+
if (!isMatchfixEntry(entry) && !isEnvironmentEntry(entry)) {
|
|
8105
|
+
if (!entry.latexTrigger && !entry.identifierTrigger && !entry.name) {
|
|
7786
8106
|
onError({
|
|
7787
8107
|
severity: "warning",
|
|
7788
8108
|
message: [
|
|
7789
8109
|
"invalid-dictionary-entry",
|
|
7790
8110
|
subject,
|
|
7791
|
-
`Expected
|
|
8111
|
+
`Expected a 'name', a 'latexTrigger' or a 'identifierTrigger'`
|
|
7792
8112
|
]
|
|
7793
8113
|
});
|
|
7794
8114
|
return false;
|
|
@@ -7819,7 +8139,7 @@ var DEFAULT_LATEX_DICTIONARY = {
|
|
|
7819
8139
|
{
|
|
7820
8140
|
name: "mu0",
|
|
7821
8141
|
kind: "symbol",
|
|
7822
|
-
|
|
8142
|
+
latexTrigger: "\\mu_0"
|
|
7823
8143
|
}
|
|
7824
8144
|
],
|
|
7825
8145
|
sets: DEFINITIONS_SETS,
|
|
@@ -7829,7 +8149,24 @@ var DEFAULT_LATEX_DICTIONARY = {
|
|
|
7829
8149
|
|
|
7830
8150
|
// src/compute-engine/latex-syntax/parse-identifier.ts
|
|
7831
8151
|
var IDENTIFIER_PREFIX = {
|
|
7832
|
-
"
|
|
8152
|
+
// Those are "grouping" prefix that also specify spacing
|
|
8153
|
+
// around the symbol. We ignore the spacing, though.
|
|
8154
|
+
"\\mathord": "",
|
|
8155
|
+
"\\mathop": "",
|
|
8156
|
+
"\\mathbin": "",
|
|
8157
|
+
"\\mathrel": "",
|
|
8158
|
+
"\\mathopen": "",
|
|
8159
|
+
"\\mathclose": "",
|
|
8160
|
+
"\\mathpunct": "",
|
|
8161
|
+
"\\mathinner": "",
|
|
8162
|
+
// This is the preferred way to specify an identifier
|
|
8163
|
+
// it defines both spacing and font. By default, identifiers
|
|
8164
|
+
// are wrapper with `\\operatorname{}`.
|
|
8165
|
+
"\\operatorname": "",
|
|
8166
|
+
// These styling commands are used to change the font of an identifier
|
|
8167
|
+
// They may be problematic, as adjacent identifiers may be merged
|
|
8168
|
+
// into a single identifier when used in editors, such a MathLive.
|
|
8169
|
+
// For example `\mathrm{speed}\mathrm{sound}` can be confused with `\mathrm{speedsound}`
|
|
7833
8170
|
"\\mathrm": "_upright",
|
|
7834
8171
|
"\\mathit": "_italic",
|
|
7835
8172
|
"\\mathbf": "_bold",
|
|
@@ -7856,7 +8193,7 @@ var IDENTIFIER_MODIFIER = {
|
|
|
7856
8193
|
"\\breve": "_breve",
|
|
7857
8194
|
"\\check": "_check"
|
|
7858
8195
|
};
|
|
7859
|
-
function
|
|
8196
|
+
function parseIdentifierToken(parser, options) {
|
|
7860
8197
|
if (parser.atEnd)
|
|
7861
8198
|
return null;
|
|
7862
8199
|
const token = parser.peek;
|
|
@@ -7894,7 +8231,7 @@ function matchIdentifierToken(parser, options) {
|
|
|
7894
8231
|
}
|
|
7895
8232
|
return parser.matchChar() ?? parser.nextToken();
|
|
7896
8233
|
}
|
|
7897
|
-
function
|
|
8234
|
+
function parseIdentifierBody(parser) {
|
|
7898
8235
|
let id = matchPrefixedIdentifier(parser);
|
|
7899
8236
|
const start = parser.index;
|
|
7900
8237
|
const prefix = IDENTIFIER_MODIFIER[parser.peek] ?? null;
|
|
@@ -7904,7 +8241,7 @@ function matchIdentifierBody(parser) {
|
|
|
7904
8241
|
parser.index = start;
|
|
7905
8242
|
return null;
|
|
7906
8243
|
}
|
|
7907
|
-
const body =
|
|
8244
|
+
const body = parseIdentifierBody(parser);
|
|
7908
8245
|
if (body === null || !parser.match("<}>")) {
|
|
7909
8246
|
parser.index = start;
|
|
7910
8247
|
return null;
|
|
@@ -7917,7 +8254,7 @@ function matchIdentifierBody(parser) {
|
|
|
7917
8254
|
const token = parser.peek;
|
|
7918
8255
|
if (token === "<}>" || token === "_" || token === "^")
|
|
7919
8256
|
break;
|
|
7920
|
-
const next =
|
|
8257
|
+
const next = parseIdentifierToken(parser, { toplevel: false });
|
|
7921
8258
|
if (next === null) {
|
|
7922
8259
|
parser.index = start;
|
|
7923
8260
|
return null;
|
|
@@ -7946,7 +8283,7 @@ function matchIdentifierBody(parser) {
|
|
|
7946
8283
|
while (!parser.atEnd) {
|
|
7947
8284
|
if (parser.match("_")) {
|
|
7948
8285
|
const hasBrace = parser.match("<{>");
|
|
7949
|
-
const sub2 =
|
|
8286
|
+
const sub2 = parseIdentifierBody(parser);
|
|
7950
8287
|
if (hasBrace && !parser.match("<}>") || sub2 === null) {
|
|
7951
8288
|
parser.index = start;
|
|
7952
8289
|
return null;
|
|
@@ -7954,7 +8291,7 @@ function matchIdentifierBody(parser) {
|
|
|
7954
8291
|
subs2.push(sub2);
|
|
7955
8292
|
} else if (parser.match("^")) {
|
|
7956
8293
|
const hasBrace = parser.match("<{>");
|
|
7957
|
-
const sup =
|
|
8294
|
+
const sup = parseIdentifierBody(parser);
|
|
7958
8295
|
if (hasBrace && !parser.match("<}>") || sup === null) {
|
|
7959
8296
|
parser.index = start;
|
|
7960
8297
|
return null;
|
|
@@ -7993,7 +8330,7 @@ function matchPrefixedIdentifier(parser) {
|
|
|
7993
8330
|
body = digit;
|
|
7994
8331
|
parser.nextToken();
|
|
7995
8332
|
}
|
|
7996
|
-
body +=
|
|
8333
|
+
body += parseIdentifierBody(parser);
|
|
7997
8334
|
if (body === null || !parser.match("<}>")) {
|
|
7998
8335
|
parser.index = start;
|
|
7999
8336
|
return null;
|
|
@@ -8017,7 +8354,7 @@ function parseInvalidIdentifier(parser) {
|
|
|
8017
8354
|
start
|
|
8018
8355
|
);
|
|
8019
8356
|
}
|
|
8020
|
-
function
|
|
8357
|
+
function parseIdentifier(parser) {
|
|
8021
8358
|
if (/^[a-zA-Z]$/.test(parser.peek) || /^\p{XIDS}$/u.test(parser.peek))
|
|
8022
8359
|
return parser.nextToken();
|
|
8023
8360
|
const start = parser.index;
|
|
@@ -8026,19 +8363,14 @@ function matchIdentifier(parser) {
|
|
|
8026
8363
|
id = "";
|
|
8027
8364
|
while (!parser.atEnd && ONLY_EMOJIS.test(id + parser.peek))
|
|
8028
8365
|
id += parser.nextToken();
|
|
8366
|
+
if (!id)
|
|
8367
|
+
id = null;
|
|
8029
8368
|
}
|
|
8369
|
+
id ?? (id = parseIdentifierToken(parser, { toplevel: true }));
|
|
8030
8370
|
if (id) {
|
|
8031
8371
|
id = id.normalize();
|
|
8032
8372
|
if (isValidIdentifier(id))
|
|
8033
|
-
return id;
|
|
8034
|
-
parser.index = start;
|
|
8035
|
-
return null;
|
|
8036
|
-
}
|
|
8037
|
-
let next = matchIdentifierToken(parser, { toplevel: true });
|
|
8038
|
-
if (next) {
|
|
8039
|
-
next = next.normalize();
|
|
8040
|
-
if (isValidIdentifier(next))
|
|
8041
|
-
return next;
|
|
8373
|
+
return id;
|
|
8042
8374
|
}
|
|
8043
8375
|
parser.index = start;
|
|
8044
8376
|
return null;
|
|
@@ -8107,7 +8439,7 @@ var DEFAULT_LATEX_NUMBER_OPTIONS = {
|
|
|
8107
8439
|
// with machine numbers, up to 15 assuming 2^53 bits floating points
|
|
8108
8440
|
positiveInfinity: "\\infty",
|
|
8109
8441
|
negativeInfinity: "-\\infty",
|
|
8110
|
-
notANumber: "\\
|
|
8442
|
+
notANumber: "\\operatorname{NaN}",
|
|
8111
8443
|
decimalMarker: ".",
|
|
8112
8444
|
// Use `{,}` for comma as a decimal marker
|
|
8113
8445
|
groupSeparator: "\\,",
|
|
@@ -8247,13 +8579,12 @@ var _Parser = class {
|
|
|
8247
8579
|
* Note: the `minPrec` condition is not checked. It should be checked separately.
|
|
8248
8580
|
*/
|
|
8249
8581
|
atTerminator(t) {
|
|
8250
|
-
|
|
8251
|
-
return true;
|
|
8252
|
-
if (t?.condition && t.condition(this))
|
|
8253
|
-
return true;
|
|
8254
|
-
return false;
|
|
8582
|
+
return this.atBoundary || ((t?.condition && t.condition(this)) ?? false);
|
|
8255
8583
|
}
|
|
8256
|
-
/**
|
|
8584
|
+
/**
|
|
8585
|
+
* True if the current token matches any of the boundaries we are
|
|
8586
|
+
* waiting for.
|
|
8587
|
+
*/
|
|
8257
8588
|
get atBoundary() {
|
|
8258
8589
|
if (this.atEnd)
|
|
8259
8590
|
return true;
|
|
@@ -8315,42 +8646,32 @@ var _Parser = class {
|
|
|
8315
8646
|
this._dictionary.lookahead,
|
|
8316
8647
|
this._tokens.length - this.index
|
|
8317
8648
|
);
|
|
8318
|
-
if (n
|
|
8649
|
+
if (n <= 0)
|
|
8319
8650
|
return [];
|
|
8320
|
-
const result =
|
|
8651
|
+
const result = [];
|
|
8321
8652
|
while (n > 0)
|
|
8322
|
-
result[n
|
|
8653
|
+
result.push([n, this.latexAhead(n--)]);
|
|
8323
8654
|
return result;
|
|
8324
8655
|
}
|
|
8325
8656
|
peekDefinitions(kind) {
|
|
8326
|
-
let defs;
|
|
8327
|
-
if (kind === "function") {
|
|
8328
|
-
const start = this.index;
|
|
8329
|
-
if (this.match("\\operatorname") || this.match("\\mathrm") || this.match("\\mathit")) {
|
|
8330
|
-
const fn = this.parseStringGroup()?.trim();
|
|
8331
|
-
const n = this.index - start;
|
|
8332
|
-
this.index = start;
|
|
8333
|
-
if (!fn || !this._dictionary.function.has(fn))
|
|
8334
|
-
return null;
|
|
8335
|
-
return this._dictionary.function.get(fn).map((x) => [x, n]);
|
|
8336
|
-
}
|
|
8337
|
-
return null;
|
|
8338
|
-
} else if (kind === "operator") {
|
|
8339
|
-
defs = this.lookAhead().map(
|
|
8340
|
-
(x, n) => this._dictionary.infix[n]?.get(x) ?? this._dictionary.postfix[n]?.get(x) ?? this._dictionary.prefix[n]?.get(x)
|
|
8341
|
-
);
|
|
8342
|
-
} else {
|
|
8343
|
-
defs = this.lookAhead().map((x, n) => this._dictionary[kind][n]?.get(x));
|
|
8344
|
-
}
|
|
8345
8657
|
const result = [];
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8658
|
+
const defs = [...this.getDefs(kind)];
|
|
8659
|
+
for (const def of defs)
|
|
8660
|
+
if (def.latexTrigger === "")
|
|
8661
|
+
result.push([def, 0]);
|
|
8662
|
+
for (const [n, tokens] of this.lookAhead()) {
|
|
8663
|
+
for (const def of defs)
|
|
8664
|
+
if (def.latexTrigger === tokens)
|
|
8665
|
+
result.push([def, n]);
|
|
8666
|
+
}
|
|
8667
|
+
for (const def of defs) {
|
|
8668
|
+
if (def.identifierTrigger) {
|
|
8669
|
+
const n = peekComplexId(this, def.identifierTrigger);
|
|
8670
|
+
if (n > 0)
|
|
8671
|
+
result.push([def, n]);
|
|
8351
8672
|
}
|
|
8352
8673
|
}
|
|
8353
|
-
return result
|
|
8674
|
+
return result;
|
|
8354
8675
|
}
|
|
8355
8676
|
/** Skip strictly `<space>` tokens.
|
|
8356
8677
|
* To also skip `{}` see `skipSpace()`.
|
|
@@ -8464,9 +8785,8 @@ var _Parser = class {
|
|
|
8464
8785
|
digits += digit;
|
|
8465
8786
|
n += 1;
|
|
8466
8787
|
}
|
|
8467
|
-
if (digits.length === caretCount)
|
|
8788
|
+
if (digits.length === caretCount)
|
|
8468
8789
|
return String.fromCodePoint(Number.parseInt(digits, 16));
|
|
8469
|
-
}
|
|
8470
8790
|
} else if (this.match("\\char")) {
|
|
8471
8791
|
let codepoint = Math.floor(this.matchLatexNumber() ?? Number.NaN);
|
|
8472
8792
|
if (!Number.isFinite(codepoint) || codepoint < 0 || codepoint > 1114111) {
|
|
@@ -8475,17 +8795,15 @@ var _Parser = class {
|
|
|
8475
8795
|
return String.fromCodePoint(codepoint);
|
|
8476
8796
|
} else if (this.match("\\unicode")) {
|
|
8477
8797
|
this.skipSpaceTokens();
|
|
8478
|
-
if (this.
|
|
8479
|
-
this.nextToken();
|
|
8798
|
+
if (this.match("<{>")) {
|
|
8480
8799
|
const codepoint = this.matchLatexNumber();
|
|
8481
8800
|
if (this.match("<}>") && codepoint !== null && codepoint >= 0 && codepoint <= 1114111) {
|
|
8482
8801
|
return String.fromCodePoint(codepoint);
|
|
8483
8802
|
}
|
|
8484
8803
|
} else {
|
|
8485
8804
|
const codepoint = this.matchLatexNumber();
|
|
8486
|
-
if (codepoint !== null && codepoint >= 0 && codepoint <= 1114111)
|
|
8805
|
+
if (codepoint !== null && codepoint >= 0 && codepoint <= 1114111)
|
|
8487
8806
|
return String.fromCodePoint(codepoint);
|
|
8488
|
-
}
|
|
8489
8807
|
}
|
|
8490
8808
|
}
|
|
8491
8809
|
this.index = index;
|
|
@@ -8512,7 +8830,7 @@ var _Parser = class {
|
|
|
8512
8830
|
// Some LaTeX commands (but not all) can accept an argument without braces,
|
|
8513
8831
|
// for example `^` , `\sqrt` or `\frac`.
|
|
8514
8832
|
// This argument will usually be a single token, but can be a sequence of
|
|
8515
|
-
// tokens (e.g. `\sqrt\frac12` or `\sqrt\
|
|
8833
|
+
// tokens (e.g. `\sqrt\frac12` or `\sqrt\operatorname{speed}`).
|
|
8516
8834
|
parseToken() {
|
|
8517
8835
|
const excluding = [
|
|
8518
8836
|
...'!"#$%&(),/;:?@[]\\`|~'.split(""),
|
|
@@ -8571,6 +8889,7 @@ var _Parser = class {
|
|
|
8571
8889
|
let peek = this.peek;
|
|
8572
8890
|
while (peek !== "&" && peek !== "\\\\" && peek !== "\\cr" && !this.atBoundary) {
|
|
8573
8891
|
expr = this.parseExpression({
|
|
8892
|
+
minPrec: 0,
|
|
8574
8893
|
condition: (p) => {
|
|
8575
8894
|
const peek2 = p.peek;
|
|
8576
8895
|
return peek2 === "&" || peek2 === "\\\\" || peek2 === "\\cr";
|
|
@@ -8614,7 +8933,7 @@ var _Parser = class {
|
|
|
8614
8933
|
}
|
|
8615
8934
|
/** Parse an environment: `\begin{env}...\end{end}`
|
|
8616
8935
|
*/
|
|
8617
|
-
parseEnvironment() {
|
|
8936
|
+
parseEnvironment(until) {
|
|
8618
8937
|
const index = this.index;
|
|
8619
8938
|
if (!this.match("\\begin"))
|
|
8620
8939
|
return null;
|
|
@@ -8622,22 +8941,22 @@ var _Parser = class {
|
|
|
8622
8941
|
if (!name)
|
|
8623
8942
|
return this.error("expected-environment-name", index);
|
|
8624
8943
|
this.addBoundary(["\\end", "<{>", ...name.split(""), "<}>"]);
|
|
8625
|
-
const def
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8944
|
+
for (const def of this.getDefs("environment"))
|
|
8945
|
+
if (def.identifierTrigger === name) {
|
|
8946
|
+
const expr = def.parse(this, until);
|
|
8947
|
+
this.skipSpace();
|
|
8948
|
+
if (!this.matchBoundary())
|
|
8949
|
+
return this.boundaryError("unbalanced-environment");
|
|
8950
|
+
if (expr !== null)
|
|
8951
|
+
return this.decorate(expr, index);
|
|
8952
|
+
this.index = index;
|
|
8953
|
+
return null;
|
|
8954
|
+
}
|
|
8955
|
+
this.parseTabular();
|
|
8634
8956
|
this.skipSpace();
|
|
8635
8957
|
if (!this.matchBoundary())
|
|
8636
8958
|
return this.boundaryError("unbalanced-environment");
|
|
8637
|
-
|
|
8638
|
-
return this.decorate(expr, index);
|
|
8639
|
-
this.index = index;
|
|
8640
|
-
return null;
|
|
8959
|
+
return this.error(["unknown-environment", { str: name }], index);
|
|
8641
8960
|
}
|
|
8642
8961
|
/** If the next token matches a `+` or `-` sign, return it and advance the index.
|
|
8643
8962
|
* Otherwise return `''` and do not advance */
|
|
@@ -8881,11 +9200,8 @@ var _Parser = class {
|
|
|
8881
9200
|
until = { minPrec: 0 };
|
|
8882
9201
|
if (!until.minPrec)
|
|
8883
9202
|
until = { ...until, minPrec: 0 };
|
|
8884
|
-
const defs = this.peekDefinitions("prefix");
|
|
8885
|
-
if (defs === null)
|
|
8886
|
-
return null;
|
|
8887
9203
|
const start = this.index;
|
|
8888
|
-
for (const [def, n] of
|
|
9204
|
+
for (const [def, n] of this.peekDefinitions("prefix")) {
|
|
8889
9205
|
this.index = start + n;
|
|
8890
9206
|
const rhs = def.parse(this, until);
|
|
8891
9207
|
if (rhs)
|
|
@@ -8896,13 +9212,11 @@ var _Parser = class {
|
|
|
8896
9212
|
}
|
|
8897
9213
|
parseInfixOperator(lhs, until) {
|
|
8898
9214
|
until ?? (until = { minPrec: 0 });
|
|
9215
|
+
console.assert(until.minPrec !== void 0);
|
|
8899
9216
|
if (until.minPrec === void 0)
|
|
8900
9217
|
until = { ...until, minPrec: 0 };
|
|
8901
|
-
const defs = this.peekDefinitions("infix");
|
|
8902
|
-
if (defs === null)
|
|
8903
|
-
return null;
|
|
8904
9218
|
const start = this.index;
|
|
8905
|
-
for (const [def, n] of
|
|
9219
|
+
for (const [def, n] of this.peekDefinitions("infix")) {
|
|
8906
9220
|
if (def.precedence >= until.minPrec) {
|
|
8907
9221
|
this.index = start + n;
|
|
8908
9222
|
const rhs = def.parse(this, lhs, until);
|
|
@@ -8944,44 +9258,6 @@ var _Parser = class {
|
|
|
8944
9258
|
this.index = savedIndex;
|
|
8945
9259
|
return null;
|
|
8946
9260
|
}
|
|
8947
|
-
/** A prime suffix is a sequence of `'`, `\prime` or `\doubleprime`
|
|
8948
|
-
* after a function or in a superscript.
|
|
8949
|
-
*/
|
|
8950
|
-
// matchPrimeSuffix(): number {
|
|
8951
|
-
// this.skipSpace();
|
|
8952
|
-
// const start = this.index;
|
|
8953
|
-
// let count = 0;
|
|
8954
|
-
// if (this.match('^')) {
|
|
8955
|
-
// if (this.match('<{>')) {
|
|
8956
|
-
// if (this.match('(')) {
|
|
8957
|
-
// const n = this.parseNumber();
|
|
8958
|
-
// if (n && this.match(')')) return parseInt(n);
|
|
8959
|
-
// this.index = start;
|
|
8960
|
-
// return 0;
|
|
8961
|
-
// }
|
|
8962
|
-
// do {
|
|
8963
|
-
// const c = countPrimeLevel(this);
|
|
8964
|
-
// if (c === 0) break;
|
|
8965
|
-
// count += c;
|
|
8966
|
-
// } while (true);
|
|
8967
|
-
// if (count !== 0 && this.match('<}>')) return count;
|
|
8968
|
-
// this.index = start;
|
|
8969
|
-
// return 0;
|
|
8970
|
-
// }
|
|
8971
|
-
// count = countPrimeLevel(this);
|
|
8972
|
-
// if (count !== 0) return count;
|
|
8973
|
-
// this.index = start;
|
|
8974
|
-
// return 0;
|
|
8975
|
-
// }
|
|
8976
|
-
// do {
|
|
8977
|
-
// const c = countPrimeLevel(this);
|
|
8978
|
-
// if (c === 0) break;
|
|
8979
|
-
// count += c;
|
|
8980
|
-
// } while (true);
|
|
8981
|
-
// if (count !== 0) return count;
|
|
8982
|
-
// this.index = start;
|
|
8983
|
-
// return 0;
|
|
8984
|
-
// }
|
|
8985
9261
|
/** If matches the normalized open delimiter, return the
|
|
8986
9262
|
* expected closing delimiter.
|
|
8987
9263
|
*
|
|
@@ -9037,9 +9313,7 @@ var _Parser = class {
|
|
|
9037
9313
|
* @internal
|
|
9038
9314
|
*/
|
|
9039
9315
|
matchEnclosureOpen() {
|
|
9040
|
-
const defs = this.
|
|
9041
|
-
if (defs.length === 0)
|
|
9042
|
-
return null;
|
|
9316
|
+
const defs = this.getDefs("matchfix");
|
|
9043
9317
|
const start = this.index;
|
|
9044
9318
|
for (const def of defs) {
|
|
9045
9319
|
this.index = start;
|
|
@@ -9062,9 +9336,7 @@ var _Parser = class {
|
|
|
9062
9336
|
* Used for error handling
|
|
9063
9337
|
* @internal */
|
|
9064
9338
|
matchEnclosureClose() {
|
|
9065
|
-
const defs = this.
|
|
9066
|
-
if (defs.length === 0)
|
|
9067
|
-
return null;
|
|
9339
|
+
const defs = this.getDefs("matchfix");
|
|
9068
9340
|
const start = this.index;
|
|
9069
9341
|
for (const def of defs) {
|
|
9070
9342
|
this.index = start;
|
|
@@ -9103,9 +9375,7 @@ var _Parser = class {
|
|
|
9103
9375
|
* and finally a closing matching operator.
|
|
9104
9376
|
*/
|
|
9105
9377
|
parseEnclosure() {
|
|
9106
|
-
const defs = this.
|
|
9107
|
-
if (defs.length === 0)
|
|
9108
|
-
return null;
|
|
9378
|
+
const defs = this.getDefs("matchfix");
|
|
9109
9379
|
const start = this.index;
|
|
9110
9380
|
for (const def of defs) {
|
|
9111
9381
|
this.index = start;
|
|
@@ -9192,8 +9462,7 @@ var _Parser = class {
|
|
|
9192
9462
|
return null;
|
|
9193
9463
|
const start = this.index;
|
|
9194
9464
|
let fn = null;
|
|
9195
|
-
const
|
|
9196
|
-
for (const [def, tokenCount] of fnDefs) {
|
|
9465
|
+
for (const [def, tokenCount] of this.peekDefinitions("function")) {
|
|
9197
9466
|
this.index = start + tokenCount;
|
|
9198
9467
|
if (typeof def.parse === "function") {
|
|
9199
9468
|
fn = def.parse(this, until);
|
|
@@ -9206,7 +9475,7 @@ var _Parser = class {
|
|
|
9206
9475
|
}
|
|
9207
9476
|
if (fn === null) {
|
|
9208
9477
|
this.index = start;
|
|
9209
|
-
fn =
|
|
9478
|
+
fn = parseIdentifier(this);
|
|
9210
9479
|
if (!this.isFunctionHead(fn)) {
|
|
9211
9480
|
this.index = start;
|
|
9212
9481
|
return null;
|
|
@@ -9225,20 +9494,17 @@ var _Parser = class {
|
|
|
9225
9494
|
if (this.atTerminator(until))
|
|
9226
9495
|
return null;
|
|
9227
9496
|
const start = this.index;
|
|
9228
|
-
const
|
|
9229
|
-
|
|
9230
|
-
|
|
9231
|
-
|
|
9232
|
-
if (
|
|
9233
|
-
|
|
9234
|
-
|
|
9235
|
-
|
|
9236
|
-
} else
|
|
9237
|
-
return def.name;
|
|
9238
|
-
}
|
|
9497
|
+
for (const [def, tokenCount] of this.peekDefinitions("symbol")) {
|
|
9498
|
+
this.index = start + tokenCount;
|
|
9499
|
+
if (typeof def.parse === "function") {
|
|
9500
|
+
const result = def.parse(this, until);
|
|
9501
|
+
if (result)
|
|
9502
|
+
return result;
|
|
9503
|
+
} else
|
|
9504
|
+
return def.name;
|
|
9239
9505
|
}
|
|
9240
9506
|
this.index = start;
|
|
9241
|
-
const id =
|
|
9507
|
+
const id = parseIdentifier(this);
|
|
9242
9508
|
if (id === null)
|
|
9243
9509
|
return null;
|
|
9244
9510
|
if (this.options.parseUnknownIdentifier?.(id, this) === "symbol")
|
|
@@ -9295,7 +9561,9 @@ var _Parser = class {
|
|
|
9295
9561
|
}
|
|
9296
9562
|
let result = lhs;
|
|
9297
9563
|
if (subscripts.length > 0) {
|
|
9298
|
-
const defs = this.
|
|
9564
|
+
const defs = [...this.getDefs("infix")].filter(
|
|
9565
|
+
(x) => x.latexTrigger === "_"
|
|
9566
|
+
);
|
|
9299
9567
|
if (defs) {
|
|
9300
9568
|
const arg = [
|
|
9301
9569
|
"Subscript",
|
|
@@ -9313,7 +9581,9 @@ var _Parser = class {
|
|
|
9313
9581
|
}
|
|
9314
9582
|
}
|
|
9315
9583
|
if (superscripts.length > 0) {
|
|
9316
|
-
const defs = this.
|
|
9584
|
+
const defs = [...this.getDefs("infix")].filter(
|
|
9585
|
+
(x) => x.latexTrigger === "^"
|
|
9586
|
+
);
|
|
9317
9587
|
if (defs) {
|
|
9318
9588
|
const arg = [
|
|
9319
9589
|
"Superscript",
|
|
@@ -9338,11 +9608,8 @@ var _Parser = class {
|
|
|
9338
9608
|
console.assert(lhs !== null);
|
|
9339
9609
|
if (lhs === null)
|
|
9340
9610
|
return null;
|
|
9341
|
-
const defs = this.peekDefinitions("postfix");
|
|
9342
|
-
if (defs === null)
|
|
9343
|
-
return null;
|
|
9344
9611
|
const start = this.index;
|
|
9345
|
-
for (const [def, n] of
|
|
9612
|
+
for (const [def, n] of this.peekDefinitions("postfix")) {
|
|
9346
9613
|
this.index = start + n;
|
|
9347
9614
|
const result = def.parse(this, lhs, until);
|
|
9348
9615
|
if (result !== null)
|
|
@@ -9406,14 +9673,14 @@ var _Parser = class {
|
|
|
9406
9673
|
applyInvisibleOperator(until, lhs) {
|
|
9407
9674
|
if (lhs === null || this.options.applyInvisibleOperator === null || head(lhs) === "Error" || symbol(lhs) === "Nothing" || isEmptySequence(lhs) || this.atTerminator(until))
|
|
9408
9675
|
return null;
|
|
9676
|
+
if (this.peekDefinitions("operator").length > 0)
|
|
9677
|
+
return null;
|
|
9409
9678
|
if (this.isFunctionHead(lhs)) {
|
|
9410
|
-
const args = this.parseArguments("enclosure", until);
|
|
9679
|
+
const args = this.parseArguments("enclosure", { ...until, minPrec: 0 });
|
|
9411
9680
|
if (args === null)
|
|
9412
9681
|
return null;
|
|
9413
9682
|
return [lhs, ...args];
|
|
9414
9683
|
}
|
|
9415
|
-
if (this.peekDefinitions("operator") !== null)
|
|
9416
|
-
return null;
|
|
9417
9684
|
const start = this.index;
|
|
9418
9685
|
const rhs = this.parseExpression({ ...until, minPrec: 390 });
|
|
9419
9686
|
if (rhs === null || symbol(rhs) === "Nothing" || isEmptySequence(rhs)) {
|
|
@@ -9460,9 +9727,9 @@ var _Parser = class {
|
|
|
9460
9727
|
parseUnexpectedLatexCommand() {
|
|
9461
9728
|
const start = this.index;
|
|
9462
9729
|
let opDefs = this.peekDefinitions("operator");
|
|
9463
|
-
if (opDefs) {
|
|
9730
|
+
if (opDefs.length > 0) {
|
|
9464
9731
|
opDefs = this.peekDefinitions("postfix");
|
|
9465
|
-
if (opDefs) {
|
|
9732
|
+
if (opDefs.length > 0) {
|
|
9466
9733
|
const [def, n] = opDefs[0];
|
|
9467
9734
|
this.index += n;
|
|
9468
9735
|
if (typeof def.parse === "function") {
|
|
@@ -9475,7 +9742,7 @@ var _Parser = class {
|
|
|
9475
9742
|
return this.error("unexpected-operator", start);
|
|
9476
9743
|
}
|
|
9477
9744
|
opDefs = this.peekDefinitions("prefix");
|
|
9478
|
-
if (opDefs) {
|
|
9745
|
+
if (opDefs.length > 0) {
|
|
9479
9746
|
const [def, n] = opDefs[0];
|
|
9480
9747
|
this.index += n;
|
|
9481
9748
|
if (typeof def.parse === "function") {
|
|
@@ -9486,12 +9753,13 @@ var _Parser = class {
|
|
|
9486
9753
|
if (def.name)
|
|
9487
9754
|
return [
|
|
9488
9755
|
def.name,
|
|
9756
|
+
// @todo: pass a precedence?
|
|
9489
9757
|
this.parseExpression() ?? this.error("missing", start)
|
|
9490
9758
|
];
|
|
9491
9759
|
return this.error("unexpected-operator", start);
|
|
9492
9760
|
}
|
|
9493
9761
|
opDefs = this.peekDefinitions("infix");
|
|
9494
|
-
if (opDefs) {
|
|
9762
|
+
if (opDefs.length > 0) {
|
|
9495
9763
|
const [def, n] = opDefs[0];
|
|
9496
9764
|
this.index += n;
|
|
9497
9765
|
if (typeof def.parse === "function") {
|
|
@@ -9585,7 +9853,10 @@ var _Parser = class {
|
|
|
9585
9853
|
if (this.match("<}>"))
|
|
9586
9854
|
return this.error("unexpected-closing-delimiter", start);
|
|
9587
9855
|
if (this.match("<{>")) {
|
|
9588
|
-
result = this.parseExpression({
|
|
9856
|
+
result = this.parseExpression({
|
|
9857
|
+
minPrec: 0,
|
|
9858
|
+
condition: (p) => p.peek === "<}>"
|
|
9859
|
+
});
|
|
9589
9860
|
if (result === null)
|
|
9590
9861
|
return this.error("expected-expression", start);
|
|
9591
9862
|
if (!this.match("<}>")) {
|
|
@@ -9601,7 +9872,7 @@ var _Parser = class {
|
|
|
9601
9872
|
result = { num };
|
|
9602
9873
|
}
|
|
9603
9874
|
result ?? (result = this.parseEnclosure());
|
|
9604
|
-
result ?? (result = this.parseEnvironment());
|
|
9875
|
+
result ?? (result = this.parseEnvironment(until));
|
|
9605
9876
|
if (result === null && this.matchAll(this._positiveInfinityTokens))
|
|
9606
9877
|
result = { num: "+Infinity" };
|
|
9607
9878
|
if (result === null && this.matchAll(this._negativeInfinityTokens))
|
|
@@ -9646,8 +9917,9 @@ var _Parser = class {
|
|
|
9646
9917
|
return null;
|
|
9647
9918
|
}
|
|
9648
9919
|
until ?? (until = { minPrec: 0 });
|
|
9920
|
+
console.assert(until.minPrec !== void 0);
|
|
9649
9921
|
if (until.minPrec === void 0)
|
|
9650
|
-
until
|
|
9922
|
+
until = { ...until, minPrec: 0 };
|
|
9651
9923
|
let lhs = this.parsePrefixOperator({ ...until, minPrec: 0 });
|
|
9652
9924
|
if (lhs === null) {
|
|
9653
9925
|
lhs = this.parsePrimary(until);
|
|
@@ -9716,7 +9988,28 @@ var _Parser = class {
|
|
|
9716
9988
|
return true;
|
|
9717
9989
|
return false;
|
|
9718
9990
|
}
|
|
9991
|
+
/** Return all defs of the specified kind */
|
|
9992
|
+
*getDefs(kind) {
|
|
9993
|
+
if (kind === "operator") {
|
|
9994
|
+
for (const def of this._dictionary.defs)
|
|
9995
|
+
if (/^prefix|infix|postfix/.test(def.kind))
|
|
9996
|
+
yield def;
|
|
9997
|
+
} else {
|
|
9998
|
+
for (const def of this._dictionary.defs)
|
|
9999
|
+
if (def.kind === kind)
|
|
10000
|
+
yield def;
|
|
10001
|
+
}
|
|
10002
|
+
}
|
|
9719
10003
|
};
|
|
10004
|
+
function peekComplexId(parser, id) {
|
|
10005
|
+
const start = parser.index;
|
|
10006
|
+
const candidate = parseIdentifier(parser)?.trim();
|
|
10007
|
+
if (candidate === null)
|
|
10008
|
+
return 0;
|
|
10009
|
+
const result = candidate !== id ? 0 : parser.index - start;
|
|
10010
|
+
parser.index = start;
|
|
10011
|
+
return result;
|
|
10012
|
+
}
|
|
9720
10013
|
|
|
9721
10014
|
// src/compute-engine/latex-syntax/serialize-number.ts
|
|
9722
10015
|
function formatFractionalPart(m, options) {
|
|
@@ -9956,68 +10249,11 @@ var STYLE_MODIFIERS = {
|
|
|
9956
10249
|
// Unicode uses 'double-struck' for 'blackboard'
|
|
9957
10250
|
// Supplemental
|
|
9958
10251
|
blackboard: (s) => `\\mathbb{${s}}`,
|
|
9959
|
-
// boldItalic: (s) => `\\mathbf{\\mathit{${s}}}`,
|
|
9960
10252
|
calligraphic: (s) => `\\mathcal{${s}}`,
|
|
9961
|
-
// scriptBold: (s) => `\\mathbf{\\mathscr{${s}}}`,
|
|
9962
|
-
// calligraphicBold: (s) => `\\mathbf{\\mathcal{${s}}}`,
|
|
9963
10253
|
gothic: (s) => `\\mathfrak{${s}}`,
|
|
9964
|
-
|
|
9965
|
-
// frakturBold: (s) => `\\mathbf{\\mathfrak{${s}}}`,
|
|
9966
|
-
sansSerif: (s) => `\\mathsf{${s}}`,
|
|
9967
|
-
// sansSerifBold: (s) => `\\mathbf{\\mathsf{${s}}}`,
|
|
9968
|
-
// sansSerifItalic: (s) => `\\mathit{\\mathsf{${s}}}`,
|
|
10254
|
+
sansserif: (s) => `\\mathsf{${s}}`,
|
|
9969
10255
|
monospace: (s) => `\\mathtt{${s}}`
|
|
9970
10256
|
};
|
|
9971
|
-
function serializeOperator(serializer, expr, def) {
|
|
9972
|
-
let result = "";
|
|
9973
|
-
const count = nops(expr);
|
|
9974
|
-
const name = headName(expr);
|
|
9975
|
-
if (def.kind === "postfix") {
|
|
9976
|
-
if (count !== 1) {
|
|
9977
|
-
serializer.onError([
|
|
9978
|
-
{
|
|
9979
|
-
severity: "warning",
|
|
9980
|
-
message: [
|
|
9981
|
-
"postfix-operator-requires-one-operand",
|
|
9982
|
-
serializer.serializeSymbol(name)
|
|
9983
|
-
]
|
|
9984
|
-
}
|
|
9985
|
-
]);
|
|
9986
|
-
}
|
|
9987
|
-
return replaceLatex(def.serialize, [
|
|
9988
|
-
serializer.wrap(op(expr, 1), def.precedence)
|
|
9989
|
-
]);
|
|
9990
|
-
}
|
|
9991
|
-
if (def.kind === "prefix") {
|
|
9992
|
-
if (count !== 1) {
|
|
9993
|
-
serializer.onError([
|
|
9994
|
-
{
|
|
9995
|
-
severity: "warning",
|
|
9996
|
-
message: [
|
|
9997
|
-
"prefix-operator-requires-one-operand",
|
|
9998
|
-
serializer.serializeSymbol(name)
|
|
9999
|
-
]
|
|
10000
|
-
}
|
|
10001
|
-
]);
|
|
10002
|
-
}
|
|
10003
|
-
return replaceLatex(def.serialize, [
|
|
10004
|
-
serializer.wrap(op(expr, 1), def.precedence + 1)
|
|
10005
|
-
]);
|
|
10006
|
-
}
|
|
10007
|
-
if (def.kind === "infix") {
|
|
10008
|
-
result = serializer.wrap(op(expr, 1), def.precedence);
|
|
10009
|
-
for (let i = 2; i < count + 1; i++) {
|
|
10010
|
-
const arg = op(expr, i);
|
|
10011
|
-
if (arg !== null) {
|
|
10012
|
-
result = replaceLatex(def.serialize, [
|
|
10013
|
-
result,
|
|
10014
|
-
serializer.wrap(arg, def.precedence)
|
|
10015
|
-
]);
|
|
10016
|
-
}
|
|
10017
|
-
}
|
|
10018
|
-
}
|
|
10019
|
-
return result;
|
|
10020
|
-
}
|
|
10021
10257
|
var Serializer = class {
|
|
10022
10258
|
constructor(options, dictionary2, onError) {
|
|
10023
10259
|
this.level = -1;
|
|
@@ -10059,7 +10295,7 @@ var Serializer = class {
|
|
|
10059
10295
|
}
|
|
10060
10296
|
const name = head(expr);
|
|
10061
10297
|
if (typeof name === "string" && name !== "Delimiter" && name !== "Subscript") {
|
|
10062
|
-
const def = this.dictionary.
|
|
10298
|
+
const def = this.dictionary.ids.get(name);
|
|
10063
10299
|
if (def && (def.kind === "symbol" || def.kind === "prefix" || def.kind === "infix" || def.kind === "postfix") && def.precedence < prec)
|
|
10064
10300
|
return this.wrapString(
|
|
10065
10301
|
this.serialize(expr),
|
|
@@ -10116,42 +10352,37 @@ var Serializer = class {
|
|
|
10116
10352
|
);
|
|
10117
10353
|
}
|
|
10118
10354
|
serializeSymbol(expr, def) {
|
|
10119
|
-
const h = head(expr);
|
|
10120
|
-
if (h)
|
|
10121
|
-
return this.serializeFunction(expr, def);
|
|
10122
10355
|
console.assert(typeof expr === "string" || isSymbolObject(expr));
|
|
10123
|
-
if (
|
|
10124
|
-
return
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
return serializeIdentifier(symbol(expr)) ?? "";
|
|
10356
|
+
if (def?.kind === "function") {
|
|
10357
|
+
return serializeIdentifier(symbol(expr) ?? "") ?? "";
|
|
10358
|
+
}
|
|
10359
|
+
return def?.serialize?.(this, expr) ?? serializeIdentifier(symbol(expr)) ?? "";
|
|
10128
10360
|
}
|
|
10129
10361
|
serializeFunction(expr, def) {
|
|
10362
|
+
if (def?.serialize)
|
|
10363
|
+
return def.serialize(this, expr);
|
|
10130
10364
|
const h = head(expr);
|
|
10131
|
-
if (
|
|
10132
|
-
return this.
|
|
10365
|
+
if (typeof h === "string")
|
|
10366
|
+
return serializeIdentifier(h, "auto") + this.wrapArguments(expr);
|
|
10133
10367
|
const args = ops(expr) ?? [];
|
|
10134
|
-
if (
|
|
10135
|
-
if (typeof def.serialize === "function")
|
|
10136
|
-
return def.serialize(this, expr);
|
|
10368
|
+
if (args.length === 1) {
|
|
10137
10369
|
return joinLatex([
|
|
10138
|
-
|
|
10139
|
-
|
|
10370
|
+
this.serialize(args[0]),
|
|
10371
|
+
"\\rhd",
|
|
10372
|
+
this.wrapString(
|
|
10373
|
+
this.serialize(h),
|
|
10374
|
+
this.options.applyFunctionStyle(expr, this.level)
|
|
10375
|
+
)
|
|
10140
10376
|
]);
|
|
10141
10377
|
}
|
|
10142
|
-
if (typeof h === "string" && h.length > 0 && h[0] === "\\") {
|
|
10143
|
-
return joinLatex([h, ...args.map((x) => `{${this.serialize(x)}}`)]);
|
|
10144
|
-
}
|
|
10145
|
-
if (typeof h === "string") {
|
|
10146
|
-
if (h.length === 1)
|
|
10147
|
-
return serializeIdentifier(h) + this.wrapArguments(expr);
|
|
10148
|
-
return serializeIdentifier(h, "upright") + this.wrapArguments(expr);
|
|
10149
|
-
}
|
|
10150
10378
|
const style = this.options.applyFunctionStyle(expr, this.level);
|
|
10151
|
-
return
|
|
10152
|
-
|
|
10153
|
-
|
|
10154
|
-
|
|
10379
|
+
return joinLatex([
|
|
10380
|
+
"\\operatorname{apply}",
|
|
10381
|
+
this.wrapString(
|
|
10382
|
+
this.serialize(h) + ", " + this.serialize(["List", ...args]),
|
|
10383
|
+
style
|
|
10384
|
+
)
|
|
10385
|
+
]);
|
|
10155
10386
|
}
|
|
10156
10387
|
serializeDictionary(dict) {
|
|
10157
10388
|
return `\\left\\lbrack\\begin{array}{lll}${Object.keys(dict).map((x) => {
|
|
@@ -10170,37 +10401,22 @@ var Serializer = class {
|
|
|
10170
10401
|
const s = stringValue(expr);
|
|
10171
10402
|
if (s !== null)
|
|
10172
10403
|
return `\\text{${s}}`;
|
|
10173
|
-
const symbolName = symbol(expr);
|
|
10174
|
-
if (symbolName !== null) {
|
|
10175
|
-
const def = this.dictionary.name.get(symbolName);
|
|
10176
|
-
if (def?.kind === "symbol")
|
|
10177
|
-
return this.serializeSymbol(expr, def);
|
|
10178
|
-
if (def?.kind === "function")
|
|
10179
|
-
return this.serializeFunction(expr, def);
|
|
10180
|
-
if (typeof def?.serialize === "function")
|
|
10181
|
-
return def.serialize(this, expr);
|
|
10182
|
-
}
|
|
10183
10404
|
const dict = dictionary(expr);
|
|
10184
10405
|
if (dict !== null)
|
|
10185
10406
|
return this.serializeDictionary(dict);
|
|
10407
|
+
const symbolName = symbol(expr);
|
|
10408
|
+
if (symbolName !== null) {
|
|
10409
|
+
return this.serializeSymbol(
|
|
10410
|
+
expr,
|
|
10411
|
+
this.dictionary.ids.get(symbolName)
|
|
10412
|
+
);
|
|
10413
|
+
}
|
|
10186
10414
|
const fnName = headName(expr);
|
|
10187
10415
|
if (fnName) {
|
|
10188
|
-
|
|
10189
|
-
if (def) {
|
|
10190
|
-
if (typeof def.serialize === "function")
|
|
10191
|
-
return def.serialize(this, expr);
|
|
10192
|
-
if (def.kind === "infix" || def.kind === "postfix" || def.kind === "prefix")
|
|
10193
|
-
return serializeOperator(this, expr, def);
|
|
10194
|
-
if (def.kind === "symbol")
|
|
10195
|
-
return this.serializeSymbol(expr, def);
|
|
10196
|
-
if (def.kind === "function")
|
|
10197
|
-
return this.serializeFunction(expr, def);
|
|
10198
|
-
return "";
|
|
10199
|
-
}
|
|
10200
|
-
}
|
|
10201
|
-
if (symbolName !== null || Array.isArray(expr) || isFunctionObject(expr)) {
|
|
10202
|
-
return this.serializeSymbol(expr);
|
|
10416
|
+
return this.serializeFunction(expr, this.dictionary.ids.get(fnName));
|
|
10203
10417
|
}
|
|
10418
|
+
if (head(expr) !== null)
|
|
10419
|
+
return this.serializeFunction(expr);
|
|
10204
10420
|
this.onError([
|
|
10205
10421
|
{
|
|
10206
10422
|
severity: "warning",
|
|
@@ -10240,22 +10456,6 @@ var Serializer = class {
|
|
|
10240
10456
|
return this.options.numericSetStyle(expr, level);
|
|
10241
10457
|
}
|
|
10242
10458
|
};
|
|
10243
|
-
function replaceLatex(template, replacement) {
|
|
10244
|
-
console.assert(typeof template === "string");
|
|
10245
|
-
console.assert(template.length > 0);
|
|
10246
|
-
let result = template;
|
|
10247
|
-
for (let i = 0; i < replacement.length; i++) {
|
|
10248
|
-
let s = replacement[i] ?? "";
|
|
10249
|
-
if (/[a-zA-Z*]/.test(s[0])) {
|
|
10250
|
-
const m = result.match(new RegExp("(.*)#" + Number(i + 1).toString()));
|
|
10251
|
-
if (m && /\\[a-zA-Z*]+/.test(m[1])) {
|
|
10252
|
-
s = " " + s;
|
|
10253
|
-
}
|
|
10254
|
-
}
|
|
10255
|
-
result = result.replace("#" + Number(i + 1).toString(), s);
|
|
10256
|
-
}
|
|
10257
|
-
return result;
|
|
10258
|
-
}
|
|
10259
10459
|
function specialName(s) {
|
|
10260
10460
|
const prefix = s.match(/^([^_]+)/)?.[1] ?? "";
|
|
10261
10461
|
let i = SYMBOLS.findIndex((x) => prefix === x[0]);
|
|
@@ -10331,7 +10531,7 @@ function parseModifiers(s) {
|
|
|
10331
10531
|
}
|
|
10332
10532
|
return [body, accent, styles, rest];
|
|
10333
10533
|
}
|
|
10334
|
-
function
|
|
10534
|
+
function parseIdentifierBody2(s, topLevel = true, style = "auto") {
|
|
10335
10535
|
let [body, accents, styles, rest] = parseModifiers(s);
|
|
10336
10536
|
for (const accent of accents) {
|
|
10337
10537
|
if (ACCENT_MODIFIERS[accent])
|
|
@@ -10347,7 +10547,7 @@ function parseIdentifierBody(s, topLevel = true, style = "auto") {
|
|
|
10347
10547
|
}
|
|
10348
10548
|
while (rest.length > 0) {
|
|
10349
10549
|
if (rest.startsWith("__")) {
|
|
10350
|
-
const [sup, rest2] =
|
|
10550
|
+
const [sup, rest2] = parseIdentifierBody2(
|
|
10351
10551
|
rest.substring(2),
|
|
10352
10552
|
false,
|
|
10353
10553
|
"none"
|
|
@@ -10355,7 +10555,7 @@ function parseIdentifierBody(s, topLevel = true, style = "auto") {
|
|
|
10355
10555
|
sups.push(sup);
|
|
10356
10556
|
rest = rest2;
|
|
10357
10557
|
} else if (rest.startsWith("_")) {
|
|
10358
|
-
const [sub2, rest2] =
|
|
10558
|
+
const [sub2, rest2] = parseIdentifierBody2(
|
|
10359
10559
|
rest.substring(1),
|
|
10360
10560
|
false,
|
|
10361
10561
|
"none"
|
|
@@ -10394,19 +10594,19 @@ function parseIdentifierBody(s, topLevel = true, style = "auto") {
|
|
|
10394
10594
|
}
|
|
10395
10595
|
return [body, rest];
|
|
10396
10596
|
}
|
|
10397
|
-
function serializeIdentifier(s,
|
|
10597
|
+
function serializeIdentifier(s, style = "auto") {
|
|
10398
10598
|
if (s === null)
|
|
10399
10599
|
return null;
|
|
10400
10600
|
if (ONLY_EMOJIS.test(s))
|
|
10401
10601
|
return s;
|
|
10402
10602
|
const m = s.match(/^(_+)(.*)/);
|
|
10403
10603
|
if (m) {
|
|
10404
|
-
const [body2, rest2] =
|
|
10405
|
-
return `\\
|
|
10604
|
+
const [body2, rest2] = parseIdentifierBody2(m[2], true, "none");
|
|
10605
|
+
return `\\operatorname{${"\\_".repeat(m[1].length) + body2 + rest2}}`;
|
|
10406
10606
|
}
|
|
10407
|
-
const [body, rest] =
|
|
10607
|
+
const [body, rest] = parseIdentifierBody2(s, true, style);
|
|
10408
10608
|
if (rest.length > 0)
|
|
10409
|
-
return `\\
|
|
10609
|
+
return `\\operatorname{${s}}`;
|
|
10410
10610
|
return body;
|
|
10411
10611
|
}
|
|
10412
10612
|
|
|
@@ -10496,7 +10696,7 @@ var LatexSyntax = class _LatexSyntax {
|
|
|
10496
10696
|
let expr = parser.parseExpression();
|
|
10497
10697
|
if (!parser.atEnd) {
|
|
10498
10698
|
const opDefs = parser.peekDefinitions("infix");
|
|
10499
|
-
if (opDefs) {
|
|
10699
|
+
if (opDefs.length > 0) {
|
|
10500
10700
|
const start = parser.index;
|
|
10501
10701
|
const [def, n] = opDefs[0];
|
|
10502
10702
|
parser.index += n;
|
|
@@ -10517,20 +10717,23 @@ var LatexSyntax = class _LatexSyntax {
|
|
|
10517
10717
|
parser.index = start;
|
|
10518
10718
|
}
|
|
10519
10719
|
const index = parser.index;
|
|
10520
|
-
const id =
|
|
10720
|
+
const id = parseIdentifier(parser);
|
|
10521
10721
|
if (id) {
|
|
10522
10722
|
const idError = parser.error(["unexpected-identifier", id], index);
|
|
10523
10723
|
return expr ? ["Sequence", expr, idError] : idError;
|
|
10524
10724
|
}
|
|
10725
|
+
let openDelimiter = parser.peek;
|
|
10525
10726
|
const closeDelimiter = parser.matchEnclosureOpen();
|
|
10526
10727
|
if (closeDelimiter) {
|
|
10728
|
+
parser.parseExpression();
|
|
10729
|
+
parser.match(closeDelimiter);
|
|
10527
10730
|
const enclosureError = parser.error(
|
|
10528
|
-
["
|
|
10731
|
+
["unexpected-open-delimiter", { str: openDelimiter }],
|
|
10529
10732
|
index
|
|
10530
10733
|
);
|
|
10531
10734
|
return expr ? ["Sequence", expr, enclosureError] : enclosureError;
|
|
10532
10735
|
}
|
|
10533
|
-
|
|
10736
|
+
openDelimiter = parser.matchEnclosureClose();
|
|
10534
10737
|
if (openDelimiter) {
|
|
10535
10738
|
const enclosureError = parser.error(
|
|
10536
10739
|
["expected-open-delimiter", { str: openDelimiter }],
|
|
@@ -11678,6 +11881,9 @@ function gcd(a, b) {
|
|
|
11678
11881
|
[a, b] = [b, a % b];
|
|
11679
11882
|
return a < 0 ? -a : a;
|
|
11680
11883
|
}
|
|
11884
|
+
function lcm(a, b) {
|
|
11885
|
+
return a * b / gcd(a, b);
|
|
11886
|
+
}
|
|
11681
11887
|
function factorial(n) {
|
|
11682
11888
|
if (!Number.isInteger(n) || n < 0)
|
|
11683
11889
|
return NaN;
|
|
@@ -13160,11 +13366,79 @@ function domainSetsLibrary() {
|
|
|
13160
13366
|
// src/compute-engine/boxed-expression/abstract-boxed-expression.ts
|
|
13161
13367
|
var import_complex6 = __toESM(require_complex());
|
|
13162
13368
|
|
|
13369
|
+
// src/compute-engine/library/utils.ts
|
|
13370
|
+
function isSymbolDefinition(def) {
|
|
13371
|
+
return !!def && typeof def === "object" && ("domain" in def || "value" in def || "constant" in def);
|
|
13372
|
+
}
|
|
13373
|
+
function isFunctionDefinition(def) {
|
|
13374
|
+
if (def === void 0 || def === null)
|
|
13375
|
+
return false;
|
|
13376
|
+
if (typeof def !== "object")
|
|
13377
|
+
return false;
|
|
13378
|
+
if ("complexity" in def || "numeric" in def || "signature" in def)
|
|
13379
|
+
return true;
|
|
13380
|
+
if (!("domain" in def))
|
|
13381
|
+
return false;
|
|
13382
|
+
if (def.domain === void 0)
|
|
13383
|
+
return false;
|
|
13384
|
+
if (typeof def.domain === "string")
|
|
13385
|
+
return def.domain === "Function";
|
|
13386
|
+
return def.domain.isFunction;
|
|
13387
|
+
}
|
|
13388
|
+
function normalizeLimits(range) {
|
|
13389
|
+
let lower = 1;
|
|
13390
|
+
let upper = lower + MAX_ITERATION;
|
|
13391
|
+
let index = "Nothing";
|
|
13392
|
+
let isFinite2 = true;
|
|
13393
|
+
if (range.head === "Tuple" || range.head === "Triple" || range.head === "Pair" || range.head === "Single") {
|
|
13394
|
+
index = (range.op1.head === "Hold" ? range.op1.op1.symbol : range.op1.symbol) ?? "Nothing";
|
|
13395
|
+
lower = asSmallInteger(range.op2) ?? 1;
|
|
13396
|
+
if (!Number.isFinite(lower))
|
|
13397
|
+
isFinite2 = false;
|
|
13398
|
+
if (range.op3.isNothing || range.op3.isInfinity) {
|
|
13399
|
+
isFinite2 = false;
|
|
13400
|
+
} else {
|
|
13401
|
+
const u = asSmallInteger(range.op3);
|
|
13402
|
+
if (u === null)
|
|
13403
|
+
isFinite2 = false;
|
|
13404
|
+
else {
|
|
13405
|
+
upper = u;
|
|
13406
|
+
if (!Number.isFinite(upper))
|
|
13407
|
+
isFinite2 = false;
|
|
13408
|
+
}
|
|
13409
|
+
}
|
|
13410
|
+
if (!isFinite2 && Number.isFinite(lower))
|
|
13411
|
+
upper = lower + MAX_ITERATION;
|
|
13412
|
+
}
|
|
13413
|
+
return [index, lower, upper, isFinite2];
|
|
13414
|
+
}
|
|
13415
|
+
|
|
13163
13416
|
// src/compute-engine/compile.ts
|
|
13417
|
+
var ComputeEngineFunction = class extends Function {
|
|
13418
|
+
constructor(body) {
|
|
13419
|
+
super("_SYS", "_", `return ${body}`);
|
|
13420
|
+
this.sys = {
|
|
13421
|
+
factorial,
|
|
13422
|
+
gamma,
|
|
13423
|
+
lngamma,
|
|
13424
|
+
gcd,
|
|
13425
|
+
lcm,
|
|
13426
|
+
chop
|
|
13427
|
+
};
|
|
13428
|
+
return new Proxy(this, {
|
|
13429
|
+
apply: (target, thisArg, argumentsList) => super.apply(thisArg, [this.sys, ...argumentsList]),
|
|
13430
|
+
get: (target, prop) => {
|
|
13431
|
+
if (prop === "toString")
|
|
13432
|
+
return () => body;
|
|
13433
|
+
return target[prop];
|
|
13434
|
+
}
|
|
13435
|
+
});
|
|
13436
|
+
}
|
|
13437
|
+
};
|
|
13164
13438
|
function compileToJavascript(expr) {
|
|
13165
13439
|
const js = compile(expr, expr.freeVars);
|
|
13166
13440
|
try {
|
|
13167
|
-
return new
|
|
13441
|
+
return new ComputeEngineFunction(js);
|
|
13168
13442
|
} catch (e) {
|
|
13169
13443
|
console.error(`${e}
|
|
13170
13444
|
${expr.latex}
|
|
@@ -13185,7 +13459,12 @@ function compile(expr, freeVars = [], prec = 0) {
|
|
|
13185
13459
|
ExponentialE: "Math.E",
|
|
13186
13460
|
I: "Math.I",
|
|
13187
13461
|
NaN: "Number.NaN",
|
|
13188
|
-
ImaginaryUnit: "NaN"
|
|
13462
|
+
ImaginaryUnit: "NaN",
|
|
13463
|
+
Half: "0.5",
|
|
13464
|
+
MachineEpsilon: "Number.EPSILON",
|
|
13465
|
+
GoldenRatio: "((1 + Math.sqrt(5)) / 2)",
|
|
13466
|
+
CatalanConstant: "0.91596559417721901",
|
|
13467
|
+
EulerGamma: "0.57721566490153286"
|
|
13189
13468
|
}[s];
|
|
13190
13469
|
if (result !== void 0)
|
|
13191
13470
|
return result;
|
|
@@ -13214,9 +13493,8 @@ function compile(expr, freeVars = [], prec = 0) {
|
|
|
13214
13493
|
return "";
|
|
13215
13494
|
return `-${compile(arg, freeVars, 3)}`;
|
|
13216
13495
|
}
|
|
13217
|
-
if (h === "Error")
|
|
13218
|
-
|
|
13219
|
-
}
|
|
13496
|
+
if (h === "Error")
|
|
13497
|
+
throw new Error("Error");
|
|
13220
13498
|
if (h === "Sum")
|
|
13221
13499
|
return compileLoop(expr, "+");
|
|
13222
13500
|
if (h === "Product")
|
|
@@ -13224,7 +13502,7 @@ function compile(expr, freeVars = [], prec = 0) {
|
|
|
13224
13502
|
if (h === "Root") {
|
|
13225
13503
|
const arg = expr.op1;
|
|
13226
13504
|
if (arg === null)
|
|
13227
|
-
|
|
13505
|
+
throw new Error("Root: no argument");
|
|
13228
13506
|
const exp2 = expr.op2;
|
|
13229
13507
|
if (exp2 === null)
|
|
13230
13508
|
return `Math.sqrt(${compile(arg, freeVars, 0)})`;
|
|
@@ -13233,24 +13511,63 @@ function compile(expr, freeVars = [], prec = 0) {
|
|
|
13233
13511
|
if (h === "Factorial") {
|
|
13234
13512
|
const arg = expr.op1;
|
|
13235
13513
|
if (arg === null)
|
|
13236
|
-
|
|
13237
|
-
return
|
|
13514
|
+
throw new Error("Factorial: no argument");
|
|
13515
|
+
return `_SYS.factorial(${compile(arg, freeVars)})`;
|
|
13516
|
+
}
|
|
13517
|
+
if (h === "Power") {
|
|
13518
|
+
const arg = expr.op1;
|
|
13519
|
+
if (arg === null)
|
|
13520
|
+
throw new Error("Power: no argument");
|
|
13521
|
+
const exp2 = asFloat(expr.op2);
|
|
13522
|
+
if (exp2 === 0.5)
|
|
13523
|
+
return `Math.sqrt(${compile(arg, freeVars)})`;
|
|
13524
|
+
if (exp2 === 1 / 3)
|
|
13525
|
+
return `Math.cbrt(${compile(arg, freeVars)})`;
|
|
13526
|
+
if (exp2 === 1)
|
|
13527
|
+
return compile(arg, freeVars);
|
|
13528
|
+
if (exp2 === -1)
|
|
13529
|
+
return `1 / ${compile(arg, freeVars)}`;
|
|
13530
|
+
if (exp2 === -0.5)
|
|
13531
|
+
return `1 / Math.sqrt(${compile(arg, freeVars)})`;
|
|
13532
|
+
}
|
|
13533
|
+
if (h === "Square") {
|
|
13534
|
+
const arg = expr.op1;
|
|
13535
|
+
if (arg === null)
|
|
13536
|
+
throw new Error("Square: no argument");
|
|
13537
|
+
return `Math.pow(${compile(arg, freeVars)}, 2)`;
|
|
13238
13538
|
}
|
|
13239
13539
|
const OPS = {
|
|
13240
|
-
Add: ["+",
|
|
13241
|
-
|
|
13242
|
-
|
|
13243
|
-
|
|
13540
|
+
Add: ["+", 11],
|
|
13541
|
+
Negate: ["-", 14],
|
|
13542
|
+
// Unary operator
|
|
13543
|
+
Subtract: ["-", 11],
|
|
13544
|
+
Multiply: ["*", 12],
|
|
13545
|
+
Divide: ["/", 13],
|
|
13546
|
+
Equal: ["===", 8],
|
|
13547
|
+
NotEqual: ["!==", 8],
|
|
13548
|
+
LessEqual: ["<=", 9],
|
|
13549
|
+
GreaterEqual: [">=", 9],
|
|
13550
|
+
Less: ["<", 9],
|
|
13551
|
+
Greater: [">", 9],
|
|
13552
|
+
And: ["&&", 4],
|
|
13553
|
+
Or: ["||", 3],
|
|
13554
|
+
Not: ["!", 14]
|
|
13555
|
+
// Unary operator
|
|
13556
|
+
// Xor: ['^', 6], // That's bitwise XOR, not logical XOR
|
|
13557
|
+
// Possible solution is to use `a ? !b : b` instead of `a ^ b`
|
|
13244
13558
|
};
|
|
13245
13559
|
const op3 = OPS[h];
|
|
13246
13560
|
if (op3 !== void 0) {
|
|
13247
13561
|
const args2 = expr.ops;
|
|
13248
13562
|
if (args2 === null)
|
|
13249
13563
|
return "";
|
|
13250
|
-
|
|
13251
|
-
|
|
13252
|
-
|
|
13253
|
-
|
|
13564
|
+
let resultStr;
|
|
13565
|
+
if (args2.length === 1) {
|
|
13566
|
+
resultStr = `${op3[0]}${compile(args2[0], freeVars, op3[1])}`;
|
|
13567
|
+
} else {
|
|
13568
|
+
resultStr = args2.map((arg) => compile(arg, freeVars, op3[1])).join(` ${op3[0]} `);
|
|
13569
|
+
}
|
|
13570
|
+
return op3[1] < prec ? `(${resultStr})` : resultStr;
|
|
13254
13571
|
}
|
|
13255
13572
|
const fn = {
|
|
13256
13573
|
Abs: "Math.abs",
|
|
@@ -13262,13 +13579,18 @@ function compile(expr, freeVars = [], prec = 0) {
|
|
|
13262
13579
|
Artanh: "Math.atanh",
|
|
13263
13580
|
// Math.cbrt
|
|
13264
13581
|
Ceiling: "Math.ceil",
|
|
13582
|
+
Chop: "_SYS.chop",
|
|
13265
13583
|
Cos: "Math.cos",
|
|
13266
13584
|
Cosh: "Math.cosh",
|
|
13267
13585
|
Exp: "Math.exp",
|
|
13268
13586
|
Floor: "Math.floor",
|
|
13587
|
+
Gamma: "_SYS.gamma",
|
|
13588
|
+
Gcd: "_SYS.gcd",
|
|
13269
13589
|
// Math.hypot
|
|
13590
|
+
Lcm: "_SYS.lcm",
|
|
13270
13591
|
Ln: "Math.log",
|
|
13271
13592
|
Log: "Math.log10",
|
|
13593
|
+
LogGamma: "_SYS.lngamma",
|
|
13272
13594
|
Lb: "Math.log2",
|
|
13273
13595
|
Max: "Math.max",
|
|
13274
13596
|
Min: "Math.min",
|
|
@@ -13302,7 +13624,7 @@ function compile(expr, freeVars = [], prec = 0) {
|
|
|
13302
13624
|
// Erfi: 'Math.erfi',
|
|
13303
13625
|
// Zeta: 'Math.zeta',
|
|
13304
13626
|
// PolyGamma: 'Math.polygamma',
|
|
13305
|
-
// HurwitzZeta: 'Math.hurwitzZeta',
|
|
13627
|
+
// HurwitzZeta: 'Math.hurwitzZeta', $$\zeta (s,a)=\sum _{n=0}^{\infty }{\frac {1}{(n+a)^{s}}}$$
|
|
13306
13628
|
// DirichletEta: 'Math.dirichletEta',
|
|
13307
13629
|
// Beta: 'Math.beta',
|
|
13308
13630
|
// Binomial: 'Math.binomial',
|
|
@@ -13375,7 +13697,7 @@ function compile(expr, freeVars = [], prec = 0) {
|
|
|
13375
13697
|
if (args !== null) {
|
|
13376
13698
|
const result = [];
|
|
13377
13699
|
for (const arg of args)
|
|
13378
|
-
result.push(compile(arg, freeVars
|
|
13700
|
+
result.push(compile(arg, freeVars));
|
|
13379
13701
|
return `${fn}(${result.join(", ")})`;
|
|
13380
13702
|
}
|
|
13381
13703
|
}
|
|
@@ -13384,18 +13706,18 @@ function compile(expr, freeVars = [], prec = 0) {
|
|
|
13384
13706
|
function compileLoop(expr, op3) {
|
|
13385
13707
|
const args = expr.ops;
|
|
13386
13708
|
if (args === null)
|
|
13387
|
-
|
|
13709
|
+
throw new Error("Sum: no arguments");
|
|
13388
13710
|
if (!expr.op1 || !expr.op2)
|
|
13389
|
-
|
|
13711
|
+
throw new Error("Sum: no limits");
|
|
13390
13712
|
const [index, lower, upper, isFinite2] = normalizeLimits(expr.op2);
|
|
13391
13713
|
const fn = compile(expr.op1, [...expr.op1.freeVars, index], 0);
|
|
13392
|
-
return `((
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13714
|
+
return `(() => {
|
|
13715
|
+
let acc = ${op3 === "+" ? "0" : "1"};
|
|
13716
|
+
const fn = (_) => ${fn};
|
|
13717
|
+
for (let i = ${lower}; i <= ${upper}; i++)
|
|
13718
|
+
acc ${op3}= fn({ ..._, ${index}: i });
|
|
13719
|
+
return acc;
|
|
13720
|
+
})()`;
|
|
13399
13721
|
}
|
|
13400
13722
|
|
|
13401
13723
|
// src/compute-engine/boxed-expression/abstract-boxed-expression.ts
|
|
@@ -13723,8 +14045,20 @@ var AbstractBoxedExpression = class {
|
|
|
13723
14045
|
N(_options) {
|
|
13724
14046
|
return this.evaluate();
|
|
13725
14047
|
}
|
|
13726
|
-
compile() {
|
|
13727
|
-
|
|
14048
|
+
compile(to = "javascript", options) {
|
|
14049
|
+
if (to !== "javascript")
|
|
14050
|
+
return void 0;
|
|
14051
|
+
options ?? (options = { optimize: ["simplify", "evaluate"] });
|
|
14052
|
+
let expr = this;
|
|
14053
|
+
if (options.optimize.includes("simplify"))
|
|
14054
|
+
expr = expr.simplify();
|
|
14055
|
+
if (options.optimize.includes("evaluate"))
|
|
14056
|
+
expr = expr.evaluate();
|
|
14057
|
+
try {
|
|
14058
|
+
return compileToJavascript(expr);
|
|
14059
|
+
} catch (e) {
|
|
14060
|
+
}
|
|
14061
|
+
return void 0;
|
|
13728
14062
|
}
|
|
13729
14063
|
};
|
|
13730
14064
|
|
|
@@ -15557,33 +15891,6 @@ function evalSummation(ce, expr, range, mode) {
|
|
|
15557
15891
|
ce.context = savedContext;
|
|
15558
15892
|
return result ?? void 0;
|
|
15559
15893
|
}
|
|
15560
|
-
function normalizeLimits(range) {
|
|
15561
|
-
let lower = 1;
|
|
15562
|
-
let upper = lower + MAX_ITERATION;
|
|
15563
|
-
let index = "Nothing";
|
|
15564
|
-
let isFinite2 = true;
|
|
15565
|
-
if (range.head === "Tuple" || range.head === "Triple" || range.head === "Pair" || range.head === "Single") {
|
|
15566
|
-
index = (range.op1.head === "Hold" ? range.op1.op1.symbol : range.op1.symbol) ?? "Nothing";
|
|
15567
|
-
lower = asSmallInteger(range.op2) ?? 1;
|
|
15568
|
-
if (!Number.isFinite(lower))
|
|
15569
|
-
isFinite2 = false;
|
|
15570
|
-
if (range.op3.isNothing || range.op3.isInfinity) {
|
|
15571
|
-
isFinite2 = false;
|
|
15572
|
-
} else {
|
|
15573
|
-
const u = asSmallInteger(range.op3);
|
|
15574
|
-
if (u === null)
|
|
15575
|
-
isFinite2 = false;
|
|
15576
|
-
else {
|
|
15577
|
-
upper = u;
|
|
15578
|
-
if (!Number.isFinite(upper))
|
|
15579
|
-
isFinite2 = false;
|
|
15580
|
-
}
|
|
15581
|
-
}
|
|
15582
|
-
if (!isFinite2 && Number.isFinite(lower))
|
|
15583
|
-
upper = lower + MAX_ITERATION;
|
|
15584
|
-
}
|
|
15585
|
-
return [index, lower, upper, isFinite2];
|
|
15586
|
-
}
|
|
15587
15894
|
|
|
15588
15895
|
// src/compute-engine/symbolic/negate.ts
|
|
15589
15896
|
var import_complex9 = __toESM(require_complex());
|
|
@@ -19039,7 +19346,7 @@ var ARITHMETIC_LIBRARY = [
|
|
|
19039
19346
|
}
|
|
19040
19347
|
},
|
|
19041
19348
|
Erf: {
|
|
19042
|
-
description: "
|
|
19349
|
+
description: "Error Function",
|
|
19043
19350
|
complexity: 7500
|
|
19044
19351
|
},
|
|
19045
19352
|
Erfc: {
|
|
@@ -19047,7 +19354,7 @@ var ARITHMETIC_LIBRARY = [
|
|
|
19047
19354
|
complexity: 7500
|
|
19048
19355
|
},
|
|
19049
19356
|
Factorial: {
|
|
19050
|
-
description: "
|
|
19357
|
+
description: "Factorial Function",
|
|
19051
19358
|
wikidata: "Q120976",
|
|
19052
19359
|
complexity: 9e3,
|
|
19053
19360
|
signature: {
|
|
@@ -19086,7 +19393,7 @@ var ARITHMETIC_LIBRARY = [
|
|
|
19086
19393
|
wikidata: "Q190573",
|
|
19087
19394
|
complexity: 8e3,
|
|
19088
19395
|
signature: {
|
|
19089
|
-
domain: ["Function", "Number", "Number"
|
|
19396
|
+
domain: ["Function", "Number", "Number"],
|
|
19090
19397
|
N: (ce, ops2) => applyN(
|
|
19091
19398
|
ops2[0],
|
|
19092
19399
|
(x) => gamma(x),
|
|
@@ -19098,7 +19405,7 @@ var ARITHMETIC_LIBRARY = [
|
|
|
19098
19405
|
LogGamma: {
|
|
19099
19406
|
complexity: 8e3,
|
|
19100
19407
|
signature: {
|
|
19101
|
-
domain: ["Function", "Number", "Number"
|
|
19408
|
+
domain: ["Function", "Number", "Number"],
|
|
19102
19409
|
N: (ce, ops2) => applyN(
|
|
19103
19410
|
ops2[0],
|
|
19104
19411
|
(x) => lngamma(x),
|
|
@@ -20141,7 +20448,7 @@ var CORE_LIBRARY = [
|
|
|
20141
20448
|
Apply: {
|
|
20142
20449
|
signature: {
|
|
20143
20450
|
domain: "Function",
|
|
20144
|
-
evaluate: (
|
|
20451
|
+
evaluate: (_ce, ops2) => apply(ops2[0], ops2.slice(1))
|
|
20145
20452
|
}
|
|
20146
20453
|
},
|
|
20147
20454
|
About: { signature: { domain: "Function" } },
|
|
@@ -20153,6 +20460,11 @@ var CORE_LIBRARY = [
|
|
|
20153
20460
|
*/
|
|
20154
20461
|
signature: { domain: "Function" }
|
|
20155
20462
|
},
|
|
20463
|
+
Derivative: {
|
|
20464
|
+
signature: {
|
|
20465
|
+
domain: ["Function", "Function", ["Maybe", "Number"], "Function"]
|
|
20466
|
+
}
|
|
20467
|
+
},
|
|
20156
20468
|
Domain: {
|
|
20157
20469
|
/** Return the domain of an expression */
|
|
20158
20470
|
signature: {
|
|
@@ -20528,7 +20840,7 @@ var LOGIC_LIBRARY = {
|
|
|
20528
20840
|
// expressions into CNF (Conjunctive Normal Form)
|
|
20529
20841
|
// https://en.wikipedia.org/wiki/Conjunctive_normal_form
|
|
20530
20842
|
// using rules (with a rule set that's kinda the inverse of the
|
|
20531
|
-
// logic rules for simplify
|
|
20843
|
+
// logic rules for simplify)
|
|
20532
20844
|
And: {
|
|
20533
20845
|
wikidata: "Q191081",
|
|
20534
20846
|
threadable: true,
|
|
@@ -20602,6 +20914,10 @@ var LOGIC_LIBRARY = {
|
|
|
20602
20914
|
return ops2[1] ? ops2[1].evaluate() : ce.box("Nothing");
|
|
20603
20915
|
return ops2[2] ? ops2[2].evaluate() : ce.box("Nothing");
|
|
20604
20916
|
},
|
|
20917
|
+
// @todo: probably don't need a N() handler. Doesn't make a difference
|
|
20918
|
+
// for the evaluation of booleans. Also, don't need to call N() on the
|
|
20919
|
+
// arguments, the caller should have done that. Same for evaluate()
|
|
20920
|
+
// and simplify() above
|
|
20605
20921
|
N: (ce, ops2) => {
|
|
20606
20922
|
const cond = ops2[0];
|
|
20607
20923
|
if (cond && cond.symbol === "True")
|
|
@@ -22774,26 +23090,6 @@ function makeFunctionDefinition(engine, name, def) {
|
|
|
22774
23090
|
);
|
|
22775
23091
|
}
|
|
22776
23092
|
|
|
22777
|
-
// src/compute-engine/library/utils.ts
|
|
22778
|
-
function isSymbolDefinition(def) {
|
|
22779
|
-
return !!def && typeof def === "object" && ("domain" in def || "value" in def || "constant" in def);
|
|
22780
|
-
}
|
|
22781
|
-
function isFunctionDefinition(def) {
|
|
22782
|
-
if (def === void 0 || def === null)
|
|
22783
|
-
return false;
|
|
22784
|
-
if (typeof def !== "object")
|
|
22785
|
-
return false;
|
|
22786
|
-
if ("complexity" in def || "numeric" in def || "signature" in def)
|
|
22787
|
-
return true;
|
|
22788
|
-
if (!("domain" in def))
|
|
22789
|
-
return false;
|
|
22790
|
-
if (def.domain === void 0)
|
|
22791
|
-
return false;
|
|
22792
|
-
if (typeof def.domain === "string")
|
|
22793
|
-
return def.domain === "Function";
|
|
22794
|
-
return def.domain.isFunction;
|
|
22795
|
-
}
|
|
22796
|
-
|
|
22797
23093
|
// src/compute-engine/library/library.ts
|
|
22798
23094
|
function getStandardLibrary(categories) {
|
|
22799
23095
|
if (categories === "all") {
|
|
@@ -23824,14 +24120,15 @@ var ComputeEngine = class _ComputeEngine {
|
|
|
23824
24120
|
* perform calculations using arbitrary precision floating point numbers.
|
|
23825
24121
|
* Use `"auto"` or `"complex"` to allow calculations on complex numbers.
|
|
23826
24122
|
*
|
|
23827
|
-
* @param options.numericPrecision Specific how many digits of precision
|
|
23828
|
-
* numeric calculations. Default is 100.
|
|
24123
|
+
* @param options.numericPrecision Specific how many digits of precision
|
|
24124
|
+
* for the numeric calculations. Default is 100.
|
|
23829
24125
|
*
|
|
23830
|
-
* @param options.tolerance If the absolute value of the difference of two
|
|
23831
|
-
* is less than `tolerance`, they are considered equal. Used by
|
|
24126
|
+
* @param options.tolerance If the absolute value of the difference of two
|
|
24127
|
+
* numbers is less than `tolerance`, they are considered equal. Used by
|
|
24128
|
+
* `chop()` as well.
|
|
23832
24129
|
*
|
|
23833
|
-
* @param options.defaultDomain If an unknown symbol is encountered, assume
|
|
23834
|
-
*
|
|
24130
|
+
* @param options.defaultDomain If an unknown symbol is encountered, assume
|
|
24131
|
+
* this is its domain. **Default** `ExtendedRealNumber`
|
|
23835
24132
|
*/
|
|
23836
24133
|
constructor(options) {
|
|
23837
24134
|
/** @internal */
|
|
@@ -24773,9 +25070,29 @@ var ComputeEngine = class _ComputeEngine {
|
|
|
24773
25070
|
this.latexSyntax.updateOptions(opts);
|
|
24774
25071
|
}
|
|
24775
25072
|
get jsonSerializationOptions() {
|
|
24776
|
-
if (this._useRawJsonSerializationOptions)
|
|
24777
|
-
return this._rawJsonSerializationOptions
|
|
24778
|
-
|
|
25073
|
+
if (this._useRawJsonSerializationOptions) {
|
|
25074
|
+
return new Proxy(this._rawJsonSerializationOptions, {
|
|
25075
|
+
get(options, prop) {
|
|
25076
|
+
if (!(prop in options))
|
|
25077
|
+
return void 0;
|
|
25078
|
+
return options[prop];
|
|
25079
|
+
}
|
|
25080
|
+
});
|
|
25081
|
+
}
|
|
25082
|
+
const self = this;
|
|
25083
|
+
return new Proxy(this._jsonSerializationOptions, {
|
|
25084
|
+
get(options, prop) {
|
|
25085
|
+
if (!(prop in options))
|
|
25086
|
+
return void 0;
|
|
25087
|
+
return options[prop];
|
|
25088
|
+
},
|
|
25089
|
+
set(options, prop, value) {
|
|
25090
|
+
if (!(prop in options))
|
|
25091
|
+
return false;
|
|
25092
|
+
self.jsonSerializationOptions = { [prop]: value };
|
|
25093
|
+
return true;
|
|
25094
|
+
}
|
|
25095
|
+
});
|
|
24779
25096
|
}
|
|
24780
25097
|
set jsonSerializationOptions(val) {
|
|
24781
25098
|
if (val.exclude)
|
|
@@ -24891,10 +25208,10 @@ var ComputeEngine = class _ComputeEngine {
|
|
|
24891
25208
|
};
|
|
24892
25209
|
|
|
24893
25210
|
// src/compute-engine.ts
|
|
24894
|
-
var version = "0.
|
|
25211
|
+
var version = "0.14.0";
|
|
24895
25212
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
24896
25213
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
24897
|
-
version: "0.
|
|
25214
|
+
version: "0.14.0"
|
|
24898
25215
|
};
|
|
24899
25216
|
export {
|
|
24900
25217
|
ComputeEngine,
|