[il-antlr-interest: 24433] Personal Accident covers
Personal Accident covers Personal Accident covers http://bpoindustries.blogspot.com http://bpoindustries.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---
[il-antlr-interest: 24434] AVOID SEX IN PUBLIC COME AND ENJOY IN BATHROOMSAVOID SEX IN PUBLIC COME AND ENJOY IN BATHROOMS
AVOID SEX IN PUBLIC COME AND ENJOY IN BATHROOMS http://joyfunnyworld.com http://joyfunnyworld.com http://joyfunnyworld.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---
[il-antlr-interest: 24435] Invest in ULIP insurance
Invest in ULIP insurance Invest in ULIP insurance http://bpoindustries.blogspot.com http://bpoindustries.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---
[il-antlr-interest: 24436] [antlr-interest] Code too large, java error
Hello, I have implemented the grammar for a fairly complex language, using it's BNF definition as base. (Basically just reformatting the syntax to match Antlr). Now this worked fine although the generated java code got pretty large, ~60´000 lines in the parser and ~7´500 in the lexer. Now there has arrived a new revision of the language and i started to implement the additions and changes and thats where i hit the wall. Using just plain Antlr and generate a non-debug version works as before, but in AntlrWorks when generating a debug version i get: [12:56:12] C:\antlr\output\ExtendedParser.java:15: code too large [12:56:12] public static final String[] tokenNames = new String[] { [12:56:12] ^ [12:56:12] 1 error The debug versions are ~85´500 lines in the parser and ~7´800 lines in the lexer. If i comment out the "tokenNames" and "ruleNames" string and the "getTokenNames" function it compiles and runs, but id rather not do this manually each time i compile. So i wounder if there is some way to break these strings into smaller pieces in Antlr or some way to get around this limitation in Java? I really like to retain as much 1:1 syntax with the language's BNF since i need to trust that the parser is correct. The parser grammar is ~900 lines with comments. BR Gustaf --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~--- List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
[il-antlr-interest: 24437] [antlr-interest] Suppress output of org.antlr.runtime.tree.TreeRewriter
Hi guys, I'm currently using a rewriting tree grammar (rewrite=true, filter=true) which means my parser is extending org.antlr.runtime.tree.TreeRewriter. I want to feed output of my program directly to another program with an unnamed pipe | on the command line. Unfortunately that's not possible now because the TreeRewriter shows every rewriting on stdout (like a -> b). So, is there a possibility to suppress this output (yes, it's using System.out.println)? regards Stefan Bischof List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---
[il-antlr-interest: 24440] [antlr-interest] Guidance sought on use of Maven and Eclipse
Hi all, So, currently I'm using eclipse with ANTLR IDE, and it's working nicely. I'm moving toward mavenising my work (which is broken into multiple projects), and the bits without ANTLR use are going fine. However, for the ANTLR bits, I'd ideally make use of maven's ANTLR plugin to make the project portable outside of eclipse. I also want to keep using at least the editor/debugger functionality of ANTLR IDE. Is there any way that people know of to marry these? How would I go about adding ANTLR to the maven pom for plugin as well as dependency? Are there docs, and where? And does anyone have experience of doing this in Eclipse and marrying it with an ANTLR Eclipse plugin? Thanks, Sam PS: I'm planning to ask the m2eclipse list as well, I just thought I'd try here first. List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---
[il-antlr-interest: 24441] Re: [antlr-interest] Guidance sought on use of Maven and Eclipse
2009/6/30 Sam Barnett-Cormack : > Hi all, > > So, currently I'm using eclipse with ANTLR IDE, and it's working nicely. > I'm moving toward mavenising my work (which is broken into multiple > projects), and the bits without ANTLR use are going fine. > > However, for the ANTLR bits, I'd ideally make use of maven's ANTLR > plugin to make the project portable outside of eclipse. I also want to > keep using at least the editor/debugger functionality of ANTLR IDE. Is > there any way that people know of to marry these? How would I go about > adding ANTLR to the maven pom for plugin as well as dependency? Are > there docs, and where? And does anyone have experience of doing this in > Eclipse and marrying it with an ANTLR Eclipse plugin? > > Thanks, > > Sam > > PS: I'm planning to ask the m2eclipse list as well, I just thought I'd > try here first. > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > Hi Sam, I have something like the following in my projects: org.antlr antlr3-maven-plugin 3.1.1.2 antlr Doing a maven build on a project puts stuff into my-module/target/generated-sources/antlr and either Eclipse / M2Eclipse or myself edited the project classpath to reference the generated classes. Cheers, James List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---
[il-antlr-interest: 24442] Re: [antlr-interest] Look-ahead problem parsing phrase?
>From: Sean O'Dell >Subject: Re: [antlr-interest] Look-ahead problem parsing phrase? > >Thanks ... that really did help. I think I didn't realize how much better the parser is than the lexer at >looking-ahead. It makes much more sense to me now, though I'm not yet sure how I will deal with tokenizing >optional trailing whitespace. > >I think, though, if I understand correctly: the lexer rule I build to consume that should not be allowed >to be empty. However, if it's optional, I should indicate that in a parser rule and not the lexer rule. > >Maybe another way to say this is (and maybe it's been said, but I didn't "hear" it correctly): lexer rules >should strive to be completely unambiguous and should match something, preferably immediately from the >left. Parser rules can have more complex look-ahead patterns. The lexer is really just as powerful as the parse, but the big difference is that Antlr will chose which lexer token to start with where with a grammar you specify the starting token. You originally posted this lexer grammar: WS : (' '|'\t')+; DIGIT : ('0'..'9'); LETTER : ('a'..'z'|'A'..'Z'); NEWLINE : '\r'? '\n'; WORD : (LETTER|DIGIT)+; EOL : WS? NEWLINE?; PHRASE : WORD (WS WORD)*; What you have to remember is that the lexer runs first and completely tokenizes the character stream before the parser runs. Also Antlr decides which lexer token to match. The way I think of it is that basically Antlr adds another lexer rule that looks like this: START : (WS | DIGIT | LETTER | NEWLINE | WORD | EOL | PHRASE); Now you can see how having to chose between PHRASE and WORD could be tricky. If you a rule is marked as a fragment, it won't be included in the "START" rule. That said, this might not have been your problem, and Jim's solution might be all you need. Dave List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---
[il-antlr-interest: 24444] Re: [antlr-interest] Suppress output of org.antlr.runtime.tree.TreeRewriter
Hi Stefan, ANTLR comes with the source code. For issues like this I created patch.jar file with small fixes to ANTLR and put on a classpath before ANTLR jar files. For ANTLR 3.1.3 this output is in antlr-3.1.3/runtime/Java/src/main/java/org/antlr/runtime/tree/TreeRewriter.java, method public Object applyOnce(Object t, fptr whichRule) { Thanks, Viktor -Original Message- From: antlr-interest-boun...@antlr.org [mailto:antlr-interest-boun...@antlr.org] On Behalf Of Stefan Bischof Sent: Tuesday, June 30, 2009 7:28 AM To: antlr-inter...@antlr.org Subject: [antlr-interest] Suppress output of org.antlr.runtime.tree.TreeRewriter Hi guys, I'm currently using a rewriting tree grammar (rewrite=true, filter=true) which means my parser is extending org.antlr.runtime.tree.TreeRewriter. I want to feed output of my program directly to another program with an unnamed pipe | on the command line. Unfortunately that's not possible now because the TreeRewriter shows every rewriting on stdout (like a -> b). So, is there a possibility to suppress this output (yes, it's using System.out.println)? regards Stefan Bischof List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---
[il-antlr-interest: 24445] Re: [antlr-interest] Guidance sought on use of Maven and Eclipse
Sam, Some additional notes that I found to be the case when I set up ANTLR and Maven just recently. 1) Use the plugin described here, exactly as described: http://antlr.org/antlr3-maven-plugin/index.html. 2) Use version '3.1.3-1' or better. It's available in central, so you can just update your plugins and away you go. 3) If you want to call the plugin directly, use 'mvn groupId:artifactId:antlr', not just 'antlr3:antlr' which will actually download and call a version by codehaus, which I tore my hair out with. I won't call it buggy, but it was an entirely unpleasant experience. 4) It wasn't entirely clear to me where to put the grammars at first; they go into 'src/main/antlr3/your/package/hierarchy/here'. The generated files will be created in the same hierarchy. Unfortunately, just like Java, you also have to give your grammar a package name to use. 5) I couldn't get m2eclipse to "see" the generated source directory; you might just have to add it to the list of source folders like I did. Sean On Tue, Jun 30, 2009 at 6:19 AM, James Abley wrote: > 2009/6/30 Sam Barnett-Cormack : > > Hi all, > > > > So, currently I'm using eclipse with ANTLR IDE, and it's working nicely. > > I'm moving toward mavenising my work (which is broken into multiple > > projects), and the bits without ANTLR use are going fine. > > > > However, for the ANTLR bits, I'd ideally make use of maven's ANTLR > > plugin to make the project portable outside of eclipse. I also want to > > keep using at least the editor/debugger functionality of ANTLR IDE. Is > > there any way that people know of to marry these? How would I go about > > adding ANTLR to the maven pom for plugin as well as dependency? Are > > there docs, and where? And does anyone have experience of doing this in > > Eclipse and marrying it with an ANTLR Eclipse plugin? > > > > Thanks, > > > > Sam > > > > PS: I'm planning to ask the m2eclipse list as well, I just thought I'd > > try here first. > > > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > > > > Hi Sam, > > I have something like the following in my projects: > > >org.antlr >antlr3-maven-plugin >3.1.1.2 > > > >antlr > > > > > > Doing a maven build on a project puts stuff into > my-module/target/generated-sources/antlr and either Eclipse / > M2Eclipse or myself edited the project classpath to reference the > generated classes. > > Cheers, > > James > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~--- List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
[il-antlr-interest: 24446] Re: [antlr-interest] Look-ahead problem parsing phrase?
Still helpful information. I did get past my issues, though ... the smoke in my eyes is blowing away gradually. Sean On Tue, Jun 30, 2009 at 6:26 AM, Dave Dutcher wrote: > >From: Sean O'Dell > >Subject: Re: [antlr-interest] Look-ahead problem parsing phrase? > > > >Thanks ... that really did help. I think I didn't realize how much better > the parser is than the lexer at > >looking-ahead. It makes much more sense to me now, though I'm not yet sure > how I will deal with tokenizing > >optional trailing whitespace. > > > >I think, though, if I understand correctly: the lexer rule I build to > consume that should not be allowed > >to be empty. However, if it's optional, I should indicate that in a parser > rule and not the lexer rule. > > > >Maybe another way to say this is (and maybe it's been said, but I didn't > "hear" it correctly): lexer rules > >should strive to be completely unambiguous and should match something, > preferably immediately from the > >left. Parser rules can have more complex look-ahead patterns. > > > The lexer is really just as powerful as the parse, but the big difference > is > that Antlr will chose which lexer token to start with where with a grammar > you specify the starting token. > > You originally posted this lexer grammar: > >WS : (' '|'\t')+; >DIGIT : ('0'..'9'); >LETTER : ('a'..'z'|'A'..'Z'); >NEWLINE : '\r'? '\n'; >WORD : (LETTER|DIGIT)+; >EOL : WS? NEWLINE?; >PHRASE : WORD (WS WORD)*; > > What you have to remember is that the lexer runs first and completely > tokenizes the character stream before the parser runs. Also Antlr decides > which lexer token to match. The way I think of it is that basically Antlr > adds another lexer rule that looks like this: > > START : > (WS | DIGIT | LETTER | NEWLINE | WORD | EOL | PHRASE); > > Now you can see how having to chose between PHRASE and WORD could be > tricky. > If you a rule is marked as a fragment, it won't be included in the "START" > rule. > > That said, this might not have been your problem, and Jim's solution might > be all you need. > > Dave > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~--- List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
[il-antlr-interest: 24447] Re: [antlr-interest] Code too large, java error
Gustaf Johansson wrote: > Hello, > > I have implemented the grammar for a fairly complex language, using > it's BNF definition as base. > (Basically just reformatting the syntax to match Antlr). > > Now this worked fine although the generated java code got pretty > large, ~60´000 lines in the parser and ~7´500 in the lexer. > > Now there has arrived a new revision of the language and i started to > implement the additions and changes and thats where i hit the wall. > > Using just plain Antlr and generate a non-debug version works as > before, but in AntlrWorks when generating a debug version i get: > > [12:56:12] C:\antlr\output\ExtendedParser.java:15: code too large > [12:56:12] public static final String[] tokenNames = new String[] { > [12:56:12] ^ > [12:56:12] 1 error > > The debug versions are ~85´500 lines in the parser and ~7´800 lines in > the lexer. > > If i comment out the "tokenNames" and "ruleNames" string and the > "getTokenNames" function it compiles and runs, but id rather not do > this manually each time i compile. You need to split your grammar into a number of component parts and use import. This generates separate classes and you won't get the problem. However, Works is not yet dealing with imports perfectly so while you can edit and so on, you will need to debug remotely from Works. Jim List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---
[il-antlr-interest: 24448] Re: [antlr-interest] Suppress output of org.antlr.runtime.tree.TreeRewriter
Stefan Bischof wrote: > Hi guys, > > I'm currently using a rewriting tree grammar (rewrite=true, filter=true) > which means my parser is extending org.antlr.runtime.tree.TreeRewriter. > > I want to feed output of my program directly to another program with an > unnamed pipe | on the command line. Unfortunately that's not possible > now because the TreeRewriter shows every rewriting on stdout (like a -> > b). > > So, is there a possibility to suppress this output (yes, it's using > System.out.println)? > Hmmm - I wonder if it is supposed to be doing that: if ( r!=null && !t.equals(r.getTree()) && r.getTree()!=null ) { // show any transformations System.out.println(((CommonTree)t).toStringTree()+" -> "+ ((CommonTree)r.getTree()).toStringTree()); } Anyway, tell ANTLR to use a superclass say AbstractMyTreeRewriter (options { superClass=AbstractMyTreeRewriter; } ) and in that class: public abstract class AbstractMyTreeRewriter extends TreeRewriter { public TreeRewriter(TreeNodeStream input) { super(input); } public TreeRewriter(TreeNodeStream input, RecognizerSharedState state) { super(input, state); } public Object applyOnce(Object t, fptr whichRule) { if ( t==null ) return null; try { // share TreeParser object but not parsing-related state state = new RecognizerSharedState(); input = new CommonTreeNodeStream(originalAdaptor, t); ((CommonTreeNodeStream)input).setTokenStream(originalTokenStream); setBacktrackingLevel(1); TreeRuleReturnScope r = (TreeRuleReturnScope)whichRule.rule(); setBacktrackingLevel(0); if ( failed() ) return t; // - // Commented out the output //if ( r!=null && !t.equals(r.getTree()) && r.getTree()!=null ) { // show any transformations //System.out.println(((CommonTree)t).toStringTree()+" -> "+ // ((CommonTree)r.getTree()).toStringTree()); //} if ( r!=null && r.getTree()!=null ) return r.getTree(); else return t; } catch (RecognitionException e) { ; } return t; } } List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---
[il-antlr-interest: 24449] Re: [antlr-interest] Guidance sought on use of Maven and Eclipse
Sam Barnett-Cormack wrote: 1) Ignore eclipse to start with; 2) Read: www.antlr.org/antlr3-maven-plugin 3) When you can type mvn install then integrate with eclipse 4) To integrate with eclipse you find the docs on the maven eclipse plugin and follow the instructions to generate an eclipse project. I have never found it to be so great at doing this, but Eclipse fans have better mileage. I use netbeans as it understands Maven without having to get Maven to produce a project and so on, you just open the directory with the pom.xml as a project. Jim > Hi all, > > So, currently I'm using eclipse with ANTLR IDE, and it's working nicely. > I'm moving toward mavenising my work (which is broken into multiple > projects), and the bits without ANTLR use are going fine. > > However, for the ANTLR bits, I'd ideally make use of maven's ANTLR > plugin to make the project portable outside of eclipse. I also want to > keep using at least the editor/debugger functionality of ANTLR IDE. Is > there any way that people know of to marry these? How would I go about > adding ANTLR to the maven pom for plugin as well as dependency? Are > there docs, and where? And does anyone have experience of doing this in > Eclipse and marrying it with an ANTLR Eclipse plugin? > > Thanks, > > Sam > > PS: I'm planning to ask the m2eclipse list as well, I just thought I'd > try here first. > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---
[il-antlr-interest: 24450] Re: [antlr-interest] Guidance sought on use of Maven and Eclipse
James Abley wrote: 2009/6/30 Sam Barnett-Cormack : Hi all, So, currently I'm using eclipse with ANTLR IDE, and it's working nicely. I'm moving toward mavenising my work (which is broken into multiple projects), and the bits without ANTLR use are going fine. However, for the ANTLR bits, I'd ideally make use of maven's ANTLR plugin to make the project portable outside of eclipse. I also want to keep using at least the editor/debugger functionality of ANTLR IDE. Is there any way that people know of to marry these? How would I go about adding ANTLR to the maven pom for plugin as well as dependency? Are there docs, and where? And does anyone have experience of doing this in Eclipse and marrying it with an ANTLR Eclipse plugin? Thanks, Sam PS: I'm planning to ask the m2eclipse list as well, I just thought I'd try here first. List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address Hi Sam, I have something like the following in my projects: org.antlr antlr3-maven-plugin 3.1.1.2 This version is still usable, but after ANTLR 3.1.2 you should use the version that corresponds to the ANTLR version you are using. Current version is 3.1.3-1 Docs at www.antlr.org/antlr3-maven-plugin Jim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~--- List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
[il-antlr-interest: 24452] Re: [antlr-interest] Suppress output of org.antlr.runtime.tree.TreeRewriter
Hey, On Tue, 2009-06-30 at 08:19 -0700, Jim Idle wrote: > Stefan Bischof wrote: > > Hi guys, > > > > I'm currently using a rewriting tree grammar (rewrite=true, filter=true) > > which means my parser is extending org.antlr.runtime.tree.TreeRewriter. > > > > I want to feed output of my program directly to another program with an > > unnamed pipe | on the command line. Unfortunately that's not possible > > now because the TreeRewriter shows every rewriting on stdout (like a -> > > b). > > > > So, is there a possibility to suppress this output (yes, it's using > > System.out.println)? > > > Hmmm - I wonder if it is supposed to be doing that: > > if ( r!=null && !t.equals(r.getTree()) && r.getTree()!=null > ) { // show any transformations > System.out.println(((CommonTree)t).toStringTree()+" -> "+ > > ((CommonTree)r.getTree()).toStringTree()); > } I'm wondering too :) > Anyway, tell ANTLR to use a superclass say AbstractMyTreeRewriter > (options { superClass=AbstractMyTreeRewriter; } ) and in that class: > > public abstract class AbstractMyTreeRewriter extends TreeRewriter { > > public TreeRewriter(TreeNodeStream input) { >super(input); > } > public TreeRewriter(TreeNodeStream input, RecognizerSharedState state) { > super(input, state); > } > > public Object applyOnce(Object t, fptr whichRule) { > if ( t==null ) return null; > try { > // share TreeParser object but not parsing-related state > state = new RecognizerSharedState(); > input = new CommonTreeNodeStream(originalAdaptor, t); > > ((CommonTreeNodeStream)input).setTokenStream(originalTokenStream); > setBacktrackingLevel(1); > TreeRuleReturnScope r = (TreeRuleReturnScope)whichRule.rule(); > setBacktrackingLevel(0); > if ( failed() ) return t; > > // > - > // Commented out the output > //if ( r!=null && !t.equals(r.getTree()) && > r.getTree()!=null ) { // show any transformations > //System.out.println(((CommonTree)t).toStringTree()+" -> "+ > // > ((CommonTree)r.getTree()).toStringTree()); > //} > > if ( r!=null && r.getTree()!=null ) return r.getTree(); > else return t; > } > catch (RecognitionException e) { ; } > return t; > } > > } Thanks a lot! That sounds like a practical solution. Do you plan to remove that in the future? Because IMO that console output should at least be packed in some logging framework or suppressible by some switch. Thanks again! regards stefan bischof List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---
[il-antlr-interest: 24453] [antlr-interest] got article back up
was dead over at codegeneration.net http://www.antlr.org/wiki/display/ST/Language+Translation+Using+ANTLR+and+StringTemplate T List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---
[il-antlr-interest: 24454] [antlr-interest] Collecting disparate subtrees into one tree?
Hi gang, Here's a question for you. (Apologies if this is explained somewhere; I haven't found it yet.) Suppose I have a language where I have procedures and functions (Oh! Pascal!), such as this: procedure a() { ... } function x() { ... } procedure b() { ... } function y() { ... } procedure c() { ... } function z() { ... } Now suppose, when I'm emitting the final representation, I want to group the procs and funcs together--I'm thinking I should somehow rewrite the tree to get it looking like this simplified version: ^( CODE ^( PROCS a b c ) ^( FUNCS x y z ) ) Is there a clever way, in tree-rewriting syntax, to attach a subtree as a child of a completely unrelated node? Thanks, Stephen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~--- List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
[il-antlr-interest: 24455] [antlr-interest] Error recovery in lexer (~ unclosed string)
Hello there. In my grammar file, i have a lexer rule to match DSL string like this: DSL:'<|' ( options {greedy=false;} : . )* '|>' ; Now my Lexer is hooked up int the NetBeans IDE to parse(well lexer only for now) files and that works well. The problem is that if you type an oening <| (unclosed at this time), the lexer errors out. What happens is that it goes all the way to the end of the file trying to find the closing |>, hits the EOF and throws an exception (null nextToken / unmatched tokens left). I'm not surprised it doesn't like this, but i want to add some error recovery so it deos not fail. I've tried many thing in last 24h but can't seem to find something that works. Latest try is basically this (using states): Grammar: DSL:'<|' {state=INCOMPLETE_DSL} ( options {greedy=false;} : . )* '|>' {state=NORMAL}; Lexer: public Token nextToken() { curToken = (CommonToken) lexer.nextToken(); if(curToken.getType()==-1) //prob. EOF { int state = lexer.getState(); switch (state) { case FanStates.INCOMPLETE_DSL: curToken.setType(FanLexer.INCOMPLETE_DSL); // set as incomplete token type break; } lexer.clearState(); } } However that still does not work quite right, it does replace the token correctly, but i guess after that it does not continue at the right place (do i need a rewind() or consume() or something ?) Or maybe i'm doing this the wrong way - should i "emit" a fake closing token(|>) instead ? I'm sure this is a pretty common issue but i couldn't find any documented way to do this in antlr3 in the book or online. Any help would be greatly appreciated, Thanks. List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---
[il-antlr-interest: 24456] Re: [antlr-interest] Error recovery in lexer (~ unclosed string)
T: '<|' ' ( options {greedy=false;} : . )* ( '|>' | // error message ) ; Jim On Jun 30, 2009, at 5:53 PM, Thibaut Colar wrote: > Hello there. > > In my grammar file, i have a lexer rule to match DSL string like this: > DSL:'<|' ( options {greedy=false;} : . )* '|>' ; > > Now my Lexer is hooked up int the NetBeans IDE to parse(well lexer > only > for now) files and that works well. > The problem is that if you type an oening <| (unclosed at this time), > the lexer errors out. > What happens is that it goes all the way to the end of the file trying > to find the closing |>, hits the EOF and throws an exception (null > nextToken / unmatched tokens left). > > I'm not surprised it doesn't like this, but i want to add some error > recovery so it deos not fail. > I've tried many thing in last 24h but can't seem to find something > that > works. > > Latest try is basically this (using states): > Grammar: > DSL:'<|' {state=INCOMPLETE_DSL} ( options > {greedy=false;} : . )* > '|>' {state=NORMAL}; > > Lexer: >public Token nextToken() >{ >curToken = (CommonToken) lexer.nextToken(); >if(curToken.getType()==-1) //prob. EOF >{ >int state = lexer.getState(); >switch (state) >{ >case FanStates.INCOMPLETE_DSL: >curToken.setType(FanLexer.INCOMPLETE_DSL); // set as > incomplete token type >break; >} >lexer.clearState(); >} >} > > > However that still does not work quite right, it does replace the > token > correctly, but i guess after that it does not continue at the right > place (do i need a rewind() or consume() or something ?) > > Or maybe i'm doing this the wrong way - should i "emit" a fake closing > token(|>) instead ? > > I'm sure this is a pretty common issue but i couldn't find any > documented way to do this in antlr3 in the book or online. > > Any help would be greatly appreciated, Thanks. > > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~--~~~~--~~--~--~---