riscemu.Tokenizer module¶
RiscEmu (c) 2021 Anton Lydike
SPDX-License-Identifier: MIT
-
riscemu.Tokenizer.
split_accepting_quotes
(string, at=re.compile('^,[ \\t]*'), quotes=('"', "'"))¶
-
class
riscemu.Tokenizer.
RiscVInput
(content: str, name: str)¶ Bases:
object
Represents an Assembly file
-
__init__
(content: str, name: str)¶ Initialize self. See help(type(self)) for accurate signature.
-
static
from_file
(src: str)¶
-
peek
(offset: int = 0, size: int = 1, regex: Optional[re.Pattern] = None, text: Optional[str] = None, regex_group: int = 0)¶
-
peek_one_of
(options: List[str])¶
-
consume
(size: int = 1, regex: Optional[re.Pattern] = None, text: Optional[str] = None, regex_group: int = 0)¶
-
consume_one_of
(options: List[str])¶
-
seek_newline
()¶
-
consume_whitespace
(linebreak=True)¶
-
has_next
()¶
-
context
(size: int = 5)¶ returns a context string: <local input before pos>|<local input after pos>
-
-
class
riscemu.Tokenizer.
TokenType
(value)¶ Bases:
enum.IntEnum
An enumeration.
-
SYMBOL
= 0¶
-
INSTRUCTION
= 1¶
-
PSEUDO_OP
= 2¶
-
-
class
riscemu.Tokenizer.
RiscVToken
(t_type: riscemu.Tokenizer.TokenType)¶ Bases:
object
-
__init__
(t_type: riscemu.Tokenizer.TokenType)¶ Initialize self. See help(type(self)) for accurate signature.
-
text
()¶ create text representation of instruction
-
-
class
riscemu.Tokenizer.
RiscVInstructionToken
(name, args)¶ Bases:
riscemu.Tokenizer.RiscVToken
-
__init__
(name, args)¶ Initialize self. See help(type(self)) for accurate signature.
-
text
()¶ create text representation of instruction
-
-
class
riscemu.Tokenizer.
RiscVSymbolToken
(name)¶ Bases:
riscemu.Tokenizer.RiscVToken
-
__init__
(name)¶ Initialize self. See help(type(self)) for accurate signature.
-
text
()¶ create text representation of instruction
-
-
class
riscemu.Tokenizer.
RiscVPseudoOpToken
(name, args)¶ Bases:
riscemu.Tokenizer.RiscVToken
-
__init__
(name, args)¶ Initialize self. See help(type(self)) for accurate signature.
-
text
()¶ create text representation of instruction
-
-
class
riscemu.Tokenizer.
RiscVTokenizer
(input_assembly: riscemu.Tokenizer.RiscVInput, instructions: List[str])¶ Bases:
object
A tokenizer for the RISC-V syntax of a given CPU
-
__init__
(input_assembly: riscemu.Tokenizer.RiscVInput, instructions: List[str])¶ Initialize self. See help(type(self)) for accurate signature.
-
tokenize
()¶
-
parse_pseudo_op
()¶
-
parse_symbol
()¶
-
parse_instruction
()¶
-
parse_comment
()¶
-