Giter Club home page Giter Club logo

grappa-tracer-backport's Introduction

Read me first

This project is licensed under both LGPLv3 and ASL 2.0. See file LICENSE for more details.

Requires Java 7 or better.

The current version is 2.0.0:

dependencies {
    compile(group: "com.github.fge", name: "grappa-tracer-backport",
        version: "2.0.0");
}

What is it

This is a backport of the event-listening parse runner (new in grappa 2.0.x) for grappa 1.0.x.

Included is a tracing listener which uou can use it to run your grappa 1.0.x/parboiled1 parsers, which you can then analyze using the GUI debugger.

Usage

An important precision first: you do NOT need to annotate your parser with @BuildParseTree in order for this tracing parser to work.

You need a path to a zip file, which must not exist prior to running the parser. In the example below:

  • your parser is called MyParser;
  • its parameter type is String;
  • the path to the zip file is /tmp/trace.zip.

Code:

final MyParser parser = Parboiled.createParser(MyParser.class);

final Path zipPath = Paths.get("/tmp/trace.zip");
final TracingListener<String> listener
    = new TracingListener<>(zipPath);
final ParseRunner<String> runner
    = new EventBasedParseRunner<>(parser.theRule());

runner.registerListener(listener);
runner.run(someInput);

After the run, the zip file will have been created. It will contain both the input text which you used (which can be very large if you used largetext) and a JSON file containing all the trace events.

You can then use the GUI debugger to load this zip file.

grappa-tracer-backport's People

Contributors

fge avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.