Changeset 4

Show
Ignore:
Timestamp:
02/06/05 20:01:10 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
1041
Message:

* This be 6.0.0.

Files:
1 added
10 modified

Legend:

Unmodified
Added
Removed
  • MANIFEST

    r1 r4  
    99inc/Module/Install/WriteAll.pm 
    1010lib/Perl6/Pugs.pm 
    11 lib/Perl6/Pugs/00Apocrypha.pod 
    12 lib/Perl6/Pugs/01Parsing.pod 
     11ChangeLog 
    1312Makefile.PL 
    1413MANIFEST                        This list of files 
  • lib/Perl6/Pugs.pm

    r1 r4  
    88Perl6::Pugs - Perl6 User's Golfing System 
    99 
     10=head1 VERSION 
     11 
     12This document describes version 6.0.0 of Pugs, released February 7, 2005. 
     13 
    1014=head1 SYNOPSIS 
    1115 
     
    1519=head1 DESCRIPTION 
    1620 
    17 Pugs is an interpreter for Perl6. 
     21Started at 2005-02-01, Pugs is an attempt at writing a Perl6 interpreter in 
     22Haskell.  Currently it is in its very early stages. 
     23 
     24Although Pugs does not yet directly relate to PGE or Parrot, the hope is that 
     25it can flesh out corner cases in the Synopses during implementation, as well 
     26as contributing more test cases to the main Perl6 project. 
     27 
     28=head2 Featherweight Perl6 
     29 
     30Featherweight Perl6 (FP6) is a simplified, side-effect-free subset of the 
     31Perl6 language, inspired by I<Featherweight Java>.  It is the first-step 
     32target language of Pugs. 
     33 
     34Notable features in Perl6 that are I<not> in FP6: 
     35 
     36=over 4 
     37 
     38=item * Assignments and mutable variables. 
     39 
     40=item * Grammar, Rules and Macros. 
     41 
     42=item * Unboxed types. 
     43 
     44=item * Run-time applications of "but" and "does". 
     45 
     46=item * I/O primitives. 
     47 
     48=item * Perl5 Compatibility Mode. 
     49 
     50=item * Non-ascii symbols: E<171>, E<187> and E<165>. 
     51 
     52=back 
     53 
     54The only ways to do I/O in FP6 are: 
     55 
     56=over 4 
     57 
     58=item * C<@*ARGS>, C<$*PID>, C<$*PROGRAM_NAME>, etc.. 
     59 
     60=item * C<< <> >> (lazily-evaluated lines of input) 
     61 
     62=item * The toplevel evaluation result is printed under flattened list context with items stringified. 
     63 
     64=back 
     65 
     66=head2 Release Plans 
     67 
     68The major/minor version numbers of Pugs converges to 2*pi; each significant 
     69digit in the minor version represents a milestone.  The third digit is 
     70incremented for each release. 
     71 
     72The current milestones are: 
     73 
     74=over 4 
     75 
     76=item 6.0: Initial release. 
     77 
     78=item 6.2: Implement FP6, without user-defined subtypes. 
     79 
     80=item 6.28: Full FP6, with classes and traits. 
     81 
     82=item 6.283: Assignment and I/O primitives. 
     83 
     84=item 6.2831: Role composition and other runtime features. 
     85 
     86=item 6.28318: Rules and Grammars. 
     87 
     88=item 6.283185: Macros; full Perl6 bootstrapping. 
     89 
     90=back 
    1891 
    1992=head1 SEE ALSO 
  • src/AST.hs

    r1 r4  
    1313 
    1414module AST where 
    15 import Data.List 
    16 import Data.Word 
    17 import Data.Char 
    18 import Data.Ratio 
    19 import Data.Complex 
    20 import Data.FiniteMap 
    21 import Text.ParserCombinators.Parsec.Pos 
     15import Internals 
    2216 
    2317type Ident = String 
  • src/Internals.hs

    r1 r4  
    1414-} 
    1515 
     16module Internals ( 
     17    module System.Environment, 
     18    module System.IO, 
     19    module Data.Bits, 
     20    module Data.List, 
     21    module Data.Word, 
     22    module Data.Char, 
     23    module Data.Maybe, 
     24    module Data.Ratio, 
     25    module Data.Complex, 
     26    module Data.FiniteMap, 
     27    module Debug.Trace, 
     28    module Text.ParserCombinators.Parsec, 
     29    module Text.ParserCombinators.Parsec.Expr, 
     30    module Text.ParserCombinators.Parsec.Language, 
     31) where 
     32 
     33import System.Environment 
     34import System.IO hiding (try) 
     35import qualified System.IO (try) 
     36import Data.Bits 
     37import Data.Maybe 
     38import Data.Ratio 
     39import Data.List 
     40import Data.Word 
     41import Data.Char 
     42import Data.Ratio 
     43import Data.Complex 
     44import Data.FiniteMap 
     45import Debug.Trace 
     46import Text.ParserCombinators.Parsec 
     47import Text.ParserCombinators.Parsec.Expr 
     48import Text.ParserCombinators.Parsec.Language 
  • src/Lexer.hs

    r3 r4  
    1111 
    1212module Lexer where 
    13 import Data.Char 
    14 import Debug.Trace 
    15 import Text.ParserCombinators.Parsec 
    16 import Text.ParserCombinators.Parsec.Expr 
    17 import Text.ParserCombinators.Parsec.Pos 
     13import Internals 
    1814import qualified Text.ParserCombinators.Parsec.Token as P 
    19 import Text.ParserCombinators.Parsec.Language 
    2015 
    2116perl6Def  = javaStyle 
     
    8984 
    9085    fraction        = do{ char '.' 
    91                         ; digits <- many1 digit <?> "fraction" 
     86                        ; digits <- many digit <?> "fraction" 
    9287                        ; return (foldr op 0.0 digits) 
    9388                        } 
     
    149144 
    150145quotedQuote = do 
    151     string "\\'" 
    152     return '\'' 
     146    char '\\' 
     147    anyChar 
    153148 
  • src/Main.hs

    r1 r4  
    1515 
    1616module Main where 
    17 import IO 
    18 import System 
     17import Internals 
    1918 
    2019import AST 
     
    3231run (('-':'e':str@(_:_)):args) = doRun str args 
    3332run ("-e":str:args) = doRun str args 
     33run ("-h":_)        = printHelp 
    3434run (file:args)     = readFile file >>= (`doRun` args) 
    3535run []              = do 
    3636    hSetBuffering stdout NoBuffering  
    37     banner 
    38     repLoop ()  
     37    isTTY <- hIsTerminalDevice stdin 
     38    if isTTY 
     39        then banner >> repLoop ()  
     40        else do 
     41            str <- getContents 
     42            doRun str [] 
    3943 
    4044repLoop :: State -> IO () 
     
    4549           Load fn  -> load fn 
    4650           Eval str -> doEval str [] >> repLoop initState  
    47            Parse str-> parse str >> repLoop initState  
     51           Parse str-> doParse str >> repLoop initState  
    4852           Help     -> printHelp >> repLoop state  
    4953 
     
    5155    return () 
    5256 
    53 parse str = runLex print parseOp str 
     57doParse str = runLex print parseOp str 
    5458 
    5559eval str = doEval str [] 
  • src/Parser.hs

    r1 r4  
    1111 
    1212module Parser where 
     13import Internals 
    1314import AST 
    1415import Lexer 
    15 import Text.ParserCombinators.Parsec 
    16 import Text.ParserCombinators.Parsec.Expr 
    1716 
    1817type StateParser a = GenParser Char () a 
     
    3736    , ternOps  [("??", "::")]                           -- Ternary 
    3837    , leftOps  " = := ::= += **= xx= "                  -- Assignment 
     38    -- XXX rewrite chained Ops using sepBy! 
    3939    , rightOps " , "                                    -- List Item Separator 
    4040    , preOps   primitiveListFunctions                   -- List Operator 
     
    7171parseTerm = parens parseOp 
    7272    <|> parseLit 
    73     <|> nonTerm 
     73--  <|> nonTerm 
    7474    <?> "term" 
    7575 
  • src/Pretty.hs

    r1 r4  
    1313 
    1414module Pretty where 
     15import Internals 
    1516import AST 
    16 import Data.List 
    17 import Data.Ratio 
    1817 
    1918class (Show a) => Pretty a where 
  • src/Prim.hs

    r1 r4  
    1313 
    1414module Prim where 
     15import Internals 
    1516import AST 
    16 import Data.Char 
    17 import Data.Bits 
    18 import Data.Word 
    19 import Data.List 
    20 import Data.Maybe 
    21 import Data.Ratio 
    2217 
    2318op1 :: Ident -> (forall a. Context a => a) -> Val 
    24 op1 "!"  = VBool . not 
     19op1 "!"  = \x -> case op1 "?" x of 
     20    VBool True  -> VBool False 
     21    VBool False -> VBool True 
    2522op1 "+"  = op1Numeric id 
    2623op1 "-"  = op1Numeric negate 
     
    154151op1Numeric f VUndef     = VInt $ f 0 
    155152op1Numeric f (VInt x)   = VInt $ f x 
     153op1Numeric f (VList l)  = VInt $ f $ genericLength l 
    156154op1Numeric f x          = VNum $ f (vCast x) 
    157155 
  • src/Shell.hs

    r1 r4  
    1 {-# OPTIONS -cpp #-} 
     1{-# OPTIONS -fglasgow-exts -cpp #-} 
     2 
     3{- 
     4    Interactive shell. 
     5 
     6    There is an inn, a merry old inn, 
     7    beneath an old grey hill, 
     8    And there they brew a beer so brown 
     9    That the Man in the Moon himself came down 
     10    one night to drink his fill... 
     11-} 
     12 
     13module Shell where 
     14import Internals 
     15import AST 
     16 
    217#define READLINE 1 
    318#include "config.h" 
    419 
    5 {------------------------------------------------------------------------------- 
    6  
    7         Copyright:              Bernie Pope 2004 
    8  
    9         Module:                 Shell 
    10  
    11         Description:            The Baskell interpreter command line.  
    12  
    13         Primary Authors:        Bernie Pope 
    14  
    15         Notes:  
    16  
    17         Will use GNU readline if it is available.  
    18  
    19 -------------------------------------------------------------------------------} 
    20  
    21 module Shell  
    22    ( Command (..) 
    23    , getCommand 
    24    , initializeShell 
    25    )  
    26    where 
    27  
    28 import AST 
    29 import Char 
    3020#ifdef READLINE 
    3121import qualified System.Console.Readline as Readline 
    32    ( readline 
    33    , addHistory 
    34    , initialize 
    35    ) 
    3622#endif 
    37  
    38 -------------------------------------------------------------------------------- 
    3923 
    4024data Command 
     
    4630   | Type Exp  
    4731   | Help 
    48 #ifdef DEBUG 
    49    | ShowAST 
    50    | ShowDepend 
    51 #endif 
    5232 
    5333-- read some input from the user 
    5434-- parse the input and return the corresponding command 
    5535getCommand :: IO Command 
    56 getCommand  
    57    = do input <- readline "pugs> "  
    58         case input of 
    59            Nothing -> return Quit 
    60            Just line 
    61               -> if all isSpace line 
    62                     then getCommand 
    63                     else do 
    64                         addHistory line 
    65                         return $ parseCommandLine line 
     36getCommand = do 
     37    input <- readline "pugs> "  
     38    doCommand input 
     39 
     40doCommand Nothing = return Quit 
     41doCommand (Just line) 
     42    | all isSpace line  = getCommand 
     43    | (s, _) <- break (== '#') line 
     44    , all isSpace s     = getCommand 
     45    | otherwise         = do 
     46        addHistory line 
     47        return $ parseCommandLine line 
    6648 
    6749parseCommandLine :: String -> Command  
     
    7052parseCommandLine (':':'q':_)    = Quit 
    7153parseCommandLine (':':'h':_)    = Help 
    72 parseCommandLine (':':'b':_)    = Browse 
    73 parseCommandLine (':':'l':str)  = Load . unwords . tail $ words str 
     54-- parseCommandLine (':':'b':_)    = Browse 
     55-- parseCommandLine (':':'l':str)  = Load . unwords . tail $ words str 
    7456parseCommandLine str            = Eval str 
    75  
    76 -------------------------------------------------------------------------------- 
    77  
    78 -- optional support for GNU Readline   
    7957 
    8058initializeShell :: IO ()