MCPcopy Create free account
hub / github.com/CMU-SAFARI/ramulator2 / parse_params

Function parse_params

python/ramulator/cpp_parser.py:142–165  ·  view source on GitHub ↗

Scan a file for RAMULATOR_PARSE_PARAM calls. Returns list of {name, cpp_type, required, default_val}.

(filepath)

Source from the content-addressed store, hash-verified

140
141
142def parse_params(filepath):
143 """Scan a file for RAMULATOR_PARSE_PARAM calls.
144
145 Returns list of {name, cpp_type, required, default_val}.
146 """
147 with open(filepath) as f:
148 content = f.read()
149 params = []
150 for m in _RE_PARSE_PARAM.finditer(content):
151 cpp_type = m.group(1).strip()
152 name = m.group(2)
153 method = m.group(3)
154 arg = m.group(4).strip()
155
156 param = {
157 "name": name,
158 "cpp_type": cpp_type,
159 "required": method == "required",
160 "default_val": None,
161 }
162 if method == "default_val" and arg:
163 param["default_val"] = _parse_default(arg, cpp_type)
164 params.append(param)
165 return params
166
167
168def parse_children(filepath, interface_keys):

Callers 2

_parse_class_with_basesFunction · 0.85

Calls 2

openFunction · 0.85
_parse_defaultFunction · 0.85

Tested by

no test coverage detected