-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
48 lines (39 loc) · 1.24 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
// 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/src/blocks"
"github.com/conflowio/conflow/src/conflow/block"
"github.com/conflowio/conflow/src/functions"
"github.com/conflowio/conflow/src/parsers"
"github.com/conflowio/conflow/src/util"
)
func main() {
ctx, cancel := util.CreateDefaultContext()
defer cancel()
parseCtx := common.NewParseContext()
mainInterpreter := blocks.MainInterpreter{}
mainInterpreter.BlockTransformerRegistry = block.InterpreterRegistry{
"module": mainInterpreter,
"import": blocks.ImportInterpreter{},
"iterator": common.IteratorInterpreter{},
"print": blocks.PrintInterpreter{},
"println": blocks.PrintlnInterpreter{},
}
mainInterpreter.FunctionTransformerRegistry = functions.DefaultRegistry()
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)
}