Pugs is several things: it is a Perl 6 compiler; a Perl 6 runtime; a test suite; a bunch of Perl 6 modules, and a nursery for several experimental projects. The core of Pugs -- the compiler and runtime -- cohabit the src/ directory.
Pugs core
Parser
Pugs.Parser and its submodules are responsible for translating Perl 6 source code into Pugs AST. The particular AST in use currently is data Exp in Pugs.AST.Internals but is being transitioned to a more elaborated set of datatypes.
The parser uses Parsec, a monadic parser combinator library.
The Perl 6 Grammar is also maintained in the src/ tree, and will likely replace at least some of the parsing.
Values
src/Pugs/Val.hs defines the datatypes representing values. Everything in Perl 6 can be treated as an object, and these types instantiate the Boxable class (see MO below) to support this.
Metamodel
MO and Pugs.Meta contain the general and Pugs-specific object-world, or metamodel. These are parts of the runtime that handle roles, classes, objects; as well as multimethod dispatch, and reflection.
As an example tying the above together:
# The Perl 6 program
"moose".reverse
# Is parsed to the AST
App (Var "&reverse") (Just (VVal (PureString "moose"))) []
# read, "App"ly the "&reverse" method on the immutable Str invocant "moose" with no args
# And since Str is an instance of Boxable, we look in the StrClass defined in
# Pugs.Meta.Str for the method:
_StrClass = mkPureClass "Str"
[ "reverse" ... Str.reverse -- this is simply Data.ByteString's reverse!
, "join" ... Str.join
, "chop" ... (\str -> if Str.null str then str else Str.init str)
...
]
Test suite
Modules
source:ext/ contains Perl 6 modules, some of them ports of well-known p5 modules from CPAN.
source:lib/ contains a few glue modules installed when you make install a built pugs.
