lark-action
Adding semantic actions to Lark parser frontend.
Features:
- semantic action support
- inline python code
- %mkrepl
- Use
#for comments instead of//. - Use
$1,$2, ... to acccess thei-th intermediate result. - Use
@1,@2, ... to access their locations(for token only) - Use
*1,*2, ... to access the lexeme of tokens(for token only)
(CONFESS: I develop this because the existing tools are crazily shitty.)
Usage
%mkrepl # generate a repl for you; not necessary
# inline python code into the generated parser
%%
def my_func():
print("call myfunc")
%%
start : ESCAPED_STRING -> $1 # '$1' accesses the 1-st component
| "%" start -> my_func()
%import common.WS
%import common.ESCAPED_STRING
%ignore WS
execute command python -m lark_action <grammar.lark> [-- package=""] [--module="mylang"], with default arguments you get 3 generated files: mylang.lark and mylang_raw.py and mylang.py.
You can directly access the generated parser via from mylang import parser.
If %mkrepl is specified, you get a simple repl to check your parser:
python mylang.py
input 'q' and exit.
> % "asd"
call myfunc
None
Metadata
Release files for lark-action 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lark_action-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for lark_action-0.1.5-py3-none-any.whl |
Release files / lark_action-0.1.5-py3-none-any.whl
| Download URL | lark_action-0.1.5-py3-none-any.whl |
|---|---|
| Size | 54.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
706edb051988485f278a4e7278989d2c8a23f2a7de666208237aa8c7f0d8e7f5
|
|
BLAKE2b-256 checksum How to use checksums |
da12d40fbac96be2439cf55a30e250127c24d3cbed24fe36a2b5790460e9d6ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8
|
Security for lark-action 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.