Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol Buffers parser #31

Closed
phodal opened this issue Oct 25, 2024 · 0 comments
Closed

Protocol Buffers parser #31

phodal opened this issue Oct 25, 2024 · 0 comments

Comments

@phodal
Copy link
Owner

phodal commented Oct 25, 2024

Protobuf is the Domain model of multiple languages.

related to phodal/shire#122

@phodal phodal changed the title Domain model of Protobuf Protobuf parser Oct 25, 2024
@phodal phodal changed the title Protobuf parser Protocol Buffers parser Oct 25, 2024
phodal added a commit that referenced this issue Oct 25, 2024
This commit introduces support for parsing Protocol Buffers (protobuf) files by adding an ANTLR grammar and associated parser. The antlr grammar (Protobuf3.g4) is based on the protobuf3 specification and includes a comprehensive set of rules for all protobuf syntax elements. The antlr-generated parser (Protobuf3Lexer and Protobuf3Parser) is used by the ProtobufAnalyser class to analyze protobuf files and extract package and message information.

Additionally, the commit includes a test protobuf file (common.proto) and a test case (ProtobufAnalyserTest.kt) to validate the parser. The antlr-generated lexer and parser are configured in build.gradle.kts, and the protobuf grammar file is located in src/main/antlr. The antlr grammar and parser provide a solid foundation for further protobuf analysis and processing within the Chapi project.
phodal added a commit that referenced this issue Oct 25, 2024
… structures #31

Previously, the Protobuf parser did not fully support parsing enum definitions and inner structures within message definitions. This commit introduces the necessary changes to:

- Update `ProtobufFullIdentListener` to properly handle `EnumDefContext` and add support for inner structures.
- Refactor `constructMessageDef` and introduce `constructEnum` to build `CodeDataStruct` for enums.
- Add a test case in `ProtobufAnalyserTest` to validate the parsing of enum definitions.

These enhancements enable more comprehensive analysis of Protobuf files, including the handling of nested and enum-related definitions.
phodal added a commit that referenced this issue Oct 25, 2024
…er.kt #31

Update the variable name from 'child' to 'enumChild' to improve readability in the context of processing enum elements within the ProtobufFullIdentListener. This change reduces confusion by differentiating the variable's role in the enum-specific branch of the when-statement.
phodal added a commit that referenced this issue Oct 25, 2024
Add the capability to properly construct nested messages within Protobuf definitions and include a new test case for enum parsing. This update ensures that the `ProtobufFullIdentListener` correctly handles nested structures and the `ProtobufAnalyserTest` reflects these changes with improved test code readability using the `@Language` annotation for Protobuf syntax highlighting.
phodal added a commit that referenced this issue Oct 25, 2024
phodal added a commit that referenced this issue Oct 25, 2024
…ion #31

Add a new real-world test case for Protobuf parsing to ensure all fields and messages are correctly parsed. Additionally, improve the `constructField` function by including the field's modifiers in the `CodeField` object.
phodal added a commit that referenced this issue Oct 25, 2024
Adds the capability to parse services within protobuf files and introduces a new FunctionType for RPCs.
@phodal phodal closed this as completed Oct 25, 2024
@phodal phodal reopened this Oct 25, 2024
phodal added a commit that referenced this issue Oct 25, 2024
#31

Add the capability to track code positions within Protobuf files by implementing a `buildPosition` function. This change also includes enhancements to data structures by incorporating additional type information and position data for improved code analysis.
phodal added a commit that referenced this issue Oct 25, 2024
…g logic #31

This commit introduces support for Protocol Buffers version 2 (proto2) by adding a new grammar file and corresponding parsing logic. The `Protobuf2FullIdentListener` class is created to handle the parsing of proto2 files, and the `ProtobufAnalyser` class is updated to conditionally use the proto2 analyser if the proto3 analyser encounters syntax errors. Additionally, a `SyntaxErrorListener` class is implemented to capture and report syntax errors during parsing. The `ProtobufRealWorldTest` is extended to include a test case for proto2 parsing.
@phodal phodal closed this as completed Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant