Allow record expressions to cover multiple lines
This commit is contained in:
parent
9221441aa4
commit
9bf81c56db
1 changed files with 29 additions and 12 deletions
|
@ -382,6 +382,7 @@ export class Scanner extends BufferedStream<Token> {
|
||||||
const enum FrameType {
|
const enum FrameType {
|
||||||
Block,
|
Block,
|
||||||
LineFold,
|
LineFold,
|
||||||
|
Fallthrough,
|
||||||
}
|
}
|
||||||
|
|
||||||
const INIT_POS = new TextPosition(0, 0, 0);
|
const INIT_POS = new TextPosition(0, 0, 0);
|
||||||
|
@ -400,25 +401,41 @@ export class Punctuator extends BufferedStream<Token> {
|
||||||
|
|
||||||
public read(): Token {
|
public read(): Token {
|
||||||
|
|
||||||
const refPos = this.referencePositions[this.referencePositions.length-1];
|
|
||||||
const frameType = this.frameTypes[this.frameTypes.length-1];
|
|
||||||
const t0 = this.tokens.peek(1);
|
const t0 = this.tokens.peek(1);
|
||||||
|
|
||||||
if (t0.kind === SyntaxKind.EndOfFile) {
|
switch (t0.kind) {
|
||||||
if (this.frameTypes.length === 1) {
|
case SyntaxKind.LBrace:
|
||||||
return t0;
|
this.frameTypes.push(FrameType.Fallthrough);
|
||||||
}
|
break;
|
||||||
this.frameTypes.pop();
|
case SyntaxKind.EndOfFile:
|
||||||
switch (frameType) {
|
{
|
||||||
case FrameType.LineFold:
|
if (this.frameTypes.length === 1) {
|
||||||
return new LineFoldEnd(t0.getStartPosition());
|
return t0;
|
||||||
case FrameType.Block:
|
}
|
||||||
return new BlockEnd(t0.getStartPosition());
|
const frameType = this.frameTypes.pop()!;
|
||||||
|
switch (frameType) {
|
||||||
|
case FrameType.LineFold:
|
||||||
|
return new LineFoldEnd(t0.getStartPosition());
|
||||||
|
case FrameType.Block:
|
||||||
|
return new BlockEnd(t0.getStartPosition());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const refPos = this.referencePositions[this.referencePositions.length-1];
|
||||||
|
const frameType = this.frameTypes[this.frameTypes.length-1];
|
||||||
|
|
||||||
switch (frameType) {
|
switch (frameType) {
|
||||||
|
|
||||||
|
case FrameType.Fallthrough:
|
||||||
|
{
|
||||||
|
if (t0.kind === SyntaxKind.RBrace) {
|
||||||
|
this.frameTypes.pop()!;
|
||||||
|
}
|
||||||
|
this.tokens.get();
|
||||||
|
return t0;
|
||||||
|
}
|
||||||
|
|
||||||
case FrameType.LineFold:
|
case FrameType.LineFold:
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue