diff options
| author | bringert <bringert@cs.chalmers.se> | 2006-12-20 20:10:15 +0000 |
|---|---|---|
| committer | bringert <bringert@cs.chalmers.se> | 2006-12-20 20:10:15 +0000 |
| commit | f9621483a0caeb49512bf4d15420bd05ea57cb22 (patch) | |
| tree | 44e21f8e2fd66b9f53f9a312ddde52bdab0fc4df /src/GF/JavaScript/PrintJS.hs | |
| parent | c7df9f4167f7b554a93a216245a013e16cca420d (diff) | |
Use LCLR algorithm for eliminating left-recursion, with lambda terms in SISR for getting trees right.
Diffstat (limited to 'src/GF/JavaScript/PrintJS.hs')
| -rw-r--r-- | src/GF/JavaScript/PrintJS.hs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/GF/JavaScript/PrintJS.hs b/src/GF/JavaScript/PrintJS.hs index 79829dec8..af9504c74 100644 --- a/src/GF/JavaScript/PrintJS.hs +++ b/src/GF/JavaScript/PrintJS.hs @@ -1,5 +1,5 @@ {-# OPTIONS -fno-warn-incomplete-patterns #-} -module GF.JavaScript.PrintJS where +module GF.JavaScript.PrintJS (printTree, Doc, Print(..)) where -- pretty-printer generated by the BNF converter @@ -25,8 +25,10 @@ render d = rend 0 (map ($ "") $ d []) "" where "}" :ts -> new (i-1) . showChar '}' . new (i-1) . rend (i-1) ts ";" :ts -> showChar ';' . new i . rend i ts t : "," :ts -> showString t . space "," . rend i ts + t : "." :ts -> showString t . showString "." . rend i ts t : ")" :ts -> showString t . showChar ')' . rend i ts t : "]" :ts -> showString t . showChar ']' . rend i ts + t : "[" :ts -> showString t . showChar '[' . rend i ts t :ts -> space t . rend i ts _ -> id new i = showChar '\n' . replicateS (2*i) (showChar ' ') . dropWhile isSpace @@ -143,6 +145,7 @@ instance Print Expr where ENull -> prPrec i 16 (concatD [doc (showString "null")]) EThis -> prPrec i 16 (concatD [doc (showString "this")]) EFun ids stmts -> prPrec i 16 (concatD [doc (showString "function") , doc (showString "(") , prt 0 ids , doc (showString ")") , doc (showString "{") , prt 0 stmts , doc (showString "}")]) + ESeq exprs -> prPrec i 16 (concatD [doc (showString "(") , prt 0 exprs , doc (showString ")")]) prtList es = case es of [] -> (concatD []) |
