Skip to content

Commit

Permalink
update stmt names -- drop Def prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Aug 5, 2023
1 parent 526a2fa commit 2e9d96d
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 0 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
update stmt names -- drop `Def` prefix

[maybe] [syntax] rename `define` to `fn`

# type

`define` -- can be a sequence of words that build a net
Expand Down
2 changes: 1 addition & 1 deletion src/lang/stmts/Defn.ts → src/lang/stmts/Define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Span } from "../span"
import { Stmt } from "../stmt"
import { Word } from "../word"

export class Defn implements Stmt {
export class Define implements Stmt {
constructor(
public name: string,
public words: Array<Word>,
Expand Down
2 changes: 1 addition & 1 deletion src/lang/stmts/Defnode.ts → src/lang/stmts/DefineNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { define } from "../mod/define"
import { Span } from "../span"
import { Stmt } from "../stmt"

export class Defnode implements Stmt {
export class DefineNode implements Stmt {
constructor(
public name: string,
public input: Array<PortExp>,
Expand Down
2 changes: 1 addition & 1 deletion src/lang/stmts/Defrule.ts → src/lang/stmts/DefineRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Span } from "../span"
import { Stmt } from "../stmt"
import { Word } from "../word"

export class Defrule implements Stmt {
export class DefineRule implements Stmt {
constructor(
public start: string,
public end: string,
Expand Down
2 changes: 1 addition & 1 deletion src/lang/stmts/Deftype.ts → src/lang/stmts/DefineType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { define } from "../mod/define"
import { Span } from "../span"
import { Stmt } from "../stmt"

export class Deftype implements Stmt {
export class DefineType implements Stmt {
constructor(
public name: string,
public arity: number,
Expand Down
8 changes: 4 additions & 4 deletions src/lang/stmts/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from "./Defn"
export * from "./Defnode"
export * from "./Defrule"
export * from "./Deftype"
export * from "./Define"
export * from "./DefineNode"
export * from "./DefineRule"
export * from "./DefineType"
export * from "./Run"
export * from "./Show"
12 changes: 8 additions & 4 deletions src/lang/syntax/matchers/stmt_matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,27 @@ import * as matchers from "../matchers"
export function stmt_matcher(tree: pt.Tree): Stmt {
return pt.matcher<Stmt>({
"stmt:node": ({ name, input, output }, { span }) =>
new Stmts.Defnode(
new Stmts.DefineNode(
pt.str(name),
matchers.ports_matcher(input),
matchers.ports_matcher(output),
span,
),
"stmt:rule": ({ start, end, words }, { span }) =>
new Stmts.Defrule(
new Stmts.DefineRule(
pt.str(start),
pt.str(end),
matchers.words_matcher(words),
span,
),
"stmt:define": ({ name, words }, { span }) =>
new Stmts.Defn(pt.str(name), matchers.words_matcher(words), span),
new Stmts.Define(pt.str(name), matchers.words_matcher(words), span),
"stmt:type": ({ name, arity }, { span }) =>
new Stmts.Deftype(pt.str(name), Number.parseFloat(pt.str(arity)), span),
new Stmts.DefineType(
pt.str(name),
Number.parseFloat(pt.str(arity)),
span,
),
"stmt:show": ({ words }, { span }) =>
new Stmts.Show(matchers.words_matcher(words), span),
"stmt:run": ({ words }, { span }) =>
Expand Down

0 comments on commit 2e9d96d

Please sign in to comment.