Antlr interest
   6 tags on

0 answers

How to define a token which is all those characters in set A, except those in sub-set B?

In RFC2616 (HTTP/1.1) the definition of a 'token' in section '2.2 Basic Rules' is given as: token = 1*<any CHAR except CTLs or separators> From that section, I've got the following ...

1 answer

Allow invalid input in Lexer or Push to Parser?

I'm using Antlr4 to build a parser and I have an implementation question. I've seen a number of grammars which have a default lexer rule which will match any character at the end. I've also seen ...

1 answers | 3 hours ago by Rossco on Stack Overflow stackoverflow.com
1 answer

ANTLR4 parse tree viewer in Eclipse

Trying to view specific portions of the parse tree inside of methods generated by ANTLR4 inside Eclipse Kepler Release. For instance ANTLR generates an 'enter/exit' method for a grammar rule created ...

1 answers | 9 hours ago by TomasTourikis on Stack Overflow stackoverflow.com
0 answers

How to show a JDialog of a parser tree in antlr4.5.1?

As mentioned above, I want the system to pop up a dialog to show the parser tree. I want to know if there is a function to invoke in java so I can do the thing above and I know at version 4.3 antlr ...

1 answer

ANTLR 4 casting operator takes too much

I'm making a language and I'm having a little trouble with implementing casting in the grammer. The syntax for casting is on line 61 of the grammer file. Currently it will take something like (Int) ...

1 answers | 2 days ago by EnderShadow on Stack Overflow stackoverflow.com
0 answers

ANTLR4: parsing an email header, lookahead not working, Python target

I am trying to parse this portion of an email header: Received: from server.mymailhost.com (mail.mymailhost.com [126.43.75.123]) by pilot01.cl.msu.edu (8.10.2/8.10.2) with ESMTP id NAA23597;Fri, 12 ...

1 answer

In Python2.7 ANTLR4, extract tokens from a parser rule and store them in a list

In my grammar I validate boolean expressions that look something like this: ((foo == true) && (bar != false) || (qux == norf)) I obtain the string from ANTLR4's context object by calling ...

2 answers

ANTLR ID gets mixed with lexer rule

I have been working on a grammar for a long time but now when I'm trying it out on a big code base I get this annoying problem. When I'm trying to parse an ID, for example "INDEX", and I have another ...

3 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

Python 2.7 & ANTLR4 : Make ANTLR throw exceptions on invalid input

I want to catch errors like line 1:1 extraneous input '\r\n' expecting {':', '/',} line 1:1 mismatched input 'Vaasje' expecting 'Tafel' I tried wrapping my functions in try-catch but, as expected, ...

0 answers

How to change Hive parser to allow default value for columns?

I am trying to update the parser to allow default value in column definition. I have changed this in the grammar file: columnNameType @init { pushMsg("column specification", state); } @after { ...

1 answer

ANTLR grammar is giving unexpected results

This is very simple. I'm in the process of learning ANTLR4 by inventing a grammar that can recognize a single word. But why isn't it matching my name? It's printing out [ ]. I am using Antlr 4 ...

1 answers | Aug 25 at 20:54 by Amy on Stack Overflow stackoverflow.com
0 answers

Antlr 4 parser rules, why is output of 'grun' influenced by unrelated rules?

I define the following silly grammar, for testing purposes: grammar Test; x: ab 'b' ab EOF; y: ab+ EOF; ab: 'a' 'b'?; I execute it as follows: $ rm -f Test*.[^g]*; antlr Test.g && javac ...

Aug 24 at 20:47 by doublep on Stack Overflow stackoverflow.com
1 answer

antlr return values as key-value

I want to parse the sentence "i am looking for a java developer from india". The output i need is language=java and place=india I created a grammar file as follows. grammar Job; eval returns ...

1 answer

Recursive rule in ANTLR

I need an idea how to express a statement like the following: Int<Double<Float>> So, in an abstract form we should have: 1.(easiest case): a<b> 2. case: a<a<b>> 3. ...

1 answers | Aug 24 at 14:34 by user3097712 on Stack Overflow stackoverflow.com
1 answer

Disambiguating unary and binary minus in antlr4 grammar

I am creating an antlr4 grammar for a moderately simple language. I am struggling to get the grammar to differentiate between unary and binary minus. I have read all the other posts that I can find on ...

1 answers | Aug 24 at 6:54 by Cope on Stack Overflow stackoverflow.com
1 answer

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: antlr-test.py from antlr4 import * # from ...

1 answers | Aug 22 at 0:55 by Diarmaid on Stack Overflow stackoverflow.com
4 answers

ANTLR: Get token name?

I've got a grammar rule, OR : '|'; But when I print the AST using, public static void Preorder(ITree tree, int depth) { if (tree == null) { return; } for (int i = 0; i ...

4 answers | Aug 21 at 18:30 by Mark on Stack Overflow stackoverflow.com
1 answer

Simple ANTLR Preprocessor

I am trying to create a simple preprocessor in ANTLR. My grammar looks like this: grammar simple_preprocessor; ifdef_statement : POUND_IFDEF IDENTIFIER ; else_statement : POUND_ELSE ; ...

1 answers | Aug 21 at 5:42 by RedTailedHawk on Stack Overflow stackoverflow.com
1 answer

How to use lexer predicates to test against list of names?

I have an AvailableCommands hash-set member. It's loaded with names before lexing/parsing starts from external source. How can I check if current CMD token exists in the set? Something like: CMD : ...

1 answers | Aug 20 at 19:44 by Tal on Stack Overflow stackoverflow.com
1 answer

antlr4 for parsing a method body

I am trying to parse a specific method body by employing the grammar provided here Java Grammar. I tweaked the grammar a bit by modifying the starting parse rule (i.e compilationUnit) to also include ...

1 answers | Aug 20 at 18:00 by user1577269 on Stack Overflow stackoverflow.com
1 answer

Using ANTLR grammar based parser in SonarQube plugin to create new language support

We're planning on adding Fortran language support to SonarQube by creating a SonarQube Fortran plugin. We already have an existing ANTLR grammar and generated parser for the Fortran language. Can we ...

1 answers | Aug 20 at 16:05 by the_jov on Stack Overflow stackoverflow.com
0 answers

Integrating antlr4 with LLVM

I am developing a compiler using ANTLR and LLVM. I have already implemented a lexer and a parser using ANTLR 4's Eclipse IDE. I want to implement a semantic analyzer and a code generator using LLVM. ...

0 answers

ANTLR4 - dynamically expression of list elements

assume that I have the case where I want to express something like: List{1,2,3} So, I have a list with integer values as elements. When I want to give a grammar, I would write a rule which covers ...

0 answers

Shorten the file overhead (Place tokens in a new class?)

I have a project that parses SQL statements using Antlr3. I've implemented about 90% of all statements (PL/SQL too) and it works really well! My only problem is that I need about 2.5GB alone to ...

1 answer

Use ANTLR4 to get a method's annotations

I'm writing a short program that scans a Java source file and finds all the methods in it using ANTLR4. For each method, I'd like to check whether it is a test method or not, and I want to do so by ...

1 answers | Aug 19 at 10:31 by mittelmania on Stack Overflow stackoverflow.com
1 answer

Understand antlr4 generated parsercontext code, Find a good way to detect terminalNode in one context

The part of G4 file is : typeSpecifier : ('void' | 'char' | 'short' | 'int' | '__m128d' | '__m128i') | '__extension__' '(' ('__m128' | '__m128d' | '__m128i') ...

1 answers | Aug 18 at 15:28 by jiamo on Stack Overflow stackoverflow.com
1 answer

Antlr4 freeze after upgrade from 4.1 to 4.3

I made a grammar in antlr 4.1. I tried to upgrade to 4.5.1, but freezes. I tested with 4.2 and works well. Then I tried the 4.3 and the freezing began to occur. When I generated the parser and lexer ...

1 answers | Aug 18 at 14:42 by KillerAll on Stack Overflow stackoverflow.com
1 answer

How to tokenize blocks (comments, strings, …) as well as inter-blocks (any char outside blocks)?

I need to tokenize everything that is "outside" any comment, until end of line. For instance: take me */ and me /* but not me! */ I'm in! // I'm not... Tokenized as (STR is the "outside" string, BC ...

1 answers | Aug 18 at 12:25 by Tal on Stack Overflow stackoverflow.com
0 answers

How to left-factor this grammar without loosing parsing alternatives?

I have an Xtext grammar with left-recursion which looks like this (cut down to the relevant part): Object: atomic=ObjectAtomic ((com1+=OBJECTCOMMANDNAMEKEYWORDS_9 arr1+=Array)* | ...

15 30 50 per page
1 2 3