1
1
Pyxell
2
2
======
3
3
4
- ### Clear and easy-to-use multi-paradigm compiled programming language with static typing. ###
5
-
6
- * Note: Up to version 0.6.0 the project had been developed in Haskell with BNFC. Now it has been rewritten to Python and ANTLR.*
4
+ ### Clean and easy-to-use multi-paradigm programming language with static typing. ###
7
5
8
6
9
7
Motivation
10
8
----------
11
9
12
10
The project aims to combine the best features of different programming languages,
13
- pack them into a clean syntax with significant indentation ,
11
+ pack them into a clean and consistent syntax ,
14
12
and provide the execution speed of native machine code.
15
13
16
14
It draws mainly from Python, Haskell, C#, and C++,
@@ -27,7 +25,7 @@ func fib(Int n) Int def
27
25
return 0
28
26
a, b = 0, 1
29
27
for i in 2..n do
30
- a, b = b, a + b
28
+ a, b = b, a+ b
31
29
return b
32
30
33
31
print fib(10)
@@ -64,44 +62,38 @@ print c.s ?? "---"
64
62
Features
65
63
--------
66
64
67
- * Python-like syntax with semantic indentation (+)
68
- * Strongly static typing with partial type inference (+)
69
- * Full compilation to machine code (+)
70
- * 64-bit integers and double-precision floating-point numbers (+)
71
- * Native tuples (+)
72
- * Immutable strings (+)
73
- * String interpolation (+)
74
- * Mutable arrays (+)
75
- * Extensive for-loops with ranges, steps, and zipping (+)
76
- * Array comprehension (+)
77
- * Slicing (+)
78
- * First-class functions (+)
79
- * Default and named arguments (+)
80
- * Lambda expressions (+)
81
- * Generic functions (+)
82
- * Module system (+/-)
83
- * Classes with safe references (+)
84
- * Separate nullable types (+ )
65
+ * Python-like syntax with semantic indentation
66
+ * Strongly static typing with partial type inference
67
+ * 64-bit integers and double-precision floating-point numbers
68
+ * Native tuples
69
+ * Immutable strings
70
+ * String interpolation
71
+ * Mutable arrays
72
+ * Complex for-loops with ranges, steps, and zipping
73
+ * Array comprehension and slicing
74
+ * First-class functions
75
+ * Default and named arguments
76
+ * Lambda expressions
77
+ * Generic functions
78
+ * Classes with safe references
79
+ * Inheritance and virtual methods
80
+ * Nullable types
81
+ * Full transpilation to C++17 and compilation to machine code
82
+ * Automatic memory management (utilizing C++'s smart pointers )
85
83
86
84
To do:
87
85
88
- * Generic types
89
86
* Containers library
90
- * Operator overloading
91
- * Arbitrary-precision arithmetic
92
87
* Closures
93
- * Coroutines
88
+ * Coroutines/generators
89
+ * Arbitrary-precision arithmetic
94
90
* Exception handling
91
+ * Unicode
92
+ * Generic classes
93
+ * Operator overloading
95
94
* Multiple inheritance
96
- * Automatic memory management
97
95
* Concurrency
98
-
99
-
100
- Details
101
- -------
102
-
103
- * LLVM IR generator and type checker written in Python with ANTLR and llvmlite.
104
- * Compilation to machine code (and optimizations) with Clang.
96
+ * Module system
105
97
106
98
107
99
Requirements
@@ -113,12 +105,7 @@ Requirements
113
105
python -m pip install -r requirements.txt
114
106
```
115
107
116
- * Clang 6+ with C++ standard library.
117
-
118
- The library shouldn't be a problem on Linux, but on Windows this may not work out of the box.
119
- In some cases Windows SDK installation may be required
120
- or it may be necessary to run ` pyxell ` with ` -target x86_64-pc-windows-gnu `
121
- (run ` test.py ` with ` -t ` argument to use this).
108
+ * C++17 compiler (e.g. GCC 7+ or Clang 5+).
122
109
123
110
124
111
Usage
@@ -128,17 +115,21 @@ Usage
128
115
python pyxell.py [-r] program.px
129
116
```
130
117
131
- If the program is correct, ` program.ll ` file and ` program.exe ` executable should be created in the same folder.
118
+ If the program is correct, ` program.cpp ` file and ` program.exe ` executable will be created in the same folder.
132
119
If not, errors will be displayed, pointing to the erroneous code location.
133
120
134
121
If ` -r ` option is given, the compiled program will be run immediately after compilation.
135
122
123
+ By default, ` gcc ` command is used to compile the code.
124
+ You can pick a different command using ` -c ` option.
125
+ Write ` -c=none ` to skip the compilation step (only C++ code will be created).
136
126
137
- Executable
138
- ----------
139
127
140
- You can build a standalone application using ` pyinstaller ` . Install it using ` pip ` , then run ` make exe ` .
141
- An executable (not requiring Python to run) will be created in the ` dist/pyxell ` folder.
128
+ PyInstaller
129
+ -----------
130
+
131
+ You can build a standalone application using ` PyInstaller ` . Install it using ` pip ` , then run ` make exe ` .
132
+ An executable ` pyxell.exe ` (not requiring Python to run) will be created in the ` dist/pyxell ` folder.
142
133
143
134
144
135
Development
@@ -149,7 +140,7 @@ first [download ANTLR](https://www.antlr.org/download/antlr-4.7.2-complete.jar)
149
140
and put the ` antlr-4.7.2-complete.jar ` file into ` src ` folder,
150
141
then run ` make parser ` .
151
142
152
- After changing the code of Pyxell libraries (` lib/*.px ` or ` src/library.py ` files),
143
+ After changing the code of Pyxell libraries (` lib/*.px ` files),
153
144
run ` make libs ` to rebuild them.
154
145
155
146
@@ -163,8 +154,8 @@ python test.py -v
163
154
Tests are divided into good (supposed to compile and run properly) and bad (should throw compilation errors).
164
155
165
156
The script is multi-threaded.
166
- Total execution time may vary from something like 10 seconds to 2 minutes,
167
- depending on the number of processors in your machine and other factors.
157
+ Total execution time may vary from something like 20 seconds to 5 minutes,
158
+ depending on the number of available CPU cores and other factors.
168
159
169
160
You can pass a path pattern to run only selected tests (e.g. ` python test.py arrays ` ).
170
161
To see all options, run it with ` -h ` .
@@ -185,3 +176,11 @@ Some more or less similar to Pyxell are, in alphabetical order:
185
176
* [ Haskell] ( https://www.haskell.org/ ) (functional, compiled),
186
177
* [ Nim] ( https://nim-lang.org/ ) (compiled via C/C++ or transpiled to JS),
187
178
* [ Python] ( https://www.python.org/ ) (dynamically typed).
179
+
180
+
181
+ History
182
+ -------
183
+
184
+ * The project was originaly written in Haskell, with BNFC as the parser generator, and used LLVM as the target language.
185
+ * In version 0.7.0 the code was rewritten to Python, with ANTLR as the parser generator.
186
+ * In version 0.9.0 the project was refactored to use C++ as the target language.
0 commit comments