jison2dart 0.2.0

  • Readme
  • Changelog
  • Installing
  • new63

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,

cd examples
node ../jison2dart.js 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 {

  dynamic 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

If you'd like to extend from your custom class, you can specify it as follows:

%class CalcParser extends MyGenericParser

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

0.2.0 #

  • %class supports extends
  • Rename dison.js to jison2dart.js

0.1.1 #

  • Support the prologue: %{ and %}. And, remove the %code-%% block

0.1.0 #

  • First release

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  jison2dart: ^0.2.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:jison2dart/jison2dart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
32
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health issues and suggestions

Document public APIs. (-0.75 points)

117 out of 118 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/jison2dart.dart. (-1.49 points)

Analysis of lib/jison2dart.dart reported 3 hints:

line 1 col 1: Prefer using /// for doc comments.

line 38 col 12: Unnecessary new keyword.

line 54 col 17: Unnecessary new keyword.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and jison2dart.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test any