-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcmdOn.go
More file actions
52 lines (45 loc) · 723 Bytes
/
cmdOn.go
File metadata and controls
52 lines (45 loc) · 723 Bytes
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
52
package main
import (
"strconv"
)
type cmdOn struct {
expr *astExpr
dsts []targetLine
sub bool
}
func (p *parser) parseOn() *cmdOn {
result := &cmdOn{}
l := p.lex.peek()
result.expr = p.parseExpr(false)
if result.expr == nil {
return nil
}
if l.token != tokGo {
return nil
}
p.lex.next()
if l.token == tokSub {
result.sub = true
} else if l.token != tokTo {
return nil
}
p.lex.next()
for l.token == tokNumber {
dst, err := strconv.Atoi(l.s)
if err != nil {
return nil
}
t := targetLine{}
t.nbr = dst
result.dsts = append(result.dsts, t)
p.lex.next()
if l.token != ',' {
break
}
p.lex.next()
}
return result
}
func (c cmdOn) receive(g guest) {
g.visit(c.expr)
}