29 DEDENT = token.DEDENT |
31 DEDENT = token.DEDENT |
30 NEWLINE = token.NEWLINE |
32 NEWLINE = token.NEWLINE |
31 EMPTY = tokenize.NL |
33 EMPTY = tokenize.NL |
32 |
34 |
33 |
35 |
|
36 @dataclass |
34 class Token: |
37 class Token: |
35 """ |
38 """ |
36 Class to store the token related infos. |
39 Class to store the token related info. |
37 """ |
40 """ |
38 |
41 |
39 def __init__(self, **kw): |
42 type: int |
40 """ |
43 text: str |
41 Constructor |
44 row: int |
42 |
45 col: int |
43 @keyparam **kw list of key, value pairs |
46 line: str |
44 """ |
|
45 self.__dict__.update(kw) |
|
46 |
47 |
47 |
48 |
48 class Parser: |
49 class Parser: |
49 """ |
50 """ |
50 Class used to parse the source code of a Python file. |
51 Class used to parse the source code of a Python file. |
155 Public method used to store an identifier. |
156 Public method used to store an identifier. |
156 |
157 |
157 @param identifier the identifier to be remembered (string) |
158 @param identifier the identifier to be remembered (string) |
158 @param row the row, the identifier is defined in (int) |
159 @param row the row, the identifier is defined in (int) |
159 """ |
160 """ |
160 if len(self.active) > 1 and self.indent_level > self.active[-1][1]: |
161 qualified = ( |
161 # __IGNORE_WARNING_Y108__ |
162 self.active[-1][0] + "." + identifier |
162 qualified = self.active[-1][0] + "." + identifier |
163 if len(self.active) > 1 and self.indent_level > self.active[-1][1] |
163 else: |
164 else identifier |
164 qualified = identifier |
165 ) |
165 self.active.append((qualified, self.indent_level, row)) |
166 self.active.append((qualified, self.indent_level, row)) |
166 self.identifiers.append(qualified) |
167 self.identifiers.append(qualified) |
167 |
168 |
168 def inc(self, key, value=1): |
169 def inc(self, key, value=1): |
169 """ |
170 """ |