Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit a674dd28f642754ab8edbe1a1970af9450e654ed @fglock committed Dec 2, 2009
Showing with 37,774 additions and 0 deletions.
  1. +56 −0 ChangeLog
  2. +53 −0 TODO
  3. +132 −0 doc/miniperl6-ast.pod
  4. +64 −0 doc/miniperl6-bootstrap-perl5.pod
  5. +28 −0 doc/miniperl6-bootstrap.pod
  6. +124 −0 doc/miniperl6-spec.pod
  7. +1 −0 hello.pl
  8. +2 −0 hello.sh
  9. +10 −0 js-util/prepare-mp6-js-main.sh
  10. +571 −0 lib/MiniPerl5/Grammar.pm
  11. +113 −0 lib/MiniPerl5/Grammar/Control.pm
  12. +641 −0 lib/MiniPerl6/Clojure/Emitter.pm
  13. +264 −0 lib/MiniPerl6/Emitter/Token.pm
  14. +797 −0 lib/MiniPerl6/Go/Emitter.pm
  15. +91 −0 lib/MiniPerl6/Go/Prelude.pm
  16. +272 −0 lib/MiniPerl6/Go/Runtime.go
  17. +638 −0 lib/MiniPerl6/Grammar.pm
  18. +109 −0 lib/MiniPerl6/Grammar/Control.pm
  19. +76 −0 lib/MiniPerl6/Grammar/Mapping.pm
  20. +366 −0 lib/MiniPerl6/Grammar/Regex.pm
  21. +699 −0 lib/MiniPerl6/Javascript/Emitter.pm
  22. +91 −0 lib/MiniPerl6/Javascript/Prelude.pm
  23. +191 −0 lib/MiniPerl6/Javascript/Runtime.js
  24. +639 −0 lib/MiniPerl6/Lisp/Emitter.pm
  25. +91 −0 lib/MiniPerl6/Lisp/Prelude.pm
  26. +267 −0 lib/MiniPerl6/Lisp/Runtime.lisp
  27. +1,019 −0 lib/MiniPerl6/PAST/Emitter.pm
  28. +937 −0 lib/MiniPerl6/Parrot/Emitter.pm
  29. +47 −0 lib/MiniPerl6/Parrot/Match.pm
  30. +536 −0 lib/MiniPerl6/Perl5/Emitter.pm
  31. +299 −0 lib/MiniPerl6/Perl5/Match.pm
  32. +46 −0 lib/MiniPerl6/Perl5/Prelude.pm
  33. +190 −0 lib/MiniPerl6/Perl5/Runtime.pm
  34. +477 −0 lib/MiniPerl6/Perl6Parrot/Emitter.pm
  35. +523 −0 lib/MiniPerl6/Pugs/Emitter.pm
  36. +499 −0 lib/MiniPerl6/Python/Emitter.pm
  37. +298 −0 lib/MiniPerl6/Python/Match.pm
  38. +156 −0 lib/MiniPerl6/Python/Runtime.py
  39. +148 −0 lib/Test.pm
  40. +67 −0 lib5/MiniPerl5/Grammar.pm
  41. +18 −0 lib5/MiniPerl5/Grammar/Control.pm
  42. +8 −0 lib5/MiniPerl6/AST/CompUnit.pm
  43. +138 −0 lib5/MiniPerl6/Emitter/Token.pm
  44. +243 −0 lib5/MiniPerl6/Go/Emitter.pm
  45. +99 −0 lib5/MiniPerl6/Grammar.pm
  46. +18 −0 lib5/MiniPerl6/Grammar/Control.pm
  47. +14 −0 lib5/MiniPerl6/Grammar/Mapping.pm
  48. +32 −0 lib5/MiniPerl6/Grammar/Regex.pm
  49. +238 −0 lib5/MiniPerl6/Javascript/Emitter.pm
  50. +264 −0 lib5/MiniPerl6/Lisp/Emitter.pm
  51. +233 −0 lib5/MiniPerl6/PAST/Emitter.pm
  52. +233 −0 lib5/MiniPerl6/Parrot/Emitter.pm
  53. +229 −0 lib5/MiniPerl6/Perl5/Emitter.pm
  54. +299 −0 lib5/MiniPerl6/Perl5/Match.pm
  55. +190 −0 lib5/MiniPerl6/Perl5/Runtime.pm
  56. +236 −0 lib5/MiniPerl6/Perl5MO/Emitter.pm
  57. +227 −0 lib5/MiniPerl6/Perl6Parrot/Emitter.pm
  58. +62 −0 lib5/MiniPerl6/Python/Emitter.pm
  59. +298 −0 lib5/MiniPerl6/Python/Match.pm
  60. +172 −0 lib5/MiniPerl6/Python/Runtime.py
  61. +36 −0 lib5/Test.pm
  62. +359 −0 libjs/MiniPerl6/Emitter/Token.js
  63. +417 −0 libjs/MiniPerl6/Grammar.js
  64. +53 −0 libjs/MiniPerl6/Grammar/Control.js
  65. +29 −0 libjs/MiniPerl6/Grammar/Mapping.js
  66. +132 −0 libjs/MiniPerl6/Grammar/Regex.js
  67. +636 −0 libjs/MiniPerl6/Javascript/Emitter.js
  68. +78 −0 libjs/MiniPerl6/Javascript/Prelude.js
  69. +191 −0 libjs/MiniPerl6/Javascript/Runtime.js
  70. +611 −0 libjs/MiniPerl6/Perl5/Emitter.js
  71. +96 −0 libjs/Test.js
  72. +22 −0 liblisp/MiniPerl6/AST/CompUnit.lisp
  73. +790 −0 liblisp/MiniPerl6/Emitter/Token.lisp
  74. +576 −0 liblisp/MiniPerl6/Grammar.lisp
  75. +73 −0 liblisp/MiniPerl6/Grammar/Control.lisp
  76. +41 −0 liblisp/MiniPerl6/Grammar/Mapping.lisp
  77. +178 −0 liblisp/MiniPerl6/Grammar/Regex.lisp
  78. +1,544 −0 liblisp/MiniPerl6/Lisp/Emitter.lisp
  79. +185 −0 liblisp/MiniPerl6/Lisp/Prelude.lisp
  80. +267 −0 liblisp/MiniPerl6/Lisp/Runtime.lisp
  81. +1,484 −0 liblisp/MiniPerl6/Perl5/Emitter.lisp
  82. +118 −0 liblisp/Test.lisp
  83. +13 −0 lisp-util/bootstrap-lisp.sh
  84. +53 −0 lisp-util/build-lisp.sh
  85. +43 −0 lisp-util/create-core-image.lisp
  86. +10 −0 lisp-util/create-core-image.sh
  87. +88 −0 lisp-util/create-mp6-lisp.pl
  88. +24 −0 lisp-util/mp6-lisp-main.lisp
  89. +30 −0 lisp-util/mp6-perl5-main.lisp
  90. +10 −0 lisp-util/prepare-mp6-lisp-main.sh
  91. +10 −0 lisp-util/prepare-mp6-perl5-main.sh
  92. +25 −0 main.lisp
  93. +9 −0 make-perlito-js.sh
  94. +59 −0 mp6-ast.pl
  95. +34 −0 mp6-clojure.pl
  96. +32 −0 mp6-go.pl
  97. +32 −0 mp6-javascript.pl
  98. BIN mp6-lisp
  99. +3,697 −0 mp6-lisp-create-core-image.lisp
  100. +3,678 −0 mp6-lisp.lisp
  101. +34 −0 mp6-lisp.pl
  102. +40 −0 mp6-parrot.pl
  103. +40 −0 mp6-past.pl
  104. +3,624 −0 mp6-perl5.lisp
  105. +39 −0 mp6-perl5.pl
  106. +54 −0 mp6-py.pl
  107. +41 −0 mp6-rakudo.pl
  108. +1 −0 parrot-util/hello-parrot.sh
  109. +13 −0 perl5-util/bootstrap-perl5.sh
  110. +57 −0 perl5-util/build-javascript.sh
  111. +57 −0 perl5-util/build-lisp.sh
  112. +72 −0 perl5-util/build-perl5.sh
  113. +38 −0 perl5-util/make-perl5.pl
  114. +77 −0 perlito.html
  115. +1,895 −0 perlito.js
  116. +48 −0 run-mp6.pl
  117. +9 −0 runjs.sh
  118. +7 −0 script.html
  119. +6 −0 t/01-sanity.t
  120. +6 −0 t/02-int.t
  121. +49 −0 t/04-op.t
  122. +30 −0 t/05-anon-sub-lex-block.t
  123. +21 −0 t/05-anon-sub.t
  124. +13 −0 t/05-array.t
  125. +20 −0 t/05-bind.t
  126. +13 −0 t/05-hash.t
  127. +11 −0 t/05-lex-block.t
  128. +21 −0 t/06-bind-array.t
  129. +26 −0 t/07-bind-array-nested.t
  130. +21 −0 t/08-bind-hash.t
  131. +25 −0 t/09-bind-constructor.t
  132. +15 −0 t/10-bind-sub-param-more.t
  133. +34 −0 t/10-bind-sub-param.t
  134. +26 −0 t/11-bind-method-param.t
  135. +31 −0 t/12-match.t
  136. +87 −0 t/13-emitter-lisp.t
  137. +46 −0 t/14-grammar.t
  138. +46 −0 t/15-grammar-2.t
  139. +114 −0 t/t-grammar/01-sanity.t
  140. +22 −0 t/t-grammar/02-apply.t
  141. +22 −0 t/t-grammar/02-emit.t
  142. +50 −0 t/t-grammar/02-exp-tap.t
  143. +102 −0 t/t-grammar/02-exp.t
  144. +105 −0 t/t-grammar/03-token.t
  145. +24 −0 t/t-grammar/04-regex.t
@@ -0,0 +1,56 @@
+2.0 2009-10-09
+- Javascript (Firefox, V8) bootstrap
+- simplified 'make' inside tokens
+
+1.0 2009-08-28
+- Lisp (SBCL) bootstrap
+- Changed accessors to lvalue
+
+date? -
+
+- Perl5 emitter: fixed Array inside signature: method ( $a, [ $b, $c ] ) ...
+- Perl5 emitter: implemented "warn"
+
+0.003 2006-12-12
+- All tests converted to TAP format
+- Parrot backend:
+ - added Parrot emitter and 'mp6-parrot' script
+ - passes several tests
+ - 'Match' class written in MP6
+- Perl5 backend:
+ - parameter binding with complex data structures
+
+0.002 2006-11-18
+- fixed array expansion in 'for @x {...}'
+- fixed grammar compilation in MiniPerl6::Grammar and MiniPerl6::Grammar::Regex
+
+- type annotations my Int $x
+- autoquote hash keys { a => 42 }
+- pair syntax sugar { :$a }
+- deep array binding [ $a, [ $b, $c ] ] := [ 1, [ 2, 3 ] ]
+
+0.001 2006-11-17
+- MiniPerl6::Perl5::Emitter and MiniPerl6::Emitter::Token compile ok
+
+ echo 'class Main { say "hello, World" }' | perl -Ilib5 mp6-perl5-boot.pl | perl -Ilib5
+
+2006-11-14
+- all files parsed
+- added Perl5 build script
+
+2006-11-11
+- parses MiniPerl6/Emitter.pm
+
+2006-11-10
+- parses mp6.pl
+
+2006-11-06
+- implemented MP6::G::Regex::rule()
+- /<%hash>/
+- /const|const/
+- /<subrule>/
+- /<'xyz'>/
+- /\n/
+
+2006-11-01
+- initial language draft (on paper)
53 TODO
@@ -0,0 +1,53 @@
+MiniPerl6 in Perl5
+
+- generate 'my' variables for subroutine signatures;
+ currently depends on autovivification
+
+- Freeze the project, because it can be useful to bootstrap other VMs
+
+Bootstrapping MiniPerl6 in Parrot
+
+- finish OO, class variables
+
+- fix die() parameter handling
+
+- rewrite mp6-parrot.pl in parrot (or mp6)
+
+- Recompile it several times using itself, in order to check the stability of the Bootstrap
+
+- Freeze the project, because it can be useful to bootstrap other VMs
+
+Missing Backends
+
+- Javascript, Haskell
+
+- MO in MP6 (MP6-2)
+
+Missing Features
+
+- detailed syntax errors
+
+- type annotations - FIXED
+
+- autoquote hash keys - FIXED
+
+- double quote interpolation and "\n"
+
+- operator precedence
+
+- all statements need a semicolon
+
+- 'use v5' is not supported
+ (maybe not needed for MP6)
+
+- no 'state', 'constant'
+
+Missing Features of the Token sub-compiler
+
+- no quantifiers
+
+- no variable interpolation
+
+Bugs
+
+- ...
@@ -0,0 +1,132 @@
+# Mini Perl 6 Syntax Nodes
+
+# A program is a sequence of compilation units.
+subset Program of (Seq of CompUnit);
+
+# A compilation unit is a named class.
+class CompUnit {
+ has $.class is Type; # class Name;
+ has %.attributes is Mapping of Type; # has $.attr is Type;
+ has %.methods is Mapping of Lit::Code; # method foo { ... }
+ has $.body is Lit::Code; # body of code
+}
+
+# An expression. Except for Control, they can also occur at LHS
+# of a Bind node -- i.e. subroutine signatures.
+subset Exp of
+ ( Var # $variable
+ | Val # "value"
+ | Lit # [literal construct]
+ | Index # $obj[1, 2, 3]
+ | Lookup # $obj{'1', '2', '3'}
+ | Control # Various control structures. Does _not_ appear in binding LHS
+ );
+
+# Things that cannot occur as LHS of a Bind node.
+subset Control of
+ ( Bind # $lhs := $rhs
+ | Call # $obj.method($arg1, $arg2)
+ | Apply # $obj($arg1, $arg2)
+ | Return # return 123;
+ | Leave # last; break;
+ | If # 1 ?? 2 !! 3
+ | When # when 3 { ... }
+ | For # $x.map(-> $i {...})
+ | While # while ... { ... }
+ );
+
+# Literal expressions.
+subset Lit of
+ ( Lit::Seq # (a, b, c)
+ | Lit::Array # [a, b, c]
+ | Lit::Hash # {a => x, b => y}
+ | Lit::Code # sub $x {...}
+ | Lit::Object # ::Tree(a => x, b => y);
+ );
+
+# Fully reduced values.
+subset Val of
+ ( Val::Undef # undef
+ | Val::Object # (not exposed to the outside)
+ | Val::int # 123
+ | Val::bit # True, False
+ | Val::num # 123.456
+ | Val::buf # "moose"
+ );
+
+subset ID of Str;
+subset Type of Str;
+
+enum Sigil ('$', '%', '@', '&');
+enum Twigil ('', '.', '!', '^');
+
+class If {
+ has $.cond is Exp;
+ has @.body is Seq of Exp;
+ has @.otherwise is Seq of Exp;
+}
+
+class When {
+ has @.parameters is Seq of Exp;
+ has @.body is Seq of Exp;
+}
+
+class For {
+ has $.cond is Exp;
+ has $.topic is Var;
+ has @.body is Seq of Exp;
+}
+
+class While {
+ has $.cond is Exp;
+ has @.body is Seq of Exp;
+}
+
+class Return {
+ has $.result is Exp;
+}
+
+class Var {
+ has $.sigil is Sigil;
+ has $.twigil is Twigil;
+ has $.name is ID;
+}
+
+class Val::Object {
+ has $.class is Type;
+ has %.fields is Mapping of Val;
+}
+
+class Lit::Seq {
+ has @.seq is Seq of Exp;
+}
+
+class Lit::Code {
+ has %.pad is Mapping of Type; # All my/state/parameter variables
+ has %.state is Mapping of Exp; # State initializers, run upon first entry
+ has @.parameters is Seq of Exp; # Signature
+ has @.body is Seq of Exp; # Code body
+}
+
+class Lit::Object {
+ has $.class is Type; # Class name
+ has %.fields is Mapping of Exp; # Field initializers
+}
+
+class Bind {
+ has @.parameters is Exp; # Signature
+ has @.arguments is Exp; # Capture
+}
+
+class Call {
+ has $.invocant is Exp; # $obj
+ has $.hyper is Bool; # .>>.
+ has $.method is ID; # .method
+ has @.arguments is Seq of Exp; # ($args)
+}
+
+class Apply {
+ has $.code is Exp; # &sub
+ has @.arguments is Seq of Exp; # ($args)
+}
+
@@ -0,0 +1,64 @@
+Bootstrapping MiniPerl6 in Perl5
+
+- Reduce the amount of nodes required to compile MP6::Grammar::Regex
+- Implement the Rul::* nodes using MP6, emit MP6 - that would amount to about 5 or 6 nodes
+
+- Implement the required syntax in MP6::Emitter, such that it can emit Perl 5
+- Check that the emitted code can compile MP6::Grammar::Regex
+
+- Check that all MP6 files compile and run properly
+- Recompile it several times using itself, in order to check the stability of the Bootstrap
+
+- Freeze the project, because it can be useful to bootstrap other VMs
+
+Limitations of the bootstrapping version:
+
+- hash keys are not autoquoted - always use single quotes.
+- there is no precedence of operators - always use parenthesis.
+- there is no string interpolation - always use single quotes; "\n" doesn't work.
+- constructors are called with ::ClassName( 'arg' => 'val', 'arg' => 'val' )
+- 'for' loops need to specify '@{}', as in: for ( @$a ) {...}
+- all statements need a semicolon
+- 'use v5' is not supported
+- no type annotations
+- no 'state', 'constant'
+
+Limitations of the Token compiler bootstrapping version:
+
+- no quantifiers
+- no variable interpolation
+
+'Token' routines:
+
+ $grammar.parse( $source, $from_pos ) returns ::Match
+
+Built-in token routines:
+
+- namespace: MiniPerl6::Grammar
+- these routines are provided by MP6
+
+ comp_unit() - parses a Class or Grammar
+ parse() - parses a whole source file (several Classes)
+
+Runtime token routines:
+
+ space()
+ digit()
+ word()
+ newline()
+ not_newline()
+
+Runtime subroutines:
+
+ join()
+ chars()
+ substr()
+ say()
+ print()
+
+Optional subroutines:
+
+- these are nice to have, but they are optional:
+
+ perl()
+ yaml()
@@ -0,0 +1,28 @@
+1. cp EmitRuleP5Ratchet into EmitRuleP6Rathet and prefix all subs with "use v5"
+2. Use v6.pm to convert EmitRuleP6Ratchet into EmitRuleP5Ratchet
+3. Port EmitRuleP6Ratchet by hand to MiniPerl 6 (without using P6 Rules or advanced OO stuff)
+
+---- Here We Declare Grammar Engine is Bootstrapped ----
+
+4. Design AST for MP6 by taking Pugs.Exp and kill nodes, or take v6/AST and add nodes.
+5. Write v6/Emit(MiniPerl6->Perl5) and redo step 3 to make an optimized PCR/EmitRuleP5Ratchet
+6. Rewrite v6/Grammar/Expression.pm to port Yapp-dependent parts into a new precedence parser
+written in MP6 that utilizes <%foo> style tokens
+7. Finalize Perl 6 AST by taking MP6 AST and expanding on it.
+8. Convert all of v6/Grammar/* to MiniPerl6 and emitted to optimized Perl 5 code
+
+---- Here We Declare Perl 6 Parser is Bootstrapped ----
+
+9. Port MO to MiniPerl6
+10. Port Sub::Multi to MiniPerl6
+11. Port builtin Value and Container classes to MiniPerl6
+
+---- Here We Declare Perl 6 Runtime is Bootstrapped ----
+
+NB: The VM is responsible to provide coroutines, threads, sockets, etc etc;
+if it's missing in the VM, it's _not_ our job to emulate them by drastically
+change the emitting strategy to e.g. CPS. All Value/Container classes do is
+to bridge the native VM API with Perl 6 class/method API.
+
+
+
Oops, something went wrong.

0 comments on commit a674dd2

Please sign in to comment.