GithubHelp home page GithubHelp logo

caiofazio / minijava-parser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cubsphere/minijava-parser

0.0 1.0 0.0 82 KB

AST construction made with the help of ANTLR

ANTLR 1.64% Java 98.36%

minijava-parser's Introduction

minijava-parser

AST construction, symbol table construction and type checking for minijava made with antlr.

The antlr grammar used to generate sources is located at src/main/antlr4/minijava.g4 The AST is built by the class ASTGenerator, which inherits from minijavaBaseListener. Its source file is src/main/java/minijava/ASTGenerator.java

The symbol table is built by the class BuildSymbolTableVisitor, which traverses the AST to build its symbol table. Its source file is src/main/java/br/ufpe/cin/if688/minijava/visitor/BuildSymbolTableVisitor.java The type checking is performed by the class TypeCheckVisitor, which uses the symbol table and traverses the AST to find type errors. We took the liberty to also make it check for inheritance errors. Its source file is src/main/java/br/ufpe/cin/if688/minijava/visitor/TypeCheckVisitor.java

BuildSymbolTableVisitor and TypeCheckVisitor will attempt to continue traversing an AST even after encountering an error, in an effort to find as many errors as possible. However, an error may make it impossible to continue, so there's no guarantee that all errors will be found.

The Main class reads all files from src/test/resources, parses them to generate ASTs, and visits them with a PrettyPrintVisitor, a BuildSymbolTableVisitor, and a TypeCheckVisitor. The files in this folder are valid minijava programs, so no error messages will be produced. It then repeats the process for src/test/resources/type-errors, which contains files with multiple type errors, which will be found and reported.

Made by lml and insbs

minijava-parser's People

Contributors

cubsphere avatar

Watchers

James Cloos 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.