Browse Source

emit async/await tokens

master
Brett Langdon 10 years ago
parent
commit
a151dea987
1 changed files with 19 additions and 17 deletions
  1. +19
    -17
      scanner/scanner.go

+ 19
- 17
scanner/scanner.go View File

@ -364,23 +364,25 @@ func (scanner *Scanner) NextToken() *token.Token {
scanner.unreadPosition(pos)
// Check for async/await
// literal := positions.String()
// if literal == "async" || literal == "await" {
// if scanner.asyncDef {
// switch literal {
// case "async":
// return positions.AsToken(token.ASYNC)
// case "await":
// return positions.AsToken(token.AWAIT)
// }
// } else if literal == "async" {
// nextToken := scanner.NextToken()
// if nextToken.ID == token.NAME && nextToken.Literal == "def" {
// scanner.asyncDef = true
// return positions.AsToken(token.ASYNC)
// }
// }
// }
literal := positions.String()
if literal == "async" || literal == "await" {
if scanner.asyncDef {
switch literal {
case "async":
return positions.AsToken(token.ASYNC)
case "await":
return positions.AsToken(token.AWAIT)
}
} else if literal == "async" {
nextToken := scanner.NextToken()
if nextToken.ID == token.NAME && nextToken.Literal == "def" {
scanner.asyncDef = true
scanner.unreadToken(nextToken)
return positions.AsToken(token.ASYNC)
}
scanner.unreadToken(nextToken)
}
}
return positions.AsToken(token.NAME)
case ch == '\n':


Loading…
Cancel
Save