Ejemplo n.º 1
0
func main() {

	flag.Parse()

	clog.EnableKey("PARSER")
	clog.EnableKey("SCANNER")

	parser := goyacc.NewN1qlParserWithDebug(*debugLevel)

	reader := bufio.NewReader(os.Stdin)

	for {
		line, err := reader.ReadString('\n')
		if err != nil {
			break
		}

		if line == "" {
			continue
		}

		ast, err := parser.Parse(line)
		if err != nil {
			clog.Error(err)
		} else {
			fmt.Printf("%v\n", ast)
		}
	}

}
Ejemplo n.º 2
0
func (this *FunctionCallEnableLog) Evaluate(item *dparval.Value) (*dparval.Value, error) {
	// first evaluate the argument
	av, err := this.Operands[0].Expr.Evaluate(item)

	// the spec defines this functin to ONLY operate on numeric values
	// all other types result in NULL
	if err != nil {
		return nil, err
	}

	if av.Type() == dparval.STRING {
		avalue := av.Value()
		switch avalue := avalue.(type) {
		case string:
			clog.EnableKey(avalue)
		}
	}

	return dparval.NewValue(true), nil
}