Documentation
¶
Index ¶
- func BuildLexer() *lexer.StatefulDefinition
- func BuildParser[T any]() *participle.Parser[T]
- type AccessorExpr
- type AddExpr
- type AndExpr
- type AssignStmt
- type CastingExpr
- type ComparisonExpr
- type CompoundStmt
- type DeclStmt
- type Declarator
- type EqualityExpr
- type ExclusiveOrExpr
- type Expr
- type ExprStmt
- type FnCallExpr
- type Function
- type IfStmt
- type InclusiveOrExpr
- type IndexExpr
- type InternalString
- type LogicalExpr
- type Module
- type MulExpr
- type Parser
- type PostfixExpr
- type PostfixExprTick
- type PrefixExpr
- type PrimaryExpr
- type ReturnStmt
- type ShiftExpr
- type SizeOfExpr
- type Stmt
- type Struct
- type StructExpr
- type StructField
- type Type
- type TypeDef
- type UnaryExpr
- type WhileStmt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildLexer ¶
func BuildLexer() *lexer.StatefulDefinition
func BuildParser ¶
func BuildParser[T any]() *participle.Parser[T]
Types ¶
type AccessorExpr ¶
type AccessorExpr struct { Head *IndexExpr `@@` Tail []struct { Op string `@("-" ">" | ".")` Field string `@Ident` Pos lexer.Position } `@@*` Pos lexer.Position }
func (*AccessorExpr) Transform ¶
func (ae *AccessorExpr) Transform(scope ast.ScopeLike) ast.ExpressionLike
type AddExpr ¶
type AddExpr struct { Head *MulExpr `@@` Tail []struct { Op string `@("+" | "-")` Expr *MulExpr `@@` Pos lexer.Position } `@@*` Pos lexer.Position }
removing left recursion, source: https://github.com/alecthomas/participle/blob/master/_examples/expr3/main.go#L33
type AndExpr ¶
type AndExpr struct { Left *EqualityExpr `@@` Op string `[ @("&")` Right *AndExpr `@@ ]` Pos lexer.Position }
type AssignStmt ¶
func (*AssignStmt) Transform ¶
func (a *AssignStmt) Transform(scope ast.ScopeLike) ast.StatementLike
type CastingExpr ¶
type CastingExpr struct { Type *Type `[ "(" @@ ")" ]` Expr *SizeOfExpr `@@` Pos lexer.Position }
func (*CastingExpr) Transform ¶
func (ce *CastingExpr) Transform(scope ast.ScopeLike) ast.ExpressionLike
type ComparisonExpr ¶
type ComparisonExpr struct { Left *ShiftExpr `@@` Op string `[ @("<" "=" | ">" "=" | "<" | ">")` Right *ComparisonExpr `@@ ]` Pos lexer.Position }
func (*ComparisonExpr) Transform ¶
func (ce *ComparisonExpr) Transform(scope ast.ScopeLike) ast.ExpressionLike
type CompoundStmt ¶
func (*CompoundStmt) Transform ¶
func (c *CompoundStmt) Transform(scope ast.ScopeLike) ast.StatementLike
type DeclStmt ¶
type DeclStmt struct { Declarator *Declarator `@@` Expr *Expr `[ "=" @@ ] ";"` Pos lexer.Position }
type Declarator ¶
type EqualityExpr ¶
type EqualityExpr struct { Left *ComparisonExpr `@@` Op string `[ @("=" "=" | "!" "=")` Right *EqualityExpr `@@ ]` Pos lexer.Position }
func (*EqualityExpr) Transform ¶
func (ee *EqualityExpr) Transform(scope ast.ScopeLike) ast.ExpressionLike
type ExclusiveOrExpr ¶
type ExclusiveOrExpr struct { Left *AndExpr `@@` Op string `[ @("^")` Right *ExclusiveOrExpr `@@ ]` Pos lexer.Position }
func (*ExclusiveOrExpr) Transform ¶
func (ea *ExclusiveOrExpr) Transform(scope ast.ScopeLike) ast.ExpressionLike
type Expr ¶
type Expr struct { LogicalExpr *LogicalExpr `@@` Pos lexer.Position }
type FnCallExpr ¶
type FnCallExpr struct { Ident string `@Ident` Args []*Expr `"(" (@@ ("," @@)*)? ")"` Pos lexer.Position }
func (*FnCallExpr) Transform ¶
func (fce *FnCallExpr) Transform(scope ast.ScopeLike) ast.ExpressionLike
type Function ¶
type Function struct { Declarator *Declarator `@@ "("` Params []*Declarator `( @@ ( "," @@ )* )?` Variadic bool `@( "," "." "." "." )? ")"` Body *CompoundStmt `( @@` OnlyDeclare bool `| @";" )` Pos lexer.Position }
type IfStmt ¶
type InclusiveOrExpr ¶
type InclusiveOrExpr struct { Left *ExclusiveOrExpr `@@` Op string `[ @("|")` Right *InclusiveOrExpr `@@ ]` Pos lexer.Position }
func (*InclusiveOrExpr) Transform ¶
func (io *InclusiveOrExpr) Transform(scope ast.ScopeLike) ast.ExpressionLike
type IndexExpr ¶
type InternalString ¶
type InternalString struct {
Parts []string `( @Escaped | @Chars )*`
}
type LogicalExpr ¶
type LogicalExpr struct { Left *InclusiveOrExpr `@@` Op string `[ @("&" "&" | "|" "|")` Right *LogicalExpr `@@ ]` Pos lexer.Position }
func (*LogicalExpr) Transform ¶
func (le *LogicalExpr) Transform(scope ast.ScopeLike) ast.ExpressionLike
type MulExpr ¶
type MulExpr struct { Head *CastingExpr `@@` Tail []struct { Op string `@("*" | "/" | "%")` Expr *CastingExpr `@@` Pos lexer.Position } `@@*` Pos lexer.Position }
type Parser ¶
type Parser struct { }
type PostfixExpr ¶
type PostfixExpr struct { Next *AccessorExpr `@@` Postfix *PostfixExprTick `@@` Pos lexer.Position }
PO -> PO o | AE removing left recursion because participle doesn't support it: https://cyberzhg.github.io/toolbox/left_rec PO -> AE PO' PO' -> o PO' | ε
func (*PostfixExpr) Transform ¶
func (pe *PostfixExpr) Transform(scope ast.ScopeLike) ast.ExpressionLike
type PostfixExprTick ¶
type PostfixExprTick struct { Op string `[ @("+" "+" | "-" "-")` Expr *PostfixExprTick `@@ ]` Pos lexer.Position }
func (*PostfixExprTick) Transform ¶
func (pet *PostfixExprTick) Transform(scope ast.ScopeLike, ae ast.ExpressionLike) ast.ExpressionLike
type PrefixExpr ¶
type PrefixExpr struct { Op string `( @( "+" "+" | "-" "-" | "!" | "-" | "*" | "&" )` Expr *PrefixExpr `@@` Next *PostfixExpr `| @@ )` Pos lexer.Position }
func (*PrefixExpr) Transform ¶
func (pe *PrefixExpr) Transform(scope ast.ScopeLike) ast.ExpressionLike
type PrimaryExpr ¶
type PrimaryExpr struct { // StructExpr must be before Ident, because StructExpr starts with Ident Struct *StructExpr `@@` Variable string `| @Ident` Sign string `| @("+" | "-")?` Number string `@Number` Char string `| ( CharStart @SingleChar CharEnd )` // we need to use a struct here, because we want to allow empty strings String *InternalString `| ( StringStart @@ StringEnd )` Expr *Expr `| "(" @@ ")"` Pos lexer.Position }
func (*PrimaryExpr) Transform ¶
func (pe *PrimaryExpr) Transform(scope ast.ScopeLike) ast.ExpressionLike
type ReturnStmt ¶
func (*ReturnStmt) Transform ¶
func (r *ReturnStmt) Transform(scope ast.ScopeLike) ast.StatementLike
type ShiftExpr ¶
type SizeOfExpr ¶
type SizeOfExpr struct { Head *PrefixExpr `@@` Type *Type `| "sizeof" "(" @@ ")"` Expr *PrefixExpr `| "sizeof" @@` Pos lexer.Position }
func (*SizeOfExpr) Transform ¶
func (soe *SizeOfExpr) Transform(scope ast.ScopeLike) ast.ExpressionLike
type Stmt ¶
type Stmt struct { DeclStmt *DeclStmt `@@` AssignStmt *AssignStmt `| @@` ExprStmt *ExprStmt `| @@` ReturnStmt *ReturnStmt `| @@` CompoundStmt *CompoundStmt `| @@` IfStmt *IfStmt `| @@` WhileStmt *WhileStmt `| @@` Pos lexer.Position }
type Struct ¶
type Struct struct {
Fields []*Declarator `"struct" "{" @@ ( "," @@ )* "," "}"`
}
type StructExpr ¶
type StructExpr struct { Alias string `@Ident` StructFields []*StructField `"{" @@ ( "," @@ )* "," "}"` }
type StructField ¶
type Type ¶
type Type struct { Lengths []int `( "[" @Number "]" )*` Struct *Struct `( @@` // must match lexer.go BasicType AND ast.Type Basic string `| @("bool" | "void" | "i8" | "i16" | "i32" | "i64" | "u8" | "u16" | "u32" | "u64" | "f32" | "f64")` Alias string `| @Ident )` Pointers string `@"*"*` Pos lexer.Position }
type UnaryExpr ¶
type UnaryExpr struct { // SizeOfExpr *SizeOfExpr `@@` FnCallExpr *FnCallExpr `@@` PrimaryExpr *PrimaryExpr `| @@` Pos lexer.Position }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.