-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
60 lines (49 loc) · 1.36 KB
/
main.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
52
53
54
55
56
57
58
59
60
// Copyright (c) 2017 Opsidian Ltd.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package main
import (
"fmt"
"os"
"github.com/conflowio/conflow/examples/common"
"github.com/conflowio/conflow/pkg/blocks"
"github.com/conflowio/conflow/pkg/conflow"
"github.com/conflowio/conflow/pkg/conflow/block"
"github.com/conflowio/conflow/pkg/functions"
"github.com/conflowio/conflow/pkg/parsers"
"github.com/conflowio/conflow/pkg/util"
)
// @block "main"
type Main struct {
// @id
id conflow.ID
}
func (m *Main) ID() conflow.ID {
return m.id
}
func (m *Main) ParseContextOverride() conflow.ParseContextOverride {
return conflow.ParseContextOverride{
BlockTransformerRegistry: block.InterpreterRegistry{
"ticker": blocks.TickerInterpreter{},
"print": blocks.PrintInterpreter{},
"println": blocks.PrintlnInterpreter{},
},
FunctionTransformerRegistry: functions.DefaultRegistry(),
}
}
func main() {
ctx, cancel := util.CreateDefaultContext()
defer cancel()
parseCtx := common.NewParseContext()
p := parsers.NewMain("main", MainInterpreter{})
if err := p.ParseFile(
parseCtx,
"main.cf",
); err != nil {
fmt.Printf("Error: %s\n", err.Error())
os.Exit(1)
}
common.Main(ctx, parseCtx, nil)
}