From 73a4e6134c0ae131b68dd946bd9f585dd21b97ee Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 23 Mar 2015 12:30:32 +0100 Subject: Add output formatter --- lexer.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lexer.go') diff --git a/lexer.go b/lexer.go index e5e025b..a52cc96 100644 --- a/lexer.go +++ b/lexer.go @@ -28,23 +28,24 @@ func (y *yyLex) Lex(lval *yySymType) int { item := <-y.items switch item.typ { case STRING: - lval.sval = item.val + lval.sval = S(item.val) case QUOTED: - lval.sval = strings.Replace(item.val, "''", "'", -1) + lval.sval = S(strings.Replace(item.val, "''", "'", -1)) case INTEGER: item.val = strings.Replace(item.val, "¯", "-", -1) - lval.ival, _ = strconv.ParseInt(item.val, 10, 64) + v, _ := strconv.ParseInt(item.val, 10, 64) + lval.ival = I(v) case FLOAT: item.val = strings.Replace(item.val, "¯", "-", -1) - lval.fval, _ = strconv.ParseFloat(item.val, 64) + v, _ := strconv.ParseFloat(item.val, 64) + lval.fval = F(v) case COMPLEX: item.val = strings.Replace(item.val, "¯", "-", -1) pos := strings.IndexAny(item.val, "jJ") r, _ := strconv.ParseFloat(item.val[:pos], 64) i, _ := strconv.ParseFloat(item.val[pos+1:], 64) - lval.cval = complex(r, i) + lval.cval = C(complex(r, i)) } - lval.sval = item.val return item.typ } -- cgit v1.2.3