Permalink
Browse files

Merge pull request #17 from erikd/master

Fix handling of empty file and file containing only comments. Tests included.
  • Loading branch information...
2 parents 43935bb + c7b9028 commit 47555a6ad09cb45cae898370aa5b9a5bca79075c @alanz alanz committed May 10, 2012
Showing with 3 additions and 0 deletions.
  1. +2 −0 runtests.hs
  2. +1 −0 src/Language/JavaScript/Parser/Grammar5.y
View
2 runtests.hs
@@ -737,6 +737,8 @@ commentPrintSuite = testGroup "Comments"
-- https://github.com/alanz/language-javascript/issues/15
, testCase "issue15" (testRoundTrip "x\t=1;")
+ , testCase "comment-only" (testRoundTrip "// comment\n\n")
+ , testCase "empty-src" (testRoundTrip "")
]
-- ---------------------------------------------------------------------
View
1 src/Language/JavaScript/Parser/Grammar5.y
@@ -1099,6 +1099,7 @@ FunctionBody : LBrace SourceElements RBrace { (AST.NN (AST.JSBlock [$1] $2 [$3])
Program :: { AST.JSNode }
Program : SourceElementsTop Eof { (combineTop $1 $2) {- Program -}}
+ | Eof { fp (AST.NN (AST.JSSourceElementsTop [$1])) }
-- For debugging/other entry points
LiteralMain :: { AST.JSNode }

0 comments on commit 47555a6

Please sign in to comment.