()
| 151 | } |
| 152 | var start; |
| 153 | function read_next() { |
| 154 | read_while(is_whitespace); |
| 155 | if (input.eof()) return null; |
| 156 | var ch = input.peek(); |
| 157 | start=input.poi(); |
| 158 | if (ch == "#"||(ch=='/'&&input.peek(1)=='/')) { |
| 159 | // skip_comment(); |
| 160 | // return read_next(); |
| 161 | return { |
| 162 | type : "Comment", |
| 163 | value : read_while(function(ch){ return ch != "\n" }), |
| 164 | poi:{ |
| 165 | line:start.line, |
| 166 | start:start.column, |
| 167 | end:input.poi().column |
| 168 | } |
| 169 | }; |
| 170 | } |
| 171 | if (ch == '"') return read_string('"'); |
| 172 | if (ch == "'") return read_string("'"); |
| 173 | if (ch == "`") return read_string("`"); |
| 174 | if (is_digit(ch)) return read_number(); |
| 175 | if (is_id_start(ch)) return read_ident(); |
| 176 | if (is_punc(ch)) return { |
| 177 | type : "punc", |
| 178 | value : input.next(), |
| 179 | poi:{ |
| 180 | line:start.line, |
| 181 | start:start.column, |
| 182 | end:input.poi().column |
| 183 | } |
| 184 | }; |
| 185 | if (is_split(ch)) return { |
| 186 | type : "sp", |
| 187 | value : input.next(), |
| 188 | poi:{ |
| 189 | line:start.line, |
| 190 | start:start.column, |
| 191 | end:input.poi().column |
| 192 | } |
| 193 | }; |
| 194 | if (is_op_char(ch)) return { |
| 195 | type : "op", |
| 196 | value : read_while(is_op_char), |
| 197 | poi:{ |
| 198 | line:start.line, |
| 199 | start:start.column, |
| 200 | end:input.poi().column |
| 201 | } |
| 202 | }; |
| 203 | input.croak(`Can't handle character :${ch}(${ch.charCodeAt(0)})`); |
| 204 | } |
| 205 | function peek() { |
| 206 | return current || (current = read_next());//after next() not call peek() |
| 207 | } |
no test coverage detected