You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, tlin directly uses the go/ast and go/parser pacakge to analyze and process the gno code. While this approach has served us very well, it presents challenges in terms of scalability, maintability, and future language divergence.
Proposal
I propose introducing an Intermediate Representation (IR) layer between AST and our linter rulws. This IR will abstract away the specifics of AST, providing a more flexible and maintainable foundation for our linter.
Pros and Cons
Pros
Abstraction: Simplifies rule implementation by hiding AST complexities.
Maintainability: Easier to update and modify rules without deep AST background knowledge.
Language Divergence: Allows for easier adaptation as gno evolves differently from Go.
Cons
Initial Complexity: Require upfront design and implementation effort.
Learning Curve: Need to learn the new IR structure.
Potential Performance Overhead: Additional layer may introduce some performance cost.
As out language evolves and potentially diverges from Go, the IR approach offers significant advantages:
Abstraction Layer: The IR serves as a buffer between the language-specific AST and out linter rulws. When language changes occur, we can update the IR generation process without modifying all the rules.
Custom Nodes: We can introduce custom IR nodes for new language features without waiting for or relying on updates to the go's package.
Gradual Migration: We can incrementally move away from go/ast (and more related packages) by implementing our own parser that generates our IR directly, allowing for a smooth transition as the language diverge.
Feature Toogling: The IR can include flags or variants to represent language specific feeatures, allowing rules to adapt their behavior based on the target language version.
The text was updated successfully, but these errors were encountered:
Background
Currently, tlin directly uses the
go/ast
andgo/parser
pacakge to analyze and process the gno code. While this approach has served us very well, it presents challenges in terms of scalability, maintability, and future language divergence.Proposal
I propose introducing an Intermediate Representation (IR) layer between AST and our linter rulws. This IR will abstract away the specifics of AST, providing a more flexible and maintainable foundation for our linter.
Pros and Cons
Pros
Cons
Proof of Concept Implementation
Here's basic PoC for the IR structure and usage:
Handling Language Divergence
As out language evolves and potentially diverges from Go, the IR approach offers significant advantages:
go/ast
(and more related packages) by implementing our own parser that generates our IR directly, allowing for a smooth transition as the language diverge.The text was updated successfully, but these errors were encountered: