Caustic's Parser -- uses grammar specification to compile Caustic source code
into a [CST (Caustic AST)](https://codeberg.org/Caustic/CausticAST)
Uses [ParGlare](https://github.com/igordejanovic/parglare) for parsing,
meant to work with [CausticGrammar](https://codeberg.org/Caustic/CausticGrammar)
to create a [CST (Caustic AST)](https://codeberg.org/Caustic/CausticAST)
# CLI usage
See `cap --help`
# Module usage
```python3
import sys
import parglare
from pprint import pprint
from pathlib import Path
from caustic import parser
grammar = parglare.Grammar.from_file(parser.builtin_grammar('canonical/canonical.pg'))
# ^ builtin_grammar fetches the builtin grammar path from caustic.grammar,
# optionally adding a subdirectory and checking if it exists
parser_ = parglare.GLRParser(grammar, lexical_disambiguation=True,
actions=parser.actions.action.all)
# ^ the actions module supplies some generally useful actions,
# as well as actions specifically for creating CST nodes
try:
forest = parser_.parse(input())
except parglare.ParseError as e:
# custom error formatting
print(parser.errors.format_exc(e), file=sys.stderr)
cst = parser_.call_actions(forest.get_first_tree())
pprint(cst)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "caustic.parser",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "caustic, language, parser, syntax, grammar",
"author": "Shae.c32",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/9e/35/4bf5b7929fc45ca16ce45705d938c035ee45d22108d7c9100865bb05e09e/caustic.parser-3.0.0.tar.gz",
"platform": null,
"description": "Caustic's Parser -- uses grammar specification to compile Caustic source code\ninto a [CST (Caustic AST)](https://codeberg.org/Caustic/CausticAST)\n\nUses [ParGlare](https://github.com/igordejanovic/parglare) for parsing,\nmeant to work with [CausticGrammar](https://codeberg.org/Caustic/CausticGrammar)\nto create a [CST (Caustic AST)](https://codeberg.org/Caustic/CausticAST)\n\n\n# CLI usage\n\nSee `cap --help`\n\n\n# Module usage\n\n```python3\nimport sys\nimport parglare\nfrom pprint import pprint\nfrom pathlib import Path\n\nfrom caustic import parser\n\ngrammar = parglare.Grammar.from_file(parser.builtin_grammar('canonical/canonical.pg'))\n# ^ builtin_grammar fetches the builtin grammar path from caustic.grammar,\n# optionally adding a subdirectory and checking if it exists\n\n\nparser_ = parglare.GLRParser(grammar, lexical_disambiguation=True,\n actions=parser.actions.action.all)\n# ^ the actions module supplies some generally useful actions,\n# as well as actions specifically for creating CST nodes\n\ntry:\n forest = parser_.parse(input())\nexcept parglare.ParseError as e:\n # custom error formatting\n print(parser.errors.format_exc(e), file=sys.stderr)\n\ncst = parser_.call_actions(forest.get_first_tree())\npprint(cst)\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Caustic's parsing framework",
"version": "3.0.0",
"project_urls": {
"Homepage": "https://codeberg.org/Caustic/CausticParser",
"Issues": "https://codeberg.org/Caustic/CausticParser/issues"
},
"split_keywords": [
"caustic",
" language",
" parser",
" syntax",
" grammar"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0cfca20bf3dd03b9330128b997d11ec683f2946d2fea1fcf79e11a337f938dc6",
"md5": "227bfed46b46cebf90b2be4811a607a9",
"sha256": "8c4faac75dc0d1b0bef23e360bcd148720e1d86b11448d94f1f3aa71703ade48"
},
"downloads": -1,
"filename": "caustic.parser-3.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "227bfed46b46cebf90b2be4811a607a9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 12204,
"upload_time": "2024-05-02T19:02:07",
"upload_time_iso_8601": "2024-05-02T19:02:07.464808Z",
"url": "https://files.pythonhosted.org/packages/0c/fc/a20bf3dd03b9330128b997d11ec683f2946d2fea1fcf79e11a337f938dc6/caustic.parser-3.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9e354bf5b7929fc45ca16ce45705d938c035ee45d22108d7c9100865bb05e09e",
"md5": "2f4a7144668161d16c7c9f103474e3a7",
"sha256": "72babc122df78c439e732be847e47c9fa99564f90176a91fd38c4a151c3f0e7d"
},
"downloads": -1,
"filename": "caustic.parser-3.0.0.tar.gz",
"has_sig": false,
"md5_digest": "2f4a7144668161d16c7c9f103474e3a7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 11616,
"upload_time": "2024-05-02T19:02:09",
"upload_time_iso_8601": "2024-05-02T19:02:09.238007Z",
"url": "https://files.pythonhosted.org/packages/9e/35/4bf5b7929fc45ca16ce45705d938c035ee45d22108d7c9100865bb05e09e/caustic.parser-3.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-02 19:02:09",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": true,
"codeberg_user": "Caustic",
"codeberg_project": "CausticParser",
"lcname": "caustic.parser"
}