Code Monkey home page Code Monkey logo

exampleantlr's Introduction

Example ANTLR

I wanted to have a bare minimum ANTLR project handy written in Java and specifically for Eclipse Oxygen. So, I created this repo for that purpose and it may be useful for anyone else.

Instructions

Most of the setup work is described discussed here and some code is provided here. The pom file will take care of the antlr4 dependencies as well as the antrl4 maven plugin which is crucial for properly generating the lexer/parser/visitor/listener classes treated as source code so it can be used by your main code.

The project structure is almost identical to the markup-example project found in the link but this is how it actually looks like once the project is built using the pom file:

drawing

With this setup, the maven plugin for antlr4 looks for the .g4 grammar file residing in a folder under src/main/antlr4/.... Make sure this nested folder structure are regular ones, i.e. not treated as Java source code by Eclipse. Once you have this structure when you generate the antlr4 files based on the .g4 file, the generated files will reside in a target/generated-sources/antlr4 folder by default. If this turns out to be non-source, right click folder, select Build Path > Use as Source Folder. This is important because you want to be able to import the generated Java files with your main code which resides in the src/main/java/... folder.

In the above picture, I have left out other folders that are generated inside of the other non-source target folder to focus on the essential files you need.

Resources

To get a better understanding of the setup I encourage you to check out antlr's maven plugin and the installation steps for ANTLR.

exampleantlr's People

Contributors

nischalshrestha avatar

Watchers

 avatar  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.