| 1 |
// Package parser provides ANSI escape sequence parsing functionality. |
| 2 |
package parser |
| 3 |
|
| 4 |
// Action is a DEC ANSI parser action. |
| 5 |
type Action = byte |
| 6 |
|
| 7 |
// These are the actions that the parser can take. |
| 8 |
const ( |
| 9 |
NoneAction Action = iota |
| 10 |
ClearAction |
| 11 |
CollectAction |
| 12 |
PrefixAction |
| 13 |
DispatchAction |
| 14 |
ExecuteAction |
| 15 |
StartAction // Start of a data string |
| 16 |
PutAction // Put into the data string |
| 17 |
ParamAction |
| 18 |
PrintAction |
| 19 |
|
| 20 |
IgnoreAction = NoneAction |
| 21 |
) |
| 22 |
|
| 23 |
// ActionNames provides string names for parser actions. |
| 24 |
var ActionNames = []string{ |
| 25 |
"NoneAction", |
| 26 |
"ClearAction", |
| 27 |
"CollectAction", |
| 28 |
"PrefixAction", |
| 29 |
"DispatchAction", |
| 30 |
"ExecuteAction", |
| 31 |
"StartAction", |
| 32 |
"PutAction", |
| 33 |
"ParamAction", |
| 34 |
"PrintAction", |
| 35 |
} |
| 36 |
|
| 37 |
// State is a DEC ANSI parser state. |
| 38 |
type State = byte |
| 39 |
|
| 40 |
// These are the states that the parser can be in. |
| 41 |
const ( |
| 42 |
GroundState State = iota |
| 43 |
CsiEntryState |
| 44 |
CsiIntermediateState |
| 45 |
CsiParamState |
| 46 |
DcsEntryState |
| 47 |
DcsIntermediateState |
| 48 |
DcsParamState |
| 49 |
DcsStringState |
| 50 |
EscapeState |
| 51 |
EscapeIntermediateState |
| 52 |
OscStringState |
| 53 |
SosStringState |
| 54 |
PmStringState |
| 55 |
ApcStringState |
| 56 |
|
| 57 |
// Utf8State is not part of the DEC ANSI standard. It is used to handle |
| 58 |
// UTF-8 sequences. |
| 59 |
Utf8State |
| 60 |
) |
| 61 |
|
| 62 |
// StateNames provides string names for parser states. |
| 63 |
var StateNames = []string{ |
| 64 |
"GroundState", |
| 65 |
"CsiEntryState", |
| 66 |
"CsiIntermediateState", |
| 67 |
"CsiParamState", |
| 68 |
"DcsEntryState", |
| 69 |
"DcsIntermediateState", |
| 70 |
"DcsParamState", |
| 71 |
"DcsStringState", |
| 72 |
"EscapeState", |
| 73 |
"EscapeIntermediateState", |
| 74 |
"OscStringState", |
| 75 |
"SosStringState", |
| 76 |
"PmStringState", |
| 77 |
"ApcStringState", |
| 78 |
"Utf8State", |
| 79 |
} |