Fixing up old stuff, cleaning up and standardizing AST.
This commit is contained in:
parent
d969661b33
commit
666d611e95
4 changed files with 645 additions and 399 deletions
|
@ -103,27 +103,28 @@ function functionToLatex(f, args) {
|
|||
* @param {string} vari - variable to convert
|
||||
* @returns {string}
|
||||
*/
|
||||
function variable(vari) {
|
||||
let unicodechars = ["α","β","γ","δ","ε","ζ","η",
|
||||
"π","θ","κ","λ","μ","ξ","ρ",
|
||||
"ς","σ","τ","φ","χ","ψ","ω",
|
||||
"Γ","Δ","Θ","Λ","Ξ","Π","Σ",
|
||||
"Φ","Ψ","Ω","ₐ","ₑ","ₒ","ₓ",
|
||||
"ₕ","ₖ","ₗ","ₘ","ₙ","ₚ","ₛ",
|
||||
"ₜ","¹","²","³","⁴","⁵","⁶",
|
||||
"⁷","⁸","⁹","⁰","₁","₂","₃",
|
||||
"₄","₅","₆","₇","₈","₉","₀",
|
||||
"pi"]
|
||||
let equivalchars = ["\\alpha","\\beta","\\gamma","\\delta","\\epsilon","\\zeta","\\eta",
|
||||
"\\pi","\\theta","\\kappa","\\lambda","\\mu","\\xi","\\rho",
|
||||
"\\sigma","\\sigma","\\tau","\\phi","\\chi","\\psi","\\omega",
|
||||
"\\Gamma","\\Delta","\\Theta","\\Lambda","\\Xi","\\Pi","\\Sigma",
|
||||
"\\Phy","\\Psi","\\Omega","{}_{a}","{}_{e}","{}_{o}","{}_{x}",
|
||||
"{}_{h}","{}_{k}","{}_{l}","{}_{m}","{}_{n}","{}_{p}","{}_{s}",
|
||||
"{}_{t}","{}^{1}","{}^{2}","{}^{3}","{}^{4}","{}^{5}","{}^{6}",
|
||||
"{}^{7}","{}^{8}","{}^{9}","{}^{0}","{}_{1}","{}_{2}","{}_{3}",
|
||||
"{}_{4}","{}_{5}","{}_{6}","{}_{7}","{}_{8}","{}_{9}","{}_{0}",
|
||||
|
||||
let unicodechars = ["α","β","γ","δ","ε","ζ","η",
|
||||
"π","θ","κ","λ","μ","ξ","ρ",
|
||||
"ς","σ","τ","φ","χ","ψ","ω",
|
||||
"Γ","Δ","Θ","Λ","Ξ","Π","Σ",
|
||||
"Φ","Ψ","Ω","ₐ","ₑ","ₒ","ₓ",
|
||||
"ₕ","ₖ","ₗ","ₘ","ₙ","ₚ","ₛ",
|
||||
"ₜ","¹","²","³","⁴","⁵","⁶",
|
||||
"⁷","⁸","⁹","⁰","₁","₂","₃",
|
||||
"₄","₅","₆","₇","₈","₉","₀",
|
||||
"pi"]
|
||||
let equivalchars = ["\\alpha","\\beta","\\gamma","\\delta","\\epsilon","\\zeta","\\eta",
|
||||
"\\pi","\\theta","\\kappa","\\lambda","\\mu","\\xi","\\rho",
|
||||
"\\sigma","\\sigma","\\tau","\\phi","\\chi","\\psi","\\omega",
|
||||
"\\Gamma","\\Delta","\\Theta","\\Lambda","\\Xi","\\Pi","\\Sigma",
|
||||
"\\Phy","\\Psi","\\Omega","{}_{a}","{}_{e}","{}_{o}","{}_{x}",
|
||||
"{}_{h}","{}_{k}","{}_{l}","{}_{m}","{}_{n}","{}_{p}","{}_{s}",
|
||||
"{}_{t}","{}^{1}","{}^{2}","{}^{3}","{}^{4}","{}^{5}","{}^{6}",
|
||||
"{}^{7}","{}^{8}","{}^{9}","{}^{0}","{}_{1}","{}_{2}","{}_{3}",
|
||||
"{}_{4}","{}_{5}","{}_{6}","{}_{7}","{}_{8}","{}_{9}","{}_{0}",
|
||||
"\\pi"]
|
||||
function variable(vari) {
|
||||
for(let i = 0; i < unicodechars.length; i++) {
|
||||
//console.log(vari, unicodechars[i], equivalchars[i]);
|
||||
if(vari.includes(unicodechars[i]))
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -25,6 +25,7 @@
|
|||
class ExpressionBuilder {
|
||||
constructor(tokenizer) {
|
||||
this.tokenizer = tokenizer;
|
||||
this.stack = []
|
||||
}
|
||||
|
||||
parseExpression(delimitors = '') {
|
||||
|
|
|
@ -71,15 +71,15 @@ const FUNCTIONS_LIST = Object.keys(FUNCTIONS);
|
|||
// TODO: Complete
|
||||
const DERIVATIVES = {
|
||||
"abs": "abs(<1>)/<1>",
|
||||
"acos": "-derivate(<1>)/sqrt(1-(<1>)^2)",
|
||||
"acosh": "derivate(<1>)/sqrt((<1>)^2-1)",
|
||||
"asin": "derivate(<1>)/sqrt(1-(<1>)^2)",
|
||||
"asinh": "derivate(<1>)/sqrt((<1>)^2+1)",
|
||||
"atan": "derivate(<1>)/(1+(<1>)^2)",
|
||||
"acos": "-derivative(<1>)/sqrt(1-(<1>)^2)",
|
||||
"acosh": "derivative(<1>)/sqrt((<1>)^2-1)",
|
||||
"asin": "derivative(<1>)/sqrt(1-(<1>)^2)",
|
||||
"asinh": "derivative(<1>)/sqrt((<1>)^2+1)",
|
||||
"atan": "derivative(<1>)/(1+(<1>)^2)",
|
||||
"atan2": "",
|
||||
}
|
||||
const INTEGRALS = {
|
||||
"abs": "integrate(<1>)*sign(<1>)",
|
||||
"abs": "integral(<1>)*sign(<1>)",
|
||||
"acos": "",
|
||||
"acosh": "",
|
||||
"asin": "",
|
||||
|
|
Loading…
Reference in a new issue