Created
September 26, 2019 04:52
-
-
Save kooooohe/c91d7f5f9480da4c54058846663a1962 to your computer and use it in GitHub Desktop.
[Blog][TopDownOperatorPrecedence(再帰下降構文解析)におけるExpression(式)の解析処理を追う]precedence.go parseIntegerLiteral.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (p *Parser) parseIntegerLiteral() ast.Expression { | |
lit := &ast.IntegerLiteral{Token: p.curToken} | |
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment