Permalink
Browse files

Merge branch 'master' into new-ast

  • Loading branch information...
2 parents f9fea3b + c7b9028 commit c1b4e113b1e0b0b6b8a521f36256fc26d5126266 @erikd committed May 9, 2012
Showing with 7 additions and 1 deletion.
  1. +3 −1 runtests.hs
  2. +1 −0 src/Language/JavaScript/Parser/Grammar5.y
  3. +3 −0 src/Language/JavaScript/Parser/Parser.hs
View
@@ -276,7 +276,7 @@ testSuite = testGroup "Parser"
, testCase "unicode4" (testProg "x=\"àáâãäå\";y='\3012a\0068'" "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"x\",JSOperator JSLiteral \"=\",JSStringLiteral '\"' \"\\224\\225\\226\\227\\228\\229\"],JSLiteral \";\",JSExpression [JSIdentifier \"y\",JSOperator JSLiteral \"=\",JSStringLiteral '\\'' \"\\3012aD\"],JSLiteral \"\"])")
- , testCase "unicode5" (testFile "./test/Unicode.js" "JSSourceElementsTop [JSExpression [JSIdentifier \"\\224\\225\\226\\227\\228\\229\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\",JSLiteral \"\"]")
+ , testCase "unicode5f" (testFile "./test/Unicode.js" "JSSourceElementsTop [JSExpression [JSIdentifier \"\\224\\225\\226\\227\\228\\229\",JSOperator JSLiteral \"=\",JSDecimal \"1\"],JSLiteral \";\",JSLiteral \"\"]")
, testCase "bug2.a" (testProg "function() {\nz = function /*z*/(o) {\nreturn r;\n};}" "Right (JSSourceElementsTop [JSExpression [JSFunctionExpression [] [] (JSBlock ([JSExpression [JSIdentifier \"z\",JSOperator JSLiteral \"=\",JSFunctionExpression [] [JSIdentifier \"o\"] (JSBlock ([JSReturn [JSExpression [JSIdentifier \"r\"]] JSLiteral \";\"]))],JSLiteral \";\"]))],JSLiteral \"\"])")
@@ -719,6 +719,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 "")
]
-- ---------------------------------------------------------------------
@@ -1096,6 +1096,7 @@ FunctionBody : LBrace SourceElements RBrace { (AST.JSBlock AST.JSNoAnnot [$1] $2
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 }
@@ -34,6 +34,9 @@ readJs input = do
Left msg -> error (show msg)
Right p -> p
+-- | Parse the given file.
+-- For UTF-8 support, make sure your locale is set such that
+-- "System.IO.localeEncoding" returns "utf8"
parseFile :: FilePath -> IO AST.JSNode
parseFile filename =
do

0 comments on commit c1b4e11

Please sign in to comment.