JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q45444F
  • License MIT

Traverses the AST to perform static analysis, semantic checks, and error detection.

Package Exports

  • @je-es/ast-analyzer
  • @je-es/ast-analyzer/dist/ast-analyzer.js
  • @je-es/ast-analyzer/dist/ast-analyzer.mjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@je-es/ast-analyzer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme


ast-analyzer

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

line
  • Install

    npm install @je-es/ast-analyzer
    import { Analyzer } from "@je-es/ast-analyzer";

    line
  • Usage

    // suppose we want to analyze the represented AST for this statement:
    pub let mut x: i32 = 42
    // [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);

    line

line