Lines Matching refs:self

27     def __init__(self, filename=None, *, verbose=False):
28 self.stack = []
29 self.in_comment = False
30 self.continuation = None
31 self.line_number = 0
32 self.filename = filename
33 self.verbose = verbose
35 def __repr__(self):
38 str(id(self)),
39 " line=", str(self.line_number),
40 " condition=", repr(self.condition()),
43 def status(self):
44 return str(self.line_number).rjust(4) + ": " + self.condition()
46 def condition(self):
50 return " && ".join(condition for token, condition in self.stack)
52 def fail(self, *a):
53 if self.filename:
54 filename = " " + self.filename
57 print("Error at" + filename, "line", self.line_number, ":")
61 def close(self):
62 if self.stack:
63 self.fail("Ended file while still in a preprocessor conditional block!")
65 def write(self, s):
67 self.writeline(line)
69 def writeline(self, line):
70 self.line_number += 1
74 if not self.stack:
75 self.fail("#" + token + " without matching #if / #ifdef / #ifndef!")
76 return self.stack.pop()
78 if self.continuation:
79 line = self.continuation + line
80 self.continuation = None
86 self.continuation = line[:-1].rstrip() + " "
101 if self.in_comment:
110 self.in_comment = False
114 if self.in_comment:
115 self.fail("Nested block comment!")
124 self.in_comment = True
146 self.fail("Invalid format for #" + token + " line: no argument!")
148 if not self.is_a_simple_defined(condition):
152 self.stack.append((previous_token, negate(previous_condition)))
156 self.fail("Invalid format for #" + token + " line: should be exactly one argument!")
163 self.stack.append((token, condition))
167 self.stack.append((previous_token, negate(previous_condition)))
176 if self.verbose:
177 print(self.status())