|
|
- export type Program = Array<Decl | Stmt>
-
- // Declarations
- export type Decl = VarDecl
-
- export type VarDecl = ADecl<"var", {
- type: Type,
- }>
-
- type ADecl<Ty, Args> = {
- type: "decl",
- decl_type: Ty,
- attrs: Array<Attr>,
- name: string,
- args: Args,
- }
-
- // Statements
- export type Stmt = AssignStmt
-
- export type AssignStmt = AStmt<"assign", {
- name: string,
- expr: Expr,
- }>
-
- type AStmt<Ty, Args> = {
- type: "stmt",
- stmt_type: Ty,
- args: Args,
- }
-
- // Expressions
- export type Expr = number
-
- // Attributes
- export type Attr = {
- name: string,
- args: Array<string | number>,
- }
-
- // Types
- export type Type = PrimitiveType
-
- export type PrimitiveType = "s8" | "u8" | "u16"
|