|
-
March 24th, 2009, 08:16 AM
#1
Why Interpreter Pattern can not be used for complex grammar
HI, guys,
I have a question about the Interpreter Pattern. I think that pattern is good and flexible. But according to information from some websites, it is said the g++ compiler and microsoft visual c++ compiler are all hand written recursive descent parser. I think Interpreter Pattern is the most natural way to implement a recursive descent parser in OO way. I meet with the problem when I was reading source code of Lua 5.1. It seems neither g++ or microsoft c++ compiler choose Interpreter Pattern as an approach for implementation.
Besides, in a web page( http://www.vincehuston.org/dp/interpreter.html ) I saw this "The pattern doesn't address parsing. When the grammar is very complex, other techniques (such as a parser) are more appropriate." I don't understand why Interpreter Pattern is not capable of complex grammar. Please help me understand if you have any clue of this.
Btw, I don't understand why they use recursive descent parser other than Yacc to generate a parser. Yacc doesn't have to trace back during parsing and Yacc is capable of doing some optimization to state switch table of parser.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|