Java Interpreter mode (Interpreter Mode)

Source: Internet
Author: User

Java Interpreter mode (Interpreter Mode)
Interpreter definition: defines the grammar of a language and creates an Interpreter to explain sentences in the language. Interpreter seems to be not widely used. It describes how a language Interpreter is made up. In practice, we may seldom construct a language grammar. Let's take a simple look. First, you must create an interface to describe common operations. Public interface extends actexpression {void interpret (Context context);} Then, let's take a look at the specific implementation of public interface Context {} extends actexpression, which contains some global information other than the interpreter: terminator expressions and non-terminator expressions. Public class TerminalExpression implements extends actexpression {public void interpret (Context context) {}} for no rule in grammar, non-terminator expressions are required: public class NonterminalExpression implements limit actexpression {private limit actexpression successor; public void setSuccessor (effecactexpression successor) {this. successor = successor;} public response actexpression getSuccessor () {return successor;} public void interpret (Context context ){}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.