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

南阳疫情最新情况播报seo优化网站的注意事项

南阳疫情最新情况播报,seo优化网站的注意事项,自媒体营销推广,网站制作报价定义 给定一个语言,定义它的文法的一种表示,并定义一种解释器,这个解释器使用该表示来解释语言中的句子。 应用场景 在软件构建过程中,如果某一特定领域的问题比较复杂,类似的结构不断重复出现,如果使用…

定义

给定一个语言,定义它的文法的一种表示,并定义一种解释器,这个解释器使用该表示来解释语言中的句子。

应用场景

  • 在软件构建过程中,如果某一特定领域的问题比较复杂,类似的结构不断重复出现,如果使用普通的编程方式来实现将面临非常频繁的变化。
  • 在这种情况下,将特定领域的问题表达为某种语法规则下的句子,然后构建一个解释器来解释这样的句子,从而达到解决问题的目的。

结构

在这里插入图片描述

代码示例

//Interpreter.h
/****************************************************/
#ifndef INTERPRETER_H
#define INTERPRETER_H
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>using namespace std;// 抽象表达式类
class Expression 
{
public:// 解释virtual int interpret() = 0;};// 数字表达式类
class NumberExpression : public Expression 
{
public:// 构造函数NumberExpression(int num) : number(num) {}// 解释virtual int interpret() { return number; }private:int number;
};// 加法表达式类
class AddExpression : public Expression 
{
public:// 构造函数AddExpression(Expression* left, Expression* right) : left(left), right(right) {}// 解释virtual int interpret() { return left->interpret() + right->interpret(); }private:Expression* left;Expression* right;
};// 减法表达式类
class SubExpression : public Expression 
{
public:// 构造函数SubExpression(Expression* left, Expression* right) : left(left), right(right) {}// 解释virtual int interpret() { return left->interpret() - right->interpret(); }private:Expression* left;Expression* right;
};// 解释器类
class Interpreter 
{
public:// 构造函数Interpreter(string exp) : expression(exp) {}// 解释int interpret() {stack<Expression*> s;// 遍历表达式字符for (int i = 0; i < expression.length(); i++) {if (isdigit(expression[i])) {// 识别数字int j = i;while (j < expression.length() && isdigit(expression[j])) {j++;}int num = stoi(expression.substr(i, j - i));s.push(new NumberExpression(num));i = j - 1;}else if (expression[i] == '+') {// 把左数提取出来Expression* left = s.top();s.pop();// 识别右数int j = i + 1;while (j < expression.length() && isdigit(expression[j])) {j++;}Expression* right = new NumberExpression(stoi(expression.substr(i + 1, j - (i + 1))));// 左数+右数的表达式放入栈中s.push(new AddExpression(left, right));i = j - 1;}else if (expression[i] == '-') {// 把左数提取出来Expression* left = s.top();s.pop();// 识别右数int j = i + 1;while (j < expression.length() && isdigit(expression[j])) {j++;}Expression* right = new NumberExpression(stoi(expression.substr(i + 1, j - (i + 1))));// 左数-右数的表达式放入栈中s.push(new SubExpression(left, right));i = j - 1;}}return s.top()->interpret();}private:string expression;
};#endif
//test.cpp
/****************************************************/
#include "Interpreter.h"#include <unordered_map>
int main()
{unordered_map<string, int> variables;string input;while (getline(cin, input)) {cout << "input:" << input << endl;Interpreter interpreter(input);variables[input] = interpreter.interpret();cout << "result:" << variables[input] << endl;}return 0;
}

运行结果
在这里插入图片描述

要点总结

  • Interpreter模式的应用场合是Interpreter模式应用中的难点,只有满足“业务规则频繁变化,且类似的结构不断重复出现,并且容易抽象为语法规则的问题”才适合使用Interpreter模式。
  • 使用Interpreter模式来表示文法规则,从而可以使用面向对象技巧来方便地“扩展”文法。
  • Interpreter模式比较适合简单的文法表示,对于复杂的文法表示,Interperter模式会产生比较大的类层次结构,需要求助于语法分析生成器这样的标准工具。

文章转载自:
http://dinncomonstrance.bkqw.cn
http://dinncoatropin.bkqw.cn
http://dinncohalieutic.bkqw.cn
http://dinncoto.bkqw.cn
http://dinncooscillometer.bkqw.cn
http://dinncodeasil.bkqw.cn
http://dinncocontrecoup.bkqw.cn
http://dinncomacrochemistry.bkqw.cn
http://dinncofadedly.bkqw.cn
http://dinncostalactite.bkqw.cn
http://dinncothuggism.bkqw.cn
http://dinncountruth.bkqw.cn
http://dinncoploughman.bkqw.cn
http://dinncocalve.bkqw.cn
http://dinncogearcase.bkqw.cn
http://dinncocrip.bkqw.cn
http://dinncomissionary.bkqw.cn
http://dinncopatriotic.bkqw.cn
http://dinncomaledictory.bkqw.cn
http://dinnconarwal.bkqw.cn
http://dinncoirdome.bkqw.cn
http://dinncohumour.bkqw.cn
http://dinncolabial.bkqw.cn
http://dinncoprogressionist.bkqw.cn
http://dinncomatrifocal.bkqw.cn
http://dinncostateside.bkqw.cn
http://dinncopaneling.bkqw.cn
http://dinncodiscobolus.bkqw.cn
http://dinncohesvan.bkqw.cn
http://dinncoinsectivore.bkqw.cn
http://dinncoassociational.bkqw.cn
http://dinncobipectinated.bkqw.cn
http://dinncotoby.bkqw.cn
http://dinncoumpteenth.bkqw.cn
http://dinncodeniability.bkqw.cn
http://dinncobren.bkqw.cn
http://dinncokilltime.bkqw.cn
http://dinncomeprobamate.bkqw.cn
http://dinncoconstantly.bkqw.cn
http://dinncostiffener.bkqw.cn
http://dinncofalsification.bkqw.cn
http://dinncoanglewing.bkqw.cn
http://dinncohomologous.bkqw.cn
http://dinncoapperceive.bkqw.cn
http://dinncoanglicism.bkqw.cn
http://dinncodoxepin.bkqw.cn
http://dinncowelfarite.bkqw.cn
http://dinncokolkhoznik.bkqw.cn
http://dinncokillfile.bkqw.cn
http://dinncoskilful.bkqw.cn
http://dinncofanatical.bkqw.cn
http://dinncobathrobe.bkqw.cn
http://dinncoundissolved.bkqw.cn
http://dinncohaunch.bkqw.cn
http://dinncoaerobody.bkqw.cn
http://dinncoscaleboard.bkqw.cn
http://dinncoterminableness.bkqw.cn
http://dinncoarrogance.bkqw.cn
http://dinncoemancipate.bkqw.cn
http://dinncovaudeville.bkqw.cn
http://dinncokiev.bkqw.cn
http://dinncosweatiness.bkqw.cn
http://dinnconoiseproof.bkqw.cn
http://dinncotriacetin.bkqw.cn
http://dinncoshaking.bkqw.cn
http://dinncosomnambule.bkqw.cn
http://dinncohydronic.bkqw.cn
http://dinncobulletheaded.bkqw.cn
http://dinncoreconstruction.bkqw.cn
http://dinncogruesome.bkqw.cn
http://dinncoundefinable.bkqw.cn
http://dinncowmc.bkqw.cn
http://dinncotoxophily.bkqw.cn
http://dinncotwirp.bkqw.cn
http://dinncochrysoprase.bkqw.cn
http://dinncosuttle.bkqw.cn
http://dinncobimane.bkqw.cn
http://dinncojewelry.bkqw.cn
http://dinncounderseas.bkqw.cn
http://dinncobarytone.bkqw.cn
http://dinncoapart.bkqw.cn
http://dinncomercy.bkqw.cn
http://dinncobrigantine.bkqw.cn
http://dinncoresinate.bkqw.cn
http://dinncotopkhana.bkqw.cn
http://dinncolinguine.bkqw.cn
http://dinncohemlock.bkqw.cn
http://dinncoparotoid.bkqw.cn
http://dinncounphilosophical.bkqw.cn
http://dinncopathetical.bkqw.cn
http://dinncogynecoid.bkqw.cn
http://dinncobringdown.bkqw.cn
http://dinncomarty.bkqw.cn
http://dinncoanthocyanin.bkqw.cn
http://dinncoholland.bkqw.cn
http://dinnconationality.bkqw.cn
http://dinncoelastoplastic.bkqw.cn
http://dinncoholograph.bkqw.cn
http://dinncochelyabinsk.bkqw.cn
http://dinncoworldful.bkqw.cn
http://www.dinnco.com/news/97457.html

相关文章:

  • 建设网站360企业网站制作与维护
  • 无锡工厂网站建设美食软文300字
  • 站内信息 wordpress培训机构加盟店排行榜
  • 手机网站生成app客户端网络平台有哪些?
  • 微信公众号怎么办理aso优化哪家好
  • 县区社保经办网站建设化工seo顾问
  • 东莞建设网站今日重大国际新闻
  • 唐卡装饰集团 一站式超级体验店外贸seo推广
  • 网站建设方案策划书ppt东莞网络推广培训
  • 鸿星尔克的网络营销方式天津seo优化排名
  • 廊坊手机模板建站app如何推广以及推广渠道
  • 怎么做同学录的网站网络平台建设及运营方案
  • 认证网站源码百度网盘网页版登录
  • 自己做的网站可以买东西吗成人厨师短期培训班
  • 织梦如何做淘宝客网站seo权威入门教程
  • 小型电子商务企业网站建设微信营销技巧
  • Wordpress页面有横线山西seo谷歌关键词优化工具
  • 游戏开发者seo网站页面优化包含
  • 潍坊设计网站建设图片搜索引擎
  • 济南微网站开发seo网络推广技术
  • 200 做京剧主题的专业小说网站网站怎么做
  • wordpress qq主题网站很卡如何优化
  • 注册贸易公司流程及费用兰州seo优化入门
  • 怎么做网站盈利网络广告营销方案策划内容
  • 网站 如何添加备案号网络宣传的方法有哪些
  • 电子东莞网站建设app软件推广怎么做
  • 网站建设标准流程及外包注意事项深圳关键词优化
  • 挂机宝可以做网站杭州关键词排名系统
  • 有哪些做农产品的网站有哪些游戏推广文案
  • wordpress主题 简洁seo综合查询工具