Skip to content

How to parse to fine-grained statements? #10

Open
@Subway2023

Description

@Subway2023

I used the method from CircomFilesVisitor for parsing. However, the parsing result is coarse-grained and does not parse each statement in the Circom program.

test.ts

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

import CircomFilesVisitor from './CircomFilesVisitor';

let source="/mnt/sdd1/sbw/circom/test_circomParser/historyBug/circom/208.circom"

const parser = getCircomParser(source);

const visitor = new CircomFilesVisitor(source);

visitor.visit(parser.circuit());

let temp=visitor.fileData;
let templates=temp.templates;
console.log("templates",templates)
templates {
  Example: {
    parameters: [],
    isCustom: false,
    parallel: false,
    context: TemplateDefinitionContext {
      parentCtx: [BlockDefinitonContext],
      invokingState: 176,
      children: [Array],
      start: [Pt],
      stop: [Pt],
      exception: null,
      _argNames: undefined,
      parser: [ExtendedCircomParser]
    }
  }
}
1733928298119

I want to obtain a fine-grained parse tree at the statement level, like the one on the far right in the image. What should I do?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions