Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func validateOperator(tokens []LexToken, i int) bool {
- switch tokens[i].value {
- case "*":
- valid := tokens[i-1].typ == tokenSpace ||
- tokens[i-1].typ == tokenSeparator ||
- tokens[i-1].value == "*"
- valid = valid &&
- tokens[i+1].typ == tokenSpace ||
- tokens[i+1].value == "*" ||
- tokens[i+1].typ == tokenSeparator ||
- tokens[i+1].typ == tokenIdentfier ||
- tokens[i+1].value == "="
- if !valid {
- fmt.Printf("%d: '*' not properly formatted\n", tokens[i].linum)
- return false
- }
- }
- return true
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement