Re: Looking for the best "Parse"...

new topic     » goto parent     » topic index » view thread      » older message » newer message

Ok Cassidy,

I think, my part of the work is near
the finish, so please see your
function in the usual compact form:


-- program parse.ex
 include wildcard.e
 
 global function parseUserText(sequence u, sequence e, sequence r)
  sequence p
   integer v,m,n,k
 	  v = match(lower(e), lower(u))
    if not v then return u end if
 	  m = length(e)
 	  n = length(u)
 	  k = n - m
     if v = 1 then 
              p = r & u[m+1..n]
     elsif v = 1 + k then 
              p = u[1..k] & r
     else 

              p = u[1..v-1] & r & u[v+m..n]
     end if
   return parseUserText(p,e,r)
 end function
 
 sequence text
 
 text = parseUserText("The $A jumped over the lazy dog.","$A","quick brown
 fox")
 
 puts (1, text)
--end of program

When I was testing the last variant, there was
misprint in the code, and recursive construction
run out of memory on my machine without
other messages about bug.

So, code with recursions are very nice and
compact, but it is some more dangerous
for the stability.

Good luck, I'll be off line some time,
so there may be delay with my answers,
if you have questions to me personally.

Regards,
Igor Kachan
kinz at peterlink.ru

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu