From 6a29b5af01d01a1d2ca3a9589574e6e9cfe17826 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Mon, 9 Apr 2012 21:04:50 +0200 Subject: [PATCH] Preparing for 0.0.16, having fixed issue #7 closes #7 --- README.markdown | 4 + Text/Jasmine/Pretty.hs | 78 ++++++------- hjsmin.cabal | 6 +- runtests.hs | 223 ++++++++++++++++++++----------------- test/parsingonly/issue7.hs | 7 ++ test/parsingonly/issue7.js | 1 + 6 files changed, 175 insertions(+), 144 deletions(-) create mode 100644 test/parsingonly/issue7.hs create mode 100644 test/parsingonly/issue7.js diff --git a/README.markdown b/README.markdown index 6b4f48b..31fef4a 100644 --- a/README.markdown +++ b/README.markdown @@ -28,6 +28,10 @@ Running the tests Changes ------- +0.0.16 - Fix bug for issue 7, blowing up when calculating if space needed after return + +0.0.15 - Fix ambiguous symbols with GHC 7.4.1, from @luite + 0.0.14 - Allow unicode characters in comments 0.0.13 - Error in parsing numbers with zeros before decimal point diff --git a/Text/Jasmine/Pretty.hs b/Text/Jasmine/Pretty.hs index 7762961..6acd74a 100644 --- a/Text/Jasmine/Pretty.hs +++ b/Text/Jasmine/Pretty.hs @@ -1,5 +1,5 @@ module Text.Jasmine.Pretty - ( + ( renderJS ) where @@ -66,15 +66,15 @@ rn (JSArguments xs) = (text "(") <> (commaListList $ map fixLiterals xs) rn (JSBlock x) = (text "{") <> (renderJS x) <> (text "}") -rn (JSIf c (NS (JSLiteral ";") _))= (text "if") <> (text "(") <> (renderJS c) <> (text ")") +rn (JSIf c (NS (JSLiteral ";") _))= (text "if") <> (text "(") <> (renderJS c) <> (text ")") rn (JSIf c t) = (text "if") <> (text "(") <> (renderJS c) <> (text ")") <> (renderJS $ fixBlock t) -rn (JSIfElse c t (NS (JSLiteral ";") _)) = (text "if") <> (text "(") <> (renderJS c) <> (text ")") <> (renderJS t) - <> (text "else") -rn (JSIfElse c t e) = (text "if") <> (text "(") <> (renderJS c) <> (text ")") <> (renderJS t) +rn (JSIfElse c t (NS (JSLiteral ";") _)) = (text "if") <> (text "(") <> (renderJS c) <> (text ")") <> (renderJS t) + <> (text "else") +rn (JSIfElse c t e) = (text "if") <> (text "(") <> (renderJS c) <> (text ")") <> (renderJS t) <> (text "else") <> (spaceOrBlock $ fixBlock e) rn (JSMemberDot xs y) = (rJS xs) <> (text ".") <> (renderJS y) -rn (JSMemberSquare xs x) = (rJS xs) <> (text "[") <> (renderJS x) <> (text "]") +rn (JSMemberSquare xs x) = (rJS xs) <> (text "[") <> (renderJS x) <> (text "]") rn (JSLiteral l) = (text l) rn (JSStringLiteral s l) = empty <> (char s) <> (text l) <> (char s) rn (JSUnary l ) = text l @@ -88,13 +88,13 @@ rn (JSCallExpression "()" xs) = (rJS xs) rn (JSCallExpression t xs) = (char $ head t) <> (rJS xs) <> (if ((length t) > 1) then (char $ last t) else empty) -- No space between 'case' and string literal. TODO: what about expression in parentheses? ---rn (JSCase (JSExpression [JSStringLiteral sepa s]) xs) = (text "case") <> (renderJS (JSStringLiteral sepa s)) -rn (JSCase (NS (JSExpression [(NS (JSStringLiteral sepa s) s1)]) _) xs) = (text "case") <> (renderJS (NS (JSStringLiteral sepa s) s1)) - <> (char ':') <> (renderJS xs) -rn (JSCase e xs) = (text "case") <+> (renderJS e) <> (char ':') <> (renderJS xs) -- <> (text ";"); +--rn (JSCase (JSExpression [JSStringLiteral sepa s]) xs) = (text "case") <> (renderJS (JSStringLiteral sepa s)) +rn (JSCase (NS (JSExpression [(NS (JSStringLiteral sepa s) s1)]) _) xs) = (text "case") <> (renderJS (NS (JSStringLiteral sepa s) s1)) + <> (char ':') <> (renderJS xs) +rn (JSCase e xs) = (text "case") <+> (renderJS e) <> (char ':') <> (renderJS xs) -- <> (text ";"); rn (JSCatch i [] s) = (text "catch") <> (char '(') <> (renderJS i) <> (char ')') <> (renderJS s) -rn (JSCatch i c s) = (text "catch") <> (char '(') <> (renderJS i) <> +rn (JSCatch i c s) = (text "catch") <> (char '(') <> (renderJS i) <> (text " if ") <> (rJS c) <> (char ')') <> (renderJS s) rn (JSContinue is) = (text "continue") <> (rJS is) -- <> (char ';') @@ -109,16 +109,16 @@ rn (JSExpressionPostfix o e) = (rJS e) <> (text o) rn (JSExpressionTernary c v1 v2) = (rJS c) <> (char '?') <> (rJS v1) <> (char ':') <> (rJS v2) rn (JSFinally b) = (text "finally") <> (renderJS b) -rn (JSFor e1 e2 e3 s) = (text "for") <> (char '(') <> (commaList e1) <> (char ';') +rn (JSFor e1 e2 e3 s) = (text "for") <> (char '(') <> (commaList e1) <> (char ';') <> (rJS e2) <> (char ';') <> (rJS e3) <> (char ')') <> (renderJS $ fixBlock s) rn (JSForIn e1 e2 s) = (text "for") <> (char '(') <> (rJS e1) <+> (text "in") <+> (renderJS e2) <> (char ')') <> (renderJS $ fixBlock s) -rn (JSForVar e1 e2 e3 s) = (text "for") <> (char '(') <> (text "var") <+> (commaList e1) <> (char ';') +rn (JSForVar e1 e2 e3 s) = (text "for") <> (char '(') <> (text "var") <+> (commaList e1) <> (char ';') <> (rJS e2) <> (char ';') <> (rJS e3) <> (char ')') <> (renderJS $ fixBlock s) -rn (JSForVarIn e1 e2 s) = (text "for") <> (char '(') <> (text "var") <+> (renderJS e1) <+> (text "in") +rn (JSForVarIn e1 e2 s) = (text "for") <> (char '(') <> (text "var") <+> (renderJS e1) <+> (text "in") <+> (renderJS e2) <> (char ')') <> (renderJS $ fixBlock s) - -rn (JSHexInteger i) = (text $ show i) -- TODO: need to tweak this + +rn (JSHexInteger i) = (text $ show i) -- TODO: need to tweak this rn (JSLabelled l v) = (renderJS l) <> (text ":") <> (rJS $ fixSourceElements [fixBlock v]) rn (JSObjectLiteral xs) = (text "{") <> (commaList xs) <> (text "}") rn (JSPropertyAccessor s n ps b) = (text s) <+> (renderJS n) <> (char '(') <> (rJS ps) <> (text ")") <> (renderJS b) @@ -127,7 +127,7 @@ rn (JSRegEx s) = (text s) rn (JSReturn []) = (text "return") rn (JSReturn [(NS (JSLiteral ";") _)]) = (text "return;") -rn (JSReturn xs) = (text "return") <> (if (spaceNeeded xs) then (text " ") else (empty)) <> (rJS $ fixSourceElements xs) +rn (JSReturn xs) = (text "return") <> (if (spaceNeeded xs) then (text " ") else (empty)) <> (rJS $ fixSourceElements xs) rn (JSThrow e) = (text "throw") <+> (renderJS e) @@ -135,11 +135,11 @@ rn (JSStatementBlock x) = (text "{") <> (renderJS x) <> (text "}") rn (JSStatementList xs) = rJS (fixSourceElements $ map fixBlock xs) -rn (JSSwitch e xs) = (text "switch") <> (char '(') <> (renderJS e) <> (char ')') <> +rn (JSSwitch e xs) = (text "switch") <> (char '(') <> (renderJS e) <> (char ')') <> (char '{') <> (rJS $ fixSemis xs) <> (char '}') rn (JSTry e xs) = (text "try") <> (renderJS e) <> (rJS xs) -rn (JSVarDecl i []) = (renderJS i) +rn (JSVarDecl i []) = (renderJS i) rn (JSVarDecl i xs) = (renderJS i) <> (text "=") <> (rJS xs) rn (JSVariables kw xs) = (text kw) <+> (commaList xs) @@ -148,7 +148,7 @@ rn (JSWhile e (NS (JSLiteral ";") _)) = (text "while") <> (char '(') <> (rende rn (JSWhile e s) = (text "while") <> (char '(') <> (renderJS e) <> (char ')') <> (renderJS s) rn (JSWith e s) = (text "with") <> (char '(') <> (renderJS e) <> (char ')') <> (rJS s) - + -- Helper functions rJS :: [JSNode] -> BB.Builder rJS xs = hcat $ map renderJS xs @@ -160,7 +160,7 @@ commaList xs = (hcat $ (punctuate comma (toDoc xs') ++ trail)) -- (xs', trail) = if (last xs == JSLiteral ",") then (init xs, [comma]) else (xs,[]) (xs', trail) = if (x' == JSLiteral ",") then (init xs, [comma]) else (xs,[]) (NS x' _) = last xs - + commaListList :: [[JSNode]] -> BB.Builder commaListList xs = (hcat $ punctuate comma $ map rJS xs) @@ -193,7 +193,7 @@ fixTop xs = if (n == (JSLiteral ";")) then (init xs) else (xs) fixSourceElements :: [JSNode] -> [JSNode] fixSourceElements xs = fixSemis $ myFix xs - + myFix :: [JSNode] -> [JSNode] myFix [] = [] @@ -210,19 +210,19 @@ myFix ((NS (JSExpression x) s1):(NS (JSBlock y) s2):xs) = (NS (JSExpression myFix ((NS (JSBlock x) s1) :(NS (JSBlock y) s2):xs) = (NS (JSBlock x) s1) :(NS (JSLiteral ";") s1):myFix ((NS (JSBlock y) s2):xs) myFix ((NS (JSBlock x) s1) :(NS (JSExpression y) s2):xs) = (NS (JSBlock x) s1) :(NS (JSLiteral ";") s1):myFix ((NS (JSExpression y) s2):xs) -myFix ((NS (JSExpression x) s1):(NS (JSStatementBlock y) s2):xs) = +myFix ((NS (JSExpression x) s1):(NS (JSStatementBlock y) s2):xs) = (NS (JSExpression x) s1):(NS (JSLiteral ";") s1):myFix ((NS (JSStatementBlock y) s2):xs) -myFix ((NS (JSStatementBlock x) s1) :(NS (JSStatementBlock y) s2):xs) = +myFix ((NS (JSStatementBlock x) s1) :(NS (JSStatementBlock y) s2):xs) = (NS (JSStatementBlock x) s1) :(NS (JSLiteral ";") s1):myFix ((NS (JSStatementBlock y) s2):xs) -myFix ((NS (JSStatementBlock x) s1) :(NS (JSExpression y) s2):xs) = +myFix ((NS (JSStatementBlock x) s1) :(NS (JSExpression y) s2):xs) = (NS (JSStatementBlock x) s1) :(NS (JSLiteral ";") s1):myFix ((NS (JSExpression y) s2):xs) -- Merge adjacent variable declarations, but only of the same type -myFix ((NS (JSVariables t1 x1s) s1):(NS (JSLiteral l) s2):(NS (JSVariables t2 x2s) s3):xs) +myFix ((NS (JSVariables t1 x1s) s1):(NS (JSLiteral l) s2):(NS (JSVariables t2 x2s) s3):xs) | t1 == t2 = myFix ((NS (JSVariables t1 (x1s++x2s)) s1):xs) | otherwise = (NS (JSVariables t1 x1s) s1):myFix ((NS (JSLiteral l) s2):(NS (JSVariables t2 x2s) s3):xs) -myFix ((NS (JSVariables t1 x1s) s1):(NS (JSVariables t2 x2s) s2):xs) +myFix ((NS (JSVariables t1 x1s) s1):(NS (JSVariables t2 x2s) s2):xs) | t1 == t2 = myFix ((NS (JSVariables t1 (x1s++x2s)) s1):xs) | otherwise = (NS (JSVariables t1 x1s) s1):myFix ((NS (JSVariables t2 x2s) s2):xs) @@ -230,7 +230,7 @@ myFix ((NS (JSVariables t1 x1s) s1):(NS (JSVariables t2 x2s) s2):xs) myFix ((NS (JSLiteral ";") s1):(NS (JSLiteral ";") _s2):xs) = myFix ((NS (JSLiteral ";") s1):xs) myFix ((NS (JSLiteral ";") s1):(NS (JSLiteral "" ) _s2):xs) = myFix ((NS (JSLiteral "") s1):xs) - + myFix (x:xs) = x : myFix xs -- Merge strings split over lines and using "+" @@ -239,11 +239,11 @@ fixLiterals [] = [] -- Old version fixLiterals ((NS (JSStringLiteral d1 s1) ss1):(NS (JSExpressionBinary "+" [(NS (JSStringLiteral d2 s2) ss2)] r) ss3):xs) | d1 == d2 = fixLiterals ((NS (JSStringLiteral d1 (s1++s2)) ss1):(r++xs)) - | otherwise = (NS (JSStringLiteral d1 s1) ss1):fixLiterals ((NS (JSExpressionBinary "+" [(NS (JSStringLiteral d2 s2) ss2)] r) ss3):xs) + | otherwise = (NS (JSStringLiteral d1 s1) ss1):fixLiterals ((NS (JSExpressionBinary "+" [(NS (JSStringLiteral d2 s2) ss2)] r) ss3):xs) fixLiterals ((NS (JSExpressionBinary "+" [(NS (JSStringLiteral d1 s1) ss2)] [(NS (JSStringLiteral d2 s2) ss3)]) ss4):xs) | d1 == d2 = fixLiterals ((NS (JSStringLiteral d1 (s1++s2)) ss2):xs) - | otherwise = (NS (JSExpressionBinary "+" [(NS (JSStringLiteral d1 s1) ss2)] [(NS (JSStringLiteral d2 s2) ss3)]) ss4):fixLiterals xs + | otherwise = (NS (JSExpressionBinary "+" [(NS (JSStringLiteral d1 s1) ss2)] [(NS (JSStringLiteral d2 s2) ss3)]) ss4):fixLiterals xs fixLiterals (x:xs) = x:fixLiterals xs @@ -256,12 +256,12 @@ fixSemis' :: [JSNode] -> [JSNode] fixSemis' [] = [] fixSemis' [(NS (JSContinue [(NS (JSLiteral ";") _)]) s2)] = [(NS (JSContinue []) s2)] fixSemis' [x] = [x] -fixSemis' ((NS (JSIf c (NS (JSReturn [(NS (JSLiteral ";") s1)]) s2) ) s3):xs) = +fixSemis' ((NS (JSIf c (NS (JSReturn [(NS (JSLiteral ";") s1)]) s2) ) s3):xs) = (NS (JSIf c (NS (JSReturn [(NS (JSLiteral ";") s1)]) s2)) s3):(fixSemis' xs) -fixSemis' ((NS (JSIf c (NS (JSContinue [(NS (JSLiteral ";") s1)]) s2) ) s3):xs) = +fixSemis' ((NS (JSIf c (NS (JSContinue [(NS (JSLiteral ";") s1)]) s2) ) s3):xs) = (NS (JSIf c (NS (JSContinue [(NS (JSLiteral ";") s1)]) s2)) s3):(fixSemis' xs) fixSemis' (x:(NS (JSLiteral "\n") s1):xs) = x:(NS (JSLiteral "\n") s1):(fixSemis' xs) -- TODO: is this needed? -fixSemis' ((NS (JSCase e1 ((NS (JSStatementList []) s1))) s2):(NS (JSCase e2 x) s3):xs) = +fixSemis' ((NS (JSCase e1 ((NS (JSStatementList []) s1))) s2):(NS (JSCase e2 x) s3):xs) = (NS (JSCase e1 ((NS (JSStatementList []) s1))) s2):fixSemis' ((NS (JSCase e2 x) s3):xs) fixSemis' (x:xs) = x:(NS (JSLiteral ";") SpanEmpty):fixSemis' xs @@ -274,10 +274,10 @@ fixBlock (NS (JSStatementBlock (NS (JSStatementList []) s1) ) _) = (NS (JSLitera fixBlock (NS (JSBlock (NS (JSStatementList [x]) _) ) _) = fixBlock x fixBlock (NS (JSStatementBlock (NS (JSStatementList [x]) _) ) _) = fixBlock x -fixBlock (NS (JSBlock (NS (JSStatementList xs) s1) ) s2) = +fixBlock (NS (JSBlock (NS (JSStatementList xs) s1) ) s2) = fixBlock' (NS (JSBlock (NS (JSStatementList (fixSourceElements xs)) s1)) s2) -fixBlock (NS (JSStatementBlock (NS (JSStatementList xs) s1) ) s2) = +fixBlock (NS (JSStatementBlock (NS (JSStatementList xs) s1) ) s2) = fixBlock' (NS (JSStatementBlock (NS (JSStatementList (fixSourceElements xs)) s1)) s2) fixBlock x = x @@ -290,12 +290,12 @@ fixBlock' x = x -- A space is needed if this expression starts with an identifier etc, but not if with a '(' spaceNeeded :: [JSNode] -> Bool -spaceNeeded xs = +spaceNeeded xs = let -- str = show $ rJS xs str = LB.unpack $ BB.toLazyByteString $ rJS xs - in - head str /= (fromIntegral $ ord '(') + in + (str /= []) && head str /= (fromIntegral $ ord '(') -- --------------------------------------------------------------------- -- Test stuff @@ -308,7 +308,7 @@ _case0 :: JSNode _case0 = NS (JSSourceElementsTop [NS (JSStatementBlock (NS (JSStatementList [NS (JSStatementBlock (NS (JSStatementList [NS (JSStatementBlock (NS (JSStatementList []) (SpanPoint {span_filename = "", span_row = 1, span_column = 3}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 3})]) (SpanPoint {span_filename = "", span_row = 1, span_column = 3}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 2})]) (SpanPoint {span_filename = "", span_row = 1, span_column = 2}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 1})]) (SpanPoint {span_filename = "", span_row = 1, span_column = 1}) _case01 :: [JSNode] -_case01 = [NS (JSStatementBlock (NS (JSStatementList [NS (JSStatementBlock (NS (JSStatementList [NS (JSStatementBlock (NS (JSStatementList []) (SpanPoint {span_filename = "", span_row = 1, span_column = 3}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 3})]) (SpanPoint {span_filename = "", span_row = 1, span_column = 3}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 2})]) (SpanPoint {span_filename = "", span_row = 1, span_column = 2}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 1})] +_case01 = [NS (JSStatementBlock (NS (JSStatementList [NS (JSStatementBlock (NS (JSStatementList [NS (JSStatementBlock (NS (JSStatementList []) (SpanPoint {span_filename = "", span_row = 1, span_column = 3}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 3})]) (SpanPoint {span_filename = "", span_row = 1, span_column = 3}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 2})]) (SpanPoint {span_filename = "", span_row = 1, span_column = 2}))) (SpanPoint {span_filename = "", span_row = 1, span_column = 1})] -- readJs "if(x){}{a=2}" _case1 :: JSNode diff --git a/hjsmin.cabal b/hjsmin.cabal index b875363..de8b941 100644 --- a/hjsmin.cabal +++ b/hjsmin.cabal @@ -1,12 +1,12 @@ name: hjsmin -version: 0.0.15 +version: 0.0.16 license: BSD3 license-file: LICENSE author: Alan Zimmerman maintainer: Alan Zimmerman synopsis: Haskell implementation of a javascript minifier description: - Reduces size of javascript files by stripping out extraneous whitespace and + Reduces size of javascript files by stripping out extraneous whitespace and other syntactic elements, without changing the semantics. category: Web stability: unstable @@ -15,7 +15,7 @@ build-type: Simple homepage: http://github.com/alanz/hjsmin bug-reports: http://github.com/alanz/hjsmin/issues -Extra-source-files: +Extra-source-files: TODO.txt, README.markdown, buildall.sh diff --git a/runtests.hs b/runtests.hs index 1925507..06819a9 100644 --- a/runtests.hs +++ b/runtests.hs @@ -16,17 +16,17 @@ main = defaultMain [testSuite,testSuiteMin,testSuiteFiles,testSuiteFilesUnminifi testSuite :: Test testSuite = testGroup "Text.Jasmine.Parse" - [ - testCase "helloWorld" caseHelloWorld - , testCase "helloWorld2" caseHelloWorld2 + [ + testCase "helloWorld" caseHelloWorld + , testCase "helloWorld2" caseHelloWorld2 , testCase "simpleAssignment" caseSimpleAssignment - , testCase "emptyFor" caseEmptyFor - , testCase "fullFor" caseFullFor - , testCase "forVarFull" caseForVarFull + , testCase "emptyFor" caseEmptyFor + , testCase "fullFor" caseFullFor + , testCase "forVarFull" caseForVarFull , testCase "ifelse1" caseIfElse1 , testCase "ifelse2" caseIfElse2 , testCase "0_f.js" case0_f - , testCase "01_semi1.js" case01_semi1 + , testCase "01_semi1.js" case01_semi1 , testCase "min_100_animals" case_min_100_animals , testCase "mergeStrings" caseMergeStrings , testCase "TrailingCommas" caseTrailingCommas @@ -34,111 +34,114 @@ testSuite = testGroup "Text.Jasmine.Parse" , testCase "Unicode" caseUnicode , testCase "Issue3" caseIssue3 , testCase "Issue4" caseIssue4 + , testCase "Issue7" caseIssue7 ] testSuiteMin :: Test testSuiteMin = testGroup "Text.Jasmine.Pretty" - [ testCase "helloWorld" caseMinHelloWorld - , testCase "helloWorld2" caseMinHelloWorld2 + [ testCase "helloWorld" caseMinHelloWorld + , testCase "helloWorld2" caseMinHelloWorld2 , testCase "simpleAssignment" caseMinSimpleAssignment , testCase "ifelse1" caseMinIfElse1 , testCase "ifelse2" caseMinIfElse2 , testCase "0_f.js" caseMin0_f - , testCase "01_semi1.js" caseMin01_semi1 + , testCase "01_semi1.js" caseMin01_semi1 , testCase "min_100_animals" caseMin_min_100_animals , testCase "minNestedSquare" caseMinNestedSquare , testCase "minMergeStrings" caseMinMergeStrings - , testCase "EitherLeft" caseEitherLeft - , testCase "EitherRight" caseEitherRight + , testCase "EitherLeft" caseEitherLeft + , testCase "EitherRight" caseEitherRight , testCase "TrailingCommas" caseMinTrailingCommas , testCase "GetSet" caseMinGetSet , testCase "Unicode" caseMinUnicode , testCase "MinIssue3" caseMinIssue3 , testCase "MinIssue4" caseMinIssue4 + , testCase "MinIssue7" caseMinIssue7 ] testSuiteFiles :: Test testSuiteFiles = testGroup "Text.Jasmine.Pretty files" [ testCase "00_f.js" (testFile "./test/pminified/00_f.js") - , testCase "01_semi1.js" (testFile "./test/pminified/01_semi1.js") - , testCase "02_sm.js" (testFile "./test/pminified/02_sm.js") - , testCase "03_sm.js" (testFile "./test/pminified/03_sm.js") - , testCase "04_if.js" (testFile "./test/pminified/04_if.js") - , testCase "05_comments_simple.js" (testFile "./test/pminified/05_comments_simple.js") - , testCase "05_regex.js" (testFile "./test/pminified/05_regex.js") - , testCase "06_callexpr.js" (testFile "./test/pminified/06_callexpr.js") - , testCase "06_newexpr.js" (testFile "./test/pminified/06_newexpr.js") - , testCase "06_var.js" (testFile "./test/pminified/06_var.js") - , testCase "07_expr.js" (testFile "./test/pminified/07_expr.js") - , testCase "10_switch.js" (testFile "./test/pminified/10_switch.js") - , testCase "14_labelled_stmts.js" (testFile "./test/pminified/14_labelled_stmts.js") - , testCase "15_literals.js" (testFile "./test/pminified/15_literals.js") - , testCase "16_literals.js" (testFile "./test/pminified/16_literals.js") - , testCase "20_statements.js" (testFile "./test/pminified/20_statements.js") - , testCase "25_trycatch.js" (testFile "./test/pminified/25_trycatch.js") - , testCase "40_functions.js" (testFile "./test/pminified/40_functions.js") - , testCase "67_bob.js" (testFile "./test/pminified/67_bob.js") - , testCase "110_perfect.js" (testFile "./test/pminified/110_perfect.js") - , testCase "120_js.js" (testFile "./test/pminified/120_js.js") - , testCase "121_jsdefs.js" (testFile "./test/pminified/121_jsdefs.js") - , testCase "122_jsexec.js" (testFile "./test/pminified/122_jsexec.js") - , testCase "122_jsexec2.js" (testFile "./test/pminified/122_jsexec2.js") - , testCase "122_jsexec3.js" (testFile "./test/pminified/122_jsexec3.js") - -- , testCase "123_jsparse.js" (testFile "./test/pminified/123_jsparse.js") + , testCase "01_semi1.js" (testFile "./test/pminified/01_semi1.js") + , testCase "02_sm.js" (testFile "./test/pminified/02_sm.js") + , testCase "03_sm.js" (testFile "./test/pminified/03_sm.js") + , testCase "04_if.js" (testFile "./test/pminified/04_if.js") + , testCase "05_comments_simple.js" (testFile "./test/pminified/05_comments_simple.js") + , testCase "05_regex.js" (testFile "./test/pminified/05_regex.js") + , testCase "06_callexpr.js" (testFile "./test/pminified/06_callexpr.js") + , testCase "06_newexpr.js" (testFile "./test/pminified/06_newexpr.js") + , testCase "06_var.js" (testFile "./test/pminified/06_var.js") + , testCase "07_expr.js" (testFile "./test/pminified/07_expr.js") + , testCase "10_switch.js" (testFile "./test/pminified/10_switch.js") + , testCase "14_labelled_stmts.js" (testFile "./test/pminified/14_labelled_stmts.js") + , testCase "15_literals.js" (testFile "./test/pminified/15_literals.js") + , testCase "16_literals.js" (testFile "./test/pminified/16_literals.js") + , testCase "20_statements.js" (testFile "./test/pminified/20_statements.js") + , testCase "25_trycatch.js" (testFile "./test/pminified/25_trycatch.js") + , testCase "40_functions.js" (testFile "./test/pminified/40_functions.js") + , testCase "67_bob.js" (testFile "./test/pminified/67_bob.js") + , testCase "110_perfect.js" (testFile "./test/pminified/110_perfect.js") + , testCase "120_js.js" (testFile "./test/pminified/120_js.js") + , testCase "121_jsdefs.js" (testFile "./test/pminified/121_jsdefs.js") + , testCase "122_jsexec.js" (testFile "./test/pminified/122_jsexec.js") + , testCase "122_jsexec2.js" (testFile "./test/pminified/122_jsexec2.js") + , testCase "122_jsexec3.js" (testFile "./test/pminified/122_jsexec3.js") + -- , testCase "123_jsparse.js" (testFile "./test/pminified/123_jsparse.js") -- TODO: something strange here, assigning code block to variable? -- See http://msdn.microsoft.com/en-us/library/77kz8hy0.aspx, get/set keywords for object accessors - - --, testCase "130_htojs2.js" (testFile "./test/parsingonly/130_htojs2.js") - --, testCase "" (testFile "./test/pminified/") - ] + + --, testCase "130_htojs2.js" (testFile "./test/parsingonly/130_htojs2.js") + --, testCase "" (testFile "./test/pminified/") + ] testSuiteFilesUnminified :: Test testSuiteFilesUnminified = testGroup "Text.Jasmine.Pretty filesUnminified" [ testCase "00_f.js" (testFileUnminified "00_f.js") - , testCase "01_semi1.js" (testFileUnminified "01_semi1.js") - , testCase "02_sm.js" (testFileUnminified "02_sm.js") - , testCase "03_sm.js" (testFileUnminified "03_sm.js") - , testCase "04_if.js" (testFileUnminified "04_if.js") - , testCase "05_comments_simple.js" (testFileUnminified "05_comments_simple.js") - , testCase "05_regex.js" (testFileUnminified "05_regex.js") - , testCase "06_callexpr.js" (testFileUnminified "06_callexpr.js") - , testCase "06_newexpr.js" (testFileUnminified "06_newexpr.js") - , testCase "06_var.js" (testFileUnminified "06_var.js") - , testCase "07_expr.js" (testFileUnminified "07_expr.js") - , testCase "10_switch.js" (testFileUnminified "10_switch.js") - , testCase "14_labelled_stmts.js" (testFileUnminified "14_labelled_stmts.js") - , testCase "15_literals.js" (testFileUnminified "15_literals.js") - , testCase "16_literals.js" (testFileUnminified "16_literals.js") - , testCase "20_statements.js" (testFileUnminified "20_statements.js") - , testCase "25_trycatch.js" (testFileUnminified "25_trycatch.js") - , testCase "40_functions.js" (testFileUnminified "40_functions.js") - , testCase "67_bob.js" (testFileUnminified "67_bob.js") - , testCase "110_perfect.js" (testFileUnminified "110_perfect.js") - , testCase "120_js.js" (testFileUnminified "120_js.js") - , testCase "121_jsdefs.js" (testFileUnminified "121_jsdefs.js") - , testCase "122_jsexec.js" (testFileUnminified "122_jsexec.js") - - --, testCase "122_jsexec2.js" (testFileUnminified "122_jsexec2.js") - ] + , testCase "01_semi1.js" (testFileUnminified "01_semi1.js") + , testCase "02_sm.js" (testFileUnminified "02_sm.js") + , testCase "03_sm.js" (testFileUnminified "03_sm.js") + , testCase "04_if.js" (testFileUnminified "04_if.js") + , testCase "05_comments_simple.js" (testFileUnminified "05_comments_simple.js") + , testCase "05_regex.js" (testFileUnminified "05_regex.js") + , testCase "06_callexpr.js" (testFileUnminified "06_callexpr.js") + , testCase "06_newexpr.js" (testFileUnminified "06_newexpr.js") + , testCase "06_var.js" (testFileUnminified "06_var.js") + , testCase "07_expr.js" (testFileUnminified "07_expr.js") + , testCase "10_switch.js" (testFileUnminified "10_switch.js") + , testCase "14_labelled_stmts.js" (testFileUnminified "14_labelled_stmts.js") + , testCase "15_literals.js" (testFileUnminified "15_literals.js") + , testCase "16_literals.js" (testFileUnminified "16_literals.js") + , testCase "20_statements.js" (testFileUnminified "20_statements.js") + , testCase "25_trycatch.js" (testFileUnminified "25_trycatch.js") + , testCase "40_functions.js" (testFileUnminified "40_functions.js") + , testCase "67_bob.js" (testFileUnminified "67_bob.js") + , testCase "110_perfect.js" (testFileUnminified "110_perfect.js") + , testCase "120_js.js" (testFileUnminified "120_js.js") + , testCase "121_jsdefs.js" (testFileUnminified "121_jsdefs.js") + , testCase "122_jsexec.js" (testFileUnminified "122_jsexec.js") + + --, testCase "122_jsexec2.js" (testFileUnminified "122_jsexec2.js") + + ] srcHelloWorld = "function Hello(a) {}" -caseHelloWorld = +caseHelloWorld = "Right (JSSourceElementsTop [JSFunction (JSIdentifier \"Hello\") [JSIdentifier \"a\"] (JSFunctionBody [])])" @=? (showStrippedMaybe $ parseProgram srcHelloWorld) -caseMinHelloWorld = +caseMinHelloWorld = -- "function Hello(a){}" @=? (minify (U.fromString srcHelloWorld)) testMinify "function Hello(a){}" srcHelloWorld - -srcHelloWorld2 = "function Hello(a) {b=1}" -caseHelloWorld2 = + +srcHelloWorld2 = "function Hello(a) {b=1}" +caseHelloWorld2 = "Right (JSSourceElementsTop [JSFunction (JSIdentifier \"Hello\") [JSIdentifier \"a\"] (JSFunctionBody [JSSourceElements [JSExpression [JSIdentifier \"b\",JSOperator \"=\",JSDecimal \"1\"]]])])" @=? (showStrippedMaybe $ parseProgram srcHelloWorld2) -caseMinHelloWorld2 = +caseMinHelloWorld2 = -- "function Hello(a){b=1}" @=? (minify (U.fromString srcHelloWorld2)) testMinify "function Hello(a){b=1}" srcHelloWorld2 -srcSimpleAssignment = "a=1;" -caseSimpleAssignment = +srcSimpleAssignment = "a=1;" +caseSimpleAssignment = "Right (JSSourceElementsTop [JSExpression [JSIdentifier \"a\",JSOperator \"=\",JSDecimal \"1\"],JSLiteral \";\"])" @=? (showStrippedMaybe $ parseProgram srcSimpleAssignment) caseMinSimpleAssignment = @@ -147,12 +150,12 @@ caseMinSimpleAssignment = srcEmptyFor = "for (i = 0;;){}" caseEmptyFor = "Right (JSSourceElementsTop [JSFor [JSExpression [JSIdentifier \"i\",JSOperator \"=\",JSDecimal \"0\"]] [] [] (JSStatementBlock (JSStatementList []))])" - @=? (showStrippedMaybe $ parseProgram srcEmptyFor) + @=? (showStrippedMaybe $ parseProgram srcEmptyFor) srcFullFor = "for (i = 0;i<10;i++){}" caseFullFor = "Right (JSSourceElementsTop [JSFor [JSExpression [JSIdentifier \"i\",JSOperator \"=\",JSDecimal \"0\"]] [JSExpression [JSExpressionBinary \"<\" [JSIdentifier \"i\"] [JSDecimal \"10\"]]] [JSExpression [JSExpressionPostfix \"++\" [JSIdentifier \"i\"]]] (JSStatementBlock (JSStatementList []))])" @=? (showStrippedMaybe $ parseProgram srcFullFor) - + srcForVarFull = "for(var i=0,j=tokens.length;i IO () testFile filename = - do + do x <- readFile (filename) let x' = trim x -- x' @=? (minify (U.fromString x') ) - testMinify x' x' + testMinify x' x' testFileUnminified :: FilePath -> IO () testFileUnminified filename = - do + do x <- readFile ("./test/pminified/" ++ filename) y <- readFile ("./test/parsingonly/" ++ filename) let x' = trim x @@ -288,6 +307,6 @@ trim = f . f where f = reverse . dropWhile isSpace -- For language-javascript -parseProgram src = parse src "src" - +parseProgram src = parse src "src" + -- EOF diff --git a/test/parsingonly/issue7.hs b/test/parsingonly/issue7.hs new file mode 100644 index 0000000..be097fa --- /dev/null +++ b/test/parsingonly/issue7.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE OverloadedStrings #-} +import Text.Jasmine +import qualified Data.ByteString.Lazy as L + +main = do + lbs <- L.readFile "tmp.js" + print $ minifym lbs diff --git a/test/parsingonly/issue7.js b/test/parsingonly/issue7.js new file mode 100644 index 0000000..3a3f678 --- /dev/null +++ b/test/parsingonly/issue7.js @@ -0,0 +1 @@ +var hljs=new function(){function m(p){return p.replace(/&/gm,"&").replace(/"}while(y.length||z.length){var v=u().splice(0,1)[0];w+=m(x.substr(r,v.offset-r));r=v.offset;if(v.event=="start"){w+=s(v.node);t.push(v.node)}else{if(v.event=="stop"){var q=t.length;do{q--;var p=t[q];w+=("")}while(p!=v.node);t.splice(q,1);while(q'+m(L[0])+""}else{N+=m(L[0])}P=O.lR.lastIndex;L=O.lR.exec(M)}N+=m(M.substr(P,M.length-P));return N}function K(r,M){if(M.sL&&d[M.sL]){var L=e(M.sL,r);t+=L.keyword_count;return L.value}else{return F(r,M)}}function I(M,r){var L=M.cN?'':"";if(M.rB){q+=L;M.buffer=""}else{if(M.eB){q+=m(r)+L;M.buffer=""}else{q+=L;M.buffer=r}}C.push(M);B+=M.r}function E(O,L,Q){var R=C[C.length-1];if(Q){q+=K(R.buffer+O,R);return false}var M=z(L,R);if(M){q+=K(R.buffer+O,R);I(M,L);return M.rB}var r=w(C.length-1,L);if(r){var N=R.cN?"":"";if(R.rE){q+=K(R.buffer+O,R)+N}else{if(R.eE){q+=K(R.buffer+O,R)+N+m(L)}else{q+=K(R.buffer+O+L,R)+N}}while(r>1){N=C[C.length-2].cN?"":"";q+=N;r--;C.length--}var P=C[C.length-1];C.length--;C[C.length-1].buffer="";if(P.starts){I(P.starts,"")}return R.rE}if(x(L,R)){throw"Illegal"}}var H=d[J];var C=[H.dM];var B=0;var t=0;var q="";try{var v=0;H.dM.buffer="";do{var y=s(D,v);var u=E(y[0],y[1],y[2]);v+=y[0].length;if(!u){v+=y[1].length}}while(!y[2]);if(C.length>1){throw"Illegal"}return{r:B,keyword_count:t,value:q}}catch(G){if(G=="Illegal"){return{r:0,keyword_count:0,value:m(D)}}else{throw G}}}function f(t){var r={keyword_count:0,r:0,value:m(t)};var q=r;for(var p in d){if(!d.hasOwnProperty(p)){continue}var s=e(p,t);s.language=p;if(s.keyword_count+s.r>q.keyword_count+q.r){q=s}if(s.keyword_count+s.r>r.keyword_count+r.r){q=r;r=s}}if(q.language){r.second_best=q}return r}function h(r,q,p){if(q){r=r.replace(/^((<[^>]+>|\t)+)/gm,function(t,w,v,u){return w.replace(/\t/g,q)})}if(p){r=r.replace(/\n/g,"
")}return r}function o(u,x,q){var y=g(u,q);var s=a(u);if(s=="no-highlight"){return}if(s){var w=e(s,y)}else{var w=f(y);s=w.language}var p=b(u);if(p.length){var r=document.createElement("pre");r.innerHTML=w.value;w.value=l(p,b(r),y)}w.value=h(w.value,x,q);var t=u.className;if(!t.match("(\\s|^)(language-)?"+s+"(\\s|$)")){t=t?(t+" "+s):s}if(/MSIE [678]/.test(navigator.userAgent)&&u.tagName=="CODE"&&u.parentNode.tagName=="PRE"){var r=u.parentNode;var v=document.createElement("div");v.innerHTML="
"+w.value+"
";u=v.firstChild.firstChild;v.firstChild.cN=r.cN;r.parentNode.replaceChild(v.firstChild,r)}else{u.innerHTML=w.value}u.className=t;u.result={language:s,kw:w.keyword_count,re:w.r};if(w.second_best){u.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function k(){if(k.called){return}k.called=true;var r=document.getElementsByTagName("pre");for(var p=0;p|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\.",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.inherit=function(p,s){var r={};for(var q in p){r[q]=p[q]}if(s){for(var q in s){r[q]=s[q]}}return r}}();hljs.LANGUAGES.bash=function(){var d={"true":1,"false":1};var b={cN:"variable",b:"\\$([a-zA-Z0-9_]+)\\b"};var a={cN:"variable",b:"\\$\\{(([^}])|(\\\\}))+\\}",c:[hljs.CNM]};var c={cN:"string",b:'"',e:'"',i:"\\n",c:[hljs.BE,b,a],r:0};var e={cN:"test_condition",b:"",e:"",c:[c,b,a,hljs.CNM],k:{literal:d},r:0};return{dM:{k:{keyword:{"if":1,then:1,"else":1,fi:1,"for":1,"break":1,"continue":1,"while":1,"in":1,"do":1,done:1,echo:1,exit:1,"return":1,set:1,declare:1},literal:d},c:[{cN:"shebang",b:"(#!\\/bin\\/bash)|(#!\\/bin\\/sh)",r:10},hljs.HCM,hljs.CNM,c,b,a,hljs.inherit(e,{b:"\\[ ",e:" \\]",r:0}),hljs.inherit(e,{b:"\\[\\[ ",e:" \\]\\]"})]}}}();hljs.LANGUAGES.javascript={dM:{k:{keyword:{"in":1,"if":1,"for":1,"while":1,"finally":1,"var":1,"new":1,"function":1,"do":1,"return":1,"void":1,"else":1,"break":1,"catch":1,"instanceof":1,"with":1,"throw":1,"case":1,"default":1,"try":1,"this":1,"switch":1,"continue":1,"typeof":1,"delete":1},literal:{"true":1,"false":1,"null":1}},c:[hljs.ASM,hljs.QSM,hljs.CLCM,hljs.CBLCLM,hljs.CNM,{b:"("+hljs.RSR+"|case|return|throw)\\s*",k:{"return":1,"throw":1,"case":1},c:[hljs.CLCM,hljs.CBLCLM,{cN:"regexp",b:"/",e:"/[gim]*",c:[{b:"\\\\/"}]}],r:0},{cN:"function",b:"\\bfunction\\b",e:"{",k:{"function":1},c:[{cN:"title",b:"[A-Za-z$_][0-9A-Za-z$_]*"},{cN:"params",b:"\\(",e:"\\)",c:[hljs.ASM,hljs.QSM,hljs.CLCM,hljs.CBLCLM]}]}]}};hljs.LANGUAGES.css=function(){var a={cN:"function",b:hljs.IR+"\\(",e:"\\)",c:[{eW:true,eE:true,c:[hljs.NM,hljs.ASM,hljs.QSM]}]};return{cI:true,dM:{i:"[=/|']",c:[hljs.CBLCLM,{cN:"id",b:"\\#[A-Za-z0-9_-]+"},{cN:"class",b:"\\.[A-Za-z0-9_-]+",r:0},{cN:"attr_selector",b:"\\[",e:"\\]",i:"$"},{cN:"pseudo",b:":(:)?[a-zA-Z0-9\\_\\-\\+\\(\\)\\\"\\']+"},{cN:"at_rule",b:"@(font-face|page)",l:"[a-z-]+",k:{"font-face":1,page:1}},{cN:"at_rule",b:"@",e:"[{;]",eE:true,k:{"import":1,page:1,media:1,charset:1},c:[a,hljs.ASM,hljs.QSM,hljs.NM]},{cN:"tag",b:hljs.IR,r:0},{cN:"rules",b:"{",e:"}",i:"[^\s]",r:0,c:[hljs.CBLCLM,{cN:"rule",b:"[^\s]",rB:true,e:";",eW:true,c:[{cN:"attribute",b:"[A-Z\\_\\.\\-]+",e:":",eE:true,i:"[^\s]",starts:{cN:"value",eW:true,eE:true,c:[a,hljs.NM,hljs.QSM,hljs.ASM,hljs.CBLCLM,{cN:"hexcolor",b:"\\#[0-9A-F]+"},{cN:"important",b:"!important"}]}}]}]}]}}}();hljs.LANGUAGES.xml=function(){var b="[A-Za-z0-9\\._:-]+";var a={eW:true,c:[{cN:"attribute",b:b,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\s/>]+"}]}]};return{cI:true,dM:{c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"",k:{title:{style:1}},c:[a],starts:{cN:"css",e:"",rE:true,sL:"css"}},{cN:"tag",b:"",k:{title:{script:1}},c:[a],starts:{cN:"javascript",e:"<\/script>",rE:true,sL:"javascript"}},{cN:"vbscript",b:"<%",e:"%>",sL:"vbscript"},{cN:"tag",b:"",c:[{cN:"title",b:"[^ />]+"},a]}]}}}();hljs.LANGUAGES.java={dM:{k:{"false":1,"synchronized":1,"int":1,"abstract":1,"float":1,"private":1,"char":1,"interface":1,"boolean":1,"static":1,"null":1,"if":1,"const":1,"for":1,"true":1,"while":1,"long":1,"throw":1,strictfp:1,"finally":1,"protected":1,"extends":1,"import":1,"native":1,"final":1,"implements":1,"return":1,"void":1,"enum":1,"else":1,"break":1,"transient":1,"new":1,"catch":1,"instanceof":1,"byte":1,"super":1,"class":1,"volatile":1,"case":1,assert:1,"short":1,"package":1,"default":1,"double":1,"public":1,"try":1,"this":1,"switch":1,"continue":1,"throws":1},c:[{cN:"javadoc",b:"/\\*\\*",e:"\\*/",c:[{cN:"javadoctag",b:"@[A-Za-z]+"}],r:10},hljs.CLCM,hljs.CBLCLM,hljs.ASM,hljs.QSM,{cN:"class",b:"(class |interface )",e:"{",k:{"class":1,"interface":1},i:":",c:[{b:"(implements|extends)",k:{"extends":1,"implements":1},r:10},{cN:"title",b:hljs.UIR}]},hljs.CNM,{cN:"annotation",b:"@[A-Za-z]+"}]}};hljs.LANGUAGES.haskell=function(){var a={cN:"label",b:"\\b[A-Z][\\w']*",r:0};var b={cN:"container",b:"\\(",e:"\\)",c:[{cN:"label",b:"\\b[A-Z][\\w\\(\\)\\.']*"},{cN:"title",b:"[_a-z][\\w']*"}]};return{dM:{k:{keyword:{let:1,"in":1,"if":1,then:1,"else":1,"case":1,of:1,where:1,"do":1,module:1,"import":1,hiding:1,qualified:1,type:1,data:1,newtype:1,deriving:1,"class":1,instance:1,"null":1,not:1,as:1}},c:[{cN:"comment",b:"--",e:"$"},{cN:"comment",b:"{-",e:"-}"},{cN:"string",b:"\\s+'",e:"'",c:[hljs.BE],r:0},hljs.QSM,{cN:"import",b:"\\bimport",e:"$",k:{"import":1,qualified:1,as:1,hiding:1},c:[b]},{cN:"module",b:"\\bmodule",e:"where",k:{module:1,where:1},c:[b]},{cN:"class",b:"\\b(class|instance|data|(new)?type)",e:"(where|$)",k:{"class":1,where:1,instance:1,data:1,type:1,newtype:1,deriving:1},c:[a]},hljs.CNM,{cN:"shebang",b:"#!\\/usr\\/bin\\/env runhaskell",e:"$"},a,{cN:"title",b:"^[_a-z][\\w']*"}]}}}();hljs.LANGUAGES.sql={cI:true,dM:{i:"[^\s]",c:[{cN:"operator",b:"(begin|start|commit|rollback|savepoint|lock|alter|create|drop|rename|call|delete|do|handler|insert|load|replace|select|truncate|update|set|show|pragma)\\b",e:";|$",k:{keyword:{all:1,partial:1,global:1,month:1,current_timestamp:1,using:1,go:1,revoke:1,smallint:1,indicator:1,"end-exec":1,disconnect:1,zone:1,"with":1,character:1,assertion:1,to:1,add:1,current_user:1,usage:1,input:1,local:1,alter:1,match:1,collate:1,real:1,then:1,rollback:1,get:1,read:1,timestamp:1,session_user:1,not:1,integer:1,bit:1,unique:1,day:1,minute:1,desc:1,insert:1,execute:1,like:1,ilike:2,level:1,decimal:1,drop:1,"continue":1,isolation:1,found:1,where:1,constraints:1,domain:1,right:1,national:1,some:1,module:1,transaction:1,relative:1,second:1,connect:1,escape:1,close:1,system_user:1,"for":1,deferred:1,section:1,cast:1,current:1,sqlstate:1,allocate:1,intersect:1,deallocate:1,numeric:1,"public":1,preserve:1,full:1,"goto":1,initially:1,asc:1,no:1,key:1,output:1,collation:1,group:1,by:1,union:1,session:1,both:1,last:1,language:1,constraint:1,column:1,of:1,space:1,foreign:1,deferrable:1,prior:1,connection:1,unknown:1,action:1,commit:1,view:1,or:1,first:1,into:1,"float":1,year:1,primary:1,cascaded:1,except:1,restrict:1,set:1,references:1,names:1,table:1,outer:1,open:1,select:1,size:1,are:1,rows:1,from:1,prepare:1,distinct:1,leading:1,create:1,only:1,next:1,inner:1,authorization:1,schema:1,corresponding:1,option:1,declare:1,precision:1,immediate:1,"else":1,timezone_minute:1,external:1,varying:1,translation:1,"true":1,"case":1,exception:1,join:1,hour:1,"default":1,"double":1,scroll:1,value:1,cursor:1,descriptor:1,values:1,dec:1,fetch:1,procedure:1,"delete":1,and:1,"false":1,"int":1,is:1,describe:1,"char":1,as:1,at:1,"in":1,varchar:1,"null":1,trailing:1,any:1,absolute:1,current_time:1,end:1,grant:1,privileges:1,when:1,cross:1,check:1,write:1,current_date:1,pad:1,begin:1,temporary:1,exec:1,time:1,update:1,catalog:1,user:1,sql:1,date:1,on:1,identity:1,timezone_hour:1,natural:1,whenever:1,interval:1,work:1,order:1,cascade:1,diagnostics:1,nchar:1,having:1,left:1,call:1,"do":1,handler:1,load:1,replace:1,truncate:1,start:1,lock:1,show:1,pragma:1},aggregate:{count:1,sum:1,min:1,max:1,avg:1}},c:[{cN:"string",b:"'",e:"'",c:[hljs.BE,{b:"''"}],r:0},{cN:"string",b:'"',e:'"',c:[hljs.BE,{b:'""'}],r:0},{cN:"string",b:"`",e:"`",c:[hljs.BE]},hljs.CNM,{b:"\\n"}]},hljs.CBLCLM,{cN:"comment",b:"--",e:"$"}]}};hljs.LANGUAGES.nginx=function(){var c={cN:"variable",b:"\\$\\d+"};var b={cN:"variable",b:"\\${",e:"}"};var a={cN:"variable",b:"[\\$\\@]"+hljs.UIR};return{dM:{c:[hljs.HCM,{b:hljs.UIR,e:";|{",rE:true,k:{accept_mutex:1,accept_mutex_delay:1,access_log:1,add_after_body:1,add_before_body:1,add_header:1,addition_types:1,alias:1,allow:1,ancient_browser:1,ancient_browser:1,ancient_browser_value:1,ancient_browser_value:1,auth_basic:1,auth_basic_user_file:1,autoindex:1,autoindex_exact_size:1,autoindex_localtime:1,"break":1,charset:1,charset:1,charset_map:1,charset_map:1,charset_types:1,charset_types:1,client_body_buffer_size:1,client_body_in_file_only:1,client_body_in_single_buffer:1,client_body_temp_path:1,client_body_timeout:1,client_header_buffer_size:1,client_header_timeout:1,client_max_body_size:1,connection_pool_size:1,connections:1,create_full_put_path:1,daemon:1,dav_access:1,dav_methods:1,debug_connection:1,debug_points:1,default_type:1,deny:1,directio:1,directio_alignment:1,echo:1,echo_after_body:1,echo_before_body:1,echo_blocking_sleep:1,echo_duplicate:1,echo_end:1,echo_exec:1,echo_flush:1,echo_foreach_split:1,echo_location:1,echo_location_async:1,echo_read_request_body:1,echo_request_body:1,echo_reset_timer:1,echo_sleep:1,echo_subrequest:1,echo_subrequest_async:1,empty_gif:1,empty_gif:1,env:1,error_log:1,error_log:1,error_page:1,events:1,expires:1,fastcgi_bind:1,fastcgi_buffer_size:1,fastcgi_buffers:1,fastcgi_busy_buffers_size:1,fastcgi_cache:1,fastcgi_cache_key:1,fastcgi_cache_methods:1,fastcgi_cache_min_uses:1,fastcgi_cache_path:1,fastcgi_cache_use_stale:1,fastcgi_cache_valid:1,fastcgi_catch_stderr:1,fastcgi_connect_timeout:1,fastcgi_hide_header:1,fastcgi_ignore_client_abort:1,fastcgi_ignore_headers:1,fastcgi_index:1,fastcgi_intercept_errors:1,fastcgi_max_temp_file_size:1,fastcgi_next_upstream:1,fastcgi_param:1,fastcgi_pass:1,fastcgi_pass_header:1,fastcgi_pass_request_body:1,fastcgi_pass_request_headers:1,fastcgi_read_timeout:1,fastcgi_send_lowat:1,fastcgi_send_timeout:1,fastcgi_split_path_info:1,fastcgi_store:1,fastcgi_store_access:1,fastcgi_temp_file_write_size:1,fastcgi_temp_path:1,fastcgi_upstream_fail_timeout:1,fastcgi_upstream_max_fails:1,flv:1,geo:1,geo:1,geoip_city:1,geoip_country:1,gzip:1,gzip_buffers:1,gzip_comp_level:1,gzip_disable:1,gzip_hash:1,gzip_http_version:1,gzip_min_length:1,gzip_no_buffer:1,gzip_proxied:1,gzip_static:1,gzip_types:1,gzip_vary:1,gzip_window:1,http:1,"if":1,if_modified_since:1,ignore_invalid_headers:1,image_filter:1,image_filter_buffer:1,image_filter_jpeg_quality:1,image_filter_transparency:1,include:1,index:1,internal:1,ip_hash:1,js:1,js_load:1,js_require:1,js_utf8:1,keepalive_requests:1,keepalive_timeout:1,kqueue_changes:1,kqueue_events:1,large_client_header_buffers:1,limit_conn:1,limit_conn_log_level:1,limit_except:1,limit_rate:1,limit_rate_after:1,limit_req:1,limit_req_log_level:1,limit_req_zone:1,limit_zone:1,lingering_time:1,lingering_timeout:1,listen:1,location:1,lock_file:1,log_format:1,log_not_found:1,log_subrequest:1,map:1,map_hash_bucket_size:1,map_hash_max_size:1,master_process:1,memcached_bind:1,memcached_buffer_size:1,memcached_connect_timeout:1,memcached_next_upstream:1,memcached_pass:1,memcached_read_timeout:1,memcached_send_timeout:1,memcached_upstream_fail_timeout:1,memcached_upstream_max_fails:1,merge_slashes:1,min_delete_depth:1,modern_browser:1,modern_browser:1,modern_browser_value:1,modern_browser_value:1,more_clear_headers:1,more_clear_input_headers:1,more_set_headers:1,more_set_input_headers:1,msie_padding:1,msie_refresh:1,multi_accept:1,open_file_cache:1,open_file_cache_errors:1,open_file_cache_events:1,open_file_cache_min_uses:1,open_file_cache_retest:1,open_file_cache_valid:1,open_log_file_cache:1,optimize_server_names:1,output_buffers:1,override_charset:1,override_charset:1,perl:1,perl_modules:1,perl_require:1,perl_set:1,pid:1,port_in_redirect:1,post_action:1,postpone_gzipping:1,postpone_output:1,proxy_bind:1,proxy_buffer_size:1,proxy_buffering:1,proxy_buffers:1,proxy_busy_buffers_size:1,proxy_cache:1,proxy_cache_key:1,proxy_cache_methods:1,proxy_cache_min_uses:1,proxy_cache_path:1,proxy_cache_use_stale:1,proxy_cache_valid:1,proxy_connect_timeout:1,proxy_headers_hash_bucket_size:1,proxy_headers_hash_max_size:1,proxy_hide_header:1,proxy_ignore_client_abort:1,proxy_ignore_headers:1,proxy_intercept_errors:1,proxy_max_temp_file_size:1,proxy_method:1,proxy_next_upstream:1,proxy_pass:1,proxy_pass_header:1,proxy_pass_request_body:1,proxy_pass_request_headers:1,proxy_read_timeout:1,proxy_redirect:1,proxy_send_lowat:1,proxy_send_timeout:1,proxy_set_body:1,proxy_set_header:1,proxy_store:1,proxy_store_access:1,proxy_temp_file_write_size:1,proxy_temp_path:1,proxy_upstream_fail_timeout:1,proxy_upstream_max_fails:1,push_authorized_channels_only:1,push_channel_group:1,push_max_channel_id_length:1,push_max_channel_subscribers:1,push_max_message_buffer_length:1,push_max_reserved_memory:1,push_message_buffer_length:1,push_message_timeout:1,push_min_message_buffer_length:1,push_min_message_recipients:1,push_publisher:1,push_store_messages:1,push_subscriber:1,push_subscriber_concurrency:1,random_index:1,read_ahead:1,real_ip_header:1,recursive_error_pages:1,request_pool_size:1,reset_timedout_connection:1,resolver:1,resolver_timeout:1,"return":1,rewrite:1,rewrite_log:1,root:1,satisfy:1,satisfy_any:1,send_lowat:1,send_timeout:1,sendfile:1,sendfile_max_chunk:1,server:1,server:1,server_name:1,server_name_in_redirect:1,server_names_hash_bucket_size:1,server_names_hash_max_size:1,server_tokens:1,set:1,set_real_ip_from:1,source_charset:1,source_charset:1,ssi:1,ssi_ignore_recycled_buffers:1,ssi_min_file_chunk:1,ssi_silent_errors:1,ssi_types:1,ssi_value_length:1,ssl:1,ssl_certificate:1,ssl_certificate_key:1,ssl_ciphers:1,ssl_client_certificate:1,ssl_crl:1,ssl_dhparam:1,ssl_prefer_server_ciphers:1,ssl_protocols:1,ssl_session_cache:1,ssl_session_timeout:1,ssl_verify_client:1,ssl_verify_depth:1,sub_filter:1,sub_filter_once:1,sub_filter_types:1,tcp_nodelay:1,tcp_nopush:1,timer_resolution:1,try_files:1,types:1,types_hash_bucket_size:1,types_hash_max_size:1,underscores_in_headers:1,uninitialized_variable_warn:1,upstream:1,use:1,user:1,userid:1,userid:1,userid_domain:1,userid_domain:1,userid_expires:1,userid_expires:1,userid_mark:1,userid_name:1,userid_name:1,userid_p3p:1,userid_p3p:1,userid_path:1,userid_path:1,userid_service:1,userid_service:1,valid_referers:1,variables_hash_bucket_size:1,variables_hash_max_size:1,worker_connections:1,worker_cpu_affinity:1,worker_priority:1,worker_processes:1,worker_rlimit_core:1,worker_rlimit_nofile:1,worker_rlimit_sigpending:1,working_directory:1,xml_entities:1,xslt_stylesheet:1,xslt_types:1},r:0,c:[hljs.HCM,{b:"\\s",e:"[;{]",rB:true,rE:true,l:"[a-z/]+",k:{built_in:{on:1,off:1,yes:1,no:1,"true":1,"false":1,none:1,blocked:1,debug:1,info:1,notice:1,warn:1,error:1,crit:1,select:1,permanent:1,redirect:1,kqueue:1,rtsig:1,epoll:1,poll:1,"/dev/poll":1}},r:0,c:[hljs.HCM,{cN:"string",b:'"',e:'"',c:[hljs.BE,c,b,a],r:0},{cN:"string",b:"'",e:"'",c:[hljs.BE,c,b,a],r:0},{cN:"string",b:"([a-z]+):/",e:"[;\\s]",rE:true},{cN:"regexp",b:"\\s\\^",e:"\\s|{|;",rE:true,c:[hljs.BE,c,b,a]},{cN:"regexp",b:"~\\*?\\s+",e:"\\s|{|;",rE:true,c:[hljs.BE,c,b,a]},{cN:"regexp",b:"\\*(\\.[a-z\\-]+)+",c:[hljs.BE,c,b,a]},{cN:"regexp",b:"([a-z\\-]+\\.)+\\*",c:[hljs.BE,c,b,a]},{cN:"number",b:"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b"},{cN:"number",b:"\\s\\d+[kKmMgGdshdwy]*\\b",r:0},c,b,a]}]}]}}}();hljs.initHighlighting();