-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeatures.html
309 lines (284 loc) · 10.4 KB
/
features.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Quail Programming Language</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/style-desktop-mid.css">
<link rel="stylesheet" href="css/style-desktop-small.css">
<link rel="stylesheet" href="css/style-mobile-big.css">
<link rel="stylesheet" href="css/secondary-page.css">
<script src="js/bootstrap.js"></script>
<script src="js/script.js"></script>
</head>
<body>
<main>
<header class="d-flex flex-wrap py-3 q-navbar">
<a href="/" class="d-flex align-items-center me-md-auto link-body-emphasis text-decoration-none">
<img src="images/quail80.png" alt="Logo" width="48" class="q-navbar-logo">
<span class="fs-4 q-navbar-logo-text">Quail</span>
</a>
<ul class="nav" id="top-navbar">
<li class="nav-item"><a href="/" class="nav-link">Home</a></li>
<li class="nav-item"><a href="/features.html" class="nav-link">Features</a></li>
<li class="nav-item"><a href="/download.html" class="nav-link">Download</a></li>
<li class="nav-item"><a href="/docs/" class="nav-link">Docs</a></li>
<li class="nav-item"><a href="https://github.com/Quail-Language/quail/" class="nav-link">Github</a></li>
</ul>
<button onclick="toggleMenu('top-navbar')" id="burger" class="burger-button burger-i-menu"></button>
</header>
<div class="container main-content mt-0 pt-3">
<div class="content-left what-is-quail w-100">
<h1>Features</h1>
<p class="mb-5">Take a look at the most amazing features in Quail!</p>
</div>
<div class="content-left">
<div class="example">
<pre class="example-code">
#:alias "set\\s*(?<id>[a-zA-Z0-9.]*)\\s*to\\s*(?<value>.*)" $1 = $2
set a to 2
set c to 455.3
</pre>
<div>
<h3>Preprocessor</h3>
<p>Simple regex-based preprocessor opens possibilities to widely customize the syntax</p>
</div>
</div>
<div class="example">
<pre class="example-code">
while true {
for i in 1:10 do
if i % 2 == 0:
print(i)
end
}
</pre>
<div>
<h3>Flexible syntax</h3>
<p>One of the many examples of Quail's flexible syntax is this. You can define code blocks
as you wish: with curly braces, do-end's or even like in Python. Quail does not limit you</p>
</div>
</div>
<div class="example">
<pre class="example-code">
a = 10
a = "abc"
print(a)
</pre>
<div>
<h3>Dynamic typing</h3>
<p>Dynamic typing opens wide possibilities when writing code</p>
</div>
</div>
<div class="example">
<pre class="example-code">
a = 10
a = "Hello"
a = [1, 2, 3]
num b = 10
b = "Hello" # causes an error
num | string c = 10
c = "Hello" # Ok
c = [1, 2, 3] # causes an error
</pre>
<div>
<h3>A little bit of static typing</h3>
<p>While Quail is conceptually a dynamic typed language, it also can do static typing.
By default, all variables are dynamic, but you can clarify the type and the
variable becomes statically typed</p>
</div>
</div>
<div class="example">
<pre class="example-code">
class Person {
name = ""
method hello(this)
out("Hello from " + this.name)
}
# Add methods to class on the way
Person.someMethod = (this, args...) -> {}
</pre>
<div>
<h3>Prototype-based OOP</h3>
<p>Prototype-oriented programming is the best in scripting, especially dynamic typed
languages. You can add methods and fields to the class at the runtime or modify
existing, easily inherit via standard tools or make your own inheritance system</p>
</div>
</div>
<div class="example">
<pre class="example-code">
Number.sum = (this, a) -> {
return this + a
}
print(15.sum(37))
</pre>
<div>
<h3>Everything is an object</h3>
<p>You can use every value in Quail as an object, add, remove, change fields and
methods, invoke them.</p>
</div>
</div>
<div class="example">
<pre class="example-code">
a = [1, 2, 3]
b = [4, 5, 6]
print(a + b) # [1, 2, 3, 4, 5, 6]
print(a [+] b) # [5, 7, 9]
c = [[1, -1], [-1, 1]]
d = [[1, 2], [3, 4]]
print(c {*} d) # [[1, -2], [-3, 4]]
</pre>
<div>
<h3>Rich tools for list manipulation</h3>
<p>Alongside with very useful <code>map</code> and <code>filter</code>
functions, Quail also provides so-called matrix and array operators which
"unfold" lists and perform operations element-by-element</p>
</div>
</div>
<div class="example">
<pre class="example-code">
n = num(input())
f = [((i) -> {
if i < 2 return i
else return _this[-2] + _this[-1]
})(i) through 0:n as i]
print(f)
</pre>
<div>
<h3>Richer generators</h3>
<p>Alongside with array and matrix operators, Quail's list and dict generators
have a richer functionality by providing a special variable <code>_this</code>
which contains currently generated list or dict. So it is now possible to generate
basing on last-generated content. For example, this could be used for calculating
Fibonacci numbers.</p>
</div>
</div>
<div class="example">
<pre class="example-code">
through 0:10 as x {
through 0:10 as y {
through 0:10 as z {
if z == 5
strike 2
print(x, y, z)
}
}
}
</pre>
<div>
<h3><code>strike</code> syntax</h3>
<p><code>strike</code> works pretty much same as <code>break</code>, but with nested
loops. In this example, when <code>z</code> reaches 5, not only z's loop will be broken,
but also the one that corresponds to <code>y</code>, because <code>2</code> is specified
in the <code>strike</code> instruction. But x's loop will remain untouched</p>
</div>
</div>
<div class="example">
<pre class="example-code">
use "lang/ji" = ji
JFrame = ji.getClass("javax.swing.JFrame")
win = JFrame("My window")
win.setSize(640, 480)
win.setDefaultCloseOperation(3)
win.setVisible(true)
while win.isVisible() {}
</pre>
<div>
<h3>Deep Java integration</h3>
<p>The JI (Java Integration) library allows you to create a bridge between Java and Quail,
so you can grab a class from Java and it will act almost like native Quail class:
you can call methods with native Quail values - they will be automatically converted
to Java values, you can construct objects and access fields</p>
</div>
</div>
<div class="example">
<pre class="example-code">
class Queue {
#? Implementation of a single-ended queue.
num size(this) {}
void add(this, object obj) {
#? Add object to back of queue
}
object pop(this) {
#? Pop object from front.
#? If queue is empty, null is returned
}
void clear(this) {}
object peek(this) {
#? Get object from front without popping it.
#? If queue is empty, null is returned
}
}
</pre>
<div>
<h3>Inbuilt documentation language</h3>
<p>You can create documentation right in your source code using comments that
start with <code>#?</code>. Then you can export that documentation to HTML
to serve on your documentation portal.
<br><br>
<i>btw, this is exactly how all <a href="docs/libs/">Quail Library Docs</a> are created</i></p>
</div>
</div>
<div class="example">
<div style="width: 40%"><pre class="example-code w-100">
public class QuailTestAddon extends QuailAddon {
public List<BuiltinLibrary> providedLibraries() {
return Arrays.asList(
new MyTestLibrary()
);
}
}
public class MyTestLibrary implements BuiltinLibrary {
public String id() { return "test/mytestlib"; }
public QObject constructLibrary(Runtime runtime) {
...
contents.put("test", new MyTestFuncTest(runtime));
...
}
}
public class MyTestFuncTest extends QBuiltinFunc {
public QObject action(...) {
return Val("Test library works!");
}
}
</pre>
<pre class="example-code w-100">
use "test/mytestlib" = testlib
print(testlib.test())
</pre>
</div>
<div>
<h3>Quail Addons</h3>
<p>And if even all these features weren't enough for you, Quail allows you to
create "addons" that can add new preprocessor directives, parser annotations
and libraries all in pure Java. Then you just package your addon into <code>.jar</code>
and add a little <code>-G.addons=myaddon.jar</code> flag when starting Quail</p>
</div>
</div>
</div>
</div>
<footer class="row q-bg-darkest-teal text-white py-5">
<div class="footer-logo-and-copy col mb-3 ms-5">
<a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto link-body-emphasis text-decoration-none">
<img src="images/quail80.png" alt="Logo" width="48" class="q-navbar-logo">
<span class="fs-4 q-navbar-logo-text text-white">Quail</span>
</a>
<p class="copyright-notice">
© Tapeline 2021-2024<br>
GNU GPL v3.0</p>
</div>
<div class="col footer-nav nav">
<ul>
<li class="nav-item"><a href="/" class="nav-link">Home</a></li>
<li class="nav-item"><a href="/features" class="nav-link">Features</a></li>
<li class="nav-item"><a href="/download" class="nav-link">Download</a></li>
<li class="nav-item"><a href="/docs" class="nav-link">Docs</a></li>
<li class="nav-item"><a href="https://github.com/Quail-Language/quail/" class="nav-link">Github</a></li>
</ul>
</div>
</footer>
</main>
</body>
</html>