[il-antlr-interest: 27979] Re: [antlr-interest] Request for Change regarding Lexer (?)
At 09:27 17/02/2010, I wrote: It'd be nice if there was some way to express a negative match via a syntactic predicate, eg: FOOLIST: 'foo[' (('foo') = ~ | ID)+ ']'; (where '~' in an alt basically means break, ie. match nothing and terminate the innermost loop.) Or, perhaps better: FOOLIST: 'foo[' (('foo') ~= ID)+ ']'; (where '~=' means only take this path if the predicate *fails*) Another possible syntax might be to allow ~ to act on sequences as well as sets. Then you could use either of these: FOOLIST: 'foo[' ((~'foo') = ID)+ ']'; FOOLIST: 'foo[' ((~('f' 'o' 'o')) = ID)+ ']'; This approach might be even more useful than the first, although it's harder to define what the result should be if you try to make a sequence out of both negative and positive sequences (ie. what should ~'foo' 'bar' mean? Is it any three characters except 'foo', followed by 'bar', or any number of characters except 'foo', followed by 'bar'? Or just meaningless? What if it were ~('foo'|'quux') 'bar'? [Assuming this is all at lexer context, so these are sequences of characters rather than individual tokens.]). 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-inter...@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: 27980] [antlr-interest] C# example of lexical filter mode ??
In The Definitive ANTLR Reference, at page 113 there is an example of a lexer grammar, with at the end of the section the remark 'Lexical filter mode is generally not used with a parser because the lexer yields an incomplete stream of tokens.' I declared the fuzzy parser as follows: FuzzyParser lexer = new FuzzyParser (new ANTLRFileStream (sourceFileName)); // derives from Lexer class Question: how do I 'execute' such a grammar lexer in C# without feeding it into a parser? I tried downloading http://www.antlr.org/download/examples-v3.tar.gz, as suggested in the book, but that URL won't open. Regards, John Pool 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-inter...@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: 27981] Re: [antlr-interest] C# example of lexical filter mode ??
Hi John, On Thu, Feb 18, 2010 at 7:52 PM, John Pool j.p...@ision.nl wrote: ... Question: how do I 'execute' such a grammar lexer in C# without feeding it into a parser? You probably meant to instantiate a FuzzyLexer instead of a FuzzyParser (unless your lexer grammar is called FuzzyParser, of course...). Try this: ANTLRStringStream in = new ANTLRStringStream(...some source as a String...); FuzzyLexer lexer = new FuzzyLexer(in); CommonTokenStream tokens = new CommonTokenStream(lexer); for(Object obj : tokens.getTokens()) { Token token = (Token)obj; System.out.println(token); } Although the code above is Java, the C# variant can't be that much different. For a complete example how to use such a lexer, see the first answer from this post on Stackoverflow: http://stackoverflow.com/questions/2284571/how-to-match-a-comment-unless-its-in-a-quoted-string I tried downloading http://www.antlr.org/download/examples-v3.tar.gz, as suggested in the book, but that URL won't open. No problem here: I can download that file just fine. Regards, Bart. 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-inter...@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: 27982] [antlr-interest] Java Grammar that outputs AST
Hi, Is there any Java grammar file available that outputs the AST. Say for example, I have a Java file and I want to output the AST for that file on the eclipse console like the one thats done in the video tutorials. I am trying to see how an AST looks like for a test Java file. All I could find on the website was a java 1.6 .g file but it doesnt output the AST as such. That would be great if I could the required grammar file. Thanks, -V 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-inter...@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: 27983] Re: [antlr-interest] Request for Change regarding Lexer (?)
Gavin, Of your three ideas ...two equivalents in one post and a third more powerful one in this post ... I currently like the second equivalent from the first post...viz ~= for two reasons. First I think your third form is so powerful as to encourage abuse and expose a lot of strange edge-cases for Terence to anticipate and guard against. Not sure, but seems possible. Second I just like having one token (second equivalent) instead of two tokens (first equivalent) to express the idea cleanly. Admittedly this is a style preference and I have been accused of questionable taste more than once. :) Your idea is helpful I would use it regardless of how it is expressed in antlr. Cheers, Kyle Sent from my Verizon Wireless BlackBerry -Original Message- From: Gavin Lambert an...@mirality.co.nz Date: Fri, 19 Feb 2010 07:38:11 To: Terence Parrpa...@cs.usfca.edu Cc: antlr-interest@antlr.org Subject: Re: [antlr-interest] Request for Change regarding Lexer (?) At 09:27 17/02/2010, I wrote: It'd be nice if there was some way to express a negative match via a syntactic predicate, eg: FOOLIST: 'foo[' (('foo') = ~ | ID)+ ']'; (where '~' in an alt basically means break, ie. match nothing and terminate the innermost loop.) Or, perhaps better: FOOLIST: 'foo[' (('foo') ~= ID)+ ']'; (where '~=' means only take this path if the predicate *fails*) Another possible syntax might be to allow ~ to act on sequences as well as sets. Then you could use either of these: FOOLIST: 'foo[' ((~'foo') = ID)+ ']'; FOOLIST: 'foo[' ((~('f' 'o' 'o')) = ID)+ ']'; This approach might be even more useful than the first, although it's harder to define what the result should be if you try to make a sequence out of both negative and positive sequences (ie. what should ~'foo' 'bar' mean? Is it any three characters except 'foo', followed by 'bar', or any number of characters except 'foo', followed by 'bar'? Or just meaningless? What if it were ~('foo'|'quux') 'bar'? [Assuming this is all at lexer context, so these are sequences of characters rather than individual tokens.]). 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-inter...@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.