[il-antlr-interest: 35034] [antlr-interest] Use of the range operator inside parser rules

2011-11-27 Thread Bart Kiers
Hi all, I seem to remember that the `..` operator inside parser rules matches token ranges. For example: grammar T; parse : A..C; A : 'a'; X : 'x'; C : 'c'; D : 'd'; The `parse` rule would match the tokens A, X or C. (Needless to say, I'd never use it in this way, but I thought it was

[il-antlr-interest: 35027] Re: [antlr-interest] Possible bug with backtrack-generated predicate methods

2011-11-26 Thread Bart Kiers
Hi Franck, On Sat, Nov 26, 2011 at 8:54 AM, franck102 franck...@yahoo.com wrote: The grammar below won't compile, this looks like a bug to me? ... No bug, syntactic predicates and rule parameters can't be mixed. You can use rule scopes instead: - grammar

[il-antlr-interest: 35029] Re: [antlr-interest] Possible bug with backtrack-generated predicate methods

2011-11-26 Thread Bart Kiers
On Sat, Nov 26, 2011 at 9:58 AM, franck102 franck...@yahoo.com wrote: In fact the tree has been constructed by the leading (ID-ID), That tree only exists inside your parenthesis, AFAIK. You can't reference it outside it (well, you can, but it will be `null`). So here is exactly what I am

[il-antlr-interest: 35021] Re: [antlr-interest] Matching compound keywords in the lexer

2011-11-25 Thread Bart Kiers
Hi Franck, On Fri, Nov 25, 2011 at 9:47 PM, franck102 franck...@yahoo.com wrote: ... containOperator : CONTAINS_TEXT | CONTAINS_MATCH CONTAINS_TEXT : 'contains' WS+ ( 'match' { $type=CONTAINS_MATCH } | 'text' ) ; //

[il-antlr-interest: 35022] Re: [antlr-interest] Matching compound keywords in the lexer

2011-11-25 Thread Bart Kiers
On Fri, Nov 25, 2011 at 9:54 PM, Bart Kiers bki...@gmail.com wrote: ... - tokens { CONTAINS_MATCH; } ... CONTAINS_TEXT : 'contains' WS+ ( 'match' CONTAINS_MATCH | 'text' ) ; ... fragment CONTAINS_MATCH

[il-antlr-interest: 35004] Re: [antlr-interest] Eliminate characters in TOKEN

2011-11-23 Thread Bart Kiers
Hi Rampon, On Wed, Nov 23, 2011 at 10:54 AM, Rampon Jerome ramponjer...@yahoo.frwrote: ... it complained on output option to be AST. If I add it in my grammar options if complains and still return error It seems it automatically adds if not there but later on still return error ??? Is

[il-antlr-interest: 35009] Re: [antlr-interest] Lexer error reporting

2011-11-23 Thread Bart Kiers
Hi Bill, On Wed, Nov 23, 2011 at 5:41 PM, Bill Andersen bill.ander...@mac.comwrote: Hi Folks... Been trying to figure out how to shut off default Lexer behavior to print messages to System.err, such as: line 2:4 no viable alternative at character ' ' Instead, I'd like to catch

[il-antlr-interest: 34962] Re: [antlr-interest] Failure to ignore newline

2011-11-18 Thread Bart Kiers
On Fri, Nov 18, 2011 at 7:55 AM, David Riddle da...@mcgilly.com wrote: Hi - This should be a very simple thing - I'm attempting to have my grammar hide newline, carriage returns, etc. However, every concievable form of a grammar that attempts to skip over these things or send them to the

[il-antlr-interest: 34964] Re: [antlr-interest] String concatenation expression rule

2011-11-18 Thread Bart Kiers
On Fri, Nov 18, 2011 at 12:39 PM, franck102 franck...@yahoo.com wrote: I am writing a grammar for a fairly complex expression language, and in particular I need to support string concatenation which is performed simply by separating string literals with a space; and which automatically

[il-antlr-interest: 34967] Re: [antlr-interest] Failure to ignore newline

2011-11-18 Thread Bart Kiers
On Fri, Nov 18, 2011 at 4:01 PM, David Riddle da...@mcgilly.com wrote: Hi Bart - Yes, it's a \n, and I thought I told the grammar to set '\n' to a hidden channel. So, why is it not hidden? Assuming you mean a new line char, then it _is_ being sent to the HIDDEN channel as Norman already

[il-antlr-interest: 34937] Re: [antlr-interest] valid grammar does not compile

2011-11-17 Thread Bart Kiers
On Thu, Nov 17, 2011 at 9:14 AM, D. Frej dieter_f...@gmx.net wrote: Hi, I build the following grammar with antlrworks: grammar questionmark; horef :'\?' ('a'..'z') ; antlrworks tells me check grammar succeeded. However, debugging does not works because the generated code

[il-antlr-interest: 34939] Re: [antlr-interest] valid grammar does not compile

2011-11-17 Thread Bart Kiers
On Thu, Nov 17, 2011 at 10:14 AM, D. Frej dieter_f...@gmx.net wrote: and still: the compilation error stays even if I do not quote the question mark Ah, hold on, you're using the `..` (range) operator inside a parser rule (horef). Either create a lexer rule matching '?' 'a'..'z': Horef

[il-antlr-interest: 34916] Re: [antlr-interest] Having trouble with creating a parser for my desired grammar. Running afoul of multiple alternatives warnings

2011-11-16 Thread Bart Kiers
Hi John, On Tue, Nov 15, 2011 at 11:46 PM, John B. Brodie j...@acm.org wrote: Greetings! ... I do not think you want to recognize floating point values in the parser. any tokens you send to the HIDDEN $channel (or skip();) will be silently accepted before and after the '.' of the float.

[il-antlr-interest: 34927] Re: [antlr-interest] Having trouble with creating a parser for my desired grammar. Running afoul of multiple alternatives warnings

2011-11-16 Thread Bart Kiers
Hi, On Wed, Nov 16, 2011 at 8:21 PM, Jarrod Roberson jar...@vertigrated.comwrote: actually thanks to Bart I need the FLOAT rule as a parser rule with the predicate because I want to be able to match But John raises a valid point that I didn't mention: by promoting such a rule to a parser

[il-antlr-interest: 34928] Re: [antlr-interest] Having trouble with creating a parser for my desired grammar. Running afoul of multiple alternatives warnings

2011-11-16 Thread Bart Kiers
On Wed, Nov 16, 2011 at 8:38 PM, Bart Kiers bki...@gmail.com wrote: Hi, On Wed, Nov 16, 2011 at 8:21 PM, Jarrod Roberson jar...@vertigrated.comwrote: actually thanks to Bart I need the FLOAT rule as a parser rule with the predicate because I want to be able to match But John raises

[il-antlr-interest: 34930] Re: [antlr-interest] Having trouble with creating a parser for my desired grammar. Running afoul of multiple alternatives warnings

2011-11-16 Thread Bart Kiers
On Wed, Nov 16, 2011 at 8:45 PM, Jarrod Roberson jar...@vertigrated.comwrote: Or even the input: 123 /* some comments */ . /* more comments */ 5 would be a valid `number`... :) Is there a way to support both a - 1. b - 1.1. in a pure lexer rule then, I didn't think there was? See

[il-antlr-interest: 34871] Re: [antlr-interest] Using range operator (INT .. INT)

2011-11-13 Thread Bart Kiers
On Sun, Nov 13, 2011 at 6:59 PM, Jiwon Seo seoji...@gmail.com wrote: Thanks for the reply! I'm trying to do it without extending lexer since I think my definition of FLOAT should not be a problem with the range operator. But it _is_ a problem if the `..` is preceded by an INT: the

[il-antlr-interest: 34763] Re: [antlr-interest] Empty ifs in Java

2011-11-06 Thread Bart Kiers
Hi Patrick, On Sun, Nov 6, 2011 at 1:40 PM, Patrick Zimmermann patr...@zakweb.dewrote: ... I still think that a scannerless parser might be a better alternative. Are there any good reasons against switching (apart from ANTLR being a great tool in general)? Nope, sorry, I don't have any

[il-antlr-interest: 34766] Re: [antlr-interest] Empty ifs in Java

2011-11-06 Thread Bart Kiers
21:31:40 Bart Kiers wrote: Hi Patrick, On Sun, Nov 6, 2011 at 1:40 PM, Patrick Zimmermann patr...@zakweb.de wrote: ... I still think that a scannerless parser might be a better alternative. Are there any good reasons against switching (apart from ANTLR being a great tool

[il-antlr-interest: 34746] Re: [antlr-interest] Empty ifs in Java

2011-11-05 Thread Bart Kiers
Hi Patrick, The range operator, `..`, only works in lexer rules, not in parser rules as you're doing. Capitalize the `letter` rule to make it a lexer rule: grammar failuretest; start: letter+; Letter: 'A' .. 'B'; // or did you mean 'A'..'Z'? and then try again. Regards, Bart.

[il-antlr-interest: 34748] Re: [antlr-interest] Empty ifs in Java

2011-11-05 Thread Bart Kiers
Hi, On Sat, Nov 5, 2011 at 4:16 PM, Patrick Zimmermann patr...@zakweb.dewrote: Hi, thank you a lot. Using a lexer rule does in fact solve this problem. And now I am already on the next: stripped down to: start : ('{' 'ab' '}')* '{a}'; using input: {ab}{a} Will not list

[il-antlr-interest: 34728] Re: [antlr-interest] about range float and stuff

2011-11-04 Thread Bart Kiers
- boun...@antlr.org] On Behalf Of Bart Kiers Sent: Friday, November 04, 2011 1:48 AM To: Fabien Hermenier Cc: antlr-interest@antlr.org Subject: Re: [antlr-interest] about range float and stuff Hi Fabien, Handling this in the parser will make your life much harder than it has

[il-antlr-interest: 34729] Re: [antlr-interest] about range float and stuff

2011-11-04 Thread Bart Kiers
For what it's worth, I found the Wiki entry I based my suggestion on: http://www.antlr.org/wiki/pages/viewpage.action?pageId=3604497 Regards, Bart. On Fri, Nov 4, 2011 at 3:11 PM, Bart Kiers bki...@gmail.com wrote: You're welcome Fabien, but note that it most likely looks a lot like

[il-antlr-interest: 34730] Re: [antlr-interest] about range float and stuff

2011-11-04 Thread Bart Kiers
without code. I much prefer the solution proposed by Terence in http://www.antlr.org/wiki/pages/viewpage.action?pageId=3604497 (which I based my suggestion on): far less verbose than the first option, IMO. Bart. On Fri, Nov 4, 2011 at 5:59 PM, Bart Kiers bki...@gmail.com wrote: The only wiki-link

[il-antlr-interest: 34733] Re: [antlr-interest] about range float and stuff

2011-11-04 Thread Bart Kiers
like of course (though these are not the same solution), but you should be accurate about the other solutions and take the time to read through them. Jim -Original Message- From: antlr-interest-boun...@antlr.org [mailto:antlr-interest- boun...@antlr.org] On Behalf Of Bart Kiers

[il-antlr-interest: 34734] Re: [antlr-interest] about range float and stuff

2011-11-04 Thread Bart Kiers
. On Fri, Nov 4, 2011 at 6:30 PM, Bart Kiers bki...@gmail.com wrote: I only know that Terence's solution solves the OP's problem AFAIK, whereas yours I am not sure of: I simply find it too verbose to fully grasp by only reading through it. Sorry. Bart. On Fri, Nov 4, 2011 at 6:18 PM, Jim Idle

[il-antlr-interest: 34737] Re: [antlr-interest] about range float and stuff

2011-11-04 Thread Bart Kiers
and lots more, which is why it seems verbose. So, I don't know where you are going with the pedantry, but it is not worth my time to follow it any more. Jim -Original Message- From: antlr-interest-boun...@antlr.org [mailto:antlr-interest- boun...@antlr.org] On Behalf Of Bart Kiers

[il-antlr-interest: 34674] Re: [antlr-interest] How to Parse a datastream of tokens and values

2011-10-31 Thread Bart Kiers
Hi David, ANTLR's lexer greedily matches characters: the input PRCLINTON is being tokenized as a single VALUE-token, not as a PR- and VALUE-token. Regards, Bart. On Mon, Oct 31, 2011 at 6:24 PM, Weiler-Thiessen, David, SASKATOON, Engineering david.weiler-thies...@purina.nestle.com wrote: Hi

[il-antlr-interest: 34676] Re: [antlr-interest] How to Parse a datastream of tokens and values

2011-10-31 Thread Bart Kiers
immediately and promptly destroy the material and any accompanying attachments from your system.* *From:* Bart Kiers [mailto:bki...@gmail.com] *Sent:* Monday, October 31, 2011 12:09 PM *To:* Weiler-Thiessen,David,SASKATOON,Engineering *Cc:* antlr-interest@antlr.org *Subject:* Re: [antlr-interest

[il-antlr-interest: 34614] [antlr-interest] Fwd: Fwd: Rule precedence works differently when using a predicate?

2011-10-27 Thread Bart Kiers
Apologies Jim, forgot to send to the list... -- Forwarded message -- From: Bart Kiers bki...@gmail.com Date: Thu, Oct 27, 2011 at 9:21 PM Subject: Re: [antlr-interest] Fwd: Rule precedence works differently when using a predicate? To: Jim Idle j...@temporal-wave.com On Thu, Oct

[il-antlr-interest: 34616] Re: [antlr-interest] Fwd: Rule precedence works differently when using a predicate?

2011-10-27 Thread Bart Kiers
be matched by the ID rule instead of the WHILE rule in: WHILE : 'while'; ID : 'a'..'z'+; (which is not the case, of course!) Regards, Bart. On Thu, Oct 27, 2011 at 10:34 PM, Jim Idle j...@temporal-wave.com wrote: .+ matches forever Jim *From:* Bart Kiers [mailto:bki...@gmail.com] *Sent

[il-antlr-interest: 34532] Re: [antlr-interest] suggestion for the static initializer too big in java

2011-10-24 Thread Bart Kiers
On Mon, Oct 24, 2011 at 10:26 AM, Patrick Ericx patrick.er...@gmail.comwrote: ... PS: is that mailing list available online? how can I access it ? receiving all these mails in my mailbox becomes a little overhead for me. Yes, here it is: http://antlr.markmail.org Regards, Bart. List:

[il-antlr-interest: 34533] [antlr-interest] Rule precedence works differently when using a predicate?

2011-10-24 Thread Bart Kiers
Hi all, As I understand it, ANTLR's lexer matches rules from top to bottom in the .g grammar file and when two rules match the same number of characters, the one that is defined first has precedence over the later one(s). However, take the following grammar: grammar T; @lexer::members {

[il-antlr-interest: 34547] Re: [antlr-interest] False error 208?

2011-10-24 Thread Bart Kiers
On Mon, Oct 24, 2011 at 5:26 PM, Jim Idle j...@temporal-wave.com wrote: Oh – I did not see it was a lexer error. Reorder the rules: IF :'if'; ID :('A'..'Z'|'a'..'z')+; RAW:({rawAhead()}?= . )+; Yeah, that is what I thought as well, but the above will cause

[il-antlr-interest: 34548] Re: [antlr-interest] False error 208?

2011-10-24 Thread Bart Kiers
On Mon, Oct 24, 2011 at 5:33 PM, Bart Kiers bki...@gmail.com wrote: ... where I (and Boon) ... Sorry, Bood, not Boon... List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received

[il-antlr-interest: 34429] Re: [antlr-interest] Lexer grammar for filtering

2011-10-17 Thread Bart Kiers
Hi Balazs, Since PC is not a parser rule, you need to account for the space(s) between 'PC_HASH_VALUE' and DIGIT. And since you've set `filter=true`, you don't need a fall-through rule ELSE, AFAIK. Regards, Bart. On Mon, Oct 17, 2011 at 11:15 AM, Balazs Varnai bvar...@gmail.com wrote: Hi

[il-antlr-interest: 34115] Re: [antlr-interest] Unexpected text

2011-09-22 Thread Bart Kiers
Hi Graham, Inside your parser-grammar, $typeSpec is the object that is returned by the parser rule (RuleReturnScope). It includes, among others, the start- and end-token and the tree of the rule. Using `.text`, which is short for `getText()` will get the source of your input from `start` to `end`

[il-antlr-interest: 34116] Re: [antlr-interest] How to do iteration in Tree Grammar

2011-09-22 Thread Bart Kiers
Hi Yifan, How about something like this: foo: ^(VIRTUAL_NODE (bar {if($bar.value) return;})* ); ? Regards, Bart. 2011/9/22 轶凡 yifan@taobao.com Hi, I defined a tree grammar as below: foo: ^(VIRTUAL_NODE bar*) { echo($bar.value); }; bar returns [boolean value] : //… Omitted

[il-antlr-interest: 34098] Re: [antlr-interest] Parsing CSS accurately and fast

2011-09-19 Thread Bart Kiers
Hi Vivek, On Mon, Sep 19, 2011 at 4:04 AM, Vivek Jhaveri vivekjhav...@hotmail.comwrote: ... To date, our efforts have yielded accuracy, but not performance. Hard to comment without seeing the grammar(s). Do you by any chance have `backtrack=true;` in the options-section of your parser? If

[il-antlr-interest: 33903] Re: [antlr-interest] new Tree interfaces

2011-09-05 Thread Bart Kiers
Hi Ter, others, Perhaps generics could be introduced in v4? public interface TreeT { TreeT getParent(); T getPayload(); TreeT getChild(int i); int getChildCount(); String toStringTree(); } Regards, Bart On Sun, Sep 4, 2011 at 11:47 PM, Terence Parr

[il-antlr-interest: 33886] Re: [antlr-interest] org.antlr.runtime.Parser.getMissingSymbol (Line 70) throws NullPointerException

2011-09-02 Thread Bart Kiers
Hi, On Fri, Sep 2, 2011 at 1:51 AM, Dejas Ninethousand dejas9...@gmail.comwrote: For this grammar with an empty string input: grammar PySON; ... I think you forgot to ask your question. Regards, Bart. List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe:

[il-antlr-interest: 33817] Re: [antlr-interest] FEN grammar

2011-08-29 Thread Bart Kiers
On Sun, Aug 28, 2011 at 11:36 PM, Bart Kiers bki...@gmail.com wrote: ... Fragment rules are only for other *fragment* rules: the parser has no notion of them. ... Correction, I meant to say: *Fragment rules are only for other lexer rule**s ...* Note that you can also call a fragment from

[il-antlr-interest: 33806] Re: [antlr-interest] Match token {n} times

2011-08-28 Thread Bart Kiers
Hi Jonne, No, that is not possible with a quantifier like {x}. You'll have to do it the hard way: ACCOUNT : NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ; Regards, Bart. On Sun, Aug 28, 2011 at 3:20 PM, Jonne Zutt jonne.zutt...@gmail.com wrote: Dear all, Is it possible

[il-antlr-interest: 33809] Re: [antlr-interest] FEN grammar

2011-08-28 Thread Bart Kiers
Hi Jonne, *On Sun, Aug 28, 2011 at 10:26 PM, Jonne Zutt jonne.zutt...@gmail.com wrote: * *... pieces : ('p'|'P' | 'n'|'N' | 'b'|'B' | 'r'|'R' | 'q'|'Q' | 'k'|'K' | '1'..'8')+; * In parser rules, you _can_ use literal tokens, but it's best to refrain from doing this: create

[il-antlr-interest: 33810] Re: [antlr-interest] FEN grammar

2011-08-28 Thread Bart Kiers
Hi Jonne, After skimming through the Wiki page you mentioned, I realize what you mean by overlap. Then no, making fragments will not help you since you will only know at parse-time if a digit should be a part of a `number` or a `rank` or a `move`. Fragment rules are only for other fragment rules:

[il-antlr-interest: 33791] Re: [antlr-interest] Problem with AST rewrite and variable

2011-08-26 Thread Bart Kiers
On Fri, Aug 26, 2011 at 1:40 PM, Adam Adamski thebigsma...@gmail.comwrote: Dear all ANTLR users, Hi Adam, Is it a mistake to use variable like I used? I mean: rule: IDN typ=(type1|type2|typ3) ; Yes, you can't do that. Try this instead: rule : (ARRAY_OF)* intermediate

[il-antlr-interest: 33769] Re: [antlr-interest] Rewriting an AST with the same type listed twice

2011-08-25 Thread Bart Kiers
Hi Garry, You either use inline operators ^ and !, or use a rewrite rule, not both. To reference a rule, add a $ before its label: mapType : 'map' '' k=anyType ',' v=anyType '' - ^('map' $k $v) ; but I think this should work too: mapType : 'map' '' anyType ',' anyType '' - ^('map'

[il-antlr-interest: 33715] Re: [antlr-interest] ignoring the rest of the file other than the rules defined

2011-08-23 Thread Bart Kiers
Could you post your grammar(s) and actual input? Example input containing is not really helpful. Regards, Bart. On Mon, Aug 22, 2011 at 1:27 PM, Swathi V swat...@zinniasystems.com wrote: Would be thankful if anyone helps me out. Problem : I have a huge file with certain categories

[il-antlr-interest: 33645] Re: [antlr-interest] iniFile grammer

2011-08-17 Thread Bart Kiers
Hi Романов, How about something like this: grammar INIFile; parse : Comment* section+ EOF ; section : SectionStart (property | Comment)* ; property : NameOrValue (Assign valueList?)? eol ; valueList : (Separator | NameOrValue)+ ; eol : LineBreak | Comment | EOF

[il-antlr-interest: 33495] Re: [antlr-interest] Line oriented parsing with Unix files on Windows machine

2011-08-04 Thread Bart Kiers
Hi Todd, Well, `EOL : ('\r' | '\n')+;` matches a single `\n`. So my guess is that some other rule in your grammar matches a `\n` as well. Can you post a complete (small) grammar that shows the problem you're having? Regards, Bart. On Thu, Aug 4, 2011 at 8:37 PM, Stevenson, Todd (GE

[il-antlr-interest: 33356] Re: [antlr-interest] Cannot match strings combining terminals w/o spaces between

2011-07-27 Thread Bart Kiers
Hi Samuel, Your input: history: is not tokenized as a STRING but as a WORD. You need to tell exclude the double quote in your WORD rule. Also, you put '\n' on the HIDDEN channel, yet you use it in your parser rule 'command'. This will cause the rule to never match properly: you need to

[il-antlr-interest: 33367] Re: [antlr-interest] Whitespace in identifiers

2011-07-27 Thread Bart Kiers
FYI: http://stackoverflow.com/questions/6847971/antlr-identifier-with-whitespace On Wed, Jul 27, 2011 at 7:39 PM, Lukas Glowania lukas.glowa...@rub.dewrote: Hi, i want identifiers that can contain whitespace. |grammar WhitespaceInSymbols; premise : ( options {greedy=false;} : 'IF' )

[il-antlr-interest: 33369] Re: [antlr-interest] Quoted String Literal - confused by greed=false behavior.

2011-07-27 Thread Bart Kiers
And by default, greedy=true (except with .* and .+), so in this case, one could simply write STRING_LITERAL : '' ('' | ~'')* '' ; AFAIK. Regards, Bart. On Wed, Jul 27, 2011 at 9:54 PM, Sam Harwell sharw...@pixelminegames.comwrote: You're reading the greedy option in reverse. :) I'd

[il-antlr-interest: 33373] Re: [antlr-interest] Quoted String Literal - confused by greed=false behavior.

2011-07-27 Thread Bart Kiers
On Wed, Jul 27, 2011 at 10:06 PM, G. Richard Bellamy rbell...@pteradigm.com wrote: Thanks to both of you for your help. Clearly I understated things when I said I was confused. 1. I was under the impression that greedy=true was the default, in every case. For instance, in The Definitive

[il-antlr-interest: 33376] Re: [antlr-interest] Empty Quoted String Literal

2011-07-27 Thread Bart Kiers
Hi Richard, Both ANTLRWorks' debugger, and my Java test rig: import org.antlr.runtime.*; public class Main { public static void main(String[] args) throws Exception { WhitespaceInSymbolsLexer lexer = new WhitespaceInSymbolsLexer(new ANTLRStringStream(\\)); WhitespaceInSymbolsParser

[il-antlr-interest: 33378] Re: [antlr-interest] Empty Quoted String Literal

2011-07-27 Thread Bart Kiers
of non-escaped quotes... (C# Verbatim String), so you'll not be able to test this on your end (since Java doesn't have an equivalent to the Verbatim String). Thanks again. -rb On 7/27/2011 2:10 PM, Bart Kiers wrote: Hi Richard, Both ANTLRWorks' debugger, and my Java test rig

[il-antlr-interest: 33380] Re: [antlr-interest] Empty Quoted String Literal

2011-07-27 Thread Bart Kiers
A quick test with Mono confirmed it, @ is just a single quote: Console.WriteLine(@); prints 1 quote! That's the problem. Bart. On Wed, Jul 27, 2011 at 11:25 PM, Bart Kiers bki...@gmail.com wrote: Richard, Note that I am a C# illiterate, but, isn't the C# literal: @ only just

[il-antlr-interest: 33338] Re: [antlr-interest] Is it possible to do rewriting for lexer?

2011-07-26 Thread Bart Kiers
But you'd have to have a good reason to use a string literal as a parser rule instead of a lexer rule. Bart. On Tue, Jul 26, 2011 at 9:16 AM, Rob Aarnts r...@aarnts.com wrote: You're entirely right. I use this trick but with a parser rule in stead of a lexer one. So SINGLE_QUOTED_STRING

[il-antlr-interest: 33319] Re: [antlr-interest] Is it possible to do rewriting for lexer?

2011-07-24 Thread Bart Kiers
Hi Qiao, With Java as the target, you could do: SINGLE_QUOTED_STRING @after { String s = getText(); setText(s.substring(1, s.length() - 1)); } : SQUOTE (~SQUOTE)* SQUOTE ; Regards, Bart. On Sun, Jul 24, 2011 at 2:43 PM, Mu Qiao qiao...@gmail.com wrote: I have some token rules

[il-antlr-interest: 33278] Re: [antlr-interest] Left recursive grammar

2011-07-21 Thread Bart Kiers
Hi Luigi, I'm not sure if this is possible with ANTLR, or any other LL parser generator. See this for a work-around: http://stackoverflow.com/questions/3799890/antlr-ast-generating-possible-madness If it _is_ possible using some sort of fancy AST rewrite magic, I'm sure someone will correct me.

[il-antlr-interest: 33280] Re: [antlr-interest] Left recursive grammar

2011-07-21 Thread Bart Kiers
Hi Sam, But of course, with the inline tree rewrite operators it looks so straight forward! Nice one! Regards, Bart. On Thu, Jul 21, 2011 at 3:52 PM, Sam Harwell sharw...@pixelminegames.comwrote: Your example is ambiguous as well as left recursive. I assume you meant one of the following:

[il-antlr-interest: 33170] Re: [antlr-interest] changes between 3.2 and 3.3 that brake a 3.2 tutorial

2011-07-14 Thread Bart Kiers
listing method described in the (very useful !) posts from Bart Kiers about its tutorial with the TL language. My problem is that his method applied on my grammar outputs nothing. I banged my head against my desk for a while for looking what I did wrong with reusing Bart's code, until I tested his

[il-antlr-interest: 33161] Re: [antlr-interest] ANTLR 3.1.2: Simplest action

2011-07-13 Thread Bart Kiers
Try: INTEGER : DIGIT+ { print($text) } ; Regards, Bart. On Wed, Jul 13, 2011 at 9:57 PM, Udo Weik weikeng...@aol.com wrote: Hello, I just want to access the attributes of INTEGER and DIGIT - but how? INTEGER: DIGIT+ { print( L: (INTEGER): ) } ; fragment DIGIT: '0'..'9' {

[il-antlr-interest: 33162] Re: [antlr-interest] ANTLR 3.1.2: Simplest action

2011-07-13 Thread Bart Kiers
Hi Udo, `$text` is just a shorthand notation for `$XYZ.text` where `XYZ` is the rule you're currently in. Regards, Bart. On Wed, Jul 13, 2011 at 10:18 PM, Udo Weik weikeng...@aol.com wrote: Hello Bart and others, yep, thanks, it works... Try: INTEGER : DIGIT+ {

[il-antlr-interest: 33163] Re: [antlr-interest] ANTLR 3.1.2: Simplest action

2011-07-13 Thread Bart Kiers
Oh, and since `DIGIT` is called from `INTEGER`, the `$text` from `DIGIT` references `$INTEGER.text`. Regards, Bart. On Wed, Jul 13, 2011 at 10:18 PM, Udo Weik weikeng...@aol.com wrote: Hello Bart and others, yep, thanks, it works... Try: INTEGER : DIGIT+ { print($text) }

[il-antlr-interest: 33165] Re: [antlr-interest] ANTLR 3.1.2: Simplest action

2011-07-13 Thread Bart Kiers
Hi Udo, Ah yes, apologies: you can only reference parser rules like that: parserRule : LexerRule { print($parserRule.text) } ; and *not*: LexerRule : OtherLexerRule { print($LexerRule.text) } ; Regards, Bart. On Wed, Jul 13, 2011 at 10:27 PM, Udo Weik weikeng...@aol.com wrote: Hello

[il-antlr-interest: 33092] Re: [antlr-interest] @members section in tree grammar

2011-07-10 Thread Bart Kiers
Hi Shane, Inside a combined- or lexer- or parser grammar, the `tokens` should be placed before the `members` section(s): (lexer | parser)? grammar ... options { ... } tokens { ... } @header { ... } (or: @parser::header { ... }, @lexer::header { ... }) @members { ... } (or: @parser::members {

[il-antlr-interest: 33082] Re: [antlr-interest] Parsing Question

2011-07-08 Thread Bart Kiers
Hi Chris, Very original! :) Try to do more in lexer rules. Some of your keywords may probably also be a part of the instruction phrase: you need to be aware of that. How about something like this: grammar KnittingGrammer; parse : instruction+ EOF ; instruction : section FullStop |

[il-antlr-interest: 33033] Re: [antlr-interest] Line start vs non-line ...

2011-07-05 Thread Bart Kiers
Hi James, Something like this would do the trick: lines : (LineStartingWithPlus | LineNotStartingWithPlus | LineBreak)* EOF ; LineStartingWithPlus : '+' ~('\r' | '\n')* ; LineNotStartingWithPlus : ~'+' ~('\r' | '\n')* ; LineBreak : ('\r'? '\n' | '\r') ; Regards, Bart.

[il-antlr-interest: 32989] Re: [antlr-interest] rule parameter question

2011-06-30 Thread Bart Kiers
Hi Mark, I presume you didn't see my answer on Stackoverflow: http://stackoverflow.com/questions/6529359/how-to-pass-commontree-parameter-to-an-antlr-rule ? If you did, is there anything that wasn't clear? Regards, Bart. On Thu, Jun 30, 2011 at 2:26 PM, Mark Truluck

[il-antlr-interest: 32991] Re: [antlr-interest] rule parameter question

2011-06-30 Thread Bart Kiers
– thanks very much. Mark From: Bart Kiers bki...@gmail.com Date: Thu, 30 Jun 2011 14:42:53 +0200 To: Mark Truluck mark.trul...@cogiton.com Cc: antlr-interest@antlr.org interest antlr-interest@antlr.org Subject: Re: [antlr-interest] rule parameter question Hi Mark, I presume you didn't

[il-antlr-interest: 32992] Re: [antlr-interest] rule parameter question

2011-06-30 Thread Bart Kiers
and a CommonTree will be used as default Treeimplementation. To avoid casting, set the type of tree in your options { ... } section: options { output=AST; ASTLabelType=CommonTree; } On Thu, Jun 30, 2011 at 3:20 PM, Bart Kiers bki...@gmail.com wrote: No problem: SO _does_ work

[il-antlr-interest: 32998] Re: [antlr-interest] Ignore Mismatched input and No viable alternative

2011-06-30 Thread Bart Kiers
Can you give an example of your input, and explain what line you want to ignore? Regards, Bart. On Thu, Jun 30, 2011 at 10:33 PM, Nilo Roberto C Paim nilop...@gmail.comwrote: Hi all, I'm trying to parse a text file created by an application. There are lines in this text file that I know

[il-antlr-interest: 33000] Re: [antlr-interest] Ignore Mismatched input and No viable alternative

2011-06-30 Thread Bart Kiers
: You could use the filter=true grammar option to discard tokens that don't match anything On Thu, Jun 30, 2011 at 10:36 PM, Bart Kiers bki...@gmail.com wrote: Can you give an example of your input, and explain what line you want to ignore? Regards, Bart. On Thu, Jun 30, 2011 at 10:33

[il-antlr-interest: 32978] Re: [antlr-interest] Someting about range (to change)

2011-06-28 Thread Bart Kiers
Hi Fabien, Can you post the grammar that produces the error? Bart. On Wed, Jun 29, 2011 at 5:57 AM, Fabien Hermenier hermenierfab...@gmail.com wrote: Hi I am sorry, but this is another problem related to sequence of integer. I don't understand my error(s), despite severals pass on the

[il-antlr-interest: 32948] Re: [antlr-interest] ANTLRWorks Interpreter

2011-06-25 Thread Bart Kiers
The interpreter is only suitable for very small grammars (without predicates!). For more complicated grammars, use ANTLRWorks' debugger instead. Regards, Bart. On Sat, Jun 25, 2011 at 10:25 PM, Mike Kappel mkap...@appfluent.com wrote: I just downloaded ANTLRWorks and tried the example

[il-antlr-interest: 32878] Re: [antlr-interest] Token Stream Rewriting

2011-06-22 Thread Bart Kiers
(...) is returning a String. Fabien. Le 22/06/11 00:36, Bart Kiers a écrit : Fabien, but what is the return type of this `merge(...)` method? Could you post the method? Or even better: post a SSCCE http://sscce.orgthat causes such an exception? Regards, Bart. On Wed, Jun 22, 2011

[il-antlr-interest: 32844] Re: [antlr-interest] test release of antlr 3.4

2011-06-20 Thread Bart Kiers
The file `/META-INF/MANIFEST.MF` is missing the 'Main-Class' attribute. Add the line: Main-Class: org.antlr.Tool to the file (inside the JAR) and all should be OK. Regards, Bart. On Mon, Jun 20, 2011 at 6:28 PM, Julien BLACHE j...@jblache.org wrote: A Z asicaddr...@gmail.com wrote:

[il-antlr-interest: 32770] Re: [antlr-interest] Facing NoSuchMethodError:CommonTreeNodeStream.getNodeIndex(obj) after upgrating ANTLR V3.1.1 to ANTLR v3.3

2011-06-14 Thread Bart Kiers
Meena, You appear to be running a v3.1 lexer parser with the run-time classes from v3.3. On Stackoverflow I recommended you generate a new lexer and parser using ANTLR v3.3 (and compile them!) which you can then use with the ANTLR v3.3 runt-time classes. Did you do that already? Bart. On Tue,

[il-antlr-interest: 32771] Re: [antlr-interest] Facing NoSuchMethodError:CommonTreeNodeStream.getNodeIndex(obj) after upgrating ANTLR V3.1.1 to ANTLR v3.3

2011-06-14 Thread Bart Kiers
that *getNodeIndex(obj)* Method is missing. Thanks, Meena. *From:* Bart Kiers [mailto:bki...@gmail.com] *Sent:* Tuesday, June 14, 2011 4:38 PM *To:* Meena Subramanian (WT01 - Banking Financial Services) *Cc:* antlr-interest@antlr.org *Subject:* Re: [antlr-interest] Facing

[il-antlr-interest: 32703] Re: [antlr-interest] issue with antlr requiring a whitespace at a specific place

2011-06-08 Thread Bart Kiers
it to maximum (see first line of attached screenshot) However I see in my editor (antlrworks) in interpreter tab: Ignore rules: WHITESPACE. I wonder why, I did not ask for such ignore, and I do not see how to remove this. Maybe this occurs in generated code too. Olivier Le 6/8/11 12:58 PM, Bart

[il-antlr-interest: 32685] Re: [antlr-interest] AST with optional parameters

2011-06-07 Thread Bart Kiers
Hi David, Try this: (ID GETS) = ID GETS expr SEMI? - ^(GETS ID expr SEMI?) Regards, Bart. On Tue, Jun 7, 2011 at 1:41 PM, David Smith david.sm...@cc.gatech.eduwrote: I'm parsing a grammar in which the semicolon on the end of a line is optional. So two of the statement rules might be:

[il-antlr-interest: 32697] Re: [antlr-interest] AST with optional parameters

2011-06-07 Thread Bart Kiers
Jim, From an earlier message, David wrote: *Yes, the language is Matlab and a semicolon on the end of an assignment expression suppresses display of the result of the assignment. ...* Bart. On Tue, Jun 7, 2011 at 6:30 PM, Jim Idle j...@temporal-wave.com wrote: Why do you want the SEMI in

[il-antlr-interest: 32660] Re: [antlr-interest] Any way to search the ANTLR interest archives?

2011-06-05 Thread Bart Kiers
Hi George, Sure, use Markmail: http://antlr.markmail.org/ http://antlr.markmail.org/Regards, Bart. On Sun, Jun 5, 2011 at 3:59 PM, George Spears geo...@woh.rr.com wrote: Hello, The ANTLR interest archives have a lot of valuable information in them..

[il-antlr-interest: 32637] Re: [antlr-interest] Accentuated chars in brazilian portuguese

2011-06-01 Thread Bart Kiers
Hi Nilo, The grammar: grammar Brasil; parse : WORD EOF ; WORD : ('\u00c0'..'\u00ff' | 'a'..'z' | 'A'..'Z' | '-')+ ; parses the input não just fine in ANTLRWorks. I'm not really familiar with C#, but for those who are, could you perhaps post *how* you are testing it? (post a

[il-antlr-interest: 32609] Re: [antlr-interest] Do you need an ANTLR programmer?

2011-05-30 Thread Bart Kiers
On Mon, May 30, 2011 at 9:23 PM, ante...@freemail.hu wrote: On 5/30/2011 11:20 PM, Bart Kiers wrote: On Mon, May 30, 2011 at 9:13 PM, ante...@freemail.hu wrote: On 5/30/2011 10:41 PM, Bart Kiers wrote: Could you stop spamming the ANTLR mailing list please? Bart. You may not know

[il-antlr-interest: 32611] Re: [antlr-interest] options greedy : getting the tokens consumed during the greedy match

2011-05-30 Thread Bart Kiers
) == '*') { isJavaDoc = true; } } (options {greedy=false;} : . )* '*/' ; Regards, Bart Kiers. On Mon, May 30, 2011 at 8:08 PM, Vijay Raj call.vijay...@yahoo.com wrote: Hi - I am trying to parse a given java file, with a code fragment that consumes

[il-antlr-interest: 32612] Re: [antlr-interest] Do you need an ANTLR programmer?

2011-05-30 Thread Bart Kiers
On Mon, May 30, 2011 at 10:38 PM, Jim Idle j...@temporal-wave.com wrote: It always been OK, but there is obvious common sense involved, such as not posting such messages every week. For a start, I make a lot of my living writing professional ANTLR grammars and occasionally, you need to ask for

[il-antlr-interest: 32565] Re: [antlr-interest] question about antlr

2011-05-26 Thread Bart Kiers
Hi Patrick, I have a hard time understanding what it is you're trying to do. Instead of springing the entire grammar on us (or me), could you extract only those rules that are causing the problem(s)? And could you include some example input you'd like to match/parse? Regards, Bart Kiers

[il-antlr-interest: 32567] Re: [antlr-interest] Nasty LHS expression

2011-05-26 Thread Bart Kiers
Hi David, Can an `expr` match something that starts with `ID OPENP` and/or `ID GETS`? Perhaps you can post your entire grammar? Or at least the `expr` rule? Regards, Bart. On Thu, May 26, 2011 at 7:02 PM, David Smith david.sm...@cc.gatech.eduwrote: I am having a difficult time

[il-antlr-interest: 32513] Re: [antlr-interest] Collecting parameters

2011-05-21 Thread Bart Kiers
Hi David, Every root (or leaf) in the AST must be an instance of a ` org.antlr.runtime.tree.Tree`, so you can't create a node that is a `java.util.List`. By default, ANTLR creates its AST using `org.antlr.runtime.tree.CommonTree` objects which inherits the `getChildren()` method from

[il-antlr-interest: 32499] Re: [antlr-interest] Can't figure this one out

2011-05-20 Thread Bart Kiers
Hi David, Your parser does not handle: ans = 3 * (-x + y) * 4 properly since `ans` is an ANS-token and not an IDENT-token. Therefor it does not get matched by your `assignmentStatement` rule. Also, you should probably add the EOF at the end of your `script` rule in your combined grammar.

[il-antlr-interest: 32502] Re: [antlr-interest] AST Question

2011-05-20 Thread Bart Kiers
Hi Your rule: targetsExpr : category ('CAND' targetsExpr)* - ^('CAND' category targetsExpr*) ; is incorrect. You're always using `CAND` in your rewrite rule but that rule could just match `category` only. You'll probably want to do: targetsExpr : category ('CAND'^ targetsExpr)* ;

[il-antlr-interest: 32507] Re: [antlr-interest] AST Question

2011-05-20 Thread Bart Kiers
On Fri, May 20, 2011 at 9:54 PM, massimiliano.m...@gmail.com massimiliano.m...@gmail.com wrote: Hi, On Fri, May 20, 2011 at 10:55 AM, Bart Kiers bki...@gmail.com wrote: targetsExpr : category ('CAND' targetsExpr)* - ^('CAND' category targetsExpr*) ; is incorrect. You're always

[il-antlr-interest: 32479] Re: [antlr-interest] Parsing comment-like sequences of arbitrary characters

2011-05-18 Thread Bart Kiers
Hi Rajesh, Inside a parser rule, the `~` negates tokens, not characters. So if you have no lexer rule that tokenizes one of: '%', ''^' or '$', then ~SEMICOLON won't match any of such tokens/characters. Your grammar (with minor modifications): grammar Test; options { output=AST; } tokens {

[il-antlr-interest: 32481] Re: [antlr-interest] Fragment rules inside parser rules

2011-05-18 Thread Bart Kiers
Hi Ben, You cannot use fragment rules inside parser rules. So yes, you need to make LKU a normal token. If you don't want that (for whatever reason), you need to include the '' in the 'NAME' rule: NAME : '' ('a'..'z')+ ; Regards, Bart. On Wed, May 18, 2011 at 3:00 PM, Ben Corne

[il-antlr-interest: 32449] Re: [antlr-interest] Lexer code missing @header info

2011-05-13 Thread Bart Kiers
Hi David, The snippet: @header { package parser; import java.util.HashMap; } is short for: @parser::header { package parser; import java.util.HashMap; } You'll need to do the following as well: @lexer::header { package parser; import java.util.HashMap; } Regards, Bart. On Fri, May

[il-antlr-interest: 32430] Re: [antlr-interest] Geting all tokens from lexer / token stream

2011-05-11 Thread Bart Kiers
CommonTokenStream inherits getTokens() which returns a List of Tokens. You'll need to cast them to a Token (or something that extends a Token), since it's a non-generics List list: CommonTokenStream tokens = new CommonTokenStream(lexer); for(Object o : tokens.getTokens()) { Token t = (Token)o;

[il-antlr-interest: 32414] Re: [antlr-interest] Translating expressions - advice?

2011-05-09 Thread Bart Kiers
I get the impression you think that when creating AST's, ANTLR inserts parenthesis (brackets). This is not the case: I guess what you're seeing is just the tree's `toStringTree()` that displays these parenthesis to make the hierarchy of the tree apparent. Or am I misinterpreting your question?

[il-antlr-interest: 32415] Re: [antlr-interest] Translating expressions - advice?

2011-05-09 Thread Bart Kiers
tree. See: http://www.antlr.org/wiki/display/ANTLR3/Tree+construction or: http://stackoverflow.com/questions/4931346/how-to-output-the-ast-built-using-antlr Regards, Bart. On Mon, May 9, 2011 at 4:10 PM, Bart Kiers bki...@gmail.com wrote: I get the impression you think that when creating

  1   2   >