Permalink
Browse files

Fix handling of empty file and file containing only comments. Tests

included.

Issue reported by Tony Morris on IRC.
  • Loading branch information...
1 parent b2bb4d5 commit c8a74d6e6e36798cb946f880fb5338277f5dc03c @erikd committed May 9, 2012
Showing with 3 additions and 0 deletions.
  1. +2 −0 runtests.hs
  2. +1 −0 src/Language/JavaScript/Parser/Grammar5.y
View
@@ -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 "")
]
-- ---------------------------------------------------------------------
@@ -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 c8a74d6

Please sign in to comment.