Socket
Book a DemoInstallSign in
Socket

@distributedlab/circom-parser

Package Overview
Dependencies
Maintainers
5
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@distributedlab/circom-parser

Circom circuit parser built with ANTLR4

0.2.6
latest
Source
npmnpm
Version published
Maintainers
5
Created
Source

Circom Parser

A TypeScript package for parsing Circom code using ANTLR (ANother Tool for Language Recognition) grammar.

It includes built-in visitors and utilities that allow you to parse, traverse, and manipulate Circom circuits.

Installation

npm install @distributedlab/circom-parser

Usage

Custom Visitor Creation

To create your own visitor, simply extend the CircomVisitor class and override the visit methods you need.

import { CircomVisitor, AnyRuleContext } from '@distributed-lab/circom-parser';

export default class MyCircomVisitor extends CircomVisitor {
    visitAnyRule = (ctx: AnyRuleContext) => {
        // override the visit logic here
    }
}

Custom Visitor Usage

After creating your custom visitor, you can use it with the CircomParser to traverse and manipulate the parse tree.

import { getCircomParser, ParserError } from '@distributed-lab/circom-parser';

import { MyCircomVisitor } from './MyCircomVisitor';

const { parser, errorListener } = getCircomParser(source);

const templateVisitor = new MyCircomVisitor();

templateVisitor.visit(parser.circuit());

if (errorListener.hasErrors()) {
    throw new ParserError(errorListener.getErrors());
}

Keywords

distributedlab

FAQs

Package last updated on 31 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.