parser_return.go 448 B

123456789101112131415161718192021222324
  1. package parser
  2. import (
  3. "code.osinet.fr/fgm/waiig15/ast"
  4. "code.osinet.fr/fgm/waiig15/token"
  5. )
  6. func (p *Parser) parseReturnStatement() *ast.ReturnStatement {
  7. stmt := &ast.ReturnStatement{
  8. Token: p.curToken,
  9. }
  10. // There should be an expression to consume here.
  11. p.nextToken()
  12. // Skip the expression for now, progress to the semicolon terminating the
  13. // statement.
  14. for !p.curTokenIs(token.SEMICOLON) {
  15. p.nextToken()
  16. }
  17. return stmt
  18. }