[il-antlr-interest: 21161] Re: [antlr-interest] Problem with disambiguating semantic predicates and the decision DFA

2009-01-01 Thread indhu bharathi
use SEMICOLON as deciding factor :-) That said this is only a hackish fix. I would prefer ANTLR using my own predicates to decide when I have explicitly mentioned the predicate. Is there an option to ask ANTLR to forcefully use my predicate when I have specified one? Cheers, Indhu Bharathi PS: I've

[il-antlr-interest: 21162] Re: [antlr-interest] Problem with disambiguating semantic predicates and the decision DFA

2009-01-01 Thread indhu bharathi
our predicate. On Thu, Jan 1, 2009 at 4:34 PM, indhu bharathi wrote: > This might not be an elegant fix. But it does fix the problem > 13c13 > < : PROCEDURE IDENTIFIER SEMICOLON subroutineBlock SEMICOLON > --- > > : PROCEDURE IDENTIFIER SEMICOLON subroutin

[il-antlr-interest: 21242] [antlr-interest] Why is parsing in antlrworks slower?

2009-01-12 Thread Indhu Bharathi
Just curious. Why is parsing inside AntlrWorks (in debug) slower than parsing using a java program? Is this because of displaying the graphical parse tree or is there some other reason? - Indhu --~--~-~--~~~---~--~~ You received this message because you are

[il-antlr-interest: 21272] Re: [antlr-interest] Selectively ignoring whitespace

2009-01-13 Thread Indhu Bharathi
If you are not using single quote anywhere else in the grammar, you can try this: STRING : SINGLEQUOTE ( options {greedy=false;} : . )* SINGLEQUOTE ; If you are using single quote at other places also, then the problem becomes little more complex. In that case you have to

[il-antlr-interest: 21465] [antlr-interest] Highlighting syntax errors

2009-01-21 Thread Indhu Bharathi
Hi, When I parse an input in ANTLRWorks IDE, I can see which portion of the input has errors using the 'input' window in the debugger. Syntax error (handled by automatic error recovery) will be highlighted in red. While this is a very useful feature, I cannot parse a very big file (approx 1 mb

[il-antlr-interest: 21466] Re: [antlr-interest] Highlighting syntax errors

2009-01-21 Thread Indhu Bharathi
Got it! I guess I can do that using org.antlr.runtime.debug.DebugEventListener's beginResync (), endResync () & consumeToken(Token t) http://www.antlr.org/api/Java/interfaceorg_1_1antlr_1_1runtime_1_1debug_1_1_debug_event_listener.html :-) - Original Message - Fr

[il-antlr-interest: 21520] Re: [antlr-interest] Binary data

2009-01-22 Thread Indhu Bharathi
'parseBinary' in Antlr examples folder might help you. - Indhu - Original Message - From: j...@mentics.com To: antlr-inter...@antlr.org Sent: Friday, January 23, 2009 1:51:23 AM GMT+0530 Asia/Calcutta Subject: [antlr-interest] Binary data I have data that is mixed text and binary, so i

[il-antlr-interest: 21959] Re: [antlr-interest] Editor using ANTLR-Parser

2009-02-17 Thread Indhu Bharathi
From: Indhu Bharathi To: Ralf Düsedau Cc: antlr-inter...@antlr.org Sent: Tuesday, February 17, 2009 4:59:11 PM GMT+0530 Asia/Calcutta Subject: Re: [antlr-interest] Editor using ANTLR-Parser ANTLRWorks - http://www.antlr.org/works/index.html - Original Message - From: Ralf Düsedau To:

[il-antlr-interest: 21958] Re: [antlr-interest] Editor using ANTLR-Parser

2009-02-17 Thread Indhu Bharathi
ANTLRWorks - http://www.antlr.org/works/index.html - Original Message - From: Ralf Düsedau To: antlr-inter...@antlr.org Sent: Tuesday, February 17, 2009 4:36:29 PM GMT+0530 Asia/Calcutta Subject: [antlr-interest] Editor using ANTLR-Parser Hi there, i'm new to ANTLR and my knowledge abo

[il-antlr-interest: 21978] Re: [antlr-interest] Lexer ambigiuoties

2009-02-17 Thread Indhu Bharathi
Looks like you are trying to do things in Lexer that actually have to be done in parser. Try keeping the bare minimum in Lexer and move other parsing logics into Parser. Can you post a small sample input you are trying to parse? - Indhu From: antlr-interest-boun...@antlr.org [mailto:an

[il-antlr-interest: 21981] Re: [antlr-interest] Problem when parsing numerics

2009-02-18 Thread Indhu Bharathi
The following grammar will fix your problem. --- grammar Test; options {language=Java;} foo : numeric DOT; numeric :NUMBER (DOT NUMBER)?; NUMBER : '0'..'9'+ ; DOT : '.' ;

[il-antlr-interest: 21982] Re: [antlr-interest] Problem when parsing numerics

2009-02-18 Thread Indhu Bharathi
t; and this comes to your parser. But what your parser is expacting is NUMERIC followed by a '.'. So parsing fails. Simple. - Indhu - Original Message - From: Indhu Bharathi To: Thomas Woelfle Cc: antlr-inter...@antlr.org, j...@temporal-wave.com Sent: Wednesday, February 18,

[il-antlr-interest: 21983] Re: [antlr-interest] Problem when parsing numerics

2009-02-18 Thread Indhu Bharathi
did not match anything at character '' - Indhu - Original Message - From: Indhu Bharathi To: Thomas Woelfle Cc: antlr-inter...@antlr.org Sent: Wednesday, February 18, 2009 2:32:49 PM GMT+0530 Asia/Calcutta Subject: Re: [antlr-interest] Problem when parsing nume

[il-antlr-interest: 21988] Re: [antlr-interest] Lexer ambigiuoties

2009-02-18 Thread Indhu Bharathi
I actually refer to the way how ANTLR decides which token has to be generated next. The simplest case would be that one has a NUMBER rule, a DOT rule and a FLOGTING_POINT rule. With the input "1." ANTLR could theoritically create a NUMBER token followed by a DOT token, but just tries to match F

[il-antlr-interest: 22052] Re: [antlr-interest] quick question

2009-02-23 Thread Indhu Bharathi
A quick guess: Green: It was parsed since you had ‘backtrack’ option set and the parse was success. It will however be parsed again in black color. Red: It was parsed since you had ‘backtrack’ option set but the parse was failure. - Indhu From:

[il-antlr-interest: 22087] Re: [antlr-interest] Loosing characters when choosing a less strong alternative

2009-02-25 Thread Indhu Bharathi
attribute_type : 'unsigned long long' | 'unsigned long' ; Though you have written 'unsigned long long' and 'unsigned long' in the parser rule, they will be still considered as lexer rule only. The lexer after seeing 'unsigned long' will try to go for the bigger match ('unsigned l

[il-antlr-interest: 22112] [antlr-interest] Error reporting with DebugListener attached

2009-02-26 Thread Indhu Bharathi
Hi, I'm attaching a debug listener to my parser and overriding 'recognitionException' method as shown below. public void recognitionException (RecognitionException e) { System.err.println(e); } But I see that the error message printed is not as good as what is printed in stderr when the

[il-antlr-interest: 22118] Re: [antlr-interest] Manipulating text in the lexer

2009-02-26 Thread Indhu Bharathi
>it's no longer possible to alter the content of a token away from what's on >the input at all. I'm not sure if this is right. I still do token.setText(...) in my actions and I'm using ANTLR 3.1.1. Just a guess... Maybe you have to use TokenRewriteStream instead of the regular CommonTokenStr

[il-antlr-interest: 22121] Re: [antlr-interest] Error reporting with DebugListener attached

2009-02-26 Thread Indhu Bharathi
method in your parser with the exception. Ter On Feb 26, 2009, at 8:28 AM, Indhu Bharathi wrote: > Hi, > > I'm attaching a debug listener to my parser and overriding > 'recognitionException' method as shown below. > > public void recognition

[il-antlr-interest: 22122] [antlr-interest] Rewriting in non tree grammar

2009-02-26 Thread Indhu Bharathi
Hi, Suppose I want to do something like this methodDecl : scope t=returnType ident LRAPEN RPAREN { insertBefore(t, "something"); or

[il-antlr-interest: 22131] Re: [antlr-interest] Rewriting in non tree grammar

2009-02-26 Thread Indhu Bharathi
ind any example out there for this requirement. Can anybody explain a little more clear. Sorry if there is some simple way to do it and I'm not getting it. - Indhu -Original Message- From: Terence Parr [mailto:pa...@cs.usfca.edu] Sent: Friday, February 27, 2009 2:53 AM To: Indh

[il-antlr-interest: 22134] Re: [antlr-interest] Rewriting in non tree grammar

2009-02-27 Thread Indhu Bharathi
{ input.insertBefore(pos, "inserted"); } ; a : 'a' ; b : 'b' ; Let me know if there is a better or more elegant way to do this. But I'm fine with this :-) Thanks, Indhu - Original Mes

[il-antlr-interest: 22149] Re: [antlr-interest] Rewriting in non tree grammar

2009-02-27 Thread Indhu Bharathi
To: indh...@s7software.com Cc: antlr-interest Subject: Re: [antlr-interest] Rewriting in non tree grammar On Feb 27, 2009, at 12:43 AM, Indhu Bharathi wrote: > Figured it out :-) Here is a sample grammar that does what is > required: > > grammar Test; > > @mem

[il-antlr-interest: 22151] Re: [antlr-interest] Rewriting in non tree grammar

2009-02-27 Thread Indhu Bharathi
Got it. What I missed is the '$' symbol while referencing I wrote: r : t=a b a { ... t.start.getTokenIndex() ... } It must have been r : t=a b a { ... $t.start.getTokenIndex() ... } Thanks :-) - Original Message - From: Terence Parr To: Indhu Bharathi

[il-antlr-interest: 22162] Re: [antlr-interest] ANTLRWorks debugger

2009-02-28 Thread Indhu Bharathi
This sometime happens due to bug in the grammar. Try running debugger with some very simple grammar. If it works, then the mistake is with the grammar. - Indhu From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] On Behalf Of Filipe David Manana Sent: Sunday, M

[il-antlr-interest: 22249] [antlr-interest] Seperating grammar and actions

2009-03-04 Thread Indhu Bharathi
Hi, Is there a way to separate grammar and actions into two different files? This will be helpful when multiple people are working with the same grammar file (each might write their own actions for the same production) and don't want to create redundant copies of the grammar file. One way I

[il-antlr-interest: 22263] Re: [antlr-interest] Seperating grammar and actions

2009-03-05 Thread Indhu Bharathi
%21+Tree+pattern+matching%2C+rewriting+a+reality . This sounds damn sexy! But has this been released? Does the latest release (3.1.2) include this? Thanks, Indhu - Original Message - From: Sam Harwell To: Indhu Bharathi , antlr-inter...@antlr.org Sent: Thursday, March 5, 2009 8:34:25

[il-antlr-interest: 22363] Re: [antlr-interest] grammar inheritance

2009-03-10 Thread Indhu Bharathi
grammar SqlSQL2Parser; options { superClass=DmlSQL2Parser; } - Indhu - Original Message - From: Maciej Gawinecki To: ANTLR Interest Mailing List Sent: Tuesday, March 10, 2009 12:29:52 PM GMT+0530 Asia/Calcutta Subject: [antlr-interest] grammar inheritance Hi, Jim Idle said that

[il-antlr-interest: 22364] Re: [antlr-interest] DMQL Grammar - ANTLR Eats Characters

2009-03-10 Thread Indhu Bharathi
Try this: Today: ( (Today_) => 'Today' ) ; fragment Today_ : 'Today' ; However, I'm not sure if this's the most elegant way to fix it. Read the following thread to understand more on why exactly this happens: http://www.antlr.org/pipermail/antlr-interest/2009-February/032959.html - Indh

[il-antlr-interest: 22471] [antlr-interest] Passing RuleReturnScope as argument

2009-03-16 Thread Indhu Bharathi
Hi, Is it not possible to pass an instance of RuleReturnScope as argument to a function? With the following sample, I get the error message 'missing attribute access on rule scope'. Curious to know the reason for this limitation... or am I missing something? Is there a workaround? foo : bar1

[il-antlr-interest: 22531] Re: [antlr-interest] "no viab le alternative at character" error for '; ' and ',' in a wild cast

2009-03-17 Thread Indhu Bharathi
Hi, The problem is because ',' or '=' is not defined anywhere in the lexer rule. To be able to lex an input completely, it is necessary that the lexer grammar must account for every character that can occur in the input and be able to convert it into tokens. If you dont want to intoduce these

[il-antlr-interest: 22570] Re: [antlr-interest] DMQL Grammar - ANTLR Eats Characters

2009-03-20 Thread Indhu Bharathi
an error state without noticing that a > different token arrangement would keep it in the green. > > > Mihai > > On Tue, Mar 10, 2009 at 3:48 AM, Indhu Bharathi > mailto:indh...@s7software.com>> wrote: > > Try this: > > Today: ( (Today_) => '

[il-antlr-interest: 22601] Re: [antlr-interest] how to all the matched in java

2009-03-21 Thread Indhu Bharathi
grammar Test; expr : (ID {System.out.println( $ID.text );} )* ; ID : 'a'..'z'+ ; WS : (' ' | '\t' | '\n')+ {$channel = HIDDEN;} ; - Indhu william yuan wrote: > Hi , > problem like this , > i ve defined a grammar like this > expr: ID*; > ID:('a'..'z')*; > and my input is > ABC DEF > so how c

[il-antlr-interest: 22625] Re: [antlr-interest] Order independent keywords

2009-03-22 Thread Indhu Bharathi
Maybe you are looking for something like this: attributes :attribute+ ; attribute :typeAttr |lengthAttr |pathAttr ; Here is a complete sample: grammar Test; attributes :attribute+ ; attribu

[il-antlr-interest: 22626] Re: [antlr-interest] Order independent keywords

2009-03-22 Thread Indhu Bharathi
is not present"); } } :attribute+ ; typeAttr:'TYPE' ID ';' { $attributes::typeAttrSeen = true; } ; - Indhu Indhu Bharathi wrote: > Maybe you are looking for something like this: > > attributes >

[il-antlr-interest: 22684] Re: [antlr-interest] How can I avoid "mismatched input" error?

2009-03-24 Thread Indhu Bharathi
Looks like you are trying to use keyword as identifier. AFAIK, this cannot be resolved in the lexer. You have to use predicates in the parser rule. Something like this: rule : keyKEYWORD1 (keyKEYWORD2 enc=Name)? ';' ; keyKEYWORD1 :{input.LT(1).getText().equals("keyword1")}? Name ; keyK

[il-antlr-interest: 22689] Re: [antlr-interest] How can I avoid "mismatched input" error?

2009-03-24 Thread Indhu Bharathi
lems you mentioned are eliminated. > > As I can see your proposed solution is not scalable if I have the > keywords: keywordA, keywordB,...,keywordZ, and the Name rules: Name1, > Name2,..., NameN. Or is it? > > Any solution for this? > > > Regards, > Gabriel > >

[il-antlr-interest: 22694] Re: [antlr-interest] How can I avoid "mismatched input" error?

2009-03-24 Thread Indhu Bharathi
a function called "function" in the namespace that has > the prefix "declare". This function takes the parameter "declare" of > type XML element having the tag name "declare", and returns also an > XML element having the tag name "function"

[il-antlr-interest: 22715] Re: [antlr-interest] Can TokenRewriteStream be applied to rules?

2009-03-24 Thread Indhu Bharathi
This will work: variableStatement : VAR? variableDeclaration ( COMMA m=variableDeclaration )* semic {tokens.replace($m.start, $m.end, "something else");} &n bsp; ; $m will be of type variableDeclaration_return which will be subclass of 'ParserRuleReturnScope'. $m is not Token. - Indhu YINGAnn

[il-antlr-interest: 22717] Re: [antlr-interest] Can TokenRewriteStream be applied to rules?

2009-03-24 Thread Indhu Bharathi
There was a typo in my mail. It is $m.stop and not $m.end. Sorry :-) And here is the documentation: http://www.antlr.org/api/Java/classorg_1_1antlr_1_1runtime_1_1_parser_rule_return_scope.html :-) YINGAnnie wrote: > > > Well, I tried it,but this timethe error is : > java.lang.NullPointerExceptio

[il-antlr-interest: 22719] Re: [antlr-interest] Can TokenRewriteStream be applied to rules?

2009-03-24 Thread Indhu Bharathi
Maybe 'm=variableDeclaration' didn't match anything in the input... YINGAnnie wrote: > > > Sorry ,Iforgot to mention, Icorrected $m.end. > > Now, I am using {tokens.replace($m.start, $m.stop, "something else");} > > but I got java.lang.NullPointerException error. > > It seems $m is null. > > > An

[il-antlr-interest: 22721] Re: [antlr-interest] Can TokenRewriteStream be applied to rules?

2009-03-24 Thread Indhu Bharathi
Are you sure 'tokens' is the TokenRewriteStream? Generally in the generated code the member variable 'input' is the token stream. Maybe you have to write 'input.replace($m.start, $m.stop, "something else");' unless you have done something to change the name of the token stream. Also note that 'inp

[il-antlr-interest: 22780] [antlr-interest] Is this possible?

2009-03-26 Thread Indhu Bharathi
Can 'dfa.predict' throw 'no viable alternative' exception? I'm facing this strange problem and wondering what could be the reason. Any pointers? Thanks, Indhu List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email

[il-antlr-interest: 22799] Re: [antlr-interest] Problem with rewrite rules with optional non-terminals

2009-03-26 Thread Indhu Bharathi
Jim Idle wrote: > Andreas Meyer wrote: >> David Jameson schrieb: >> >>> I have the following grammar fragment >>> >>> refTag : >>> LSQUARE a=expression (COMMA b=expression)? RSQUARE >>> { >>> //stuff >>> >>> } ->

[il-antlr-interest: 22909] Re: [antlr-interest] how to best break apart multiple assignments

2009-04-01 Thread Indhu Bharathi
How about something like this? r:(ID EQ)+ INTLIT SEMICOLON -> ^(ASSIGN ID INTLIT)+ ; So, for your example, this will create two subtrees with ASSIGN as root. The tree generated will be ^(nil ^(ASSIGN Odd 0) ^(ASSIGN Even 0)) And then you can write string template in the tree walker

[il-antlr-interest: 22910] Re: [antlr-interest] Handling wiki-style plain text with optional markup?

2009-04-01 Thread Indhu Bharathi
Take a look at 'filter' mode of ANTLR lexer. This will let you skip text you are not interested in. Posting a more specific example of what you need might help. Peter Bertok wrote: > > > > I'm working on a trivial embedded "wiki" style content management > system for a web project, and I'm tr

[il-antlr-interest: 22961] [antlr-interest] Composite grammar and memoize

2009-04-02 Thread Indhu Bharathi
Hi, It looks like memoize at rule level doesn't work in composite grammar. I get the error message '! memo array is null for ParserPart.g'. 'state.ruleMemo' is always null. Also, it looks like this is a known issue. Has this been fixed or is there a workaround? I tried turning on mem

[il-antlr-interest: 22975] Re: [antlr-interest] Composite grammar and memoize

2009-04-02 Thread Indhu Bharathi
n Behalf Of Indhu Bharathi Sent: Thursday, April 02, 2009 10:58 PM To: antlr-interest Subject: [antlr-interest] Composite grammar and memoize Hi, It looks like memoize at rule level doesn't work in composite grammar. I get the error message '! memo array is null for ParserPart.g&

[il-antlr-interest: 22978] Re: [antlr-interest] A Simple Question on Channels

2009-04-02 Thread Indhu Bharathi
I don't have ANTLR right now to test this. But guess it would work NEWLINE: '\r'?'\n' {$channel = HIDDEN;}; Then write expression_statement rule like this: expression_statement :expression { NewLineBeforeNextToken( input.LT(1) ) }?=> /*nothing*/ ; And in the @

[il-antlr-interest: 22980] Re: [antlr-interest] A Simple Question on Channels

2009-04-02 Thread Indhu Bharathi
l pass whereas "foo" will fail :-) I casted input to 'DebugTokenStream' since I was running inside ANTLRWorks. You can cast it to CommonTokenStream. Cheers, Indhu Indhu Bharathi wrote: > > I don't have ANTLR right now to test this. But guess it would

[il-antlr-interest: 23015] Re: [antlr-interest] A Simple Question on Channels

2009-04-04 Thread Indhu Bharathi
'expression' is rule 'r' wont return a Token since it is not a lexer rule. It will instead return 'ParserRuleReturnScope' since it is a parser rule. So '$expression.stop' or '$t.stop' will give you the last token of 'expr'. You can use it like shown below: r : t=expression { newLineBeforeNextT

[il-antlr-interest: 23026] [antlr-interest] Why doesn't this work?

2009-04-07 Thread Indhu Bharathi
I was working in a big grammar and stumbled on a problem with predicates. I've simplified the problem as much as possible and here it is: When I give the input "1.", I expect the tokens . But what I get is "No viable alternative at character 'EOF'. I'm not able to understand why this happens.

[il-antlr-interest: 23035] Re: [antlr-interest] Why doesn't this work?

2009-04-07 Thread Indhu Bharathi
Hi, Any clue why this doesn't work? I'm still clueless. - Indhu Indhu Bharathi wrote: > I was working in a big grammar and stumbled on a problem with > predicates. I've simplified the problem as much as possible and here it is: > > When I give the input "1.&

[il-antlr-interest: 23047] Re: [antlr-interest] [antlr-dev] Why doesn't this work?

2009-04-08 Thread Indhu Bharathi
LIT; } ; DOT:'.' ; fragment PATTERN :; fragment FLOAT_LIT :; fragment INT_LIT :; fragment NUMBER:('0'..'9')+ ; fragment LETTER:'a'..'z' ; Thanks, Indhu Jim Idle

[il-antlr-interest: 23051] Re: [antlr-interest] Why doesn't this work?

2009-04-08 Thread Indhu Bharathi
At 03:12 9/04/2009, Indhu Bharathi wrote: >> INT_FLOAT_PATTERN >> :(NUMBER DOT NUMBER LETTER ) => NUMBER DOT NUMBER LETTER >> { $type=PATTERN; } >> >> |( NUMBER DOT NUMBER ) => NUMBER DOT NUMBER >> { $type=FLOAT_LIT; }

[il-antlr-interest: 23053] Re: [antlr-interest] simple arithmetic counter

2009-04-08 Thread Indhu Bharathi
Use '@members' to store 'global' variables. like @members{ int cnt; } and increase 'cnt' in 'species' production, like species : ret=atom NUMBER? { cnt += $ret.weight * Integer.parseInt($NUMBER.text) } ; and print out the sum in file production, like file

[il-antlr-interest: 23057] Re: [antlr-interest] discrepancy between antlrworks and antlr generated parser

2009-04-09 Thread Indhu Bharathi
WS: (' ' | '\n' | '\r' )+ {$channel=HIDDEN}; This should give you compile error. There must be a ';' immediately after 'HIDDEN'. ( {$channel=HIDDEN;} ) Are you using tab instead of space in input? David Cournapeau wrote: > Hi, > > I have started using antlr to catch up my lack of knowledge in

[il-antlr-interest: 23076] Re: [antlr-interest] Inject Lexer Tokens before parsing further

2009-04-09 Thread Indhu Bharathi
Curious. Why not change formula production to formula : EQ expression | expression ; If for some reason you want to enforce that the input has to start with PLUS or MINUS then maybe you can rewrite formula production as formula : EQ expression | (PLUS | MINUS)=> expression ; Thi

[il-antlr-interest: 23078] Re: [antlr-interest] Inject Lexer Tokens before parsing further

2009-04-09 Thread Indhu Bharathi
gt; being entered, so I have to accomodate it. > > I have a rough solution which is to Pre-parse the text and then change > the text to "=-5+4" and then pass the new text to the second parser, > but I was wondering if there is a more elegant solution > > Than

[il-antlr-interest: 23080] Re: [antlr-interest] Inject Lexer Tokens before parsing further

2009-04-09 Thread Indhu Bharathi
how would I pass the whole expression to > "expression"? > > Thanks > Des > > > > 2009/4/10 Indhu Bharathi <mailto:indh...@s7software.com>> > > Well, in that case the second solution that uses syntactic > predicate should work. > >

[il-antlr-interest: 23192] Re: [antlr-interest] Unexpected CommonTokenStream.Size() result in CSharp runtime

2009-04-16 Thread Indhu Bharathi
This is expected behavior only. It is designed this way so that user can filter for a particular channel if needed. For your task, you can use getTokens() method which will return a List of tokens that can be iterated. Cheers, Indhu Chris Lambrou wrote: > Yesterday I was stung by some odd behav

[il-antlr-interest: 23317] Re: [antlr-interest] Lexing 7-bit ASCII stream

2009-04-21 Thread Indhu Bharathi
Order doesn't matter. ANTLR will match the longest possible token. One case when order matters is when the rule below cannot match any token inspite of the 'lengthiest token matching' mechanism. Example: ID   :   'a'..''z'+ ; SOME_KEYWORD   :   'key' ; In this case ANTLR will report an err

[il-antlr-interest: 23498] Re: [antlr-interest] Tuning parser to non-default channel

2009-05-04 Thread Indhu Bharathi
It is true that the parser can 'tune' to any channel. But you can't do it while parsing. The channel should be set before parsing begins. If you want to see the off channel token while parsing, you can use LA( int ) and LT( int ) within the parser. For your example, you can write something li

[il-antlr-interest: 23596] Re: [antlr-interest] Sometimes significant new lines

2009-05-07 Thread Indhu Bharathi
Did you evaluate the option of making semicolon a default token itself instead of hidden token? Unless there is compelling reason to make semicolon hidden token, let's make it default token. That will make the work easy. Now assuming there is some compelling reason to make semicolon hidden toke

[il-antlr-interest: 23603] Re: [antlr-interest] Whitespace issues

2009-05-08 Thread Indhu Bharathi
Looks like a lot of work that has to be done in the lexer is getting done in the parser. I would prefer tokenizing '[%"Dear "%]' as a separate token and similarly '[% name %]' as a separate token. Simple substring, trim operations can get you the actual block and string content later. Here i

[il-antlr-interest: 23608] Re: [antlr-interest] Recursive not supposed behaivor when finding EOF

2009-05-08 Thread Indhu Bharathi
Looks like you are parsing with empty input. What is the input you gave to the parser? Cheers, Indhu Marwan Ajraoui wrote: > Hi there; > > I'm getting a strange error form a parser. I have defined a grammar, > wich contains these rules; > > > decl_codigo : decl_libreria decl_program > > decl_l

[il-antlr-interest: 23741] Re: [antlr-interest] Lexer matching non-matching rule

2009-05-15 Thread Indhu Bharathi
This is because on seeing 'f' of foo lexer has two options - 1. IDENT 2. URL. And it takes the second options since that seems to be longer that the first alternative. Note that the lexer always tries to match the longest token possible. After having decided to go for URL, it matches the inpu

[il-antlr-interest: 23748] Re: [antlr-interest] how to match any char between two string?

2009-05-16 Thread Indhu Bharathi
You get the error because 'SELECT' will match everything in the input till EOF greedily (because of .+) and obviously WS cannot match anything. When you use .+, you have to turn off greedy. Try something like: TEXT        :    SELECT ( options {greedy=false;} : . )* FROM This should work:

[il-antlr-interest: 23882] Re: [antlr-interest] I want to throw an exception and stop parse, please!

2009-05-24 Thread Indhu Bharathi
Two methods of parser (mismatch and recoverFromMismatchedSet) are responsible for auto-recovery and showing error messages. If you want to throw an exception and exit right on the first error you need to override these methods and just throw the exception instead of handling it. Something like

[il-antlr-interest: 23884] Re: [antlr-interest] I want to throw an exception and stop parse, please!

2009-05-25 Thread Indhu Bharathi
Ah, forgot. Things changed after the book was written. I guess you have to override the following two methods from BaseRecognizer void recover (IntStream input, RecognitionException re) Object recoverFromMismatchedSet (IntStream input, RecognitionException e, BitSet follow) throws RecognitionE

[il-antlr-interest: 23943] Re: [antlr-interest] BOF or BOL (Beginning of file/line)

2009-05-31 Thread Indhu Bharathi
Overwride the emit method and check 'getCharPositionInLine' for the tokens emited. If the value is zero emit an additional BOL token. This will take care of beginning of file too. Something like this: java.util.LinkedList tokenQueue = new java.util.LinkedList(); public void emit(Token token)

[il-antlr-interest: 23990] Re: [antlr-interest] Grammer file queries...

2009-06-03 Thread Indhu Bharathi
For your second and third question, solution is to use 'composite grammar'. You'll be able to extend the existing grammar file. You can also form a grammar by combining multiple .g files. One file might contain the lexer and the parser itself could be spread across multiple grammar files. There is

[il-antlr-interest: 23998] Re: [antlr-interest] Inconsistent Parse Results

2009-06-03 Thread Indhu Bharathi
That is an expected behavior. Seeing ' C' the lexer decides to go for 'CORP' token instead of OTHER(space) and WORD. You need to do some left factoring there. Or you can modify your grammar to avoid such problems. Here is a suggested correction: grammar Test ; test1 : NUMBER CORP data {System.ou

[il-antlr-interest: 24029] Re: [antlr-interest] How to f orce ANTLR 3.1.2 to raise exceptions on invalid tokens?

2009-06-04 Thread Indhu Bharathi
By default error recovery is turned on and ANTLR will try to recover from syntax errors. However it will print error message on stderr. If you need error recovery to be turned off and throw an exception at the first sight of an error, you need to override 'recoverFromMismatchedToken' as shown in

[il-antlr-interest: 24036] Re: [antlr-interest] how to implement this string rule?

2009-06-04 Thread Indhu Bharathi
STRING : '"' ( options {greedy=false;} : . )* '"' ; Greedy is turned off so that .* doesn't consume the terminating '"' also. Cheers, Indhu -Original Message- From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] On Behalf Of Xiaohua Guo Sent: Thursday, June 0

[il-antlr-interest: 24106] Re: [antlr-interest] Newbie grammar question...

2009-06-08 Thread Indhu Bharathi
I don't get any exception. BTW, it is good to match the entire 'phrase' as one token in the lexical analysis itself. Something like: PHRASE :( '0'..'9' | 'A'..'Z' | ' ' | '\t')+ ; and modify stmt to: stmt :SUBJ_TOK COLON PHRASE NL+ ; Else, you'll end up creating too man

[il-antlr-interest: 24118] Re: [antlr-interest] newbie grammar question

2009-06-08 Thread Indhu Bharathi
SL_COMMENT_2 : '--' (options {greedy=false;} : . )* '\n' {$channel=HIDDEN;} { setText( "//" + getText().substring(2) ); } ; Should work. -Original Message- From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org]

[il-antlr-interest: 24123] Re: [antlr-interest] Bug in AntlrWorks debugger

2009-06-08 Thread Indhu Bharathi
ANTLRWORKS accepts tab in input box without any problem. The version I'm using is 1.2.3 -Original Message- From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] On Behalf Of Dukie Banderjee Sent: Tuesday, June 09, 2009 12:45 AM To: antlr-inter...@antlr.org Subj

[il-antlr-interest: 24159] Re: [antlr-interest] Excluding keywords

2009-06-10 Thread Indhu Bharathi
As stated in the link you provided, there is nothing you have to do to get this functionality. But 'identifier' should be a lexer rule. I guess your grammar should be something like this: APPLY : 'apply'; BROWSE : 'browse' . ID

[il-antlr-interest: 25282] Re: [antlr-interest] Using predicates for keywords

2009-08-17 Thread Indhu Bharathi
Maybe you can use a setter to set what 'ifKeyword' is and use that in a semantic predicate. Something like: @members { String ifKeyword; Public void setIfKeyword(String str) { this.ifKeyword = str; } } ifKeyword : { LT(1).getText().equals(i

[il-antlr-interest: 25597] Re: [antlr-interest] ANTLR debug error

2009-09-04 Thread Indhu Bharathi
What exactly is the error message you get? On Sep 4, 2009, at 12:57 PM, Klaus Martinschitz wrote: > Hi! > > I already looked around in the internet and do not find any answer to > solve following problem. I downloaded the newest antlr works version > 1.2.3 were antlr and antlr works are bundle

[il-antlr-interest: 25677] Re: [antlr-interest] Grammar inclusion

2009-09-09 Thread Indhu Bharathi
I guess you can do it with composite grammars. -Original Message- From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] On Behalf Of Martin Potier Sent: Wednesday, September 09, 2009 7:10 PM To: antlr-inter...@antlr.org Subject: [antlr-interest] Grammar inclusio

[il-antlr-interest: 25695] Re: [antlr-interest] Optimized code generation

2009-09-10 Thread Indhu Bharathi
Yes, backtracking will affect performance. If you are concerned about performance, don't use backtrack and try left factoring your grammar instead. From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] On Behalf Of Bharath R Sent: Thursday, September 10, 2009 5:25 PM

[il-antlr-interest: 25701] Re: [antlr-interest] Optimized code generation

2009-09-11 Thread Indhu Bharathi
dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it! _ From: Indhu Bharathi [mailto:indh...@s7software.com] Sent: Thursday, September 10, 2009 10:37 PM T

[il-antlr-interest: 25780] Re: [antlr-interest] About API in ANTLRWorks

2009-09-16 Thread Indhu Bharathi
A related mail from archive: you mean a parse tree, not AST, right? There is a ParseTreeBuilder i think. T On Sep 1, 2009, at 12:50 PM, Stefan Groschupf wrote: > Hi, > I'm making my first baby with antlr. > Is there any chance to get a AST exactly as antlr work is generating > wit

[il-antlr-interest: 25797] Re: [antlr-interest] Parsing comments

2009-09-17 Thread Indhu Bharathi
Try using semantic predicates to look-ahead and decide whether to emit SLCOMMENT or TEMPLATE Something like: fragment SLCOMMENT : ; fragment TEMPLATE : ; SLCOMMENT_OR_TEMPLATE : '//' (

[il-antlr-interest: 25837] Re: [antlr-interest] Error: Declared package doesn't match expected package

2009-09-19 Thread Indhu Bharathi
Check if you are creating the lexer/parser under the right directories. Look like the files are getting generated at root level in source tree. On Sep 19, 2009, at 9:28 AM, Sailesh Kandula wrote: > While building my first ANTLR project SimpleCalc.g i ran into the > error: > > The declare

[il-antlr-interest: 25900] Re: [antlr-interest] Howto modify token creation?

2009-09-23 Thread Indhu Bharathi
You can do something like ID : LETTER (LETTER|DIGIT)* { String text = getText(); Integer tknType; if( (tknType=table.get(text))!=null ) { $type = tknType; } } The table can be passed to t

[il-antlr-interest: 25911] Re: [antlr-interest] Question with greedy

2009-09-24 Thread Indhu Bharathi
'!' is a rewrite operator used in tree construction. Since lexer doesn't construction a tree, I don't think this will work. -Original Message- From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] On Behalf Of Gordon Tyler Sent: Thursday, September 24, 2009 6:5

[il-antlr-interest: 25929] Re: [antlr-interest] Recover grammar file from generated code?

2009-09-25 Thread Indhu Bharathi
I don't think if any tool exists to do it automatically. But the generator adds the grammar also as comments into the generated lexer/parser. You can manually go through it and recover the grammar. -Original Message- From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@a

[il-antlr-interest: 25995] Re: [antlr-interest] StringTemplate to generate Grammar docs?

2009-09-29 Thread Indhu Bharathi
Try the tool 'strip'. It comes with ANTLR. From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] On Behalf Of Jonathan Claggett Sent: Tuesday, September 29, 2009 3:41 AM To: antlr-inter...@antlr.org Subject: [antlr-interest] StringTemplate to generate Grammar docs?

[il-antlr-interest: 26083] Re: [antlr-interest] Out of Memory

2009-10-05 Thread Indhu Bharathi
Is it possible to write a separate program to break the PGN files into separate games and pass each game to the lexer/parser? That will be a simple solution assuming there is an easy way to split games in a PGN file. -Original Message- From: antlr-interest-boun...@antlr.org [mailto:antlr

[il-antlr-interest: 26089] Re: [antlr-interest] How to do "not" in a syntactic predicate?

2009-10-05 Thread Indhu Bharathi
Try something like: (a)=> ((b)=>/*nothing*/ | a) I remember facing similar problem. I guess you can't use '~' in a syntactic predicate. From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] On Behalf Of Naveen Chawla Sent: Monday, October 05, 2009 7:32 PM T

[il-antlr-interest: 26090] Re: [antlr-interest] A wish

2009-10-05 Thread Indhu Bharathi
ANTLRWORKS already has this feature. Compile your grammar in ANTLRWORKS. When there is an ambiguity, the rule will be marked in red and you can check the "Syntax diagram" tab to graphically see the ambiguity. From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] On

[il-antlr-interest: 26122] Re: [antlr-interest] Help writing a particular semantic predicate

2009-10-06 Thread Indhu Bharathi
In that case you have to use syntactic predicate. Cheers, Indhu From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] On Behalf Of Naveen Chawla Sent: Wednesday, October 07, 2009 4:33 AM To: antlr-inter...@antlr.org Subject: Re: [antlr-interest] Help writing a par

[il-antlr-interest: 26164] Re: [antlr-interest] Whitespace question

2009-10-09 Thread Indhu Bharathi
Try something like r : lbl=searchTerm ({spaceFollows($lbl.stop)}?=> lbl=searchTerm)* ; @members { public boolean spaceFollows(Token tkn) { return input.get(tkn.getTokenIndex()+1).getType()==WS; } } Cheers, Indhu Bharathi &l

[il-antlr-interest: 26181] Re: [antlr-interest] Is it possible to include another grammar file?

2009-10-10 Thread Indhu Bharathi
Refer 'composite grammar' from wiki. http://www.antlr.org/wiki/display/ANTLR3/Composite+Grammars Cheers, Indhu Bharathi <http://www.s7software.com/> S7 Software Solutions From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] On Beha

[il-antlr-interest: 26202] Re: [antlr-interest] [LEXER] Unwanted behaviour ?

2009-10-12 Thread Indhu Bharathi
Can you post a small sample where the problem exists? -Original Message- From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] On Behalf Of Martin Potier Sent: Monday, October 12, 2009 5:44 PM To: antlr-inter...@antlr.org Subject: [antlr-interest] [LEXER] U

[il-antlr-interest: 26204] Re: [antlr-interest] MismatchedTokenException in loop

2009-10-12 Thread Indhu Bharathi
our problem, I’m not sure if this is an elegant way of fixing this problem. I would vote for parser checking only the syntax and the symantics handled by tree walkers. You can establish the relation between messages while tree walking. Cheers, Indhu Bharathi <http://www.s7software.co

[il-antlr-interest: 26223] Re: [antlr-interest] caseSensitive = false in C taget ??

2009-10-13 Thread Indhu Bharathi
AFAIK, there is no shortcut. You will have to write something like HELLO : ( ('H'|'h') ('E'|'e') ('L'|'l') ('L'|'l') ('O'|'o') ) ; You can make it more readable using fragments. HELLO : H E L L O fragment H: ('H'|'h') fragment E: ('E'|'e') fragment L: ('L'|'l') fragment O:

  1   2   >