Skip to content

Commit

Permalink
Merge pull request #17 from erikd/master
Browse files Browse the repository at this point in the history
Fix handling of empty file and file containing only comments. Tests included.
  • Loading branch information
alanz committed May 10, 2012
2 parents 43935bb + c7b9028 commit 47555a6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions runtests.hs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 47555a6

Please sign in to comment.