def pyF1ToCfgCompare(compNd):
     ''' extract a compare node - returns new model node else returns None on no match '''
     left = __class__.pyF1ToCfgData(compNd.left)
     right = __class__.pyF1ToCfgData(compNd.comparators[0])
     op = __class__.pyToCfgCompareOp(compNd)
     #print(type(compNd).__name__, 'left:', left, 'op:', op, 'right:', right)
     if op.isSupported():
         compNd.__cfg_valid__ = True  # tag this ast node as translated
     return Cm.CfgCompare(left, op,
                          right)  # TODO check ops here before creating
Exemple #2
0
 def enterWhile_loop(self, ctx: ConfigParser.While_loopContext):
     #print('enterWhile_loop: ')
     leftOp = ctx.value(0).getText()
     rightOp = ctx.value(1).getText()
     compareOp = ctx.compare_op().getText()
     #print(' ' + compareOp + ' ' + rightOp)
     leftVal = Cm.CfgVariable.resolveRhsExpression(
         leftOp, Cm.CfgNumDataType)  # numeric var or instance
     rightVal = Cm.CfgVariable.resolveRhsExpression(
         rightOp, Cm.CfgNumDataType)  # numeric var or instance
     whileCompare = Cm.CfgCompare(leftVal, compareOp, rightVal)
     Cm.CfgWhileNode(whileCompare)
Exemple #3
0
 def enterPoll_config_call(self, ctx: ConfigParser.Poll_config_callContext):
     #print('enterPoll_config_call: ')
     readType = ctx.getChild(0).getText()
     readPath = ctx.path().getText()
     pollOp = ctx.compare_op().getText()
     pollVal = ctx.value(0).getText()
     #print(' ' + readType + ' ' + readPath + ' ' + pollOp + ' ' + pollVal)
     rtype = Cm.CfgPathHierType.resolve(
         readType)  # poll is compare of read value, so explicitly set type
     rNode = Cm.CfgReadNode(readPath, rtype, None)
     pVal = Cm.CfgVariable.resolveRhsExpression(
         pollVal,
         Cm.CfgNumDataType)  # read compares to a numeric var or instance
     whileCompare = Cm.CfgCompare(rNode, pollOp, pVal)
     Cm.CfgWhileNode(whileCompare)