Start MathPage class
This commit is contained in:
parent
189439227f
commit
8f42f771d8
33
src/support/page.ts
Normal file
33
src/support/page.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import {MathStatement} from './parse'
|
||||
import * as math from 'mathjs'
|
||||
|
||||
export class MathPage {
|
||||
protected statements: Record<string, MathStatement> = {}
|
||||
|
||||
constructor(
|
||||
public readonly id: string,
|
||||
) {}
|
||||
|
||||
addStatement(statement: MathStatement): this {
|
||||
this.statements[statement.id] = statement
|
||||
return this
|
||||
}
|
||||
|
||||
symbols(): math.SymbolNode[] {
|
||||
return Object.values(this.statements)
|
||||
.map(x => x.symbols())
|
||||
.reduce((carry, current) => current.concat(carry), [])
|
||||
}
|
||||
|
||||
defines(): math.SymbolNode[] {
|
||||
return Object.values(this.statements)
|
||||
.map(x => x.defines())
|
||||
.reduce((carry, current) => current.concat(carry), [])
|
||||
}
|
||||
|
||||
uses(): math.SymbolNode[] {
|
||||
return Object.values(this.statements)
|
||||
.map(x => x.uses())
|
||||
.reduce((carry, current) => current.concat(carry), [])
|
||||
}
|
||||
}
|
@ -253,6 +253,7 @@ export class LValSymbolWalk extends SymbolWalk {
|
||||
|
||||
export class MathStatement {
|
||||
constructor(
|
||||
public readonly id: string,
|
||||
public readonly raw: string,
|
||||
) {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user