From f9621483a0caeb49512bf4d15420bd05ea57cb22 Mon Sep 17 00:00:00 2001 From: bringert Date: Wed, 20 Dec 2006 20:10:15 +0000 Subject: Use LCLR algorithm for eliminating left-recursion, with lambda terms in SISR for getting trees right. --- src/GF/JavaScript/PrintJS.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/GF/JavaScript/PrintJS.hs') 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 []) -- cgit v1.2.3