Peek returns but does not consume the next token.
()
| 135 | |
| 136 | // Peek returns but does not consume the next token. |
| 137 | func (m *LexTokenPager) Peek() lex.Token { |
| 138 | if len(m.tokens) <= m.cursor+1 && !m.done { |
| 139 | m.lexNext() |
| 140 | } |
| 141 | if len(m.tokens) < 2 { |
| 142 | m.lexNext() |
| 143 | } |
| 144 | if len(m.tokens) == m.cursor+1 { |
| 145 | return m.tokens[m.cursor] |
| 146 | } |
| 147 | if m.cursor == -1 { |
| 148 | return m.tokens[1] |
| 149 | } |
| 150 | return m.tokens[m.cursor+1] |
| 151 | } |
| 152 | |
| 153 | // Tree is the representation of a single parsed expression |
| 154 | type tree struct { |