Skip to content

Commit 0f5acc2

Browse files
committed
Merge branch 'cpp-target'
2 parents e64a08e + 9ef4434 commit 0f5acc2

File tree

237 files changed

+4378
-6982
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+4378
-6982
lines changed

.gitignore

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
pyxell
22
*.exe
3-
*.o
43
*.jar
54
.idea/
65
*.iml
76
_*
87
*.tmp
9-
*.bc
10-
*.ll
8+
*.cpp
9+
*.gch
1110
*.spec
1211
build/
1312
dist/

LICENSE.txt

+17-21
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
Copyright (c) 2018 Adam Sołtysik. All rights reserved.
21

3-
Redistribution and use in source and binary forms, with or without modification,
4-
are permitted provided that the following conditions are met:
2+
The MIT License (MIT)
53

6-
- Redistributions of source code must retain the above copyright notice,
7-
this list of conditions and the following disclaimer.
4+
Copyright (c) 2020 Adam Sołtysik
85

9-
- Redistributions in binary form must reproduce the above copyright notice,
10-
this list of conditions and the following disclaimer in the documentation
11-
and/or other materials provided with the distribution.
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
1212

13-
- Neither the name of the copyright holder nor the names of contributors may
14-
be used to endorse or promote products derived from this software without
15-
specific prior written permission.
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
1615

17-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ libs:
77
python pyxell.py --libs
88

99
exe:
10-
python -m PyInstaller --add-data "lib/;lib/" pyxell.py --noconfirm
10+
python -m PyInstaller --hidden-import=decorator --add-data "lib/;lib/" pyxell.py --noconfirm
1111

1212
clean:
1313
"$(MAKE)" clean -C src

README.md

+48-49
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
Pyxell
22
======
33

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. ###
75

86

97
Motivation
108
----------
119

1210
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,
1412
and provide the execution speed of native machine code.
1513

1614
It draws mainly from Python, Haskell, C#, and C++,
@@ -27,7 +25,7 @@ func fib(Int n) Int def
2725
return 0
2826
a, b = 0, 1
2927
for i in 2..n do
30-
a, b = b, a + b
28+
a, b = b, a+b
3129
return b
3230
3331
print fib(10)
@@ -64,44 +62,38 @@ print c.s ?? "---"
6462
Features
6563
--------
6664

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)
8583

8684
To do:
8785

88-
* Generic types
8986
* Containers library
90-
* Operator overloading
91-
* Arbitrary-precision arithmetic
9287
* Closures
93-
* Coroutines
88+
* Coroutines/generators
89+
* Arbitrary-precision arithmetic
9490
* Exception handling
91+
* Unicode
92+
* Generic classes
93+
* Operator overloading
9594
* Multiple inheritance
96-
* Automatic memory management
9795
* 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
10597

10698

10799
Requirements
@@ -113,12 +105,7 @@ Requirements
113105
python -m pip install -r requirements.txt
114106
```
115107

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+).
122109

123110

124111
Usage
@@ -128,17 +115,21 @@ Usage
128115
python pyxell.py [-r] program.px
129116
```
130117

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.
132119
If not, errors will be displayed, pointing to the erroneous code location.
133120

134121
If `-r` option is given, the compiled program will be run immediately after compilation.
135122

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).
136126

137-
Executable
138-
----------
139127

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.
142133

143134

144135
Development
@@ -149,7 +140,7 @@ first [download ANTLR](https://www.antlr.org/download/antlr-4.7.2-complete.jar)
149140
and put the `antlr-4.7.2-complete.jar` file into `src` folder,
150141
then run `make parser`.
151142

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),
153144
run `make libs` to rebuild them.
154145

155146

@@ -163,8 +154,8 @@ python test.py -v
163154
Tests are divided into good (supposed to compile and run properly) and bad (should throw compilation errors).
164155

165156
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.
168159

169160
You can pass a path pattern to run only selected tests (e.g. `python test.py arrays`).
170161
To see all options, run it with `-h`.
@@ -185,3 +176,11 @@ Some more or less similar to Pyxell are, in alphabetical order:
185176
* [Haskell](https://www.haskell.org/) (functional, compiled),
186177
* [Nim](https://nim-lang.org/) (compiled via C/C++ or transpiled to JS),
187178
* [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

Comments
 (0)