forked from karlseguin/gerb
/
break.go
46 lines (35 loc) · 918 Bytes
/
break.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
package gerb
import (
"github.com/karlseguin/gerb/core"
)
var (
breakCode = &ControlFlowCode{core.BreakState}
continueCode = &ControlFlowCode{core.ContinueState}
)
func BreakFactory(p *core.Parser) (core.Code, error) {
return breakCode, nil
}
func ContinueFactory(p *core.Parser) (core.Code, error) {
return continueCode, nil
}
type ControlFlowCode struct {
state core.ExecutionState
}
func (c *ControlFlowCode) Execute(context *core.Context) core.ExecutionState {
return c.state
}
func (c *ControlFlowCode) IsCodeContainer() bool {
return false
}
func (c *ControlFlowCode) IsContentContainer() bool {
return false
}
func (c *ControlFlowCode) IsSibling() bool {
return false
}
func (c *ControlFlowCode) AddExecutable(core.Executable) {
panic("AddExecutable called on control flow tag")
}
func (c *ControlFlowCode) AddCode(code core.Code) error {
panic("AddCode called on control flow tag")
}