WIP: math parser

This commit is contained in:
2025-02-03 17:13:32 +01:00
parent 3ffb7f8181
commit b3ac5ee075
3 changed files with 100 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
type Token = number | '+' | '-' | '*' | '/' | '(' | ')';
type ASTNode = {
type: string,
}
type OperatorNode = {
type: 'operator',
value: '+' | '-' | '*' | '/',
left: ASTNode,
right: ASTNode,
}
type NumberNode = {
type: 'number',
value: number,
}
type GroupNode = {
type: 'group',
value: ASTNode,
}
type NegationNode = {
type: 'negation',
value: ASTNode,
}
export function calc(expression: string): number {
// evaluate `expression` and return result
return 0;
}