tree-sitter/spec/runtime/languages/arithmetic/main.txt
Max Brunsfeld a437d39773 Add rule precedence construct
Still need to add some way of expressing left and right
associativity
2014-04-15 08:40:46 -07:00

53 lines
913 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)))
===============================================
binds multiplication more tightly than addition
===============================================
a * b + c * d
---
(expression (sum
(product (variable) (variable))
(product (variable) (variable))))
============================
parses exponents
============================
x + y * z^(a + b)
---
(expression (sum
(variable)
(product
(variable)
(exponent
(variable)
(group (sum (variable) (variable)))))))