讲解:C++:CSCI104 String ExpressionC/C++ Assignment

代写一个字符串表达式解析器引擎,并计算表达式的值。RequirementYour task is to write a program that will read expressions consisting of strings and operations from a file, and evaluate and show the output of the given expression.String expressions consist of strings, the operators + (concatenate), - (remove), < (remove end), and > (remove start), along with parentheses to specify a desired order of operations. The < operator indicates you should delete the last character of the string, unless the string consists of only a single character, in which case you should not change the string. The > operator indicates you should delete the first character of the string, unless the string consists of only a single character, in which case you should not change the string. The + operator indicates you should append the second string to the end of the first string. The - operator indicates that you should remove the first instance of the second string from the first string (the first string is returned unmodified if there is no match).String expressions are defined formally as follows:Any string of 1 or more letters a-z (lower-case only) is a string expression.If Y1, Y2, …, Yk are string expressions (for k > 1) then the following are string expressions:

Y1(Y1-Y2)(Y1+Y2+Y3+...+Yk)Notice that our format rules out the expression ab+bc, since it is missing the parentheses. It also rules out (ab+bc-b) which would have to instead be written ((ab+bc)-b), so you never have to worry about precedence. This should make your parsing task significantly easier. Whitespace may occur in arbitrary places in string expressions, but never in the middle of a string of letters. Each expression will be on a single line.Examples (the first four are valid, the other four are not):(<>yoda+go )) // evaluates to b <> <<<((eve + boo+buzz) - >< ((<>zelda)- ><

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 9,539评论 0 13
  • 本文转载自知乎 作者:季子乌 笔记版权归笔记作者所有 其中英文语句取自:英语流利说-懂你英语 ——————————...
    Danny_Edward阅读 43,964评论 4 38
  • Thanks you very much for sharing this book with me. I’m r...
    骆蔚阅读 413评论 0 0
  • 最近最热门的一个话题莫过于网络红语:996 自从某知名公司提出996后,社会各界单位人员都不淡定了。...
    美丽玲珑阅读 397评论 0 3
  • 无可厚非,信息安全是互联网技术中非常重要的一块,所以觉得有必要系统学习一下几种java的加密方法。 一、DES D...
    方凌川阅读 7,792评论 0 0