Implement adding expression and var decls

This commit is contained in:
2022-04-09 17:48:41 -05:00
parent 18252912a9
commit 4a3e92b910
8 changed files with 296 additions and 17 deletions

View File

@@ -16,6 +16,11 @@ export class MathPage {
public readonly id: string,
) {}
/** Get all defined statements. */
getStatements(): MathStatement[] {
return Object.values(this.statements)
}
/** Get a statement by ID if it exists. */
getStatement(id: StatementID): Maybe<MathStatement> {
return this.statements[id]

View File

@@ -324,4 +324,18 @@ export class MathStatement {
uses(): math.SymbolNode[] {
return (new RValSymbolWalk()).walk(this.parse())
}
/** Returns true if the definition is correctly non-recursive. */
isNotRecursive(): boolean {
const uses = this.uses()
const defines = this.defines()
for ( const define of defines ) {
if ( uses.some(x => x.name === define.name) ) {
return false
}
}
return true
}
}