chaokunyang opened a new issue, #3178:
URL: https://github.com/apache/fory/issues/3178

   ### Feature Request
   
   Refactor fory compiler to transform the Fory compiler into a hierarchical, 
multi-frontend architecture. 
   
   The key insight is to establish the Fory IDL AST as the **canonical 
intermediate representation (IR)**, with separate frontend parsers for 
different IDL formats (`.proto`, `.fbs`, `.fdl`) that all translate to this 
common IR.
   
   ### Is your feature request related to a problem? Please describe
   
   Current Architecture
   
   ```
   ┌─────────────┐    ┌─────────────┐    ┌─────────────┐
   │  .fdl file  │───▶│   Parser    │───▶│  Fory AST   │───▶ Generators
   └─────────────┘    └─────────────┘    └─────────────┘
                      (combined parsing
                       & validation)
   ```
   
   **Current Components:**
   - `parser/lexer.py` - Tokenizer for FDL syntax
   - `parser/parser.py` - Recursive descent parser (handles FDL + 
protobuf-style syntax)
   - `parser/ast.py` - AST node definitions
   - `generators/*.py` - Code generators for each target language
   
   **Current Issues:**
   1. Parser mixes FDL-native and protobuf-compatible syntax handling
   2. FDL parser handles protobuf-style `option (fory).xxx = value;` syntax 
unnecessarily
   3. No clear separation between parsing, semantic analysis, and code 
generation
   4. Adding new IDL formats requires modifying the core parser
   5. Validation is scattered across parsing and `Schema.validate()`
   
   
   ### Describe the solution you'd like
   
   ```
                       ┌─────────────┐
                       │  .fdl file  │
                       └──────┬──────┘
                              │
                       ┌──────▼──────┐
                       │  FDL Lexer  │
                       │  FDL Parser │
                       └──────┬──────┘
                              │
   ┌─────────────┐     ┌──────▼──────┐     ┌─────────────┐
   │ .proto file │────▶│  Proto to   │────▶│             │
   └─────────────┘     │  Fory AST   │     │             │
                       └─────────────┘     │             │
                                           │  Fory AST   │───▶ Validation ───▶ 
Generators
   ┌─────────────┐     ┌─────────────┐     │    (IR)     │
   │  .fbs file  │────▶│  FBS to     │────▶│             │
   └─────────────┘     │  Fory AST   │     │             │
                       └─────────────┘     │             │
                                           │             │
   ┌─────────────┐     ┌─────────────┐     │             │
   │  Future IDL │────▶│  New Parser │────▶│             │
   └─────────────┘     └─────────────┘     └─────────────┘
   ```
   
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to