Antlr interest
   6 tags on

0 answers

Grammar in ANTLR and the selected words

This is my grammar: LET : [a-z] ; cchar : LET | '-' ; word : cchar+ ; // not important part aaa : '#' 'or' word+ '#'; When I parse for example a word: 'test' it works fine. When I parse a ...

1 answer

ANTLR with non-greedy rules

I would like to have the following grammar (part of it): expression : expression 'AND' expression | expression 'OR' expression | StringSequence ; StringSequence : StringCharacters ; fragment ...

1 answer

ANTLR4: Two channels, one for CSV-formatted data, one for key/value-formatted data — does not work

The lexer grammar below contains two sets of rules: (1) rules for tokenizing CSV-formatted input, and (2) rules for tokenizing key/value-formatted input. For (1) I put the tokens on channel(0). For ...

1 answer

Antlr V4 C#/java grammars available?

Are there grammar files (.g4) that are available for C# and Java that i can use directly? If so, are they following certain standards? Thanks, Mostafa

1 answers | 8 hours ago by Hamzawey on Stack Overflow
1 answer

Ambiguous ANTLR parser rule

I have a very simple example text which I want to parse with ANTLR, and yet I'm getting wrong results due to ambiguous definition of the rule. Here is the grammar: grammar SimpleExampleGrammar; ...

1 answers | 10 hours ago by baruchl on Stack Overflow
0 answers

Ignoring leading and tailing quotes in a string literal match

I want to match 'Foo' as Foo, not 'Foo'. I have the following lexer rule: STRING_LITERAL : '\'' ( ~'\'' | '\'\'' )* '\'' ; But it seems to match the quotes. My visitor looks like this: public ...

1 answer

getting line of a literal?

Is there any way of getting the line and position of a _LITERAL_NAMES? For example : constant returns [String typeS, int line, int pos] : sign number {$typeS = "integer"; $line = $number.line; ...

1 answers | 12 hours ago by Damiii on Stack Overflow
0 answers

I want to create google protocol buffer .proto file for the List<String> in the below order class, But unable to do so

How to create .proto file for the Order class. How to represent List<String> in proto file? Please help public class Order { @SuppressWarnings("unused") private int ...

1 answer

Grammar rule for sequence of blocks of digits that increase in length each repetition

I want to generate a parsing rule (using ANTLR 4) that defines a repeating chain of binary blocks separated by ':'. Each block has one digit more than the previous block, starting with two digits. ...

0 answers

Running ANTRL TestRig GUI from within a Java application

I know it's possible to generate a graphical representation of a parse tree using ANTLR's TestRig "grun" through the terminal: $ alias grun='java org.antlr.v4.runtime.misc.TestRig'​​ $ grun Example ...

2 answers

The following set of rules are mutually left-recursive

I'm working with ANTLR4 i get the following error: The following sets of rules are mutually left-recursive [primary_expression, primary_no_array_creation_expression]. Below is the snippet from ...

2 answers | yesterday by Hamzawey on Stack Overflow
0 answers

Regex code in antlr4 showing error

I have written the following lexer rule to check email in antlr4 EMAIL: ...

1 answer

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

How to handle whitespace between tokens in an antlr3 grammar

I have a question about whitespace handling in an antlr3 grammar. Here's a stripped-down version of the grammar: grammar SLiMScript; inputFile : NEWLINE* sectionOutput? ; ...

1 answers | 2 days ago by Ben Haller on Stack Overflow
1 answer

ANTLR C# 4 Grammar - Precedence

I have the grammar below (simplified for demonstration) and I'm having a problem in a particular case related to logical operators. Everything I've test works except the case a logical operator is ...

1 answers | Mar 29 at 0:30 by Jerry Tucker on Stack Overflow
1 answer

Mutual left recursion in type specifier grammar

I'm trying to make a parser rule to recognise type specifiers for my language. This is the rule I have: type: TYPE | type '[' numexpr? ']' | MAP '(' TYPE ',' type ')'; TYPE : ...

1 answers | Mar 28 at 9:26 by Setzer22 on Stack Overflow
0 answers

alternative parsing rules is not recognized by antlr4

My antlr parser rule is not selecting alternative rules. its always considering the first option. ex: if I am trying to use expression to select "profiletype" its selecting xxx every time. ...

0 answers

how to get string character escapes to work in antlr3?

This is a pretty boilerplate grammar, but I can't get it to work. Apologies if it is a duplicate or FAQ; I read quite a few things, at stackoverflow and elsewhere, about doing string escapes in a ...

1 answer

Setup ANTLR 4 grammar to handle Java and C# enviornments

I'm using an ANTLR 4 split grammar both in both C# and Java environments and I am unable to compile the grammar in both languages unless I change the function NotifyErrorListeners to use camel case ...

1 answers | Mar 27 at 20:07 by Daniel Johnson on Stack Overflow
1 answer

ANTLR4: [Modes] Need multiple lexer rules for whitespace?

I am creating a parser for input like this: FirstName, LastName, Street, City, State, ZipCode Mark,, 4460 Stuart Street, Marion Center, PA, 15759 ---- FirstName=John LastName=Smith The data before ...

1 answer

Parsing diferent range integers in Xtext?

I'm new in xText, I installed a couple of days ago and this may look like a simple question but I haven't find a solution yet and I've being looking over Google a lot. Basically I want to define an ...

1 answers | Mar 27 at 0:48 by Marcopolo Ramos on Stack Overflow
1 answer

Xtext: Overriding the quickfix to a Reference

I am attempting to detect whether the right hand side of an assignment is a possible hex value as opposed to another variable reference. so that for example myvariable = 2 a = 4 /* the c reference ...

1 answers | Mar 26 at 22:25 by Har on Stack Overflow
1 answer

C# Antlr4 Maximize Speed

In Java there is this line parser.getInterpreter().setSLL(true); to switch the ANTLR4 parser to SLL(*). What is the equivalent in C#? Thank you in advance, Widi

1 answers | Mar 26 at 21:56 by Widi on Stack Overflow
1 answer

Antlr4 add new node to tree

I am working with antlr4 to create a tree from cobol code and my main objective is to add new code by modifying tree. Are there any way to modify or add new nodes to the tree and generate a new cobol ...

1 answers | Mar 26 at 19:35 by Viktor Persson on Stack Overflow
2 answers

Preferentially match shorter token in ANTLR4

I'm currently attempting to write a UCUM parser using ANTLR4. My current approach has involved defining every valid unit and prefix as a token. Here's a very small subset of the defined tokens. I ...

2 answers | Mar 26 at 19:30 by Rook on Stack Overflow
1 answer

How can I Adapt an already built antlr4 Cobol parser into antlr3 interfaces

I have built an antlr v4 grammar for parsing Cobol files. It is tested and fully functional. Now I need to adapt it to be used within a XText project (with unfortunately uses antlrv3). How can I ...

1 answers | Mar 26 at 12:42 by gilcesar on Stack Overflow
1 answer

Convert Hand-Written Parser to ANTLR

I am currently working on a programming language, and for about 9 months I have been using a hand-written lexer and parser. What I am now trying to do is to convert this to an ANTLR parser. The ...

1 answers | Mar 25 at 6:32 by Clashsoft on Stack Overflow
2 answers

how to handling nested comments in antlr lexer

How to handle nested comments in antlr4 lexer? ie I need to count the number of "/*" inside this token and close only after the same number of "*/" have been received. As an example, the D language ...

2 answers | Mar 25 at 3:58 by Rog on Stack Overflow
0 answers

no viable alternative at input antlr

I have to do a lexer and a parser for Python using ANTLR, but when I run with this input: print 99 appears this error: "no viable alternative at input print99". Why puts all together?? I really ...

0 answers

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

15 30 50 per page
1 2 3