Total Complexity | 2 |
Total Lines | 22 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | 2 | import { Token } from "./Token" |
|
2 | |||
3 | /** |
||
4 | * @class Lexer |
||
5 | * @name Lexer |
||
6 | */ |
||
7 | 2 | export class Lexer { |
|
8 | s: string |
||
9 | |||
10 | /** |
||
11 | * Initialize a lexer. |
||
12 | */ |
||
13 | constructor(input: string) { |
||
14 | 2 | this.s = input |
|
15 | } |
||
16 | |||
17 | /** |
||
18 | * Yields tokens as they are parsed. |
||
19 | * |
||
20 | */ |
||
21 | *tokens(): Generator<Token> { |
||
22 | 1 | for (let i=0; i<this.s.length; i++) { |
|
23 | 3 | yield new Token(this.s[i]) |
|
24 | } |
||
30 |