Regexp.fromString

Matthew Fluet fluet@CS.Cornell.EDU
Thu, 14 Mar 2002 19:46:47 -0500 (EST)


> The "upper" function, used to implement range, appears broken to me.
> Here is the definition.
> 
> 	 fun upper (r, n: int) =
> 	    if n = 0
> 	       then null
> 	    else or [r, upper (r, n - 1)]
> 
> I would assume that you want upper (r, 3) to return
> 
> 	null | r | rr | rrr

You're right; that should be 

else or [repeat (r, n), upper (r, n - 1)]

> Also, is there any reason why you didn't just translate ^ as
> AnchorStart?

No reason; just seemed pointless to support "^" and not "$".  Also, there
are rules in the regexp man pages about ensuring that "^" and "$" occur
only at the beginning or end of top-level regexps, and I didn't feel like
threading enough state to ensure that they were obeyed.