-
-
Notifications
You must be signed in to change notification settings - Fork 85
/
c3.scroll
284 lines (272 loc) · 5.66 KB
/
c3.scroll
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
import ../code/conceptPage.scroll
id c3
name C3
appeared 2019
creators Christoffer Lernö
tags pl
website http://www.c3-lang.org/
blog https://c3.handmade.network/blog
conceptDescription C3 is a programming language that builds on the syntax and semantics of the C language, with the goal of evolving it while still retaining familiarity for C programmers.
isOpenSource true
writtenIn c markdown json yaml python yacc cmake cpp lex bourne-shell dockerfile make
influencedBy c2 c
fileExtensions c3 c3i
rosettaCode https://rosettacode.org/wiki/Category:C3
repoStats
firstCommit 2019
commits 1788
committers 57
files 1215
newestCommit 2024
country Sweden
originCommunity The C3 Language Project
reference https://www.reddit.com/r/ProgrammingLanguages/comments/ex7hpp/february_2020_monthly_what_are_you_working_on/fgdpuki/
reference https://news.ycombinator.com/item?id=32005678
example
module stack <Type>;
// Above: the parameterized type is applied to the entire module.
import std::mem;
struct Stack
{
usize capacity;
usize size;
Type* elems;
}
// The type methods offers dot syntax calls,
// so this function can either be called
// Stack.push(&my_stack, ...) or
// my_stack.push(...)
fn void Stack.push(Stack* this, Type element)
{
if (this.capacity == this.size)
{
this.capacity *= 2;
this.elems = mem::realloc(this.elems, $sizeof(Type) * this.capacity);
}
this.elems[this.size++] = element;
}
fn Type Stack.pop(Stack* this)
{
assert(this.size > 0);
return this.elems[--this.size];
}
fn bool Stack.empty(Stack* this)
{
return !this.size;
}
twitter https://twitter.com/C3Lang
githubRepo https://github.com/c3lang/c3c
firstCommit 2019
stars 886
subscribers 19
created 2019
updated 2023
issues 41
forks 49
description The C3 compiler.
lineCommentToken //
multiLineCommentTokens /* */
booleanTokens true false
hasLineComments true
// A comment
hasComments true
// A comment
/* Another comment */
hasRegularExpressionsSyntaxSugar false
hasSemanticIndentation false
hasBooleans true
hasBitWiseOperators true
int i = b << 4 + x; // Same as (b << 4) + x
hasOctals true
0o177
hasArraySlicingSyntax true
int[] slice1 = array[0..5]; // start..end
int[] slice2 = array[0:6]; // start:length
hasAsyncAwait false
hasBoundedCheckedArrays true
hasBreak true
hasBuiltInRegex false
hasContinue true
hasDuckTyping false
hasDynamicProperties false
hasEscapeCharacters true
"\e\n\r"
hasExpressions true
hasForLoops true
hasHereDocs false
hasHexadecimals true
hasIfs true
hasIfElses true
hasImplicitTypeConversions true
hasFunctions true
hasFunctionOverloading false
hasFunctionComposition false
hasHomoiconicity false
hasInheritance true
hasLabels true
while FOO: (x > 0)
{
for (int i = 0; i < 10; i++
{
x = baz();
if (x > i) break FOO;
}
}
hasLazyEvaluation true
fn void print(String s)
{
io::printfn("Said: %s", s);
}
macro @foo(bool run, #lazy)
{
if (run) #lazy;
}
// Only "Said: Hello" is printed:
@foo(false, print("Bye"));
@foo(true, print("Hello"));
hasMagicGettersAndSetters false
hasMessagePassing false
hasNull true
hasPipes false
hasSExpressions false
hasBinaryNumbers true
0b110011
hasExplicitTypeCasting true
double d = 3.3;
int x = (int)d;
hasNamespaces true
import std::io;
...
io::printf("%d", i);
hasMultipleInheritance false
hasDirectives false
hasIntegers true
int x = 314159;
hasIncrementAndDecrementOperators true
i++; --j;
hasManualMemoryManagement true
hasAssertStatements true
assert(a > 0, "Expected a positive number");
$assert(Foo.sizeof == 8, "Foo sizecheck at compile time failed");
hasDefaultParameters true
fn void test(int x = 10) { ... }
hasZeroBasedNumbering true
hasAccessModifiers true
hasClasses false
hasConstants true
const FOO = 123;
const void* BAR = null;
hasAbstractTypes false
hasDocComments true
/**
* @param [in] foo "The foo value"
* @return "the toal foo count"
**/
hasEnums true
enum TestEnum : int
{
FOO,
BAR,
BAZ
}
hasUnaryOperators true
hasUnicodeIdentifiers false
hasUnitsOfMeasure false
hasUserDefinedOperators false
hasSingleTypeArrays true
hasVariableSubstitutionSyntax false
hasUnionTypes true
union Foo
{
int x;
float f;
struct
{
char[2] z;
}
}
hasMacros true
macro square(x)
{
return x * x;
}
hasForEachLoops true
foreach (x : list)
{
foo(x);
}
hasImports true
import std::io;
hasMethods true
fn int Foo.get_value(Foo* this)
{
return this.value;
}
hasMultiLineComments true
/*
Multiline comment
*/
hasMultilineStrings true
String s = `this
string is multiline`;
hasOperatorOverloading true
fn int IntList.get(IntList* this, int idx) @operator([])
{
return this.vals[idx];
}
...
IntList x = ...
foo(x[1]);
hasModules true
module my_module::submodule;
...
hasReservedWords true
hasVariadicFunctions true
fn void foo_typed(int x, int... arg) { ... }
fn void foo_untyped(int x, ...arg)
...
foo_typed(1, 2, 3);
foo_untyped(1, "hello", 1.2);
hasPointers true
isCaseSensitive true
hasConstructors false
hasCaseInsensitiveIdentifiers false
hasAssignment true
a = b;
hasConditionals true
hasWhileLoops true
while (int x = foo(); x > 0)
{
sum += x;
}
hasScientificNotation true
hasTernaryOperators true
int foo = x ? 1 : 0;
hasStrings true
String s = "hello";
String t = `I say "hello"`;
hasStructs true
struct Test
{
int x;
float y;
String z;
}
hasGotos false
hasGarbageCollection false
hasSwitch true
switch(expression)
{
case 1:
do_something();
case 2:
if (x > 0) nextcase 1; // Jump to 1
nextcase; // Jump to the next case.
default:
foo();
}
domainName c3-lang.org
registered 2019
awisRank
2022 6109240
semanticScholar 0