Mercurial > urweb
comparison src/urweb.grm @ 1045:36efaf119b85
Refactor compile functions; allow empty tag contents
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Wed, 25 Nov 2009 08:52:32 -0500 |
parents | 1d456a06ea4e |
children | e933297c4e24 |
comparison
equal
deleted
inserted
replaced
1044:0d916892e39e | 1045:36efaf119b85 |
---|---|
287 | eterm of exp | 287 | eterm of exp |
288 | etuple of exp list | 288 | etuple of exp list |
289 | rexp of (con * exp) list | 289 | rexp of (con * exp) list |
290 | xml of exp | 290 | xml of exp |
291 | xmlOne of exp | 291 | xmlOne of exp |
292 | xmlOpt of exp | |
292 | tag of (string * exp) * exp | 293 | tag of (string * exp) * exp |
293 | tagHead of string * exp | 294 | tagHead of string * exp |
294 | bind of string * con option * exp | 295 | bind of string * con option * exp |
295 | edecl of edecl | 296 | edecl of edecl |
296 | edecls of edecl list | 297 | edecls of edecl list |
1292 xmlOne), pos), | 1293 xmlOne), pos), |
1293 xml), pos) | 1294 xml), pos) |
1294 end) | 1295 end) |
1295 | xmlOne (xmlOne) | 1296 | xmlOne (xmlOne) |
1296 | 1297 |
1298 xmlOpt : xml (xml) | |
1299 | (EApp ((EVar (["Basis"], "cdata", Infer), dummy), | |
1300 (EPrim (Prim.String ""), dummy)), | |
1301 dummy) | |
1302 | |
1297 xmlOne : NOTAGS (EApp ((EVar (["Basis"], "cdata", Infer), s (NOTAGSleft, NOTAGSright)), | 1303 xmlOne : NOTAGS (EApp ((EVar (["Basis"], "cdata", Infer), s (NOTAGSleft, NOTAGSright)), |
1298 (EPrim (Prim.String NOTAGS), s (NOTAGSleft, NOTAGSright))), | 1304 (EPrim (Prim.String NOTAGS), s (NOTAGSleft, NOTAGSright))), |
1299 s (NOTAGSleft, NOTAGSright)) | 1305 s (NOTAGSleft, NOTAGSright)) |
1300 | tag DIVIDE GT (let | 1306 | tag DIVIDE GT (let |
1301 val pos = s (tagleft, GTright) | 1307 val pos = s (tagleft, GTright) |
1316 pos) | 1322 pos) |
1317 in | 1323 in |
1318 (EApp (#2 tag, cdata), pos) | 1324 (EApp (#2 tag, cdata), pos) |
1319 end) | 1325 end) |
1320 | 1326 |
1321 | tag GT xml END_TAG (let | 1327 | tag GT xmlOpt END_TAG (let |
1322 val pos = s (tagleft, GTright) | 1328 val pos = s (tagleft, GTright) |
1323 val et = tagIn END_TAG | 1329 val et = tagIn END_TAG |
1324 in | 1330 in |
1325 if #1 (#1 tag) = et then | 1331 if #1 (#1 tag) = et then |
1326 if et = "form" then | 1332 if et = "form" then |
1327 (EApp ((EVar (["Basis"], "form", Infer), pos), | 1333 (EApp ((EVar (["Basis"], "form", Infer), pos), |
1328 xml), pos) | 1334 xmlOpt), pos) |
1329 else if et = "subform" then | 1335 else if et = "subform" then |
1330 (EApp ((EDisjointApp (#2 (#1 tag)), pos), | 1336 (EApp ((EDisjointApp (#2 (#1 tag)), pos), |
1331 xml), pos) | 1337 xmlOpt), pos) |
1332 else if et = "subforms" then | 1338 else if et = "subforms" then |
1333 (EApp ((EDisjointApp (#2 (#1 tag)), pos), | 1339 (EApp ((EDisjointApp (#2 (#1 tag)), pos), |
1334 xml), pos) | 1340 xmlOpt), pos) |
1335 else if et = "entry" then | 1341 else if et = "entry" then |
1336 (EApp ((EVar (["Basis"], "entry", Infer), pos), | 1342 (EApp ((EVar (["Basis"], "entry", Infer), pos), |
1337 xml), pos) | 1343 xmlOpt), pos) |
1338 else | 1344 else |
1339 (EApp (#2 tag, xml), pos) | 1345 (EApp (#2 tag, xmlOpt), pos) |
1340 else | 1346 else |
1341 (if ErrorMsg.anyErrors () then | 1347 (if ErrorMsg.anyErrors () then |
1342 () | 1348 () |
1343 else | 1349 else |
1344 ErrorMsg.errorAt pos "Begin and end tags don't match."; | 1350 ErrorMsg.errorAt pos "Begin and end tags don't match."; |