• 羽飞's avatar
    Expression 四则运算 (#233) · 3cd3c2f9
    羽飞 提交于
    ### What problem were solved in this pull request?
    
    Problem: close #229 
    当前的词法分析语法分析非常简单,那当遇到比较复杂的词法分析语法分析题目,比如表达式,有些同学就难以入手
    
    ### What is changed and how it works?
    增加一个支持四则运算的功能,关键字是calc,虽然与标准的SQL不同,但是可以作为学习表达式入门使用。
    使用示例:
    ```
    (base) build_debug $ ./bin/observer -f ../etc/observer.ini -P cli
    Successfully load ../etc/observer.ini
    miniob > calc 2*(2*(2+3));
    2*(2*(2+3))
    20
    
    miniob > calc (1+2) * (2 * (20+ -(5*1)))
    (1+2) * (2 * (20+ -(5*1)))
    90
    
    miniob > calc 1, 2, 3;
    1 | 2 | 3
    1 | 2 | 3
    
    miniob > calc 1 + 2 - 3+4;
    1 + 2 - 3+4
    4
    
    miniob > calc 2* 4;
    2* 4
    8
    
    miniob > calc 1, 2, 3;
    1 | 2 | 3
    1 | 2 | 3
    
    miniob > calc 1 + 2 - 3+4;
    1 + 2 - 3+4
    4
    
    miniob > calc 2* 4;
    2* 4
    8
    ```
    3cd3c2f9
book.toml 233 字节