Coder Social home page Coder Social logo

rikulo / jison2dart Goto Github PK

View Code? Open in Web Editor NEW
4.0 8.0 0.0 71 KB

Generate Dart parsers using Jison - Bison/Yacc in JavaScript

Home Page: https://quire.io

License: MIT License

Dart 67.64% JavaScript 24.09% Yacc 8.27%
jison bison dart-parser dart flutter yacc

jison2dart's Introduction

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

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

cd example
node ../lib/js/jison2dart.js calculator.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 DefaultJisonParser {

  Object 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(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 override it, say, for different platforms, you can specify abstract too:

%class abstract ParserBase

%extends

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

%extends MyGenericParser

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

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

jison2dart's People

Contributors

justkawal avatar tomyeh avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jison2dart's Issues

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.