Skip to content

Commit

Permalink
Simplify parser, avoid extra function call (#2073)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito authored and IvanGoncharov committed Aug 3, 2019
1 parent ce8b4cd commit 392db5a
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/language/parser.js
Expand Up @@ -433,7 +433,7 @@ class Parser {
return {
kind: Kind.ARGUMENT,
name: this.parseName(),
value: (this.expectToken(TokenKind.COLON), this.parseConstValue()),
value: (this.expectToken(TokenKind.COLON), this.parseValueLiteral(true)),
loc: this.loc(start),
};
}
Expand Down Expand Up @@ -597,22 +597,14 @@ class Parser {
};
}

parseConstValue(): ValueNode {
return this.parseValueLiteral(true);
}

parseValueValue(): ValueNode {
return this.parseValueLiteral(false);
}

/**
* ListValue[Const] :
* - [ ]
* - [ Value[?Const]+ ]
*/
parseList(isConst: boolean): ListValueNode {
const start = this._lexer.token;
const item = isConst ? this.parseConstValue : this.parseValueValue;
const item = () => this.parseValueLiteral(isConst);
return {
kind: Kind.LIST,
values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R),
Expand Down Expand Up @@ -949,7 +941,7 @@ class Parser {
const type = this.parseTypeReference();
let defaultValue;
if (this.expectOptionalToken(TokenKind.EQUALS)) {
defaultValue = this.parseConstValue();
defaultValue = this.parseValueLiteral(true);
}
const directives = this.parseDirectives(true);
return {
Expand Down

0 comments on commit 392db5a

Please sign in to comment.