diff --git a/TODO.md b/TODO.md index 6f76830e..d71ae0f6 100644 --- a/TODO.md +++ b/TODO.md @@ -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 diff --git a/src/lang/word/Word.ts b/src/lang/word/Word.ts index 76a6312b..77c7623b 100644 --- a/src/lang/word/Word.ts +++ b/src/lang/word/Word.ts @@ -2,6 +2,7 @@ import { Span } from "../span" export type Word = | Call + | LiteralNode | Builtin | Local | PortPush @@ -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" diff --git a/src/lang/word/formatWord.ts b/src/lang/word/formatWord.ts index 1820d55b..285b4ec8 100644 --- a/src/lang/word/formatWord.ts +++ b/src/lang/word/formatWord.ts @@ -6,6 +6,10 @@ export function formatWord(word: Word): string { return word.name } + case "LiteralNode": { + return `(${word.name})` + } + case "Builtin": { return `@${word.name}` }