Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion esprima/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

del U_CATEGORIES, UNICODE_LETTER, UNICODE_COMBINING_MARK
del UNICODE_DIGIT, UNICODE_CONNECTOR_PUNCTUATION
del DECIMAL_CONV, OCTAL_CONV, HEX_CONV
del DECIMAL_CONV

class Character:
@staticmethod
Expand Down
3 changes: 3 additions & 0 deletions esprima/esprima.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def parse(code, options=None, delegate=None, **kwargs):
options['jsx'] = True
options['classProperties'] = True

# Auto-enable features for ES2024
options['classProperties'] = True # ES2022: Public class fields

commentHandler = None

def proxyDelegate(node, metadata):
Expand Down
49 changes: 41 additions & 8 deletions esprima/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ def __init__(self, params, body, expression):


class AsyncFunctionDeclaration(Node):
def __init__(self, id, params, body):
def __init__(self, id, params, body, generator=False):
self.type = Syntax.FunctionDeclaration
self.generator = False
self.generator = generator
self.expression = False
self.isAsync = True
self.id = id
Expand All @@ -101,9 +101,9 @@ def __init__(self, id, params, body):


class AsyncFunctionExpression(Node):
def __init__(self, id, params, body):
def __init__(self, id, params, body, generator=False):
self.type = Syntax.FunctionExpression
self.generator = False
self.generator = generator
self.expression = False
self.isAsync = True
self.id = id
Expand Down Expand Up @@ -138,10 +138,11 @@ def __init__(self, label):


class CallExpression(Node):
def __init__(self, callee, args):
def __init__(self, callee, args, optional=False):
self.type = Syntax.CallExpression
self.callee = callee
self.arguments = args
self.optional = optional


class CatchClause(Node):
Expand All @@ -151,6 +152,12 @@ def __init__(self, param, body):
self.body = body


class ChainExpression(Node):
def __init__(self, expression):
self.type = Syntax.ChainExpression
self.expression = expression


class ClassBody(Node):
def __init__(self, body):
self.type = Syntax.ClassBody
Expand All @@ -174,11 +181,12 @@ def __init__(self, id, superClass, body):


class ComputedMemberExpression(Node):
def __init__(self, object, property):
def __init__(self, object, property, optional=False):
self.type = Syntax.MemberExpression
self.computed = True
self.object = object
self.property = property
self.optional = optional


class ConditionalExpression(Node):
Expand Down Expand Up @@ -275,6 +283,14 @@ def __init__(self, left, right, body):
self.body = body


class ForAwaitStatement(Node):
def __init__(self, left, right, body):
self.type = Syntax.ForAwaitStatement
self.left = left
self.right = right
self.body = body


class ForStatement(Node):
def __init__(self, init, test, update, body):
self.type = Syntax.ForStatement
Expand Down Expand Up @@ -312,6 +328,18 @@ def __init__(self, name):
self.name = name


class PrivateIdentifier(Node):
def __init__(self, name):
self.type = Syntax.PrivateIdentifier
self.name = name


class StaticBlock(Node):
def __init__(self, body):
self.type = Syntax.StaticBlock
self.body = body


class IfStatement(Node):
def __init__(self, test, consequent, alternate):
self.type = Syntax.IfStatement
Expand All @@ -326,10 +354,14 @@ def __init__(self):


class ImportDeclaration(Node):
def __init__(self, specifiers, source):
def __init__(self, specifiers, source, assertions=None, attributes=None):
self.type = Syntax.ImportDeclaration
self.specifiers = specifiers
self.source = source
if assertions is not None:
self.assertions = assertions
if attributes is not None:
self.attributes = attributes


class ImportDefaultSpecifier(Node):
Expand Down Expand Up @@ -472,11 +504,12 @@ def __init__(self, argument):


class StaticMemberExpression(Node):
def __init__(self, object, property):
def __init__(self, object, property, optional=False):
self.type = Syntax.MemberExpression
self.computed = False
self.object = object
self.property = property
self.optional = optional


class Super(Node):
Expand Down
Loading