Re: Parsing

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

Irv Mullins writes:
> When you get data from the command_line, Euphoria parses
> it nicely, disposing of leading and trailing spaces, etc.
> Why can we not call parse() ourselves, passing it a string,
> and getting a sequence of words back?

Here's a routine lifted from euphoria\bin\search.ex

function blank_delim(sequence s)
-- break up a blank-delimited, \n-terminated string,
-- to return a sequence of words
    sequence list, segment
    integer i

    list = {}
    i = 1
    while i < length(s) do
        while find(s[i], " \t") do
            i = i + 1
        end while
        if s[i] = '\n' then
            exit
        end if
        segment = ""
        while not find(s[i], " \t\n") do
            segment = segment & s[i]
            i = i + 1
        end while
        list = append(list, segment)
    end while
    return list
end function

Regards,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/

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

Search



Quick Links

User menu

Not signed in.

Misc Menu