Skip to main content

Protobuf proto3 syntax parser

Project description

protopie

LALR(1) parser for protobuf.

One interesting aspect about the implementation of the parser is that we utilize Python type annotations to define the grammar productions. And the whole project passes the strict mypy type checker.

Disclaimer: This project is heavily assisted by code agents.

Note that currently only proto3 syntax is supported.

Installation

uv add protopie

Quickstart

Parse source code directly

from protopie import parse_source

source = '''
syntax = "proto3";

message User {
  string name = 1;
  int32 age = 2;
}
'''

ast = parse_source(source)

Parse files with import resolution

from protopie import parse_files

result = parse_files(
    entrypoints=["/abs/path/to/root.proto"],
    import_paths=["/abs/path/to/include"],
)

# result.files maps absolute path -> AST File node
root_ast = result.files[result.entrypoints[0]]

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

protopie-0.1.0.tar.gz (60.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

protopie-0.1.0-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

Details for the file protopie-0.1.0.tar.gz.

File metadata

  • Download URL: protopie-0.1.0.tar.gz
  • Upload date:
  • Size: 60.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for protopie-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d70b1a2adeb3768bdd2c90d4f8efbc8bc892e740a00c0ead303a19e9ce20a5d8
MD5 46c06822ec10ec598bcac37e4e70f032
BLAKE2b-256 201e21dad2ff1b652991ff7ee1adf48d28f3b59e315ed8275d74644d56a35da3

See more details on using hashes here.

File details

Details for the file protopie-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: protopie-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for protopie-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6ed46f656a7204a086d46afd375b1e0a3958793fce8626ff7cd8742f0ab62ac9
MD5 092a4a8035217a0353fb19d63a4250de
BLAKE2b-256 967d9cab8e2a099db44a817ee39c6bffac3bdb86a50838cea91158f3e8df8c1d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page