Skip to content

ASTAbstract Syntax Tree Tools

Type-safe AST parsing for JavaScript with extensible architecture powered by ANTLR v4

AST Logo

Quick Example

typescript
import { parse } from '@sylphlab/ast-javascript';

const code = `
  const greeting = "Hello, World!";
  console.log(greeting);
`;

const ast = parse(code);
console.log(ast);

Architecture Overview

The AST toolkit follows a layered architecture:

┌─────────────────────────────────────────┐
│  @sylphlab/ast-javascript               │
│  (JavaScript-specific parser)           │
└────────────────┬────────────────────────┘
                 │ depends on

┌─────────────────────────────────────────┐
│  @sylphlab/ast-core                     │
│  (Generic AST interfaces & types)       │
└─────────────────────────────────────────┘

Parsing Flow

Source Code (String)


  ANTLR Lexer
  (Tokenization)


  ANTLR Parser
  (Parse Tree)


  Custom Visitor
  (Transformation)


  Custom AST
  (@sylphlab/ast-core types)

Why Choose AST?

The Problem

Traditional AST tools are often:

  • Tightly coupled to single languages
  • Difficult to extend or customize
  • Limited type safety
  • Complex integration

The Solution

AST Toolkit provides:

  • Clean, extensible architecture
  • ANTLR-powered parsing
  • Full TypeScript type safety
  • Monorepo structure for modularity

The Result

Production-ready AST parsing with a foundation for supporting any programming language.

Technology Stack

ComponentTechnologyPurpose
LanguageTypeScript 5.8Type safety & modern JS
ParserANTLR v4Grammar-based parsing
Monorepopnpm workspacesDependency management
BuildTurborepoTask orchestration
BundlertsupFast ESM/CJS builds
TestingVitestUnit testing
LintingESLint 9 (flat config)Code quality

Getting Started

Ready to build AST parsers? Get started with our comprehensive guide:

Community


Type-safe AST parsing for the modern web
Built with TypeScript and ANTLR

Released under the MIT License.