In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
In this article, the editor introduces in detail "who are the participants in the web interpreter mode", the content is detailed, the steps are clear, and the details are handled properly. I hope this article "what are the participants in the web interpreter mode" can help you solve your doubts? let's follow the editor's ideas to learn new knowledge.
Applicability
If a language can be represented as an abstract syntax tree that is simple enough, and efficiency is not the most important factor, you can use the interpreter pattern.
structure
Participant
Abstract_Expression (abstract expression, such as Expr)
-declares an abstract interpretation operation that is shared by all subclasses.
Nonterminal_Expression (non-Terminator expressions, such as AdditiveExpr, MultiplicativeExpr, etc.)
-all syntax nodes in a grammar that can be decomposed into a combination of subordinate syntax nodes need a NonterminalExpression class to implement their functions.
-NonterminalExpression maintains a list of AbstractExpression types for subordinate syntax nodes.
-implement the Interpret operation. In addition to recursively calling the interpretation operation that represents the subordinate syntax node, Interpret can also further calculate the interpretation results of each node. For example, AdditiveExpr needs to perform a generalized (addition or subtraction) addition calculation for the interpretation results of each MultiplicativeExpr.
Terminal_Expression (Terminator expression, such as IntegerLiteral, etc.)
-directly implement simple operations or calculations in grammar.
Context (context)
-contains some global information outside the interpreter.
Client (customer)
-build a syntax tree.
-invoke the interpretation operation.
Collaboration
Client builds an abstract syntax tree. The context is then initialized and the interpretation operation is invoked. Building a syntax tree can also be implemented as a function of syntax node classes. After all, the one who is most familiar with the syntax node is the grammar node class itself.
Each non-Terminator expression node invokes the interpretation operation of the corresponding subexpression and synthesizes the processing result. Each Terminator expression is responsible for simple processing or computation that does not depend on other nodes.
The interpretation operation of each node can store and access the state of the interpreter through context. For example, obtaining or storing calculation results, obtaining pre-defined constants, calling pre-logged-in functions, and so on, all need to be implemented through context.
After reading this, the article "who are the participants in the web interpreter mode" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it. If you want to know more about the article, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.