On 15/12/2010, at 7:02 PM, john skaller wrote: > > i doubt this will fix the original problem with regex .. but at least now > with my > cleaned up code it generates working code most of the time again .. :)
Actually .. it **does** seem to fix it: //////////// include "./src/lib/std/regdef"; open Regdef; var digit = Charset "9"; val digits = Rpt (digit, 1, -1); var letter = Charset "x"; var us = Regdef::String "_"; var id = Seqs (list ( Alts (list(us,letter)), Rpt( Alts(list(letter,digit,us)),0,-1))); println$ render id; /////////////////////// ~/felix>flx --test=build/release/ rt (?:_|[x])(?:[x]|[9]|_)* This is the expected output, the Perl regexp for a C identifier. Note the code builds a tree of type regex, and then renders it into a string with Perl syntax. This SUCKS but it is the only way to call Google Re2 (or TRE for that matter, only it requires Posix encoding). Re2 also supports Posix encoding but I don't see the point of bothering. Anyhow, the point is that whilst the combinator approach is devoid of stupid concerns of quoting and syntax, it is still long winded to use prefix notation. Hence the syntax extension I have encoded which would allow the above to be written: regdef digit = charset "9"; regdef letter = charset "x"; regdef us = "_"; regdef id = (us | letter) ( us | letter | digit) *; The parser would just translate this into the code I wrote above. In particular this means the whole thing is executable and will work with run-time calculated strings as well (not just constants like the last time we had regdefs). You'd be able to use already encoded regexps too, with something like: regdef = perl "(ab)*"; where the argument of "perl" can be any expression returning a string. -- john skaller skal...@users.sourceforge.net ------------------------------------------------------------------------------ Lotusphere 2011 Register now for Lotusphere 2011 and learn how to connect the dots, take your collaborative environment to the next level, and enter the era of Social Business. http://p.sf.net/sfu/lotusphere-d2d _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language