Documentation ¶
Overview ¶
Package node implements some AST nodes.
Index ¶
Constants ¶
const ( TypeCharacter = "Character" TypeUnion = "Union" TypeConcat = "Concat" TypeStar = "Star" TypePlus = "Plus" TypeQuestion = "Question" TypeAny = "Any" TypeEpsilon = "Epsilon" // Empty character )
String to identify the type of Node.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Any ¶
type Any struct {
Ty string
}
Any represents the Any node.
func (*Any) Compile ¶
Compile returns a BC compiled from Any node which VM can execute. The BC compiled from an expression '.' will be like below:
|00| Any
Note: The bytecode is just a fragment, so when finally give VM it, you need to add the instruction of Match to the last of BC.
func (*Any) SubtreeString ¶
SubtreeString returns a string to which converts a subtree with the Any node at the top.
type Character ¶
Character represents the Character node.
func (*Character) Compile ¶
Compile returns a BC compiled from Character node which VM can execute. The BC compiled from an expression 'a' will be like below:
|0| Char 'a'
Note: The bytecode is just a fragment, so when finally give VM it, you need to add the instruction of Match to the last of BC.
func (*Character) SubtreeString ¶
SubtreeString returns a string to which converts a subtree with the Character node at the top.
type Concat ¶
Concat represents the Concat node.
func (*Concat) Compile ¶
Compile returns a BC compiled from Concat node which VM can execute. The BC compiled from an expression 'abc' will be like below:
|0| Char 'a' |1| Char 'b' |2| Char 'c'
Note: The bytecode is just a fragment, so when finally give VM it, you need to add the instruction of Match to the last of BC.
func (*Concat) SubtreeString ¶
SubtreeString returns a string to which converts a subtree with the Concat node at the top.
type Epsilon ¶
type Epsilon struct {
Ty string
}
Epsilon represents the Epsilon node.
func (*Epsilon) SubtreeString ¶
SubtreeString returns a string to which converts a subtree with the Epsilon node at the top.
type Node ¶
type Node interface { // SubtreeString returns a string to which converts // a subtree with Node at the top. SubtreeString() string // Compile returns a byte code fragment for VM. Compile() *bytecode.BC }
Node is the interface Node implements.
type Plus ¶
Plus represents the Plus node.
func (*Plus) Compile ¶
Compile returns a BC compiled from Plus node which VM can execute. The BC compiled from an expression 'a' will be like below:
|00| Char 'a' |01| Split 0, 2 |02| <nop>
Note: The bytecode is just a fragment, so when finally give VM it, you need to add the instruction of Match to the last of BC.
func (*Plus) SubtreeString ¶
SubtreeString returns a string to which converts a subtree with the Star node at the top.
type Question ¶
Question represents the Question node.
func (*Question) Compile ¶
Compile returns a BC compiled from Question node which VM can execute. The BC compiled from an expression 'a' will be like below:
|00| Split 1, 2 |01| Char 'a' |02| <nop>
Note: The bytecode is just a fragment, so when finally give VM it, you need to add the instruction of Match to the last of BC.
func (*Question) SubtreeString ¶
SubtreeString returns a string to which converts a subtree with the Star node at the top.
type Star ¶
Star represents the Star node.
func (*Star) Compile ¶
Compile returns a BC compiled from Star node which VM can execute. The BC compiled from an expression 'abc' will be like below:
|00| Split 1, 3 |01| Char 'a' |02| Jmp 0 |03| <nop>
Note: The bytecode is just a fragment, so when finally give VM it, you need to add the instruction of Match to the last of BC.
func (*Star) SubtreeString ¶
SubtreeString returns a string to which converts a subtree with the Star node at the top.
type Union ¶
Union represents the Union node.
func (*Union) Compile ¶
Compile returns a BC compiled from Union node which VM can execute. The BC compiled from an expression 'a|b' will be like below:
|0| Split 1, 3 |1| Char 'a' |2| Jmp 4 |3| Char 'b' |4| <nop>
Note: The bytecode is just a fragment, so when finally give VM it, you need to add the instruction of Match to the last of BC.
func (*Union) SubtreeString ¶
SubtreeString returns a string to which converts a subtree with the Union node at the top.