Can you provide an update on the progress of the JavaScript target development in antlr3?

What is the current status of Antlr3's Javascript target? I attempted to generate a parser for a simple grammar, but encountered numerous compiler errors in the generated code. After investigating the website, I downloaded the latest antlr3.5-snapshot code and compiled antlr from the source using Maven. However, the issues persist. Is there a specific version that I should be using, or is the Javascript target simply broken? (I found discussions about the target being broken in versions 3.1 and 3.2, working fine in 3.3, but no information on versions 3.4 and 3.5)

// public class variables
var = ,
    = ,
    = ,
...
    = ,
    = ;

The generated lexer and parser files contain more snippets of problematic Javascript code.

Any advice or guidance would be greatly appreciated.

Below is a basic test grammar that I utilized to experiment with Javascript code generation. Most of it was automatically generated by Antlrworks. I included the target language and the "prog" rule. (Please refrain from spending excessive time trying to modify this grammar to function correctly. Antlrworks validated the grammar and Java code generation works properly. Therefore, Javascript code generation should theoretically work without major modifications. Thanks once again for your assistance.

grammar TestgrammarV001;

options {
language=JavaScript;
}


prog    :    ID | INT;

ID  :   ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
    ;

INT :   '0'..'9'+
    ;

FLOAT
    :   ('0'..'9')+ '.' ('0'..'9')* EXPONENT?
    |   '.' ('0'..'9')+ EXPONENT?
    |   ('0'..'9')+ EXPONENT
    ;

COMMENT
    :   '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
    |   '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
    ;

WS  :   ( ' '
        | '\t'
        | '\r'
        | '\n'
        ) {$channel=HIDDEN;}
    ;

STRING
    :  '"' ( ESC_SEQ | ~('\\'|'"') )* '"'
    ;

CHAR:  '\'' ( ESC_SEQ | ~('\''|'\\') ) '\''
    ;

fragment
EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;

fragment
HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ;

fragment
ESC_SEQ
    :   '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
    |   UNICODE_ESC
    |   OCTAL_ESC
    ;

fragment
OCTAL_ESC
    :   '\\' ('0'..'3') ('0'..'7') ('0'..'7')
    |   '\\' ('0'..'7') ('0'..'7')
    |   '\\' ('0'..'7')
    ;

fragment
UNICODE_ESC
    :   '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
    ;

Answer №1

About a year and a half ago, I asked a similar question (you can find the post here: Status of Javascript in antlr 3.4 or 3.5).

It seems that while the JavaScript target was functional in ANTLR v3.3, it encountered issues in versions 3.4 and 3.5.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Looking for a .NET MVC AJAX search solution. How can I enhance the code below?

I am looking to implement a search functionality using AJAX. I have tried using the get method in my controller by passing the search string, but it is not working as expected. Below is a snippet of my controller code, where I retrieve the search value fr ...

When using console.log in Node.js, an empty object may be displayed as the

I'm intrigued by the way Node.js displays objects when using console.log(object). In the file constructor.js, I found the following code snippet (taken from the book Learning Javascript Design Patterns): var defineProp = function(obj, key, value){ ...

Accessing the nested arrays within an ng-repeat loop

Can anyone help me figure out what I'm doing incorrectly here? I've fetched some data and passed it to a controller as 'productInfo'. While I can successfully load the data, I am encountering issues when trying to target specific valu ...

Changing an array into a list using javascript

function convertArrayToList(inputArray) { let list = null; for (let i = inputArray.length - 1; i >= 0; i--) { list = { value: inputArray[i], rest: list }; } return list; } let result = convertArrayToList([10, 20]); console.log(JSON.stringi ...

Tips for properly documenting varying numbers of parameters in specific scenarios using JSDoc

Is there a way to document in JSDoc that my function only requires the second and third parameters when the first one is not equal to 3? getTimeframe: function(timeframe, since, until) { /* * @param {Number} timeframe Can be 0, 1, 2, or 3 * @param {Nu ...

Struggling to convert my VueJS component from JavaScript to TypeScript, feeling a bit lost

I am new to VueJS and I am facing a challenge converting my VueJS project to use TypeScript. I have been trying to bind functions to certain variables in JavaScript, but I am struggling with accomplishing the same in TypeScript. Even though there are no er ...

Do all descendants consistently trigger rerenders?

Recently, I was exploring the React new documentation here, where I came across this interesting piece of information: The context value mentioned here is a JavaScript object with two properties, one being a function. Whenever MyApp re-renders (for examp ...

If statement utilized for conditional looping

As I dive into the world of basic JavaScript, I'm eager to understand how to loop back to the beginning of a method under specific conditions. Consider this scenario: in order for the program to progress to the statement "The character you typed was, ...

Clear out all current cookies

I utilized the following JavaScript code to generate a pop-up window on the website that would only appear once. However, my client now wants to launch a new promotion and I am attempting to remove existing cookies so that the pop-up window displays again ...

Manipulating and transforming data through Puppeteer's iterative process into an object structure

As a beginner with the puppetteer library, I'm trying to iterate through Amazon reviews and save each comment as an object. Although my code seems to be functioning, it only retrieves the first comment and then stops. async function scrapeProduct(ur ...

Initiating a GET request to retrieve the file generated by the server

I am currently delving into the Mean stack and have encountered a challenge with downloading a file from my server-side application using the Angular front end. Despite successfully generating the file on the back end, clicking the download button on the f ...

Is the params object sorted by $http in AngularJS?

Currently, I am in the process of writing unit tests for my AngularJS application. In order to perform these tests, I am utilizing the $httpBackend to mock the $http request internally. During the testing phase, I make use of $httpBackend.expectGET to ens ...

Unable to access variables beyond the function scope results in an undefined value

I'm currently working with an npm package that shortens URLs but I'm struggling because there isn't much documentation available. The package takes the "this.src" URL and shortens it, but when I try to use the "url" element in HTML, it retur ...

Error encountered when attempting to retrieve data from an API route using s3, resulting in an uncaught promise with the message "SyntaxError: Unexpected token < in JSON at position 0

I'm attempting to retrieve a JSON file from an S3 bucket. Here is the API route I'm using to fetch the json file: const {GetObjectCommand, S3Client} = require("@aws-sdk/client-s3"); const client = new S3Client() // Add opts to S3 if nee ...

What could be causing my cmd to report an error stating that it is unable to locate the node-modules

https://i.sstatic.net/4ztfB.png Take a look at my command prompt below. Do I need to keep the module folder and the code folder in the same directory? ...

Retrieving data for a route resolver involves sending HTTP requests, where the outcome of the second request is contingent upon the response from the first request

In my routing module, I have a resolver implemented like this: { path: 'path1', component: FirstComponent, resolve: { allOrders: DataResolver } } Within the resolve function of DataResolver, the following logic exists: re ...

Retrieving a JavaScript variable from a Python Selenium request

Currently, I am utilizing Python in conjunction with Selenium to monitor changes on our pbx system. A specific value that I require is being retrieved through a JavaScript call and unfortunately, it is not directly written into the HTML code. This has made ...

Enhancing Your Model with Additional Details using Angular Formly

I have been utilizing Angular Formly to display forms generated from the JSON response received from services. However, I have a few inquiries. Is it feasible to retrieve data in a field (templateOptions.label, for instance) to include in the model? ...

What is the process for converting a file to base64 encoding, and then uploading it as a multipart file to a backend API using JavaScript

I am working on a project to create a micro-service that can receive base64 encoded data. However, when attempting to send more than 6 MB of data, I encountered the following error message: The multi-part request contains parameterized data (excluding ...

What is the best way to immediately update the state in a React functional component?

Having recently started learning React, I find myself struggling to understand the lifecycle of a functional component. Let's consider a scenario where I have multiple checkboxes labeled as: checkbox, a, b, c, and d, each corresponding to values a, b, ...