Переглянути джерело

update iteration syntax, make it nice to use

tcheukueppo 2 роки тому
батько
коміт
7b53d033b3

+ 0 - 0
hacking_pity/abstracted_ast.ast → Makefile


+ 20 - 7
TODO.md → Roadmap.md

@@ -4,24 +4,37 @@
 - Build pity lexer and test
 - Implement the basic functionality of Pity objects just for the sake of completely accomplish the parsing process and test
 - Write a module for interacting with PRCE2 and implement the `Regex` and `Match` object
-- Build AST by parsing Tokens. test, test, and test the AST AST
+- Build AST by parsing Tokens
+- Write Deparser for testing AST
 - Setup the list of pity vm opcodes
+- Build compiler data structure
 - Implement the compiler and its debugger (While compiling, apply Tail Call optimization and NaN Boxing). Test, test, and test
 - Implement the bytecode runner. Test, test and test
 - Complete the implementation of pity objects, test, test and test
 - Optimize the AST with the following optimizations
 
-1. Constant folding, test AST
-2. Common subexpression elimination, test AST
-3. Dead code elimination, test AST
+1. Constant folding, test AST by deparsing
+2. Common subexpression elimination, test AST ...
+3. Dead code elimination, test AST ...
 
 - Apply the following optimization during the compilation process
 
 1. Constant propagation, test compiler
 2. Code hoisting, test compiler
-3. (Maybe)? Register Allocation
+3. (Maybe)? Register Allocation, test compiler
 
-- Test language features
+- Make the deparser be `pityfy` for pityfying
+- Test language features individualy
 - Test objects
-- Write 150 rosetta codes to test, test and test
+- Write 150 rosetta codes to test `pity` as a whole
 - Write documentation
+- Call friends to make builders for plan9, BSDs, Linux, Mac and Windows platforms
+- Call friends to setup CI/CD pipeline to package build pity for the following linux and BSD distributions
+
+1. (Open|Free|Net)BSD
+2. Debian & Ubuntu
+3. Alpine Linux
+4. Archlinux
+5. 
+
+- Call friends/(or why not me?) to make windows installer GUI app

+ 0 - 0
hacking_pity/vm_guide.md → docs/hacking_pity/abstracted_ast.ast


+ 0 - 0
hacking_pity/example_scripts/sample_1.pi → docs/hacking_pity/example_scripts/sample_1.pi


+ 0 - 0
hacking_pity/example_scripts/sample_2.pi → docs/hacking_pity/example_scripts/sample_2.pi


+ 0 - 0
hacking_pity/example_scripts/sample_3.pi → docs/hacking_pity/example_scripts/sample_3.pi


+ 0 - 0
hacking_pity/example_scripts/sample_4.pi → docs/hacking_pity/example_scripts/sample_4.pi


+ 0 - 0
hacking_pity/objects.md → docs/hacking_pity/objects.md


+ 0 - 0
hacking_pity/objects/Int.md → docs/hacking_pity/objects/Int.md


+ 0 - 0
hacking_pity/objects/String.md → docs/hacking_pity/objects/String.md


+ 19 - 10
hacking_pity/pity.md → docs/hacking_pity/pity.md

@@ -171,7 +171,7 @@ say q%interpolation won't work%
 say qq/interpolation works, array: #a/
 
 # [ "0ne", "Tw0" ]
-b = a.grep(-> x { x =~ m|o| }).map{ s|o|0| }.map{ .ucfirst }
+b = a.grep({[x] x =~ m|o| }).map{ s|o|0| }.map{ .ucfirst }
 b.say
 ```
 
@@ -415,23 +415,27 @@ else     { say "never here" }
 6. `for`
 
 ```ruby
-for "a", qr/regex/, [2, 4] { .say }
+foreach "a", qr/regex/, [2, 4] { .say }
 
 # output: 3 3 5 4 4
-for ar -> i { i.len.say }
+foreach i in ar { i.len.say }
 
 ar = <one two three four five>
 # "ar" is now [3, 3, 5, 4, 4]
-for ar -> j is rw {
+foreach j in ar {
     j = j.len
 }
 
 # (3, 3) (5, 4) (4, nil)
-for ar -> i, j { say "(#i, #j)" }
+for i, j in ar {
+    say "(#i, #j)"
+}
 
 # set a custom value when we are running out of elements
 # (3, 3) (5, 4) (4, none)
-for ar -> i, j = "none" { say "(#i, #j)" }
+for i, j = "none" in ar {
+    say "(#i, #j)"
+}
 
 .say for ar
 ```
@@ -485,7 +489,7 @@ given x {
     say "variable x has two elements" if x.len == 2
 }
 
-print .map -> rx { rx ** 2 } given x
+print .map {[rx] rx ** 2 } given x
 ```
 
 10. `loop`
@@ -576,7 +580,9 @@ of the number of iterations. One great advantage it offers is avoid the burdens
 conditional construct to avoid the execution of a statement.
 
 ```raku
-for { one => 1, two => 1, three => 3 }.each_kv -> k, v {
+let h = { one => 1, two => 1, three => 3 }
+for h.each_kv {
+    [k,v]
     once say "I got one" if v == 1
     printfln "%s => %d", k, v
 }
@@ -599,14 +605,17 @@ NOTE: topic variables should only be named at the begining of the block of conce
 let a = [2, 5, 34]
 
 # declaring a topic variable x
-print a.map -> x {
+print a.map {[x]
     once say "first call"
     next if x == 3
     √x
 }
 
 # 2,2 4,none
-[2, 2, 4].each -> x, y = "none" { say "#x,#y" }
+[2, 2, 4].each {
+    [x, y = "none"]
+    say "#x,#y"
+}
 ```
 
 # Functions

+ 0 - 0
hacking_pity/pity_bnf.bnf → docs/hacking_pity/pity_bnf.bnf


+ 0 - 0
docs/hacking_pity/vm_guide.md


+ 0 - 21
test.go

@@ -1,21 +0,0 @@
-package main
-
-import (
-   "fmt"
-)
-
-var ast      = make([]any, 0)
-var prefix   = []string{"+", "-"}
-var op_codes = map[int8]any {
-                              0: []string{ "+", "-" },
-                              1: "/",
-                              2: "*",
-                              3: "(",
-                            }
-
-// 2 * + 4 / 2 - 1 --> ((2 * (+4)) / 2) - 1
-func main() {
-   expr := []any{2, "*", "+", 4, "/", 2, "-", 1}
-
-
-}