Example #1
0
    def testParseNodeShould(self):
        "test ParseNode should allow registering of node classes"

        class CustomParseNode(ParseNode):
            def __init__(self, children):
                ParseNode.__init__(self, "CUSTOM_NODE_TYPE", children)

        ParseNode.register_node_type("CUSTOM_NODE_TYPE", CustomParseNode)
        try:

            node = ParseNode.construct_node("CUSTOM_NODE_TYPE", [])
            self.assertEquals(
                type(node), CustomParseNode,
                "ParseNode.construct_node didn't dispatch to CustomParseNode")
            self.assertEquals(node.type, "CUSTOM_NODE_TYPE",
                              "Wrong type attribute")
            self.assertEquals(node.children, [], "Wrong children")

            node = ParseNode.construct_node("FISH BOWL", ["gox blamp"])
            self.assertEquals(
                type(node), ParseNode,
                "ParseNode.construct_node didn't fall back to ParseNode")
            self.assertEquals(node.type, "FISH BOWL", "Wrong type attribute")
            self.assertEquals(node.children, ["gox blamp"], "Wrong children")

            self.assertIsNotNone(ParseNode.classRegistry,
                                 "ParseNode didn't have a class registry")
        finally:
            del ParseNode.classRegistry["CUSTOM_NODE_TYPE"]
Example #2
0
 def testRegisteredWithParse(self):
     "test registered with ParseNode"
     self.assertEquals(
         type(
             ParseNode.construct_node(ParseNode.FL_CELL_RANGE,
                                      ['a1', ':', 'b4'])),
         FLCellRangeParseNode, "Class is not registered with ParseNode")
 def testRegisteredWithParse(self):
     "test registered with ParseNode"
     self.assertEquals(
         type(ParseNode.construct_node(
             ParseNode.FL_CELL_RANGE, ['a1', ':', 'b4'])),
         FLCellRangeParseNode,
         "Class is not registered with ParseNode")
Example #4
0
 def testRegisteredWithParse(self):
     "test registered with ParseNode"
     self.assertEquals(
         type(
             ParseNode.construct_node(ParseNode.FL_NAMED_COLUMN_REFERENCE,
                                      ['dfytjdky'])),
         FLNamedColumnReferenceParseNode,
         "Class is not registered with ParseNode")
    def testParseNodeShould(self):
        "test ParseNode should allow registering of node classes"
        class CustomParseNode(ParseNode):
            def __init__(self, children):
                ParseNode.__init__(self, "CUSTOM_NODE_TYPE", children)

        ParseNode.register_node_type("CUSTOM_NODE_TYPE", CustomParseNode)
        try:

            node = ParseNode.construct_node("CUSTOM_NODE_TYPE", [])
            self.assertEquals(type(node), CustomParseNode, "ParseNode.construct_node didn't dispatch to CustomParseNode")
            self.assertEquals(node.type, "CUSTOM_NODE_TYPE", "Wrong type attribute")
            self.assertEquals(node.children, [], "Wrong children")


            node = ParseNode.construct_node("FISH BOWL", ["gox blamp"])
            self.assertEquals(type(node), ParseNode, "ParseNode.construct_node didn't fall back to ParseNode")
            self.assertEquals(node.type, "FISH BOWL", "Wrong type attribute")
            self.assertEquals(node.children, ["gox blamp"], "Wrong children")


            self.assertIsNotNone(ParseNode.classRegistry, "ParseNode didn't have a class registry")
        finally:
            del ParseNode.classRegistry["CUSTOM_NODE_TYPE"]
def ArgList(children):
    return ParseNode.construct_node(ParseNode.ARG_LIST, children)
def ArithExpr(children):
    return ParseNode.construct_node(ParseNode.ARITH_EXPR, children)
def GenIter(children):
    return ParseNode.construct_node(ParseNode.GEN_ITER, children)
Example #9
0
def VarArgsList(children):
    return ParseNode.construct_node(ParseNode.VAR_ARGS_LIST, children)
def DictMaker(children):
    return ParseNode.construct_node(ParseNode.DICT_MAKER, children)
def FPDef(children):
    return ParseNode.construct_node(ParseNode.FP_DEF, children)
Example #12
0
def FLDeletedReference(children):
    return ParseNode.construct_node(ParseNode.FL_DELETED_REFERENCE, children)
def FLReference(children):
    return ParseNode.construct_node(ParseNode.FL_REFERENCE, children)
Example #14
0
def Atom(children):
    return ParseNode.construct_node(ParseNode.ATOM, children)
Example #15
0
def FLDDECall(children):
    return ParseNode.construct_node(ParseNode.FL_DDE_CALL, children)
Example #16
0
def ArithExpr(children):
    return ParseNode.construct_node(ParseNode.ARITH_EXPR, children)
Example #17
0
def Argument(children):
    return ParseNode.construct_node(ParseNode.ARGUMENT, children)
Example #18
0
def ArgList(children):
    return ParseNode.construct_node(ParseNode.ARG_LIST, children)
def FLDDECall(children):
    return ParseNode.construct_node(ParseNode.FL_DDE_CALL, children)
Example #20
0
def FLInvalidReference(children):
    return ParseNode.construct_node(ParseNode.FL_INVALID_REFERENCE, children)
def FLInvalidReference(children):
    return ParseNode.construct_node(ParseNode.FL_INVALID_REFERENCE, children)
Example #22
0
def FLNakedWorksheetReference(children):
    return ParseNode.construct_node(ParseNode.FL_NAKED_WORKSHEET_REFERENCE,
                                    children)
def Comparison(children):
    return ParseNode.construct_node(ParseNode.COMPARISON, children)
Example #24
0
def FLReference(children):
    return ParseNode.construct_node(ParseNode.FL_REFERENCE, children)
def ExprList(children):
    return ParseNode.construct_node(ParseNode.EXPR_LIST, children)
Example #26
0
def FLRoot(children):
    return ParseNode.construct_node(ParseNode.FL_ROOT, children)
def GenFor(children):
    return ParseNode.construct_node(ParseNode.GEN_FOR, children)
Example #28
0
def Comparison(children):
    return ParseNode.construct_node(ParseNode.COMPARISON, children)
def ListFor(children):
    return ParseNode.construct_node(ParseNode.LIST_FOR, children)
Example #30
0
def CompOperator(children):
    return ParseNode.construct_node(ParseNode.COMP_OPERATOR, children)
Example #31
0
def TestListGexp(children):
    return ParseNode.construct_node(ParseNode.TEST_LIST_GEXP, children)
Example #32
0
def DictMaker(children):
    return ParseNode.construct_node(ParseNode.DICT_MAKER, children)
def Argument(children):
    return ParseNode.construct_node(ParseNode.ARGUMENT, children)
Example #34
0
def ExprList(children):
    return ParseNode.construct_node(ParseNode.EXPR_LIST, children)
def Atom(children):
    return ParseNode.construct_node(ParseNode.ATOM, children)
Example #36
0
def Factor(children):
    return ParseNode.construct_node(ParseNode.FACTOR, children)
def FLDeletedReference(children):
    return ParseNode.construct_node(ParseNode.FL_DELETED_REFERENCE, children)
Example #38
0
def FPDef(children):
    return ParseNode.construct_node(ParseNode.FP_DEF, children)
def FLNakedWorksheetReference(children):
    return ParseNode.construct_node(ParseNode.FL_NAKED_WORKSHEET_REFERENCE, children)
Example #40
0
def FPList(children):
    return ParseNode.construct_node(ParseNode.FP_LIST, children)
def FLRoot(children):
    return ParseNode.construct_node(ParseNode.FL_ROOT, children)
Example #42
0
def GenFor(children):
    return ParseNode.construct_node(ParseNode.GEN_FOR, children)
def CompOperator(children):
    return ParseNode.construct_node(ParseNode.COMP_OPERATOR, children)
Example #44
0
def GenIf(children):
    return ParseNode.construct_node(ParseNode.GEN_IF, children)
def Expr(children):
    return ParseNode.construct_node(ParseNode.EXPR, children)
Example #46
0
def Expr(children):
    return ParseNode.construct_node(ParseNode.EXPR, children)
def Factor(children):
    return ParseNode.construct_node(ParseNode.FACTOR, children)
Example #48
0
def Name(children):
    return ParseNode.construct_node(ParseNode.NAME, children)
def FPList(children):
    return ParseNode.construct_node(ParseNode.FP_LIST, children)
Example #50
0
def ShiftExpr(children):
    return ParseNode.construct_node(ParseNode.SHIFT_EXPR, children)
def GenIf(children):
    return ParseNode.construct_node(ParseNode.GEN_IF, children)
def ListIter(children):
    return ParseNode.construct_node(ParseNode.LIST_ITER, children)
def LambDef(children):
    return ParseNode.construct_node(ParseNode.LAMBDEF, children)
def Name(children):
    return ParseNode.construct_node(ParseNode.NAME, children)
def ListIf(children):
    return ParseNode.construct_node(ParseNode.LIST_IF, children)
Example #56
0
def Trailer(children):
    return ParseNode.construct_node(ParseNode.TRAILER, children)
def ListMaker(children):
    return ParseNode.construct_node(ParseNode.LIST_MAKER, children)
def AndTest(children):
    return ParseNode.construct_node(ParseNode.AND_TEST, children)
Example #59
0
 def testRegisteredWithParse(self):
     "test registered with ParseNode"
     self.assertEquals(type(ParseNode.construct_node(ParseNode.FL_ROW_REFERENCE, [])), FLRowReferenceParseNode,
                       "Class is not registered with ParseNode")
Example #60
0
def TestList(children):
    return ParseNode.construct_node(ParseNode.TEST_LIST, children)