MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / UpdateCharState

Function UpdateCharState

tools/cpp_format_struct_table.py:102–133  ·  view source on GitHub ↗
(c: str, state: CharState)

Source from the content-addressed store, hash-verified

100
101
102def UpdateCharState(c: str, state: CharState):
103 prev_char = state.prev_char
104 state.prev_char = c
105 state.pushed_paren = ""
106 if state.in_comment:
107 if prev_char == "*" and c == "/":
108 state.in_comment = False
109 return
110 if prev_char == "/" and c == "*":
111 state.in_comment = True
112 return
113 if state.backslash_escape:
114 state.backslash_escape = False
115 return
116 if c == "\\":
117 state.backslash_escape = True
118 elif c == '"' or c == "'":
119 if not state.quotes:
120 state.quotes.append(c)
121 elif state.quotes[-1] == c:
122 state.quotes.pop()
123 elif not state.quotes:
124 if c in _OPEN_PARENTHESES:
125 state.parentheses.append(c)
126 state.pushed_paren = c
127 elif c in _CLOSE_PARENTHESES:
128 if state.parentheses and state.parentheses[-1] == _PARENTHESES_MAP.get(c):
129 state.parentheses.pop()
130 else:
131 raise RuntimeError(
132 f"Mismatched parenthesis. Stack: {state.parentheses}. Value: '{c}'"
133 )
134
135
136_SKIP_LINE_RE = re.compile(r"^\s*(//|\})")

Callers 1

ParseRowFunction · 0.85

Calls 2

popMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected