Antlr interest
   6 tags on

0 answers

ANTLR4 - Is it possible to store a variable of a certain data type within a matched rule?

I would like to somehow store a variable of a pre-determined type (or even an Object) within the matched rule, much like in GNU Bison, where you would define the type that each rule has and therefore ...

1 answer

ANTLR4 comparing syntax trees

How can I compare two java source code generated AST's in ANTLR4? I have already tried to walk the trees using JavaBaseVisitor and JavaBaseListener, but I can't seem to get what I need from the tree. ...

1 answer

ANTLR empty block should be documented

Anyone know of a way of getting rid of the "empty block should be documented" warning in generated files when using ANTLR. I know I can disable the warning in Eclipse but I would like to keep it ...

1 answers | yesterday by Keith Whittingham on Stack Overflow
0 answers

Running methods generated by AntLR 4 grammar

I found a project [GitHub] to parse the natural date string and show the appropriate Date value. I wanted to modify the grammar according to my need and I did to some extent. But when I tried to run ...

2 answers

ANTLR4: lexer rule for: Any string as long as it doesn't contain these two side-by-side characters?

Is there any way to express this in ANTLR4: Any string as long as it doesn't contain the asterisk immediately followed by a forward slash? This doesn't work: (~'*/')* as ANTRL throws this ...

1 answer

No method prog() to build a ParseTree object

I experience issues with ANTLR 4, using the visitor classes. I try to write the following code: import bla.gen.InputLexer; import bla.gen.InputParser; import org.antlr.v4.runtime.ANTLRFileStream; ...

1 answers | yesterday by Adri on Stack Overflow
1 answer

ANTLR4 - Syntax error on '#' (alternative rule label)

I have made a grammar that will be used with ANTLR4 with the following definition for expressions: // Expressions Expr : Integer # Expr_Integer | Float # Expr_Float ...

1 answers | yesterday by SamTebbs33 on Stack Overflow
3 answers

Making some parser rules case-insensitive in antlr

I am wrting a small csharp console application which reads text from console, do some some manipulations and returns a string. For this, I am using Antlr. The grammar file is shown below. ...

3 answers | yesterday by Sravan on Stack Overflow
2 answers

Code a term-rewriting parser/expression evaluator with ANTLR (or any other tool)

I'm trying to code a software which should execute instructions of a basic programming language only with these capabilities: Arithmetic expression evaluator (add,minus,mult,divide,parenthesis,...) ...

1 answer

setup problems with ANTLRworks 2.4.1 and 1.5.2

I haven't had any luck getting the ANTLRworks plug-ins to work. So this question is an attempt to update the ANTLRworks setup procedures and, as I say at the end, I'm willing to provide pull requests ...

1 answers | 2 days ago by highpost on Stack Overflow
1 answer

Adding an Antlr4 parse tree to another Antlr4 parse tree

I need to implement generics with Antlr4. In order to do this, I need to be able to take a class and, as it is used, dynamically generate code for it like a macro, tokenize that code, generate a tree, ...

1 answers | Apr 15 at 4:41 by nestharus on Stack Overflow
2 answers

How to generate multiple parse trees for ambiguous input in ANTLR

I'm facing an ambiguous case where the input string could be parsed using different rules, I need to consider both options and generate multiple parse trees for them. For simplicity, considering a ...

2 answers | Apr 14 at 14:37 by vanilla on Stack Overflow
0 answers

ANTLR4 grammar token recognition error after import

I am using a parser grammar and a lexer grammar for antlr4 from GitHub to parse PHP in Python3. When I use these grammars directly my PoC code works: from antlr4 import * # from ...

1 answer

How to get the java Class to which a method belongs given the method signature?

I am using ANTLR on the Java8 grammar to parse some Android code, and I'm searching for method invocations having the signature abortBroadcast(). However, I need to check if abortBroadcast() is the ...

0 answers

ANTLRWorks undefined import error

I have ANTLRWorks 1.5.2. I need to resolve Decision can match input using multiple alternative warnings in my one grammar file which imports another file. parser grammar PL; import SQL; I ...

1 answer

Use Visitor or Listener with ANTLR4 when returning objects of different types

I translate one language into another with ANTLR4. For example when I read numerical literals I can return an Integer or Double. @Override public Integer visitIntegerValue(Parser.IntegerValueContext ...

1 answers | Apr 14 at 9:55 by vasily on Stack Overflow
0 answers

Generate code from antlr tokens

We are currently working on trying to generate a new code using antlr. We have a grammar file that pretty much can recognize everything. Now, our problem is that we want to be able to create code ...

1 answer

Antlr prediction analysis

I have a SQL-like grammar written in Antlr, and I'm having problems with the IN operator. A sample query/input (without an IN clause) would look like select sum(sum(sum.........N)) from table where ...

1 answers | Apr 13 at 22:34 by Pranav Kevadiya on Stack Overflow
1 answer

TestRig in Eclipse with ANTLR4 IDE for Eclipse

I have installed ANTLR 4 IDE for Eclipse in my Eclipse software. I want to test the grammar directly from Eclipse by using TestRig found in antlr-4*.jar file. I found this way of testing the antlr4 ...

1 answers | Apr 13 at 15:59 by CPJ on Stack Overflow
1 answer

ANTLR 4: Avoid error printing to console

With ANTLR I parse a grammar. The ANTLR errors are indicated in a custom editor for the grammar. However I would like to disable the printing of error messages to a Java console. I've implemented my ...

1 answers | Apr 13 at 15:32 by Marcel on Stack Overflow
1 answer

How do I diagnose ambiguities in my ANTLR4 grammar?

Short version: I am using parser.addErrorListener(new DiagnosticErrorListener()); parser.getInterpreter().setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION); But when I run my parser I ...

1 answers | Apr 13 at 15:22 by jonr on Stack Overflow
1 answer

mismatched input in antlr generated parser

I have a short ANTLR grammar: query : word (WS word)+; word : simpleword | compoundword; compoundword : simpleword (NONWORD+ simpleword)+ | NONWORD+ simpleword (NONWORD+ simpleword)* NONWORD*; ...

1 answers | Apr 13 at 7:00 by Tomasz Grobelny on Stack Overflow
1 answer

ANTLR4 sending a null context attribute to listener

I'm creating a simple language compiler, and I'm facing an unexpected behavior. I simplified the grammar as follows: grammar Language; program : (varDecl)* (funcDecl)* EOF; varDecl : ...

1 answers | Apr 12 at 17:28 by Daniel Castro on Stack Overflow
1 answer

Parsing simple template with Antlr4

I'm trying to parse expressions like he did [something called :action], where action is a variable and the brackets imply that the block is optional. If one of the variables inside the brackets is ...

1 answers | Apr 12 at 7:26 by Boyolame on Stack Overflow
0 answers

ANTLR4: no viable alternative at input error

Im using a cut down version of a pascal grammar to create a compiler which converts pascal to javascript, however i keep running into this error line 3:4 no viable alternative at input 'PROCEDURE' ...

1 answer

Format output of jasmin with ANTLR in java

int addr = gen_address(); $code.addr = addr; $code.append( ldc(44), istore(addr), "getstatic java/lang/System/out ...

1 answers | Apr 11 at 11:11 by boudi on Stack Overflow
2 answers

How to handle ambiguous token in grammar rule in ANTLR?

I have the following grammar for parsing person name after normalizing it. exp : fullName EOF; fullName : title? f=name m=name? l=name; title: TITLE; name : NAME; TITLE : 'mr'| 'mrs' | 'ms'; NAME ...

2 answers | Apr 10 at 20:37 by vanilla on Stack Overflow
0 answers

Can ANTLR4 plugin for Intellj support lexer debug?

Can ANTLR4 plugin for intellj support to run lexer using -token options? I only find the parse tree but there is no output of token analysis results. Thanks!

1 answer

What's the easiest way to distinguish different input types based on your Antlr grammar?

In my grammar I have rules as below: set_stmt :SET ID (DOT ID)? TO setExpr NEWLINE+ ; setExpr : arithExpr | ID (DOT ID)? | STRINGLITERAL ; For the different input types as below, set id to id ...

1 answers | Apr 10 at 6:26 by msn on Stack Overflow
2 answers

Ignoring whitespace (in certain parts) in Antlr4

I am not so familiar with antlr. I am using version 4 and I have a grammar where whitespace is not important in some parts (but it might be in others, or rather its luck). So say we have the ...

15 30 50 per page
1 2 3