Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. func validateOperator(tokens []LexToken, i int) bool {
  2. switch tokens[i].value {
  3. case "*":
  4. valid := tokens[i-1].typ == tokenSpace ||
  5. tokens[i-1].typ == tokenSeparator ||
  6. tokens[i-1].value == "*"
  7. valid = valid &&
  8. tokens[i+1].typ == tokenSpace ||
  9. tokens[i+1].value == "*" ||
  10. tokens[i+1].typ == tokenSeparator ||
  11. tokens[i+1].typ == tokenIdentfier ||
  12. tokens[i+1].value == "="
  13. if !valid {
  14. fmt.Printf("%d: '*' not properly formatted\n", tokens[i].linum)
  15. return false
  16. }
  17. }
  18. return true
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement