On 16/12/2010, at 6:22 PM, john skaller wrote:
> 
> // alternate encoding
> var digit = #(charset "9" );
> var digits = #(digit+);
> var letter = #(charset "x");
> var us = #("_");
> var id = #( (us|letter)(letter|digit|us)*);



I have now fixed this to use "regexp" instead of "#". So the competition is now 
on
to design a nice syntax!

For example, instead of

  regex (charset "0123456789")

we might want

  regex ( ["0123456789"] )

since that is closer to the traditional notation. The constraints here are: it 
has to fit in
to the existing grammar and lexicology, so we will NOT allow this:

  regex ( [0123456789] )

without some very serious thinking, because it requires a completely new lexing 
rule just for
charsets (any sequence of characters other than ], but - has special meaning as 
does ^ at the start).

The existing notation is:

  expr = regex ( re )
  re = charset string-literal  // string considered as character set
  re = string                            // match the string literally
  re = identifier                      // name of a Felix variable of regex type
  re = a | b | c | ...                   // alternatives
  re = a b c d                          // sequence
  re = ( r )                                // non-capturing group
  re = group (r)                      // capturing group
  re = perl (string-expr)        // a string considered as a Perl regexp
  re = felix ( re )                     // a felix expression returning a regex
  re = r*                                   //  0-infinte repeat
  re = r+                                  // 1-infinite repeat
  re= r?                                   // optional, 0-1 repeat
  string = render re               // make a Perl encoded regex string from a 
regex

Google Re2 supports a lot more, such as named charsets, words,
and some other stuff (NOT backreferences), numbered repeats 

   r {min,max}

You should note again: this stuff generates regexps dynamically.
It is miles better than any other way, because you can get all the grouping
and quoting right because you simply don't have to do it.


--
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

Reply via email to