Code Monkey home page Code Monkey logo

Comments (4)

kaby76 avatar kaby76 commented on May 29, 2024 1

Here is a repo containing an example for an "Expression" grammar with TypeScript: https://github.com/kaby76/ExpressionTypeScript. I gathered the visitor code from Antlr4ng , which is a fork of Antlr4, then ported it back to Antlr4. That example didn't work for Antlr4ng either (compilation errors among other problems).

But, to implement an Antlr visitor in TypeScript, you need to override every single visitor "method". In the example I provide, I didn't implement methods for subtraction, multiplication, or division, but you should get the point. From command line, bash run.sh -input '1+2', outputs 3.

from antlr4.

YuMuuu avatar YuMuuu commented on May 29, 2024

@kaby76
Thank you for quick reply.
I haven't tried this code yet, do I need to write code for the Visitor by myself instead of antlr?
And do I need to fix the Typescript implementation of the automatic generation to contribute to the document?

from antlr4.

kaby76 avatar kaby76 commented on May 29, 2024

There's nothing you need to write to get the example to work--other than have the prerequisites. The example is self contained. However, the build scripts are written for an Ubuntu environment, i.e., it uses "make", "Bash", etc., which every programmer should know.

from antlr4.

YuMuuu avatar YuMuuu commented on May 29, 2024

I was able to understand the example you gave by running.

And what I wanted to say is how to fix this document, I understand that too.

Thank you.

from antlr4.

Related Issues (20)

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.