Skip to content

Commit

Permalink
LiteralNode as a word
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Sep 13, 2023
1 parent 91075d0 commit 6500851
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
`Node` as word
`Ports` as builtin
`LiteralNode` -- syntax

`@ports` as built-in to spread ports of a node
`@apply` as built-in to apply a node

remove syntax of rearrange
update docs about using `@ports` to do rearrange

Expand Down
8 changes: 8 additions & 0 deletions src/lang/word/Word.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Span } from "../span"

export type Word =
| Call
| LiteralNode
| Builtin
| Local
| PortPush
Expand All @@ -17,6 +18,13 @@ export type Call = {
span: Span
}

export type LiteralNode = {
"@type": "Word"
"@kind": "LiteralNode"
name: string
span: Span
}

export type Builtin = {
"@type": "Word"
"@kind": "Builtin"
Expand Down
4 changes: 4 additions & 0 deletions src/lang/word/formatWord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export function formatWord(word: Word): string {
return word.name
}

case "LiteralNode": {
return `(${word.name})`
}

case "Builtin": {
return `@${word.name}`
}
Expand Down

0 comments on commit 6500851

Please sign in to comment.