forked from deb-sig/double-entry-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.go
33 lines (28 loc) · 882 Bytes
/
interface.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
package compiler
import (
"fmt"
"github.com/deb-sig/double-entry-generator/pkg/analyser"
"github.com/deb-sig/double-entry-generator/pkg/compiler/beancount"
"github.com/deb-sig/double-entry-generator/pkg/config"
"github.com/deb-sig/double-entry-generator/pkg/consts"
"github.com/deb-sig/double-entry-generator/pkg/ir"
)
// Interface is the type for the compiler.
type Interface interface {
Compile() error
}
// New creates a new compiler.
func New(providerName, targetName, output string,
appendMode bool, c *config.Config, i *ir.IR) (Interface, error) {
a, err := analyser.New(providerName)
if err != nil {
return nil, err
}
switch targetName {
case consts.CompilerBeanCount:
return beancount.New(providerName, targetName,
output, appendMode, c, i, a)
default:
return nil, fmt.Errorf("Fail to create the compiler for the given name %s", targetName)
}
}