rename "ArgumentType" to "ArgumentParser"

This commit is contained in:
2019-12-28 17:57:12 -08:00
parent 1e8a72d826
commit 10c9fcc4df
9 changed files with 19 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
class ArgumentType(object): class ArgumentParser(object):
def can_parse(token: str) -> bool: def can_parse(token: str) -> bool:
raise NotImplementedError() raise NotImplementedError()

View File

@@ -1,8 +1,8 @@
from .ArgumentType import ArgumentType from .ArgumentParser import ArgumentParser
from . import Arguments from . import Arguments
class Address(ArgumentType): class Address(ArgumentParser):
NAME = "Address" NAME = "Address"
@@ -20,7 +20,7 @@ class Address(ArgumentType):
return Address.NAME return Address.NAME
class Label(ArgumentType): class Label(ArgumentParser):
NAME = "Label" NAME = "Label"
@@ -39,7 +39,7 @@ class Label(ArgumentType):
return Label.NAME return Label.NAME
class Register8(ArgumentType): class Register8(ArgumentParser):
NAME = "Register8" NAME = "Register8"
@@ -63,7 +63,7 @@ class Register8(ArgumentType):
return Register8.NAME return Register8.NAME
class Register16(ArgumentType): class Register16(ArgumentParser):
NAME = "Immediate8" NAME = "Immediate8"
@@ -83,7 +83,7 @@ class Register16(ArgumentType):
return Register16.NAME return Register16.NAME
class Immediate8(ArgumentType): class Immediate8(ArgumentParser):
NAME = "Immediate8" NAME = "Immediate8"
@@ -100,7 +100,7 @@ class Immediate8(ArgumentType):
def get_name(self) -> str: def get_name(self) -> str:
return Immediate8.NAME return Immediate8.NAME
class Immediate16(ArgumentType): class Immediate16(ArgumentParser):
NAME = "Immediate16" NAME = "Immediate16"
@@ -121,7 +121,7 @@ class Immediate16(ArgumentType):
return Immediate16.NAME return Immediate16.NAME
class Flag(ArgumentType): class Flag(ArgumentParser):
NAME = "Flag" NAME = "Flag"

View File

@@ -1,3 +1,3 @@
from .ArgumentType import ArgumentType from .ArgumentParser import ArgumentParser
from .ArgumentTypes import Label, Address, Immediate8, Immediate16, Register8, Register16 from .ArgumentParsers import Label, Address, Immediate8, Immediate16, Register8, Register16
from .Arguments import Argument from .Arguments import Argument

View File

@@ -11,7 +11,7 @@ from .instructions.nop import Nop
from .instructions.stop import Stop from .instructions.stop import Stop
from .instructions.jr import Jr from .instructions.jr import Jr
from .instructions.ld import Ld from .instructions.ld import Ld
from .arguments import ArgumentType, Argument from .arguments import ArgumentParser, Argument
from typing import Callable, Dict, List, Optional from typing import Callable, Dict, List, Optional
@@ -36,7 +36,7 @@ def build_instruction_map() -> Dict[str, Instruction]:
return d return d
def try_parse_arguments(args: List[str], def try_parse_arguments(args: List[str],
arg_types: List[ArgumentType]) -> Optional[List[Argument]]: arg_types: List[ArgumentParser]) -> Optional[List[Argument]]:
if len(args) != len(arg_types): if len(args) != len(arg_types):
return None return None

View File

@@ -1,9 +1,9 @@
from typing import Callable, List from typing import Callable, List
from ..arguments import Argument, ArgumentType from ..arguments import Argument, ArgumentParser
class Instruction(object): class Instruction(object):
def __init__(self, token: str, argument_specs: List[List[ArgumentType]]): def __init__(self, token: str, argument_specs: List[List[ArgumentParser]]):
self.token = token self.token = token
self.argument_specs = argument_specs self.argument_specs = argument_specs

View File

@@ -1,5 +1,5 @@
from .Instruction import Instruction from .Instruction import Instruction
from ..arguments.ArgumentTypes import Register8, Register16 from ..arguments.ArgumentParsers import Register8, Register16
from ..arguments import Argument from ..arguments import Argument
from typing import Callable, List from typing import Callable, List

View File

@@ -1,5 +1,5 @@
from .Instruction import Instruction from .Instruction import Instruction
from ..arguments.ArgumentTypes import Register8, Register16 from ..arguments.ArgumentParsers import Register8, Register16
from ..arguments import Argument from ..arguments import Argument
from typing import Callable, List from typing import Callable, List

View File

@@ -1,5 +1,5 @@
from .Instruction import Instruction from .Instruction import Instruction
from ..arguments.ArgumentTypes import Flag, Label from ..arguments.ArgumentParsers import Flag, Label
from ..arguments import Argument from ..arguments import Argument
from typing import Callable, List from typing import Callable, List

View File

@@ -1,5 +1,5 @@
from .Instruction import Instruction from .Instruction import Instruction
from ..arguments.ArgumentTypes import Register16, Immediate16 from ..arguments.ArgumentParsers import Register16, Immediate16
from ..arguments import Argument from ..arguments import Argument
from typing import Callable, List from typing import Callable, List