4
4
### Clean and easy-to-use multi-paradigm programming language with static typing. ###
5
5
6
6
7
+ Documentation
8
+ -------------
9
+
10
+ https://www.pyxell.org/docs/
11
+
12
+
7
13
Motivation
8
14
----------
9
15
10
- The project aims to combine the best features of different programming languages,
16
+ Pyxell [ _ pixel _ ] aims to combine the best features of different programming languages,
11
17
pack them into a clean and consistent syntax,
12
18
and provide the execution speed of native machine code.
13
19
14
20
It draws mainly from Python, C++, C#, and Haskell,
15
- and tries to avoid common design flaws that have been nicely described
21
+ trying to avoid common design flaws that have been nicely described
16
22
[ in this blog post] ( https://eev.ee/blog/2016/12/01/lets-stop-copying-c/ ) .
17
23
18
24
19
- Examples
20
- --------
21
-
22
- Rational numbers:
23
-
24
- ```
25
- print 1/10 + 5^-1 # 3/10
26
- ```
27
-
28
- Range literals, for-loops, string interpolation:
29
-
30
- ```
31
- a = ['A'..'Z']
32
- for x, i in a, 0... by 5 do
33
- print "a[{i}] = {x}"
34
- ```
35
-
36
- Dynamic containers:
37
-
38
- ```
39
- [Int] a = [1] # array (Python's list / C++'s vector)
40
- a.push(2)
41
-
42
- {Float} b = {3.0} # hash set
43
- b.add(4.0)
44
-
45
- {Char:String} c = {'5': "6"} # dictionary (hash map)
46
- c['7'] = "8"
47
- ```
48
-
49
- Generic functions, lambda expressions:
50
-
51
- ```
52
- func fold<A,B>([A] a, A->B->B f, B r) B def
53
- for x in a do
54
- r = f(x, r)
55
- return r
56
-
57
- print fold([2, 3, 4], _*_, 1) # 24
58
-
59
- -- There are built-in methods like this:
60
- print [0..10 by 2].reduce(_+_) # 30
61
- ```
62
-
63
- Generators, tuples, spread syntax:
64
-
65
- ```
66
- fib = lambda* n def
67
- if n <= 0 do
68
- return
69
- a, b = 0, 1
70
- yield a
71
- for _ in 2..n do
72
- yield b
73
- a, b = b, a+b
74
-
75
- print [...fib(10)]
76
- ```
77
-
78
- Classes, nullable types:
79
-
80
- ```
81
- class C def
82
- String? s: null
83
-
84
- c = C()
85
- print c.s?.length
86
- print c.s ?? "---"
87
- ```
88
-
89
-
90
25
Features
91
26
--------
92
27
@@ -115,12 +50,14 @@ Features
115
50
To do:
116
51
117
52
* Exception handling
118
- * Unicode
53
+ * Static class fields and methods
54
+ * Complex numbers
55
+ * Unicode support
56
+ * Module system
57
+ * Multiple inheritance
119
58
* Generic classes
120
59
* Operator overloading
121
- * Multiple inheritance
122
- * Concurrency
123
- * Module system
60
+ * Asynchronous programming
124
61
125
62
126
63
Requirements
@@ -134,8 +71,10 @@ python -m pip install -r requirements.txt
134
71
135
72
* C++17 compiler: Clang 5+ or GCC 7+.
136
73
137
- Note that generators are currently supported only in Clang, since they are based on C++'s coroutines
138
- (GCC 10 also supports coroutines, but as of version 10.1 the implementation is buggy, so it is not yet supported by Pyxell).
74
+ Note that generators are currently available only with Clang, since they are based on C++'s coroutines.
75
+ Though GCC 10 also supports coroutines, as of version 10.2 the implementation is buggy
76
+ (see [ here] ( https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95591 ) or [ here] ( https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95823 ) ),
77
+ so it is not yet supported by Pyxell.
139
78
140
79
141
80
Usage
@@ -145,28 +84,29 @@ Usage
145
84
python pyxell.py program.px
146
85
```
147
86
148
- If the program is correct , ` program.cpp ` file and ` program.exe ` executable will be created in the same folder,
87
+ If the program is valid , ` program.cpp ` file and ` program.exe ` executable will be created in the same folder,
149
88
and it will be automatically executed (unless you add ` -n ` option).
150
89
Otherwise, errors will be displayed, pointing to the erroneous code location.
151
90
152
91
By default, ` clang ` command is used to compile the code.
153
92
You can pick a different compiler using ` -c ` option.
154
93
155
- Use ` -s ` to skip the compilation step and obtain transpiled C++ code with all headers included,
156
- ready for manual compilation (with -std=c++17 option, and with -fcoroutines-ts in the case of Clang).
157
-
158
94
The executable is not optimized by default.
159
95
You can set the optimization level with ` -O ` option, e.g. ` -O2 ` .
160
96
This will make the program run faster, but also make the compilation slower.
161
97
98
+ Use ` -s ` to skip the compilation step and obtain transpiled C++ code with all headers included,
99
+ ready for manual compilation (with ` -std=c++17 ` option, and with ` -fcoroutines-ts ` in the case of Clang).
100
+
162
101
To see all options, use ` -h ` .
163
102
164
103
165
104
PyInstaller
166
105
-----------
167
106
168
- You can build a standalone application using ` PyInstaller ` . Install it using ` pip ` , then run ` make exe ` .
169
- An executable ` pyxell.exe ` (not requiring Python to run) will be created in the ` dist/pyxell ` folder.
107
+ You can build a standalone compiler application using ` PyInstaller ` .
108
+ Install ` PyInstaller ` with ` pip ` , then run ` make exe ` .
109
+ An executable (not requiring Python to run) will be created in the ` dist/pyxell ` folder.
170
110
171
111
172
112
Development
@@ -180,19 +120,22 @@ then run `make parser`.
180
120
After changing the code of Pyxell libraries (` lib/*.px ` files),
181
121
run ` make libs ` to rebuild them.
182
122
123
+ To build the documentation, go to the ` docs ` folder, run ` npm install ` , then ` make ` .
124
+ To start a documentation server locally, install ` flask ` and run ` server.py ` in the same folder.
125
+
183
126
184
127
Tests
185
128
-----
186
129
187
130
```
188
- python test.py [-v]
131
+ python test.py
189
132
```
190
133
191
134
Tests are divided into good (supposed to compile and run properly) and bad (should throw compilation errors).
192
135
193
- By default, the whole C++ code for correct tests is merged, so that only one file is compiled,
136
+ By default, the whole C++ code for valid tests is merged, so that only one file is compiled,
194
137
which is faster than compiling hundreds of files individually, even using multiple threads.
195
- Total execution time should be around 30-60 seconds.
138
+ Total execution time (with default settings) should be around 30-60 seconds.
196
139
197
140
If, however, the script fails with an error like this: ` too many sections ` / ` file too big `
198
141
(seen with GCC 7.2 on Windows), or there is another compilation error that is hard to decipher,
@@ -202,9 +145,6 @@ You can pass a path pattern to run only selected tests (e.g. `python test.py arr
202
145
203
146
To see all options, run the script with ` -h ` .
204
147
205
- Tests serve currently also as a documentation of the language.
206
- You can browse them to learn the syntax and semantics.
207
-
208
148
209
149
Alternatives
210
150
------------
0 commit comments