Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #17 from erikd/master

Fix handling of empty file and file containing only comments. Tests included.
  • Loading branch information...
commit 47555a6ad09cb45cae898370aa5b9a5bca79075c 2 parents 43935bb + c7b9028
@alanz authored
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 }
Please sign in to comment.
Something went wrong with that request. Please try again.