Skip to content

Commit a459777

Browse files
string iterator into new file
1 parent 43dd8f0 commit a459777

File tree

1 file changed

+1
-39
lines changed

1 file changed

+1
-39
lines changed

assembly/parser/parser.ts

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { isDigit, Char } from "../char";
2+
import { StringIterator } from "./string-iterator";
23
import {
34
AST,
45
RangeRepetitionNode,
@@ -58,46 +59,7 @@ class Range {
5859
to: i32 = -1;
5960
}
6061

61-
class StringIterator {
62-
current: u32;
63-
cursor: u32 = 0;
64-
65-
constructor(private sourceString: string) {
66-
this.current = this.sourceString.charCodeAt(0);
67-
}
68-
69-
lookahead(distance: u32): u32 {
70-
return this.sourceString.charCodeAt(this.cursor + distance);
71-
}
72-
73-
next(): bool {
74-
this.cursor++;
75-
if (this.cursor >= u32(this.sourceString.length)) {
76-
return false;
77-
}
78-
this.current = this.sourceString.charCodeAt(this.cursor);
79-
return true;
80-
}
81-
82-
currentAsString(): string {
83-
return String.fromCharCode(this.current);
84-
}
85-
86-
more(): bool {
87-
return this.cursor < u32(this.sourceString.length);
88-
}
89-
90-
copy(): StringIterator {
91-
const iterator = new StringIterator(this.sourceString);
92-
iterator.cursor = this.cursor;
93-
iterator.current = this.current;
94-
return iterator;
95-
}
96-
}
97-
9862
export class Parser {
99-
// currentToken: string = "";
100-
// cursor: u32 = 0;
10163
iterator: StringIterator;
10264

10365
private constructor(input: string) {

0 commit comments

Comments
 (0)