func ParseConfiguration(data []byte) (*Configuration, error) { opts := &parse.Options{SkipWhite: func(str []byte, loc int) int { return parse.SkipAll(str, loc, parse.SkipShellComment, parse.SkipSpaces) }} cfg := new(Configuration) _, err := parse.Parse(cfg, data, opts) return cfg, err }
func ParseJSON(json []byte) (res map[string]interface{}, err error) { var obj Object _, err = parse.Parse(&obj, json, &parse.Options{PackratEnabled: false, SkipWhite: parse.SkipSpaces}) if err != nil { return } return obj.values, nil }
// Function to calculate value of expression: func calc(expr string) float64 { var e Expression nl, err := parse.Parse(&e, []byte(expr), nil) if err != nil { println("Error: ", err) return 0.0 } else if nl < len(expr) { println("WARNING: '", expr[nl:], "' was not parsed!") } return e.Calc() }