Skip to content

Commit

Permalink
[new-syntax] stmts-next/ -- TopLevelEvaluate
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Sep 19, 2023
1 parent a93d5c6 commit 709f598
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
5 changes: 4 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# new-syntax

[new-syntax] `stmts-next/` -- `TopLevelEvaluate`
`formatExp`

[new-syntax] `stmts-next/` -- fix `TopLevelEvaluate` by `formatExp`

[new-syntax] `stmts-next/` -- `TopLevelLet`

[new-syntax] `Exp` -- `syntax-next/`
Expand Down
2 changes: 1 addition & 1 deletion src/lang/stmts-next/DefineFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class DefineFunction implements Stmt {
} catch (error) {
throw appendReport(error, {
message: [
`[Define.execute] I fail to define word.`,
`[DefineFunction.execute] I fail to define word.`,
``,
` word: ${this.name}`,
].join("\n"),
Expand Down
2 changes: 1 addition & 1 deletion src/lang/stmts-next/DefineType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class DefineType implements Stmt {
} catch (error) {
throw appendReport(error, {
message: [
`[DefineNode.execute] I fail to define node.`,
`[DefineType.execute] I fail to define node.`,
``,
` node name: ${this.name}`,
].join("\n"),
Expand Down
32 changes: 32 additions & 0 deletions src/lang/stmts-next/TopLevelEvaluate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { appendReport } from "../errors/appendReport.js"
import { Exp } from "../exp/Exp.js"
import { Mod } from "../mod/index.js"
import { Span } from "../span/index.js"
import { Stmt } from "../stmt/index.js"

export class TopLevelEvaluate implements Stmt {
constructor(
public exp: Exp,
public span: Span,
) {}

async execute(mod: Mod): Promise<void> {
try {
// compose(mod, mod.env, this.word, {
// checking: mod.checking,
// })
} catch (error) {
throw appendReport(error, {
message: [
`[TopLevelEvaluate.execute] I fail to evaluate top level exp.`,
``,
// ` exp: ${formatExp(this.exp)}`,
].join("\n"),
context: {
span: this.span,
text: mod.text,
},
})
}
}
}
1 change: 1 addition & 0 deletions src/lang/stmts-next/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from "./DefineNode"
export * from "./DefineRule"
export * from "./DefineType"
export * from "./Parameter"
export * from "./TopLevelEvaluate"

0 comments on commit 709f598

Please sign in to comment.