Passed
Push — main ( d506c6...8104af )
by Dylan
03:33
created

Lexer.tokens   A

Complexity

Conditions 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 8
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
crap 2
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
    }
25
  }
26
27
}
28
29
export default Lexer
30