antlrope 1.0.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.
- antlrope-1.0.0/.clang-format +12 -0
- antlrope-1.0.0/.claude/CLAUDE.md +112 -0
- antlrope-1.0.0/.gitattributes +7 -0
- antlrope-1.0.0/.github/workflows/ci.yml +77 -0
- antlrope-1.0.0/.github/workflows/docs-deploy.yml +33 -0
- antlrope-1.0.0/.github/workflows/wheels.yml +69 -0
- antlrope-1.0.0/.gitignore +41 -0
- antlrope-1.0.0/CHANGELOG.md +78 -0
- antlrope-1.0.0/CMakeLists.txt +54 -0
- antlrope-1.0.0/CONTRIBUTING.md +154 -0
- antlrope-1.0.0/LICENSE +208 -0
- antlrope-1.0.0/PKG-INFO +365 -0
- antlrope-1.0.0/README.md +132 -0
- antlrope-1.0.0/RELEASING.md +59 -0
- antlrope-1.0.0/conda-recipe/recipe.yaml +95 -0
- antlrope-1.0.0/cpp/binding.cpp +1253 -0
- antlrope-1.0.0/cpp/events.h +208 -0
- antlrope-1.0.0/cpp/file_char_stream.h +277 -0
- antlrope-1.0.0/docs/about/acknowledgements.md +25 -0
- antlrope-1.0.0/docs/about/changelog.md +1 -0
- antlrope-1.0.0/docs/about/license.md +17 -0
- antlrope-1.0.0/docs/about/motivation.md +50 -0
- antlrope-1.0.0/docs/assets/alternates/favicon-green.svg +23 -0
- antlrope-1.0.0/docs/assets/alternates/logo-green.svg +26 -0
- antlrope-1.0.0/docs/assets/alternates/profile-mark.svg +40 -0
- antlrope-1.0.0/docs/assets/favicon.png +0 -0
- antlrope-1.0.0/docs/assets/favicon.svg +35 -0
- antlrope-1.0.0/docs/assets/logo-dark.svg +36 -0
- antlrope-1.0.0/docs/assets/logo.svg +36 -0
- antlrope-1.0.0/docs/benchmarks/make_chart.py +109 -0
- antlrope-1.0.0/docs/benchmarks/systemrdl.md +146 -0
- antlrope-1.0.0/docs/benchmarks/systemrdl.svg +35 -0
- antlrope-1.0.0/docs/chunking.md +118 -0
- antlrope-1.0.0/docs/concepts.md +143 -0
- antlrope-1.0.0/docs/examples/index.md +81 -0
- antlrope-1.0.0/docs/examples/json.md +107 -0
- antlrope-1.0.0/docs/examples/schema.md +163 -0
- antlrope-1.0.0/docs/getting-started.md +167 -0
- antlrope-1.0.0/docs/glossary.md +90 -0
- antlrope-1.0.0/docs/index.md +87 -0
- antlrope-1.0.0/docs/installation.md +110 -0
- antlrope-1.0.0/docs/llms.txt +72 -0
- antlrope-1.0.0/docs/migrating.md +108 -0
- antlrope-1.0.0/docs/parallel-parsing.md +64 -0
- antlrope-1.0.0/docs/performance.md +211 -0
- antlrope-1.0.0/docs/reference/api.md +19 -0
- antlrope-1.0.0/docs/reference/cli.md +210 -0
- antlrope-1.0.0/docs/streaming-records.md +128 -0
- antlrope-1.0.0/docs/stylesheets/extra.css +28 -0
- antlrope-1.0.0/examples/json/JSON.g4 +67 -0
- antlrope-1.0.0/examples/json/__init__.py +0 -0
- antlrope-1.0.0/examples/json/generated/JSONLexer.py +105 -0
- antlrope-1.0.0/examples/json/generated/JSONParser.py +383 -0
- antlrope-1.0.0/examples/json/generated/__init__.py +0 -0
- antlrope-1.0.0/examples/json/json_listener.py +76 -0
- antlrope-1.0.0/examples/json/to_python.py +130 -0
- antlrope-1.0.0/examples/predicate/Pred.g4 +15 -0
- antlrope-1.0.0/examples/predicate/__init__.py +0 -0
- antlrope-1.0.0/examples/predicate/generated/PredLexer.py +50 -0
- antlrope-1.0.0/examples/predicate/generated/PredParser.py +122 -0
- antlrope-1.0.0/examples/predicate/generated/__init__.py +0 -0
- antlrope-1.0.0/examples/schema/Schema.g4 +37 -0
- antlrope-1.0.0/examples/schema/__init__.py +0 -0
- antlrope-1.0.0/examples/schema/generated/SchemaLexer.py +87 -0
- antlrope-1.0.0/examples/schema/generated/SchemaParser.py +421 -0
- antlrope-1.0.0/examples/schema/generated/__init__.py +0 -0
- antlrope-1.0.0/examples/schema/index.py +227 -0
- antlrope-1.0.0/examples/schema/sample.schema +33 -0
- antlrope-1.0.0/examples/schema/schema_listener.py +89 -0
- antlrope-1.0.0/pixi.lock +4444 -0
- antlrope-1.0.0/pyproject.toml +389 -0
- antlrope-1.0.0/scripts/asan_harness.py +190 -0
- antlrope-1.0.0/scripts/asan_pytest.py +117 -0
- antlrope-1.0.0/scripts/bench_chunking.py +121 -0
- antlrope-1.0.0/scripts/bench_runtime_patches.py +134 -0
- antlrope-1.0.0/scripts/build_native.py +76 -0
- antlrope-1.0.0/scripts/gen_cli_docs.py +123 -0
- antlrope-1.0.0/scripts/stubgen.py +117 -0
- antlrope-1.0.0/scripts/typecheck_smoke.py +48 -0
- antlrope-1.0.0/src/antlrope/VERSION +1 -0
- antlrope-1.0.0/src/antlrope/__init__.py +47 -0
- antlrope-1.0.0/src/antlrope/_native.pyi +250 -0
- antlrope-1.0.0/src/antlrope/base.py +1750 -0
- antlrope-1.0.0/src/antlrope/cli/__init__.py +20 -0
- antlrope-1.0.0/src/antlrope/cli/check.py +143 -0
- antlrope-1.0.0/src/antlrope/cli/generate.py +304 -0
- antlrope-1.0.0/src/antlrope/cli/main.py +88 -0
- antlrope-1.0.0/src/antlrope/cli/metadata.py +130 -0
- antlrope-1.0.0/src/antlrope/cli/regen.py +102 -0
- antlrope-1.0.0/src/antlrope/cli/rules.py +60 -0
- antlrope-1.0.0/src/antlrope/cli/tokens.py +61 -0
- antlrope-1.0.0/src/antlrope/cli/uptodate.py +83 -0
- antlrope-1.0.0/src/antlrope/location.py +121 -0
- antlrope-1.0.0/src/antlrope/py.typed +0 -0
- antlrope-1.0.0/tests/asan/harness.cpp +90 -0
- antlrope-1.0.0/tests/conftest.py +54 -0
- antlrope-1.0.0/tests/test_chunking.py +629 -0
- antlrope-1.0.0/tests/test_cli_docs.py +33 -0
- antlrope-1.0.0/tests/test_cli_inspect.py +86 -0
- antlrope-1.0.0/tests/test_cli_metadata.py +94 -0
- antlrope-1.0.0/tests/test_errors.py +78 -0
- antlrope-1.0.0/tests/test_event_counts.py +92 -0
- antlrope-1.0.0/tests/test_facade.py +121 -0
- antlrope-1.0.0/tests/test_filtering.py +60 -0
- antlrope-1.0.0/tests/test_generate.py +156 -0
- antlrope-1.0.0/tests/test_location.py +136 -0
- antlrope-1.0.0/tests/test_parallel.py +146 -0
- antlrope-1.0.0/tests/test_predicate_limitation.py +95 -0
- antlrope-1.0.0/tests/test_specs.py +98 -0
- antlrope-1.0.0/tests/test_threading.py +180 -0
- antlrope-1.0.0/vendor/antlr4-cpp/LICENSE.txt +28 -0
- antlrope-1.0.0/vendor/antlr4-cpp/UPDATING.md +67 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ANTLRErrorListener.cpp +10 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ANTLRErrorListener.h +172 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ANTLRErrorStrategy.cpp +10 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ANTLRErrorStrategy.h +124 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ANTLRFileStream.cpp +25 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ANTLRFileStream.h +33 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ANTLRInputStream.cpp +185 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ANTLRInputStream.h +83 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/BailErrorStrategy.cpp +63 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/BailErrorStrategy.h +62 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/BaseErrorListener.cpp +29 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/BaseErrorListener.h +41 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/BufferedTokenStream.cpp +422 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/BufferedTokenStream.h +207 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/CharStream.cpp +11 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/CharStream.h +39 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/CommonToken.cpp +199 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/CommonToken.h +163 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/CommonTokenFactory.cpp +43 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/CommonTokenFactory.h +79 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/CommonTokenStream.cpp +80 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/CommonTokenStream.h +82 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ConsoleErrorListener.cpp +19 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ConsoleErrorListener.h +40 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/DefaultErrorStrategy.cpp +342 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/DefaultErrorStrategy.h +473 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/DiagnosticErrorListener.cpp +88 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/DiagnosticErrorListener.h +83 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/Exceptions.cpp +66 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/Exceptions.h +101 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/FailedPredicateException.cpp +54 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/FailedPredicateException.h +35 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/FlatHashMap.h +58 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/FlatHashSet.h +57 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/InputMismatchException.cpp +18 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/InputMismatchException.h +25 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/IntStream.cpp +13 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/IntStream.h +221 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/InterpreterRuleContext.cpp +20 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/InterpreterRuleContext.h +47 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/Lexer.cpp +301 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/Lexer.h +202 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/LexerInterpreter.cpp +63 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/LexerInterpreter.h +49 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/LexerNoViableAltException.cpp +38 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/LexerNoViableAltException.h +34 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ListTokenSource.cpp +97 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ListTokenSource.h +94 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/NoViableAltException.cpp +48 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/NoViableAltException.h +43 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/Parser.cpp +678 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/Parser.h +469 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ParserInterpreter.cpp +302 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ParserInterpreter.h +181 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ParserRuleContext.cpp +141 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ParserRuleContext.h +154 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ProxyErrorListener.cpp +58 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/ProxyErrorListener.h +43 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/RecognitionException.cpp +68 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/RecognitionException.h +103 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/Recognizer.cpp +164 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/Recognizer.h +169 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/RuleContext.cpp +150 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/RuleContext.h +145 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/RuleContextWithAltNum.cpp +28 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/RuleContextWithAltNum.h +34 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/RuntimeMetaData.cpp +56 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/RuntimeMetaData.h +156 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/Token.cpp +9 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/Token.h +96 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/TokenFactory.h +34 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/TokenSource.cpp +9 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/TokenSource.h +90 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/TokenStream.cpp +11 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/TokenStream.h +142 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/TokenStreamRewriter.cpp +433 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/TokenStreamRewriter.h +302 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/UnbufferedCharStream.cpp +213 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/UnbufferedCharStream.h +121 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/UnbufferedTokenStream.cpp +276 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/UnbufferedTokenStream.h +122 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/Version.h +42 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/Vocabulary.cpp +69 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/Vocabulary.h +181 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/WritableToken.cpp +9 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/WritableToken.h +26 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/antlr4-common.h +101 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/antlr4-runtime.h +172 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATN.cpp +162 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATN.h +141 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNConfig.cpp +112 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNConfig.h +162 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNConfigSet.cpp +240 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNConfigSet.h +162 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNDeserializationOptions.cpp +40 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNDeserializationOptions.h +48 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNDeserializer.cpp +634 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNDeserializer.h +35 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNSimulator.cpp +36 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNSimulator.h +72 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNState.cpp +59 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNState.h +144 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNStateType.cpp +34 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNStateType.h +36 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ATNType.h +20 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ActionTransition.cpp +34 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ActionTransition.h +40 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/AmbiguityInfo.cpp +17 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/AmbiguityInfo.h +70 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ArrayPredictionContext.cpp +136 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ArrayPredictionContext.h +55 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/AtomTransition.cpp +31 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/AtomTransition.h +39 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/BasicBlockStartState.h +26 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/BasicState.h +25 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/BlockEndState.h +28 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/BlockStartState.h +33 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ContextSensitivityInfo.cpp +15 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ContextSensitivityInfo.h +49 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/DecisionEventInfo.cpp +15 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/DecisionEventInfo.h +71 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/DecisionInfo.cpp +28 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/DecisionInfo.h +231 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/DecisionState.cpp +14 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/DecisionState.h +37 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/EpsilonTransition.cpp +36 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/EpsilonTransition.h +47 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ErrorInfo.cpp +16 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ErrorInfo.h +45 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/HashUtils.h +18 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LL1Analyzer.cpp +197 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LL1Analyzer.h +81 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerATNConfig.cpp +71 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerATNConfig.h +47 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerATNSimulator.cpp +629 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerATNSimulator.h +205 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerAction.cpp +17 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerAction.h +102 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerActionExecutor.cpp +114 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerActionExecutor.h +131 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerActionType.h +58 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerChannelAction.cpp +46 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerChannelAction.h +62 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerCustomAction.cpp +48 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerCustomAction.h +78 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerIndexedCustomAction.cpp +55 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerIndexedCustomAction.h +79 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerModeAction.cpp +46 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerModeAction.h +60 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerMoreAction.cpp +40 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerMoreAction.h +56 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerPopModeAction.cpp +40 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerPopModeAction.h +56 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerPushModeAction.cpp +46 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerPushModeAction.h +60 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerSkipAction.cpp +40 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerSkipAction.h +54 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerTypeAction.cpp +46 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LexerTypeAction.h +54 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LookaheadEventInfo.cpp +17 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LookaheadEventInfo.h +44 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/LoopEndState.h +28 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/NotSetTransition.cpp +26 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/NotSetTransition.h +33 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/OrderedATNConfigSet.cpp +17 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/OrderedATNConfigSet.h +27 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ParseInfo.cpp +104 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ParseInfo.h +105 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ParserATNSimulator.cpp +1425 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ParserATNSimulator.h +918 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ParserATNSimulatorOptions.h +52 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PlusBlockStartState.h +32 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PlusLoopbackState.h +28 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PrecedencePredicateTransition.cpp +28 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PrecedencePredicateTransition.h +41 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PredicateEvalInfo.cpp +20 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PredicateEvalInfo.h +64 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PredicateTransition.cpp +29 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PredicateTransition.h +56 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PredictionContext.cpp +612 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PredictionContext.h +230 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PredictionContextCache.cpp +59 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PredictionContextCache.h +65 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PredictionContextMergeCache.cpp +171 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PredictionContextMergeCache.h +104 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PredictionContextMergeCacheOptions.h +71 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PredictionContextType.h +21 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PredictionMode.cpp +207 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/PredictionMode.h +441 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ProfilingATNSimulator.cpp +183 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/ProfilingATNSimulator.h +64 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/RangeTransition.cpp +30 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/RangeTransition.h +37 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/RuleStartState.h +28 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/RuleStopState.h +29 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/RuleTransition.cpp +38 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/RuleTransition.h +47 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/SemanticContext.cpp +424 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/SemanticContext.h +241 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/SemanticContextType.h +23 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/SerializedATNView.h +101 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/SetTransition.cpp +33 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/SetTransition.h +45 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/SingletonPredictionContext.cpp +85 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/SingletonPredictionContext.h +46 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/StarBlockStartState.h +27 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/StarLoopEntryState.h +40 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/StarLoopbackState.cpp +20 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/StarLoopbackState.h +27 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/TokensStartState.h +27 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/Transition.cpp +40 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/Transition.h +70 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/TransitionType.cpp +28 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/TransitionType.h +33 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/WildcardTransition.cpp +24 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/atn/WildcardTransition.h +32 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/dfa/DFA.cpp +123 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/dfa/DFA.h +122 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/dfa/DFASerializer.cpp +64 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/dfa/DFASerializer.h +35 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/dfa/DFAState.cpp +98 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/dfa/DFAState.h +195 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/dfa/LexerDFASerializer.cpp +19 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/dfa/LexerDFASerializer.h +25 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/internal/Synchronization.cpp +101 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/internal/Synchronization.h +154 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/misc/InterpreterDataReader.cpp +128 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/misc/InterpreterDataReader.h +36 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/misc/Interval.cpp +63 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/misc/Interval.h +86 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/misc/IntervalSet.cpp +516 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/misc/IntervalSet.h +194 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/misc/MurmurHash.cpp +121 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/misc/MurmurHash.h +104 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/misc/Predicate.cpp +4 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/misc/Predicate.h +21 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/support/Any.cpp +8 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/support/Any.h +16 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/support/Arrays.cpp +46 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/support/Arrays.h +153 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/support/BitSet.h +80 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/support/CPPUtils.cpp +213 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/support/CPPUtils.h +71 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/support/Casts.h +34 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/support/Declarations.h +161 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/support/StringUtils.cpp +40 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/support/StringUtils.h +18 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/support/Unicode.h +28 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/support/Utf8.cpp +246 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/support/Utf8.h +56 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/AbstractParseTreeVisitor.h +132 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/ErrorNode.h +26 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/ErrorNodeImpl.cpp +56 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/ErrorNodeImpl.h +47 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/IterativeParseTreeWalker.cpp +69 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/IterativeParseTreeWalker.h +53 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/ParseTree.cpp +12 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/ParseTree.h +115 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/ParseTreeListener.cpp +9 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/ParseTreeListener.h +39 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/ParseTreeProperty.h +50 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/ParseTreeType.h +22 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/ParseTreeVisitor.cpp +9 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/ParseTreeVisitor.h +58 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/ParseTreeWalker.cpp +48 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/ParseTreeWalker.h +55 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/TerminalNode.h +43 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/TerminalNodeImpl.cpp +56 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/TerminalNodeImpl.h +37 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/Trees.cpp +246 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/Trees.h +82 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/Chunk.cpp +9 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/Chunk.h +45 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/ParseTreeMatch.cpp +72 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/ParseTreeMatch.h +135 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/ParseTreePattern.cpp +66 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/ParseTreePattern.h +107 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/ParseTreePatternMatcher.cpp +378 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/ParseTreePatternMatcher.h +191 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/RuleTagToken.cpp +80 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/RuleTagToken.h +120 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/TagChunk.cpp +40 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/TagChunk.h +88 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/TextChunk.cpp +29 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/TextChunk.h +53 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/TokenTagToken.cpp +37 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/pattern/TokenTagToken.h +82 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPath.cpp +162 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPath.h +90 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathElement.cpp +33 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathElement.h +42 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathLexer.cpp +186 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathLexer.g4 +64 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathLexer.h +56 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathLexer.tokens +12 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathLexerErrorListener.cpp +17 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathLexerErrorListener.h +27 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathRuleAnywhereElement.cpp +22 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathRuleAnywhereElement.h +30 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathRuleElement.cpp +33 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathRuleElement.h +30 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathTokenAnywhereElement.cpp +22 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathTokenAnywhereElement.h +28 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathTokenElement.cpp +36 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathTokenElement.h +30 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathWildcardAnywhereElement.cpp +24 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathWildcardAnywhereElement.h +25 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathWildcardElement.cpp +25 -0
- antlrope-1.0.0/vendor/antlr4-cpp/src/tree/xpath/XPathWildcardElement.h +25 -0
- antlrope-1.0.0/zensical.toml +166 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# C++ formatting for cpp/ (run `pixi run format-cpp`). Matches the code's
|
|
2
|
+
# existing LLVM-ish style (attached braces, right-aligned pointers, 80 columns)
|
|
3
|
+
# with a 4-space indent, and puts one argument per line for any call or
|
|
4
|
+
# declaration whose arguments do not fit on a single line.
|
|
5
|
+
BasedOnStyle: LLVM
|
|
6
|
+
IndentWidth: 4
|
|
7
|
+
AccessModifierOffset: -4
|
|
8
|
+
ColumnLimit: 80
|
|
9
|
+
BinPackArguments: false
|
|
10
|
+
BinPackParameters: false
|
|
11
|
+
# The existing code separates trailing comments with two spaces.
|
|
12
|
+
SpacesBeforeTrailingComments: 2
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# antlr-pyfacade — project context
|
|
2
|
+
|
|
3
|
+
A fast, C++-accelerated ANTLR runtime for Python with **no per-grammar C/C++
|
|
4
|
+
compilation by the user**. It drives the official ANTLR4 C++ runtime from the
|
|
5
|
+
serialized ATN that the stock `-Dlanguage=Python3` ANTLR tool already emits, and
|
|
6
|
+
hands Python a single bulk, filtered int32 event stream instead of a per-node
|
|
7
|
+
parse-tree walk. Users generate a parser with the normal ANTLR tool, install this
|
|
8
|
+
package, generate a small facade, and write a pure-Python event listener.
|
|
9
|
+
|
|
10
|
+
## Layout
|
|
11
|
+
|
|
12
|
+
- `src/antlr_pyfacade/` — the Python package (src/ layout).
|
|
13
|
+
- `specs.py` — `load_specs(LexerCls, ParserCls)` / `load_lexer_spec` read ATN +
|
|
14
|
+
metadata off the stock-generated Python lexer/parser classes; the
|
|
15
|
+
grammar-agnostic bridge.
|
|
16
|
+
- `base.py` — `FacadeListener` (base of every generated facade) and its
|
|
17
|
+
`drive()` method: introspects which callbacks a subclass overrides, builds
|
|
18
|
+
native rule/token masks, runs the event loop. Also `Chunk` and the
|
|
19
|
+
`walk_parallel` thread-pool driver.
|
|
20
|
+
- `chunking.py` — the chunkers that produce `Chunk`s for `walk_parallel`:
|
|
21
|
+
`split_on_token` / `split_between_tokens` (token), `split_on_pattern` /
|
|
22
|
+
`chunk_by_pattern` (regex), `chunk_by_rule` (grammar rule), `stream_on_token` /
|
|
23
|
+
`stream_on_pattern` (bounded-memory streaming), and `lex`.
|
|
24
|
+
- `location.py` — `SourceMap` (char offset ↔ line/column).
|
|
25
|
+
- `generate.py` — the `antlr-pyfacade` console script; emits a
|
|
26
|
+
`<Grammar>EventListener` base class from a generated parser module.
|
|
27
|
+
- `cpp/` — the nanobind extension sources (`binding.cpp`, `events.h`); module
|
|
28
|
+
name `_native`.
|
|
29
|
+
- `vendor/antlr4-cpp/` — vendored ANTLR4 C++ runtime sources. **BSD-3-Clause**,
|
|
30
|
+
kept separate from the package's own Apache-2.0 license. See its `UPDATING.md`
|
|
31
|
+
before refreshing the snapshot.
|
|
32
|
+
- `examples/json/`, `examples/predicate/` — end-to-end examples that double as
|
|
33
|
+
test fixtures.
|
|
34
|
+
- `tests/`, `docs/` (Zensical site, config in `zensical.toml`).
|
|
35
|
+
|
|
36
|
+
## Event stream
|
|
37
|
+
|
|
38
|
+
Records are `(kind, payload, start, stop)` int32, decoded via
|
|
39
|
+
`struct.iter_unpack("<4i", raw)`. `kind`: `0=ENTER_RULE, 1=EXIT_RULE,
|
|
40
|
+
2=TERMINAL, 3=ERROR`. `payload` is the rule index or token type. Token text is
|
|
41
|
+
recovered Python-side by slicing `text[start:stop + 1]` — no strings cross the
|
|
42
|
+
boundary. Only overridden rules/tokens are emitted (native filtering).
|
|
43
|
+
|
|
44
|
+
## Dev workflow (pixi)
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
pixi install # solve + build the editable extension
|
|
48
|
+
pixi run build # rebuild _native after editing cpp/ or vendor/ (cmake)
|
|
49
|
+
pixi run test # pytest suite
|
|
50
|
+
pixi run example # JSON reconstruction example
|
|
51
|
+
pixi run docs-build # build the docs site into site/
|
|
52
|
+
pixi run stubgen # regenerate _native.pyi after binding API changes
|
|
53
|
+
pixi run gen-json # regenerate the JSON example parser (gen env, needs JDK)
|
|
54
|
+
pixi run gen-facade # regenerate the JSON facade
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Environments: `default` (Python build + test, no JDK), `gen` (openjdk + ANTLR
|
|
58
|
+
tool, isolated), `docs` (Zensical, no default feature), `recipe` (rattler-build).
|
|
59
|
+
The editable install uses `no-build-isolation`, so cmake/ninja must be on PATH —
|
|
60
|
+
they come from the pixi env.
|
|
61
|
+
|
|
62
|
+
## Build
|
|
63
|
+
|
|
64
|
+
scikit-build-core + nanobind + CMake. `editable.rebuild = false` — imports never
|
|
65
|
+
invoke the toolchain (so the package imports from any interpreter, even an
|
|
66
|
+
unactivated IDE prefix); after editing `cpp/` or `vendor/`, recompile explicitly
|
|
67
|
+
with `pixi run build` (a cmake build+install via `scripts/build_native.py`).
|
|
68
|
+
`wheel.packages = ["src/antlr_pyfacade"]`. Extension built with `STABLE_ABI` (abi3
|
|
69
|
+
only materializes on CPython 3.12+; older build per-version).
|
|
70
|
+
`MACOSX_DEPLOYMENT_TARGET = 11.0`. Minimum Python is **3.10** — use modern typing
|
|
71
|
+
(`list[...]`, `X | None`, `collections.abc` over `typing`).
|
|
72
|
+
|
|
73
|
+
Version is single-sourced in `src/antlr_pyfacade/VERSION` (pyproject reads it
|
|
74
|
+
dynamically; `antlr_pyfacade.__version__` reads it via `importlib.resources`). The
|
|
75
|
+
compiled `_native` module has a checked-in stub `src/antlr_pyfacade/_native.pyi`
|
|
76
|
+
(IDEs/type-checkers can't follow the editable redirector) — after changing the
|
|
77
|
+
binding's public interface, run `pixi run stubgen` (it re-applies the hand edits
|
|
78
|
+
automatically via `scripts/stubgen.py`).
|
|
79
|
+
|
|
80
|
+
## Known limitation
|
|
81
|
+
|
|
82
|
+
The pure-ATN interpreter **cannot evaluate target-language semantic predicates
|
|
83
|
+
(`{...}?`) or embedded actions (`{...}`)** — predicates are treated as true.
|
|
84
|
+
Grammars depending on them won't parse correctly. This is pinned by
|
|
85
|
+
`tests/test_predicate_limitation.py` and documented loudly; keep it that way.
|
|
86
|
+
|
|
87
|
+
## Conventions
|
|
88
|
+
|
|
89
|
+
- Default branch is `dev`.
|
|
90
|
+
- Bump the patch in `src/antlr_pyfacade/VERSION` and add a `CHANGELOG.md` entry on
|
|
91
|
+
every commit that changes runtime behavior or user-facing docs (`README`,
|
|
92
|
+
`docs/`); build/test/tooling-only changes don't bump. See `CONTRIBUTING.md`.
|
|
93
|
+
- Hand-authored `.py`/`.cpp` files carry the Apache-2.0 header; docstrings use
|
|
94
|
+
mkdocstrings/Markdown style (single backticks, Google-style sections) — no
|
|
95
|
+
reStructuredText roles or `::` directives. Cross-references are
|
|
96
|
+
`[title][antlr_pyfacade.Symbol]` with a **plain** title — never backtick the
|
|
97
|
+
title. `` [`title`][ref] `` renders the title as inline code, which hides that
|
|
98
|
+
it's a clickable link. (Backticks remain correct for inline code that is *not* a
|
|
99
|
+
cross-reference.)
|
|
100
|
+
- Package license is **Apache-2.0**; the vendored runtime under `vendor/` stays
|
|
101
|
+
**BSD-3-Clause** — never relicense vendored code.
|
|
102
|
+
- Public docs (README, `docs/`) compare only against alternatives the reader
|
|
103
|
+
actually has (the official `antlr4-python3-runtime`). No internal research
|
|
104
|
+
context, no testbed names.
|
|
105
|
+
- Dev/build details live in `CONTRIBUTING.md`, not the README.
|
|
106
|
+
- `docs/llms.txt` is a hand-written LLM summary published verbatim at the doc-site
|
|
107
|
+
root (`/llms.txt`) for coding agents. It is not generated and `docs-build` won't
|
|
108
|
+
flag it as stale, so keep it in sync when the public API (`__all__`), the
|
|
109
|
+
generate→facade→`walk` workflow, install steps, or the doc page set / `site_url`
|
|
110
|
+
change. (It lives in `docs/`, so updating it bumps the version.)
|
|
111
|
+
- Never commit `.idea/`. Only commit when explicitly asked; never push without
|
|
112
|
+
asking; never skip git hooks.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Check out text files with LF everywhere (overrides Windows autocrlf): tests
|
|
2
|
+
# and the streaming chunkers treat file contents verbatim, so CRLF working
|
|
3
|
+
# copies would shift every character offset the fixtures assert.
|
|
4
|
+
* text=auto eol=lf
|
|
5
|
+
|
|
6
|
+
# SCM syntax highlighting & preventing 3-way merges
|
|
7
|
+
pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
# Run the test suite, and a memory-safety pass with AddressSanitizer. The ASan
|
|
4
|
+
# leg builds the extension (and a C++ harness) with -fsanitize=address — it is
|
|
5
|
+
# what would have caught the DFA-edge heap overflow that normal builds missed.
|
|
6
|
+
|
|
7
|
+
# Runs on every branch push so work on any feature/dev branch is validated.
|
|
8
|
+
# (Same-repo branch pushes are covered here; re-add a `pull_request:` trigger if
|
|
9
|
+
# the project starts taking pull requests from forks.)
|
|
10
|
+
on:
|
|
11
|
+
push:
|
|
12
|
+
branches: ["**"]
|
|
13
|
+
workflow_dispatch:
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
test:
|
|
17
|
+
name: tests (${{ matrix.os }})
|
|
18
|
+
runs-on: ${{ matrix.os }}
|
|
19
|
+
strategy:
|
|
20
|
+
fail-fast: false
|
|
21
|
+
matrix:
|
|
22
|
+
os: [ubuntu-latest, macos-14]
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
- uses: prefix-dev/setup-pixi@v0.8.1
|
|
26
|
+
with:
|
|
27
|
+
environments: default
|
|
28
|
+
cache: true
|
|
29
|
+
- run: pixi run build
|
|
30
|
+
# Run the suite under coverage (only src/ is measured); the summary lands in
|
|
31
|
+
# the job log and the HTML/JSON artifacts in .coverage/.
|
|
32
|
+
- run: pixi run coverage
|
|
33
|
+
# Smoke-test the worked examples end to end (both OSes), so a runtime change
|
|
34
|
+
# that breaks them — or their checked-in generated parsers/facades — is caught.
|
|
35
|
+
- name: Examples
|
|
36
|
+
run: |
|
|
37
|
+
pixi run example
|
|
38
|
+
pixi run example-schema
|
|
39
|
+
|
|
40
|
+
# The pixi workspace covers linux/macOS only, but wheels.yml ships Windows
|
|
41
|
+
# (amd64) wheels — so run the suite on Windows via a plain pip build: MSVC on
|
|
42
|
+
# the runner compiles the extension, scikit-build-core pulls cmake/ninja from
|
|
43
|
+
# PyPI. This is what validates the Windows wheels beyond an import smoke test.
|
|
44
|
+
test-windows:
|
|
45
|
+
name: tests (windows-latest)
|
|
46
|
+
runs-on: windows-latest
|
|
47
|
+
steps:
|
|
48
|
+
- uses: actions/checkout@v4
|
|
49
|
+
# 3.14 matches the pixi dev env, so version-sensitive argparse help
|
|
50
|
+
# rendering (tests/test_cli_docs.py compares against the committed
|
|
51
|
+
# reference) agrees. The 3.12 abi3 floor is covered by cibuildwheel's
|
|
52
|
+
# per-wheel import test.
|
|
53
|
+
- uses: actions/setup-python@v5
|
|
54
|
+
with:
|
|
55
|
+
python-version: "3.14"
|
|
56
|
+
- name: Build and install
|
|
57
|
+
run: pip install . pytest
|
|
58
|
+
# Run from the repo (tests/ + examples/ fixtures), against the installed
|
|
59
|
+
# package (no src layout conflict: the extension lives in site-packages).
|
|
60
|
+
- name: Test
|
|
61
|
+
run: python -m pytest tests -q
|
|
62
|
+
|
|
63
|
+
asan:
|
|
64
|
+
name: addresssanitizer (linux)
|
|
65
|
+
runs-on: ubuntu-latest
|
|
66
|
+
steps:
|
|
67
|
+
- uses: actions/checkout@v4
|
|
68
|
+
- uses: prefix-dev/setup-pixi@v0.8.1
|
|
69
|
+
with:
|
|
70
|
+
environments: default
|
|
71
|
+
cache: true
|
|
72
|
+
# Portable C++ harness over the example grammars (also runnable on macOS).
|
|
73
|
+
- name: ASan C++ harness
|
|
74
|
+
run: pixi run asan-test
|
|
75
|
+
# Full pytest suite under ASan — covers the nanobind binding too (Linux).
|
|
76
|
+
- name: pytest under ASan
|
|
77
|
+
run: pixi run asan-pytest
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: docs
|
|
2
|
+
|
|
3
|
+
# Deploy the versioned documentation site to gh-pages when a release tag is
|
|
4
|
+
# pushed (the same trigger that publishes wheels to PyPI), or on demand via
|
|
5
|
+
# workflow_dispatch. `pixi run docs-deploy` runs mike, which builds the site
|
|
6
|
+
# with zensical and commits it to gh-pages under the release's major.minor
|
|
7
|
+
# with the `latest` alias — patch releases overwrite their minor in place.
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
push:
|
|
11
|
+
tags: ["v*"]
|
|
12
|
+
workflow_dispatch:
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: write # mike pushes to the gh-pages branch
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
deploy:
|
|
19
|
+
name: deploy versioned docs
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
with:
|
|
24
|
+
fetch-depth: 0 # mike needs the gh-pages branch history
|
|
25
|
+
- uses: prefix-dev/setup-pixi@v0.8.1
|
|
26
|
+
with:
|
|
27
|
+
environments: docs
|
|
28
|
+
cache: true
|
|
29
|
+
- name: Configure git identity
|
|
30
|
+
run: |
|
|
31
|
+
git config user.name "github-actions[bot]"
|
|
32
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
33
|
+
- run: pixi run docs-deploy
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
name: wheels
|
|
2
|
+
|
|
3
|
+
# Build wheels and an sdist on pushes to main (no publish), and publish to PyPI
|
|
4
|
+
# when a version tag is pushed. Development happens on `dev`, which is covered by
|
|
5
|
+
# the lighter `ci` workflow; the full multi-platform wheel build only runs once
|
|
6
|
+
# work lands on main. cibuildwheel compiles the vendored ANTLR C++ runtime for
|
|
7
|
+
# each platform/CPython; scikit-build-core fetches cmake/ninja.
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
push:
|
|
11
|
+
branches: [main]
|
|
12
|
+
tags: ["v*"]
|
|
13
|
+
workflow_dispatch:
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
build_wheels:
|
|
17
|
+
name: wheels on ${{ matrix.os }}
|
|
18
|
+
runs-on: ${{ matrix.os }}
|
|
19
|
+
strategy:
|
|
20
|
+
fail-fast: false
|
|
21
|
+
matrix:
|
|
22
|
+
# ubuntu-latest = manylinux x86_64; ubuntu-24.04-arm = native manylinux
|
|
23
|
+
# aarch64 (free ARM runner, no QEMU); macos-15-intel = x86_64 (the last
|
|
24
|
+
# free Intel image — macos-13 was retired and its jobs queue forever);
|
|
25
|
+
# macos-14 = arm64; windows-latest = amd64. cibuildwheel infers the
|
|
26
|
+
# wheel arch from the runner.
|
|
27
|
+
os:
|
|
28
|
+
[ubuntu-latest, ubuntu-24.04-arm, macos-15-intel, macos-14, windows-latest]
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v4
|
|
31
|
+
|
|
32
|
+
- name: Build wheels
|
|
33
|
+
uses: pypa/cibuildwheel@v2.21
|
|
34
|
+
env:
|
|
35
|
+
MACOSX_DEPLOYMENT_TARGET: "11.0"
|
|
36
|
+
|
|
37
|
+
- uses: actions/upload-artifact@v4
|
|
38
|
+
with:
|
|
39
|
+
name: wheels-${{ matrix.os }}
|
|
40
|
+
path: ./wheelhouse/*.whl
|
|
41
|
+
|
|
42
|
+
build_sdist:
|
|
43
|
+
name: sdist
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@v4
|
|
47
|
+
- name: Build sdist
|
|
48
|
+
run: pipx run build --sdist
|
|
49
|
+
- uses: actions/upload-artifact@v4
|
|
50
|
+
with:
|
|
51
|
+
name: sdist
|
|
52
|
+
path: dist/*.tar.gz
|
|
53
|
+
|
|
54
|
+
publish:
|
|
55
|
+
name: publish to PyPI
|
|
56
|
+
needs: [build_wheels, build_sdist]
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
# Only on a version tag. Uses Trusted Publishing (OIDC) — configure the
|
|
59
|
+
# publisher on PyPI; no API token secret required.
|
|
60
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
|
61
|
+
environment: pypi
|
|
62
|
+
permissions:
|
|
63
|
+
id-token: write
|
|
64
|
+
steps:
|
|
65
|
+
- uses: actions/download-artifact@v4
|
|
66
|
+
with:
|
|
67
|
+
path: dist
|
|
68
|
+
merge-multiple: true
|
|
69
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Build artifacts
|
|
2
|
+
/build/
|
|
3
|
+
# Standalone build dir for scripts/bench_runtime_patches.py (runtime-patch A/B/C)
|
|
4
|
+
/build-bench/
|
|
5
|
+
/dist/
|
|
6
|
+
# rattler-build output (the recipe-build task)
|
|
7
|
+
/output/
|
|
8
|
+
# Coverage artifacts (pixi run coverage): data file, HTML site, JSON report
|
|
9
|
+
/.coverage/
|
|
10
|
+
# Zensical documentation site output
|
|
11
|
+
/site/
|
|
12
|
+
/.zensical/
|
|
13
|
+
*.so
|
|
14
|
+
*.pyd
|
|
15
|
+
*.egg-info/
|
|
16
|
+
__pycache__/
|
|
17
|
+
*.py[cod]
|
|
18
|
+
.pytest_cache/
|
|
19
|
+
# AddressSanitizer build dirs (scripts/asan_pytest.py, scripts/asan_harness.py)
|
|
20
|
+
/build-asan/
|
|
21
|
+
/tests/asan/build/
|
|
22
|
+
|
|
23
|
+
# ANTLR tool side outputs (the gen-* tasks): token maps and IDE/TestRig
|
|
24
|
+
# interpreter data the examples never use (no ANTLR flag suppresses them).
|
|
25
|
+
examples/*/generated/*.tokens
|
|
26
|
+
examples/*/generated/*.interp
|
|
27
|
+
|
|
28
|
+
# Editors
|
|
29
|
+
.idea/
|
|
30
|
+
.vscode/
|
|
31
|
+
.DS_Store
|
|
32
|
+
|
|
33
|
+
# Claude Code local settings (CLAUDE.md is committed; local overrides are not)
|
|
34
|
+
.claude/settings.local.json
|
|
35
|
+
|
|
36
|
+
# Env
|
|
37
|
+
.venv/
|
|
38
|
+
.pixi/
|
|
39
|
+
# pixi environments
|
|
40
|
+
.pixi/*
|
|
41
|
+
!.pixi/config.toml
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format is based on
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and from 1.0 the project
|
|
5
|
+
follows semantic versioning (see the version policy in
|
|
6
|
+
[CONTRIBUTING.md](CONTRIBUTING.md)).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2026-07-08
|
|
9
|
+
|
|
10
|
+
First stable release. **Antlrope** is a fast, C++-accelerated ANTLR runtime for
|
|
11
|
+
Python: it drives the official ANTLR4 C++ runtime's ATN interpreter directly from
|
|
12
|
+
the serialized ATN that the stock `-Dlanguage=Python3` ANTLR tool already emits —
|
|
13
|
+
no per-grammar codegen, nothing to compile — and delivers the parse to Python as
|
|
14
|
+
one bulk, filtered event stream instead of a per-node tree walk (typically 10–20×
|
|
15
|
+
the official pure-Python runtime). The public API — `FacadeListener` and its
|
|
16
|
+
generated `<Grammar>EventListener` facades, `walk` / `walk_parallel`, the chunking
|
|
17
|
+
and streaming family, and the `antlrope` command group — is stable as of this
|
|
18
|
+
release.
|
|
19
|
+
|
|
20
|
+
Final pre-release polish (over the 0.x history below):
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- The CLI prints a clean one-line error (exit status 2) for bad input — an
|
|
24
|
+
unimportable module, a module that is not a generated parser, an unreadable or
|
|
25
|
+
unwritable file — instead of a Python traceback.
|
|
26
|
+
- `FacadeListener.rule_name` now raises `IndexError` for any out-of-range rule
|
|
27
|
+
index; previously a negative index silently wrapped from the end.
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- Release engineering: complete PyPI metadata (development-status classifier,
|
|
31
|
+
documentation/changelog/issue URLs), a documented release procedure
|
|
32
|
+
([RELEASING.md](RELEASING.md)), automated versioned-docs deployment on release
|
|
33
|
+
tags, and a Windows CI job running the full test suite (Windows wheels were
|
|
34
|
+
previously only import-smoke-tested).
|
|
35
|
+
|
|
36
|
+
## 0.x development history
|
|
37
|
+
|
|
38
|
+
The 0.x versions (0.1.0 2026-05-31 through 0.2.28 2026-06-28) were development
|
|
39
|
+
builds, never published to PyPI. Condensed highlights, roughly in order:
|
|
40
|
+
|
|
41
|
+
- **Engine** (0.1.0): the bulk filtered event stream over a vendored ANTLR4 C++
|
|
42
|
+
runtime — parse in C++, cross into Python once with `(kind, payload, start,
|
|
43
|
+
stop)` int32 records, filter unsubscribed rules/tokens natively; GIL released
|
|
44
|
+
during the parse; `py.typed` + a checked-in `_native` stub. Two runtime patches
|
|
45
|
+
written for upstream: lock-free DFA-edge reads and per-DFA write locks (shared
|
|
46
|
+
specs scale across threads instead of running slower than serial). A
|
|
47
|
+
heap-buffer-overflow in the patched DFA-edge cache was found and fixed under
|
|
48
|
+
AddressSanitizer, which the CI now runs routinely.
|
|
49
|
+
- **Facade**: generated `<Grammar>EventListener` classes with per-rule callbacks,
|
|
50
|
+
token-type constants (symbolic plus ANTLR's positional `T__n` literal names),
|
|
51
|
+
and baked-in lexer/parser — `listener.walk(text)` needs no class arguments.
|
|
52
|
+
`walk_parallel` parses chunks across cores as a lazy, order-preserving iterator.
|
|
53
|
+
Consumer helpers grew in: `depth` / `rule_stack` / `current_rule`, `text`,
|
|
54
|
+
`token_name` / `rule_name`, `line_col` / `span` / `sourcename`, collected
|
|
55
|
+
`syntax_errors` (now `ParseError` exceptions), and the
|
|
56
|
+
`enterEveryRule` / `exitEveryRule` hooks.
|
|
57
|
+
- **Chunking family**: token-aware `split_on_token` / `split_between_tokens` over
|
|
58
|
+
a C++ `lex` pass; regex `split_on_pattern` / `chunk_by_pattern`; structural
|
|
59
|
+
`chunk_by_rule`; and bounded-memory streaming counterparts `stream_on_token`,
|
|
60
|
+
`stream_on_pattern`, and `stream_by_rule` (which fails loudly on malformed
|
|
61
|
+
record sequences). All yield positioned `Chunk`s with optional `sourcename`;
|
|
62
|
+
`trim=False` preserves whitespace terminators.
|
|
63
|
+
- **API consolidation**: the chunkers and spec handling moved onto
|
|
64
|
+
`FacadeListener`; the low-level layer (event buffers, native specs, typing
|
|
65
|
+
protocols, the `cached=` option) went private, leaving a seven-name public
|
|
66
|
+
surface plus a `clear_cache()` escape hatch.
|
|
67
|
+
- **CLI**: grew from a single generator command into the `antlrope` command group
|
|
68
|
+
— `gen` (with a deterministic origin header), `regen` and `up-to-date`
|
|
69
|
+
(regenerate / staleness-check from that header), `check` (flag semantic
|
|
70
|
+
predicates and embedded actions the ATN interpreter cannot run), and `rules` /
|
|
71
|
+
`tokens` introspection.
|
|
72
|
+
- **Packaging**: renamed from `antlr-pyfacade` to **antlrope** (0.2.0); Python
|
|
73
|
+
floor raised to 3.12 so a single Stable-ABI (`cp312-abi3`) wheel per platform
|
|
74
|
+
covers 3.12+ (Linux x86_64/aarch64, macOS x86_64/arm64, Windows amd64).
|
|
75
|
+
- **Docs**: the zensical + mkdocstrings site (user guide, examples, glossary,
|
|
76
|
+
generated API and CLI references), an LLM-oriented `llms.txt`, and the SystemRDL
|
|
77
|
+
benchmark: ~21× the pure-Python runtime and ~8× the speedy-antlr accelerator
|
|
78
|
+
end-to-end on a 2.6 MB input, at lower peak memory.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.21)
|
|
2
|
+
project(antlrope LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
5
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
6
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
7
|
+
|
|
8
|
+
# The ANTLR4 C++ runtime sources are vendored into the repo (see
|
|
9
|
+
# vendor/antlr4-cpp/UPDATING.md). Self-contained so the sdist builds with no
|
|
10
|
+
# external checkout. Override with -DANTLR4_CPP_SRC=... only for development.
|
|
11
|
+
set(ANTLR4_CPP_SRC "${CMAKE_CURRENT_SOURCE_DIR}/vendor/antlr4-cpp/src"
|
|
12
|
+
CACHE PATH "Path to ANTLR4 C++ runtime src directory")
|
|
13
|
+
|
|
14
|
+
if (NOT EXISTS "${ANTLR4_CPP_SRC}/ParserInterpreter.cpp")
|
|
15
|
+
message(FATAL_ERROR "ANTLR4_CPP_SRC does not point at the C++ runtime src: ${ANTLR4_CPP_SRC}")
|
|
16
|
+
endif()
|
|
17
|
+
|
|
18
|
+
file(GLOB antlr4_runtime_SRC
|
|
19
|
+
"${ANTLR4_CPP_SRC}/*.cpp"
|
|
20
|
+
"${ANTLR4_CPP_SRC}/atn/*.cpp"
|
|
21
|
+
"${ANTLR4_CPP_SRC}/dfa/*.cpp"
|
|
22
|
+
"${ANTLR4_CPP_SRC}/internal/*.cpp"
|
|
23
|
+
"${ANTLR4_CPP_SRC}/misc/*.cpp"
|
|
24
|
+
"${ANTLR4_CPP_SRC}/support/*.cpp"
|
|
25
|
+
"${ANTLR4_CPP_SRC}/tree/*.cpp"
|
|
26
|
+
"${ANTLR4_CPP_SRC}/tree/pattern/*.cpp"
|
|
27
|
+
"${ANTLR4_CPP_SRC}/tree/xpath/*.cpp"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Request the Stable ABI (Limited API) component too, so nanobind's STABLE_ABI
|
|
31
|
+
# can build an abi3 extension. scikit-build-core sets SKBUILD_SABI_COMPONENT to
|
|
32
|
+
# "Development.SABIModule" when [tool.scikit-build] wheel.py-api is configured
|
|
33
|
+
# (the wheel builds); it is empty for a plain local cmake build (pixi run build),
|
|
34
|
+
# which then produces a normal version-specific extension. Without this component
|
|
35
|
+
# nanobind silently falls back to a full-ABI build and the wheel is mis-tagged.
|
|
36
|
+
find_package(Python 3.12 REQUIRED
|
|
37
|
+
COMPONENTS Interpreter Development.Module ${SKBUILD_SABI_COMPONENT})
|
|
38
|
+
find_package(nanobind CONFIG REQUIRED)
|
|
39
|
+
find_package(Threads REQUIRED)
|
|
40
|
+
|
|
41
|
+
nanobind_add_module(_native STABLE_ABI
|
|
42
|
+
cpp/binding.cpp
|
|
43
|
+
${antlr4_runtime_SRC}
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
target_compile_definitions(_native PRIVATE ANTLR4CPP_STATIC)
|
|
47
|
+
target_include_directories(_native PRIVATE
|
|
48
|
+
"${ANTLR4_CPP_SRC}"
|
|
49
|
+
"${ANTLR4_CPP_SRC}/tree/pattern"
|
|
50
|
+
"${ANTLR4_CPP_SRC}/tree/xpath"
|
|
51
|
+
)
|
|
52
|
+
target_link_libraries(_native PRIVATE Threads::Threads)
|
|
53
|
+
|
|
54
|
+
install(TARGETS _native LIBRARY DESTINATION antlrope)
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in improving `antlrope`. This page covers the
|
|
4
|
+
local development setup; for what the package does and how to use it, see the
|
|
5
|
+
[README](README.md) and the [docs](docs/index.md).
|
|
6
|
+
|
|
7
|
+
## Development environment
|
|
8
|
+
|
|
9
|
+
This project uses [pixi](https://pixi.sh). The toolchain (C++ compiler, CMake,
|
|
10
|
+
Ninja, nanobind, scikit-build-core) comes from the pixi environment, so the
|
|
11
|
+
editable `editable.rebuild` hook always finds a persistent CMake on `PATH`.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
pixi install # solve + build the editable extension
|
|
15
|
+
pixi run build # rebuild the _native C++ extension after editing C++
|
|
16
|
+
pixi run test # run the pytest suite
|
|
17
|
+
pixi run example # run the JSON reconstruction example
|
|
18
|
+
pixi run docs-serve # preview the docs site at http://localhost:8000
|
|
19
|
+
pixi run docs-build # build the static docs site into site/
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Environments
|
|
23
|
+
|
|
24
|
+
- **default** — Python build + test toolchain (no JDK); `pixi run test` lives here.
|
|
25
|
+
- **gen** — adds `openjdk` + the ANTLR tool, isolated from the runtime envs.
|
|
26
|
+
Regenerate the example from the grammar with `pixi run gen-json` (re-runs the
|
|
27
|
+
ANTLR Python target on `examples/json/JSON.g4`) and `pixi run gen-facade`.
|
|
28
|
+
- **docs** — [Zensical](https://zensical.org) static site generator, isolated
|
|
29
|
+
with no default feature so building the docs pulls neither the JDK nor the C++
|
|
30
|
+
toolchain. Configured by `zensical.toml`; output goes to `site/` (gitignored).
|
|
31
|
+
|
|
32
|
+
## The native extension and its type stub
|
|
33
|
+
|
|
34
|
+
The C++ engine is the nanobind module `antlrope._native`, built from
|
|
35
|
+
`cpp/binding.cpp` against the vendored runtime. The C++ rarely changes, so it is
|
|
36
|
+
**not** rebuilt on import (`editable.rebuild = false`). After editing anything
|
|
37
|
+
under `cpp/` or `vendor/antlr4-cpp/`, recompile explicitly:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pixi run build # incremental cmake build + install (scripts/build_native.py)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then `pixi run test` runs against the fresh build. Because import never invokes
|
|
44
|
+
the build toolchain, the package imports fine from any interpreter — including an
|
|
45
|
+
IDE that points at `.pixi/envs/default` without activating it (e.g. PyCharm using
|
|
46
|
+
the env prefix as a plain interpreter); no `cmake` on `PATH` is required.
|
|
47
|
+
|
|
48
|
+
`_native` is a compiled module loaded through scikit-build-core's editable
|
|
49
|
+
redirector, which IDEs and type checkers cannot follow. A checked-in stub,
|
|
50
|
+
`src/antlrope/_native.pyi`, gives them the interface (and the `py.typed`
|
|
51
|
+
marker advertises the package as typed). If you change the **public interface** of
|
|
52
|
+
`cpp/binding.cpp` — add or rename a class, method, or function, or change a
|
|
53
|
+
signature — rebuild, then regenerate the stub:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
pixi run build
|
|
57
|
+
pixi run stubgen
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`pixi run stubgen` runs `scripts/stubgen.py`, which invokes nanobind's stubgen and
|
|
61
|
+
then re-applies the edits nanobind cannot infer — the license header and the
|
|
62
|
+
`parse_events` / `lex` return types — so the committed stub is produced directly.
|
|
63
|
+
To change those edits, edit `scripts/stubgen.py`, not the `.pyi`.
|
|
64
|
+
|
|
65
|
+
## Naming the product
|
|
66
|
+
|
|
67
|
+
In prose, the product is **Antlrope** (capitalized). Render it **bold on the first
|
|
68
|
+
mention in a page or section** and plain capitalized (`Antlrope`) afterwards. Reserve
|
|
69
|
+
the lowercase, backticked `` `antlrope` `` form for the literal Python module
|
|
70
|
+
(`from antlrope import …`), the CLI command (`antlrope gen`), or the package id in an
|
|
71
|
+
install command (`pip install antlrope`). Headings, the site/README title, URLs, the
|
|
72
|
+
logo wordmark, and code stay lowercase.
|
|
73
|
+
|
|
74
|
+
## Docstrings
|
|
75
|
+
|
|
76
|
+
Docstrings are rendered into the API docs by mkdocstrings, which resolves
|
|
77
|
+
cross-references written as `[title][path.to.symbol]` (e.g.
|
|
78
|
+
`[walk_parallel][antlrope.FacadeListener.walk_parallel]`).
|
|
79
|
+
|
|
80
|
+
**Do not wrap the cross-reference title in backticks.** Write `[title][ref]`, not
|
|
81
|
+
`` [`title`][ref] ``. Backticks render the title as inline code, which visually
|
|
82
|
+
hides that the text is a clickable link — the reference still resolves, but
|
|
83
|
+
readers can't tell it's a link. Plain `[title][ref]` renders as a normal styled
|
|
84
|
+
link. Backticks are still correct for inline code that is *not* a cross-reference
|
|
85
|
+
(a parameter or type name with no `][ref]` after it).
|
|
86
|
+
|
|
87
|
+
## `llms.txt`
|
|
88
|
+
|
|
89
|
+
`docs/llms.txt` is a hand-written, LLM-oriented summary of the library (install, the
|
|
90
|
+
generate → facade → `walk` workflow, the listener model, the public API, and doc
|
|
91
|
+
links), published verbatim at the doc-site root (`/llms.txt`) for coding agents — see
|
|
92
|
+
[llmstxt.org](https://llmstxt.org/). It is **not generated**, so keep it in sync when
|
|
93
|
+
any of these change: the public API (`__all__`), the workflow or listener model,
|
|
94
|
+
install instructions, the supported Python/platform versions, or the doc page set and
|
|
95
|
+
`site_url` (its doc links are absolute). It is excluded from the rendered docs — no
|
|
96
|
+
nav, search, or sitemap — so `pixi run docs-build` will **not** flag it as stale.
|
|
97
|
+
|
|
98
|
+
## CLI reference
|
|
99
|
+
|
|
100
|
+
The command reference in `docs/reference/cli.md` (the region between the
|
|
101
|
+
`gen-cli-help` markers) is **generated from the live `antlrope --help` output** by
|
|
102
|
+
`scripts/gen_cli_docs.py`. After any change to the CLI (`antlrope.cli` — a command's
|
|
103
|
+
arguments or help text, or adding/renaming a subcommand), regenerate it:
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
pixi run gen-cli-docs
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The prose outside the markers (the intro and the origin-header section) is hand-written.
|
|
110
|
+
`tests/test_cli_docs.py` runs `gen-cli-docs --check`, so `pixi run test` fails if the
|
|
111
|
+
committed doc has drifted from the CLI.
|
|
112
|
+
|
|
113
|
+
## Version
|
|
114
|
+
|
|
115
|
+
The version lives in one place: `src/antlrope/VERSION`. The build reads it
|
|
116
|
+
(scikit-build-core's regex metadata provider) so the wheel and its
|
|
117
|
+
`importlib.metadata` follow it, and `antlrope.__version__` reads the same
|
|
118
|
+
file via `importlib.resources`. The conda recipe is the exception: it tracks the
|
|
119
|
+
*published* release it packages, not the dev version, so it pins its own value
|
|
120
|
+
(bumped per release).
|
|
121
|
+
|
|
122
|
+
**Policy: bump the patch on every commit that changes runtime behavior or
|
|
123
|
+
user-facing docs.** Edit `VERSION` in the same commit that touches the runtime
|
|
124
|
+
(`src/`, `cpp/`, `vendor/antlr4-cpp/`) or the external docs (`README.md`,
|
|
125
|
+
`docs/`). Build-only, test-only, or dev-tooling changes (pixi/CMake config,
|
|
126
|
+
`scripts/`, `CONTRIBUTING.md`, CI) don't need a bump. When you bump, add a matching
|
|
127
|
+
entry to [CHANGELOG.md](CHANGELOG.md). Bumping the file is enough for the version
|
|
128
|
+
itself — `__version__` reflects it immediately; run `pixi install` to refresh the
|
|
129
|
+
installed package metadata too.
|
|
130
|
+
|
|
131
|
+
## Vendored runtime
|
|
132
|
+
|
|
133
|
+
The vendored ANTLR C++ runtime is built from `vendor/antlr4-cpp/`; see
|
|
134
|
+
`vendor/antlr4-cpp/UPDATING.md` to refresh the snapshot.
|
|
135
|
+
|
|
136
|
+
## Before submitting
|
|
137
|
+
|
|
138
|
+
- If you changed C++ (`cpp/` or `vendor/antlr4-cpp/`), run `pixi run build` first.
|
|
139
|
+
- If you changed `cpp/`, run `pixi run format-cpp` (clang-format; config in
|
|
140
|
+
`.clang-format` — one argument per line when a call/declaration doesn't fit).
|
|
141
|
+
- Run `pixi run test` and make sure the suite is green.
|
|
142
|
+
- If you changed `cpp/binding.cpp`'s public interface, run `pixi run stubgen` (it
|
|
143
|
+
re-applies the hand edits automatically).
|
|
144
|
+
- If you changed the CLI (`antlrope.cli`), run `pixi run gen-cli-docs` to regenerate
|
|
145
|
+
the `docs/reference/cli.md` command reference (`pixi run test` fails if it's stale).
|
|
146
|
+
- If you changed the docs, confirm `pixi run docs-build` succeeds.
|
|
147
|
+
- If you changed the public API, the workflow, or the doc page set, update
|
|
148
|
+
`docs/llms.txt` to match (it's hand-maintained and not flagged by `docs-build`).
|
|
149
|
+
|
|
150
|
+
## Releasing
|
|
151
|
+
|
|
152
|
+
Releases are cut from `main` via a `vX.Y.Z` tag; see [RELEASING.md](RELEASING.md)
|
|
153
|
+
for the full procedure (CHANGELOG, version bump, wheels/PyPI, docs deploy,
|
|
154
|
+
conda-forge).
|