Last updated:
0 purchases
jison2dart
jison2dart #
Generate Dart parsers using Jison - Bison/Yacc in JavaScript.
Getting Started #
First, you have to prepare Nodejs for your environment, and install jison.
git clone [email protected]:rikulo/jison2dart.git
cd jison2dart/lib/js
npm install
copied to clipboard
Then, you can compile a Jison file to a Dart parser. For example,
cd example
node ../lib/js/jison2dart.js calculator.jison
copied to clipboard
For more options, please run
node bison.js --help
copied to clipboard
The Dart file will contain a class depending on the jison filename. For example,
class Caculator extends DefaultJisonParser {
Object parse() {
...
copied to clipboard
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(Caculator().parse("2 * 3"));
copied to clipboard
Special Extensions #
%library #
Optional. Generates the library statement in the Dart pasrer.
%library my.lib
copied to clipboard
%class #
Optional. Specfies the name of the Dart pasrer.
%class CalcParser
copied to clipboard
If you'd like to override it, say, for different platforms, you can specify abstract too:
%class abstract ParserBase
copied to clipboard
%extends #
If you'd like to extend from your custom class, you can specify it as follows:
%extends MyGenericParser
copied to clipboard
Note: Your implementation must implement JisonParser, or extends DefaultJisonParser.
%case-sensitive #
By default, the lexer is case senstive. You can turn off as follows:
%case-sensitive false
copied to clipboard
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) {
...
}
}%
copied to clipboard
Note: unlike Bison's prologue, you can put at most one prologue.
Resources #
API Reference
Git Repos
Who Uses #
Quire - a simple, collaborative, multi-level task management tool.
Keikai - a sophisticated spreadsheet for big data
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.