[antlr-interest] any comments on Mantra?

Rob Finneran robfinneran at gmail.com
Sat Oct 13 21:28:03 PDT 2007


Hello Fellow Listees,

Can a programmer control how much gets piped as either a stream of
line objects, or collection of line objects?

For example, change

File("coffee") => Lines() => MyFilter(".*parrt.*");

to

(File("coffee") => Lines()) => MyFilter(".*parrt.*");

The additional parens would tell it to send a collection of lines to
MyFilter instead of calling MyFilter() in a for-each fashion with each
line. (I realize that my example is poor because File() or maybe
File()=>Lines() probably already generates a collection to begin with,
does it not?.)

The point I'm trying to make is that it should be able to accumulate a
collection of piped objects before passing to the next element in the
pipeline. Sometimes you do not want to start processing the next step
until you are completely sure that the first steps have already been
completed.

The canonical example might first read an entire file into memory as a
collection of lines.  The next element in the pipeline would then be
able to overwrite the original file, and without using a temp file,
since the file's read-handle would already be closed. A converse
example might pull items from a very long queue. In this case the
for-each processing of each single object along the pipeline would
likely be the desired approach.

Cheers!

On 10/13/07, Terence Parr <parrt at cs.usfca.edu> wrote:
>
> On Oct 13, 2007, at 10:15 AM, Rob Finneran wrote:
>
> > Hi ANTLR Animals,
> >
> > Forgive me if this is a little off-topic:
> >
> > Can Mantra make instances of Java classes, access their fields, call
> > their methods?
> > How about calling static methods on Java classes.
>
> Sure.  use "java {...}" in classes, methods, or expressions.  Any
> time i need a construct missing in mantra, i drop into java to
> implement it.
>
> class T {
>         java {...}
>         foo() {
>                 java {System.out.println("...");}
>                 int i  = {Integer.parseInt("34")};
>         }
> }
>
> > Does Mantra support RegEx expressions and easy file processing?
>
> Library is just beginning, but it's easy to access java underneath.
> It has some good file stuff .  Check out the examples like:
>
> File("coffee") => Lines() => grep(".*parrt.*");
>
> where => is pipe like unix pipe 'cept it passes objects.
>
> Ter
>


More information about the antlr-interest mailing list