package parser import ( "fmt" "strconv" "code.osinet.fr/fgm/waiig15/ast" ) func (p *Parser) parseIntegerLiteral() ast.Expression { lit := &ast.IntegerLiteral{ Token: p.curToken, } // Base 0 allows straight interpretation of octal 0755 or hex 0xABCD. value, err := strconv.ParseInt(p.curToken.Literal, 0, 64) if err != nil { msg := fmt.Sprintf("could not parse %q as integer", p.curToken.Literal) p.errors = append(p.errors, msg) return nil } lit.Value = value return lit }