-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command_item.go
51 lines (44 loc) · 1.28 KB
/
command_item.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import "fmt"
// item represents a token or text string returned from the scanner.
type item struct {
typ itemType
val string
}
func (i *item) String() string {
return fmt.Sprintf("type: %s; val: %q", itemTypes[i.typ], i.val)
}
// itemType identifies the type of lex items.
type itemType int
// [num][range][num][action][delim][pattern][delim][pattern][delim][additional]
const (
itemError itemType = iota + 1 // error occurred; value is text of error
itemEOF
itemAddress
itemAddressPattern
itemRange
itemIncr
itemAction
itemPattern
itemSubstitution
itemDestination
itemAdditional
itemGlobalPrefix
itemReplaceNum
itemArg
)
var itemTypes = map[itemType]string{
itemError: "itemError",
itemEOF: "itemEOF",
itemAddress: "itemAddress", // a single address
itemAddressPattern: "itemAddressPattern", // find lines matching this pattern
itemRange: "itemRange", // a range of addresses
itemIncr: "itemIncr", // use relative addresses
itemAction: "itemAction",
itemPattern: "itemPattern",
itemSubstitution: "itemSubstitution",
itemDestination: "itemDestination",
itemGlobalPrefix: "itemGlobalPrefix",
itemReplaceNum: "itemReplaceNum",
itemArg: "itemArg",
}