Scan a file for RAMULATOR_PARSE_PARAM calls. Returns list of {name, cpp_type, required, default_val}.
(filepath)
| 140 | |
| 141 | |
| 142 | def 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 | |
| 168 | def parse_children(filepath, interface_keys): |
no test coverage detected