-
Notifications
You must be signed in to change notification settings - Fork 0
/
scanner.go
42 lines (37 loc) · 1.02 KB
/
scanner.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
package dms
import "github.com/blackchip-org/scan"
const (
IntType = scan.IntType
RealType = scan.RealType
DegType = "deg"
MinType = "min"
SecType = "sec"
EastType = "E"
NorthType = "N"
SouthType = "S"
WestType = "W"
)
var (
SignRule = scan.NewClassRule(scan.IsSign)
DegRule = scan.NewClassRule(scan.Rune('d', '°')).WithType(DegType)
MinRule = scan.NewClassRule(scan.Rune('m', '\'', '′')).WithType(MinType)
SecRule = scan.NewClassRule(scan.Rune('s', '"', '″')).WithType(SecType)
EastRule = scan.NewClassRule(scan.Rune('E')).WithType(EastType)
NorthRule = scan.NewClassRule(scan.Rune('N')).WithType(NorthType)
SouthRule = scan.NewClassRule(scan.Rune('S')).WithType(SouthType)
WestRule = scan.NewClassRule(scan.Rune('W')).WithType(WestType)
)
type Context struct {
RuleSet scan.RuleSet
}
func NewContext() *Context {
c := &Context{}
c.RuleSet = scan.NewRuleSet(
scan.SkipSpaceRule,
scan.RealRule,
SignRule,
DegRule, MinRule, SecRule,
EastRule, NorthRule, SouthRule, WestRule,
)
return c
}