Documentation
¶
Overview ¶
Package parser defines the AST node types for MX Script and the recursive-descent parser that builds an AST from a token stream.
Package parser implements a recursive-descent parser that converts a stream of tokens (produced by the lexer) into an MX Script AST.
Index ¶
- type ArrayLit
- type AssignStmt
- type BinaryExpr
- type BoolLit
- type BreakStmt
- type CallExpr
- type ContinueStmt
- type Expr
- type ExprStmt
- type FnDecl
- type FnLit
- type Identifier
- type IfStmt
- type ImportStmt
- type IndexExpr
- type LetStmt
- type LoopStmt
- type MatchArm
- type MatchExpr
- type MemberExpr
- type MiddlewareDecl
- type Node
- type NullLit
- type NumberLit
- type ObjectLit
- type ObjectPair
- type ParseError
- type Parser
- type Program
- type ReturnStmt
- type RouteDecl
- type ServerBlock
- type SpreadExpr
- type StaticStmt
- type Stmt
- type StringLit
- type TryStmt
- type UnaryExpr
- type UseStmt
- type WhileStmt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssignStmt ¶
type BinaryExpr ¶
type BreakStmt ¶ added in v0.2.0
type BreakStmt struct {
// contains filtered or unexported fields
}
BreakStmt exits the nearest enclosing loop.
type ContinueStmt ¶ added in v0.2.0
type ContinueStmt struct {
// contains filtered or unexported fields
}
ContinueStmt jumps to the next iteration of the nearest enclosing loop.
type Expr ¶
type Expr interface {
Node
// contains filtered or unexported methods
}
Expr is the type implemented by all expression nodes.
type FnDecl ¶
type Identifier ¶
type Identifier struct {
Name string
// contains filtered or unexported fields
}
type ImportStmt ¶
type ImportStmt struct {
Path string
// contains filtered or unexported fields
}
type LoopStmt ¶
type LoopStmt struct {
Iterable Expr
Var string
Body []Stmt
// contains filtered or unexported fields
}
LoopStmt is `loop iterable as item { ... }` — iterates arrays / numeric ranges.
type MatchExpr ¶ added in v0.5.0
MatchExpr is `match subject { p1 => e1, p2 => e2, _ => e3 }`. Arms are tested top-to-bottom; the first matching arm's body is the result. A pattern is either an expression (compared with `==`) or the bare identifier `_` which matches anything.
type MemberExpr ¶
type MiddlewareDecl ¶
type ObjectLit ¶
type ObjectLit struct {
Pairs []ObjectPair
// contains filtered or unexported fields
}
type ObjectPair ¶
type ParseError ¶ added in v0.2.0
ParseError carries a structured location so the CLI can render source-context errors with a caret pointer.
func (*ParseError) Error ¶ added in v0.2.0
func (e *ParseError) Error() string
type ReturnStmt ¶
type ReturnStmt struct {
Value Expr // nil if `return` with no value
// contains filtered or unexported fields
}
type RouteDecl ¶
type ServerBlock ¶
type ServerBlock struct {
Settings []ObjectPair
// contains filtered or unexported fields
}
type SpreadExpr ¶ added in v0.3.0
type SpreadExpr struct {
Inner Expr
// contains filtered or unexported fields
}
SpreadExpr wraps an expression that should be expanded inline inside an array literal, an object literal, or a call argument list.
type StaticStmt ¶ added in v0.3.0
type StaticStmt struct {
Dir string
Mount string // URL prefix; defaults to "/" if not specified
// contains filtered or unexported fields
}
StaticStmt declares a static-file mount point.
static "./public" // serves files from ./public at / static "./assets" at "/cdn" // serves files from ./assets at /cdn
type Stmt ¶
type Stmt interface {
Node
// contains filtered or unexported methods
}
Stmt is the type implemented by all statement / top-level declaration nodes.