Documentation ¶
Index ¶
- Variables
- type Argument
- type ArgumentList
- type BlockStatement
- type CompilationUnit
- type Entry
- type Expression
- type ExpressionStatement
- type ExpressionWithIdentifier
- type HashIdentifier
- type HashObject
- type HashSymbol
- type Identifier
- type IdentifierNameExpression
- type IfStatementOrExpression
- type IfStatementOrExpressionConditionExpression
- type InvocationExpression
- type InvocationExpressionWithParen
- type LambdaExpression
- type Literal
- type MemberAccessExpression
- type MemberAccessExpressionTExpression
- type Pair
- type Statement
- type StatementInternal
- type Value
- type ValueExpression
Constants ¶
This section is empty.
Variables ¶
View Source
var Keywords = []string{
"do",
"if",
"end",
"true",
"false",
"nil",
}
View Source
var Parser = participle.MustBuild[Entry]( participle.Lexer(RubyLikeLexer), participle.Elide("Comment", "Whitespace"), participle.Unquote("String"), participle.UseLookahead(2), )
View Source
var RubyLikeLexer = lexer.MustSimple([]lexer.SimpleRule{
{"True", "true"},
{"False", "false"},
{"Null", "nil"},
{"Number", `\d+(?:\.\d+)?`},
{"Identifier", `[A-Za-z_][A-Za-z0-9_]*`},
{"HashIdentifier", `[A-Za-z_][A-Za-z0-9_]+:`},
{"HashKeyword", `[A-Za-z0-9_]+`},
{`String`, `'[^']*'|"[^"]*"`},
{"Comment", `#.*(\n)?`},
{"Whitespace", `[ \t]+`},
{"NewLine", `[\r\n]+`},
{"COLON", ":"},
{"OPEN_PAREN", `\(`},
{"CLOSE_PAREN", `\)`},
{"OPEN_BRACKET", "{"},
{"CLOSE_BRACKET", "}"},
{"COMMA", ","},
})
Functions ¶
This section is empty.
Types ¶
type Argument ¶
type Argument struct { Identifier *string `parser:"(@Identifier ':')?"` Expression Expression `parser:"@@"` }
type ArgumentList ¶
type ArgumentList struct { Argument []Argument `parser:"(@@ (',' @@)*)?"` LambdaExpression *LambdaExpression `parser:"@@?"` }
type BlockStatement ¶
type CompilationUnit ¶
type CompilationUnit struct {
Statements []Statement `parser:"@@*"`
}
type Expression ¶
type Expression struct { // MemberAccessExpression *MemberAccessExpression `parser:"@@ |"` LambdaExpression *LambdaExpression `parser:"@@ |"` ValueExpression *ValueExpression `parser:"@@ |"` InvocationExpression *InvocationExpression `parser:"@@ |"` InvocationExpressionWithParen *InvocationExpressionWithParen `parser:"@@ |"` IfExpression *IfStatementOrExpression `parser:"@@"` }
type ExpressionStatement ¶
type ExpressionStatement struct {
Expression Expression `parser:"@@"`
}
type ExpressionWithIdentifier ¶
type ExpressionWithIdentifier struct {
IdentifierNameExpression *IdentifierNameExpression `parser:"@@"`
}
type HashIdentifier ¶
type HashIdentifier struct {
Identifier string `parser:"@Identifier ':'"`
}
type HashObject ¶
type HashSymbol ¶
type HashSymbol struct {
Identifier string `parser:"':' @Identifier"`
}
type Identifier ¶
type Identifier struct {
Name string `parser:"@Identifier"`
}
func (*Identifier) Parse ¶
func (v *Identifier) Parse(lex *lexer.PeekingLexer) error
type IdentifierNameExpression ¶
type IdentifierNameExpression struct {
Identifier Identifier `parser:"@@"`
}
type IfStatementOrExpression ¶
type IfStatementOrExpression struct { IfKeyword string `parser:"'if'"` OpenParen *string `parser:"'('?"` Condition IfStatementOrExpressionConditionExpression `parser:"@@"` CloseParen *string `parser:"')'?"` NewParen *string `parser:"@NewLine?"` Statements []Statement `parser:"@@*"` EndKeyword string `parser:"'end'"` }
type IfStatementOrExpressionConditionExpression ¶
type IfStatementOrExpressionConditionExpression struct { InvocationExpression *InvocationExpression `parser:"@@ |"` InvocationExpressionWithParen *InvocationExpressionWithParen `parser:"@@ |"` ValueExpression *ValueExpression `parser:"@@"` }
type InvocationExpression ¶
type InvocationExpression struct { Expression ExpressionWithIdentifier `parser:"@@"` ArgumentList ArgumentList `parser:"@@"` }
type InvocationExpressionWithParen ¶
type InvocationExpressionWithParen struct { Expression ExpressionWithIdentifier `parser:"@@"` OpenParen string `parser:"'('"` ArgumentList ArgumentList `parser:"@@"` CloseParen string `parser:"')'"` }
type LambdaExpression ¶
type MemberAccessExpression ¶
type MemberAccessExpression struct { Expression MemberAccessExpressionTExpression `parser:"@@"` Dot string `parser:"'.'"` Identifier Identifier `parser:"@@"` }
type MemberAccessExpressionTExpression ¶
type MemberAccessExpressionTExpression struct { MemberAccessExpression *MemberAccessExpression `parser:"@@ |"` InvocationExpression *InvocationExpressionWithParen `parser:"@@"` }
type Pair ¶
type Pair struct { Identifier HashIdentifier `parser:"@@"` Value Value `parser:"@@"` }
type Statement ¶
type Statement struct { Statement StatementInternal `parser:"@@"` NewLine string `parser:"@NewLine"` }
type StatementInternal ¶
type StatementInternal struct { BlockStatement *BlockStatement `parser:"@@ |"` IfStatement *IfStatementOrExpression `parser:"@@ |"` ExpressionStatement *ExpressionStatement `parser:"@@"` }
type Value ¶
type Value struct { Literal *Literal `parser:"@@ |"` HashSymbol *HashSymbol `parser:"@@ |"` Hash *HashObject `parser:"@@"` }
type ValueExpression ¶
type ValueExpression struct {
Value Value `parser:"@@"`
}
Click to show internal directories.
Click to hide internal directories.