Permalink
Browse files

Version 0.4.3 Correct lexer for decimalToken, only leading digit need…

…s to be non-zero.
  • Loading branch information...
1 parent 8e0f683 commit cc32d8dcebb03b7e44d4750ea497e4bd5d9a9652 @alanz alanz committed Mar 31, 2011
Showing with 11 additions and 4 deletions.
  1. +5 −1 README
  2. +1 −1 language-javascript.cabal
  3. +3 −0 runtests.hs
  4. +2 −2 src/Language/JavaScript/Parser/Lexer.x
View
6 README
@@ -21,7 +21,9 @@ Running the tests
To debug the grammar
-happy -iparse.txt -g -a -d src/Language/JavaScript/Parser/Grammar.y
+happy -iparse.txt -g -a -d src/Language/JavaScript/Parser/Grammar.y
+OR
+happy -iparse.txt -g -a -d src/Language/JavaScript/Parser/Grammar5.y
This generates src/Language/JavaScript/Parser/Grammar.hs, delete this
when done with the debug version
@@ -45,6 +47,8 @@ $ cabal install --reinstall alex
Changes
+0.4.3 correct lexer for decimalToken, only leading digit needs to be non-zero.
+
0.4.2 Expose SrcSpan
0.4.1 Expose AST.Node as well.
@@ -1,5 +1,5 @@
Name: language-javascript
-Version: 0.4.2
+Version: 0.4.3
Synopsis: Parser for JavaScript
Description: Parses Javascript into an Abstract Syntax Tree (AST). Initially intended as frontend to hjsmin.
Homepage: https://github.com/alanz/language-javascript
View
@@ -272,6 +272,9 @@ testSuite = testGroup "Parser"
, testCase "bug2.b" (testProg "function() {\nz = function z(o) {\nreturn r;\n};}" "Right (JSSourceElementsTop [JSExpression [JSFunctionExpression [] [] (JSFunctionBody [JSSourceElements [JSExpression [JSIdentifier \"z\",JSOperator \"=\",JSFunctionExpression [JSIdentifier \"z\"] [JSIdentifier \"o\"] (JSFunctionBody [JSSourceElements [JSReturn [JSExpression [JSIdentifier \"r\"],JSLiteral \";\"]]])],JSLiteral \";\"]])]])")
+ -- https://github.com/alanz/hjsmin/issues/#issue/3
+ , testCase "bug3" (testProg "var myLatlng = new google.maps.LatLng(56.8379100, 60.5806664);" "Right (JSSourceElementsTop [JSVariables \"var\" [JSVarDecl (JSIdentifier \"myLatlng\") [JSLiteral \"new \",JSMemberDot [JSMemberDot [JSIdentifier \"google\"] (JSIdentifier \"maps\")] (JSIdentifier \"LatLng\"),JSArguments [[JSDecimal \"56.8379100\"],[JSDecimal \"60.5806664\"]]]]])")
+
, testCase "02_sm.js" (testProg "{zero}\none1;two\n{three\nfour;five;\n{\nsix;{seven;}\n}\n}" "Right (JSSourceElementsTop [JSStatementBlock (JSStatementList [JSExpression [JSIdentifier \"zero\"]]),JSExpression [JSIdentifier \"one1\"],JSLiteral \";\",JSExpression [JSIdentifier \"two\"],JSStatementBlock (JSStatementList [JSExpression [JSIdentifier \"three\"],JSExpression [JSIdentifier \"four\"],JSLiteral \";\",JSExpression [JSIdentifier \"five\"],JSLiteral \";\",JSStatementBlock (JSStatementList [JSExpression [JSIdentifier \"six\"],JSLiteral \";\",JSStatementBlock (JSStatementList [JSExpression [JSIdentifier \"seven\"],JSLiteral \";\"])])])])")
, testCase "02_sm.js.2" (testProg "{zero}\nget;two\n{three\nfour;set;\n{\nsix;{seven;}\n}\n}" "Right (JSSourceElementsTop [JSStatementBlock (JSStatementList [JSExpression [JSIdentifier \"zero\"]]),JSExpression [JSIdentifier \"get\"],JSLiteral \";\",JSExpression [JSIdentifier \"two\"],JSStatementBlock (JSStatementList [JSExpression [JSIdentifier \"three\"],JSExpression [JSIdentifier \"four\"],JSLiteral \";\",JSExpression [JSIdentifier \"set\"],JSLiteral \";\",JSStatementBlock (JSStatementList [JSExpression [JSIdentifier \"six\"],JSLiteral \";\",JSStatementBlock (JSStatementList [JSExpression [JSIdentifier \"seven\"],JSLiteral \";\"])])])])")
@@ -214,8 +214,8 @@ tokens :-
-- | {Non Zero Digits}+ {Digit}*
-- | '0'
-- | '0' '.' {Digit}+
-<reg,divide> $non_zero_digit+ "." $digit* ("e"|"E") ("+"|"-")? $non_zero_digit+ $digit*
- | $non_zero_digit+ "." $digit*
+<reg,divide> $non_zero_digit $digit* "." $digit* ("e"|"E") ("+"|"-")? $non_zero_digit+ $digit*
+ | $non_zero_digit $digit* "." $digit*
| "0." $digit+ ("e"|"E") ("+"|"-")? $non_zero_digit+ $digit*
| $non_zero_digit+ $digit*
| "0"

0 comments on commit cc32d8d

Please sign in to comment.