mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
scanner: set initial offset
This commit is contained in:
parent
5c4f879b89
commit
8b5413e6b8
|
@ -41,10 +41,10 @@ class MultiLineStream {
|
|||
private len: number;
|
||||
private position: number;
|
||||
|
||||
constructor(source: string) {
|
||||
constructor(source: string, position: number) {
|
||||
this.source = source;
|
||||
this.len = source.length;
|
||||
this.position = 0;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public eos(): boolean {
|
||||
|
@ -201,9 +201,9 @@ export interface Scanner {
|
|||
getScannerState(): ScannerState;
|
||||
}
|
||||
|
||||
export function createScanner(input: string, initialState: ScannerState = ScannerState.Content) : Scanner {
|
||||
export function createScanner(input: string, initialOffset = 0, initialState: ScannerState = ScannerState.Content) : Scanner {
|
||||
|
||||
let stream = new MultiLineStream(input);
|
||||
let stream = new MultiLineStream(input, initialOffset);
|
||||
let state = initialState;
|
||||
let tokenOffset: number = 0;
|
||||
let tokenType: number = void 0;
|
||||
|
|
|
@ -19,7 +19,7 @@ suite('HTML Scanner', () => {
|
|||
|
||||
let scannerState = ScannerState.Content;
|
||||
for (let t of tests) {
|
||||
let scanner = createScanner(t.input, scannerState);
|
||||
let scanner = createScanner(t.input, 0, scannerState);
|
||||
let tokenType = scanner.scan();
|
||||
let actual : Token[] = [];
|
||||
while (tokenType !== TokenType.EOS) {
|
||||
|
|
Loading…
Reference in a new issue