我怎样写在C或Objective-C的解析器没有一个解析器生成? [英] How do I write a parser in C or Objective-C without a parser generator?

查看:113
本文介绍了我怎样写在C或Objective-C的解析器没有一个解析器生成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在C或Objective-C的计算器接受沿着

I am trying to make a calculator in C or Objective-C that accepts a string along the lines of

8/2+4(3*9)^2

和返回答案,2920我preFER不使用像莱克斯或者Yacc的发电机,所以我想code将其从地上爬起来。我应该如何去这样做呢?除了龙书,是否有任何建议文本,涵盖这个主题?

and returns the answer 2920. I would prefer not to use a generator like Lex or Yacc, so I want to code it from the ground up. How should I go about doing this? Other than the Dragon book, are there any recommended texts that cover this subject matter?

推荐答案

试试这个:

http://en.wikipedia.org/wiki/Shunting-yard_algorithm

这篇关于我怎样写在C或Objective-C的解析器没有一个解析器生成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆