summaryrefslogtreecommitdiff
path: root/web/maple/mapleweb/maple.spider
blob: c5406aabd086dbc5a26d4d38286312a1fc049b76 (plain)
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
language MAPLE extension mpl 

module definition stmt use stmt
token newline category ignore_scrap translation <>

comment begin <"#"> end newline

default translation <*> mathness no

line begin <"#line"> end <>

token pseudo_semi category terminator translation <"\\rx">

token identifier	category ident
token number	category numbr
token {		category slopen translation <"\\{">
token }		category slclose translation <"\\}">
token [		category slopen tangleto <space-"\[">
token ]		category slclose tangleto <"\]"-space>
token (		category open
token )		category close

#what to do with ' and ` and "??
#token `		category backquote

token '		category math tangleto <space-"'">
token .		category point
token ;		category terminator translation <";"-break_space>
token :		category terminator translation <":"-break_space>
token ,		category comma translation <","-opt-1>
token \		category backslash translation <"\\backslash">
#tijdelijk: van vorige regel: tangleto <"\\">
token :=	category assignment translation <":=">
token $		category binop translation <"\\,\\$\\,">
#token ..	category binop translation <"..">
token *		category binop
token ^		category binop
token /		category binop
token <>	category binop translation <"\\NEQ">  tangleto <"<>">
token <=	category binop translation <"\\leq">
token >=	category binop translation <"\\geq">
token =		category binop
token <		category binop
token >		category binop
token !		category unop
token +		category unorbinop
token -		category unorbinop

#ilk definitions
ilk forstart_like category forstart
ilk forbodystart_like category forbodystart
ilk forbodyend_like category forbodyend
ilk ifbegin_like category ifbegin
ilk ifthen_like category ifthen
ilk elif_like category elif
ilk ifbody_like category ifbody
ilk ifend_like category ifend
ilk procedure_like category procedure
ilk procextra_like category procextra
ilk procend_like category procend
ilk return_like category return
ilk ident_like category ident

default translation <"\\"-space-*-"\\"-space>

ilk binop_like category binop 

reserved proc ilk procedure_like
reserved end ilk procend_like
reserved local ilk procextra_like
reserved option ilk procextra_like
reserved minus ilk binop_like

reserved for  ilk forstart_like
reserved while  ilk forstart_like
reserved to ilk forstart_like
reserved in ilk forstart_like
reserved from  ilk forstart_like
reserved do  ilk forbodystart_like
reserved od  ilk forbodyend_like
reserved if  ilk ifbegin_like
reserved then ilk ifthen_like
reserved elif ilk elif_like
reserved else ilk ifbody_like
reserved fi ilk ifend_like
reserved RETURN ilk return_like
reserved break ilk ident_like
reserved next ilk ident_like
#token category 

#production rules
#? ignore_scrap --> #1

#handling statements;
<"$"> math <"$"> terminator --> stmt
stmt <space>  stmt --> stmt
stmt terminator --> stmt
ignore_scrap --> terminator
terminator --> stmt

#handling comments
#comment newline --> newline
#comment ? --> comment

#handling idents and math etc.
<force> return --> math
ident --> math
numbr --> math
(unop|unorbinop|binop) math --> math
math (unop|unorbinop|binop) --> math
math math --> math
math comma --> math
math [ point point ] --> math binop
math point --> math
math assignment --> math
<"$"> math <"$"> <space> terminator --> stmt


#handlig forloops
forstart <space>  <"$"> math <"$"> <space> --> forstart
forstart forstart  --> forstart
forstart <space> forbodystart <force-indent>  --> forbodystart
forbodystart stmt --> forbodystart
<force> forbodystart <outdent-force> forbodyend terminator <force> --> stmt
<force> forbodystart <outdent-force> forbodyend  <force> --> stmt
<force> forbodystart <space> <"$"> math <"$"> <outdent-force> forbodyend terminator <force> --> stmt
<force> forbodystart <space> <"$"> math <"$"> <outdent> <force> forbodyend  <force> --> stmt


#handling ifstatements
<force> ifbegin <space> <"$"> math <"$"> <space>  ifthen <force-indent> --> ifbegin
ifbegin stmt --> ifbegin
ifbegin <outdent-force> ifend terminator <force> --> stmt
ifbegin <outdent-force> ifend <force> --> stmt
ifbegin <"$"> math <"$"> <outdent-force> ifend terminator  <force> --> stmt
ifbegin <"$"> math <"$"> <outdent-force> ifend  <force> --> stmt

ifbegin <outdent-force> ifbody <space> <indent> --> ifbegin
ifbegin <space> <"$"> math <"$"> <outdent-force> ifbody <space> <indent> --> ifbegin

elif  <space> <"$"> math <"$"> <space>  ifthen <force-indent> --> elif
elif stmt --> elif
elif <space> <"$"> math <"$">  <outdent-force> elif --> elif
elif <outdent-force> elif --> elif
elif <outdent-force> ifbody <space> <indent> --> elif
elif   <"$"> math <"$"> <outdent-force> ifbody <space> <indent>  --> elif
elif  <"$">  math <"$"> <outdent-force> ifend  terminator <force>  --> elifend
elif   <"$"> math <"$"> <outdent-force> ifend <force>  --> elifend
elif <outdent-force> ifend terminator <force> --> elifend
elif <outdent-force> ifend <force> --> elifend

ifbegin <outdent-force> elifend --> stmt
ifbegin <"$"> math <"$"> <outdent-force> elifend --> stmt

#handling procedures

<"$"> math  <"$"> <force> <indent> procedure <"$"> math  <"$"> <force> --> procedure
procedure  <force> procextra <space> stmt <force> --> procedure
procedure <indent> stmt --> procbody
procbody stmt --> procbody

procbody <outdent> <force> procend terminator <big_force-outdent> --> stmt
procbody <"$"> math  <"$"> <outdent> <force> procend terminator <big_force-outdent> --> stmt

procbody <outdent> <force> procend <big_force-outdent> --> stmt
procbody <"$"> math  <"$"> <outdent> <force> procend <big_force-outdent> --> stmt
procedure <space> <indent> <"$"> math  <"$"> <force> <outdent>  procend terminator <big_force-outdent>  --> stmt
procedure <space> <indent> <"$"> math  <"$"> <force> <outdent> procend <big_force-outdent> --> stmt

#handling sets and lists 
open <"\\,"> close --> math
open <"\\,"> math <"\\,"> close --> math
slopen <"\\,"> slclose --> math
slopen  <"\\,"> math  <"\\,"> slclose  --> math

#handling backslash
math backslash math    -->  math
backslash newline --> newline
backslash backslash --> math
backslash --> math

#handling backquote
#changefile makes '`' reading as string!


macros begin
\def\commentbegin{\#}
\def\commentend{}
\def\NEQ{\ne}
\def\LL{\ll\,}
\def\RR{\,\gg}
\def\PS{\joinrel{+\equiv}}
\let\rx\relax

macros end