npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

simc-ast-builder

v0.3.3

Published

Parser and AST generator for SimulationCraft files

Readme

SimC AST Builder

A TypeScript library for parsing and building abstract syntax trees (ASTs) from SimulationCraft (SimC) action lists.

Features

  • Parse SimulationCraft expressions and action lists
  • Generate fully-typed abstract syntax trees
  • Optimize conditions with various transformation rules
  • Built with ANTLR4 for robust parsing
  • Full TypeScript support with type definitions

Installation

npm install simc-ast-builder

Usage

Basic Parsing

import { parse } from 'simc-ast-builder';

// Parse a SimC action line
const code = 'actions=frost_strike,if=runic_power>=80';
const ast = parse(code);
console.log(JSON.stringify(ast, null, 2));

Condition Optimization

import { parse, optimize } from 'simc-ast-builder';

// Parse a SimC action with complex conditions
const code = 'actions=frost_strike,if=!(!runic_power>=80&!buff.killing_machine.up)';
const ast = parse(code);

// Optimize the AST to simplify conditions
const optimizedAst = optimize(ast);
console.log(JSON.stringify(optimizedAst, null, 2));

Custom Optimization Options

import { parse, optimize } from 'simc-ast-builder';

const code = 'actions=frost_strike,if=!(!runic_power>=80&buff.killing_machine.up)';
const ast = parse(code);

// Apply only specific optimizations
const customOptimizedAst = optimize(ast, { 
  enabled: true,               // Overall enable/disable flag for all optimizations
  doubleNegation: true,        // Simplify double negation (!!A → A)
  deMorgansLaw: true,          // Apply De Morgan's laws (!(A && B) → !A || !B)
  complementaryTerms: false,   // Simplify complementary terms (A && !A → false, A || !A → true)
  constantsAndIdentities: false, // Simplify constants and identity operations (true && A → A, false || A → A, etc.)
  absorptionLaws: false,       // Apply absorption laws (A && (A || B) → A, A || (A && B) → A)
  flattenNestedOperations: false, // Flatten nested operations (A && (B && C) → (A && B) && C)
  commonSubexpressions: false  // Eliminate common subexpressions ((A && B) || (A && C) → A && (B || C))
});

All-in-one Parsing and Optimization

import { generateAST } from 'simc-ast-builder';

const code = 'actions=frost_strike,if=runic_power>=80';
const result = generateAST(code);
// Result contains the optimized AST and any errors

Project Structure

  • /src - Source code
    • /parser - ANTLR4 parser integration
      • /antlr4 - ANTLR4 grammar and generated files
      • /visitors - AST visitor implementation
    • /types - TypeScript type definitions
    • /utils - Utility functions including condition optimizer

Development

Prerequisites

  • Node.js (v14+)
  • npm or yarn

Setup

# Clone the repository
git clone https://github.com/legacy3/simc-ast-builder.git
cd simc-ast-builder

# Install dependencies
npm install

# Generate ANTLR4 parser from grammar
npm run generate

# Build the project
npm run build

# Run tests
npm test

Available Scripts

  • npm run build - Build the project
  • npm run generate - Generate ANTLR4 parser files from grammar
  • npm test - Run tests
  • npm run format - Format code with Prettier
  • npm run lint - Lint code with ESLint

License

This project is licensed under the GPL-3.0 License.