Skip to content

Instantly share code, notes, and snippets.

@kooooohe
Created September 26, 2019 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kooooohe/c91d7f5f9480da4c54058846663a1962 to your computer and use it in GitHub Desktop.
Save kooooohe/c91d7f5f9480da4c54058846663a1962 to your computer and use it in GitHub Desktop.
[Blog][TopDownOperatorPrecedence(再帰下降構文解析)におけるExpression(式)の解析処理を追う]precedence.go parseIntegerLiteral.go
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