예제 #1
0
 def clearParseActions(self):
     HEXNUM.setParseAction(lambda x: x)
     REGISTER.setParseAction(lambda x: x)
     CONNECTIVE.setParseAction(lambda x: x)
     EQ_SYMBOL.setParseAction(lambda x: x)
     MEMREF.setParseAction(lambda x: x)
     RELATION.setParseAction(lambda x: x)
     FORMULA.setParseAction(lambda x: x)
예제 #2
0
 def setupParseActions(self):
     HEXNUM.setParseAction(self.createConstExpr)
     REGISTER.setParseAction(self.getRegisterExpr)
     CONNECTIVE.setParseAction(self.createNewLogicExpr)
     EQ_SYMBOL.setParseAction(self.createEqSymbol)
     MEMREF.setParseAction(self.createNewMemref)
     RELATION.setParseAction(self.createNewRelation)
     FORMULA.setParseAction(self.createNewFormula)
예제 #3
0
 def clearParseActions(self):
     HEXNUM.setParseAction(lambda x:x)
     REGISTER.setParseAction(lambda x:x)
     CONNECTIVE.setParseAction(lambda x:x)
     EQ_SYMBOL.setParseAction(lambda x:x)
     MEMREF.setParseAction(lambda x:x)
     RELATION.setParseAction(lambda x:x)
     FORMULA.setParseAction(lambda x:x)
예제 #4
0
 def setupParseActions(self):
     HEXNUM.setParseAction(self.createConstExpr)
     REGISTER.setParseAction(self.getRegisterExpr)
     CONNECTIVE.setParseAction(self.createNewLogicExpr)
     EQ_SYMBOL.setParseAction(self.createEqSymbol)
     MEMREF.setParseAction(self.createNewMemref)
     RELATION.setParseAction(self.createNewRelation)
     FORMULA.setParseAction(self.createNewFormula)
예제 #5
0
    def check_syntax(self, f_str):
        self.clearParseActions()

        if self.debug_mode:
            self.addDebugActions()

        try:
            FORMULA.parseString(f_str)
        except ParseException, e:
            return (False, str(e))
예제 #6
0
    def check_syntax(self, f_str):
        self.clearParseActions()

        if self.debug_mode:
            self.addDebugActions()

        try:
            FORMULA.parseString(f_str)
        except ParseException, e:
            return (False, str(e))
예제 #7
0
    def parseFormula(self, state_machine, f_str):
        self.sm = state_machine
        self.solver = self.sm.solver

        self.connective_stack = []
        self.eq_symbol_stack = []
        self.expr_stack = []

        self.setupParseActions()
        FORMULA.parseString(f_str)

        return self.expr_stack.pop()
예제 #8
0
 def add_debug_actions(self):
     HEXNUM.addParseAction(lambda x: self.debugLog("Hexnum %s" % str(x)))
     REGISTER.addParseAction(
         lambda x: self.debugLog("Register %s" % str(x)))
     CONNECTIVE.addParseAction(
         lambda x: self.debugLog("Connective %s" % str(x)))
     EQ_SYMBOL.addParseAction(
         lambda x: self.debugLog("Eqsymbol %s" % str(x)))
     MEMREF.addParseAction(lambda x: self.debugLog("Memref %s" % str(x)))
     RELATION.addParseAction(
         lambda x: self.debugLog("Relation %s" % str(x)))
     FORMULA.addParseAction(lambda x: self.debugLog("Formula %s" % str(x)))
예제 #9
0
    def parseFormula(self, state_machine, f_str):
        self.sm = state_machine
        self.solver = self.sm.solver

        self.connective_stack = []
        self.eq_symbol_stack = []
        self.expr_stack = []

        self.setupParseActions()
        FORMULA.parseString(f_str)

        return self.expr_stack.pop()
예제 #10
0
    def enableDebug(self, verbose=False):
        self.debug_mode = True

        if verbose:
            HEXNUM.setDebug()
            REGISTER.setDebug()
            CONNECTIVE.setDebug()
            EQ_SYMBOL.setDebug()
            MEMREF.setDebug()
            RELATION.setDebug()
            FORMULA.setDebug()

        self.add_debug_actions()
예제 #11
0
    def enableDebug(self, verbose=False):
        self.debug_mode = True

        if verbose:
            HEXNUM.setDebug()
            REGISTER.setDebug()
            CONNECTIVE.setDebug()
            EQ_SYMBOL.setDebug()
            MEMREF.setDebug()
            RELATION.setDebug()
            FORMULA.setDebug()

        self.add_debug_actions()
예제 #12
0
 def add_debug_actions(self):
     HEXNUM.addParseAction(lambda x:self.debugLog(
                 "Hexnum %s" % str(x)))
     REGISTER.addParseAction(lambda x:self.debugLog(
                 "Register %s" % str(x)))
     CONNECTIVE.addParseAction(lambda x:self.debugLog(
                 "Connective %s" % str(x)))
     EQ_SYMBOL.addParseAction(lambda x:self.debugLog(
                 "Eqsymbol %s" % str(x)))
     MEMREF.addParseAction(lambda x:self.debugLog(
                 "Memref %s" % str(x)))
     RELATION.addParseAction(lambda x:self.debugLog(
                 "Relation %s" % str(x)))
     FORMULA.addParseAction(lambda x:self.debugLog(
                 "Formula %s" % str(x)))
예제 #13
0
 def testFORMULA(self):
     FORMULA.parseString('EAX <= EBX ^ ECX = 50')
     FORMULA.parseString('EAX <= EBX')
     FORMULA.parseString('EAX = 0x50')
     #FORMULA.parseString('(EAX = 0x50)')
     self.assertRaises(ParseException, 
             FORMULA.parseString, '50 <= EAX')