Traverses the AST to perform static analysis, semantic checks, and error detection.
npm install @je-es/ast-analyzer

A static analysis tool that traverses the AST
to perform semantic checks, validation, scope resolution, and error detection.

- ### Install
``bash`
npm install @je-es/ast-analyzer
`ts`
import { Analyzer } from "@je-es/ast-analyzer";
- ### Usage
`rust`
// suppose we want to analyze the represented AST for this statement:
pub let mut x: i32 = 42
`ts
// [1] Create syntax
const syntax = Syntax.create({ // :: using @je-es/syntax(parser/lexer)
name : 'Kemet',
version : '0.0.1',
lexer : lexerRules,
parser : parserRules,
settings : parserSettings
} as syntax.SyntaxConfig
);
// [2] Parsing the input
const parser_result = syntax.parse('pub let mut x: i32 = 42');
// [3] Create module using the parser result
const main_module = AST.Module.create( // :: using @je-es/ast
// Name
'main',
// Statements
parser_result.ast.length > 0
// in my case, first item refers to an array of stmts.
? parser_result.ast[0].getCustomData()! as AST.StmtNode[]
// otherwise, empty module.
: [],
// Metadata
{ path: './src/main.k' }
);
// [4] Create program with the created module
const program = AST.Program.create([main_module], { entryModule: 'main', path: './' });
// [5] Create analyzer for the created program
const analyzer = Analyzer.create({ debug: 'off' });
const analyzer_result = analyzer.analyze(program);
`
- ### Related
- #### kemet-lang (MVP)
> #### 1. @je-es/lexer
> #### 2. @je-es/parser
> #### 3. @je-es/ast
> #### 4. @je-es/syntax
> #### 5. @je-es/ast-analyzer`
> #### 6. @je-es/project
> #### 7. @je-es/lsp
> #### 8. @je-es/codegen
> #### 9. @je-es/compiler
