Re: newbee help : parser in C

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Antoninus Twink

    Re: newbee help : parser in C

    On 19 Jun 2008 at 21:27, vaib wrote:
    hi all . i am trying to build a parser in ANSI C .
    Check out yacc (aka bison).

  • vaib

    #2
    Re: newbee help : parser in C

    On Jun 20, 3:16 am, Antoninus Twink <nos...@nospam. invalidwrote:
    On 19 Jun 2008 at 21:27, vaib wrote:
    >
    hi all . i am trying to build a parser in ANSI C .
    >
    Check out yacc (aka bison).
    i know what yacc (aka bison) does but i was avoiding to use tools .
    but yes it is a very good idea to look at the code generated by it .
    it might be of huge hepl . could you direct me to a grammar that yacc
    takes ? thanx .

    Comment

    • Nick Keighley

      #3
      Re: newbee help : parser in C

      On 20 Jun, 09:01, vaib <vaibhavpang... @gmail.comwrote :
      On Jun 20, 3:16 am, Antoninus Twink <nos...@nospam. invalidwrote:
      On 19 Jun 2008 at 21:27, vaib wrote:
      hi all . i am trying to build a parser in ANSI C .
      Check out yacc (aka bison).
      >
      i know what yacc (aka bison) does but i was avoiding to use tools .
      but yes it is a very good idea to look at the code generated by it .
      it might be of huge hepl . could you direct me to a grammar that yacc
      takes ?
      my understanding is that the code produced by bison isn't very
      readable.
      You arn't meant to read it.

      Look up Recursive Descent Parser and try something simpler
      than C to start with. Maybe a subset of C.

      int i;
      float f;

      int foo (int x)
      {
      }

      int main(void)
      {
      foo (i);
      return 0;
      }

      only two simple types and three keywords.

      You may know more about parsers than I (not hard)
      but specifing the grammar as reg exps sounds odd to me
      Why not modified Backus Naar? See the appendix in K&R
      for a C grammer.

      From the grammar a RDP should follow in quite a
      straitforward manner.

      Beware C is some tricky corners (eg. typedefs).


      --
      Nick Keighley



      Comment

      • vaib

        #4
        Re: newbee help : parser in C

        On Jun 20, 1:28 pm, Nick Keighley <nick_keighley_ nos...@hotmail. com>
        wrote:
        On 20 Jun, 09:01, vaib <vaibhavpang... @gmail.comwrote :
        >
        On Jun 20, 3:16 am, Antoninus Twink <nos...@nospam. invalidwrote:
        On 19 Jun 2008 at 21:27, vaib wrote:
        hi all . i am trying to build a parser in ANSI C .
        Check out yacc (aka bison).
        >
        i know what yacc (aka bison) does but i was avoiding to use tools .
        but yes it is a very good idea to look at the code generated by it .
        it might be of huge hepl . could you direct me to a grammar that yacc
        takes ?
        >
        my understanding is that the code produced by bison isn't very
        readable.
        You arn't meant to read it.
        >
        Look up Recursive Descent Parser and try something simpler
        than C to start with. Maybe a subset of C.
        >
        int i;
        float f;
        >
        int foo (int x)
        {
        >
        }
        >
        int main(void)
        {
            foo (i);
            return 0;
        >
        }
        >
        only two simple types and three keywords.
        >
        You may know more about parsers than I (not hard)
        but specifing the grammar as reg exps sounds odd to me
        Why not modified Backus Naar? See the appendix in K&R
        for a C grammer.
        >
        From the grammar a RDP should follow in quite a
        straitforward manner.
        >
        Beware C is some tricky corners (eg. typedefs).
        >
        --
        Nick Keighley
        yes Nick i got your point - do simpler things first and then move onto
        more complex issues . i was now thinking of using yacc first and i'm
        reading 'lex and yacc' for that purpose . yes now i know that i'll
        write a simple grammar in Backus Naur from and then make a recursive
        descent parser for the same . but can u tell me how to do it
        exactly ?? and no , i dont know about parsers more than you ( or
        anybody else for that matter - i'm just a beginner ) . thanks a lot .

        Comment

        • Nick Keighley

          #5
          Re: newbee help : parser in C

          On 25 Jun, 19:36, vaib <vaibhavpang... @gmail.comwrote :
          On Jun 20, 1:28 pm, Nick Keighley <nick_keighley_ nos...@hotmail. com>
          wrote:
          On 20 Jun, 09:01, vaib <vaibhavpang... @gmail.comwrote :
          On Jun 20, 3:16 am, Antoninus Twink <nos...@nospam. invalidwrote:
          On 19 Jun 2008 at 21:27, vaib wrote:
          >i am trying to build a parser in ANSI C .
          Check out yacc (aka bison).
          >
          Look up Recursive Descent Parser and try something simpler
          than C to start with. Maybe a subset of C.
          <snip>
          You may know more about parsers than I (not hard)
          but specifing the grammar as reg exps sounds odd to me
          Why not modified Backus Naar? See the appendix in K&R
          for a C grammer.
          >
          From the grammar a RDP should follow in quite a
          straitforward manner.
          >
          Beware C [has] some tricky corners (eg. typedefs).
          yes Nick i got your point - do simpler things first and then move onto
          more complex issues . i was now thinking of using yacc first and i'm
          reading 'lex and yacc' for that purpose . yes now i know that i'll
          write a simple grammar in Backus Naur from and then make a recursive
          descent parser for the same . but can u tell me how to do it
          exactly ?? and no , i dont know about parsers more than you ( or
          anybody else for that matter - i'm just a beginner )
          first hit:


          it has code as well

          --
          Nick Keighley


          Comment

          • user923005

            #6
            Re: newbee help : parser in C

            On Jun 26, 3:48 am, Nick Keighley <nick_keighley_ nos...@hotmail. com>
            wrote:
            On 25 Jun, 19:36, vaib <vaibhavpang... @gmail.comwrote :
            >
            On Jun 20, 1:28 pm, Nick Keighley <nick_keighley_ nos...@hotmail. com>
            wrote:
            On 20 Jun, 09:01, vaib <vaibhavpang... @gmail.comwrote :
            On Jun 20, 3:16 am, Antoninus Twink <nos...@nospam. invalidwrote:
            On 19 Jun 2008 at 21:27, vaib wrote:
            i am trying to build a parser in ANSI C .
            Check out yacc (aka bison).
            >
            Look up Recursive Descent Parser and try something simpler
            than C to start with. Maybe a subset of C.
            >
            <snip>
            >
            >
            >
            >
            >
            You may know more about parsers than I (not hard)
            but specifing the grammar as reg exps sounds odd to me
            Why not modified Backus Naar? See the appendix in K&R
            for a C grammer.
            >
            From the grammar a RDP should follow in quite a
            straitforward manner.
            >
            Beware C [has] some tricky corners (eg. typedefs).
            yes Nick i got your point - do simpler things first and then move onto
            more complex issues . i was now thinking of using yacc first and i'm
            reading 'lex and yacc' for that purpose . yes now i know that i'll
            write a simple grammar in Backus Naur from and then make a recursive
            descent parser for the same . but can u tell me how to do it
            exactly ?? and no , i dont know about parsers more than you ( or
            anybody else for that matter - i'm just a beginner )
            >
            first hit:
               http://en.wikipedia.org/wiki/Recursive_descent_parser
            >
            it has code as well
            Or even

            which gives over 37000 hits.

            Comment

            Working...