Dead code. cleaning up parse. allowing trailing commas. starting to work on the 'os' palette
This commit is contained in:
parent
a30d2217b8
commit
2d687b5d38
5 changed files with 77 additions and 112 deletions
|
|
@ -140,25 +140,7 @@ export class Parser {
|
|||
}
|
||||
|
||||
private parseExpression(): AST {
|
||||
// Lambda
|
||||
if (this.isLambdaStart()) {
|
||||
return this.parseLambda();
|
||||
}
|
||||
|
||||
// Let
|
||||
if ((this.current().kind === 'ident' || this.current().kind === 'underscore') && this.peek().kind === 'equals') {
|
||||
return this.parseLet();
|
||||
}
|
||||
|
||||
let expr = this.parseInfix();
|
||||
|
||||
// Rebind
|
||||
if (this.current().kind == 'colon-equals') {
|
||||
const token = this.current();
|
||||
this.advance();
|
||||
const value = this.parseExpression();
|
||||
return { kind: 'rebind', target: expr, value, ...this.getPos(token) };
|
||||
}
|
||||
let expr = this.parseExpressionNoMatch();
|
||||
|
||||
// Match
|
||||
if (this.current().kind === 'pipe') {
|
||||
|
|
@ -180,9 +162,18 @@ export class Parser {
|
|||
return this.parseLet();
|
||||
}
|
||||
|
||||
return this.parseInfix();
|
||||
}
|
||||
let expr = this.parseInfix();
|
||||
|
||||
// Rebind
|
||||
if (this.current().kind == 'colon-equals') {
|
||||
const token = this.current();
|
||||
this.advance();
|
||||
const value = this.parseExpression();
|
||||
return { kind: 'rebind', target: expr, value, ...this.getPos(token) };
|
||||
}
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
||||
private parseMatch(expr: AST): AST {
|
||||
const token = this.current();
|
||||
|
|
@ -241,7 +232,10 @@ export class Parser {
|
|||
let spreadName: string | null = null;
|
||||
|
||||
while (this.current().kind !== 'close-bracket') {
|
||||
if (!first) this.expect('comma');
|
||||
if (!first) {
|
||||
this.expect('comma');
|
||||
if (this.current().kind === 'close-bracket') break; // trailing commas
|
||||
}
|
||||
first = false;
|
||||
|
||||
// Spread
|
||||
|
|
@ -271,7 +265,10 @@ export class Parser {
|
|||
let first = true;
|
||||
|
||||
while (this.current().kind !== 'close-brace') {
|
||||
if (!first) this.expect('comma');
|
||||
if (!first) {
|
||||
this.expect('comma');
|
||||
if (this.current().kind === 'close-brace') break; // trailing commas
|
||||
}
|
||||
first = false;
|
||||
|
||||
const keyToken = this.expect('ident');
|
||||
|
|
@ -409,6 +406,7 @@ export class Parser {
|
|||
while (this.current().kind !== 'close-brace') {
|
||||
if (!first) {
|
||||
this.expect('comma');
|
||||
if (this.current().kind === 'close-brace') break; // trailing commas
|
||||
}
|
||||
first = false;
|
||||
|
||||
|
|
@ -454,6 +452,7 @@ export class Parser {
|
|||
while (this.current().kind !== 'close-bracket') {
|
||||
if (!first) {
|
||||
this.expect('comma');
|
||||
if (this.current().kind === 'close-bracket') break; // trailing commas
|
||||
}
|
||||
first = false;
|
||||
|
||||
|
|
@ -481,6 +480,7 @@ export class Parser {
|
|||
while (this.current().kind !== 'close-brace') {
|
||||
if (!first) {
|
||||
this.expect('comma');
|
||||
if (this.current().kind === 'close-brace') break; // trailing commas
|
||||
}
|
||||
first = false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue