On Thu, 2007-03-29 at 23:13 -0700, Erick Tryzelaar wrote: > skaller wrote: > > However I see no problem: just copy the array. The hard part is > > knowing how long to make the C array for tre .. only tre knows > > how many groups there are. Note that tre will not exceed the > > specified array length .. you just lose the trailing groups. > > > > I think there's a way to find how many groups there are in a > > compiled regex, isn't there? > > > > Yeah, I believe it's the function "nsub". tre_regexec already returns > that along with the matches, so it'd be pretty easy to make the varray.
Er no, the problem is you need the nsub value BEFORE you actually do a regexp, otherwise you can't tell how long the array needs to be to hold the matches. > I'll also add some ctors so it'll be a little easier to use than the > not-exactly-obvious constructors mkiv and mkuiv. Should be pretty simple It isn't .. otherwise I would have already done it :) Also, varray access should probably be made safe, the way Ocaml does it: if you use s.[i] notation it should be bounds checked, if you want fast access then you have to use functions like 'get_elt s i'. The problem is that in s.[i]=x; s.[i] must be an lvalue, and Felix functions cannot accept or return lvalues (only primitives can do that). > >> And speaking of data structures, what should we use as our default > >> return type? varrays or lists? > >> > > > > Probably a varray. The reason is Posix defines subgroups by integers. > > It's not very nice, but that's the price for dynamic string regexps. > > > > What do you think for in general? I don't understand what you mean 'in general' :) -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language