MCPcopy Create free account
hub / github.com/aiscript-dev/aiscript / parsePostfix

Function parsePostfix

src/parser/syntaxes/expressions.ts:167–190  ·  view source on GitHub ↗
(s: ITokenStream, expr: Ast.Expression)

Source from the content-addressed store, hash-verified

165}
166
167function parsePostfix(s: ITokenStream, expr: Ast.Expression): Ast.Expression {
168 const startPos = s.getPos();
169 const op = s.getTokenKind();
170
171 switch (op) {
172 case TokenKind.OpenParen: {
173 return parseCall(s, expr);
174 }
175 case TokenKind.OpenBracket: {
176 s.next();
177 const index = parseExpr(s, false);
178 s.expect(TokenKind.CloseBracket);
179 s.next();
180
181 return NODE('index', {
182 target: expr,
183 index,
184 }, startPos, s.getPos());
185 }
186 default: {
187 throw unexpectedTokenError(op, startPos);
188 }
189 }
190}
191
192function parseAtom(s: ITokenStream, isStatic: boolean): Ast.Expression {
193 const startPos = s.getPos();

Callers 1

parsePrattFunction · 0.85

Calls 8

parseCallFunction · 0.85
parseExprFunction · 0.85
NODEFunction · 0.85
unexpectedTokenErrorFunction · 0.85
getPosMethod · 0.65
getTokenKindMethod · 0.65
nextMethod · 0.65
expectMethod · 0.65

Tested by

no test coverage detected