Loading ...
Sorry, an error occurred while loading the content.

Lists and recursive descent parsers

Expand Messages
  • Mike Austin
    Hi all. I have a partial recursive descent parser working... the only thing I m not sure of is how to deal with lists of things, such as arguments. It seems
    Message 1 of 1 , Oct 2, 2006
    • 0 Attachment
      Hi all. I have a partial recursive descent parser
      working... the only thing I'm not sure of is how to
      deal with lists of things, such as arguments. It
      seems possible that you can either use recursion or a
      loop. Given the expression "x cos, y sin", does this
      seem like the right track (in pseudo-python)?

      def expression( expr )
      token = stream.nextToken

      if token.type == IDENTIFIER
      expr.push( token.value )
      return message( expr )

      return false


      def message( expr )
      token = stream.nextToken

      if token.type == IDENTIFIER
      expr.push( token.value );
      message( expr )

      if token.type == COMMA
      list = []
      list.push( [expr.pop()] )

      expr = expresssion( [] )
      while expr:
      list.push( expr )
      expr = expresssion( [] )


      Peace,
      Mike

      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com
    Your message has been successfully submitted and would be delivered to recipients shortly.