-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.shen
60 lines (46 loc) · 1.42 KB
/
example.shen
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
\\ single line comment
"root-level string"
123
(define root-level-function
Var lit -> (+ (* X X) (/ Y Y) (- Z Z)))
\* block comment *\
(package example []
(define special-keywords ->
(do
(set *language* (value *custom*))
(trap-error
(do (simple-error "whoops!") (error "oh, no!"))
(lambda E (output "~S" (error-to-string E)))
(/. E (print (error-to-string E) (stoutput))))
skip))
\* multi
line
block
comment *\
(define typed-function {A --> (list A) --> boolean}
_ [] -> [true define 0123 false] (f true define +323)
X [X | _] -> true \\ end of line comment
X [{ | Xs] -> [0a X Xs ()])
(datatype maybe
H : boolean; X : A;
____________________
[H | X] : (maybe A);)
(defmacro syntax-magic
[@p] -> [} ++--+-+012323.2434])
"package-level string"
(defcc <rule>
<patterns> -> <action> where <guard> := [<patterns> [where <guard> <action>]];
<patterns> <- <action> where <guard> := [<patterns> [where <guard> [choicepoint! <action>]]];)
(define strings ->
(cases
(= X (and Y Z))
(output "~%Shen, copyright c#123; c#dfc; 2010-2015 c#; Mark Tarver~%")
(not (< Qwe Asd))
(output "www.shenlanguage.org, ~A~%" (value *version*))
true
(output "~%port ~A ported by ~A~%"
(value *port*)
(value *porters*))))
(defprolog mem
X [X | _] <--;
X [Y | Z] <-- (mem X Z);))