(tok)
| 151 | // Parse from a token, regexp or string, and move forward if match |
| 152 | // |
| 153 | function $(tok) { |
| 154 | var match, length; |
| 155 | |
| 156 | // |
| 157 | // Non-terminal |
| 158 | // |
| 159 | if (tok instanceof Function) { |
| 160 | return tok.call(parser.parsers); |
| 161 | // |
| 162 | // Terminal |
| 163 | // |
| 164 | // Either match a single character in the input, |
| 165 | // or match a regexp in the current chunk (chunk[j]). |
| 166 | // |
| 167 | } else if (typeof(tok) === 'string') { |
| 168 | match = input.charAt(i) === tok ? tok : null; |
| 169 | length = 1; |
| 170 | sync (); |
| 171 | } else { |
| 172 | sync (); |
| 173 | |
| 174 | if (match = tok.exec(chunks[j])) { |
| 175 | length = match[0].length; |
| 176 | } else { |
| 177 | return null; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | // The match is confirmed, add the match length to `i`, |
| 182 | // and consume any extra white-space characters (' ' || '\n') |
| 183 | // which come after that. The reason for this is that LeSS's |
| 184 | // grammar is mostly white-space insensitive. |
| 185 | // |
| 186 | if (match) { |
| 187 | skipWhitespace(length); |
| 188 | |
| 189 | if(typeof(match) === 'string') { |
| 190 | return match; |
| 191 | } else { |
| 192 | return match.length === 1 ? match[0] : match; |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | function skipWhitespace(length) { |
| 198 | var oldi = i, oldj = j, |
no test coverage detected