How to use the edgedb.lang.common.lang.javascript.parser.js.Nonterm function in edgedb

To help you get started, we’ve selected a few edgedb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github edgedb / edgedb / edgedb / lang / common / lang / javascript / parser / js.py View on Github external
# | LSBRACKET ElementList RSBRACKET
    # | LSBRACKET ElementList COMMA Elision RSBRACKET

    def reduce_LSBRACKET_ElisionOPT_RSBRACKET(self, *kids):
        "%reduce LSBRACKET ElisionOPT RSBRACKET"
        self.val = jsast.ArrayLiteralNode(array=kids[1].val)

    def reduce_LSBRACKET_ElementList_RSBRACKET(self, *kids):
        "%reduce LSBRACKET ElementList RSBRACKET"
        self.val = jsast.ArrayLiteralNode(array=kids[1].val)

    def reduce_LSBRACKET_ElementList_COMMA_Elision_RSBRACKET(self, *kids):
        "%reduce LSBRACKET ElementList COMMA Elision RSBRACKET"
        self.val = jsast.ArrayLiteralNode(array=kids[1].val + kids[3].val)

class ElisionOPT(Nonterm):
    #  | Elision

    def reduce_empty(self, *kids):
        "%reduce "
        self.val = []

    def reduce_Elision(self, *kids):
        "%reduce Elision"
        self.val = kids[0].val

class Elision(Nonterm):
    # COMMA | Elision COMMA

    def reduce_COMMA(self, *kids):
        "%reduce COMMA"
        self.val = [None]
github edgedb / edgedb / edgedb / lang / common / lang / javascript / parser / js.py View on Github external
self.val = kids[0].val
class ConditionalExpressionNotSTMT(Nonterm, ConditionalExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> NotSTMT, RIGHTMOD -> '''
class AssignmentExpressionNotSTMT(Nonterm, AssignmentExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] CONDMOD -> NotSTMT, LEFTMOD -> NotSTMT, RIGHTMOD -> '''


class ExpressionListSTMT(Nonterm, ExpressionList_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT, RIGHTMOD -> '''
class CallExpressionSTMT(Nonterm, CallExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT'''
class LHSExpressionSTMT(Nonterm, LHSExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT'''
class PostfixExpressionSTMT(Nonterm, PostfixExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT'''
class UnaryExpressionSTMT(Nonterm, UnaryExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT'''
class ConditionalExpressionSTMT(Nonterm, ConditionalExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT, RIGHTMOD -> '''
class AssignmentExpressionSTMT(Nonterm, AssignmentExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] CONDMOD -> STMT, LEFTMOD -> STMT, RIGHTMOD -> '''


#class ExpressionListNoIN(Nonterm, ExpressionList_template, metaclass=ProductionGenMeta):
#    '''[generate][replace] LEFTMOD -> NoIN, RIGHTMOD -> NoIN'''
#class ConditionalExpressionNoIN(Nonterm, ConditionalExpression_template, metaclass=ProductionGenMeta):
#    '''[generate][replace] LEFTMOD -> NoIN, RIGHTMOD -> NoIN'''
#class AssignmentExpressionNoIN(Nonterm, AssignmentExpression_template, metaclass=ProductionGenMeta):
#    '''[generate][replace] CONDMOD -> NoIN, LEFTMOD -> STMT, RIGHTMOD -> NoIN'''


class ExpressionListOPT(Nonterm):
github edgedb / edgedb / edgedb / lang / common / lang / javascript / parser / js.py View on Github external
'''[generate][replace] LEFTMOD -> NotSTMT, RIGHTMOD -> '''
class AssignmentExpressionNotSTMT(Nonterm, AssignmentExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] CONDMOD -> NotSTMT, LEFTMOD -> NotSTMT, RIGHTMOD -> '''


class ExpressionListSTMT(Nonterm, ExpressionList_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT, RIGHTMOD -> '''
class CallExpressionSTMT(Nonterm, CallExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT'''
class LHSExpressionSTMT(Nonterm, LHSExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT'''
class PostfixExpressionSTMT(Nonterm, PostfixExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT'''
class UnaryExpressionSTMT(Nonterm, UnaryExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT'''
class ConditionalExpressionSTMT(Nonterm, ConditionalExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT, RIGHTMOD -> '''
class AssignmentExpressionSTMT(Nonterm, AssignmentExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] CONDMOD -> STMT, LEFTMOD -> STMT, RIGHTMOD -> '''


#class ExpressionListNoIN(Nonterm, ExpressionList_template, metaclass=ProductionGenMeta):
#    '''[generate][replace] LEFTMOD -> NoIN, RIGHTMOD -> NoIN'''
#class ConditionalExpressionNoIN(Nonterm, ConditionalExpression_template, metaclass=ProductionGenMeta):
#    '''[generate][replace] LEFTMOD -> NoIN, RIGHTMOD -> NoIN'''
#class AssignmentExpressionNoIN(Nonterm, AssignmentExpression_template, metaclass=ProductionGenMeta):
#    '''[generate][replace] CONDMOD -> NoIN, LEFTMOD -> STMT, RIGHTMOD -> NoIN'''


class ExpressionListOPT(Nonterm):
    #  | ExpressionList
    def reduce_empty(self, *kids):
github edgedb / edgedb / edgedb / lang / common / lang / javascript / parser / js.py View on Github external
'''[generate][replace] LEFTMOD -> NotSTMT'''
class PostfixExpressionNotSTMT(Nonterm, PostfixExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> NotSTMT'''
class UnaryExpressionNotSTMT(Nonterm):
    def reduce_PostfixExpression(self, *kids):
        "%reduce PostfixExpressionNotSTMT"
        self.val = kids[0].val
class ConditionalExpressionNotSTMT(Nonterm, ConditionalExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> NotSTMT, RIGHTMOD -> '''
class AssignmentExpressionNotSTMT(Nonterm, AssignmentExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] CONDMOD -> NotSTMT, LEFTMOD -> NotSTMT, RIGHTMOD -> '''


class ExpressionListSTMT(Nonterm, ExpressionList_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT, RIGHTMOD -> '''
class CallExpressionSTMT(Nonterm, CallExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT'''
class LHSExpressionSTMT(Nonterm, LHSExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT'''
class PostfixExpressionSTMT(Nonterm, PostfixExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT'''
class UnaryExpressionSTMT(Nonterm, UnaryExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT'''
class ConditionalExpressionSTMT(Nonterm, ConditionalExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT, RIGHTMOD -> '''
class AssignmentExpressionSTMT(Nonterm, AssignmentExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] CONDMOD -> STMT, LEFTMOD -> STMT, RIGHTMOD -> '''


#class ExpressionListNoIN(Nonterm, ExpressionList_template, metaclass=ProductionGenMeta):
#    '''[generate][replace] LEFTMOD -> NoIN, RIGHTMOD -> NoIN'''
#class ConditionalExpressionNoIN(Nonterm, ConditionalExpression_template, metaclass=ProductionGenMeta):
github edgedb / edgedb / edgedb / lang / common / lang / javascript / parser / js.py View on Github external
#    def reduce_EqualityExpression(self, *kids):
#        "%reduce EqualityExpressionNoIN"
#        self.val = kids[0].val


class BitwiseXORExpressionNotSTMT(Nonterm, BinaryExpression_template, metaclass=ProductionGenMeta):
    '''
    [generate] {template; OP; CIRCUM}
    [replace] LEFTSIDE -> BitwiseXORExpressionNotSTMT, RIGHTSIDE -> BitwiseANDExpression
    '''
    def reduce_BitwiseANDExpression(self, *kids):
        "%reduce BitwiseANDExpressionNotSTMT"
        self.val = kids[0].val


class BitwiseXORExpressionSTMT(Nonterm, BinaryExpression_template, metaclass=ProductionGenMeta):
    '''
    [generate] {template; OP; CIRCUM}
    [replace] LEFTSIDE -> BitwiseXORExpressionSTMT, RIGHTSIDE -> BitwiseANDExpression
    '''
    def reduce_BitwiseANDExpression(self, *kids):
        "%reduce BitwiseANDExpressionSTMT"
        self.val = kids[0].val


#class BitwiseXORExpressionNoIN(Nonterm, BinaryExpression_template, metaclass=ProductionGenMeta):
#    '''
#    [generate] {template; OP; CIRCUM}
#    [replace] LEFTSIDE -> BitwiseXORExpressionSTMT, RIGHTSIDE -> BitwiseANDExpression
#    '''
#    def reduce_BitwiseANDExpression(self, *kids):
#        "%reduce BitwiseANDExpressionNoIN"
github edgedb / edgedb / edgedb / lang / common / lang / javascript / parser / js.py View on Github external
def reduce_empty(self, *kids):
        "%reduce "
        self.val = None

    def reduce_ExpressionList(self, *kids):
        "%reduce ExpressionList"
        self.val = kids[0].val


class AssignmentOp_template():
    def template(self, *kids):
        'reduce OP'
        self.val = kids[0].val


class AssignmentOp(Nonterm, AssignmentOp_template, metaclass=ProductionGenMeta):
    '''
    [generate]
    {template; OP;
    ASSIGN | MULTASSIGN | DIVASSIGN | REMAINASSIGN
    | PLUSASSIGN | MINUSASSIGN
    | LSHIFTASSIGN | SRSHIFTASSIGN | ZRSHIFTASSIGN
    | ANDASSIGN | XORASSIGN | ORASSIGN }
    [replace]
    '''


class ArrayLiteral(Nonterm):
    # LSBRACKET ElisionOPT RSBRACKET
    # | LSBRACKET ElementList RSBRACKET
    # | LSBRACKET ElementList COMMA Elision RSBRACKET
github edgedb / edgedb / edgedb / lang / common / lang / javascript / parser / js.py View on Github external
# | OtherIfOpenStatements

    def reduce_IfClause_Statement(self, *kids):
        "%reduce IfClause Statement"
        self.val = jsast.IfNode(ifclause=kids[0].val, thenclause=kids[1].val, elseclause=None)

    def reduce_IfClause_IfClosedStatement_ELSE_IfOpenStatement(self, *kids):
        "%reduce IfClause IfClosedStatement ELSE IfOpenStatement"
        self.val = jsast.IfNode(ifclause=kids[0].val, thenclause=kids[1].val, elseclause=kids[3].val)

    def reduce_OtherIfOpenStatement(self, *kids):
        "%reduce OtherIfOpenStatement"
        self.val = kids[0].val


class IfClosedStatement(Nonterm):
    # all 'if' are paired up with 'else'
    #
    # BasicStatement
    # | IfClause IfClosedStatement ELSE IfClosedStatement
    # | OtherIfClosedStatement

    def reduce_BasicStatement(self, *kids):
        "%reduce BasicStatement"
        self.val = kids[0].val

    def reduce_IfClause_IfClosedStatement_ELSE_IfClosedStatement(self, *kids):
        "%reduce IfClause IfClosedStatement ELSE IfClosedStatement"
        self.val = jsast.IfNode(ifclause=kids[0].val, thenclause=kids[1].val, elseclause=kids[3].val)

    def reduce_OtherIfClosedStatement(self, *kids):
        "%reduce OtherIfClosedStatement"
github edgedb / edgedb / edgedb / lang / common / lang / javascript / parser / js.py View on Github external
#    ExpressionSTMT -> BinaryExpressionSTMT'''
#class ConditionalExpression(Nonterm, Expression_template, metaclass=ProductionGenMeta):
#    '''[generate][replace]
#    ExpressionNotSTMT -> ConditionalExpressionNotSTMT,
#    ExpressionSTMT -> ConditionalExpressionSTMT'''
class AssignmentExpression(Nonterm, Expression_template, metaclass=ProductionGenMeta):
    '''[generate][replace]
    ExpressionNotSTMT -> AssignmentExpressionNotSTMT,
    ExpressionSTMT -> AssignmentExpressionSTMT'''


class ExpressionListNotSTMT(Nonterm, ExpressionList_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> NotSTMT, RIGHTMOD -> '''
class CallExpressionNotSTMT(Nonterm, CallExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> NotSTMT'''
class LHSExpressionNotSTMT(Nonterm, LHSExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> NotSTMT'''
class PostfixExpressionNotSTMT(Nonterm, PostfixExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> NotSTMT'''
class UnaryExpressionNotSTMT(Nonterm):
    def reduce_PostfixExpression(self, *kids):
        "%reduce PostfixExpressionNotSTMT"
        self.val = kids[0].val
class ConditionalExpressionNotSTMT(Nonterm, ConditionalExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> NotSTMT, RIGHTMOD -> '''
class AssignmentExpressionNotSTMT(Nonterm, AssignmentExpression_template, metaclass=ProductionGenMeta):
    '''[generate][replace] CONDMOD -> NotSTMT, LEFTMOD -> NotSTMT, RIGHTMOD -> '''


class ExpressionListSTMT(Nonterm, ExpressionList_template, metaclass=ProductionGenMeta):
    '''[generate][replace] LEFTMOD -> STMT, RIGHTMOD -> '''
class CallExpressionSTMT(Nonterm, CallExpression_template, metaclass=ProductionGenMeta):
github edgedb / edgedb / edgedb / lang / common / lang / javascript / parser / js.py View on Github external
def reduce_SourceElement(self, *kids):
        "%reduce SourceElement"
        if kids[0].val == None:
            self.val = jsast.SourceElementsNode(code=[])
        else:
            self.val = jsast.SourceElementsNode(code=[kids[0].val])

    def reduce_SourceElements_SourceElement(self, *kids):
        "%reduce SourceElements SourceElement"
        if kids[1].val != None:
            kids[0].val.code += [kids[1].val]
        self.val = kids[0].val


class SourceElement(Nonterm):
    # Statement | FunctionDeclaration

    def reduce_Statement(self, *kids):
        "%reduce Statement"
        self.val = kids[0].val

#    def reduce_FunctionDeclaration(self, *kids):
#        "%reduce FunctionDeclaration"
#        self.val = kids[0].val


# Expressions

# need to distinguish expresions based on:
# 1) whether they contain 'in'
# 2) whether they start with an object literal
github edgedb / edgedb / edgedb / lang / common / lang / javascript / parser / js.py View on Github external
# catch ( Identifier ) Block

    def reduce_CATCH_LPAREN_ID_RPAREN_Block(self, *kids):
        "%reduce CATCH LPAREN ID RPAREN Block"
        self.id, self.val = kids[2].val, kids[4].val

class Finally(Nonterm):
    # finally Block

    def reduce_FINALLY_Block(self, *kids):
        "%reduce FINALLY Block"
        self.val = kids[1].val

# function

class FunctionExpression(Nonterm):
    # function ( ) { FunctionBody }
    # | function Identifier ( ) { FunctionBody }
    # | function ( FormalParameterList ) { FunctionBody }
    # | function Identifier ( FormalParameterList ) { FunctionBody }

    def reduce_function_without_id_and_parameters(self, *kids):
        "%reduce FUNCTION LPAREN RPAREN LCBRACKET FunctionBody RCBRACKET"
        self.val = jsast.FunctionNode(name=None, param=[], body=kids[4].val)

    def reduce_function_with_name_and_without_parameters(self, *kids):
        "%reduce FUNCTION ID LPAREN RPAREN LCBRACKET FunctionBody RCBRACKET"
        self.val = jsast.FunctionNode(name=kids[1].val, param=[], body=kids[5].val)

    def reduce_function_without_name_and_with_parameters(self, *kids):
        "%reduce FUNCTION LPAREN FormalParameterList RPAREN LCBRACKET FunctionBody RCBRACKET"
        self.val = jsast.FunctionNode(name=None, param=kids[2].val, body=kids[5].val)