Просмотр исходного кода

split ideas-features to versions

221V 3 недель назад
Родитель
Сommit
6df8195253
3 измененных файлов с 477 добавлено и 143 удалено
  1. 15 143
      docs/readme.md
  2. 120 0
      docs/todo_v2.md
  3. 342 0
      docs/todo_v3.md

+ 15 - 143
docs/readme.md

@@ -52,12 +52,12 @@ File extension - `*.de` (because `de` shorter than `def`).
 
 
 # 2. Syntax and Ideas
+### (partial moved to next versions)
 
 
 ## 2.1 toml file for config keys-values
 
 ```toml
-[lexer]
 indent_type = 0
 indent_matter = 4
 indent_out = 2
@@ -244,8 +244,9 @@ void main(){
 ```
 
 ```
-// left = function type, right = arguments type
-bool = string str
+// function type = arguments type =
+//   next lines function body
+bool has_end_test = string str =
 has_end_test _ ++ "test" = true
 has_end_test _ = false
 
@@ -263,8 +264,9 @@ bool has_end_test(string str){
 ```
 
 ```
-// left = function type, right = arguments type
-bool = string str, out string rest
+// function type = arguments type =
+//   next lines function body
+bool has_end_test = string str, out string rest =
 has_end_test rest ++ "test" = true
 has_end_test _ = false
 
@@ -298,8 +300,9 @@ void main(){
 ```
 
 ```
-// left = function type, right = arguments type
-int = int x
+// function type = arguments type =
+//   next lines function body
+my_func int = int x =
 my_func 1 = 1
 my_func 5 = 5 * 2
 my_func 9 = 9 * 3
@@ -321,9 +324,10 @@ int my_func(int x){
 ```
 
 ```
-// left = function type, right = arguments type
+// function type = arguments type =
+//   next lines function body
 // "_sw" in function name' end for use switch (no "_sw" in dlang function name)
-int = int x
+int my_func_sw = int x =
 my_func_sw 1 = 1
 my_func_sw 5 = 5 * 2
 my_func_sw 9 = 9 * 3
@@ -391,134 +395,8 @@ switch(x){
 todo more examples -- with switch case dlang
 
 
-## 2.5 aliases for imports, externs etc
-```
-use core.stdc.stdio [ printf scanf ]
-    std.conv [ to ]
-
-->
-
-import core.stdc.stdio : printf, scanf;
-import std.conv : to;
-```
-
-```
-// definition at the beginning of the file
-use as use1
-    core.stdc.stdio [ printf scanf ]
-    std.conv [ to ]
-    std.stdio
-    std.array
-    std.string
-    std.algorithm
-
-
-use1 // use elsewhere in the file
 
-->
-import core.stdc.stdio : printf, scanf;
-import std.conv : to;
-import std.stdio;
-import std.array;
-import std.string;
-import std.algorithm;
-```
-todo add more examples
-
-
-## 2.6 main, wasm import from js (wasm export to js = as usual function + return)
-```
-main
-
-->
-
-void main()
-{
-...
-```
-
-```
-smain
-
-->
-
-extern(C) void main()
-{
-...
-```
-
-```
-// for wasm
-wmain
-
-->
-
-void _start(){  }
-```
-
-```
-// wasm import from js
-void = int a
-print
-
-->
-
-void print(int a);
-```
-
-
-## 2.7 data types aliases
-```
-// signed
-i8   ->   byte     //                  -128 — 127
-i16  ->   short    //                -32768 — 32767
-i32  ->   int      //           -2147483648 — 2147483647
-i64  ->   long     //  -9223372036854775808 — 9223372036854775807
-
-// unsigned
-u8   ->   ubyte    //  0 — 255
-u16  ->   ushort   //  0 — 65535
-u32  ->   uint     //  0 — 4294967295
-u64  ->   ulong    //  0 — 18446744073709551615
-
-// 128 not exists  //  0 — 340282366920938463463374607431768211455
-
-f32  ->   float
-f64  ->   double
-f128 ->   real     // up to 128 bit
-```
-
-```
-// todo mv to code
-alias i8 = char;
-alias i16 = short;
-alias i32 = int;
-alias i64 = long;
-alias u8 = uchar;
-alias u16 = ushort;
-alias u32 = uint;
-alias u64 = ulong;
-alias f32 = float;
-alias f64 = double;
-alias f128 = real;
-```
-
-
-## 2.8 code between ```dlang``` reserved words translates into target .d file without changes
-```
-...
-
-dlang
-
-// common dlang code here
-
-dlang
-
-...
-```
-
-
-## 2.9 reserved words (keywords) list
+## 2.10 reserved words (keywords) list
 including https://dlang.org/spec/lex.html#keywords  
 ```
 abstract alias align asm assert auto 
@@ -565,8 +443,6 @@ __VERSION__
 [deprecated keywords] body cdouble cent cfloat creal delete idouble ifloat ireal ucent
 
 
-use
-as
 ptn
 ptns
 
@@ -575,12 +451,8 @@ _
 
 *_sw (function name end)
 
-main
-smain
-wmain
-
-dlang (dlang code without changes)
 ```
 todo
 
+### [todo_v2](todo_v2.md), [todo_v3](todo_v3.md) etc
 

+ 120 - 0
docs/todo_v2.md

@@ -0,0 +1,120 @@
+
+## 2.7 data types aliases
+```
+// signed
+i8   ->   byte     //                  -128 — 127
+i16  ->   short    //                -32768 — 32767
+i32  ->   int      //           -2147483648 — 2147483647
+i64  ->   long     //  -9223372036854775808 — 9223372036854775807
+
+// unsigned
+u8   ->   ubyte    //  0 — 255
+u16  ->   ushort   //  0 — 65535
+u32  ->   uint     //  0 — 4294967295
+u64  ->   ulong    //  0 — 18446744073709551615
+
+// 128 not exists  //  0 — 340282366920938463463374607431768211455
+
+f32  ->   float
+f64  ->   double
+f128 ->   real     // up to 128 bit
+```
+
+```
+// todo mv to code
+alias i8 = char;
+alias i16 = short;
+alias i32 = int;
+alias i64 = long;
+alias u8 = uchar;
+alias u16 = ushort;
+alias u32 = uint;
+alias u64 = ulong;
+alias f32 = float;
+alias f64 = double;
+alias f128 = real;
+```
+
+
+## 2.8 code between ```dlang``` reserved words translates into target .d file without changes
+```
+...
+
+dlang
+
+// common dlang code here
+
+dlang
+
+...
+```
+
+
+## 2.9 make no needs ; in lines ends
+
+
+## 2.10 reserved words (keywords) list
+including https://dlang.org/spec/lex.html#keywords  
+```
+abstract alias align asm assert auto 
+bool break byte 
+case cast catch char class const continue 
+dchar debug default delegate deprecated do double 
+else enum export extern 
+false final finally float for foreach foreach_reverse function 
+goto  
+if immutable import in inout int interface invariant is 
+lazy long 
+macro mixin module 
+new nothrow null 
+out override 
+package pragma private protected public pure 
+real ref return 
+scope shared static struct super switch synchronized 
+template this throw true try typeid typeof 
+ubyte uint ulong union unittest ushort 
+version void 
+wchar while with 
+
+__FILE__
+__FILE_FULL_PATH__
+__FUNCTION__
+__LINE__
+__MODULE__
+__PRETTY_FUNCTION__
+
+__gshared
+__parameters
+__rvalue
+__traits
+__vector
+
+__DATE__
+__EOF__
+__TIME__
+__TIMESTAMP__
+__VENDOR__
+__VERSION__
+
+
+[deprecated keywords] body cdouble cent cfloat creal delete idouble ifloat ireal ucent
+
+
+use
+as
+ptn
+ptns
+
+_
+++
+
+*_sw (function name end)
+
+main
+smain
+wmain
+
+dlang (dlang code without changes)
+```
+todo
+

+ 342 - 0
docs/todo_v3.md

@@ -0,0 +1,342 @@
+
+### 2.4.2 pattern matching examples -- own types in line before function body
+```
+// left = function type, right = arguments type
+bool = string str
+has_begin_test "test" ++ _ = true
+has_begin_test _ = false
+
+->
+
+bool has_begin_test(string str){
+    if(str.length >= 4 && str[0..4] == "test"){
+        return true;
+    }
+    return false;
+}
+```
+
+```
+// left = function type, right = arguments type
+bool = string str, out string rest
+has_begin_test    "test" ++ rest = true
+has_begin_test    _ = false
+
+->
+
+// import std.stdio;
+
+bool has_begin_test(string str, out string rest){
+    if(str.length >= 4 && str[0..4] == "test"){
+        rest = str[4..$];
+        return true;
+    }
+    rest = str;
+    return false;
+}
+
+/*
+void main(){
+    string rest;
+    
+    writeln( has_begin_test("test123", rest) ); // true, rest = "123"
+    writeln(rest); // "123"
+    
+    writeln( has_begin_test("test", rest) ); // true, rest = ""
+    writeln(rest); // ""
+    
+    writeln( has_begin_test("example", rest) ); // false, rest = "example"
+    writeln(rest); // "example"
+}
+*/
+```
+
+```
+// left = function type, right = arguments type
+bool = string str
+has_end_test _ ++ "test" = true
+has_end_test _ = false
+
+->
+
+// match from string ending
+bool has_end_test(string str){
+    if(str.length >= 4){
+        if(str[$-4 .. $] == "test"){
+            return true;
+        }
+    }
+    return false;
+}
+```
+
+```
+// left = function type, right = arguments type
+bool = string str, out string rest
+has_end_test rest ++ "test" = true
+has_end_test _ = false
+
+->
+
+// import std.stdio;
+
+bool has_end_test(string str, out string rest){
+    if(str.length >= 4 && str[$-4 .. $] == "test"){
+        rest = str[0 .. $-4];
+        return true;
+    }
+    rest = str;
+    return false;
+}
+
+/*
+void main(){
+    string rest;
+    
+    writeln( has_end_test("hellotest", rest) ); // true, rest = "hello"
+    writeln(rest); // "hello"
+    
+    writeln( has_end_test("example", rest) ); // false, rest = "example"
+    writeln(rest); // "example"
+    
+    writeln( has_end_test("test", rest) ); // true, rest = ""
+    writeln(rest); // ""
+}
+*/
+```
+
+```
+// left = function type, right = arguments type
+int = int x
+my_func 1 = 1
+my_func 5 = 5 * 2
+my_func 9 = 9 * 3
+my_func X = X * 4
+
+->
+
+int my_func(int x){
+    if(x == 1){
+        return 1;
+    }else if(x == 5){
+        return 5 * 2; // return x * 2;
+    }else if(x == 9){
+        return 9 * 3; // return x * 3;
+    }else{ // other cases
+        return x * 4;
+    }
+}
+```
+
+```
+// left = function type, right = arguments type
+// "_sw" in function name' end for use switch (no "_sw" in dlang function name)
+int = int x
+my_func_sw 1 = 1
+my_func_sw 5 = 5 * 2
+my_func_sw 9 = 9 * 3
+my_func_sw X = X * 4
+
+->
+
+int my_func(int x){
+    switch(x){
+        case 1:
+            return 1; // if x == 1
+        case 5:
+            return 5 * 2; // return x * 2; // if x == 5
+        case 9:
+            return 9 * 3; // return x * 3; // if x == 9
+        default:
+            return x * 4; // other cases
+    }
+}
+```
+
+```
+// ptn = pattern = for pattern matching like `case X of` in erlang
+y = ptn x
+  1 = 1
+  5 = 5 * 2
+  9 = 9 * 3
+  _ = x * 4
+
+->
+
+if (x == 1){
+    y = 1;
+}else if(x == 5){
+    y = 5 * 2; // return x * 2;
+}else if(x == 9){
+    y = 9 * 3; // return x * 3;
+}else{ // other cases
+    y = x * 4;
+}
+```
+
+```
+// ptns = use switch in dlang for this pattern matching
+y = ptns x
+  1 = 1
+  5 = 5 * 2
+  9 = 9 * 3
+  _ = x * 4
+
+->
+
+switch(x){
+    case 1:
+        y = 1; // if x == 1
+    case 5:
+        y = 5 * 2; // y = x * 2; // if x == 5
+    case 9:
+        y = 9 * 3; // y = x * 3; // if x == 9
+    default:
+        y = x * 4; // other cases
+}
+```
+
+todo more examples -- with switch case dlang
+
+
+
+## 2.5 aliases for imports, externs etc
+```
+use core.stdc.stdio [ printf scanf ]
+    std.conv [ to ]
+
+->
+
+import core.stdc.stdio : printf, scanf;
+import std.conv : to;
+```
+
+```
+// definition at the beginning of the file
+use as use1
+    core.stdc.stdio [ printf scanf ]
+    std.conv [ to ]
+    std.stdio
+    std.array
+    std.string
+    std.algorithm
+
+
+use1 // use elsewhere in the file
+
+->
+import core.stdc.stdio : printf, scanf;
+import std.conv : to;
+import std.stdio;
+import std.array;
+import std.string;
+import std.algorithm;
+```
+todo add more examples
+
+
+## 2.6 main, wasm import from js (wasm export to js = as usual function + return)
+```
+main
+
+->
+
+void main()
+{
+...
+```
+
+```
+smain
+
+->
+
+extern(C) void main()
+{
+...
+```
+
+```
+// for wasm
+wmain
+
+->
+
+void _start(){  }
+```
+
+```
+// wasm import from js
+void = int a
+print
+
+->
+
+void print(int a);
+```
+
+## 2.10 reserved words (keywords) list
+including https://dlang.org/spec/lex.html#keywords  
+```
+abstract alias align asm assert auto 
+bool break byte 
+case cast catch char class const continue 
+dchar debug default delegate deprecated do double 
+else enum export extern 
+false final finally float for foreach foreach_reverse function 
+goto  
+if immutable import in inout int interface invariant is 
+lazy long 
+macro mixin module 
+new nothrow null 
+out override 
+package pragma private protected public pure 
+real ref return 
+scope shared static struct super switch synchronized 
+template this throw true try typeid typeof 
+ubyte uint ulong union unittest ushort 
+version void 
+wchar while with 
+
+__FILE__
+__FILE_FULL_PATH__
+__FUNCTION__
+__LINE__
+__MODULE__
+__PRETTY_FUNCTION__
+
+__gshared
+__parameters
+__rvalue
+__traits
+__vector
+
+__DATE__
+__EOF__
+__TIME__
+__TIMESTAMP__
+__VENDOR__
+__VERSION__
+
+
+[deprecated keywords] body cdouble cent cfloat creal delete idouble ifloat ireal ucent
+
+
+use
+as
+ptn
+ptns
+
+_
+++
+
+*_sw (function name end)
+
+main
+smain
+wmain
+
+dlang (dlang code without changes)
+```
+todo
+