Last active
September 22, 2018 01:05
-
-
Save tyler569/233522b2a929fe2af21d68f9eef50a69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tyler@xps:~/lcc$ python3 parse_test.py | |
| > | |
| > 2+2 | |
| [2, '+', 2] | |
| ('+', 2, 2) | |
| 4 | |
| > 2*2+2 | |
| [2, '*', 2, '+', 2] | |
| ('+', ('*', 2, 2), 2) | |
| 6 | |
| > 2+2*2 | |
| [2, '+', 2, '*', 2] | |
| ('+', 2, ('*', 2, 2)) | |
| 6 | |
| > 2-2-2 | |
| [2, '-', 2, '-', 2] | |
| ('-', ('-', 2, 2), 2) | |
| -2 | |
| > 4/2-1 | |
| [4, '/', 2, '-', 1] | |
| ('-', ('/', 4, 2), 1) | |
| 1.0 | |
| > 1-4/2 | |
| [1, '-', 4, '/', 2] | |
| ('-', 1, ('/', 4, 2)) | |
| -1.0 | |
| > 2*2+3*4/5-3-4 | |
| [2, '*', 2, '+', 3, '*', 4, '/', 5, '-', 3, '-', 4] | |
| ('-', ('-', ('+', ('*', 2, 2), ('*', 3, ('/', 4, 5))), 3), 4) | |
| -0.5999999999999996 | |
| > |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tyler@xps:~/lcc$ python3 parse_test.py | |
| > | |
| > | |
| > | |
| > 2 - (2 - 2) | |
| [2, '-', '(', 2, '-', 2, ')'] | |
| ('-', 2, ('-', 2, 2)) | |
| 2 | |
| > | |
| > (2 - 2) - 2 | |
| ['(', 2, '-', 2, ')', '-', 2] | |
| ('-', ('-', 2, 2), 2) | |
| -2 | |
| > | |
| > (1 + 1) * 2 | |
| ['(', 1, '+', 1, ')', '*', 2] | |
| ('*', ('+', 1, 1), 2) | |
| 4 | |
| > 1 + (1 * 2) | |
| [1, '+', '(', 1, '*', 2, ')'] | |
| ('+', 1, ('*', 1, 2)) | |
| 3 | |
| > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment