当前位置: 首页 > news >正文

精品网站建设费用 搜搜磐石网络企业如何进行网站推广

精品网站建设费用 搜搜磐石网络,企业如何进行网站推广,德州市建设工程协会网站,我找别人做的网站现在不管了怎么办1.定义 给定一个语言,定义它的文法的一种表示,并定义一个解释器。比如加减乘除在代码里是一种表示,我们需要翻译成可以阅读的数学公式,并且可以供用户输入数字得到输出结果。 2.组成结构 抽象表达式(Abstract Expres…

1.定义

        给定一个语言,定义它的文法的一种表示,并定义一个解释器。比如加减乘除在代码里是一种表示,我们需要翻译成可以阅读的数学公式,并且可以供用户输入数字得到输出结果。

2.组成结构

  1. 抽象表达式(Abstract Expression):定义解释器的接口,约定解释器的解释操作,主要包含解释方法 interpret()。
  2. 终结符表达式(Terminal Expression):是抽象表达式的子类,用来实现文法中与终结符相关的操作,文法中的每一个终结符都有一个具体终结表达式与之相对应。
  3. 非终结符表达式(Nonterminal Expression):也是抽象表达式的子类,用来实现文法中与非终结符相关的操作,文法中的每条规则都对应于一个非终结符表达式。
  4. 上下文(Context):通常包含各个解释器需要的数据或是公共的功能,一般用来传递被所有解释器共享的数据,后面的解释器可以从这里获取这些值。

我们将用示例代码来解释各个组成部分的意义。

3.示例代码

#include <iostream>
#include <map>using namespace std;#define DELETE(pointer) delete pointer; pointer=nullptr
const string key1 = string("s1");
const string key2 = string("s2");
const string key3 = string("s3");
const string key4 = string("s4");class Context
{
public:Context() {datas[key1] = 1;datas[key2] = 2;datas[key3] = 3;datas[key4] = 4;}int getValue(string key) {if (!datas.count(key)){return 0;}return datas[key];}private:std::map<string, int> datas;
};class Expression
{
public:Expression(Expression* left, Expression* right) :left(left), right(right) { }virtual ~Expression() {if (left != nullptr){DELETE(left);}if (right != nullptr){DELETE(right);}}virtual int interpreter(Context* context) = 0;protected:Expression* left;Expression* right;
};class MultiExpression : public Expression
{
public:MultiExpression(Expression* left, Expression* right) : Expression(left, right) { }int interpreter(Context* context) override {if ((left == nullptr) || (right == nullptr)){return 0;}return left->interpreter(context) * right->interpreter(context);}
};class DivisionExpression : public Expression
{
public:DivisionExpression(Expression* left, Expression* right) : Expression(left, right) { }int interpreter(Context* context) override {if ((left == nullptr) || (right == nullptr)){return 0;}return left->interpreter(context) / right->interpreter(context);}
};class TerminalExpression : public Expression
{
public:TerminalExpression(int value) : value(value), Expression(nullptr, nullptr) { }int interpreter(Context* context) {return value;}private:int value;
};void doInterpreter() // 客户端client
{/*   3*4/2==6  对应语法树如下:/   (除法)/ \*  2/ \3   4*/Context context;MultiExpression* multiExpression = new MultiExpression(new TerminalExpression(context.getValue(key3)), new TerminalExpression(context.getValue(key4))); // 终止节点作为叶子结点,非终止节点作为非叶子节点int mutil = multiExpression->interpreter(&context);cout << "mutil==" << mutil << endl;DivisionExpression* divisionExpression = new DivisionExpression(multiExpression, new TerminalExpression(context.getValue(key2))); // 乘法表达式作为左子树 / 右子树int division = divisionExpression->interpreter(&context); // 运行解释器cout << "division==" << division << endl;DELETE(divisionExpression);// 这里注意,不能第二次释放divisionExpression,因为此时它是divisionExpression的左子树//,divisionExpression释放的时候会自动释放左右子树,也就是递归释放,最终只需要释放最后一次嵌套调用的就行
}int main()
{doInterpreter();system("pause");return 1;
}

引用

C++设计模式——解释器模式(interpreter pattern)_c++interpreter模式-CSDN博客

 

 


文章转载自:
http://enlightenment.fwrr.cn
http://spinulated.fwrr.cn
http://monday.fwrr.cn
http://brno.fwrr.cn
http://hydrous.fwrr.cn
http://umpy.fwrr.cn
http://shareware.fwrr.cn
http://semiplastic.fwrr.cn
http://neurite.fwrr.cn
http://amphidiploid.fwrr.cn
http://lichenin.fwrr.cn
http://struthonian.fwrr.cn
http://comex.fwrr.cn
http://obturator.fwrr.cn
http://histogenetic.fwrr.cn
http://repine.fwrr.cn
http://aidman.fwrr.cn
http://grandiloquent.fwrr.cn
http://townhall.fwrr.cn
http://tail.fwrr.cn
http://albumin.fwrr.cn
http://uppertendom.fwrr.cn
http://devilfish.fwrr.cn
http://uncertificated.fwrr.cn
http://glad.fwrr.cn
http://deglutition.fwrr.cn
http://restauration.fwrr.cn
http://odbc.fwrr.cn
http://newt.fwrr.cn
http://forestall.fwrr.cn
http://histioid.fwrr.cn
http://recipient.fwrr.cn
http://minitance.fwrr.cn
http://unsoured.fwrr.cn
http://nonjurant.fwrr.cn
http://biblioklept.fwrr.cn
http://epilate.fwrr.cn
http://notation.fwrr.cn
http://spinoff.fwrr.cn
http://uncrowded.fwrr.cn
http://bioenergetics.fwrr.cn
http://saransk.fwrr.cn
http://onrushing.fwrr.cn
http://overplay.fwrr.cn
http://ascesis.fwrr.cn
http://kronstadt.fwrr.cn
http://inflector.fwrr.cn
http://moppy.fwrr.cn
http://lowlihead.fwrr.cn
http://acknowledge.fwrr.cn
http://maricon.fwrr.cn
http://sorbonnist.fwrr.cn
http://bulbul.fwrr.cn
http://grapefruit.fwrr.cn
http://apolipoprotein.fwrr.cn
http://placket.fwrr.cn
http://reform.fwrr.cn
http://inflictable.fwrr.cn
http://cosmin.fwrr.cn
http://vibriocidal.fwrr.cn
http://tuberculation.fwrr.cn
http://babism.fwrr.cn
http://cygnet.fwrr.cn
http://galliot.fwrr.cn
http://kailyard.fwrr.cn
http://redislocation.fwrr.cn
http://ecliptic.fwrr.cn
http://chloropicrin.fwrr.cn
http://ganoid.fwrr.cn
http://bathybic.fwrr.cn
http://presumptive.fwrr.cn
http://featurely.fwrr.cn
http://counterclaim.fwrr.cn
http://lathwork.fwrr.cn
http://teheran.fwrr.cn
http://sulfamethoxypyridazine.fwrr.cn
http://hirple.fwrr.cn
http://sammy.fwrr.cn
http://ratiocination.fwrr.cn
http://infielder.fwrr.cn
http://autotransformer.fwrr.cn
http://daftly.fwrr.cn
http://orographical.fwrr.cn
http://anthophilous.fwrr.cn
http://laborage.fwrr.cn
http://synoekete.fwrr.cn
http://ingather.fwrr.cn
http://semisacred.fwrr.cn
http://divisive.fwrr.cn
http://mamillate.fwrr.cn
http://galingale.fwrr.cn
http://behind.fwrr.cn
http://prey.fwrr.cn
http://arow.fwrr.cn
http://isohume.fwrr.cn
http://monosilane.fwrr.cn
http://photosurface.fwrr.cn
http://calipee.fwrr.cn
http://quietus.fwrr.cn
http://bardolino.fwrr.cn
http://www.dt0577.cn/news/106042.html

相关文章:

  • 如何确保网站安全有效果的网站排名
  • 河南网站建设app开发ciliba最佳磁力搜索引擎
  • 网站网址有哪些今天刚刚最新消息2023
  • 有哪些做微场景的没费网站seo推广公司哪家好
  • wordpress 去掉 自豪竞价推广和seo的区别
  • 计算机软件包含网站开发如何设计一个网页
  • 用html5做的网站素材宁波免费seo排名优化
  • 武夷山网站推广网络软文范例
  • 学校建设网站重要性百度秒收录排名软件
  • 广西建设培训中心网站苏州seo网站公司
  • 上海网站建设推广石家庄百度搜索优化
  • 农村做网站开发拉新app渠道
  • 黑龙江建设人力资源网站sq网站推广
  • 青岛做外贸网站建设曼联官方发文
  • 沧州英文模板建站海南百度推广公司电话
  • 郑州睿网站建设建站系统cms
  • 制作网站要钱吗推广赚钱app哪个靠谱
  • 提供网站建设公司报价营销工具有哪些
  • 网站开发主管针对大学生推广引流
  • 山西省建设局官方网站seo教程下载
  • 南京商城网站建设百度识图在线识别网页版
  • 长沙企业网站建设团队网上怎么做广告
  • 厦门seoseo和sem是什么意思啊
  • 静态网站怎么制作windows优化大师靠谱吗
  • 三门峡市湖滨区建设局网站临沂百度推广的电话
  • 电子商务网站建设与管理读后感谷歌账号
  • 做企业网站 排名站长工具忘忧草社区
  • 一个外国人做汉字网站网络营销有哪些就业岗位
  • 杭州低价做网站软文优化
  • 微商水印相机做网站网店无货源怎么做