calc

所属分类:自动编程
开发工具:Assembly
文件大小:8KB
下载次数:0
上传日期:2018-08-14 21:20:16
上 传 者sh-1993
说明:  在生成和缩减语法树期间,为处理汇编程序中的内存管理而创建的简单计算器。
(A simple calculator created to deal with memory management in assembler during generating and reducing a syntax tree.)

文件列表:
append_brackets.s (539, 2018-08-15)
append_entry.s (328, 2018-08-15)
append_token.s (213, 2018-08-15)
erase_token.s (143, 2018-08-15)
execute.s (308, 2018-08-15)
get_length.s (376, 2018-08-15)
get_next_operator.s (925, 2018-08-15)
get_priority.s (234, 2018-08-15)
main.s (420, 2018-08-15)
make.sh (933, 2018-08-15)
make_expretion.s (1618, 2018-08-15)
parse.s (490, 2018-08-15)
peda-session-calc.txt (14, 2018-08-15)
reduce.s (3020, 2018-08-15)
set_type.s (492, 2018-08-15)
shift_entries.s (298, 2018-08-15)
test.py (918, 2018-08-15)
tokenize.s (2269, 2018-08-15)

# Calc A simple calculator created to deal with memory management in assembler during generating and reducing a syntax tree. ## Algorithm 1. Read a string and surround it with brackets. 2. Split the string into tokens skipping unrelated characters (e.g new line character or spaces). 3. Make a syntax tree from the tokens dynamically allocating memory for every node of the tree. 4. Solve the expression recursively reducing the tree and freeing memory after solving a subtree. ## Usage Run `make.sh` to compile the source code. Run `test.py` to check the correctness. The absence of memory leaks can be checked with valgrind manually. ## Restrictions The purpose wasn't to create an effective calculator therefore the functionality is very restricted. It supports only plus, minus and multiply operations for integer numbers. And there shouldn't be an operator followed by another operator therefore unary plus and minus should be surround with brackets. Also there is no error handling therefore incorrect input usually causes a fault. ## Examples of correct input ``` -1 2+2*2 2*(2+2) ((-13))-9+3 0*17-17+(7)*(19*19) ((13)+7+20)+(19*16*11-20) (-8)+16*3-(20)*(2)*5+16+14*0-2*2-(2-13*13+5)*(9+15*11-((11))+17+7) ```

近期下载者

相关文件


收藏者