[antlr-interest] Parsing tab delimited datamatrix

Emond Papegaaij e.papegaaij at student.utwente.nl
Mon May 15 12:50:59 PDT 2006


On Monday 15 May 2006 19:33, John B. Brodie wrote:
> >During the parsing I would like to put the column header identifiers
> >into a array of string, the row "header" identifiers into another aray
> >of strings and the doubles into a jama matrix (basically just a
> >double[][]). My idea is that the wee parser and lexer below is pretty
> >much what I need. However, I suppose I need to add some actions where
> >the start are (please see below). The problem is what to add... How do I
> >for instance know how big to make the String[] and the double[][]..?
>
> I would also suggest use of java.util.Vector rather than an array;
> thus avoiding the need to know in advance how big to make each of the
> arrays.  If arrays are a requirement, then gather the data into
> Vectors (or Lists) and, at the end of the input, translate those
> results into the necessary arrays.

I'd recommend not to use Vector for various reasons. First of all, it is 
synchronized, making it slower. ArrayList should be used in a non-threaded 
environment. However both implementations are not optimised for incremental 
growth. LinkedList should be more efficient for a growing list. It's also the 
best implementation for lineair list traversal.

Best regards,
Emond Papegaaij


More information about the antlr-interest mailing list