-
Notifications
You must be signed in to change notification settings - Fork 3
/
microalg_export_casio.l
160 lines (152 loc) · 5.42 KB
/
microalg_export_casio.l
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
(de Litteral (content)
(cond
((num? content) content)
((str? content) (pack "\"" content "\""))
(T "Littéral de type inconnu.")
))
(de Variable inputs
(let (nom_var (car inputs))
(if nom_var nom_var "")
)
)
(de indent (!instr)
(indent_std !instr)
)
(de + @ (pack "(" (glue "+" (rest)) ")"))
(de - (A B) (pack "(" A "-" B ")"))
(de * @ (pack "(" (glue "×" (rest)) ")"))
(de / (A B) (pack "(" A "÷" B ")"))
(de % (A B) (pack "Mod(" A "," B ")"))
(de ^ (A B) (pack "(" A "\^" B ")"))
(de Carre (A) (pack "(" A ")²"))
(setq Carré Carre)
(de Racine (A) (pack "√(" A ")"))
(setq Somme +)
(setq Diff -)
(setq Produit *)
(setq Quotient /)
(setq Reste %)
(setq Puissance ^)
(de !!! (comz) (pack "' " (cdr (reverse (cdr (reverse (chop comz))))) "^J"))
(de Afficher (obj) (pack obj "◢^J"))
(de !store (!arg_lst)
(let (var (eval (car !arg_lst))
val (cadr !arg_lst))
(cond
((== 'Demander (car val)) (pack "?→Str " var "^J"))
((== 'Demander_un_nombre (car val)) (pack "?→" var "^J"))
((and (== 'Nombre (car val))
(== 'Demander (car (cadr val)))) (pack "?→" var "^J"))
(T (pack (eval val) "→" var "^J"))
)
))
(de Declarer !arg_lst
(let (!splitted (split !arg_lst 'De_type)
!vars (mapcar 'cadr (car !splitted)) # var name is in (Variable ...)
!type (caadr !splitted))
(pack "' " (glue " " !vars) " de type " (cadr !type) "^J") # type is in (Litteral ...)
)
)
(setq Déclarer 'Declarer)
(de Affecter_a !arg_lst (!store !arg_lst))
(setq Affecter_à 'Affecter_a)
(de Demander () (pack "-- La commande `Demander` doit être utilisée avec "
"`Affecter_a`. --"))
(de Demander_un_nombre () (pack "-- La commande `Demander_un_nombre` doit être utilisée avec "
"`Affecter_a`. --"))
(de Demander_un_nombre_pour !arg_lst
(let (!var (cadr (car !arg_lst))) # var name is in (Variable ...)
(pack "?→" !var "^J")
)
)
(de Entier@ (A B) (pack "RanInt#(" A "," B ")"))
(setq Vrai "1")
(setq Faux "0")
(setq Rien "Rien")
(de Si arg_lst (let (condition (car arg_lst)
kw_alors (cadr arg_lst)
splitted (split (cddr arg_lst) 'Sinon)
bloc_vrai (car splitted)
bloc_faux (cadr splitted))
(pack
"If " (eval condition) "^J" "Then^J"
(mapcar 'eval bloc_vrai)
(if bloc_faux (pack "Else^J" (mapcar 'eval bloc_faux)))
"IfEnd^J"
)
)
)
(de Non (bool) (pack "(Not " bool ")"))
(de Et !arg_lst (pack "(" (glue " And " (mapcar 'eval !arg_lst)) ")"))
(de Ou !arg_lst (pack "(" (glue " Or " (mapcar 'eval !arg_lst)) ")"))
(de Tant_que arg_lst (let (!cond (car arg_lst)
!mot-clef (cadr arg_lst)
!corps (cddr arg_lst))
(pack
"While " (eval !cond) "^J"
(mapcar 'eval !corps)
"WhileEnd^J"
)
)
)
(de Faire arg_lst (let (!splitted (split arg_lst 'Tant_que)
!corps (car !splitted)
!cond (caadr !splitted))
(pack
"Do^J"
(mapcar 'eval !corps)
"LpWhile " (eval !cond) "^J"
)
)
)
(de = (A B) (pack "(" A "=" B ")"))
(de < (A B) (pack "(" A "<" B ")"))
(de <= (A B) (pack "(" A "<=" B ")"))
(de > (A B) (pack "(" A ">" B ")"))
(de >= (A B) (pack "(" A ">=" B ")"))
(de =/ (A B) (pack "(" A "≠" B ")"))
(de ... () " (...) ")
(de !no_export (cmd)
(pack "-- La commande " cmd " ne peut être exportée. --^J"))
(de Concatener () (!no_export "Concatener")) # StrJoin(
(de Concaténer () (!no_export "Concaténer"))
(de Liste () (!no_export "Liste"))
(de Longueur () (!no_export "Longueur"))
(de Nieme () (!no_export "Nieme"))
(de Tete () (!no_export "Tete"))
(de Queue () (!no_export "Queue"))
(de Ajouter_a () (!no_export "Ajouter_a"))
(de Retirer_de () (!no_export "Retirer_de"))
# En_position
(de Initialiser@ () (!no_export "Initialiser@"))
(de Nieme@ () (!no_export "Nieme@"))
(de Type () (!no_export "Type"))
(de Texte () (!no_export "Texte"))
(de Nombre () (!no_export "Nombre"))
# Alors Sinon
(de Repeter () (!no_export "Repeter"))
(de Répéter () (!no_export "Répéter"))
(de Definir () (!no_export "Definir"))
(de Définir () (!no_export "Définir"))
(de Retourner () (!no_export "Retourner"))
(de Exemples_de () (!no_export "Exemples_de"))
(de Tester () (!no_export "Tester"))
(de ? () (!no_export "?"))
(de Millisecondes () (!no_export "Millisecondes"))
(de AV () (!no_export "AV"))
(de BC () (!no_export "BC"))
(de LC () (!no_export "LC"))
(de TD () (!no_export "TD"))
(de TG () (!no_export "TG"))
(de Cercle () (!no_export "Cercle"))
(de Contour () (!no_export "Contour"))
(de Ellipse () (!no_export "Ellipse"))
(de Epaisseur () (!no_export "Epaisseur"))
(de RAZ () (!no_export "RAZ"))
(de Rectangle () (!no_export "Rectangle"))
(de Remplissage () (!no_export "Remplissage"))
(de Repere () (!no_export "Repere"))
(de Segment () (!no_export "Segment"))
(de Triangle () (!no_export "Triangle"))
(de 1000Cosinus () (!no_export "1000Cosinus"))
(de 1000Sinus () (!no_export "1000Sinus"))