Questions tagged [antlr3]

Version 3 of ANTLR (ANother Tool for Language Recognition) created and written by Dr. Terrence Parr

Version 3 of ANTLR.

What is ANTLR?

"ANTLR, ANother Tool for Language Recognition, is a language tool that provides a framework for constructing recognizers, interpreters, compilers, and translators from grammatical descriptions containing actions in a variety of target languages. ANTLR provides excellent support for tree construction, tree walking, translation, error recovery, and error reporting. ..." -- http://www.antlr.org

Updated links

On January 24th 2013, the www.antlr.org address was changed from pointing at site for ANTLR version 3 (www.antlr3.org) to ANTLR version 4 (www.antlr4.org). So questions and answers that used www.antlr.org were correct for ANTLR 3.x before this date. The links should be updated to www.antlr3.org for ANTLR 3.x or www.antlr4.org for ATNLR 4.x.

Useful ANTLR links

Examples and/or useful posts on SO

Related links

Code at Git

Related tags

911 questions
-1
votes
2 answers

ASN.1/SMI comment syntax on ANTLR 3

On ANTLR 2, the comment syntax is like this, // Single-line comments SL_COMMENT : (options {warnWhenFollowAmbig=false;} : '--'( { LA(2)!='-' }? '-' | ~('-'|'\n'|'\r'))* ( (('\r')? '\n') { newline(); }| '--') ) …
Lex Li
  • 60,503
  • 9
  • 116
  • 147
-1
votes
1 answer

ANTLR Matching all tokens except

Is there any way to match a token in antlr except a specific one? I have a rule which states that a '_' can be an ID. Now I have a specific situation in which I want to match an ID, but in this particular case I want it to ignore the '_'…
halfwarp
  • 1,780
  • 5
  • 24
  • 41
-1
votes
1 answer

How to change token type in parser rule in ANTLR using CSharp3 language

I am using ANTLR 3.3 with langage CSharp3. In my token types, I have a tokens called WORD, UTTAR, PRADESH, UPABBR among others. I also have a rule as follows specialSynonym5 : (UTTAR PRADESH)=>a=UTTAR b=PRADESH -> ^(SpecialSynonymNode…
Puneet
  • 472
  • 3
  • 14
-1
votes
1 answer

Antlr3 behaves differently in 2 different rules when the rule's intent is effectively same

While working with Antlr3 grammar, I have come across a situation when the rule's intent is effectively same but behaves differently. I have created a small example- I want to parse a qualified object name which may be 3-part or 2-part or…
asthac
  • 31
  • 8
-1
votes
1 answer

Java: Code too large for Oracle's javac is not so for Eclipse

I have an Antlr3-generated Java lexer/parser for this MySQL grammar. Eclipse Neon can compile the above lexer/parser just fine. The resulting program too runs just fine. However, the Oracle Java 8 compiler gives a 'code too large' error for the same…
Harry
  • 3,684
  • 6
  • 39
  • 48
-1
votes
2 answers

Antlr3 - Non Greedy Double Quoted String with Escaped Double Quote

The following Antlr3 Grammar file doesn't cater for escaped double quotes as part of the STRING lexer rule. Any ideas why? Expressions working: \"hello\" ref(\"hello\",\"hello\") Expressions NOT working: \"h\"e\"l\"l\"o\" ref(\"hello\",…
user550241
-1
votes
1 answer

ANTLR 3 - Can I use it in other way around?

I have in my hands a Java project that has a parser for some language. And it works very nice to read and parse. But I would like to know if using ANTLR I can also get the other way around, like given a the Java Object go to the string…
Arruda
  • 862
  • 1
  • 12
  • 24
-1
votes
2 answers

ANTLR: Lexer Throwing NoViableAltException

After a break of a few weeks, it's time to fight with ANTLR again... Anyhow, I have the following Lexer tokens defined: fragment EQ: '='; fragment NE: '<>'; BOOLEAN_FIELD : ('ISTRAINED'|'ISCITIZEN') ; BOOLEAN_CONSTANT :…
Jason
  • 3,943
  • 12
  • 64
  • 104
-1
votes
1 answer

How to use ANTLR3 lexer only, without parser?

I need to use lexer only in ANTLR3, i don't need parser. How can i do it ? I use the following code (in main.c), which i found somehwere in the internet. #include #include int ANTLR3_CDECL main (int argc, char…
-2
votes
0 answers

Why is alternative of an integer to a letter not done?

I'm new to ANRL3 and I'm trying to parse hello. world 123. one two. using the grammar INT: '0'..'9'+ ; WORD: 'a'..'z'+ ; SENTENCE: ('a'..'z') ('a'..'z'|' ')+ ('a'..'z'); NEWLINE: '\n' ; expression : WORD '.' NEWLINE WORD ' ' INT '. ' SENTENCE…
byerun
  • 1
-2
votes
2 answers

ANTLR grammar conversion

I have C++ grammar file(EX:CPP_grammar.g), which when fed to ANTLR------two files will generate like CPPParser and CPPLexer,this is how ANTLR works.But my question is----- Is there any way that I can do changes in C++ grammar so that I get Java…
Abhid
  • 1
  • 2
1 2 3
60
61