Git Product home page Git Product logo

antlr-experiment's Introduction

antlr-experiment

A toy interpreter for a toy version of ABAP.

Getting started

  1. Clone the repo.
  2. Run CLASSPATH=path/to/your/antlr-4.8-complete.jar make prepare (the Makefile has `/usr/share/java/antlr-4.8-comple.har as a default path).
  3. Run the project as node index.js or event ./index.js!

Usage

node index.js --source <sourceFile> [--input <inputFile>]

Input defaults to stdin.

Project structure

  • task.md: The task in hand.
  • ABAP.g4: ANTLR grammar for the project
  • index.js: Entrypoint for the interpreter. Contains the setup of the parser and the handling of the arguments.
  • ChecksVisitor.js: A ParseTreeVisitor that transforms a parse tree into a (maybe empty) list of errors.
  • CompilerVisitor.js: A ParseTreeVisitor that transforms a parse tree into an anonymous function that interprets the program.
  • test: Small "test-suite"
    • example*.abap: An example file
    • example*.input: The input to test that example file
    • example*.output: The expected output

Useful Makefile targets:

Note: the Makefile uses GNU Make syntax. If you use Windows or BSD flavors of make it will not work.

  • tree-% and gui-%: Run antlr's grun and see the parse tree of test/example%.abap
  • test-%: Run the interpeter on test/example&.abap with test/example%.input as input and compare the results against test/example%.output.
  • prepare: Generates the javascript parser files.
  • clean: Remove all the files generated by antlr.

antlr-experiment's People

Contributors

iglosiggio avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

augustdzw

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.