tree-sitter/spec/runtime/languages/arithmetic/main.txt
Max Brunsfeld 99817a38c1 Improve trees generated by arithmetic grammar
This work should inform how to implement operator
precedence helper functions
2014-03-29 18:37:51 -07:00

53 lines
836 B
Text

====================
parses numbers
===================
5
---
(expression (number))
===================
parses variables
===================
x
---
(expression (variable))
===================
parses products
===================
x * x
---
(expression (product
(variable)
(variable)))
===================
parses sums
===================
x + x
---
(expression (sum
(variable)
(variable)))
====================
parses complex trees
====================
x * y + z / a
---
(expression (sum
(product (variable) (variable))
(quotient (variable) (variable))))
============================
parses exponents
============================
x + y * z^(a + b)
---
(expression (sum
(variable)
(product
(variable)
(exponent
(variable)
(grouping (sum (variable) (variable)))))))