77from api .debug import __DEBUG__
88
99
10+ DEBUG_LEVEL = 3 # Which -d level is required to show debug info
11+
12+
1013class MacroCall :
1114 """ A call to a macro, stored in an object.
1215 Every time the macro() is called, the macro returns
@@ -32,41 +35,41 @@ def eval(arg):
3235 def __call__ (self , symbolTable = None ):
3336 """ Execute the macro call using LAZY evaluation
3437 """
35- __DEBUG__ ("evaluating '%s'" % self .id_ , 2 )
38+ __DEBUG__ ("evaluating '%s'" % self .id_ , DEBUG_LEVEL )
3639 if symbolTable is None :
3740 symbolTable = self .table
3841
3942 # The macro is not defined => returned as is
4043 if not self .is_defined (symbolTable ):
41- __DEBUG__ ("macro '%s' not defined" % self .id_ , 2 )
44+ __DEBUG__ ("macro '%s' not defined" % self .id_ , DEBUG_LEVEL )
4245 tmp = self .id_
4346 if self .callargs is not None :
4447 tmp += str (self .callargs )
45- __DEBUG__ ("evaluation result: %s" % tmp , 2 )
48+ __DEBUG__ ("evaluation result: %s" % tmp , DEBUG_LEVEL )
4649 return tmp
4750
4851 # The macro is defined
49- __DEBUG__ ("macro '%s' defined" % self .id_ , 2 )
52+ __DEBUG__ ("macro '%s' defined" % self .id_ , DEBUG_LEVEL )
5053 TABLE = copy .deepcopy (symbolTable )
5154 ID = TABLE [self .id_ ] # Get the defined macro
5255 if ID .hasArgs and self .callargs is None :
5356 return self .id_ # If no args passed, returned as is
5457
5558 if self .callargs : # has args. Evaluate them removing spaces
56- __DEBUG__ ("'%s' has args defined" % self .id_ , 2 )
59+ __DEBUG__ ("'%s' has args defined" % self .id_ , DEBUG_LEVEL )
5760 __DEBUG__ ("evaluating %i arg(s) for '%s'" %
58- (len (self .callargs ), self .id_ ), 2 )
61+ (len (self .callargs ), self .id_ ), DEBUG_LEVEL )
5962 args = [x (TABLE ).strip () for x in self .callargs ]
6063 __DEBUG__ ("macro call: %s%s" %
61- (self .id_ , '(' + ', ' .join (args ) + ')' ), 2 )
64+ (self .id_ , '(' + ', ' .join (args ) + ')' ), DEBUG_LEVEL )
6265
6366 if not ID .hasArgs : # The macro doesn't need args
64- __DEBUG__ ("'%s' has no args defined" % self .id_ , 2 )
67+ __DEBUG__ ("'%s' has no args defined" % self .id_ , DEBUG_LEVEL )
6568 tmp = ID (TABLE ) # If no args passed, returned as is
6669 if self .callargs is not None :
6770 tmp += '(' + ', ' .join (args ) + ')'
6871
69- __DEBUG__ ("evaluation result: %s" % tmp , 2 )
72+ __DEBUG__ ("evaluation result: %s" % tmp , DEBUG_LEVEL )
7073 return tmp
7174
7275 # Now ensure both args and callargs have the same length
@@ -76,9 +79,9 @@ def __call__(self, symbolTable=None):
7679 len (self .callargs )), self .lineno )
7780
7881 # Carry out unification
79- __DEBUG__ ('carrying out args unification' , 2 )
82+ __DEBUG__ ('carrying out args unification' , DEBUG_LEVEL )
8083 for i in range (len (self .callargs )):
81- __DEBUG__ ("arg '%s' = '%s'" % (ID .args [i ].name , args [i ]), 2 )
84+ __DEBUG__ ("arg '%s' = '%s'" % (ID .args [i ].name , args [i ]), DEBUG_LEVEL )
8285 TABLE .set (ID .args [i ].name , self .lineno , args [i ])
8386
8487 tmp = ID (TABLE )
0 commit comments