This package offers both a portable {py3} module and a command-line
tool.
-WARNING: This version of Normand is 0.4, meaning both the Normand
+WARNING: This version of Normand is 0.5, meaning both the Normand
language and the module/CLI interface aren't stable.
ifdef::env-github[]
LE = ...
-VarsT = typing.Dict[str, int]
-
-
class TextLoc:
# Line number.
@property
...
+SymbolsT = typing.Dict[str, int]
+
+
class ParseResult:
# Generated data.
@property
# Updated variable values.
@property
- def variables(self) -> VarsT:
+ def variables(self) -> SymbolsT:
...
# Updated main group label values.
@property
- def labels(self) -> VarsT:
+ def labels(self) -> SymbolsT:
...
# Final offset.
# Final byte order.
@property
- def byte_order(self) -> typing.Optional[int]:
+ def byte_order(self) -> typing.Optional[ByteOrder]:
...
+
def parse(normand: str,
- init_variables: typing.Optional[VarsT] = None,
- init_labels: typing.Optional[VarsT] = None,
+ init_variables: typing.Optional[SymbolsT] = None,
+ init_labels: typing.Optional[SymbolsT] = None,
init_offset: int = 0,
init_byte_order: typing.Optional[ByteOrder] = None) -> ParseResult:
...
# Upstream repository: <https://github.com/efficios/normand>.
__author__ = "Philippe Proulx"
-__version__ = "0.4.0"
+__version__ = "0.5.0"
__all__ = [
"ByteOrder",
"parse",
"ParseError",
"ParseResult",
"TextLoc",
- "VarsT",
+ "SymbolsT",
"__author__",
"__version__",
]
# Variable/label dictionary type.
-VarsT = Dict[str, int]
+SymbolsT = Dict[str, int]
# Python name pattern.
class _Parser:
# Builds a parser to parse the Normand input `normand`, parsing
# immediately.
- def __init__(self, normand: str, variables: VarsT, labels: VarsT):
+ def __init__(self, normand: str, variables: SymbolsT, labels: SymbolsT):
self._normand = normand
self._at = 0
self._line_no = 1
def _create(
cls,
data: bytearray,
- variables: VarsT,
- labels: VarsT,
+ variables: SymbolsT,
+ labels: SymbolsT,
offset: int,
bo: Optional[ByteOrder],
):
def _init(
self,
data: bytearray,
- variables: VarsT,
- labels: VarsT,
+ variables: SymbolsT,
+ labels: SymbolsT,
offset: int,
bo: Optional[ByteOrder],
):
# Generator state.
class _GenState:
def __init__(
- self, variables: VarsT, labels: VarsT, offset: int, bo: Optional[ByteOrder]
+ self,
+ variables: SymbolsT,
+ labels: SymbolsT,
+ offset: int,
+ bo: Optional[ByteOrder],
):
self.variables = variables.copy()
self.labels = labels.copy()
def __init__(
self,
group: _Group,
- variables: VarsT,
- labels: VarsT,
+ variables: SymbolsT,
+ labels: SymbolsT,
offset: int,
bo: Optional[ByteOrder],
):
# Raises `ParseError` on any parsing error.
def parse(
normand: str,
- init_variables: Optional[VarsT] = None,
- init_labels: Optional[VarsT] = None,
+ init_variables: Optional[SymbolsT] = None,
+ init_labels: Optional[SymbolsT] = None,
init_offset: int = 0,
init_byte_order: Optional[ByteOrder] = None,
):