Skip to content

Commit 9986c76

Browse files
authored
Merge pull request #38 from jmespath-community/style-and-console-log
style: format code for better readability and maintain consistency
2 parents d0cb134 + e7259d9 commit 9986c76

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

src/AST.type.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,4 @@ export type ExpressionNode =
141141
| BindingNode
142142
| VariableNode;
143143

144-
export type ExpressionReference = { expref: true; } & ExpressionNode;
144+
export type ExpressionReference = { expref: true } & ExpressionNode;

src/Lexer.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,11 @@ class StreamLexer {
221221
this._current += 1;
222222
if (this._current < stream.length && stream[this._current] === peek) {
223223
this._current += 1;
224-
return { start: start, type: orElse, value: stream.slice(start, this._current) };
224+
return {
225+
start: start,
226+
type: orElse,
227+
value: stream.slice(start, this._current),
228+
};
225229
}
226230
return { start: start, type: token, value: stream[start] };
227231
}

src/Parser.ts

+19-5
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,19 @@ class TokenParser {
131131
}
132132
case Token.TOK_MINUS: {
133133
const child = this.expression(bindingPower.Minus);
134-
return { type: 'Unary', operator: token.type, operand: child } as UnaryArithmeticNode;
134+
return {
135+
type: 'Unary',
136+
operator: token.type,
137+
operand: child,
138+
} as UnaryArithmeticNode;
135139
}
136140
case Token.TOK_PLUS: {
137141
const child = this.expression(bindingPower.Plus);
138-
return { type: 'Unary', operator: token.type, operand: child } as UnaryArithmeticNode;
142+
return {
143+
type: 'Unary',
144+
operator: token.type,
145+
operand: child,
146+
} as UnaryArithmeticNode;
139147
}
140148
case Token.TOK_STAR: {
141149
const left: ExpressionNode = { type: 'Identity' };
@@ -148,7 +156,10 @@ class TokenParser {
148156
case Token.TOK_LBRACE:
149157
return this.parseMultiselectHash();
150158
case Token.TOK_FLATTEN: {
151-
const left: ExpressionNode = { type: 'Flatten', child: { type: 'Identity' } };
159+
const left: ExpressionNode = {
160+
type: 'Flatten',
161+
child: { type: 'Identity' },
162+
};
152163
const right: ExpressionNode = this.parseProjectionRHS(bindingPower.Flatten);
153164
return { type: 'Projection', left, right };
154165
}
@@ -178,7 +189,6 @@ class TokenParser {
178189
return { type: 'ExpressionReference', child };
179190
}
180191
case Token.TOK_LPAREN: {
181-
console.log('nud::TOK_LPAREN');
182192
const args: ExpressionNode[] = [];
183193
let expression = this.expression(0);
184194
args.push(expression);
@@ -310,7 +320,11 @@ class TokenParser {
310320
left: ExpressionNode,
311321
right: ExpressionNode,
312322
): BinaryExpressionNode<'Projection' | 'IndexExpression'> {
313-
const indexExpr: BinaryExpressionNode<'IndexExpression'> = { type: 'IndexExpression', left, right };
323+
const indexExpr: BinaryExpressionNode<'IndexExpression'> = {
324+
type: 'IndexExpression',
325+
left,
326+
right,
327+
};
314328
if (right.type === 'Slice') {
315329
return {
316330
left: indexExpr,

src/Runtime.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class Runtime {
7979

8080
constructor(interpreter: TreeInterpreter) {
8181
this._interpreter = interpreter;
82-
this._functionTable = this.functionTable
82+
this._functionTable = this.functionTable;
8383
}
8484

8585
registerFunction(

0 commit comments

Comments
 (0)