package parser
const (
TransitionActionShift = 4
TransitionStateMask = 15
IndexStateShift = 8
DefaultTableSize = 4096
)
var Table = GenerateTransitionTable()
type TransitionTable []byte
func ( int) TransitionTable {
if <= 0 {
= DefaultTableSize
}
return TransitionTable(make([]byte, ))
}
func ( TransitionTable) ( Action, State) {
for := range {
[] = <<TransitionActionShift |
}
}
func ( TransitionTable) ( byte, State, Action, State) {
:= int()<<IndexStateShift | int()
:= <<TransitionActionShift |
[] =
}
func ( TransitionTable) ( []byte, State, Action, State) {
for , := range {
.AddOne(, , , )
}
}
func ( TransitionTable) (, byte, State, Action, State) {
for := int(); <= int(); ++ {
.AddOne(byte(), , , )
}
}
func ( TransitionTable) ( State, byte) (State, Action) {
:= int()<<IndexStateShift | int()
:= []
return & TransitionStateMask, >> TransitionActionShift
}
func (, byte) []byte {
var []byte
for := int(); <= int(); ++ {
= append(, byte())
}
return
}
func () TransitionTable {
:= NewTransitionTable(DefaultTableSize)
.SetDefault(NoneAction, GroundState)
for , := range r(GroundState, Utf8State) {
.AddMany([]byte{0x18, 0x1a, 0x99, 0x9a}, , ExecuteAction, GroundState)
.AddRange(0x80, 0x8F, , ExecuteAction, GroundState)
.AddRange(0x90, 0x97, , ExecuteAction, GroundState)
.AddOne(0x9C, , ExecuteAction, GroundState)
.AddOne(0x1B, , ClearAction, EscapeState)
.AddOne(0x98, , StartAction, SosStringState)
.AddOne(0x9E, , StartAction, PmStringState)
.AddOne(0x9F, , StartAction, ApcStringState)
.AddOne(0x9B, , ClearAction, CsiEntryState)
.AddOne(0x90, , ClearAction, DcsEntryState)
.AddOne(0x9D, , StartAction, OscStringState)
.AddRange(0xC2, 0xDF, , CollectAction, Utf8State)
.AddRange(0xE0, 0xEF, , CollectAction, Utf8State)
.AddRange(0xF0, 0xF4, , CollectAction, Utf8State)
}
.AddRange(0x00, 0x17, GroundState, ExecuteAction, GroundState)
.AddOne(0x19, GroundState, ExecuteAction, GroundState)
.AddRange(0x1C, 0x1F, GroundState, ExecuteAction, GroundState)
.AddRange(0x20, 0x7E, GroundState, PrintAction, GroundState)
.AddOne(0x7F, GroundState, ExecuteAction, GroundState)
.AddRange(0x00, 0x17, EscapeIntermediateState, ExecuteAction, EscapeIntermediateState)
.AddOne(0x19, EscapeIntermediateState, ExecuteAction, EscapeIntermediateState)
.AddRange(0x1C, 0x1F, EscapeIntermediateState, ExecuteAction, EscapeIntermediateState)
.AddRange(0x20, 0x2F, EscapeIntermediateState, CollectAction, EscapeIntermediateState)
.AddOne(0x7F, EscapeIntermediateState, IgnoreAction, EscapeIntermediateState)
.AddRange(0x30, 0x7E, EscapeIntermediateState, DispatchAction, GroundState)
.AddRange(0x00, 0x17, EscapeState, ExecuteAction, EscapeState)
.AddOne(0x19, EscapeState, ExecuteAction, EscapeState)
.AddRange(0x1C, 0x1F, EscapeState, ExecuteAction, EscapeState)
.AddOne(0x7F, EscapeState, IgnoreAction, EscapeState)
.AddRange(0x30, 0x4F, EscapeState, DispatchAction, GroundState)
.AddRange(0x51, 0x57, EscapeState, DispatchAction, GroundState)
.AddOne(0x59, EscapeState, DispatchAction, GroundState)
.AddOne(0x5A, EscapeState, DispatchAction, GroundState)
.AddOne(0x5C, EscapeState, DispatchAction, GroundState)
.AddRange(0x60, 0x7E, EscapeState, DispatchAction, GroundState)
.AddRange(0x20, 0x2F, EscapeState, CollectAction, EscapeIntermediateState)
.AddOne('X', EscapeState, StartAction, SosStringState)
.AddOne('^', EscapeState, StartAction, PmStringState)
.AddOne('_', EscapeState, StartAction, ApcStringState)
.AddOne('P', EscapeState, ClearAction, DcsEntryState)
.AddOne('[', EscapeState, ClearAction, CsiEntryState)
.AddOne(']', EscapeState, StartAction, OscStringState)
for , := range r(SosStringState, ApcStringState) {
.AddRange(0x00, 0x17, , PutAction, )
.AddOne(0x19, , PutAction, )
.AddRange(0x1C, 0x1F, , PutAction, )
.AddRange(0x20, 0x7F, , PutAction, )
.AddOne(0x1B, , DispatchAction, EscapeState)
.AddOne(0x9C, , DispatchAction, GroundState)
.AddMany([]byte{0x18, 0x1A}, , IgnoreAction, GroundState)
}
.AddRange(0x00, 0x07, DcsEntryState, IgnoreAction, DcsEntryState)
.AddRange(0x0E, 0x17, DcsEntryState, IgnoreAction, DcsEntryState)
.AddOne(0x19, DcsEntryState, IgnoreAction, DcsEntryState)
.AddRange(0x1C, 0x1F, DcsEntryState, IgnoreAction, DcsEntryState)
.AddOne(0x7F, DcsEntryState, IgnoreAction, DcsEntryState)
.AddRange(0x20, 0x2F, DcsEntryState, CollectAction, DcsIntermediateState)
.AddRange(0x30, 0x3B, DcsEntryState, ParamAction, DcsParamState)
.AddRange(0x3C, 0x3F, DcsEntryState, PrefixAction, DcsParamState)
.AddRange(0x08, 0x0D, DcsEntryState, PutAction, DcsStringState)
.AddOne(0x1B, DcsEntryState, PutAction, DcsStringState)
.AddRange(0x40, 0x7E, DcsEntryState, StartAction, DcsStringState)
.AddRange(0x00, 0x17, DcsIntermediateState, IgnoreAction, DcsIntermediateState)
.AddOne(0x19, DcsIntermediateState, IgnoreAction, DcsIntermediateState)
.AddRange(0x1C, 0x1F, DcsIntermediateState, IgnoreAction, DcsIntermediateState)
.AddRange(0x20, 0x2F, DcsIntermediateState, CollectAction, DcsIntermediateState)
.AddOne(0x7F, DcsIntermediateState, IgnoreAction, DcsIntermediateState)
.AddRange(0x30, 0x3F, DcsIntermediateState, StartAction, DcsStringState)
.AddRange(0x40, 0x7E, DcsIntermediateState, StartAction, DcsStringState)
.AddRange(0x00, 0x17, DcsParamState, IgnoreAction, DcsParamState)
.AddOne(0x19, DcsParamState, IgnoreAction, DcsParamState)
.AddRange(0x1C, 0x1F, DcsParamState, IgnoreAction, DcsParamState)
.AddRange(0x30, 0x3B, DcsParamState, ParamAction, DcsParamState)
.AddOne(0x7F, DcsParamState, IgnoreAction, DcsParamState)
.AddRange(0x3C, 0x3F, DcsParamState, IgnoreAction, DcsParamState)
.AddRange(0x20, 0x2F, DcsParamState, CollectAction, DcsIntermediateState)
.AddRange(0x40, 0x7E, DcsParamState, StartAction, DcsStringState)
.AddRange(0x00, 0x17, DcsStringState, PutAction, DcsStringState)
.AddOne(0x19, DcsStringState, PutAction, DcsStringState)
.AddRange(0x1C, 0x1F, DcsStringState, PutAction, DcsStringState)
.AddRange(0x20, 0x7E, DcsStringState, PutAction, DcsStringState)
.AddOne(0x7F, DcsStringState, PutAction, DcsStringState)
.AddRange(0x80, 0xFF, DcsStringState, PutAction, DcsStringState)
.AddOne(0x1B, DcsStringState, DispatchAction, EscapeState)
.AddOne(0x9C, DcsStringState, DispatchAction, GroundState)
.AddMany([]byte{0x18, 0x1A}, DcsStringState, IgnoreAction, GroundState)
.AddRange(0x00, 0x17, CsiParamState, ExecuteAction, CsiParamState)
.AddOne(0x19, CsiParamState, ExecuteAction, CsiParamState)
.AddRange(0x1C, 0x1F, CsiParamState, ExecuteAction, CsiParamState)
.AddRange(0x30, 0x3B, CsiParamState, ParamAction, CsiParamState)
.AddOne(0x7F, CsiParamState, IgnoreAction, CsiParamState)
.AddRange(0x3C, 0x3F, CsiParamState, IgnoreAction, CsiParamState)
.AddRange(0x40, 0x7E, CsiParamState, DispatchAction, GroundState)
.AddRange(0x20, 0x2F, CsiParamState, CollectAction, CsiIntermediateState)
.AddRange(0x00, 0x17, CsiIntermediateState, ExecuteAction, CsiIntermediateState)
.AddOne(0x19, CsiIntermediateState, ExecuteAction, CsiIntermediateState)
.AddRange(0x1C, 0x1F, CsiIntermediateState, ExecuteAction, CsiIntermediateState)
.AddRange(0x20, 0x2F, CsiIntermediateState, CollectAction, CsiIntermediateState)
.AddOne(0x7F, CsiIntermediateState, IgnoreAction, CsiIntermediateState)
.AddRange(0x40, 0x7E, CsiIntermediateState, DispatchAction, GroundState)
.AddRange(0x30, 0x3F, CsiIntermediateState, IgnoreAction, GroundState)
.AddRange(0x00, 0x17, CsiEntryState, ExecuteAction, CsiEntryState)
.AddOne(0x19, CsiEntryState, ExecuteAction, CsiEntryState)
.AddRange(0x1C, 0x1F, CsiEntryState, ExecuteAction, CsiEntryState)
.AddOne(0x7F, CsiEntryState, IgnoreAction, CsiEntryState)
.AddRange(0x40, 0x7E, CsiEntryState, DispatchAction, GroundState)
.AddRange(0x20, 0x2F, CsiEntryState, CollectAction, CsiIntermediateState)
.AddRange(0x30, 0x3B, CsiEntryState, ParamAction, CsiParamState)
.AddRange(0x3C, 0x3F, CsiEntryState, PrefixAction, CsiParamState)
.AddRange(0x00, 0x06, OscStringState, IgnoreAction, OscStringState)
.AddRange(0x08, 0x17, OscStringState, IgnoreAction, OscStringState)
.AddOne(0x19, OscStringState, IgnoreAction, OscStringState)
.AddRange(0x1C, 0x1F, OscStringState, IgnoreAction, OscStringState)
.AddRange(0x20, 0xFF, OscStringState, PutAction, OscStringState)
.AddOne(0x1B, OscStringState, DispatchAction, EscapeState)
.AddOne(0x07, OscStringState, DispatchAction, GroundState)
.AddOne(0x9C, OscStringState, DispatchAction, GroundState)
.AddMany([]byte{0x18, 0x1A}, OscStringState, IgnoreAction, GroundState)
return
}