definition: Given a language, defines a representation of his grammar, and defines an interpreter that uses the representation to interpret a sentence in a language.Type: behavior class patternclass Diagram:
Interpreter mode is a less used mode, I have not used this model before. Now let's take a look at the interpreter pattern.structure of the
Interpreter pattern (interpreter pattern): Given a language, defines a representation of its grammar and defines an interpreter that uses that representation to interpret sentences in the language.Here is a demo of the Interpreter mode:1 #!/usr/bin/env python2 #-*-coding:utf-8-*-3 4 __author__='Andy'5 """6 Liar design
This article has two purposes: one is to tell the general method of implementing the computer language interpreter, and the other is to show how to use Python to realize a subset of the scheme of Lisp dialect. I refer to my interpreter as Lispy (lis.py). A few years ago, I introduced how to write a scheme interpreter using Java, and I also wrote a version using C
Hello, world
[dongsong@bogon python_study]$ cat py.cpp #include
Original official documentationHttp://docs.python.org/3/extending/embedding.html5. Embedding Python in Another Application
In the previous chapter, we discussed how to extend Python, that is, to extend Python functions by connecting to the C function library. There is also a way to do this: enrich our C/C ++ applications by embedding Python. Embedded so that our program can use Python to implement certain functions, rather than u
There's a question on StackOverflow about the comparison between Java and Python, and there are questions about why Java's runtime is called a JVM, and Python is called interpreter.This problem is estimated not many people think, first look at Wikipedia to see the definition of virtual machine.There are 2 definitions of virtual machines, one is a VMware-like system virtual machine, and the other is a virtual machine called a program virtual machine, such as JVM,CLR, which is the most common virt
StatementIn order to improve the quality of teaching, my college is planning to prepare C language teaching materials. "Write the Interpreter in C language" series of articles after finishing will be revenue book "comprehensive Experiment" chapter. Therefore, the main reading of this series of articles for students who have just finished C language (not requiring data structure and other knowledge), so the wording is more verbose, do not be offended.
])==0) {printf ("type: external command \ n"); printf ("the dir\t internal command displays the files and subdirectories in a directory. \ n"); printf ("the cd\t internal command displays the name of the current directory or changes it. \ n"); printf ("md\t Internal command to create a directory. \ n"); printf ("rd\t Internal command to delete directory: \ n"); printf ("cls\t Internal command clears the screen. \ n"); printf ("date\t The internal command to display or set the date. \ n"); printf
Assume that a text box in the system allows the user to enter a string expression, such"5 Division 2 multiplication 3 modulo 4 multiplication 6", The system is required to be able to calculate the expression result according to the Java integer multiplication and division operation rules, such as 12.
Assume that the system allows the user to input a string expression in a text box, such as"List name age student ID sortby student IDThe system is required to extract student information from the da
Mono has perfected its own on-the-fly compilers and static compilers through new ways of running code.In 2001, the Mono project officially began, and the Mono development team wrote an interpreter for the. NET instruction set to boot a self-hosted. NET development environment on Linux.It was thought that the interpreter was just a temporary tool that could be used when creating a just-in-time (JIT) compiler
This article has two purposes: one is to describe a common method for implementing a computer language interpreter, and the other is to highlight how to use Python to implement a subset of the Lisp scheme. I refer to my interpreter as Lispy (lis.py). A few years ago, I introduced how to write a scheme interpreter using Java, and I also wrote a version using Commo
2. Use the Python interpreter 2.1. Invocation of the Python interpreterPython interpreter is usually installed in the machine /usr/local/bin/python3.6 directory, if the directory is available, use your Unix shell to search the /usr/local/bin directory and type the following command to start: [1]python3.6Since the choice of the directory where the Interpreter live
I. Introduction
In fact, there is no good example to introduce the interpreter mode, because it describes how to form a simple language interpreter, mainly used in the use of object-oriented language development compilers; in practical applications, we may rarely encounter the situation of constructing a language grammar.
Although you can hardly use this model, you can still be inspired by it.
Ii. De
18.3 interpreter mode Overview
The interpreter mode is a design mode that uses a relatively low frequency but is difficult to learn. It is used to describe how to use object-oriented languages to form a simple language interpreter. In some cases, to better describe certain types of problems, we can create a new language that has its own expressions and structures
These two days there are many Python small white to join the learning group, and asked a lot of questions about Pycharm Basic use, today's small series to configure the Python interpreter problem to give you a simple ramble.1, generally, when we start pycharm, if pycharm normal activation, it will go directly into the pycharm, and pycharm often pop-up interface. (If there is a small partner pycharm has not been activated, you can stand in private mess
Design One, primer
In fact, there is no good example to introduce the interpreter pattern, because it describes how to form a simple language interpreter, the main application in the use of object-oriented language development compiler; In practical applications, we may rarely encounter the syntax to construct a language.
Although you can hardly use this model, it is still possible to get some inspiration
Introductionconcept: given a language, define a representation of its grammar and define an interpreter that uses that representation to interpret sentences in the language.Application Scenario: language Interpreter (translates the code we can read into an ugly machine code)Benefits: use complex things in a simple way.ExampleInterpreter Package Note.com.interpreter; /** @author*/Publicclass
Introduction
People who work with shell are familiar with shell programming in Unix/Linux. # is mentioned in all shell programming books #! /Bin/bash. What exactly does it contain? What does this string mean for the operating system? You may say, isn't it true that the/bin/bash program will be used to explain the script program? Of course you are right. Let's look at our title. Here we will talk about the interpreter. Let's take a look at what the fir
In the book "Java and Patterns" of Dr. Shanhong, this describes the interpreter (interpreter) Pattern:The interpreter pattern is the behavior pattern of the class. Given a language, the interpreter pattern can define a representation of its grammar and provide an interpreter
People who work with shell are familiar with shell programming in Unix/Linux. # is mentioned in all shell programming books #! /Bin/bash. What exactly does it contain? What does this string mean for the operating system? You may say, isn't it true that the/bin/bash program will be used to explain the script program? Of course you are right. Let's look at our title. Here we will talk about the interpreter. Let's take a look at what the first sentence i
2006.6.1 Li Jianzhong
Motivation)
In the process of software building, if the problems in a specific field are complicated and similar models are repeated, the implementation of common programming methods will face frequent changes.
In this case, the problem in a specific field is expressed as a sentence under a certain syntax rule, and then an interpreter is constructed to explain such a sentence, so as to solve the problem.
Intent)
Given a language
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.