[il-antlr-interest: 25220] [antlr-interest] How can I match 1 or more tokens (or token streams) and then perform a different action or rewrite on the final one than on the others?

2009-08-13 Thread Joe Schmoe
I want to perform a different embedded action (or generate a different AST node) on the final rule in a list of rules. Here's the most basic example I can think of: identifierList: : (Identifier -> ^(ID $Identifier))* (Identifier -> ^(OTHER $Identifier)) ; This doesn't work becau

[il-antlr-interest: 25219] Re: [antlr-interest] Extracting a string whose value clashes with token value

2009-08-13 Thread Achint Mehta
It seems that I missed one scenario. Now if I give the input as ANTLR ANTLR then I get an error. It seems that the second token is a super-set of the first token and this case both the words are treated as ANTLRTOKEN . A similar situation is described in the section "Ambiguities and Non determinis

[il-antlr-interest: 25218] Re: [antlr-interest] case-insensitivity in ANTLR (Java)

2009-08-13 Thread Michael Bedward
Hi Bruce, Just like this... ANTLRNoCaseFileStream strm = new ANTLRNoCaseFileStream( myfilename ); MyLexer lexer = new MyLexer( strm ); That's all there is to it really. If only all things in life were so easy :) Michael List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe:

[il-antlr-interest: 25217] [antlr-interest] Why I'm getting syntax errors while I'm cheking for semantic errors?

2009-08-13 Thread Marwan Ajraoui
Hi comunity; When I'm runing the tree grammar I defined I'm getting errors like Error: mismatched input '[]' expecting FN_ID So the it seems that it doesn't recognize ([])*. I 've already checked the entry sintactically, so why antlr get confused? What could be the problem, here is a part of m

[il-antlr-interest: 25216] Re: [antlr-interest] There is any documetation I can check; Fwd: How should I extend Commo nTreeNodeStream?

2009-08-13 Thread Marwan Ajraoui
I did find how to implement it; 1. changed my main class setting a walker myAdator // Create a tree Walker attached to the nodes stream BTLSem walker = new BTLSem(nodes); //setting the adapter to

[il-antlr-interest: 25215] Re: [antlr-interest] Simple Grammar breaks ANTLRWorks Interpreter & Debugger?

2009-08-13 Thread consiliens
Gavin Lambert wrote: > Tracing it through with either the debugger or a unit test should show > where the problem lies. A good thing to try is to write a unit test > that simply pulls all the generated tokens off the lexer and verifies > them; if your lexer isn't producing the tokens you're ex

[il-antlr-interest: 25214] Re: [antlr-interest] Simple Grammar breaks ANTLRWorks Interpreter & Debugger?

2009-08-13 Thread consiliens
Gavin Lambert wrote: > At 08:56 14/08/2009, consili...@gmail.com wrote: > >Thanks for the tip! I marked the appropriate rules as fragments, > >however all the issues in the original post still stand. The > >debugger simply generates a Parse Tree of root -> quiz, while > >the Interpreter correc

[il-antlr-interest: 25213] Re: [antlr-interest] Simple Grammar breaks ANTLRWorks Interpreter & Debugger?

2009-08-13 Thread Gavin Lambert
At 08:56 14/08/2009, consili...@gmail.com wrote: >Thanks for the tip! I marked the appropriate rules as fragments, >however all the issues in the original post still stand. The >debugger simply generates a Parse Tree of root -> quiz, while >the Interpreter correctly generates the Parse Tree.

[il-antlr-interest: 25212] Re: [antlr-interest] Simple Grammar breaks ANTLRWorks Interpreter & Debugger?

2009-08-13 Thread consiliens
Gavin Lambert wrote: > At 07:32 14/08/2009, consili...@gmail.com wrote: > >I have a simple grammar for quizzes that doesn't work in the > >debugger, although works fine in the interpreter. > [...] > >LETTER : ('a'..'z'|'A'..'Z'); > >INT : '0'..'9'+; > >NEWLINE : '\n' '\r'?

[il-antlr-interest: 25211] [antlr-interest] case-insensitivity in ANTLR (Java)

2009-08-13 Thread Bruce Bauman
I'm using Jim Idle's snippet of code from the wiki (ANTLRNoCaseFileStream.java), but I'm not sure how to hook this into the ANTLR generated Lexer. Do I put ANTLRNoCaseFileStream.java in the same directory with my "Main.java"? How do I use the new stream instead of the normal ANTLRFileStream? Th

[il-antlr-interest: 25210] Re: [antlr-interest] Simple Grammar breaks ANTLRWorks Interpreter & Debugger?

2009-08-13 Thread Gavin Lambert
At 07:32 14/08/2009, consili...@gmail.com wrote: >I have a simple grammar for quizzes that doesn't work in the >debugger, although works fine in the interpreter. [...] >LETTER: ('a'..'z'|'A'..'Z'); >INT : '0'..'9'+; >NEWLINE : '\n' '\r'? {skip();}; These rules should

[il-antlr-interest: 25209] [antlr-interest] There is any documetation I can check; Fwd: How should I extend CommonTre eNodeStream?

2009-08-13 Thread Marwan Ajraoui
-- Forwarded message -- From: Marwan Ajraoui Date: 2009/8/13 Subject: How should I extend CommonTreeNodeStream? Do I need to change my adaptor or something else? To: antlr-inter...@antlr.org Hi there; I did define a customized node, extending a commonTree, defined an adaptor ex

[il-antlr-interest: 25208] [antlr-interest] Getting cast exceptions in generated code for customized tree

2009-08-13 Thread Marwan Ajraoui
Hi there; I did define a customized node, extending a commonTree, defined an adaptor extending a CommonTreeAdaptor, for my semantic analysis. I did extend as well CommonErrorNode; And now myAdaptor look like: public class BTLTreeAdaptor extends CommonTreeAdaptor{ @Override publi

[il-antlr-interest: 25207] [antlr-interest] Simple Grammar breaks ANTLRWorks Interpreter & Debugger?

2009-08-13 Thread consiliens
I have a simple grammar for quizzes that doesn't work in the debugger, although works fine in the interpreter. However, using a * in place of a + breaks it in the interpreter also. At one point it worked in the debugger. Why does that line, noted in the below grammar, break the Interpreter? Wh

[il-antlr-interest: 25206] Re: [antlr-interest] Why and how exactly does ANTLR manage to fail on non recursive grammar for finite language?

2009-08-13 Thread Nikolay Ognyanov
Actually, even backtracking does not solve this. The problem is apparently as you noted Jim resolving standalone vs embedded expr2. In standalone expr2 following SUFFIX has to be consumed unconditionally whereas in embedded expr2 it has to be consumed only if followed by yet another SUFFIX. To

[il-antlr-interest: 25205] Re: How can I match 1 or more tokens (or token streams) and then perform a different action or rewrite on the final one than on the others?

2009-08-13 Thread Shambolic
I think I am not being clear. In essence, because of where I want to embed actions or rewrites, a simplifed example of what I am trying to do is to write a rule like this: simplified: Identifier* Identifier; ANTLR tells me: warning(200): Decision can match input such as "Identifier" using mult

[il-antlr-interest: 25204] Re: [antlr-interest] parse tree construction

2009-08-13 Thread Jim Idle
Safiye Celik wrote: Hi, I have a grammar such below: a: b A b: C^ B What I want is to set "A" token in rule "a" as the last branch of rule "b" 's parse tree without changing the grammar, rules, tokens etc. (because the rules and tokens are used somewhere else, the grammar is not such simp

[il-antlr-interest: 25203] [antlr-interest] How can I match 1 or more tokens (or token streams) and then perform a different action or rewrite on the final one than on the others?

2009-08-13 Thread Shambolic
I want to perform a different embedded action (or generate a different AST node) on the final rule in a list of rules. Here's the most basic example I can think of: identifierList: : (Identifier -> ^(ID $Identifier))* (Identifier -> ^(OTHER $Identifier)) ; This doesn't work bec

[il-antlr-interest: 25202] Re: [antlr-interest] Compiling generated C Code from ANTLR

2009-08-13 Thread Jim Idle
Heiko Folkerts wrote: Hello, I have trouble compiling the generated C code from ANTLR with Visual Studio 2008. I get the following errors: 1>c:\Projekte\modelisar\trunk\vendorsrc\antlr-3.1.3\runtime\C\include\antlr3lexer.h(130) : error C2059: syntax error : '' 1>c:\Projekte\modelisar\trunk\v

[il-antlr-interest: 25201] Re: [antlr-interest] Why and how exactly does ANTLR manage to fail on non recursive grammar for finite language?

2009-08-13 Thread Jim Idle
David-Sarah Hopwood wrote: Because at the time it is in expr2, it is ambiguous as to whether it should match PREFIX_2 and exit, or match PREFIX_2 SUFFIX and then exit. Yes. You only have 1 token of lookahead (by default). That's not right. The value of k

[il-antlr-interest: 25200] Re: [antlr-interest] Tree rewriting: java.lang.RuntimeException more than one node as root

2009-08-13 Thread Gavin Lambert
At 00:59 14/08/2009, Jeroen van Schagen wrote: >I recently started writing an interpreter for the WAEBRIC >language, which is a language for generating XHTML code based on >self defined function blocks. However, I keep getting runtime >exceptions when running my parser. The following program >

[il-antlr-interest: 25199] [antlr-interest] parse tree construction

2009-08-13 Thread Safiye Celik
Hi, I have a grammar such below: a: b A b: C^ B What I want is to set "A" token in rule "a" as the last branch of rule "b" 's parse tree without changing the grammar, rules, tokens etc. (because the rules and tokens are used somewhere else, the grammar is not such simple of course) That's, I wan

[il-antlr-interest: 25198] [antlr-interest] Tree rewriting: java.lang.RuntimeException more than one node as root

2009-08-13 Thread Jeroen van Schagen
Hello, I recently started writing an interpreter for the WAEBRIC language, which is a language for generating XHTML code based on self defined function blocks. However, I keep getting runtime exceptions when running my parser. The following program interprets fine: module simple def main htm

[il-antlr-interest: /] Re: [antlr-interest] tree rewrite ambiguous enclosing rule/referenced in production

2009-08-13 Thread Gavin Lambert
At 13:45 13/08/2009, Tim Williams wrote: >For the scopedClause rule below, I'm getting this error(132): >"$scopedClause is ambiguous; rule scopedClause is enclosing rule >and referenced in the production (assuming enclosing rule)" [...] >scopedClause: > LPAREN (scopedClause->scopedCla

[il-antlr-interest: 25196] [antlr-interest] How should I extend CommonTreeNodeStream? Do I need to change my adaptor or something else?

2009-08-13 Thread Marwan Ajraoui
Hi there; I did define a customized node, extending a commonTree, defined an adaptor extending a CommonTreeAdaptor, for my semantic analysis. I did extend as well CommonErrorNode; And now myAdaptor look like: public class BTLTreeAdaptor extends CommonTreeAdaptor{ @Override pub

[il-antlr-interest: 25195] Re: [antlr-interest] Why and how exactly does ANTLR manage to fail on non recursive grammar for finite language?

2009-08-13 Thread Sam Barnett-Cormack
Nikolay Ognyanov wrote: > Well, there is nothing else that the extra SUFFIX can belong to > according to the > grammar so this is not derivation/parsing of the statement per the grammar. ANTLR makes no assumptions where to stop, as when it is in a "deeper" rule, it does not know what path it to

[il-antlr-interest: 25194] [antlr-interest] Compiling generated C Code from ANTLR

2009-08-13 Thread Heiko Folkerts
Hello, I have trouble compiling the generated C code from ANTLR with Visual Studio 2008. I get the following errors: 1>c:\Projekte\modelisar\trunk\vendorsrc\antlr-3.1.3\runtime\C\include\antlr3lexer.h(130) : error C2059: syntax error : '' 1>c:\Projekte\modelisar\trunk\vendorsrc\antlr-3.1.3\runti