Skip to content

Commit

Permalink
Split standard diskdefs into files by prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
keirf committed Sep 6, 2024
1 parent 8575148 commit f205a42
Show file tree
Hide file tree
Showing 30 changed files with 1,380 additions and 1,319 deletions.
22 changes: 12 additions & 10 deletions src/greaseweazle/codec/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,18 @@ def _get_diskdef(
disk_match = re.match(r'disk\s+([\w,.-]+)', t)
if disk_match:
parse_mode = ParseMode.Disk
active = prefix + disk_match.group(1) == format_name
active = ((prefix + disk_match.group(1)).casefold()
== format_name.casefold())
if active:
disk = DiskDef()
else:
prefix_match = re.match(r'prefix\s+([\w,.-]+)\s+(\S+)', t)
error.check(prefix_match is not None, 'syntax error')
assert prefix_match is not None # mypy
import_match = re.match(r'import\s+([\w,.-]*)\s*"([^"]+)"',
t)
error.check(import_match is not None, 'syntax error')
assert import_match is not None # mypy
disk = _get_diskdef(format_name, DiskDef_File(
name = prefix_match.group(2),
prefix = prefix_match.group(1),
name = import_match.group(2),
prefix = import_match.group(1),
parent = diskdef_file))
if disk:
break
Expand Down Expand Up @@ -346,11 +348,11 @@ def get_all_formats(diskdef_file: DiskDef_File) -> List[str]:
disk_match = re.match(r'\s*disk\s+([\w,.-]+)', l)
if disk_match:
formats.append(prefix + disk_match.group(1))
prefix_match = re.match(r'\s*prefix\s+([\w,.-]+)\s+(\S+)', l)
if prefix_match:
import_match = re.match(r'\s*import\s+([\w,.-]*)\s*"([^"]+)"', l)
if import_match:
formats += get_all_formats(DiskDef_File(
name = prefix_match.group(2),
prefix = prefix_match.group(1),
name = import_match.group(2),
prefix = import_match.group(1),
parent = diskdef_file))
return formats

Expand Down
Loading

0 comments on commit f205a42

Please sign in to comment.