Giter Club home page Giter Club logo

jall's Introduction

jall是一个使用java写成的轻量级语法分析代码生成器

jall使用一个定制的语法描述语言作为输入,对输入的语法执行消左递归与提取左公因子 jall可以针对不同的目标语言生成对应的代码

你可以使用

java -jar jall.jar language.ll show

来展示经过处理后的语法

java -jar jall.jar language.ll java

来展示生成的对应java代码

生成的代码需要使用以下四个方法/函数和一个字段/变量

// 读取下一个词法类型
void next();
// 将下一个词法单元读取
Token push();
// 检查下一个词法类型
void check(TokenType needTokenType) throws Exceptions;
// 返回词法不匹配的错误
Exceptions need(TokenType has,TokenType... needs);

// 下一个词法类型
TokenType token;

其中

Exceptions,TokenType,Token

可以由用户定义 默认值是

空,int,String

其伪代码为

Queue<Token> queue;

void next() {
    readToken();
    token = readedTokenType;
    queue.add(readedToken);
}

Token push() {
    return queue.remove();
}

void check(TokenType needTokenType) throws Exceptions {
    if(token != needTokenType){
        throw need(token, needTokenType);
    }
}

Exceptions need(TokenType token,TokenType... needTokenTypes) {
    return new Exceptions("...");
}

jall's People

Contributors

823984418 avatar

Stargazers

周祺皓 avatar  avatar

Watchers

 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.