Changeset 7866

Show
Ignore:
Timestamp:
11/06/05 01:28:07 (3 years ago)
Author:
autrijus
Message:

* New compiler backend targets around PIL2:

./pugs -C PIL2-Perl5
./pugs -C PIL2-JSON
./pugs -C PIL2-Binary

The dash is optional (all nonalphanum is dropped), and
it's case insensitive. Eventually these will replace
the PIL1 variants when our p5/js codegens finishes the
migration.

Files:
4 modified

Legend:

Unmodified
Added
Removed
  • Pugs.cabal.in

    r7843 r7866  
    1212author: Autrijus Tang <autrijus@autrijus.org> 
    1313tested-with: GHC -any 
    14 exposed-modules: Pugs Pugs.AST Pugs.AST.Internals Pugs.AST.Pad Pugs.AST.Pos Pugs.AST.Prag Pugs.AST.SIO Pugs.AST.Scope Pugs.Bind Pugs.CodeGen Pugs.CodeGen.Binary Pugs.CodeGen.JSON Pugs.CodeGen.PIL1 Pugs.CodeGen.PIL2 Pugs.CodeGen.PIR Pugs.CodeGen.PIR.Prelude Pugs.CodeGen.Perl5 Pugs.Compat Pugs.Compile Pugs.Compile.Haskell Pugs.Compile.Pugs Pugs.Config Pugs.Cont Pugs.Embed Pugs.Embed.Haskell Pugs.Embed.Parrot Pugs.Embed.Perl5 Pugs.Embed.Pugs Pugs.Eval Pugs.Eval.Var Pugs.External Pugs.External.Haskell Pugs.Help Pugs.Internals Pugs.Junc Pugs.Lexer Pugs.Monads Pugs.PIL1 Pugs.PIL2 Pugs.Parser Pugs.Parser.Number Pugs.Parser.Program Pugs.Parser.Types Pugs.Parser.Unsafe Pugs.Pretty Pugs.Prim Pugs.Prim.Code Pugs.Prim.Eval Pugs.Prim.FileTest Pugs.Prim.Keyed Pugs.Prim.Lifts Pugs.Prim.List Pugs.Prim.Match Pugs.Prim.Numeric Pugs.Prim.Param Pugs.Prim.Yaml Pugs.Rule Pugs.Rule.Char Pugs.Rule.Combinator Pugs.Rule.Error Pugs.Rule.Expr Pugs.Rule.Language Pugs.Rule.Pos Pugs.Rule.Prim Pugs.Rule.Token Pugs.Run Pugs.Run.Args Pugs.Run.Perl5 Pugs.Shell Pugs.Types Pugs.Version Emit.Common Emit.PIR  
     14exposed-modules: Pugs Pugs.AST Pugs.AST.Internals Pugs.AST.Pad Pugs.AST.Pos Pugs.AST.Prag Pugs.AST.SIO Pugs.AST.Scope Pugs.Bind Pugs.CodeGen Pugs.CodeGen.Binary Pugs.CodeGen.JSON Pugs.CodeGen.PIL1 Pugs.CodeGen.PIL2 Pugs.CodeGen.PIR Pugs.CodeGen.PIR.Prelude Pugs.CodeGen.Perl5 Pugs.Compat Pugs.Compile Pugs.Compile.PIL2 Pugs.Compile.Haskell Pugs.Compile.Pugs Pugs.Config Pugs.Cont Pugs.Embed Pugs.Embed.Haskell Pugs.Embed.Parrot Pugs.Embed.Perl5 Pugs.Embed.Pugs Pugs.Eval Pugs.Eval.Var Pugs.External Pugs.External.Haskell Pugs.Help Pugs.Internals Pugs.Junc Pugs.Lexer Pugs.Monads Pugs.PIL1 Pugs.PIL2 Pugs.Parser Pugs.Parser.Number Pugs.Parser.Program Pugs.Parser.Types Pugs.Parser.Unsafe Pugs.Pretty Pugs.Prim Pugs.Prim.Code Pugs.Prim.Eval Pugs.Prim.FileTest Pugs.Prim.Keyed Pugs.Prim.Lifts Pugs.Prim.List Pugs.Prim.Match Pugs.Prim.Numeric Pugs.Prim.Param Pugs.Prim.Yaml Pugs.Rule Pugs.Rule.Char Pugs.Rule.Combinator Pugs.Rule.Error Pugs.Rule.Expr Pugs.Rule.Language Pugs.Rule.Pos Pugs.Rule.Prim Pugs.Rule.Token Pugs.Run Pugs.Run.Args Pugs.Run.Perl5 Pugs.Shell Pugs.Types Pugs.Version Emit.Common Emit.PIR  
    1515buildable: True 
    1616c-sources: src/cbits/fpstring.c src/pcre/pcre.c __UNICODE_C__ 
  • src/Pugs/CodeGen.hs

    r7843 r7866  
    1414import Pugs.Internals 
    1515import Pugs.CodeGen.PIL1 (genPIL1) 
    16 import Pugs.CodeGen.PIL2 (genPIL2) 
     16import Pugs.CodeGen.PIL2 (genPIL2, genPIL2Perl5, genPIL2Binary, genPIL2JSON) 
    1717import Pugs.CodeGen.PIR (genPIR) 
    1818import Pugs.CodeGen.Perl5 (genPerl5) 
     
    3333    , ("PIL1",        genPIL1) 
    3434    , ("PIL2",        genPIL2) 
     35    , ("PIL2-Perl5",  genPIL2Perl5) 
     36    , ("PIL2-JSON",   genPIL2JSON) 
     37    , ("PIL2-Binary", genPIL2Binary) 
    3538    , ("Perl5",       genPerl5) 
    3639    , ("Pugs",        genPugs) 
     
    4447 
    4548norm :: String -> String 
    46 norm = norm' . map toLower 
     49norm = norm' . map toLower . filter isAlphaNum 
    4750    where 
    4851    norm' "ghc"    = "GHC" 
     
    5356    norm' "pil2"   = "PIL2" 
    5457    norm' "perl5"  = "Perl5" 
     58    norm' "pil2perl5"  = "PIL2-Perl5" 
     59    norm' "pil2json"   = "PIL2-JSON" 
     60    norm' "pil2binary" = "PIL2-Binary" 
    5561    norm' "pugs"   = "Pugs" 
    5662    norm' "binary" = "Binary" 
  • src/Pugs/CodeGen/PIL2.hs

    r7849 r7866  
    22{-# OPTIONS_GHC -#include "../../UnicodeC.h" #-} 
    33 
    4 module Pugs.CodeGen.PIL2 (genPIL2) where 
     4module Pugs.CodeGen.PIL2 ( 
     5    genPIL2, 
     6    genPIL2Perl5, genPIL2Binary, genPIL2JSON 
     7) where 
    58import Pugs.Internals 
    69import Pugs.AST 
    7 import Pugs.PIL1 
    8 import Pugs.Compile 
     10import Pugs.PIL2 
     11import Pugs.Compile.PIL2 
     12import System.IO 
     13import System.Directory 
     14import DrIFT.Perl5 
     15import DrIFT.Binary 
     16import DrIFT.JSON 
    917 
    1018genPIL2 :: Eval Val 
     
    1725        , "    }" 
    1826        ] 
     27 
     28genPIL2Perl5 :: Eval Val 
     29genPIL2Perl5 = do 
     30    penv <- compile () :: Eval PIL_Environment 
     31    return . VStr . unlines $ [showPerl5 penv] 
     32 
     33genPIL2Binary :: Eval Val 
     34genPIL2Binary = do 
     35    penv <- compile () :: Eval PIL_Environment 
     36    liftIO $ do 
     37        tmp         <- getTemporaryDirectory 
     38        (file, fh)  <- openBinaryTempFile tmp "pugs.bin" 
     39        bh          <- openBinIO fh 
     40        put_ bh penv 
     41        hClose fh 
     42        return $ VStr (unlines [file]) 
     43 
     44genPIL2JSON :: Eval Val 
     45genPIL2JSON = do 
     46    penv <- compile () :: Eval PIL_Environment 
     47    return . VStr . unlines $ [showJSON penv] 
  • src/Pugs/Compile/PIL2.hs

    r7865 r7866  
    11{-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances -fno-warn-orphans -funbox-strict-fields -cpp #-} 
    2 {-# OPTIONS_GHC -#include "../UnicodeC.h" #-} 
    3  
    4 {-| 
    5     Compiler interface. 
    6  
    7 >   And words unheard were spoken then 
    8 >   Of folk and Men and Elven-kin, 
    9 >   Beyond the world were visions showed 
    10 >   Forbid to those that dwell therein... 
    11 -} 
    12  
    13 module Pugs.Compile ( 
     2{-# OPTIONS_GHC -#include "../../UnicodeC.h" #-} 
     3 
     4module Pugs.Compile.PIL2 ( 
    145    PIL_Stmts(..), PIL_Stmt(..), PIL_Expr(..), PIL_Decl(..), PIL_Literal(..), PIL_LValue(..), 
    156    Compile(..), 
     
    2617import Pugs.Eval.Var 
    2718import Pugs.Monads 
    28 import Pugs.PIL1 
     19import Pugs.PIL2 
    2920import Emit.PIR 
    3021import Text.PrettyPrint