Recursive Descent Parsers

Sharky Forums


Results 1 to 3 of 3

Thread: Recursive Descent Parsers

  1. #1
    Expensive Sushi cjohnson's Avatar
    Join Date
    Oct 2002
    Location
    North Carolina
    Posts
    35

    Recursive Descent Parsers

    I think I'm going to write a simple parser/interpreter for a small language as a project in my languages class. My professor said he discouraged the use of parser generators, and suggested a recursive descent parser instead. Can anyone point me to information about these or give me an overview of them. I looked on google a little big, but didn't find much that was helpful. Thanks in advance.
    <wik> /bin/finger that girl in the back row of machines

  2. #2
    Hammerhead Shark EverlastingGod's Avatar
    Join Date
    Feb 2003
    Location
    MD
    Posts
    1,364
    Basically you have a function for each non-terminal. That function matches terminals and calls the other non-terminal functions to parse them.

    Ex: A, B, C are non-terminals, d, e, f are terminals

    A -> B d e f C

    Your A function would be something like:
    Code:
    void A()
    {
      B();
      match(d);
      match(e);
      match(f);
      C();
    }
    Sorry, I know that wasn't a good explanation.
    Stay cool
    and be somebody's fool this year

  3. #3
    Hammerhead Shark
    Join Date
    Feb 2001
    Posts
    1,612
    http://pages.cpsc.ucalgary.ca/%7Erob.../webnotes.html

    Check out the notes and the links at the bottom. I got up to the LR parsers before I got confused.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •