Crates.io | proto-file-parser |
lib.rs | proto-file-parser |
version | 0.1.1 |
source | src |
created_at | 2024-11-10 14:02:12.961858 |
updated_at | 2024-11-17 15:47:25.856197 |
description | A Protocol Buffer Definition (.proto) parser that converts proto files to JSON format |
homepage | |
repository | https://github.com/yourusername/proto-file-parser |
max_upload_size | |
id | 1442939 |
size | 58,170 |
A Rust library and CLI tool for parsing Protocol Buffer Definition (.proto) files into JSON format.
https://crates.io/crates/proto-file-parser
The parser processes .proto files through the following stages:
Lexical Analysis
Syntax Parsing
Semantic Analysis
JSON Generation
proto = syntax_spec package_spec? import_spec*
(message_def | enum_def | service_def)*
syntax_spec = "syntax" "=" quote ("proto2" | "proto3") quote ";"
package_spec = "package" full_ident ";"
import_spec = "import" quote import_path quote ";"
message_def = "message" ident "{" field_def* "}"
field_def = type_name ident "=" number ";"
enum_def = "enum" ident "{" enum_field* "}"
service_def = "service" ident "{" rpc_def* "}"
rpc_def = "rpc" ident "(" message_type ")"
"returns" "(" message_type ")" ";"
# Parse a .proto file and output JSON
proto-file-parser parse input.proto
# Display help information
proto-file-parser help
# Show version and credits
proto-file-parser version
use proto_parser::Parser;
let parser = Parser::new();
let json = parser.parse_file("input.proto")?;
println!("{}", json);
# Format code
make format
# Run tests
make test
# Run linter
make lint
# Run all checks before committing
make pre-commit