Esempio n. 1
0
File: output.go Progetto: xet7/gerb
func createOutputTag(p *core.Parser, isUnsafe bool) (core.Executable, error) {
	value, err := p.ReadValue()
	if err != nil {
		return nil, err
	}
	if err = p.ReadCloseTag(); err != nil {
		return nil, err
	}
	return &OutputTag{value, !isUnsafe}, nil
}
Esempio n. 2
0
File: content.go Progetto: xet7/gerb
func ContentFactory(p *core.Parser) (core.Code, error) {
	value, err := p.ReadValue()
	if err != nil {
		return nil, err
	}
	if p.SkipSpaces() != '{' {
		return nil, p.Error("Missing openening brace for content statement")
	}
	p.Next()
	return &ContentCode{new(core.NormalContainer), value}, nil
}
Esempio n. 3
0
File: for.go Progetto: xet7/gerb
func RangedForFactory(p *core.Parser) (core.Code, error) {
	code := &RangedForCode{NormalContainer: new(core.NormalContainer)}
	tokens, err := p.ReadTokenList()
	if err != nil {
		return nil, err
	}
	if len(tokens) != 2 {
		return nil, p.Error("Invalid for loop, ranged loop should have two variables")
	}
	code.tokens = tokens
	c := p.SkipSpaces()
	if c == ':' {
		c = p.Next()
	}
	if c != '=' {
		return nil, p.Error("Invalid for loop, ranged loop expecting assignment operator")
	}
	p.Next()

	if p.SkipSpaces() != 'r' || p.ConsumeIf([]byte("range")) == false {
		return nil, p.Error("invalid for loop, expected 'range' keyword")
	}

	value, err := p.ReadValue()
	if err != nil {
		return nil, err
	}
	code.value = value
	if p.SkipSpaces() != '{' {
		return nil, p.Error("Missing openening brace for if statement")
	}
	p.Next()

	return code, nil

}