Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 626281x 626281x 626281x 626281x 626281x 626281x 75309x 75309x 626281x 1x 1x 9414051x 9414051x 1x 1x 13x 13x 1x 1x 550972x 550972x 550972x 550972x 1x 1x 764598x 764598x 1x 1x 1084740x 1084740x 1x 1x 527383x 527383x 1x 1x 1x 1x 1x 1x 10839641x 10839641x 1x 1x | import {AbstractToken} from "../1_lexer/tokens/abstract_token";
import {ExpressionNode} from "../nodes/expression_node";
import {TokenNode} from "../nodes/token_node";
export class Result {
private readonly tokens: readonly AbstractToken[];
private readonly tokenIndex: number;
private nodes: (ExpressionNode | TokenNode)[] | undefined;
public constructor(tokens: readonly AbstractToken[], tokenIndex: number, nodes?: (ExpressionNode | TokenNode)[]) {
// tokens: all tokens, from the tokenIndex = not yet matched
// nodes: matched tokens
this.tokens = tokens;
this.tokenIndex = tokenIndex;
this.nodes = nodes;
if (this.nodes === undefined) {
this.nodes = [];
}
}
public peek(): AbstractToken {
return this.tokens[this.tokenIndex];
}
public peekAt(offset: number): AbstractToken | undefined {
return this.tokens[this.tokenIndex + offset];
}
public shift(node: ExpressionNode | TokenNode): Result {
const cp = this.nodes!.slice();
cp.push(node);
return new Result(this.tokens, this.tokenIndex + 1, cp);
}
public popNode(): ExpressionNode | TokenNode | undefined {
return this.nodes!.pop();
}
public getNodes(): (ExpressionNode | TokenNode)[] {
return this.nodes!;
}
public setNodes(n: (ExpressionNode | TokenNode)[]): void {
this.nodes = n;
}
public getTokens(): readonly AbstractToken[] {
return this.tokens;
}
public getTokenIndex(): number {
return this.tokenIndex;
}
public remainingLength(): number {
return this.tokens.length - this.tokenIndex;
}
} |