Skip to main content

Caustic's Parser -- uses grammar specification to compile Caustic source code into a CST (Caustic AST)

Uses ParGlare for parsing, meant to work with CausticGrammar to create a CST (Caustic AST)

CLI usage

See cap --help

Module usage

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)

Metadata

Release files for caustic.parser 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for caustic.parser 3.0.0
File Size Uploaded
caustic.parser-3.0.0.tar.gz 11.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for caustic.parser 3.0.0
File Interpreter ABI Platform
caustic.parser-3.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.8 kB

Release files / caustic.parser-3.0.0.tar.gz

Download URL caustic.parser-3.0.0.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
72babc122df78c439e732be847e47c9fa99564f90176a91fd38c4a151c3f0e7d
BLAKE2b-256 checksum
How to use checksums
9e354bf5b7929fc45ca16ce45705d938c035ee45d22108d7c9100865bb05e09e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / caustic.parser-3.0.0-py3-none-any.whl

Download URL caustic.parser-3.0.0-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c4faac75dc0d1b0bef23e360bcd148720e1d86b11448d94f1f3aa71703ade48
BLAKE2b-256 checksum
How to use checksums
0cfca20bf3dd03b9330128b997d11ec683f2946d2fea1fcf79e11a337f938dc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 release files

2.2.6

2 release files

2.2.5

2 release files

2.2.4

2 release files

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page