Skip to content

Commit

Permalink
Fix handling of empty file and file containing only comments. Tests
Browse files Browse the repository at this point in the history
included.

Issue reported by Tony Morris on IRC.
  • Loading branch information
erikd committed May 9, 2012
1 parent b2bb4d5 commit c8a74d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions runtests.hs
Expand Up @@ -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 "")
]

-- ---------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/Language/JavaScript/Parser/Grammar5.y
Expand Up @@ -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 }
Expand Down

0 comments on commit c8a74d6

Please sign in to comment.