A LAMMPS script parser and sanitizer using Lark
Project description
LAMMPS-AST
LAMMPS-AST is a Python package for sanitizing and parsing LAMMPS input scripts into abstract syntax trees (ASTs). It is built on Lark and is intended for structural analysis, validation, comparison, and downstream workflows around LAMMPS input files.
What It Provides
- script sanitization before parsing
- parsing of LAMMPS input scripts into ASTs
- AST transformation and comparison utilities
- repository examples showing how the parser can be used in notebook and pipeline workflows
Install
Install from PyPI:
pip install lammps_ast
If you need the optional visualization tooling used in some example workflows, you may also want a local Graphviz install.
Minimal Usage
from lammps_ast.sanitizer import sanitize
from lammps_ast.parser import parse_to_AST
script = """
units metal
atom_style atomic
boundary p p p
"""
sanitized = sanitize(script)
tree, errors = parse_to_AST(sanitized, lint=True)
parse_to_AST(..., lint=True) returns a parse tree plus collected parse errors. With lint=False, it behaves like a direct parser call and returns either a tree or an exception object.
Repository Layout
lammps_ast/: package source, including parser, sanitizer, grammar, and AST utilitiesexamples/: small examples of using the parser directlypublication/: notebook-based workflow used for the publication-oriented evaluation exampleez-pipeline/: script-oriented evaluation pipeline built on top oflammps_ast
The PyPI distribution is focused on the lammps_ast package itself. The notebook and pipeline folders are repository examples and supporting workflows.
Development Install
To work from a local clone:
pip install -e .
Citation
If you use LAMMPS-AST or the evaluation workflow in academic work, please cite the associated publication.
@misc{lammps_ast_paper,
title = {Evaluating LLM-generated code for domain-specific languages: molecular dynamics with LAMMPS},
author = {Holbrook, Ethan W. and Verduzco, Juan C. and Strachan, Alejandro},
year = {2026},
note = {Manuscript in preparation}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lammps_ast-0.1.8.tar.gz.
File metadata
- Download URL: lammps_ast-0.1.8.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bc64fd9095cbf41dd6bef1a0f25e51a53375ddcb2e5cb7cde31d9fbbbb2fc61
|
|
| MD5 |
b62f63aee5919e7a86e6dbb76ec2557f
|
|
| BLAKE2b-256 |
8401f002a7723a5b70e5fad86626340267130c28f302be141b6a2efd3774de92
|
File details
Details for the file lammps_ast-0.1.8-py3-none-any.whl.
File metadata
- Download URL: lammps_ast-0.1.8-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81c5ec0159156de956a947f88ec5913647d8101e23cf21912568e12d15b73c23
|
|
| MD5 |
2ad4a0848d4fdf267d5d63ea701d0f83
|
|
| BLAKE2b-256 |
de6f08c7964cc1320136b4d2d659310ec9aa32e47dc2e7bb7cf9e04b1eb24223
|