Пример #1
0
func NewZipped(rules *ast.Rules, desc *descriptor.FileDescriptorSet) (ProtoTokens, error) {
	stringTokens, err := ast.GetStringTokens(rules)
	if err != nil {
		return nil, err
	}
	tokens, err := new(rules.GetRoot().GetPackage(), rules.GetRoot().GetMessage(), desc, stringTokens)
	if err != nil {
		return nil, err
	}
	return tokens, nil
}
Пример #2
0
func Compile(rules *ast.Rules, tokens Tokens) (eval *exec.Exec, rootToken int, err error) {
	tab := table.New(rules.GetTransitions(), rules.GetIfExprs())
	catcher := funcs.NewCatcher(false)
	link, err := link.NewLink(rules, tokens, tab, catcher)
	if err != nil {
		return nil, 0, err
	}
	rootToken, err = tokens.GetTokenId(rules.GetRoot().GetPackage() + "." + rules.GetRoot().GetMessage())
	if err != nil {
		return nil, 0, err
	}
	startState, err := findStartState(rules.GetRoot(), rules.GetInits(), tab)
	if err != nil {
		return nil, 0, err
	}
	acceptState, err := tab.NameToState("accept")
	if err != nil {
		return nil, 0, err
	}
	eval = exec.NewExec(tab, link, catcher, startState, acceptState)
	return eval, rootToken, nil
}
Пример #3
0
func New(rules *ast.Rules, desc *descriptor.FileDescriptorSet) (ProtoTokens, error) {
	srcPackage, srcMessage := rules.GetRoot().GetPackage(), rules.GetRoot().GetMessage()
	return new(srcPackage, srcMessage, desc, nil)
}