简体   繁体   English

解析方程式

[英]Parsing an equation erlang

I am learning erlang recently and I have a question. 我最近正在学习erlang,并且有一个问题。

I have an equation like this (~(2+1)). 我有一个像这样的方程(〜(2 + 1))。 I want to parse to polish notation? 我想解析波兰语符号吗? For eg.{unaryMin{add,2,1}} 例如{unaryMin {add,2,1}}

How do I start? 我该如何开始?

If you want to parse something, from a simple formula to a programming language, you should start by learning about grammar , language and Compiler-compiler . 如果要解析从简单公式到编程语言的内容,则应先学习语法语言Compiler-compiler Learning how to parse and translate/interpret something to another format is a very common task for any programmer (pretty much everything has a compiler/interpreter, even you image viewer, web browser, etc ...) so it's very important to learn about those things. 对于任何程序员来说,学习如何解析和翻译/解释为另一种格式都是非常常见的任务(几乎所有东西都有编译器/解释器,甚至您有图像查看器,Web浏览器等),因此了解这一点非常重要。那些事。

For Erlang, LYSE got a chapter about making a reverse-polish notation calculator here , and for converting from an infix equation to a prefix/postfix one, you should read about Shunt-Yard algorithm . 对于二郎,细胞溶解得到了有关使逆波兰式计算器章这里 ,并从缀公式转换为前缀/后缀一个,你应该阅读有关分流码算法 Erlang also have is own version of yacc & lex : yecc , leex . Erlang也有自己的yacc和lex版本: yeccleex

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM