jison2dart 0.1.1 copy "jison2dart: ^0.1.1" to clipboard
jison2dart: ^0.1.1 copied to clipboard

outdated

Generate Dart parsers using Jison

jison2dart #

Generate Dart parsers using Jison - Bison in JavaScript.

Getting Started #

First, you have to prepare Nodejs for your environment, and install jison.

git clone git@github.com:rikulo/jison2dart.git
cd jison2dart/lib/js
npm install

Then, you can compile a Jison file to a Dart parser. For example,

node bison.js examples/caculator.jison

For more options, please run

node bison.js --help

The Dart file will contain a class depending on the jison filename. For example,

class Caculator extends JisonParser {

  parse() {
...

To use the Dart parser in your application, you have to put jison2dart to your pubspec.yaml.

Then, you can use the parser. For example,

print(new Caculator().parse("2 * 3"));

Special Extensions #

%library #

Optional. Generates the library statement in the Dart pasrer.

%library my.lib

%class #

Optional. Specfies the name of the Dart pasrer.

%class CalcParser

The prologue: %{ and %} #

Optional. If you'd like to import other libraries or embed Dart codes, you can put the code between %{ and %}.

%{
  import "super/foo.dart";

  String camelize(String text) {
    ...
  }
}%

Note: unlike Bison's prologue, you can put at most one prologue.

Resources #

Who Uses #

  • Quire - a simple, collaborative, multi-level task management tool.
  • Keikai - a sophisticated spreadsheet for big data