any good racc examples that parse from an IO instead of a String?

Discussion in 'Ruby' started by Eric Mahurin, Nov 3, 2005.

  1. Eric Mahurin

    Eric Mahurin Guest

    ------=_Part_24069_12170461.1131056239952
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    I wanted to compare how the my grammar project compares against racc in
    terms of performance. I have yet to find an example that parses from an IO.
    Everything I've found so far parses from a String. Seems kind of silly if
    racc has to read in the whole file before parsing - or everybody is doing i=
    t
    that way. Maybe because people write there lexers based on regexes which
    require Strings (I noticed discussions about this on another thread).

    ------=_Part_24069_12170461.1131056239952--
    Eric Mahurin, Nov 3, 2005
    #1
    1. Advertising

  2. Eric Mahurin wrote:
    > I wanted to compare how the my grammar project compares against racc in
    > terms of performance. I have yet to find an example that parses from an IO.
    > Everything I've found so far parses from a String. Seems kind of silly if
    > racc has to read in the whole file before parsing - or everybody is doing it
    > that way. Maybe because people write there lexers based on regexes which
    > require Strings (I noticed discussions about this on another thread).


    I don't understand the question. The parser operates on a token stream,
    neither String nor IO.

    I have a real (but arcane) Racc application; you're welcome to see it.
    (It's a reverse-engineered parser for the export format of a commercial
    system engineering tool.) The lexer pushes tokens onto an array and the
    parser shifts from it. The lexer does read the entire file into memory
    before parsing, but that could be trivially changed by running the lexer
    in a separate thread and using a Queue for the token stream.

    Steve
    Steven Jenkins, Nov 4, 2005
    #2
    1. Advertising

  3. Eric Mahurin

    Eric Mahurin Guest

    ------=_Part_31459_15343953.1131114890624
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    On 11/4/05, Steven Jenkins <> wrote:
    >
    > Eric Mahurin wrote:
    > > I wanted to compare how the my grammar project compares against racc in
    > > terms of performance. I have yet to find an example that parses from an

    > IO.
    > > Everything I've found so far parses from a String. Seems kind of silly

    > if
    > > racc has to read in the whole file before parsing - or everybody is

    > doing it
    > > that way. Maybe because people write there lexers based on regexes whic=

    h
    > > require Strings (I noticed discussions about this on another thread).

    >
    > I don't understand the question. The parser operates on a token stream,
    > neither String nor IO.
    >
    > I have a real (but arcane) Racc application; you're welcome to see it.
    > (It's a reverse-engineered parser for the export format of a commercial
    > system engineering tool.) The lexer pushes tokens onto an array and the
    > parser shifts from it. The lexer does read the entire file into memory
    > before parsing, but that could be trivially changed by running the lexer
    > in a separate thread and using a Queue for the token stream.



    All the example racc parsers I've seen use lexers that parse from a string.
    I think this is because they are using regexes which operates naturally on
    strings, but not IO's.

    So, I guess I mainly want to see a racc lexer example that operates on an
    IO/File. Can you give me a link to what you have?

    ------=_Part_31459_15343953.1131114890624--
    Eric Mahurin, Nov 4, 2005
    #3
  4. Eric Mahurin wrote:
    > All the example racc parsers I've seen use lexers that parse from a string.
    > I think this is because they are using regexes which operates naturally on
    > strings, but not IO's.
    >
    > So, I guess I mainly want to see a racc lexer example that operates on an
    > IO/File. Can you give me a link to what you have?


    OK. It's not exactly published, but not exactly proprietary either. I'll
    email it to you.

    For the record, the lexer iterates over input lines with IO#each and
    then uses regexes to split each line into tokens. So I suppose the lexer
    is, strictly speaking, tokenizing a string.

    Steve
    Steven Jenkins, Nov 4, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    19
    Views:
    1,127
    Daniel Vallstrom
    Mar 15, 2005
  2. Phil Tomson

    RACC examples

    Phil Tomson, Aug 25, 2004, in forum: Ruby
    Replies:
    12
    Views:
    712
    Richard Kilmer
    Aug 26, 2004
  3. Ben Giddings

    Examples for racc?

    Ben Giddings, Mar 15, 2005, in forum: Ruby
    Replies:
    11
    Views:
    195
    Charles Comstock
    Mar 17, 2005
  4. barjunk

    Fun with RACC examples

    barjunk, Aug 18, 2007, in forum: Ruby
    Replies:
    3
    Views:
    117
    barjunk
    Aug 22, 2007
  5. nntpman68
    Replies:
    7
    Views:
    613
Loading...

Share This Page