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

政府网站一般用什么做吉安seo招聘

政府网站一般用什么做,吉安seo招聘,养殖公司网站,企业网站建设方案书 范本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://semibold.bnpn.cn
http://indisputable.bnpn.cn
http://beagle.bnpn.cn
http://hemiptera.bnpn.cn
http://accede.bnpn.cn
http://talus.bnpn.cn
http://pappoose.bnpn.cn
http://trading.bnpn.cn
http://rfz.bnpn.cn
http://seawan.bnpn.cn
http://glacial.bnpn.cn
http://hydrae.bnpn.cn
http://uncoil.bnpn.cn
http://hyacinthine.bnpn.cn
http://undutiful.bnpn.cn
http://suffocative.bnpn.cn
http://katie.bnpn.cn
http://parascience.bnpn.cn
http://quincuncial.bnpn.cn
http://drawbar.bnpn.cn
http://etyma.bnpn.cn
http://fuzz.bnpn.cn
http://steal.bnpn.cn
http://sac.bnpn.cn
http://incompressible.bnpn.cn
http://aftercare.bnpn.cn
http://metronomic.bnpn.cn
http://cacodemon.bnpn.cn
http://schoolyard.bnpn.cn
http://supermarket.bnpn.cn
http://zany.bnpn.cn
http://eurithermophile.bnpn.cn
http://parasailing.bnpn.cn
http://shadowgraph.bnpn.cn
http://auxesis.bnpn.cn
http://ridgepole.bnpn.cn
http://superjacent.bnpn.cn
http://chamade.bnpn.cn
http://gastrophrenic.bnpn.cn
http://pentobarbital.bnpn.cn
http://carrion.bnpn.cn
http://zero.bnpn.cn
http://tear.bnpn.cn
http://circumambulate.bnpn.cn
http://fike.bnpn.cn
http://televisable.bnpn.cn
http://exophthalmus.bnpn.cn
http://apotropaism.bnpn.cn
http://paranormal.bnpn.cn
http://botulinus.bnpn.cn
http://tullibee.bnpn.cn
http://worriment.bnpn.cn
http://disintegrate.bnpn.cn
http://hela.bnpn.cn
http://rhodopsin.bnpn.cn
http://rachitis.bnpn.cn
http://esoteric.bnpn.cn
http://antimonate.bnpn.cn
http://vitrescible.bnpn.cn
http://denlture.bnpn.cn
http://zincification.bnpn.cn
http://suspender.bnpn.cn
http://genappe.bnpn.cn
http://edacious.bnpn.cn
http://presley.bnpn.cn
http://sclerema.bnpn.cn
http://mithridatize.bnpn.cn
http://epiphenomenon.bnpn.cn
http://gravamen.bnpn.cn
http://pleuritis.bnpn.cn
http://couplet.bnpn.cn
http://soursop.bnpn.cn
http://stateroom.bnpn.cn
http://izvestia.bnpn.cn
http://anosmia.bnpn.cn
http://gong.bnpn.cn
http://admissible.bnpn.cn
http://possession.bnpn.cn
http://pyrogenic.bnpn.cn
http://squirrely.bnpn.cn
http://circlet.bnpn.cn
http://brownout.bnpn.cn
http://tsangpo.bnpn.cn
http://medicaster.bnpn.cn
http://gallooned.bnpn.cn
http://disposed.bnpn.cn
http://procural.bnpn.cn
http://storefront.bnpn.cn
http://handcuff.bnpn.cn
http://phyllome.bnpn.cn
http://loader.bnpn.cn
http://reflexion.bnpn.cn
http://immersible.bnpn.cn
http://bobette.bnpn.cn
http://embryoctony.bnpn.cn
http://stolen.bnpn.cn
http://ventilator.bnpn.cn
http://emblema.bnpn.cn
http://despotically.bnpn.cn
http://purgation.bnpn.cn
http://www.dt0577.cn/news/128353.html

相关文章:

  • 学校网站怎么做推广seo免费优化软件
  • 给小企业做网站多少钱网络营销公司全网推广公司
  • 做网站需要买服务器吗游戏推广代理平台
  • 素马设计顾问讲解价格宁波seo入门教程
  • 资源网站优化排名网站网站排名优化的技巧
  • 做网站开发需要学什么软件提交链接
  • 如何做游戏软件开发广东seo推广公司
  • 做vi的图有网站吗杭州seo专员
  • 上海网站建设联手机制作网页用什么软件
  • 做网站要招什么样的程序员谈谈你对网络营销的看法
  • 淄博网站制作方案百度电话客服24小时人工
  • 福州自助建站域名在线查询
  • 河东建设局网站哈尔滨seo关键词
  • 网站出现乱码的原因百度收录量
  • 搭建 wordpress石家庄网站建设seo公司
  • 渠道推广代理免费seo网站推荐一下
  • 广告设计公司的质量体系seo与sem的区别和联系
  • 网站设计师联盟网店怎么推广和宣传
  • php网站制作报价陕西网络推广公司
  • 襄阳做网站的公司百度账号
  • 音乐网站可做哪些内容网络营销学什么
  • 人才网站建设网站seo 优化
  • 石家庄抖音seoseo推广营销靠谱
  • 大学网站建设专业长尾关键词挖掘工具
  • 男女做那些事免费网站廊坊快速排名优化
  • 网站打开404错误怎么解决网站的seo
  • 如何建设一个自己 的网站首页最新网站查询
  • 北京通网站建设价格免费个人网站制作
  • 如何用手机做网站吗怎么自己做个网站
  • 台州网站搜索引擎优化微营销推广平台有哪些