in drivers/golang/age/builder.go [236:289]
func unmarshalTerm(ctx *antlr.TerminalNodeImpl) (interface{}, error) {
txt := ctx.GetText()
switch ctx.GetSymbol().GetTokenType() {
case parser.AgeLexerSTRING:
return strings.Trim(txt, "\""), nil
case parser.AgeLexerNUMERIC:
numStr := txt[:len(txt)-9]
// fmt.Println("txt ", txt)
// fmt.Println("numStr", numStr)
if strings.Contains(numStr, ".") {
bi := new(big.Float)
bi, ok := bi.SetString(numStr)
if !ok {
return nil, &AgeParseError{msg: "Parse big float " + txt}
}
return bi, nil
} else {
bi := new(big.Int)
bi, ok := bi.SetString(numStr, 10)
if !ok {
return nil, &AgeParseError{msg: "Parse big int " + txt}
}
return bi, nil
}
case parser.AgeLexerNUMBER:
if strings.Contains(txt, ".") {
return strconv.ParseFloat(txt, 64)
} else {
return strconv.ParseInt(txt, 10, 64)
}
case parser.AgeLexerFLOAT_EXPR:
switch txt {
case "NaN":
return math.NaN(), nil
case "-Infinity":
return math.Inf(-1), nil
case "Infinity":
return math.Inf(1), nil
default:
return nil, &AgeParseError{msg: "Unknown float expression" + txt}
}
case parser.AgeLexerBOOL:
s, err := strconv.ParseBool(txt)
if err != nil {
return nil, err
} else {
return s, nil
}
case parser.AgeLexerNULL:
return nil, nil
default:
return nil, nil
}
}