Don't store tree's hidden children in a separate array

Just mark hidden trees as such, and skip them when
pretty-printing a tree
This commit is contained in:
Max Brunsfeld 2014-07-16 18:38:06 -07:00
parent 95fbdb6fdb
commit 779bf0d745
17 changed files with 167 additions and 243 deletions

View file

@ -10,6 +10,6 @@ recovers from errors inside parenthesized expressions
=====================================================
x + (y * + z) * 5
---
(expression (sum
(sum
(variable)
(product (group (ERROR '+')) (number))))
(product (group (ERROR '+')) (number)))

View file

@ -3,51 +3,47 @@ parses numbers
===================
5
---
(expression (number))
(number)
===================
parses variables
===================
x
---
(expression (variable))
(variable)
===================
parses products
===================
x * x
---
(expression (product
(variable)
(variable)))
(product (variable) (variable))
===================
parses sums
===================
x + x
---
(expression (sum
(variable)
(variable)))
(sum (variable) (variable))
===============================================
binds multiplication more tightly than addition
===============================================
a * b + c * d
---
(expression (sum
(sum
(product (variable) (variable))
(product (variable) (variable))))
(product (variable) (variable)))
============================
parses exponents
============================
x + y * z^(a + b)
---
(expression (sum
(sum
(variable)
(product
(variable)
(exponent
(variable)
(group (sum (variable) (variable)))))))
(group (sum (variable) (variable))))))

View file

@ -39,7 +39,7 @@ var x = {
(statement_block (var_declaration (identifier) (identifier)))))))
==========================================
parses comments z
parses comments
==========================================
// this is the beginning of the script.
// here we go.
@ -57,14 +57,14 @@ var thing = {
(program
(comment)
(comment)
(var_declaration (identifier) (object
(program (var_declaration (identifier) (object
(comment)
(comment)
(identifier) (function_expression
(formal_parameters (identifier) (comment))
(statement_block
(comment)
(expression_statement (function_call (identifier))))))))
(expression_statement (function_call (identifier)))))))))
==========================================
parses comments within expressions

View file

@ -17,24 +17,24 @@ recovers from errors inside arrays
==========================================
[1, , 2]
---
(value (array
(array
(number)
(ERROR <EOF>)
(number)))
(number))
==========================================
recovers from errors inside objects
==========================================
{ "key1": 1, oops }
---
(value (object (string) (number) (ERROR 'o')))
(object (string) (number) (ERROR 'o'))
==========================================
recovers from errors inside nested objects
==========================================
{ "key1": { "key2": 1, 2 }, [, "key3": 3 }
---
(value (object
(object
(string) (object (string) (number) (ERROR '2'))
(ERROR '[')
(string) (number)))
(string) (number))

View file

@ -3,14 +3,14 @@ parses floating point numbers
=============================
3.14
---
(value (number))
(number)
===================
parses empty arrays
===================
[]
---
(value (array))
(array)
===================
parses arrays
@ -23,19 +23,19 @@ parses arrays
{ "stuff": "good" }
]
---
(value (array
(array
(number)
(null)
(true)
(false)
(object (string) (string))))
(object (string) (string)))
====================
parses empty objects
====================
{}
---
(value (object))
(object)
===================
parses long objects
@ -45,8 +45,7 @@ parses long objects
"key2": 1
}
---
(value (object
(object
(string) (string)
(string) (number)
))
(string) (number))