mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-05 22:48:43 +00:00
basic printers, type printers, some fixes, part of expression printers
This commit is contained in:
parent
3914ff7d8b
commit
3669084f55
14 changed files with 795 additions and 39 deletions
232
tests/formatting.langexp
Normal file
232
tests/formatting.langexp
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
// import
|
||||
|
||||
:: x = y : func1 func2 func3 func4 func5;
|
||||
|
||||
:: x = y :
|
||||
func1
|
||||
func2
|
||||
func3
|
||||
func4
|
||||
func5;
|
||||
|
||||
// type
|
||||
|
||||
: info
|
||||
@a annotation info
|
||||
Type = @a A;
|
||||
|
||||
Type 'A 'B 'C = @a1 'A | @b2 'B | @c2 'C;
|
||||
|
||||
Type 'A 'B 'C
|
||||
= @a1 'A | @b2 'B | @c2 'C;
|
||||
|
||||
Type
|
||||
'A
|
||||
'B
|
||||
'C
|
||||
= @a1 'A | @b2 'B | @c2 'C;
|
||||
|
||||
Type 'A 'B 'C =
|
||||
| & @a1 'A
|
||||
& @b1 'B
|
||||
& @c1 'C
|
||||
| @a2 'A & @b2 'B & @c2 'C;
|
||||
|
||||
Type
|
||||
'A
|
||||
'B
|
||||
'C
|
||||
=
|
||||
| & @a1 'A
|
||||
& @b1 'B
|
||||
& @c1 'C
|
||||
| @a2 'A & @b2 'B & @c2 'C;
|
||||
|
||||
Type {
|
||||
|
||||
func1;
|
||||
|
||||
func2;
|
||||
|
||||
func3;
|
||||
|
||||
}
|
||||
|
||||
// typeclass
|
||||
|
||||
: info
|
||||
#Typeclass;
|
||||
|
||||
#Typeclass : #A #B #C;
|
||||
|
||||
#Typeclass :
|
||||
#A
|
||||
#B
|
||||
#C;
|
||||
|
||||
// function
|
||||
|
||||
: info
|
||||
@a annotation info
|
||||
func 'a;
|
||||
|
||||
func 'a 'b 'c : A B C -> D;
|
||||
|
||||
func
|
||||
'a
|
||||
'b
|
||||
'c
|
||||
: A B C -> D;
|
||||
|
||||
func 'a 'b 'c
|
||||
: A B C -> D;
|
||||
|
||||
func
|
||||
'a
|
||||
'b
|
||||
'c
|
||||
: A B C -> D
|
||||
|
||||
func 'a 'b 'c
|
||||
:
|
||||
A
|
||||
B
|
||||
C
|
||||
-> D;
|
||||
|
||||
func
|
||||
'a
|
||||
'b
|
||||
'c
|
||||
:
|
||||
A
|
||||
B
|
||||
C
|
||||
-> D;
|
||||
|
||||
// flow control
|
||||
|
||||
func = {
|
||||
x := y => do_something
|
||||
:= z
|
||||
=> do_something;
|
||||
|
||||
@ => do_something;
|
||||
|
||||
@ a => do_something;
|
||||
|
||||
@ a
|
||||
=> do_something;
|
||||
|
||||
@ a : b => do_something;
|
||||
|
||||
@ a : b
|
||||
=> do_something;
|
||||
|
||||
}
|
||||
|
||||
// operators, containers, modifiers
|
||||
|
||||
func {
|
||||
|
||||
x + y;
|
||||
|
||||
x
|
||||
+ y;
|
||||
|
||||
{
|
||||
expr;
|
||||
expr;
|
||||
expr;
|
||||
};
|
||||
|
||||
[[ expr expr expr ]];
|
||||
|
||||
[[
|
||||
expr
|
||||
expr
|
||||
expr
|
||||
]];
|
||||
|
||||
return x;
|
||||
|
||||
return
|
||||
x;
|
||||
|
||||
%x;
|
||||
|
||||
a[b];
|
||||
|
||||
a[
|
||||
b];
|
||||
|
||||
a.11;
|
||||
|
||||
break;
|
||||
|
||||
<> x;
|
||||
|
||||
x?;
|
||||
|
||||
// other
|
||||
|
||||
func {
|
||||
|
||||
x
|
||||
.func a b c;
|
||||
|
||||
x
|
||||
.func
|
||||
a
|
||||
b
|
||||
c;
|
||||
|
||||
Type.func a b c;
|
||||
|
||||
Type.func
|
||||
a
|
||||
b
|
||||
c;
|
||||
|
||||
Type @a x @b y @c z;
|
||||
|
||||
Type
|
||||
@a x
|
||||
@b y
|
||||
@c z;
|
||||
|
||||
\ 'x 'y 'z => x;
|
||||
|
||||
\ 'x
|
||||
'y
|
||||
'z
|
||||
=> x;
|
||||
|
||||
\ 'x 'y 'z
|
||||
=> x;
|
||||
|
||||
\ 'x
|
||||
'y
|
||||
'z
|
||||
=>
|
||||
x;
|
||||
|
||||
(x);
|
||||
|
||||
(
|
||||
x
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue