2 |
3 | Edit the text, then click the ▶ button to run it.
4 | The only I/O supported is logging.
5 |
6 |
7 |
8 | main void()
9 | info log "Hello, world!"
10 |
11 |
12 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/function-pointer-lambda.crow.out:
--------------------------------------------------------------------------------
1 | exit code: 1
2 | stderr:
3 | test/end-to-end/compile-errors/function-pointer-lambda.crow 2:25-2:33 A function pointer can't be implemented by a lambda. Write a function and use '&f' instead.
4 | Uncaught exception: Reached compile error
5 | at main
6 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/imported-name-refers-to-nothing.crow.out:
--------------------------------------------------------------------------------
1 | exit code: 1
2 | stdout:
3 | info: hello
4 | stderr:
5 | test/end-to-end/compile-errors/imported-name-refers-to-nothing.crow 2:17-2:20 Imported name 'foo' does not refer to anything.
6 | Uncaught exception: Reached compile error
7 | at main
8 |
--------------------------------------------------------------------------------
/test/end-to-end/parse-errors/type-parens.crow.out:
--------------------------------------------------------------------------------
1 | exit code: 1
2 | stderr:
3 | test/end-to-end/parse-errors/type-parens.crow 1:10-1:12 '()' is not a type. Did you mean 'void'?
4 | test/end-to-end/parse-errors/type-parens.crow 2:10-2:12 '()' is not a type. Did you mean 'void'?
5 | Stopping due to compile errors.
6 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/enum-value-overflow.crow:
--------------------------------------------------------------------------------
1 | main void()
2 | ()
3 |
4 | e enum
5 | a = -1
6 | b = 0
7 | c = 4294967295
8 | d = 4294967296
9 |
10 | e enum int8 storage
11 | a = -129
12 | b = -128
13 | c = 127
14 | d = 128
15 |
16 | f flags nat16 storage
17 | a = 65535
18 | b = 65536
19 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/match-warnings.crow:
--------------------------------------------------------------------------------
1 | main void()
2 | ()
3 |
4 | f nat(a nat?)
5 | match a
6 | as none
7 | 1
8 | as some x
9 | x
10 | else
11 | 3
12 |
13 | f nat(a comparison)
14 | match a
15 | as less
16 | 1
17 | as equal
18 | 2
19 | as greater
20 | 3
21 | else
22 | 4
23 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/match-warnings.crow.out:
--------------------------------------------------------------------------------
1 | exit code: 0
2 | stderr:
3 | test/end-to-end/compile-errors/match-warnings.crow 10:5-10:9 'match' handles every case, so the 'else' is unused.
4 | test/end-to-end/compile-errors/match-warnings.crow 21:5-21:9 'match' handles every case, so the 'else' is unused.
5 |
--------------------------------------------------------------------------------
/test/end-to-end/parse-errors/spec-signature-unfinished.crow.out:
--------------------------------------------------------------------------------
1 | exit code: 1
2 | stderr:
3 | test/end-to-end/parse-errors/spec-signature-unfinished.crow 3:1-2:12 Expected a name (non-operator).
4 | test/end-to-end/parse-errors/spec-signature-unfinished.crow 3:1-2:12 Expected ','.
5 | Stopping due to compile errors.
6 |
--------------------------------------------------------------------------------
/test/unit/library/shared-map-tests.crow:
--------------------------------------------------------------------------------
1 | dummy-shared-map-tests nat()
2 | 0
3 |
4 | test
5 | res nat shared[nat] = ()
6 | for x : 0::nat .. 100 parallel
7 | res[x] := x * 2
8 | ()
9 | res.move-to::nat[nat] is for x : 0::nat .. 100
10 | x, x * 2
11 | ()
12 |
13 | -to symbol(a nat)
14 | a.show to
15 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/auto-fun-flags.crow:
--------------------------------------------------------------------------------
1 | main void()
2 | x r = 1, (), ()
3 | info log "{x == x}"
4 | ()
5 |
6 | r record
7 | x nat
8 | y foo
9 | z bar
10 | == bool(a r, b r) bare
11 |
12 | foo record
13 | == bool(a foo, b foo) unsafe
14 |
15 | bar record
16 | == bool(a bar, b bar) summon
17 |
18 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/lambda-errors.crow:
--------------------------------------------------------------------------------
1 | main void()
2 | d = () => 1
3 | 3 foo (x string) => ()
4 | 3 bar x => ()
5 |
6 | foo void(x nat, f void mut(x nat))
7 | ()
8 | bar void(x nat, f void mut(x nat))
9 | ()
10 | bar void(x nat, f nat)
11 | ()
12 | bar void(x nat, f void mut(x string))
13 | ()
14 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/record-privacy-b.crow:
--------------------------------------------------------------------------------
1 | import
2 | ./record-privacy-a
3 |
4 | main void()
5 | ()
6 |
7 | foo void()
8 | a private-ctor = 0,
9 | _ = a
10 | b private-mut = 0, 0, 0
11 | b.j := 0
12 | _ = b.j
13 | b.k := 0
14 | _ = b.k
15 | b.l := 0
16 | _ = b.l
17 | _ internal-ctor = 0,
18 |
--------------------------------------------------------------------------------
/test/end-to-end/parse-errors/unfinished-string-interpolation.crow.out:
--------------------------------------------------------------------------------
1 | exit code: 1
2 | stderr:
3 | test/end-to-end/parse-errors/unfinished-string-interpolation.crow 2:7-2:7 Unexpected newline.
4 | test/end-to-end/parse-errors/unfinished-string-interpolation.crow 2:7-2:7 Expected '}'.
5 | Stopping due to compile errors.
6 |
--------------------------------------------------------------------------------
/test/unit/loops.crow:
--------------------------------------------------------------------------------
1 | dummy-loops nat()
2 | 0
3 |
4 | test
5 | x mut nat = 0
6 | y nat = loop
7 | if x == 5
8 | break x * 2
9 | else
10 | x +:= 1
11 | continue
12 | x is 5
13 | y is 10
14 |
15 | until x == 15
16 | x +:= 1
17 | x is 15
18 |
19 | while x > 10
20 | x -:= 1
21 | x is 10
22 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/cant-infer-type-args.crow.out:
--------------------------------------------------------------------------------
1 | exit code: 1
2 | stderr:
3 | test/end-to-end/compile-errors/cant-infer-type-args.crow 5:5-5:6 Can't infer type arguments to 'f[t] void()' (from test/end-to-end/compile-errors/cant-infer-type-args.crow line 1)
4 | Uncaught exception: Reached compile error
5 | at main
6 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/mut-param.crow.out:
--------------------------------------------------------------------------------
1 | exit code: 1
2 | stderr:
3 | test/end-to-end/compile-errors/mut-param.crow 6:10-6:13 A parameter can't be mutable.
4 | test/end-to-end/compile-errors/mut-param.crow 7:5-7:12 Local variable 'a' was not marked 'mut'.
5 | Uncaught exception: Reached compile error
6 | at f
7 | at main
8 |
--------------------------------------------------------------------------------
/test/unit/crow-parser/operator-precedence.crow:
--------------------------------------------------------------------------------
1 | dummy-operator-precedence nat()
2 | 0
3 |
4 | test
5 | xs nat mut[] = ()
6 | a nat mut[]? = xs,
7 | a ?? () foo= 3
8 | xs.move-to::nat[] is (3,)
9 |
10 | foo= void(a nat mut[], b nat)
11 | a ~= b
12 |
13 | test
14 | (1::nat64) * 2 + 3 is 5
15 | 1::nat64 + 2 * 3 is 7
16 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/literal-does-not-match-expected-type.crow.out:
--------------------------------------------------------------------------------
1 | exit code: 1
2 | stderr:
3 | test/end-to-end/compile-errors/literal-does-not-match-expected-type.crow 2:16-2:17 The literal doesn't match the expected type at this location.
4 | Expected type 'string'.
5 | Uncaught exception: Reached compile error
6 | at main
7 |
--------------------------------------------------------------------------------
/demo/libraries/SDL2/SDL_rwops.crow:
--------------------------------------------------------------------------------
1 | import
2 | crow/c-types: c-int
3 |
4 | +SDL_RWops extern
5 |
6 | +SDL_RWFromFile SDL_RWops mut*(file c-string, mode c-string) SDL2 extern
7 | +SDL_RWFromMem SDL_RWops mut*(mem any-mut-pointer, size c-int) SDL2 extern
8 | +SDL_RWFromConstMem SDL_RWops mut*(mem any-const-pointer, size c-int) SDL2 extern
9 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/string-literal-invalid.crow.out:
--------------------------------------------------------------------------------
1 | exit code: 0
2 | stdout:
3 | info: a
4 | info: a
5 | stderr:
6 | test/end-to-end/compile-errors/string-literal-invalid.crow 2:14-2:20 'string' literal can't contain '\0'.
7 | test/end-to-end/compile-errors/string-literal-invalid.crow 3:16-3:22 'symbol' literal can't contain '\0'.
8 |
--------------------------------------------------------------------------------
/test/end-to-end/runnable/logging.crow:
--------------------------------------------------------------------------------
1 | main void() native extern
2 | info log "Logged once"
3 | lh = get-log-handler
4 | doubler log-handler = logged =>
5 | lh[logged]
6 | lh[logged]
7 | with : doubler temp-log-handler
8 | warn log "Logged twice"
9 | with : (_ => ()) temp-log-handler
10 | warn log "Logged never"
11 | ()
12 |
--------------------------------------------------------------------------------
/test/unit/matches.crow:
--------------------------------------------------------------------------------
1 | dummy-matches nat()
2 | 0
3 |
4 | # Test that switching on a signed int < 64 bits works
5 | test trusted, native extern
6 | # Read a pointer to get an int32 that is not sign extended
7 | a int32 = -7
8 | ap int32* = &a
9 | b = *ap
10 | match b
11 | as -7
12 | ()
13 | else
14 | throw unreachable
15 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/wrong-number-type-args.crow.out:
--------------------------------------------------------------------------------
1 | exit code: 0
2 | stderr:
3 | test/end-to-end/compile-errors/wrong-number-type-args.crow 8:7-8:12 There are functions named 'magic', but none takes 1 type arguments. candidates:
4 | 'magic[out, in] out?(a in?)' (from test/end-to-end/compile-errors/wrong-number-type-args.crow line 4)
5 |
--------------------------------------------------------------------------------
/include/system/stdlib.crow:
--------------------------------------------------------------------------------
1 | no-std
2 | import
3 | crow/c-types: size_t
4 | crow/pointer: any-mut-pointer
5 | crow/private/bootstrap: void
6 |
7 | +calloc any-mut-pointer(n-elems size_t, sizeof-elem size_t) libc extern, pure
8 | +malloc any-mut-pointer(size-bytes size_t) libc extern, pure
9 | +free void(p any-mut-pointer) libc extern, pure
10 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/trusted-unnecessary.crow:
--------------------------------------------------------------------------------
1 | main void()
2 | ()
3 |
4 | f nat*() unsafe, native extern
5 | trusted null
6 |
7 | f nat*() native extern
8 | trusted trusted null
9 |
10 | f nat() native extern
11 | # testing twice to verify that we reset 'usedTrusted' after each 'trusted'
12 | _ nat = trusted 0
13 | trusted 0
14 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/import-non-existing.crow.out:
--------------------------------------------------------------------------------
1 | exit code: 1
2 | stderr:
3 | test/end-to-end/compile-errors/does-not-exist.crow 1:1-1:1 This file does not exist.
4 | test/end-to-end/compile-errors/import-non-existing.crow 2:5-2:21 Imported file test/end-to-end/compile-errors/does-not-exist.crow does not exist.
5 | Stopping due to compile errors.
6 |
--------------------------------------------------------------------------------
/test/failure.crow:
--------------------------------------------------------------------------------
1 | failure record(path string, message string)
2 |
3 | show-failures string(failures failure[])
4 | s string = "\n" join for failure : failures
5 | "{bold}{failure.path}{reset} {failure.message}"
6 | "{s}\n{failures.size} failures"
7 |
8 | # TODO:MOVE
9 | -bold string()
10 | "\x1b[1m"
11 |
12 | -reset string()
13 | "\x1b[m"
14 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/loop-disallowed-body.crow.out:
--------------------------------------------------------------------------------
1 | exit code: 1
2 | stderr:
3 | test/end-to-end/compile-errors/loop-disallowed-body.crow 3:9-3:12 Loop body cannot be a 'finally' expression
4 | test/end-to-end/compile-errors/loop-disallowed-body.crow 9:9-9:16 Loop body cannot be a 'finally' expression
5 | Uncaught exception: Reached compile error
6 | at main
7 |
--------------------------------------------------------------------------------
/test/end-to-end/compile-errors/tuple-too-big.crow.out:
--------------------------------------------------------------------------------
1 | exit code: 1
2 | stderr:
3 | test/end-to-end/compile-errors/tuple-too-big.crow 2:5-2:44 Expected a tuple with 10 elements, but got '<