Documentation
¶
Overview ¶
Package isa provides types for all instructions in the GPeg virtual machine.
Index ¶
- type Any
- type BackCommit
- type BackReference
- type Call
- type CaptureBegin
- type CaptureEnd
- type CaptureFull
- type CaptureLate
- type Char
- type CheckBegin
- type CheckEnd
- type Checker
- type Choice
- type Commit
- type Empty
- type End
- type Error
- type Fail
- type FailTwice
- type Insn
- type Jump
- type JumpType
- type Label
- type MapChecker
- type MemoClose
- type MemoOpen
- type MemoTree
- type MemoTreeClose
- type MemoTreeInsert
- type MemoTreeOpen
- type Nop
- type PartialCommit
- type Program
- type RefKind
- type Return
- type Set
- type Span
- type TestAny
- type TestChar
- type TestCharNoChoice
- type TestSet
- type TestSetNoChoice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Any ¶
type Any struct { N byte // contains filtered or unexported fields }
Any consumes the next N bytes and fails if that is not possible.
type BackCommit ¶
type BackCommit struct { Lbl Label // contains filtered or unexported fields }
BackCommit pops a backtrack entry off the stack, goes to the subject position in the entry, and jumps to Lbl.
func (BackCommit) String ¶
func (i BackCommit) String() string
String returns the string representation of this instruction.
type BackReference ¶
func NewBackRef ¶
func NewBackRef() *BackReference
type Call ¶
type Call struct { Lbl Label // contains filtered or unexported fields }
Call pushes the next instruction to the stack as a return address and jumps to Lbl.
type CaptureBegin ¶
type CaptureBegin struct { Id int // contains filtered or unexported fields }
CaptureBegin begins capturing the given ID.
func (CaptureBegin) String ¶
func (i CaptureBegin) String() string
String returns the string representation of this instruction.
type CaptureEnd ¶
type CaptureEnd struct { Id int // contains filtered or unexported fields }
CaptureEnd completes an active capture.
func (CaptureEnd) String ¶
func (i CaptureEnd) String() string
String returns the string representation of this instruction.
type CaptureFull ¶
CaptureFull begins a capture for the given ID at the current subject position minus Back, and immediately completes the capture. This is equivalent to CaptureLate Back ID; CaptureEnd.
func (CaptureFull) String ¶
func (i CaptureFull) String() string
String returns the string representation of this instruction.
type CaptureLate ¶
CaptureLate begins capturing the given ID at the current subject position minus Back.
func (CaptureLate) String ¶
func (i CaptureLate) String() string
String returns the string representation of this instruction.
type Char ¶
type Char struct { Byte byte // contains filtered or unexported fields }
Char consumes the next byte of the subject if it matches Byte and fails otherwise.
type CheckBegin ¶
CheckBegin marks the beginning position for a checker.
func (CheckBegin) String ¶
func (i CheckBegin) String() string
String returns the string representation of this instruction.
type CheckEnd ¶
type CheckEnd struct { Checker Checker // contains filtered or unexported fields }
CheckEnd records the end position of a checker and applies the checker to determine if the match should fail.
type Checker ¶
A Checker is used so the user can perform additional custom validation of parse results. For example, you might want to parse only 8-bit integers by matching [0-9]+ and then using a checker to ensure the matched integer is in the range 0-256.
type Choice ¶
type Choice struct { Lbl Label // contains filtered or unexported fields }
Choice pushes Lbl to the stack and if there is a failure the label will be popped from the stack and jumped to.
type Commit ¶
type Commit struct { Lbl Label // contains filtered or unexported fields }
Commit jumps to Lbl and removes the top entry from the stack
type Empty ¶
Empty makes a zero-width assertion according to the Op option. We use the same zero-width assertions that are supported by Go's regexp package.
type End ¶
type End struct { Fail bool // contains filtered or unexported fields }
End immediately completes the pattern as a match.
type Error ¶
type Error struct { Message string // contains filtered or unexported fields }
Error logs an error message at the current position.
type Fail ¶
type Fail struct {
// contains filtered or unexported fields
}
Fail causes the instruction pointer to go to the fail state.
type FailTwice ¶
type FailTwice struct {
// contains filtered or unexported fields
}
FailTwice pops an entry off the stack and sets the instruction pointer to the fail state.
type Insn ¶
type Insn interface {
// contains filtered or unexported methods
}
Insn represents the interface for an instruction in the ISA
type Jump ¶
type Jump struct { Lbl Label // contains filtered or unexported fields }
Jump jumps to Lbl.
type JumpType ¶
type JumpType interface {
// contains filtered or unexported methods
}
A JumpType instruction is any instruction that refers to a Label.
type Label ¶
type Label struct { Id int // contains filtered or unexported fields }
Label is used for marking a location in the instruction code with a unique ID
type MapChecker ¶
type MapChecker map[string]struct{}
func NewMapChecker ¶
func NewMapChecker(strs []string) MapChecker
type MemoClose ¶
type MemoClose struct {
// contains filtered or unexported fields
}
MemoClose completes a memoization entry and adds the entry into the memo table if it meets certain conditions (size, or other heuristics).
type MemoOpen ¶
MemoOpen begins a memo entry at this position. It marks the pattern that is being memoized with a unique ID for that pattern, and stores a label to jump to if the pattern is found in the memoization table.
type MemoTree ¶
type MemoTree struct {
// contains filtered or unexported fields
}
MemoTree "tree-ifies" the current memoization entries on the stack.
type MemoTreeClose ¶
type MemoTreeClose struct { Id int // contains filtered or unexported fields }
MemoTreeClose completes the tree memoization routine.
func (MemoTreeClose) String ¶
func (i MemoTreeClose) String() string
String returns the string representation of this instruction.
type MemoTreeInsert ¶
type MemoTreeInsert struct {
// contains filtered or unexported fields
}
MemoTreeInsert performs insertion into the memoization table for the tree memoization strategy.
func (MemoTreeInsert) String ¶
func (i MemoTreeInsert) String() string
String returns the string representation of this instruction.
type MemoTreeOpen ¶
MemoTreeOpen starts a memoization tree repetition routine.
func (MemoTreeOpen) String ¶
func (i MemoTreeOpen) String() string
String returns the string representation of this instruction.
type PartialCommit ¶
type PartialCommit struct { Lbl Label // contains filtered or unexported fields }
PartialCommit modifies the backtrack entry on the top of the stack to point to the current subject offset, and jumps to Lbl.
func (PartialCommit) String ¶
func (i PartialCommit) String() string
String returns the string representation of this instruction.
type Program ¶
type Program []Insn
A Program is a sequence of instructions
type Return ¶
type Return struct {
// contains filtered or unexported fields
}
Return pops a return address off the stack and jumps to it.
type TestAny ¶
TestAny consumes the next N bytes and jumps to Lbl if that is not possible. If the consumption is possible, a backtrack entry referring to Lbl and the subject position from before consumption is pushed to the stack.
type TestChar ¶
TestChar consumes the next byte if it matches Byte and jumps to Lbl otherwise. If the consumption is possible, a backtrack entry referring to Lbl and the subject position from before consumption is pushed to the stack.
type TestCharNoChoice ¶
TestCharNoChoice consumes the next byte if it matches Byte and jumps to Lbl otherwise. No backtrack entry is pushed to the stack.
func (TestCharNoChoice) String ¶
func (i TestCharNoChoice) String() string
String returns the string representation of this instruction.
type TestSet ¶
TestSet consumes the next byte if it is in the set Chars and jumps to Lbl otherwise. If the consumption is possible, a backtrack entry referring to Lbl and the subject position from before consumption is pushed to the stack.
type TestSetNoChoice ¶
type TestSetNoChoice struct { Chars charset.Set Lbl Label // contains filtered or unexported fields }
TestSetNoChoice is the same as TestSet but no backtrack entry is pushed to the stack.
func (TestSetNoChoice) String ¶
func (i TestSetNoChoice) String() string
String returns the string representation of this instruction.