Attach comments to AST nodes. (#64)
* Attach comments to AST nodes.
This feature is off by default. More testing will be needed before
exposing it to the ParseFile function.
Logic is copied from Buildifier (https://github.com/bazelbuild/buildtools/tree/master/build).
bug #63
* Fix tests by saving the state of 'blank' in the scanner.
* - Rename flattenAST
- Add new argument to the Parser and the Scanner
- Update tests
* Remove global constant keepComments
* Update more tests (new argument to the parser)
* Add CommentsRef to allow allocating comments
Address a few other issues
* Remove the COMMENT tokens
Parser won't see COMMENT tokens anymore. The list is kept by the
scanner. This simplifies the code and reverts some of my previous
changes.
* Address review comments
* - Removed the .Suffix boolean
- Renamed CommentsRef to commentsRef
- Simplified assignComments function (reversing was not useful)
* assignComments leaves early if there is no comments
+ address other review comments
* Address review comments (for -> if, removed useless code about suffix comments)
diff --git a/eval_test.go b/eval_test.go
index e74445c..9ee38bc 100644
--- a/eval_test.go
+++ b/eval_test.go
@@ -437,7 +437,7 @@
// TestRepeatedExec parses and resolves a file syntax tree once then
// executes it repeatedly with different values of its global variables.
func TestRepeatedExec(t *testing.T) {
- f, err := syntax.Parse("repeat.sky", "y = 2 * x")
+ f, err := syntax.Parse("repeat.sky", "y = 2 * x", 0)
if err != nil {
t.Fatal(f) // parse error
}