dbrownell-parserlib 0.4.0__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dbrownell_parserlib-0.4.0 → dbrownell_parserlib-0.5.0}/PKG-INFO +2 -1
- {dbrownell_parserlib-0.4.0 → dbrownell_parserlib-0.5.0}/pyproject.toml +4 -2
- {dbrownell_parserlib-0.4.0 → dbrownell_parserlib-0.5.0}/src/dbrownell_ParserLib/__init__.py +3 -0
- dbrownell_parserlib-0.5.0/src/dbrownell_ParserLib/antlr/__init__.py +8 -0
- dbrownell_parserlib-0.5.0/src/dbrownell_ParserLib/antlr/build_antlr_grammar/__init__.py +45 -0
- dbrownell_parserlib-0.5.0/src/dbrownell_ParserLib/antlr/build_antlr_grammar/antlr-4.13.2-complete.jar +0 -0
- {dbrownell_parserlib-0.4.0 → dbrownell_parserlib-0.5.0}/README.md +0 -0
- {dbrownell_parserlib-0.4.0 → dbrownell_parserlib-0.5.0}/src/dbrownell_ParserLib/errors.py +0 -0
- {dbrownell_parserlib-0.4.0 → dbrownell_parserlib-0.5.0}/src/dbrownell_ParserLib/location.py +0 -0
- {dbrownell_parserlib-0.4.0 → dbrownell_parserlib-0.5.0}/src/dbrownell_ParserLib/py.typed +0 -0
- {dbrownell_parserlib-0.4.0 → dbrownell_parserlib-0.5.0}/src/dbrownell_ParserLib/region.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: dbrownell-parserlib
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Functionality useful when creating parsers.
|
|
5
5
|
Author: Dave Brownell
|
|
6
6
|
Author-email: Dave Brownell <github@DavidBrownell.com>
|
|
@@ -10,6 +10,7 @@ Classifier: Operating System :: Microsoft :: Windows
|
|
|
10
10
|
Classifier: Operating System :: POSIX :: Linux
|
|
11
11
|
Classifier: Programming Language :: Python
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Requires-Dist: dbrownell-common>=0.16.8
|
|
13
14
|
Requires-Python: >=3.14
|
|
14
15
|
Project-URL: Homepage, https://github.com/davidbrownell/dbrownell_ParserLib
|
|
15
16
|
Project-URL: Documentation, https://github.com/davidbrownell/dbrownell_ParserLib
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "dbrownell-parserlib"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.5.0"
|
|
4
4
|
# ^^^^^
|
|
5
5
|
# Wheel names will be generated according to this value. Do not manually modify this value; instead
|
|
6
6
|
# update it according to committed changes by running this command from the root of the repository:
|
|
@@ -13,7 +13,9 @@ authors = [
|
|
|
13
13
|
{ name = "Dave Brownell", email = "github@DavidBrownell.com" }
|
|
14
14
|
]
|
|
15
15
|
requires-python = ">= 3.14"
|
|
16
|
-
dependencies = [
|
|
16
|
+
dependencies = [
|
|
17
|
+
"dbrownell-common>=0.16.8",
|
|
18
|
+
]
|
|
17
19
|
classifiers = [
|
|
18
20
|
"Operating System :: MacOS",
|
|
19
21
|
"Operating System :: Microsoft :: Windows",
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
from importlib.metadata import version
|
|
4
4
|
|
|
5
|
+
from dbrownell_ParserLib.antlr import BuildAntlrGrammar
|
|
5
6
|
from dbrownell_ParserLib.errors import Error, PythonError
|
|
6
7
|
from dbrownell_ParserLib.location import Location
|
|
7
8
|
from dbrownell_ParserLib.region import Region
|
|
8
9
|
|
|
10
|
+
|
|
9
11
|
# ----------------------------------------------------------------------
|
|
10
12
|
__all__ = [
|
|
13
|
+
"BuildAntlrGrammar",
|
|
11
14
|
"Error",
|
|
12
15
|
"Location",
|
|
13
16
|
"PythonError",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# noqa: D104
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from dbrownell_Common import SubprocessEx
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from dbrownell_Common.Streams.DoneManager import DoneManager
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# ----------------------------------------------------------------------
|
|
12
|
+
def BuildAntlrGrammar(
|
|
13
|
+
dm: DoneManager,
|
|
14
|
+
antlr_grammar_filename: Path,
|
|
15
|
+
output_dir: Path,
|
|
16
|
+
*,
|
|
17
|
+
create_init_file: bool = True,
|
|
18
|
+
create_gitignore_file: bool = True,
|
|
19
|
+
) -> None:
|
|
20
|
+
"""Build the Antlr grammar; note that java must be available on the command line."""
|
|
21
|
+
|
|
22
|
+
with dm.Nested(f"Generating '{antlr_grammar_filename.name}'...") as generate_dm:
|
|
23
|
+
jar_filename = Path(__file__).parent / "antlr-4.13.2-complete.jar"
|
|
24
|
+
assert jar_filename.is_file(), jar_filename
|
|
25
|
+
|
|
26
|
+
command_line = f'java -jar "{jar_filename}" -Dlanguage=Python3 -o "{output_dir}" -no-listener -visitor "{antlr_grammar_filename}"'
|
|
27
|
+
|
|
28
|
+
generate_dm.WriteVerbose(f"Command line: {command_line}\n\n")
|
|
29
|
+
|
|
30
|
+
with generate_dm.YieldStream() as stream:
|
|
31
|
+
generate_dm.result = SubprocessEx.Stream(command_line, stream)
|
|
32
|
+
if generate_dm.result != 0:
|
|
33
|
+
return
|
|
34
|
+
|
|
35
|
+
if create_init_file:
|
|
36
|
+
init_filename = output_dir / "__init__.py"
|
|
37
|
+
|
|
38
|
+
if not init_filename.is_file():
|
|
39
|
+
init_filename.touch()
|
|
40
|
+
|
|
41
|
+
if create_gitignore_file:
|
|
42
|
+
gitignore_filename = output_dir / ".gitignore"
|
|
43
|
+
|
|
44
|
+
if not gitignore_filename.is_file():
|
|
45
|
+
gitignore_filename.write_text("*\n")
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|