MCPcopy Create free account
hub / github.com/dop251/goja / parseUnaryExpression

Method parseUnaryExpression

parser/expression.go:853–889  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

851}
852
853func (self *_parser) parseUnaryExpression() ast.Expression {
854
855 switch self.token {
856 case token.PLUS, token.MINUS, token.NOT, token.BITWISE_NOT:
857 fallthrough
858 case token.DELETE, token.VOID, token.TYPEOF:
859 tkn := self.token
860 idx := self.idx
861 self.next()
862 return &ast.UnaryExpression{
863 Operator: tkn,
864 Idx: idx,
865 Operand: self.parseUnaryExpression(),
866 }
867 case token.AWAIT:
868 if self.scope.allowAwait {
869 idx := self.idx
870 self.next()
871 if !self.scope.inAsync {
872 self.errorUnexpectedToken(token.AWAIT)
873 return &ast.BadExpression{
874 From: idx,
875 To: self.idx,
876 }
877 }
878 if self.scope.inFuncParams {
879 self.error(idx, "Illegal await-expression in formal parameters of async function")
880 }
881 return &ast.AwaitExpression{
882 Await: idx,
883 Argument: self.parseUnaryExpression(),
884 }
885 }
886 }
887
888 return self.parseUpdateExpression()
889}
890
891func (self *_parser) parseExponentiationExpression() ast.Expression {
892 parenthesis := self.token == token.LEFT_PARENTHESIS

Callers 2

parseUpdateExpressionMethod · 0.95

Calls 4

nextMethod · 0.95
errorUnexpectedTokenMethod · 0.95
errorMethod · 0.95
parseUpdateExpressionMethod · 0.95

Tested by

no test coverage detected