In the book Design Patterns, written by the Gang of Four, the following is stated in the 'Applicability' section of the Interpreter pattern:
efficiency is not a critical concern. The most efficient interpreters are usually not implemented by interpreting parse trees directly but by first translating them into another form. For example, regular expressions are often transformed into state machines.
- Why is interpreting parse trees directly not efficient?
- How do state machines help in improving this efficiency?
- Are state machines more efficient then an Abstract Syntax Tree for 'interpretation' of a sentence? If so, why?
I viewed AST and state machine articles on the internet:
- https://www.pearsonhighered.com/assets/samplechapter/0/3/2/1/0321112547.pdf
- https://ljvmiranda921.github.io/notebook/2022/10/07/finite-state-automata/
- https://www.cs.cornell.edu/courses/cs2112/2018fa/recitations/07ast/ast.pdf
Unfortunately, I wasn't able to find the answer to the questions stated in the problem section. The reason for that could be that I don't fully comprehend the 'Applicability' section of the Interpreter pattern. As a result not formulating the right questions.
Aucun commentaire:
Enregistrer un commentaire