Comments (4)
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.
@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.
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.
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)
- Android Tool run
- Separated package/artifactId when the minor version is upgraded for compatibility issues
- [Go] Can not use BailErrorStrategy since ParseCancellationException is not implement HOT 2
- Issue with using ANTLR4 from Julia via PyCall
- C++ warning + fix HOT 2
- Error with books source examples in chapter 4
- Clarify supported Python runtime language version HOT 4
- Unable to customize error messages on top of error messages generated by ANTLR4 Parser HOT 1
- [go] performance downgrade a lot after upgrade antlr from 4.9 to 4.13.1 HOT 8
- [C++] Building grammar with rule named "match" causes errors
- JavaScript runtime fails to parse input that can be parsed by `grun` with same grammar HOT 1
- Regex
- Go target: missing constructor call to the superclass of the generated parser or lexer HOT 2
- limits like DIGIT {min,max} in patterns HOT 1
- antlr4 lacks automatic module name, which is inconsistent to antlr4-runtime
- ANTLR 4.2 and later fail to report error with mislocated 'assoc'
- ANLTR4 Pascal target for parsing Pascal Object Notation HOT 8
- TSQL select query not parsed when it inside the quotes
- [go target] Build errors with PartiQL parser HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from antlr4.