validateToken - Check if current token type is appearing in provided expectedTokens array
(tokenType token.Type, expectedTokens []token.Type)
| 48 | |
| 49 | // validateToken - Check if current token type is appearing in provided expectedTokens array |
| 50 | func validateToken(tokenType token.Type, expectedTokens []token.Type) error { |
| 51 | var contains = false |
| 52 | expectedTokensStrings := make([]string, 0) |
| 53 | for _, x := range expectedTokens { |
| 54 | expectedTokensStrings = append(expectedTokensStrings, string(x)) |
| 55 | |
| 56 | if x == tokenType { |
| 57 | contains = true |
| 58 | break |
| 59 | } |
| 60 | } |
| 61 | if !contains { |
| 62 | return &SyntaxError{expectedTokensStrings, string(tokenType)} |
| 63 | } |
| 64 | return nil |
| 65 | } |
| 66 | |
| 67 | // parseCreateCommand - Return ast.CreateCommand created from tokens and validate the syntax |
| 68 | // |
no outgoing calls
no test coverage detected