-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
91 lines (89 loc) · 5.11 KB
/
index.html
File metadata and controls
91 lines (89 loc) · 5.11 KB
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
---
title: Home
layout: document
---
<img src="/resources/Wizardry_banner.png" style="max-width: 30%; min-width: 200pt; display: block; margin-left: auto; margin-right: auto;"></img>
<br><div class="divider" style="max-width: 50%; min-width: 240pt;"></div><br>
<h1>About</h1>
Wizardry is a system programming language with a C-like syntax and some extra features.<br>
These features include:<br>
<ul>
<li>
<code><code_kw>defer</code_kw></code>:<br>
<span class="dent">
<code><code_kw>defer</code_kw></code> allows you to add code to run before exiting the scope.<br>
You can add a single statement or a whole block enclosed in curly brackets.<br>
It can be useful in the case you want to allocate multiple variables but need to check for things along the way that may cause a return.<br>
</span>
</li>
<li>
All-in-one types:<br>
<span class="dent">
<code><code_type>int</code_type>[<code_num>5</code_num>]<code_type>$</code_type>[<code_num>2</code_num>] <code_var>myvar</code_var>;</code>
will declare <code><code_var>myvar</code_var></code> as an array of five pointers to arrays of 2 integers.
</span>
</li>
<li>
An improved <code><code_func>printf</code_func></code> and <code><code_func>scanf</code_func></code> syntax:<br>
<span class="dent">
</span>
</li>
<li>
Function overloading and non-invasive symbol mangling:<br>
<span class="dent">
</span>
</li>
</ul>
<br><div class="divider"></div><br>
<h1>Links</h1>
<span style="display: table;">
<span class="linkspan"><b>Documentation:</b> <tb></span>
<span style="linkspan">
<a HREF="/pages/docs/">Page</a><tb><a HREF="https://github.com/Wizardry-PL/Wizardry">Repository</a><br>
</span>
<span class="linkspan"><b>Compiler:</b> <tb></span>
<span style="linkspan">
<disabled>Download</disabled><tb><a HREF="https://github.com/Wizardry-PL/Wizard">Repository</a><br>
</span>
<span class="linkspan"><b>Github page:</b> <tb></span>
<span style="linkspan">
<a HREF="https://github.com/Wizardry-PL">Wizardry-PL</a><br>
</span>
</span>
<br><div class="divider"></div><br>
<h1>Example code</h1>
A hello world program:<br>
<div class="code">
<code_rem># Hello World</code_rem><br>
<code_cmd>@include <wizardry></code_cmd><br>
<br>
<code_type>int</code_type> <code_func>main</code_func>(<code_type>int</code_type> <code_var>argc</code_var>, <code_type>char$$</code_type> <code_var>argv</code_var>) {<br>
<tb><code_ns>wiz</code_ns>.<code_func>print</code_func>(<code_str>"Hello, world!\n"</code_str>);<br>
<tb><code_kw>return</code_kw> <code_num>0</code_num>;<br>
}<br>
</div><br>
A hypothetical function showing a possible use for the <code><code_kw>defer</code_kw></code> keyword:<br>
<div class="code">
<code_type>void</code_type> <code_func>printdata</code_func>() {<br>
<tb><code_type>char$$</code_type> <code_var>mystr</code_var> = <code_ns>wiz</code_ns>.<code_func>alloc</code_func>(<code_num>256</code_num>);<br>
<tb><code_kw>defer</code_kw> <code_ns>wiz</code_ns>.<code_func>free</code_func>(<code_var>mystr</code_var>);<br>
<tb><code_func>getdata</code_func>(<code_var>mystr</code_var>, <code_num>256</code_num>);<br>
<tb><code_kw>if</code_kw> (!<code_var>mystr</code_var>$) <code_kw>return</code_kw>; <code_rem># frees mystr before returning due to defer</code_rem><br>
<tb><code_type>char$$</code_type> <code_var>outstr</code_var> = <code_ns>wiz</code_ns>.<code_func>alloc</code_func>(<code_num>4096</code_num>);<br>
<tb><code_kw>defer</code_kw> <code_ns>wiz</code_ns>.<code_func>free</code_func>(<code_var>outstr</code_var>);<br>
<tb><code_func>mkreadable</code_func>(<code_var>mystr</code_var>, <code_var>outstr</code_var>, <code_num>4096</code_num>);<br>
<tb><code_ns>wiz</code_ns>.<code_func>printf</code_func>(<code_str>"Data: <code_fmt>%[s]</code_fmt>\n"</code_str>, <code_var>outstr</code_var>);<br>
<tb><code_rem># frees mystr and outstr before returning due to the two defers</code_rem><br>
}<br>
</div><br>
A program that displays info about the arguments passed to it:<br>
<div class="code">
<code_cmd>@include <wizardry></code_cmd><br>
<br>
<code_type>int</code_type> <code_func>main</code_func>(<code_type>int</code_type> <code_var>argc</code_var>, <code_type>char$$</code_type> <code_var>argv</code_var>) {<br>
<tb><code_kw>for</code_kw> (<code_type>int</code_type> <code_var>i</code_var> = <code_num>0</code_num>; <code_var>i</code_var> < <code_var>argc</code_var>; ++<code_var>i</code_var>) {<br>
<tb><tb><code_ns>wiz</code_ns>.<code_func>printf</code_func>(<code_str>"Arg <code_fmt>%[i]</code_fmt> (<code_fmt>%[i]</code_fmt> chars): <code_fmt>%[s]</code_fmt>\n"</code_str>, <code_var>i</code_var>, <code_ns>wiz</code_ns>.<code_func>strlen</code_func>(<code_var>argv</code_var>[<code_var>i</code_var>]), <code_var>argv</code_var>[<code_var>i</code_var>]);<br>
<tb>}<br>
<tb><code_kw>return</code_kw> <code_num>0</code_num>;<br>
}<br>
</div>