|
13 | 13 | from api.debug import __DEBUG__ |
14 | 14 | from .output import CURRENT_FILE |
15 | 15 |
|
| 16 | +DEBUG_LEVEL = 3 # Which -d level is required to show debug info |
| 17 | + |
16 | 18 |
|
17 | 19 | class ID: |
18 | 20 | """ This class represents an identifier. It stores a string |
@@ -52,37 +54,35 @@ def __dumptable(table): |
52 | 54 | sys.stdout.write("\n") |
53 | 55 |
|
54 | 56 | def __call__(self, table): |
55 | | - __DEBUG__("evaluating id '%s'" % self.name) |
| 57 | + __DEBUG__("evaluating id '%s'" % self.name, DEBUG_LEVEL) |
56 | 58 | if self.value is None: |
57 | | - __DEBUG__("undefined (null) value. BUG?") |
| 59 | + __DEBUG__("undefined (null) value. BUG?", DEBUG_LEVEL) |
58 | 60 | return '' |
59 | 61 |
|
60 | 62 | result = '' |
61 | 63 | for token in self.value: |
62 | | - __DEBUG__("evaluating token '%s'" % str(token)) |
| 64 | + __DEBUG__("evaluating token '%s'" % str(token), DEBUG_LEVEL) |
63 | 65 | if isinstance(token, MacroCall): |
64 | | - __DEBUG__("token '%s'(%s) is a MacroCall" % |
65 | | - (token.id_, str(token))) |
| 66 | + __DEBUG__("token '%s'(%s) is a MacroCall" % (token.id_, str(token)), DEBUG_LEVEL) |
66 | 67 | if table.defined(token.id_): |
67 | 68 | tmp = table[token.id_] |
68 | | - __DEBUG__("'%s' is defined in the symbol table as '%s'" % |
69 | | - (token.id_, tmp.name)) |
| 69 | + __DEBUG__("'%s' is defined in the symbol table as '%s'" % (token.id_, tmp.name), DEBUG_LEVEL) |
70 | 70 |
|
71 | 71 | if isinstance(tmp, ID) and not tmp.hasArgs: |
72 | | - __DEBUG__("'%s' is an ID" % tmp.name) |
| 72 | + __DEBUG__("'%s' is an ID" % tmp.name, DEBUG_LEVEL) |
73 | 73 | token = copy.deepcopy(token) |
74 | 74 | token.id_ = tmp(table) |
75 | | - __DEBUG__("'%s' is the new id" % token.id_) |
| 75 | + __DEBUG__("'%s' is the new id" % token.id_, DEBUG_LEVEL) |
76 | 76 |
|
77 | | - __DEBUG__("executing MacroCall '%s'" % token.id_) |
| 77 | + __DEBUG__("executing MacroCall '%s'" % token.id_, DEBUG_LEVEL) |
78 | 78 | tmp = token(table) |
79 | 79 | else: |
80 | 80 | if isinstance(token, ID): |
81 | | - __DEBUG__("token '%s' is an ID" % token.id_) |
| 81 | + __DEBUG__("token '%s' is an ID" % token.id_, DEBUG_LEVEL) |
82 | 82 | token = token(table) |
83 | 83 | tmp = token |
84 | 84 |
|
85 | | - __DEBUG__("token got value '%s'" % tmp) |
| 85 | + __DEBUG__("token got value '%s'" % tmp, DEBUG_LEVEL) |
86 | 86 | result += tmp |
87 | 87 |
|
88 | 88 | return result |
0 commit comments