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

cxx-frontend

v1.1.27

Published

A compiler front end for the C++ language

Readme

A compiler front end for the C++ language

cxx-frontend is a work-in-progress compiler frontend for C++23

The compiler frontend is designed to be a powerful tool for developers, enabling them to parse, analyze, and modify C++ source code. This project aims to provide a robust foundation for building a complete C++ frontend, staying up-to-date with the latest language features and standards.

Changelog and What's New

For updates, improvements, and recent features in cxx-frontend, please consult the Changelog.

Key Features

  • Syntax Analysis: APIs to scan, preprocess, parse, and inspect the syntax of source code, making it a versatile tool for various code analysis tasks.

  • Multi-Language Support: In addition to C++, the library provides APIs for TypeScript and JavaScript.

  • C++-23 Support: Latest language enhancements, syntax, and features (WIP).

Syntax Checker and AST Browser Showcase

Storybook and CodeMirror are used to demonstrate how to create a syntax checker and navigate the Abstract Syntax Tree (AST)

https://robertoraggi.github.io/cplusplus/

Installing from npm

To integrate the latest stable version of the C++ Compiler Frontend bindings into your project, you can install them from npm:

npm install cxx-frontend

Once installed, you can use the bindings in your Node.js or web projects as needed.

Getting Started Using Example Projects

These projects are pre-configured and serve as starting points for various use cases.

For Node.js

npx degit robertoraggi/cplusplus/templates/cxx-parse cxx-parse
cd cxx-parse
npm install
node .

For web-based applications, use these commands to clone, set up, and start a development server:

npx degit robertoraggi/cplusplus/templates/cxx-browser-esm-vite cxx-browser-esm-vite
cd cxx-browser-esm-vite
npm install
npm run dev

Build the npm package (requires docker)

cd packages/cxx-frontend

# prepare the package
npm ci

# compile WASM and TypeScript code
npm run build

# build the package
npm pack

Build the WASM/WASI (requires docker)

# build for WASI and install it under build.em/install/
./scripts/build-wasi.sh

# run the C++ front end CLI tool using wasmtime
wasmtime \
  --mapdir=/::build.wasi/install \
  --mapdir tests::tests \
  build.wasi/install/usr/bin/cxx.wasm -- \
  tests/manual/source.cc -ast-dump

Native Build and CLI tools

On Linux, macOS and Windows:

# install the python packages required to run the unit tests (optional)
pip install -r tests/unit_tests/requirements.txt

# configure the source code
cmake . \
 -G Ninja \
 -B build \
 -DCMAKE_BUILD_TYPE=Release \
 -DCXX_INTERPROCEDURAL_OPTIMIZATION=1

# build
cmake --build build

# run the unit tests
cd build
ctest --progress

Serialize the AST

Use -emit-ast to serialize the AST of a C++ program to a flatbuffer binary file

# serialize the AST
$ ./build/src/frontend/cxx -emit-ast source.cc -o source.ast

You can use any flatbuffers supported decoder to read the AST, e.g.

# Use flatc to dump the AST to JSON
$ ./build/_deps/flatbuffers-build/flatc --raw-binary -t build/src/parser/cxx/ast.bfbs  -- source.ast

$ ll source.*
source.ast source.cc source.json

License

Copyright (c) 2023 Roberto Raggi [email protected]

Licensed under the MIT license.