-
Notifications
You must be signed in to change notification settings - Fork 122
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
Tact as library #314
Comments
This would be insanely useful in tools like language server and such! In general, I agree with all those points, but implementation of some may just require us to make our own lexer→parser→semantic analysis pipeline, suitable for compiler AND external tooling depending on various steps in it. I'd say this depends on #286, but I may be wrong and we could pull off such feat without compromising the Ohm's toolkit. |
I would also suggest creating named union types for AST entries used in fields. For example: export type ASTContract = {
kind: 'def_contract';
origin: TypeOrigin;
id: number;
name: string;
traits: ASTString[];
attributes: ASTContractAttribute[];
declarations: (ASTField | ASTFunction | ASTInitFunction | ASTReceive | ASTConstant)[];
ref: ASTRef;
}; Could be rewritten as: export type ASTContractDeclaration = (ASTField | ASTFunction | ASTInitFunction | ASTReceive | ASTConstant);
export type ASTContract = {
kind: 'def_contract';
origin: TypeOrigin;
id: number;
name: string;
traits: ASTString[];
attributes: ASTContractAttribute[];
declarations: ASTContractDeclaration[];
ref: ASTRef;
}; This will simplify the life of tooling developers by enabling them to reuse these type definitions from the compiler. Otherwise, I find myself copy-pasting these entries in my projects. Here is an example of a function with such a signature implemented in the static analyzer internals: function getMethodInfo(
decl: ASTField | ASTFunction | ASTInitFunction | ASTReceive | ASTConstant,
): [string | undefined, FunctionKind | undefined] { |
Added three more points:
|
This should be introduced in the compiler's API: tact-lang/tact#314
This improves compiler's API providing an interface to traverse the AST. It should be a part of the compiler, since it is be useful for devtools using the API and might be useful internally. Refers to tact-lang#314
This improves compiler's API providing an interface to traverse the AST. It should be a part of the compiler, since it is useful for devtools using the API and might be useful internally. Refers to #314
Added while working on tests for #559:
|
Every point here makes a lot of sense, except for
In fact, we should remove id from AST nodes. They are just disguised references, and there is neither GC nor type safety to ensure AST ids stored elsewhere won't become dangling references. While we could patch |
I would argue against any idea of mutating the AST. If we need to transform AST, we should create a second AST to ensure a clean design for both the compiler and API users. Otherwise, the AST should be available at all stages of compilation since we need to access that information from different places; therefore, it will never be GCed. Additionally, having unique IDs is essential for maintaining symbol tables that are useful at different stages of compilation, particularly for analysis and accessing the AST from other IRs what is used in Misti. |
Third-party TypeScript API
The text was updated successfully, but these errors were encountered: