Documentation
¶
Overview ¶
Package node implements some AST nodes.
Index ¶
Constants ¶
const ( TypeCharacter = "Character" TypeUnion = "Union" TypeConcat = "Concat" TypeStar = "Star" TypePlus = "Plus" )
String to identify the type of Node.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Character ¶
Character represents the Character node.
func (*Character) Assemble ¶
func (c *Character) Assemble(ctx *utils.Context) *nfabuilder.Fragment
Assemble returns a NFA fragment assembled with Character node. The fragment assembled from a Character node is like below:
q1(Initial State) -- [Character.V] --> q2(Accept state)
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) Assemble ¶
func (c *Concat) Assemble(ctx *utils.Context) *nfabuilder.Fragment
Assemble returns a NFA fragment assembled with Concat node. The fragment assembled from a Concat node is like below:
frg1 -- ['ε'] --> frg2 + frg1(fragment assembled with Concat.Ope1): I1 -- [???] --> F1 + frg2(fragment assembled with Concat.Ope2): I2 -- [???] --> F2
func (*Concat) SubtreeString ¶
SubtreeString returns a string to which converts a subtree with the Concat 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
// Assemble returns a NFA fragment assembled with a Node.
Assemble(*utils.Context) *nfabuilder.Fragment
}
Node is the interface Node implements.
type Plus ¶
Plus represents the Star node.
func (*Plus) Assemble ¶
func (p *Plus) Assemble(ctx *utils.Context) *nfabuilder.Fragment
Assemble returns a NFA fragment assembled with Plus node.
func (*Plus) SubtreeString ¶
SubtreeString returns a string to which converts a subtree with the Plus node at the top.
type Star ¶
Star represents the Star node.
func (*Star) Assemble ¶
func (s *Star) Assemble(ctx *utils.Context) *nfabuilder.Fragment
Assemble returns a NFA fragment assembled with Star node. The fragment assembled from a Star node is like below:
(new state1) -- ['ε'] --> I1 -----> F1 -- ['ε'] --> (new state2) \ ↑--['ε']-´ ↑ \ / `-------------------------['ε']------------------------´ + frg1(fragment assembled with Ope): I1 -- [???] --> F1
Note: Accept states of new fragment is "(new state2)" and "I1".
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) Assemble ¶
func (u *Union) Assemble(ctx *utils.Context) *nfabuilder.Fragment
Assemble returns a NFA fragment assembled with Union node. The fragment assembled from a Union node is like below:
I'(new initial state) -- ['ε'] --> frg1
`- ['ε'] --> frg2
+ frg1(fragment assembled with Union.Ope1): I1 -- [???] --> F1
+ frg2(fragment assembled with Union.Ope2): I2 -- [???] --> F2
func (*Union) SubtreeString ¶
SubtreeString returns a string to which converts a subtree with the Union node at the top.