Questions tagged [antlrworks]

ANTLRWorks is a grammar development environment for ANTLR v3 grammars written by Jean Bovet. It combines a grammar-aware editor with an interpreter for rapid prototyping and a language-agnostic debugger for isolating grammar errors.

ANTLRWorks is a grammar development environment for ANTLR v3 grammars written by Jean Bovet (with suggested use cases from Terence Parr). It combines a grammar-aware editor with an interpreter for rapid prototyping and a language-agnostic debugger for isolating grammar errors. ANTLRWorks helps eliminate grammar nondeterminisms, one of the most difficult problems for beginners and experts alike, by highlighting nondeterministic paths in the syntax diagram associated with a grammar. ANTLRWorks' goal is to make grammars more accessible to the average programmer, improve maintainability and readability of grammars by providing grammar navigation and refactoring tools, and address the most common questions and problems encountered by grammar developers:

  • Why is this grammar fragment nondeterministic?
  • Does this rule match a sample input?
  • Why is this grammar improperly matching this complete input?
  • Why is there a syntax error given this input?
  • Why is there no syntax error given this ungrammatical input?

-- http://www.antlr.org/works/index.html

242 questions
38
votes
2 answers

Is "Implicit token definition in parser rule" something to worry about?

I'm creating my first grammar with ANTLR and ANTLRWorks 2. I have mostly finished the grammar itself (it recognizes the code written in the described language and builds correct parse trees), but I haven't started anything beyond that. What worries…
Matěj Zábský
  • 16,909
  • 15
  • 69
  • 114
20
votes
1 answer

When is EOF needed in ANTLR 4?

The TestDriver in ANTLRWorks2 seems kind of finicky about when it'll accept a grammer without and explicit EOF and when it will not. The Hello grammar in the ANTLR4 Getting Started Guide doesn't use EOF anywhere, so I inferred that it's better to…
DaoWen
  • 32,589
  • 6
  • 74
  • 101
16
votes
2 answers

ANTLR not throwing errors on invalid input

I'm using ANTLR to parse logical expressions in a Java tool I'm writing, and I'm having issues because passing invalid input strings to the generated ANTLR lexer and parser doesn't cause any exceptions. Instead of throwing a RecognitionException,…
user550617
10
votes
2 answers

Visualizing an AST created with ANTLR (in a .Net environment)

For a pet project I started to fiddle with ANTLR. After following some tutorials I'm now trying to create the grammar for my very own language and to generate an AST. For now I'm messing around in ANTLRWorks mostly, but now that I have validated…
Benjamin Podszun
  • 9,679
  • 3
  • 34
  • 45
8
votes
4 answers

ANTLR and Eclipse (or any decent IDE)

I have been using ANTLR with Eclipse for some time using the ANTLRv3IDE plugin. While it is not perfect, and a bit outdated, it does its job reasonably well. Now I am looking to switch to ANTLRv4 for another DSL that I am creating. However, Eclipse…
Krumelur
  • 31,081
  • 7
  • 77
  • 119
7
votes
2 answers

"FOLLOW_set_in_"... is undefined in generated parser

I have written a grammar for vaguely Java-like DSL. While there are still some issues with it (it doesn't recognize all the inputs as I would want it to), what concerns me most is that the generated C code is not compilable. I use AntlrWorks 1.5…
Matěj Zábský
  • 16,909
  • 15
  • 69
  • 114
6
votes
2 answers

How to deal with list return values in ANTLR

What is the correct way to solve this problem in ANTLR: I have a simple grammar rule, say for a list with an arbitrary number of elements. list : '[]' | '[' value (COMMA value)* ']' If I wanted to assign a return value for list, and have that…
Ryan
  • 4,179
  • 6
  • 30
  • 31
6
votes
1 answer

The following alternatives can never be reached: 2

I'm trying to create a very simple grammar to learn to use ANTLR but I get the following message: "The following alternatives can never be reached: 2" This is my grammar attempt: grammar Robot; file : command+; command : (…
OscarRyz
  • 196,001
  • 113
  • 385
  • 569
6
votes
1 answer

ANTLR - trouble getting AST hierarchy setup

I am trying to get my head around the tree construction operators (^ and !) in ANTLR. I have a grammar for flex byte arrays (a UINT16 that describe number of bytes in array, followed by that many bytes). I've commented out all of the semantic…
Anssssss
  • 3,087
  • 31
  • 40
6
votes
1 answer

Parsing Newlines, EOF as End-of-Statement Marker with ANTLR3

My question is in regards to running the following grammar in ANTLRWorks: INT :('0'..'9')+; SEMICOLON: ';'; NEWLINE: ('\r\n'|'\n'|'\r'); STMTEND: (SEMICOLON (NEWLINE)*|NEWLINE+); statement : STMTEND | INT STMTEND ; program:…
aliahy
  • 509
  • 6
  • 15
6
votes
3 answers

Does anyone know of a way to debug tree grammars in ANTLRWorks

The recommended pattern for ANTLR usage is to have the Parser construct an Abstract Syntax Tree, and then build Tree walkers (AKA tree grammars) to process them. I'm trying to get to the bottom of why my tree grammar isn't working and would love to…
Mike Cargal
  • 6,610
  • 3
  • 21
  • 27
5
votes
2 answers

Parsing with incomplete grammars

Are there any common solutions how to use incomplete grammars? In my case I just want to detect methods in Delphi (Pascal)-files, that means procedures and functions. The following first attempt is working methods : ( procedure | function…
ANTLRStarter
  • 309
  • 1
  • 4
  • 16
5
votes
2 answers

Is it possible to have a grammar where a "keyword" can also be treated as a "non-keyword"?

I have the following grammar in ANTLRWorks 1.4. I'm playing around with ideas for implementation of a parser in a text-adventure game creator, where the user will specify the various allowable commands for his game. grammar test; parse : …
Rao
  • 892
  • 1
  • 8
  • 20
5
votes
1 answer

What does ^ and ! stand for in ANTLR grammar

I was having difficulty figuring out what does ^ and ! stand for in ANTLR grammar terminology.
ssingh3
  • 125
  • 1
  • 8
5
votes
2 answers

ANTLR "unexpected end of subtree"

Hey. I'm new to ANTLR. ANTLRWorks wizard wrrited for me the following code: grammar test; ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')* ; INT : '0'..'9'+ ; FLOAT : ('0'..'9')+ '.' ('0'..'9')* EXPONENT? | …
Alon Gubkin
  • 56,458
  • 54
  • 195
  • 288
1
2 3
16 17