cpp-signatures
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

C++ Signatures

C++ function signature parsers.

Review Version Downloads Size Quality Coverage

Motivation

C++ is really hard to parse. However, we can still use regular expressions to tokenise some common expressions:

import { Signature } from "cpp-signatures";

const signature = new Signature("F map(std::function<A(A)> mapper, F vec)");

console.log(signature);
{
  "name": "map",
  "inputs": [
    {
      "name": "mapper",
      "typename": "std::function<A(A)>"
    },
    {
      "name": "vec",
      "typename": "F"
    }
  ],
  "output": {
    "name": null,
    "typename": "F"
  }
}

We can also format the signatures to Haskell style type signatures:

new Signature("int increment(const int &x)").format();
"const int & -> int"

This includes lambda expressions:

new Signature("FA map(const std::function<A(A)> &mapper, FA vec)").format();
"(A -> A) -> FA -> FA"

Note we have omitted the const and & from const (A -> A) & for brevity.

Installing

npm install cpp-signatures

Documentation

Documentation and more detailed examples are hosted on Github Pages.

Tooling

Dependencies

To install dependencies:

yarn install

Tests

To run tests:

yarn test

Documentation

To generate the documentation locally:

yarn docs

Linters

To run linters:

yarn lint

Formatters

To run formatters:

yarn format

Contributing

Please read this repository's Code of Conduct which outlines our collaboration standards and the Changelog for details on breaking changes that have been made.

This repository adheres to semantic versioning standards. For more information on semantic versioning visit SemVer.

Bump2version is used to version and tag changes. For example:

bump2version patch

Contributors

Remarks

Lots of love to the open source community!

Be kind to your mind Love each other It's ok to have a bad day

Package Sidebar

Install

npm i cpp-signatures

Weekly Downloads

206

Version

1.1.0

License

MIT

Unpacked Size

15.7 kB

Total Files

17

Last publish

Collaborators

  • joellefkowitz