[il-antlr-interest: 23134] Re: [antlr-interest] Predicate hoisting pain

2009-04-13 Thread Sam Harwell
Hoisting is a very difficult problem. Until I finish my new spec for implementing reliable hoisting, I suggest one of the following: High speed solution A, used as appropriate: elementsTrue : objectSetElements | LPAREN! elementSetSpecTrue RPAREN! ; elementsFalse : subtypeElements

[il-antlr-interest: 23137] Re: [antlr-interest] Predicate hoisting pain

2009-04-13 Thread Sam Barnett-Cormack
Sam Barnett-Cormack wrote: I guess the question really is, for me, why does it get hoisted in one case and not another? I'm assuming it's because of the choice in the objectSetSpec rule, and I can't see any way to refactor that to lose the choice. Of course, there's probably a kludgy

[il-antlr-interest: 23138] Re: [antlr-interest] Predicate hoisting pain

2009-04-13 Thread Sam Harwell
This will fail unexpectedly with certain types of grammars, as demonstrated by some grammars I've sent to the list in the past. I'll find them later today and send a link. Sam -Original Message- From: Sam Barnett-Cormack [mailto:s.barnett-corm...@lancaster.ac.uk] Sent: Monday, April

[il-antlr-interest: 23139] Re: [antlr-interest] Predicate hoisting pain

2009-04-13 Thread Sam Barnett-Cormack
Sam Harwell wrote: This will fail unexpectedly with certain types of grammars, as demonstrated by some grammars I've sent to the list in the past. I'll find them later today and send a link. I can't see why it'd fail horribly in this case... the problem would come if os were being used in a

[il-antlr-interest: 23140] Re: [antlr-interest] Predicate hoisting pain

2009-04-13 Thread Sam Barnett-Cormack
Sam Barnett-Cormack wrote: Sam Harwell wrote: This will fail unexpectedly with certain types of grammars, as demonstrated by some grammars I've sent to the list in the past. I'll find them later today and send a link. I can't see why it'd fail horribly in this case... the problem would

[il-antlr-interest: 23141] Re: [antlr-interest] AntLR C# target exceptions problem

2009-04-13 Thread Johannes Luber
Hi, I'm trying to get the C# target to work, only with partial success. I'm using VS 2008 SP1 or VS 2005 with AntlrWorks and the runtime from DOT-NET-runtime-3.1.2.zip. The problem is, that exceptions raised due to invalid input don't bubble up to my code. I noticed the paragraph

[il-antlr-interest: 23142] Re: [antlr-interest] AntLR C# target exceptions problem

2009-04-13 Thread Jan Newger
Johannes Luber wrote: Hi, I'm trying to get the C# target to work, only with partial success. I'm using VS 2008 SP1 or VS 2005 with AntlrWorks and the runtime from DOT-NET-runtime-3.1.2.zip. The problem is, that exceptions raised due to invalid input don't bubble up to my code. I noticed

[il-antlr-interest: 23143] Re: [antlr-interest] AntLR C# target exceptions problem

2009-04-13 Thread Johannes Luber
Johannes Luber wrote: Does putting a breakpoint into the catch block work? Otherwise the menu for exceptions offers the options to break when an exception is thrown and if an exception is caught. Furthermore, did you add a messagebox call or console print to check if the catch block is

[il-antlr-interest: 23144] Re: [antlr-interest] Predicate hoisting pain

2009-04-13 Thread Jim Idle
Sam Barnett-Cormack wrote: Hi all, So, in my grammar I have need to re-use rules so they ultimately refer to a different rule (so I don't have to duplicate intersection/union/exception rules). I use a parameter and gated predicates, like so: elements[boolean os] :

[il-antlr-interest: 23145] Re: [antlr-interest] AntLR C# target exceptions problem

2009-04-13 Thread Jan Newger
Johannes Luber wrote: Johannes Luber wrote: Does putting a breakpoint into the catch block work? Otherwise the menu for exceptions offers the options to break when an exception is thrown and if an exception is caught. Furthermore, did you add a messagebox call or console print to check if

[il-antlr-interest: 23147] Re: [antlr-interest] AntLR C# target exceptions problem

2009-04-13 Thread Sam Harwell
The error handling mechanisms are fairly complicated, but adding your own handlers is easy. Just call the base versions after you do what you want: public override void ReportError( RecognitionException e ) { // do something, the StackTrace for e will tell you where the error occurred

[il-antlr-interest: 23148] Re: [antlr-interest] AntLR C# target exceptions problem

2009-04-13 Thread Jim Idle
Jan Newger wrote: Johannes Luber wrote: Johannes Luber wrote: Does putting a breakpoint into the catch block work? Otherwise the menu for exceptions offers the options to break when an exception is thrown and if an exception is

[il-antlr-interest: 23149] Re: [antlr-interest] AntLR C# target exceptions problem

2009-04-13 Thread Jan Newger
Sam Harwell wrote: It's a good idea to override ReportError, and this will almost surely provide you with the results you want. You can also put a breakpoint in NoViableAltException's constructor. So you are proposing that I override ReportError and re-throw the exception? I basically want

[il-antlr-interest: 23150] Re: [antlr-interest] AntLR C# target exceptions problem

2009-04-13 Thread Sam Harwell
I make my IntelliSense parser stop after N exceptions (default 20) via an OperationCanceledException to prevent major performance problems with very large files in the IDE, since the file is often syntactically incorrect while it is being edited and it's reparsed often. Sam From:

[il-antlr-interest: 23152] Re: [antlr-interest] Stupid languages, and parsing them

2009-04-13 Thread Andy Tripp
What I do to handle SQL embedded inside C, C++, and COBOL is have a simple preprocessor that replaces all embedded code with a single, unique token (e.g. SQLTOKEN123) and stores the embedded code in a hashtable (e.g. SQLTOKEN123 - EXEC SQL SELECT * FROM EMPLOYEE END-EXEC). The lexing and parsing

[il-antlr-interest: 23153] Re: [antlr-interest] Predicate hoisting pain

2009-04-13 Thread Sam Barnett-Cormack
Sam Barnett-Cormack wrote: Jim Idle wrote: Sam Barnett-Cormack wrote: Hi all, So, in my grammar I have need to re-use rules so they ultimately refer to a different rule (so I don't have to duplicate intersection/union/exception rules). I use a parameter and gated predicates, like so:

[il-antlr-interest: 23154] Re: [antlr-interest] Predicate hoisting pain

2009-04-13 Thread Sam Barnett-Cormack
Jim Idle wrote: However, as you can obviously distinguish the cases at some point higher up the rule chain, then if you wish to pursue this, then all you need do is create a scope with your flag in it at a high enough level, init it to the default case, then set/unset it as the rules

[il-antlr-interest: 23155] Re: [antlr-interest] Predicate hoisting pain

2009-04-13 Thread Jim Idle
Sam Barnett-Cormack wrote: Jim Idle wrote: However, as you can obviously distinguish the cases at some point higher up the rule chain, then if you wish to pursue this, then all you need do is create a scope with your flag in it at a high enough level, init it to the default case, then

[il-antlr-interest: 23156] Re: [antlr-interest] AntLR C# target exceptions problem

2009-04-13 Thread Jan Newger
Jan Newger wrote: Sam Harwell wrote: It's a good idea to override ReportError, and this will almost surely provide you with the results you want. You can also put a breakpoint in NoViableAltException's constructor. So you are proposing that I override ReportError and re-throw the

[il-antlr-interest: 23157] Re: [antlr-interest] Predicate hoisting pain

2009-04-13 Thread Sam Barnett-Cormack
Jim Idle wrote: Sam Barnett-Cormack wrote: Jim Idle wrote: However, as you can obviously distinguish the cases at some point higher up the rule chain, then if you wish to pursue this, then all you need do is create a scope with your flag in it at a high enough level, init it to the

[il-antlr-interest: 23158] Re: [antlr-interest] line 0:-1 mismatched input 'EOF' expecting PACKAGE

2009-04-13 Thread William H. Schultz
On Apr 7, 2009, at 3:18 PM, YINGAnnie wrote: Hi all, Everytime when I run the program, I got this error. Here is the grammar of packageDeclaration packageDeclaration @init { tokens = (ASTokenRewriteStream)input; Token start = input.LT(1); } : PACKAGE type? '{'

[il-antlr-interest: 23159] Re: [antlr-interest] AntLR C# target exceptions problem

2009-04-13 Thread Erik Giron
I had the same problem two months ago, And the best solution that I could find was to override the ReportError method like public override void ReportError(RecognitionException e) { throw e; } rethrowing the exception to the method that called the parser. Then there, I could