Commit f0efa7e5574a4a33ee7fe8fbf9a05811e03ebc99
1 parent
466de685
Ce git me pete les couilles comme c'est pas possible. Ras le bol de cette merde et vive svn.
Showing
16 changed files
with
659 additions
and
368 deletions
Show diff stats
anubis_dev/library/doc_tools/maml3.anubis
| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | Copyright (c) Alain Prouté 2015. |
| 11 | 11 | |
| 12 | +define One xxx = todo("Handle the restricted use of marks for the web."). | |
| 12 | 13 | |
| 13 | 14 | This file obsoletes the following files in the same directory: |
| 14 | 15 | latex.anubis |
| ... | ... | @@ -88,7 +89,7 @@ public type MAML_Pos: // position in a MAML text |
| 88 | 89 | Int offset). |
| 89 | 90 | |
| 90 | 91 | public type MAML_Error: |
| 91 | - empty_mark_name (MAML_Pos pos), | |
| 92 | + //empty_mark_name (MAML_Pos pos), | |
| 92 | 93 | unknown_mark (MAML_Pos pos, String name), // name of mark not recognized |
| 93 | 94 | too_few_arguments (MAML_Pos pos, String mark_name, |
| 94 | 95 | Int found, |
| ... | ... | @@ -126,7 +127,8 @@ public type MAML_Parse_Option: |
| 126 | 127 | option is to inhibit all maml marks which could be dangerous for the server. These marks are |
| 127 | 128 | not documented in 'maml3_tutorial.maml'. They are the following: |
| 128 | 129 | |
| 129 | - $input(<file_path>) allows to 'input' the content of a file (similar to LaTeX '\input', or Anubis 'read'). | |
| 130 | + $input(<file_path>) allows to input the content of a file (similar to LaTeX '\input', or Anubis 'read'). | |
| 131 | + $output(<file path>)(text) allows to output text to a file. | |
| 130 | 132 | |
| 131 | 133 | |
| 132 | 134 | *** (4) Generating an HTML output. |
| ... | ... | @@ -407,6 +409,7 @@ define MAML_Pos |
| 407 | 409 | *** [1.4] The type 'MAML' of MAML texts. |
| 408 | 410 | |
| 409 | 411 | type MAML: |
| 412 | + end, | |
| 410 | 413 | var (Int), // MAML variable $1, $2, ... |
| 411 | 414 | text (Text), // ordinary text |
| 412 | 415 | mark (String name, List(MAML) args), // mark |
| ... | ... | @@ -421,6 +424,7 @@ define String |
| 421 | 424 | ) = |
| 422 | 425 | if m is |
| 423 | 426 | { |
| 427 | + end then "", | |
| 424 | 428 | var(v) then "$"+abs_to_decimal(v), |
| 425 | 429 | text(txt) then to_string(txt), |
| 426 | 430 | mark(name,args) then if args is [] then "$"+name+" " else |
| ... | ... | @@ -706,6 +710,7 @@ public define List(MAMLMark) |
| 706 | 710 | mark("ifpdf", 1), |
| 707 | 711 | mark("define", 3), // defining a MAML macro: $define(name)(2)(body ... $1 ... $2 ...) |
| 708 | 712 | mark("dollar", 0), // the caracter $ itself |
| 713 | + mark("", 0), // same as "dollar" | |
| 709 | 714 | mark("lpar", 0), // left parenthesis |
| 710 | 715 | mark("rpar", 0), // right parenthesis |
| 711 | 716 | mark("par", 0), // new paragraph |
| ... | ... | @@ -863,7 +868,7 @@ define ReadMarkNameResult |
| 863 | 868 | Stream s |
| 864 | 869 | ) = |
| 865 | 870 | with name = read_mark_name_aux(s,[]), |
| 866 | - if name = "" then error(empty_mark_name(get_pos(s))) else | |
| 871 | + if name = "" then mark("") else | |
| 867 | 872 | if decimal_scan(name) is |
| 868 | 873 | { |
| 869 | 874 | failure then mark(name), |
| ... | ... | @@ -958,6 +963,7 @@ define Result(MAML_Error,(MAML,List(MAMLMark))) |
| 958 | 963 | { |
| 959 | 964 | error(msg) then error(msg), |
| 960 | 965 | mark(name) then |
| 966 | + if name = "end" then ok((end,maml_marks)) else | |
| 961 | 967 | if name = "verbatim" then if read_verbatim_argument(s,"verbatim") is |
| 962 | 968 | { |
| 963 | 969 | error(msg) then error(msg), |
| ... | ... | @@ -1035,6 +1041,7 @@ define Maybe(String) |
| 1035 | 1041 | ) = |
| 1036 | 1042 | if m is |
| 1037 | 1043 | { |
| 1044 | + end then failure, | |
| 1038 | 1045 | var(_) then failure, |
| 1039 | 1046 | text(txt) then success(to_string(txt)), |
| 1040 | 1047 | mark(_,_) then failure, |
| ... | ... | @@ -1072,7 +1079,7 @@ define Maybe(String) |
| 1072 | 1079 | { |
| 1073 | 1080 | failure then failure, |
| 1074 | 1081 | success(s) then |
| 1075 | - if mapand((Word8 c) |-> member(c,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyz0123456789"),explode(s)) | |
| 1082 | + if mapand((Word8 c) |-> member(c,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_~"),explode(s)) | |
| 1076 | 1083 | then success(s) |
| 1077 | 1084 | else failure |
| 1078 | 1085 | }. |
| ... | ... | @@ -1117,7 +1124,7 @@ define Result(MAML_Error,List(MAMLMark)) |
| 1117 | 1124 | define Result(MAML_Error,(MAML,List(MAMLMark))) |
| 1118 | 1125 | parse_MAML |
| 1119 | 1126 | ( |
| 1120 | - List(MAML_Parse_Option) parse_options, | |
| 1127 | + List(MAML_Parse_Option) parse_options, | |
| 1121 | 1128 | Stream s, |
| 1122 | 1129 | List(MAMLMark) maml_marks, |
| 1123 | 1130 | Maybe(Int) mb_level |
| ... | ... | @@ -1132,6 +1139,7 @@ define Result(MAML_Error,(MAML,List(MAMLMark))) |
| 1132 | 1139 | { |
| 1133 | 1140 | error(msg) then error(msg), |
| 1134 | 1141 | ok(p) then since p is (m,new_marks), |
| 1142 | + if m is end then ok((text(prefix),maml_marks)) else | |
| 1135 | 1143 | if update_mark_list(s,m,new_marks) is // add a new mark if m is $define()()() |
| 1136 | 1144 | { |
| 1137 | 1145 | error(msg) then error(msg), |
| ... | ... | @@ -1189,12 +1197,15 @@ define String |
| 1189 | 1197 | ) = |
| 1190 | 1198 | if m is |
| 1191 | 1199 | { |
| 1200 | + end then "", | |
| 1192 | 1201 | var(i) then "$"+i, |
| 1193 | 1202 | text(s) then to_string(s), |
| 1194 | 1203 | mark(name,args) then "$"+name+concat(map((MAML m1) |-> "("+must_be_text(m1)+")",args),""), |
| 1195 | 1204 | m1 + m2 then must_be_text(m1)+must_be_text(m2) |
| 1196 | 1205 | }. |
| 1197 | 1206 | |
| 1207 | + | |
| 1208 | + | |
| 1198 | 1209 | *** [3.2] define. |
| 1199 | 1210 | |
| 1200 | 1211 | Extending the context with a new definition: |
| ... | ... | @@ -1251,6 +1262,7 @@ define MAML |
| 1251 | 1262 | ) = |
| 1252 | 1263 | if body is |
| 1253 | 1264 | { |
| 1265 | + end then end, | |
| 1254 | 1266 | var(i) then |
| 1255 | 1267 | if nth(i-1,values) is |
| 1256 | 1268 | { |
| ... | ... | @@ -1347,7 +1359,7 @@ define String |
| 1347 | 1359 | ". |
| 1348 | 1360 | |
| 1349 | 1361 | \\usepackage{tikz} |
| 1350 | - s\usetikzlibrary{shapes,arrows} | |
| 1362 | + \usetikzlibrary{shapes,arrows} | |
| 1351 | 1363 | |
| 1352 | 1364 | |
| 1353 | 1365 | |
| ... | ... | @@ -1662,6 +1674,8 @@ define List(Output) |
| 1662 | 1674 | ok(text,_,outs) then do_output(filename,text,outs,outs) |
| 1663 | 1675 | }. |
| 1664 | 1676 | |
| 1677 | + | |
| 1678 | + | |
| 1665 | 1679 | define To_HTML_Result |
| 1666 | 1680 | to_HTML |
| 1667 | 1681 | ( |
| ... | ... | @@ -1676,6 +1690,7 @@ define To_HTML_Result |
| 1676 | 1690 | since opts is options(spath,cpath,tpath,fsize,fnsize,twidth), |
| 1677 | 1691 | if m is |
| 1678 | 1692 | { |
| 1693 | + end then ok(t,ctxt,outs), | |
| 1679 | 1694 | var(i) then should_not_happen(ok(t,ctxt,outs)), |
| 1680 | 1695 | |
| 1681 | 1696 | text(txt) then ok(handle_special_chars(txt,html_schar),ctxt,outs), |
| ... | ... | @@ -1689,6 +1704,7 @@ define To_HTML_Result |
| 1689 | 1704 | if name = "rq" then ok(t-"»",ctxt,outs) else |
| 1690 | 1705 | if name = "~" then ok(t-"~",ctxt,outs) else |
| 1691 | 1706 | if name = "dollar" then ok(t-"$",ctxt,outs) else |
| 1707 | + if name = "" then ok(t-"$",ctxt,outs) else | |
| 1692 | 1708 | if name = "lpar" then ok(t-"(",ctxt,outs) else |
| 1693 | 1709 | if name = "rpar" then ok(t-")",ctxt,outs) else |
| 1694 | 1710 | if name = "par" then ok(t-"<br>",ctxt,outs) else |
| ... | ... | @@ -1774,7 +1790,7 @@ define To_HTML_Result |
| 1774 | 1790 | { |
| 1775 | 1791 | [ ] then |
| 1776 | 1792 | // two operands |
| 1777 | - if name = "output" then with outs1 = do_output(must_be_text(a1),to_HTML(a2,ctxt,opts,stack,tocfile,outs,lab),outs), | |
| 1793 | + if name = "output" then with outs1 = do_output(must_be_text(a1),t - must_be_text(a2),outs,outs), | |
| 1778 | 1794 | ok(t,ctxt,outs1) else |
| 1779 | 1795 | if name = "code" then ok(t-"<pre style=\"color: inherit; font-size: inherit; background-color: rgb(" |
| 1780 | 1796 | -must_be_text(a1)-"); width: "-to_decimal(text_width(opts))-"px;\">"- |
| ... | ... | @@ -1939,6 +1955,7 @@ define List(Word8) |
| 1939 | 1955 | then explode("\\texttt{\\symbol{94}}") + latex_prepare(t,ic,il) |
| 1940 | 1956 | else ['\\', '^', '{', '}' . latex_prepare(t,ic,il)] else |
| 1941 | 1957 | if c = '&' then ['\\', '&' . latex_prepare(t,ic,il)] else |
| 1958 | + if c = '%' then ['\\', '%' . latex_prepare(t,ic,il)] else | |
| 1942 | 1959 | if c = '#' then ['\\', '#' . latex_prepare(t,ic,il)] else |
| 1943 | 1960 | if c = '\\' then if ic |
| 1944 | 1961 | then explode("{\\texttt{\\symbol{92}}}") + latex_prepare(t,ic,il) |
| ... | ... | @@ -1980,6 +1997,7 @@ define MAML |
| 1980 | 1997 | ) = |
| 1981 | 1998 | if m is |
| 1982 | 1999 | { |
| 2000 | + end then end, | |
| 1983 | 2001 | var(i) then m, |
| 1984 | 2002 | text(txt) then text(latex_prepare(txt,ic,il)), |
| 1985 | 2003 | mark(name,args) then if (name = "tt" | name = "code") |
| ... | ... | @@ -2074,6 +2092,7 @@ define (Text,List(MAML_Macro)) |
| 2074 | 2092 | ) = |
| 2075 | 2093 | if m is |
| 2076 | 2094 | { |
| 2095 | + end then (t,ctxt), | |
| 2077 | 2096 | var(i) then (t,ctxt), |
| 2078 | 2097 | |
| 2079 | 2098 | text(txt) then (txt,ctxt), |
| ... | ... | @@ -2086,6 +2105,7 @@ define (Text,List(MAML_Macro)) |
| 2086 | 2105 | if name = "rq" then (t-"\\fg{}",ctxt) else |
| 2087 | 2106 | if name = "~" then (t-"\\textasciitilde{}",ctxt) else |
| 2088 | 2107 | if name = "dollar" then (t-"\\$",ctxt) else |
| 2108 | + if name = "" then (t-"\\$",ctxt) else | |
| 2089 | 2109 | if name = "lpar" then (t-"(",ctxt) else |
| 2090 | 2110 | if name = "rpar" then (t-")",ctxt) else |
| 2091 | 2111 | if name = "par" then (t-"\\rule{1mm}{0mm}\n\n",ctxt) else |
| ... | ... | @@ -2285,8 +2305,8 @@ public define String |
| 2285 | 2305 | ) = |
| 2286 | 2306 | if e is |
| 2287 | 2307 | { |
| 2288 | - empty_mark_name(pos) then | |
| 2289 | - "Empty mark name at "+format_without_offset(pos)+".", | |
| 2308 | + //empty_mark_name(pos) then | |
| 2309 | + // "Empty mark name at "+format_without_offset(pos)+".", | |
| 2290 | 2310 | |
| 2291 | 2311 | unknown_mark(pos,name) then |
| 2292 | 2312 | "Unknown mark '$"+name+"' at "+format_without_offset(pos)+".", |
| ... | ... | @@ -2391,14 +2411,35 @@ define Maybe(WStream) |
| 2391 | 2411 | success(f) then success(weaken(f)) |
| 2392 | 2412 | }. |
| 2393 | 2413 | |
| 2414 | + | |
| 2415 | +type Option: | |
| 2416 | + pdf. // generate a PDF file | |
| 2417 | + | |
| 2418 | + | |
| 2419 | +define List(Option) | |
| 2420 | + get_options | |
| 2421 | + ( | |
| 2422 | + List(String) args | |
| 2423 | + ) = | |
| 2424 | + if args is | |
| 2425 | + { | |
| 2426 | + [ ] then [ ], | |
| 2427 | + [h . t] then | |
| 2428 | + if h = "-pdf" then [pdf . get_options(t)] else | |
| 2429 | + get_options(t) | |
| 2430 | + }. | |
| 2431 | + | |
| 2394 | 2432 | global define One |
| 2395 | 2433 | maml |
| 2396 | 2434 | ( |
| 2397 | 2435 | List(String) args |
| 2398 | 2436 | ) = |
| 2437 | + with options = get_options(args), | |
| 2399 | 2438 | if args is |
| 2400 | 2439 | { |
| 2401 | - [ ] then print("Usage: anbexec maml <filename>\n"), | |
| 2440 | + [ ] then print("Usage: anbexec maml <filename> <option> ... <option>\n"+ | |
| 2441 | + " Options:\n"+ | |
| 2442 | + " -pdf generate a PDF (and LaTeX) output\n"), | |
| 2402 | 2443 | [h . _] then if file(h,read) is |
| 2403 | 2444 | { |
| 2404 | 2445 | failure then print("File '"+h+"' not found.\n"), |
| ... | ... | @@ -2438,22 +2479,24 @@ global define One |
| 2438 | 2479 | -html_text-"</div></td></tr></table></center></body></html>")) |
| 2439 | 2480 | }; |
| 2440 | 2481 | // output the LaTeX |
| 2441 | - if to_LaTeX(m,predefined,0,false) is (latex_text,_) then | |
| 2442 | - if file(h+".tex",new) is | |
| 2443 | - { | |
| 2444 | - failure then print("Cannot create file '"+h+".tex'.\n"), | |
| 2445 | - success(f) then forget(print(weaken(f), | |
| 2446 | - t-latex_pdf_preambule("")-latex_text-latex_pdf_postambule)); | |
| 2447 | - forget(flush(f)); | |
| 2448 | - if (Maybe(Word8))execute(success("."),"pdflatex", | |
| 2449 | - ["-no-shell-escape", // avoid security problems | |
| 2450 | - "-interaction", "nonstopmode", // avoid stopping | |
| 2451 | - h+".tex"]) is | |
| 2452 | - { | |
| 2453 | - failure then print("Cannot execute pdflatex.\n"), | |
| 2454 | - success(_) then unique | |
| 2455 | - } | |
| 2456 | - } | |
| 2482 | + if pdf:options | |
| 2483 | + then (if to_LaTeX(m,predefined,0,false) is (latex_text,_) then | |
| 2484 | + if file(h+".tex",new) is | |
| 2485 | + { | |
| 2486 | + failure then print("Cannot create file '"+h+".tex'.\n"), | |
| 2487 | + success(f) then forget(print(weaken(f), | |
| 2488 | + t-latex_pdf_preambule("")-latex_text-latex_pdf_postambule)); | |
| 2489 | + forget(flush(f)); | |
| 2490 | + if (Maybe(Word8))execute(success("."),"pdflatex", | |
| 2491 | + ["-no-shell-escape", // avoid security problems | |
| 2492 | + "-interaction", "nonstopmode", // avoid stopping | |
| 2493 | + h+".tex"]) is | |
| 2494 | + { | |
| 2495 | + failure then print("Cannot execute pdflatex.\n"), | |
| 2496 | + success(_) then unique | |
| 2497 | + } | |
| 2498 | + }) | |
| 2499 | + else unique | |
| 2457 | 2500 | } |
| 2458 | 2501 | } |
| 2459 | 2502 | } | ... | ... |
anubis_dev/library/doc_tools/maml3_tutorial.maml
| ... | ... | @@ -5,11 +5,11 @@ $comment( The MAML3 tutorial (written in MAML3) |
| 5 | 5 | $define(title)(1)($par$par$center($big($big($bold($1))))$par$par) |
| 6 | 6 | $define(MAML)(0)($bold($red(MAML))) |
| 7 | 7 | $define(em)(1)($italic($1)) |
| 8 | +$define(argu)(1)($rgb(0,80,0)(<$1>)) | |
| 8 | 9 | $define(mark0)(1)($label($1)$subsection($red($tt($dollar $1)))) |
| 9 | -$define(mark1)(2)($label($1)$subsection($red($tt($dollar $1$lpar$2$rpar)))) | |
| 10 | -$define(mark2)(3)($label($1)$subsection($red($tt($dollar $1$lpar$2$rpar$lpar$3$rpar)))) | |
| 11 | -$define(mark3)(4)($label($1)$subsection($red($tt($dollar $1$lpar$2$rpar$lpar$3$rpar$lpar$4$rpar)))) | |
| 12 | -$define(arg)(1)($tt($red($1))) | |
| 10 | +$define(mark1)(2)($label($1)$subsection($red($tt($dollar $1$lpar$argu($2)$rpar)))) | |
| 11 | +$define(mark2)(3)($label($1)$subsection($red($tt($dollar $1$lpar$argu($2)$rpar$lpar$argu($3)$rpar)))) | |
| 12 | +$define(mark3)(4)($label($1)$subsection($red($tt($dollar $1$lpar$argu($2)$rpar$lpar$argu($3)$rpar$lpar$argu($4)$rpar)))) | |
| 13 | 13 | $define(LaTeX)(0)($latex(\LaTeX)) |
| 14 | 14 | $define(tcode)(1)($code(255,255,255)($1)) |
| 15 | 15 | |
| ... | ... | @@ -86,7 +86,7 @@ text, rather than writing them from scratch at each occurrence. In some sens, de |
| 86 | 86 | creating your own style. |
| 87 | 87 | $par$par |
| 88 | 88 | For example, it can be the case that some concept of your discourse has to be emphasized in a particular way, say printed |
| 89 | -in red. You whould not use $tt($dollar red(...)) in the text. You should better first give a name (say $tt(thething)) to | |
| 89 | +in red. You should not use $tt($dollar red(...)) in the text. You should better first give a name (say $tt(thething)) to | |
| 90 | 90 | your concept, and define it near the beginning of the text: |
| 91 | 91 | $par$par |
| 92 | 92 | $tt($dollar define(thething)(1)($dollar red($dollar 1))) |
| ... | ... | @@ -98,19 +98,22 @@ This will structure your text in a useful semantic way, instead of a non signifi |
| 98 | 98 | to later update. |
| 99 | 99 | It also has the advantage that you can later easily change the layout of the text by modifying |
| 100 | 100 | only the values in these $tt($dollar define). |
| 101 | - | |
| 102 | - | |
| 101 | +$par | |
| 102 | +$par | |
| 103 | +The $tt($dollar input) mark let you ``input'' a $MAML source at any point of nother $MAML source. Hence, you should | |
| 104 | +define your style in a file (say $tt(mystyle.maml)) and put an $tt($dollar input(mystyle.maml)) at the beginning of your | |
| 105 | +source file. | |
| 103 | 106 | |
| 104 | 107 | |
| 105 | 108 | $section(The catalog of $MAML marks) |
| 106 | 109 | Below are the $MAML marks in alphabetic order: |
| 107 | 110 | |
| 108 | - $mark1(big)(text) Prints its argument $arg(text) bigger. This mark can be nested. | |
| 111 | + $mark1(big)(text) Prints its argument $argu(text) bigger. This mark can be nested. | |
| 109 | 112 | |
| 110 | 113 | |
| 111 | - $mark1(bold)(text) Prints its argument $arg(text) in $bold(bold). | |
| 114 | + $mark1(bold)(text) Prints its argument $argu(text) in $bold(bold). | |
| 112 | 115 | |
| 113 | - $mark2(box)(width)(text) This mark puts $arg(text) into an invisible box of width $arg(width). The text if left aligned | |
| 116 | + $mark2(box)(width)(text) This mark puts $argu(text) into an invisible box of width $argu(width). The text if left aligned | |
| 114 | 117 | within the box. This mark can be used for simulating tabulators. For example, |
| 115 | 118 | $tcode( |
| 116 | 119 | $dollar box(50)(Smith) $dollar box(50)(John) $dollar box(30)(24) Baltimore $dollar par |
| ... | ... | @@ -124,14 +127,14 @@ Below are the $MAML marks in alphabetic order: |
| 124 | 127 | Of course, if you have to produce such tables, you should better first define a new mark whose role is to display |
| 125 | 128 | a single line of the table. This mark should include the $tt($dollar par) at the end of line. |
| 126 | 129 | |
| 127 | - $mark1(center)(text) This mark horizontally centers the $arg(text) in the page. | |
| 130 | + $mark1(center)(text) This mark horizontally centers the $argu(text) in the page. | |
| 128 | 131 | |
| 129 | - $mark2(code)(background-color)(text) This marks is for writing computer code. | |
| 130 | - The $arg(background-color) argument must have the form $tt(r,g,b), where $tt(r), $tt(g) and $tt(b) are intensities of | |
| 132 | + $mark2(code)(background color)(text) This marks is for writing computer code. | |
| 133 | + The $argu(background-color) argument must have the form $tt(r,g,b), where $tt(r), $tt(g) and $tt(b) are intensities of | |
| 131 | 134 | red green and blue and must be integers between 0 and 255. |
| 132 | - The $arg(text) argument is formated using a fixed width | |
| 135 | + The $argu(text) argument is formated using a fixed width | |
| 133 | 136 | (typewriter) font, spaces and newlines are taken into account, so that the result has essentially the same layout as the |
| 134 | - original. Nevertheless, $MAML marks are allowed within $arg(text), but some of them, such as $tt($dollar list), | |
| 137 | + original. Nevertheless, $MAML marks are allowed within $argu(text), but some of them, such as $tt($dollar list), | |
| 135 | 138 | can produce incoherent result. For example, |
| 136 | 139 | $par |
| 137 | 140 | $tcode($dollar code(220,220,220)( |
| ... | ... | @@ -167,36 +170,41 @@ $red(define) $blue(Int) |
| 167 | 170 | |
| 168 | 171 | $mark1(comment)(text) This mark allows you to put a comment, which will not be rendered, in your $MAML source text. |
| 169 | 172 | $par |
| 170 | - $em(Warning:) Parentheses must be balanced within $arg(text), otherwise the $MAML parser will not find the end of the | |
| 173 | + $em(Warning:) Parentheses must be balanced within $argu(text), otherwise the $MAML parser will not find the end of the | |
| 171 | 174 | comment. |
| 172 | 175 | |
| 173 | - $mark3(define)(name)(num)(value) | |
| 174 | - This mark let you define new marks (i.e. macros). It takes three arguments. The first argument $arg(name) is the name of the new mark. It should | |
| 176 | + $mark3(define)(name)(numer of arguments)(value) | |
| 177 | + This mark let you define new marks (i.e. macros). It takes three arguments. The first argument $argu(name) is the name of the new mark. It should | |
| 175 | 178 | not be already in use, must be made only of letters (A to Z and a to z) and numbers (0 to 9), and |
| 176 | - must contain at least one letter. The second argument $arg(num) is the number of arguments your new mark will accept. It must | |
| 177 | - be a positive or zero integer. The last argument $arg(value) is the value of the mark. This is a $MAML text, and it can | |
| 179 | + must contain at least one letter. The second argument $argu(number of arguments) is the number of arguments your new mark will accept. It must | |
| 180 | + be a positive or zero integer. The last argument $argu(value) is the value of the mark. This is a $MAML text, and it can | |
| 178 | 181 | contain marks of the form $tt($dollar 1), $tt($dollar 2), $tt($dollar 3), ... (called $MAML $em(variables)) which represent the arguments |
| 179 | 182 | of the mark, and which will be later replaced by the actual arguments when the mark is used in the text. |
| 180 | 183 | |
| 181 | 184 | $mark0(dollar) This mark inserts a character $dollar in the text. Notice that $tt($dollar tt($dollar dollar)) |
| 182 | - produces $tt($dollar), wheras $tt($dollar dollar) produces $dollar. | |
| 185 | + produces $tt($dollar), wheras $tt($dollar dollar) produces $dollar. You can also write $tt($) instead of $tt($ dollar), | |
| 186 | + provided that the character $tt($) is not followed by an integer, nor a latin letter nor a tilde character. | |
| 183 | 187 | |
| 184 | - $mark1(ifhtml)(text) The argument $arg(text) will be present in the HTML output, but not in the $LaTeX nor in the PDF | |
| 188 | + $mark0(end) This mark indicates that the MAML compiler should stop reading. In case this mark appears within a | |
| 189 | + source text read through an $tt($dollar input) mark, the ``input'' file is closed and parsing resumes in the | |
| 190 | + calling source. | |
| 191 | + | |
| 192 | + $mark1(ifhtml)(text) The argument $argu(text) will be present in the HTML output, but not in the $LaTeX nor in the PDF | |
| 185 | 193 | output. |
| 186 | 194 | |
| 187 | - $mark1(ifpdf)(text) The argument $arg(text) will be present in the $LaTeX and in the PDF | |
| 195 | + $mark1(ifpdf)(text) The argument $argu(text) will be present in the $LaTeX and in the PDF | |
| 188 | 196 | output, but not in the HTML output. |
| 189 | 197 | |
| 190 | - $mark2(image)(width)(path) | |
| 191 | - This mark allows you to insert an image in the text. The argument $arg(width) is the width the image will have | |
| 192 | - when displayed (in pixels in the case of HTML, and points in the case of $LaTeX), and $arg(path) is the path of the file | |
| 198 | + $mark2(image)(width)(file path) | |
| 199 | + This mark allows you to insert an image in the text. The argument $argu(width) is the width the image will have | |
| 200 | + when displayed (in pixels in the case of HTML, and points in the case of $LaTeX), and $argu(file path) is the path of the file | |
| 193 | 201 | containing the image. For example, |
| 194 | 202 | $tcode($dollar center($dollar image($dollar ifpdf(100)$dollar ifhtml(200))(cows.jpg))) |
| 195 | 203 | will produce this: |
| 196 | 204 | $center($image($ifpdf(100)$ifhtml(200))(cows.jpg)) |
| 197 | 205 | At the same time, you remark that the width of the image can be computed by $MAML marks. |
| 198 | 206 | $par |
| 199 | - $em(Warning:) The $arg(path) of the image is relative to the root directory on the server in the case of | |
| 207 | + $em(Warning:) The $argu(file path) of the image is relative to the root directory on the server in the case of | |
| 200 | 208 | an HTML output. In the case of a $LaTeX/PDF output, it is relative to the directory within which |
| 201 | 209 | the MAML parser is executed. |
| 202 | 210 | |
| ... | ... | @@ -204,12 +212,14 @@ $red(define) $blue(Int) |
| 204 | 212 | $mark1(input)(file name) |
| 205 | 213 | This mark let you insert the content of another $MAML file. This other file could for example contain your own $MAML |
| 206 | 214 | macros or be the file with extension $tt(.mamltoc) generated by the $MAML compiler (see $ref(section)($tt($dollar section))). |
| 215 | + For security reasons, this mark has restricted use in the web version of MAML. It can read files from one directory | |
| 216 | + only. | |
| 207 | 217 | |
| 208 | - $mark1(italic)(text) Prints its argument $arg(text) in $italic(italic). | |
| 218 | + $mark1(italic)(text) Prints its argument $argu(text) in $italic(italic). | |
| 209 | 219 | |
| 210 | 220 | $mark0(item) Marks the begining of an $em(item) within a $ref(list)($tt($dollar list)) |
| 211 | 221 | |
| 212 | - $mark1(label)(name) This mark defines a $em(label) in the text, in other words, a position where to jump. | |
| 222 | + $mark1(label)(tag) This mark defines a $em(label) in the text, in other words, a position where to jump. | |
| 213 | 223 | This is to be used in conjunction with $ref(ref)($tt($dollar ref)). |
| 214 | 224 | |
| 215 | 225 | $mark1(latex)(formula) This mark allows to include math formulas to be formated by $LaTeX. |
| ... | ... | @@ -219,44 +229,48 @@ $red(define) $blue(Int) |
| 219 | 229 | $latex($$\int_0^\infty\frac{dx}{1+x^2}$$) |
| 220 | 230 | This mark should not be used for big pieces of $LaTeX |
| 221 | 231 | text. It is mainly intended for math formulas, especially for HTML output where the formula is rendered |
| 222 | - as a PNG image with tansparent background. | |
| 232 | + as a PNG image with transparent background. | |
| 223 | 233 | $par$par |
| 224 | 234 | You can use $tt($dollar latex) in the text. The result will be correctly aligned with the text. For example,$par |
| 225 | 235 | $center($tcode(the polynomial $dollar latex($dollar X^2+X+1$dollar) is of degree 2)) |
| 226 | 236 | is rendered as~: |
| 227 | 237 | $center(the polynomial $latex($X^2+X+1$) is of degree 2) |
| 228 | 238 | |
| 229 | - $mark1(list)(text) This mark allows to create a list. The argument $arg(text) must be a sequence of $em(items), | |
| 230 | - i.e. texts which are all beginning by the mark $ref(item)($tt($dollar item)). | |
| 239 | + $mark1(list)(items) This mark allows to create a list. The argument $argu(items) must be a sequence of $em(items), | |
| 240 | + i.e. texts which are all prefixed by the mark $ref(item)($tt($dollar item)). | |
| 231 | 241 | |
| 232 | 242 | $mark0(lpar) This mark inserts a left (opening) parenthese into the text. You must use $tt($dollar lpar) and/or |
| 233 | 243 | $tt($dollar rpar) if you want to introduce unbalanced parentheses within an argument of a mark. |
| 234 | 244 | |
| 235 | - $mark2(mailto)(address)(text) This marks, which appears as $arg(text), | |
| 245 | + $mark2(mailto)(address)(text) This marks, which appears as $argu(text), | |
| 236 | 246 | creates a link which is supposed, in the HTML case, to open your mail agent in order to let you |
| 237 | - send an email to the indicated $arg(address). In the PDF case, the $arg(address) is just indicated between parentheses | |
| 238 | - beside $arg(text). | |
| 247 | + send an email to the indicated $argu(address). In the PDF case, the $argu(address) is just indicated between parentheses | |
| 248 | + beside $argu(text). | |
| 239 | 249 | For example, |
| 240 | 250 | $center($tt($dollar blue($dollar mailto(XZ32@planet.mars)(the martian)))) produces: |
| 241 | 251 | $blue($mailto(XZ32@planet.mars)(the martian)) |
| 242 | 252 | |
| 243 | - $mark1(note)(text) This mark produces a footnote containing $arg(text). | |
| 253 | + $mark1(note)(text) This mark produces a footnote containing $argu(text). | |
| 244 | 254 | In the case of $LaTeX/PDF this is a usual |
| 245 | 255 | footnote.$ifpdf($note(Like this one.)) In the case of HTML, this is a popup which appears at the bottom of the browser's window when the mouse |
| 246 | 256 | passes over this indication : $ifhtml($note(Here is the note !))$ifpdf(($sup(note))).$ifhtml( Try it !) |
| 247 | 257 | |
| 258 | + $mark2(output)(file path)(text) This mark does not produce anything in the resulting HTML or PDF files, but outputs | |
| 259 | + $argu(text) (without any modification) into the file $argu(file path). For security reasons, this mark is not available | |
| 260 | + in the web version of MAML. | |
| 261 | + | |
| 248 | 262 | $mark0(par) This marks generates a line break. You can use several $tt($dollar par) in order to make some |
| 249 | 263 | vertical space in your text. |
| 250 | 264 | $par$par |
| 251 | 265 | $em(Warning:) The MAML parser doesn't take newline characters into account (they are just read as spaces). Hence, |
| 252 | 266 | using $tt($dollar par) is often necessary. |
| 253 | 267 | |
| 254 | - $mark2(ref)(name)(text) | |
| 268 | + $mark2(ref)(tag)(text) | |
| 255 | 269 | This mark creates an internal hyperlink. When clicked upon, this moves the text |
| 256 | - to the position of the $ref(label)($tt($dollar label)) (this is a $tt($dollar ref) !) with the same name. | |
| 270 | + to the position of the $ref(label)($tt($dollar label)) (this is a $tt($dollar ref) !) with the same tag name. | |
| 257 | 271 | |
| 258 | - $mark2(rgb)(color)(text) This mark sets the color of characters in $arg(text) to $arg(color), where | |
| 259 | - $arg(color) has the form of three integers separated by commas, representing the intensities of red, green and blue. | |
| 272 | + $mark2(rgb)(color)(text) This mark sets the color of characters in $argu(text) to $argu(color), where | |
| 273 | + $argu(color) has the form of three integers separated by commas, representing the intensities of red, green and blue. | |
| 260 | 274 | These numbers must be between 0 and 255. For example, |
| 261 | 275 | $center($tcode($dollar rgb(255,0,0)(the text))) |
| 262 | 276 | produces: |
| ... | ... | @@ -269,49 +283,50 @@ $red(define) $blue(Int) |
| 269 | 283 | $tt($dollar rpar) if you want to introduce unbalanced parentheses within an argument of a mark. |
| 270 | 284 | |
| 271 | 285 | $mark1(section)(title) This mark defines a $em(section) within the text. It is translated into |
| 272 | - $tt(<h3>$arg(title)</h3>) in HTML and into $tt(\section{$arg(title)}) in $LaTeX, producing a numbered | |
| 273 | - section in the PDF output.$par$par | |
| 286 | + $tt(<h3>$argu(title)</h3>) in HTML and into $tt(\section{$argu(title)}) in $LaTeX. Sections are automatically numbered. | |
| 287 | + $par$par | |
| 274 | 288 | When it encouters either $tt($dollar section), $tt($dollar subsection) or $tt($dollar subsubsection), the $MAML |
| 275 | 289 | compiler adds a line to the file with the same name as the source file but with $tt(.mamltoc) appended. This file contains |
| 276 | 290 | marks of the form $tt($dollar tocsec(label)(text)) (and similarly $tt($dollar tocsubsec) and |
| 277 | 291 | $tt($dollar tocsubsubsec)), and it is up to you to define the meaning of these marks. Combined with $tt($dollar input) this lets |
| 278 | - you make a table of contents for the HTML output. | |
| 292 | + you make a table of contents for the HTML output. Actually, this is how the table of contents of the present tutorial | |
| 293 | + was made. | |
| 279 | 294 | |
| 280 | - $mark1(sub)(text) This mark lowers $arg(text) and renders it in a smaller size. For example, $tt(x$dollar sub(1)) | |
| 295 | + $mark1(sub)(text) This mark lowers $argu(text) and renders it in a smaller size. For example, $tt(x$dollar sub(1)) | |
| 281 | 296 | produces x$sub(1). |
| 282 | 297 | |
| 283 | 298 | $mark1(subsection)(title) This mark defines a $em(subsection) within the text. It is translated into |
| 284 | - $tt(<h4>$arg(title)</h4>) in HTML and into $tt(\subsection{$arg(title)}) in $LaTeX, producing a numbered | |
| 285 | - subsection in the PDF output. | |
| 299 | + $tt(<h4>$argu(title)</h4>) in HTML and into $tt(\subsection{$argu(title)}) in $LaTeX. Subsections are automatically | |
| 300 | + numbered. | |
| 286 | 301 | |
| 287 | 302 | $mark1(subsubsection)(title) This mark defines a $em(subsubsection) within the text. It is translated into |
| 288 | - $tt(<h5>$arg(title)</h5>) in HTML and into $tt(\subsubsection{$arg(title)}) in $LaTeX, producing a numbered | |
| 289 | - subsubsection in the PDF output. | |
| 303 | + $tt(<h5>$argu(title)</h5>) in HTML and into $tt(\subsubsection{$argu(title)}) in $LaTeX. Subsubsections are automatically | |
| 304 | + numbered. | |
| 290 | 305 | |
| 291 | - $mark1(sup)(text) This mark raises $arg(text) and renders it in a smaller size. For example, $tt(x$dollar sup(1)) | |
| 306 | + $mark1(sup)(text) This mark raises $argu(text) and renders it in a smaller size. For example, $tt(x$dollar sup(1)) | |
| 292 | 307 | produces x$sup(1). |
| 293 | 308 | |
| 294 | - $mark2(tbgc)(color)(text) This mark ($em(text background color)) shows $arg(text) over a background of color | |
| 295 | - $arg(color). For example, | |
| 309 | + $mark2(tbgc)(color)(text) This mark ($em(text background color)) shows $argu(text) over a background of color | |
| 310 | + $argu(color). For example, | |
| 296 | 311 | $center($tcode($dollar tbgc(255,200,200)(Some text.))) |
| 297 | - produces: $tbgc(255,200,200)(Some text.) $em(Warning:) This will force $arg(text) to be on a single line, so that | |
| 298 | - it is valuable only for very short texts. | |
| 312 | + produces: $tbgc(255,200,200)(Some text.) $em(Warning:) This will force $argu(text) to be on a single line, so that | |
| 313 | + it is valuable only for very short texts. See also $ref(code)($tt($dollar code(...))). | |
| 299 | 314 | |
| 300 | - $mark2(tlink)(text)(url) This mark creates an hypertext link targeting the $arg(url), and shown as the clickable | |
| 301 | - $arg(text) (which can also be an image). | |
| 315 | + $mark2(tlink)(text)(url) This mark creates an hypertext link targeting the $argu(url), and shown as the clickable | |
| 316 | + $argu(text) (which can also be an image). | |
| 302 | 317 | |
| 303 | - $mark1(tt)(text) This mark renders $arg(text) in fixed width (typewriter) font. It is similar to | |
| 304 | - $ref(code)($tt($dollar code(...))), with the difference that $arg(text) is put inline instead of as a separate block. | |
| 305 | - For example, $tt($dollar tt(This) is $dollar code(an) example.) | |
| 318 | + $mark1(tt)(text) This mark renders $argu(text) in fixed width (typewriter) font. It is similar to | |
| 319 | + $ref(code)($tt($dollar code(...))), with the difference that $argu(text) is put inline instead of as a separate block. | |
| 320 | + For example, $tt($dollar tt(This) is $dollar code(255,255,255)(an) example.) | |
| 306 | 321 | produces: $tt(This) is $tcode(an) example. |
| 307 | 322 | $par |
| 308 | 323 | See also $ref(code)($tt($dollar code(...))) and $ref(verbatim)($tt($dollar verbatim(...))). |
| 309 | 324 | |
| 310 | 325 | $mark1(verbatim)(text) This marks reproduces its content without any change with two exceptions. |
| 311 | 326 | Indeed, $MAML marks within |
| 312 | - $arg(text) are not interpreted, except the two marks $tt($dollar lpar) and $tt($dollar rpar), which allows you | |
| 313 | - to produce unbalanced parentheses in $arg(text) despite the fact that actual parentheses $em(must) be | |
| 314 | - balanced in $arg(text). Example: | |
| 327 | + $argu(text) are not interpreted, except the two marks $tt($dollar lpar) and $tt($dollar rpar), which allows you | |
| 328 | + to produce unbalanced parentheses in $argu(text) despite the fact that actual parentheses $em(must) be | |
| 329 | + balanced in $argu(text). Example: | |
| 315 | 330 | $par |
| 316 | 331 | $tcode($dollar verbatim( |
| 317 | 332 | In this ($dollar blue(text))(), ((parentheses) are) $dollar rpar$dollar rpar$dollar lpar balanced. |
| ... | ... | @@ -329,7 +344,7 @@ $red(define) $blue(Int) |
| 329 | 344 | See also $ref(code)($tt($dollar code(...))) and $ref(tt)($tt($dollar tt(...))). |
| 330 | 345 | |
| 331 | 346 | |
| 332 | -$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par | |
| 347 | +$ifhtml($par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par$par) | |
| 333 | 348 | |
| 334 | 349 | |
| 335 | 350 | ... | ... |
anubis_dev/library/doc_tools/maml3_tutorial.maml.html
| ... | ... | @@ -60,39 +60,41 @@ This documentation itself was written in <strong><div style="display: inline; co |
| 60 | 60 | <br><br><br><center><table style="color: inherit; font-size: inherit;"><tr><td><strong><big>Contents</big></strong></td></tr></table></center><br><big><a rel="tag" href="#toclab1">The <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> syntax</a></big><br> |
| 61 | 61 | <big><a rel="tag" href="#toclab2">Creating your own style</a></big><br> |
| 62 | 62 | <big><a rel="tag" href="#toclab3">The catalog of <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> marks</a></big><br> |
| 63 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab4"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$big(text)</span></div></a><br> | |
| 64 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab5"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$bold(text)</span></div></a><br> | |
| 65 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab6"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$box(width)(text)</span></div></a><br> | |
| 66 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab7"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$center(text)</span></div></a><br> | |
| 67 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab8"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$code(background-color)(text)</span></div></a><br> | |
| 68 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab9"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$comment(text)</span></div></a><br> | |
| 69 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab10"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$define(name)(num)(value)</span></div></a><br> | |
| 63 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab4"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$big(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 64 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab5"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$bold(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 65 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab6"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$box(<div style="display: inline; color: rgb(0,80,0)"><width></div>)(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 66 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab7"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$center(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 67 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab8"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$code(<div style="display: inline; color: rgb(0,80,0)"><background color></div>)(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 68 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab9"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$comment(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 69 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab10"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$define(<div style="display: inline; color: rgb(0,80,0)"><name></div>)(<div style="display: inline; color: rgb(0,80,0)"><numer of arguments></div>)(<div style="display: inline; color: rgb(0,80,0)"><value></div>)</span></div></a><br> | |
| 70 | 70 | <div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab11"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$dollar</span></div></a><br> |
| 71 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab12"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ifhtml(text)</span></div></a><br> | |
| 72 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab13"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ifpdf(text)</span></div></a><br> | |
| 73 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab14"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$image(width)(path)</span></div></a><br> | |
| 74 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab15"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$input(file name)</span></div></a><br> | |
| 75 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab16"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$italic(text)</span></div></a><br> | |
| 76 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab17"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$item</span></div></a><br> | |
| 77 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab18"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$label(name)</span></div></a><br> | |
| 78 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab19"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$latex(formula)</span></div></a><br> | |
| 79 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab20"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$list(text)</span></div></a><br> | |
| 80 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab21"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$lpar</span></div></a><br> | |
| 81 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab22"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$mailto(address)(text)</span></div></a><br> | |
| 82 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab23"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$note(text)</span></div></a><br> | |
| 83 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab24"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$par</span></div></a><br> | |
| 84 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab25"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ref(name)(text)</span></div></a><br> | |
| 85 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab26"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$rgb(color)(text)</span></div></a><br> | |
| 86 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab27"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$rpar</span></div></a><br> | |
| 87 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab28"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$section(title)</span></div></a><br> | |
| 88 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab29"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$sub(text)</span></div></a><br> | |
| 89 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab30"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$subsection(title)</span></div></a><br> | |
| 90 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab31"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$subsubsection(title)</span></div></a><br> | |
| 91 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab32"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$sup(text)</span></div></a><br> | |
| 92 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab33"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tbgc(color)(text)</span></div></a><br> | |
| 93 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab34"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tlink(text)(url)</span></div></a><br> | |
| 94 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab35"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tt(text)</span></div></a><br> | |
| 95 | -<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab36"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$verbatim(text)</span></div></a><br> | |
| 71 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab12"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$end</span></div></a><br> | |
| 72 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab13"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ifhtml(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 73 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab14"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ifpdf(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 74 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab15"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$image(<div style="display: inline; color: rgb(0,80,0)"><width></div>)(<div style="display: inline; color: rgb(0,80,0)"><file path></div>)</span></div></a><br> | |
| 75 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab16"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$input(<div style="display: inline; color: rgb(0,80,0)"><file name></div>)</span></div></a><br> | |
| 76 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab17"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$italic(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 77 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab18"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$item</span></div></a><br> | |
| 78 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab19"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$label(<div style="display: inline; color: rgb(0,80,0)"><tag></div>)</span></div></a><br> | |
| 79 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab20"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$latex(<div style="display: inline; color: rgb(0,80,0)"><formula></div>)</span></div></a><br> | |
| 80 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab21"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$list(<div style="display: inline; color: rgb(0,80,0)"><items></div>)</span></div></a><br> | |
| 81 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab22"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$lpar</span></div></a><br> | |
| 82 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab23"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$mailto(<div style="display: inline; color: rgb(0,80,0)"><address></div>)(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 83 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab24"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$note(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 84 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab25"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$output(<div style="display: inline; color: rgb(0,80,0)"><file path></div>)(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 85 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab26"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$par</span></div></a><br> | |
| 86 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab27"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ref(<div style="display: inline; color: rgb(0,80,0)"><tag></div>)(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 87 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab28"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$rgb(<div style="display: inline; color: rgb(0,80,0)"><color></div>)(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 88 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab29"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$rpar</span></div></a><br> | |
| 89 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab30"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$section(<div style="display: inline; color: rgb(0,80,0)"><title></div>)</span></div></a><br> | |
| 90 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab31"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$sub(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 91 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab32"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$subsection(<div style="display: inline; color: rgb(0,80,0)"><title></div>)</span></div></a><br> | |
| 92 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab33"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$subsubsection(<div style="display: inline; color: rgb(0,80,0)"><title></div>)</span></div></a><br> | |
| 93 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab34"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$sup(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 94 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab35"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tbgc(<div style="display: inline; color: rgb(0,80,0)"><color></div>)(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 95 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab36"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tlink(<div style="display: inline; color: rgb(0,80,0)"><text></div>)(<div style="display: inline; color: rgb(0,80,0)"><url></div>)</span></div></a><br> | |
| 96 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab37"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tt(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 97 | +<div align="left" style="display: inline-block; width: 20px;"></div><a rel="tag" href="#toclab38"><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$verbatim(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></a><br> | |
| 96 | 98 | <br> |
| 97 | 99 | |
| 98 | 100 | <a id=toclab1></a><h2>The <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> syntax</h2> |
| ... | ... | @@ -104,8 +106,8 @@ in HTML. If you want to insert an actual <em>tilde</em> character in your text, |
| 104 | 106 | that what follows is a <em>mark</em>. The name of the mark immediatly follows the character <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$</span>. The arguments |
| 105 | 107 | of the mark follow this name, and each one must be delimited by a pair of parentheses. For example, if you |
| 106 | 108 | want to render some text in blue, you can write: |
| 107 | -<br><center><table style="color: inherit; font-size: inherit;"><tr><td><table style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;"><tr><td><pre>$blue(this text is rendered in blue) | |
| 108 | -</pre></td></tr></table></td></tr></table></center><br> | |
| 109 | +<br><center><table style="color: inherit; font-size: inherit;"><tr><td><pre style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;">$blue(this text is rendered in blue) | |
| 110 | +</pre></td></tr></table></center><br> | |
| 109 | 111 | which will produce this: |
| 110 | 112 | <br><center><table style="color: inherit; font-size: inherit;"><tr><td><div style="display: inline; color: rgb(0,0,200)">this text is rendered in blue</div></td></tr></table></center><br> |
| 111 | 113 | <br>Each mark accepts a fixed number of arguments. Since each argument must be delimited by a pair of parentheses |
| ... | ... | @@ -115,12 +117,12 @@ parenthese. Nevertheless, you can still include unbalanced parentheses in an arg |
| 115 | 117 | <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$lpar</span> (left parenthese) and <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$rpar</span> (right parenthese). |
| 116 | 118 | <br><br>The mark <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$blue</span> takes one argument as you saw above. As another example, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tlink</span> takes two |
| 117 | 119 | arguments, and the text: |
| 118 | -<br><center><table style="color: inherit; font-size: inherit;"><tr><td><table style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;"><tr><td><pre>$tlink(Visit | |
| 120 | +<br><center><table style="color: inherit; font-size: inherit;"><tr><td><pre style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;">$tlink(Visit | |
| 119 | 121 | $big($blue(G)$red(o)$yellow(o)$blue(g)$green(l)$red(e))) |
| 120 | 122 | (http://www.google.com) |
| 121 | -</pre></td></tr></table></td></tr></table></center><br> | |
| 123 | +</pre></td></tr></table></center><br> | |
| 122 | 124 | will produce this (that you can click upon): |
| 123 | -<br><br><center><table style="color: inherit; font-size: inherit;"><tr><td><a href="http://www.google.com" target="w3f3e70818b5b9c6a9b18ca17def89046a999c993">Visit <big><div style="display: inline; color: rgb(0,0,200)">G</div><div style="display: inline; color: rgb(220,0,0)">o</div><div style="display: inline; color: rgb(180,180,0)">o</div><div style="display: inline; color: rgb(0,0,200)">g</div><div style="display: inline; color: rgb(0,180,0)">l</div><div style="display: inline; color: rgb(220,0,0)">e</div></big></a></td></tr></table></center><br> | |
| 125 | +<br><br><center><table style="color: inherit; font-size: inherit;"><tr><td><a href="http://www.google.com" target="wf6007c235f2664f2d79cbe18b01f9097aa7eab80">Visit <big><div style="display: inline; color: rgb(0,0,200)">G</div><div style="display: inline; color: rgb(220,0,0)">o</div><div style="display: inline; color: rgb(180,180,0)">o</div><div style="display: inline; color: rgb(0,0,200)">g</div><div style="display: inline; color: rgb(0,180,0)">l</div><div style="display: inline; color: rgb(220,0,0)">e</div></big></a></td></tr></table></center><br> | |
| 124 | 126 | <br><em>Remark:</em> The name of a mark is right delimited by the first character which is not an acceptable character |
| 125 | 127 | for such a name. If this character is a space, it is discarded. On the contrary, if a second |
| 126 | 128 | space follows, it is not discarded. Hence for example, |
| ... | ... | @@ -138,7 +140,7 @@ marks. In other words, it's better to first define (using the <span style="font- |
| 138 | 140 | text, rather than writing them from scratch at each occurrence. In some sens, defining these concepts is the same as |
| 139 | 141 | creating your own style. |
| 140 | 142 | <br><br>For example, it can be the case that some concept of your discourse has to be emphasized in a particular way, say printed |
| 141 | -in red. You whould not use <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$red(...)</span> in the text. You should better first give a name (say <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">thething</span>) to | |
| 143 | +in red. You should not use <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$red(...)</span> in the text. You should better first give a name (say <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">thething</span>) to | |
| 142 | 144 | your concept, and define it near the beginning of the text: |
| 143 | 145 | <br><br><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$define(thething)(1)($red($1))</span> |
| 144 | 146 | <br><br>and write <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$thething(...)</span> in the text instead of <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$red(...)</span>. |
| ... | ... | @@ -146,38 +148,39 @@ your concept, and define it near the beginning of the text: |
| 146 | 148 | to later update. |
| 147 | 149 | It also has the advantage that you can later easily change the layout of the text by modifying |
| 148 | 150 | only the values in these <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$define</span>. |
| 149 | - | |
| 150 | - | |
| 151 | +<br><br>The <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$input</span> mark let you ``input'' a <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> source at any point of nother <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> source. Hence, you should | |
| 152 | +define your style in a file (say <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">mystyle.maml</span>) and put an <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$input(mystyle.maml)</span> at the beginning of your | |
| 153 | +source file. | |
| 151 | 154 | |
| 152 | 155 | |
| 153 | 156 | <a id=toclab3></a><h2>The catalog of <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> marks</h2> |
| 154 | 157 | Below are the <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> marks in alphabetic order: |
| 155 | 158 | |
| 156 | - <a id="big"></a><a id=toclab4></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$big(text)</span></div></h3> Prints its argument <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> bigger. This mark can be nested. | |
| 159 | + <a id="big"></a><a id=toclab4></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$big(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> Prints its argument <div style="display: inline; color: rgb(0,80,0)"><text></div> bigger. This mark can be nested. | |
| 157 | 160 | |
| 158 | 161 | |
| 159 | - <a id="bold"></a><a id=toclab5></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$bold(text)</span></div></h3> Prints its argument <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> in <strong>bold</strong>. | |
| 162 | + <a id="bold"></a><a id=toclab5></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$bold(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> Prints its argument <div style="display: inline; color: rgb(0,80,0)"><text></div> in <strong>bold</strong>. | |
| 160 | 163 | |
| 161 | - <a id="box"></a><a id=toclab6></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$box(width)(text)</span></div></h3> This mark puts <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> into an invisible box of width <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">width</div></span>. The text if left aligned | |
| 164 | + <a id="box"></a><a id=toclab6></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$box(<div style="display: inline; color: rgb(0,80,0)"><width></div>)(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> This mark puts <div style="display: inline; color: rgb(0,80,0)"><text></div> into an invisible box of width <div style="display: inline; color: rgb(0,80,0)"><width></div>. The text if left aligned | |
| 162 | 165 | within the box. This mark can be used for simulating tabulators. For example, |
| 163 | - <table style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;"><tr><td><pre> | |
| 166 | + <pre style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;"> | |
| 164 | 167 | $box(50)(Smith) $box(50)(John) $box(30)(24) Baltimore $par |
| 165 | 168 | $box(50)(Ford) $box(50)(Max) $box(30)(32) New York $par |
| 166 | - </pre></td></tr></table> | |
| 169 | + </pre> | |
| 167 | 170 | produces: |
| 168 | 171 | <br><br> <div align="left" style="display: inline-block; width: 50px;">Smith</div> <div align="left" style="display: inline-block; width: 50px;">John</div> <div align="left" style="display: inline-block; width: 30px;">24</div> Baltimore <br> <div align="left" style="display: inline-block; width: 50px;">Ford</div> <div align="left" style="display: inline-block; width: 50px;">Max</div> <div align="left" style="display: inline-block; width: 30px;">32</div> New York <br> <br> Of course, if you have to produce such tables, you should better first define a new mark whose role is to display |
| 169 | 172 | a single line of the table. This mark should include the <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$par</span> at the end of line. |
| 170 | 173 | |
| 171 | - <a id="center"></a><a id=toclab7></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$center(text)</span></div></h3> This mark horizontally centers the <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> in the page. | |
| 174 | + <a id="center"></a><a id=toclab7></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$center(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> This mark horizontally centers the <div style="display: inline; color: rgb(0,80,0)"><text></div> in the page. | |
| 172 | 175 | |
| 173 | - <a id="code"></a><a id=toclab8></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$code(background-color)(text)</span></div></h3> This marks is for writing computer code. | |
| 174 | - The <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">background-color</div></span> argument must have the form <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">r,g,b</span>, where <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">r</span>, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">g</span> and <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">b</span> are intensities of | |
| 176 | + <a id="code"></a><a id=toclab8></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$code(<div style="display: inline; color: rgb(0,80,0)"><background color></div>)(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> This marks is for writing computer code. | |
| 177 | + The <div style="display: inline; color: rgb(0,80,0)"><background-color></div> argument must have the form <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">r,g,b</span>, where <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">r</span>, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">g</span> and <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">b</span> are intensities of | |
| 175 | 178 | red green and blue and must be integers between 0 and 255. |
| 176 | - The <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> argument is formated using a fixed width | |
| 179 | + The <div style="display: inline; color: rgb(0,80,0)"><text></div> argument is formated using a fixed width | |
| 177 | 180 | (typewriter) font, spaces and newlines are taken into account, so that the result has essentially the same layout as the |
| 178 | - original. Nevertheless, <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> marks are allowed within <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span>, but some of them, such as <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$list</span>, | |
| 181 | + original. Nevertheless, <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> marks are allowed within <div style="display: inline; color: rgb(0,80,0)"><text></div>, but some of them, such as <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$list</span>, | |
| 179 | 182 | can produce incoherent result. For example, |
| 180 | - <br> <table style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;"><tr><td><pre>$code(220,220,220)( | |
| 183 | + <br> <pre style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;">$code(220,220,220)( | |
| 181 | 184 | $red(define) $blue(Int) |
| 182 | 185 | length |
| 183 | 186 | ( |
| ... | ... | @@ -188,9 +191,9 @@ $red(define) $blue(Int) |
| 188 | 191 | [ ] $red(then) 0, $green(// the list is empty) |
| 189 | 192 | [h . t] $red(then) 1+length(t) |
| 190 | 193 | }. |
| 191 | - )</pre></td></tr></table> | |
| 194 | + )</pre> | |
| 192 | 195 | <br> produces: |
| 193 | - <br> <table style="color: inherit; font-size: inherit; background-color: rgb(220,220,220); width: 600px;"><tr><td><pre> | |
| 196 | + <br> <pre style="color: inherit; font-size: inherit; background-color: rgb(220,220,220); width: 600px;"> | |
| 194 | 197 | <div style="display: inline; color: rgb(220,0,0)">define</div> <div style="display: inline; color: rgb(0,0,200)">Int</div> |
| 195 | 198 | length |
| 196 | 199 | ( |
| ... | ... | @@ -201,158 +204,170 @@ $red(define) $blue(Int) |
| 201 | 204 | [ ] <div style="display: inline; color: rgb(220,0,0)">then</div> 0, <div style="display: inline; color: rgb(0,180,0)">// the list is empty</div> |
| 202 | 205 | [h . t] <div style="display: inline; color: rgb(220,0,0)">then</div> 1+length(t) |
| 203 | 206 | }. |
| 204 | - </pre></td></tr></table> | |
| 207 | + </pre> | |
| 205 | 208 | <br> See also <a rel="tag" href="#tt"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tt(...)</span></a> and <a rel="tag" href="#verbatim"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$verbatim(...)</span></a> |
| 206 | 209 | |
| 207 | 210 | |
| 208 | - <a id="comment"></a><a id=toclab9></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$comment(text)</span></div></h3> This mark allows you to put a comment, which will not be rendered, in your <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> source text. | |
| 209 | - <br> <em>Warning:</em> Parentheses must be balanced within <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span>, otherwise the <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> parser will not find the end of the | |
| 211 | + <a id="comment"></a><a id=toclab9></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$comment(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> This mark allows you to put a comment, which will not be rendered, in your <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> source text. | |
| 212 | + <br> <em>Warning:</em> Parentheses must be balanced within <div style="display: inline; color: rgb(0,80,0)"><text></div>, otherwise the <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> parser will not find the end of the | |
| 210 | 213 | comment. |
| 211 | 214 | |
| 212 | - <a id="define"></a><a id=toclab10></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$define(name)(num)(value)</span></div></h3> | |
| 213 | - This mark let you define new marks (i.e. macros). It takes three arguments. The first argument <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">name</div></span> is the name of the new mark. It should | |
| 215 | + <a id="define"></a><a id=toclab10></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$define(<div style="display: inline; color: rgb(0,80,0)"><name></div>)(<div style="display: inline; color: rgb(0,80,0)"><numer of arguments></div>)(<div style="display: inline; color: rgb(0,80,0)"><value></div>)</span></div></h3> | |
| 216 | + This mark let you define new marks (i.e. macros). It takes three arguments. The first argument <div style="display: inline; color: rgb(0,80,0)"><name></div> is the name of the new mark. It should | |
| 214 | 217 | not be already in use, must be made only of letters (A to Z and a to z) and numbers (0 to 9), and |
| 215 | - must contain at least one letter. The second argument <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">num</div></span> is the number of arguments your new mark will accept. It must | |
| 216 | - be a positive or zero integer. The last argument <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">value</div></span> is the value of the mark. This is a <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> text, and it can | |
| 218 | + must contain at least one letter. The second argument <div style="display: inline; color: rgb(0,80,0)"><number of arguments></div> is the number of arguments your new mark will accept. It must | |
| 219 | + be a positive or zero integer. The last argument <div style="display: inline; color: rgb(0,80,0)"><value></div> is the value of the mark. This is a <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> text, and it can | |
| 217 | 220 | contain marks of the form <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$1</span>, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$2</span>, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$3</span>, ... (called <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> <em>variables</em>) which represent the arguments |
| 218 | 221 | of the mark, and which will be later replaced by the actual arguments when the mark is used in the text. |
| 219 | 222 | |
| 220 | 223 | <a id="dollar"></a><a id=toclab11></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$dollar</span></div></h3> This mark inserts a character $ in the text. Notice that <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tt($dollar)</span> |
| 221 | - produces <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$</span>, wheras <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$dollar</span> produces $. | |
| 224 | + produces <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$</span>, wheras <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$dollar</span> produces $. You can also write <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$</span> instead of <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$dollar</span>, | |
| 225 | + provided that the character <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$</span> is not followed by an integer, nor a latin letter nor a tilde character. | |
| 222 | 226 | |
| 223 | - <a id="ifhtml"></a><a id=toclab12></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ifhtml(text)</span></div></h3> The argument <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> will be present in the HTML output, but not in the <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px"> nor in the PDF | |
| 227 | + <a id="end"></a><a id=toclab12></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$end</span></div></h3> This mark indicates that the MAML compiler should stop reading. In case this mark appears within a | |
| 228 | + source text read through an <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$input</span> mark, the ``input'' file is closed and parsing resumes in the | |
| 229 | + calling source. | |
| 230 | + | |
| 231 | + <a id="ifhtml"></a><a id=toclab13></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ifhtml(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> The argument <div style="display: inline; color: rgb(0,80,0)"><text></div> will be present in the HTML output, but not in the <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px"> nor in the PDF | |
| 224 | 232 | output. |
| 225 | 233 | |
| 226 | - <a id="ifpdf"></a><a id=toclab13></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ifpdf(text)</span></div></h3> The argument <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> will be present in the <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px"> and in the PDF | |
| 234 | + <a id="ifpdf"></a><a id=toclab14></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ifpdf(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> The argument <div style="display: inline; color: rgb(0,80,0)"><text></div> will be present in the <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px"> and in the PDF | |
| 227 | 235 | output, but not in the HTML output. |
| 228 | 236 | |
| 229 | - <a id="image"></a><a id=toclab14></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$image(width)(path)</span></div></h3> | |
| 230 | - This mark allows you to insert an image in the text. The argument <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">width</div></span> is the width the image will have | |
| 231 | - when displayed (in pixels in the case of HTML, and points in the case of <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px">), and <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">path</div></span> is the path of the file | |
| 237 | + <a id="image"></a><a id=toclab15></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$image(<div style="display: inline; color: rgb(0,80,0)"><width></div>)(<div style="display: inline; color: rgb(0,80,0)"><file path></div>)</span></div></h3> | |
| 238 | + This mark allows you to insert an image in the text. The argument <div style="display: inline; color: rgb(0,80,0)"><width></div> is the width the image will have | |
| 239 | + when displayed (in pixels in the case of HTML, and points in the case of <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px">), and <div style="display: inline; color: rgb(0,80,0)"><file path></div> is the path of the file | |
| 232 | 240 | containing the image. For example, |
| 233 | - <table style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;"><tr><td><pre>$center($image($ifpdf(100)$ifhtml(200))(cows.jpg))</pre></td></tr></table> | |
| 241 | + <pre style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;">$center($image($ifpdf(100)$ifhtml(200))(cows.jpg))</pre> | |
| 234 | 242 | will produce this: |
| 235 | 243 | <br><center><table style="color: inherit; font-size: inherit;"><tr><td><img src="cows.jpg" width="200"></td></tr></table></center><br> |
| 236 | 244 | At the same time, you remark that the width of the image can be computed by <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> marks. |
| 237 | - <br> <em>Warning:</em> The <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">path</div></span> of the image is relative to the root directory on the server in the case of | |
| 245 | + <br> <em>Warning:</em> The <div style="display: inline; color: rgb(0,80,0)"><file path></div> of the image is relative to the root directory on the server in the case of | |
| 238 | 246 | an HTML output. In the case of a <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px">/PDF output, it is relative to the directory within which |
| 239 | 247 | the MAML parser is executed. |
| 240 | 248 | |
| 241 | 249 | |
| 242 | - <a id="input"></a><a id=toclab15></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$input(file name)</span></div></h3> | |
| 250 | + <a id="input"></a><a id=toclab16></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$input(<div style="display: inline; color: rgb(0,80,0)"><file name></div>)</span></div></h3> | |
| 243 | 251 | This mark let you insert the content of another <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> file. This other file could for example contain your own <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> macros or be the file with extension <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">.mamltoc</span> generated by the <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> compiler (see <a rel="tag" href="#section"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$section</span></a>). |
| 252 | + For security reasons, this mark has restricted use in the web version of MAML. It can read files from one directory | |
| 253 | + only. | |
| 244 | 254 | |
| 245 | - <a id="italic"></a><a id=toclab16></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$italic(text)</span></div></h3> Prints its argument <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> in <em>italic</em>. | |
| 255 | + <a id="italic"></a><a id=toclab17></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$italic(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> Prints its argument <div style="display: inline; color: rgb(0,80,0)"><text></div> in <em>italic</em>. | |
| 246 | 256 | |
| 247 | - <a id="item"></a><a id=toclab17></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$item</span></div></h3> Marks the begining of an <em>item</em> within a <a rel="tag" href="#list"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$list</span></a> | |
| 257 | + <a id="item"></a><a id=toclab18></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$item</span></div></h3> Marks the begining of an <em>item</em> within a <a rel="tag" href="#list"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$list</span></a> | |
| 248 | 258 | |
| 249 | - <a id="label"></a><a id=toclab18></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$label(name)</span></div></h3> This mark defines a <em>label</em> in the text, in other words, a position where to jump. | |
| 259 | + <a id="label"></a><a id=toclab19></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$label(<div style="display: inline; color: rgb(0,80,0)"><tag></div>)</span></div></h3> This mark defines a <em>label</em> in the text, in other words, a position where to jump. | |
| 250 | 260 | This is to be used in conjunction with <a rel="tag" href="#ref"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ref</span></a>. |
| 251 | 261 | |
| 252 | - <a id="latex"></a><a id=toclab19></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$latex(formula)</span></div></h3> This mark allows to include math formulas to be formated by <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px">. | |
| 262 | + <a id="latex"></a><a id=toclab20></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$latex(<div style="display: inline; color: rgb(0,80,0)"><formula></div>)</span></div></h3> This mark allows to include math formulas to be formated by <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px">. | |
| 253 | 263 | For example, |
| 254 | - <br><center><table style="color: inherit; font-size: inherit;"><tr><td><table style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;"><tr><td><pre>$latex($$\int_0^\infty\frac{dx}{1+x^2}$$)</pre></td></tr></table></td></tr></table></center><br> | |
| 264 | + <br><center><table style="color: inherit; font-size: inherit;"><tr><td><pre style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;">$latex($$\int_0^\infty\frac{dx}{1+x^2}$$)</pre></td></tr></table></center><br> | |
| 255 | 265 | will be rendered as: |
| 256 | 266 | <br><center><img src="png/fq22PnfBrYNx2fPr8NQyxy5tdO_A.png" width="72" height="36" style="vertical-align: -0px"></center><br> |
| 257 | 267 | This mark should not be used for big pieces of <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px"> |
| 258 | 268 | text. It is mainly intended for math formulas, especially for HTML output where the formula is rendered |
| 259 | - as a PNG image with tansparent background. | |
| 260 | - <br><br> You can use <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$latex</span> in the text. The result will be correctly aligned with the text. For example,<br> <br><center><table style="color: inherit; font-size: inherit;"><tr><td><table style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;"><tr><td><pre>the polynomial $latex($X^2+X+1$) is of degree 2</pre></td></tr></table></td></tr></table></center><br> | |
| 269 | + as a PNG image with transparent background. | |
| 270 | + <br><br> You can use <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$latex</span> in the text. The result will be correctly aligned with the text. For example,<br> <br><center><table style="color: inherit; font-size: inherit;"><tr><td><pre style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;">the polynomial $latex($X^2+X+1$) is of degree 2</pre></td></tr></table></center><br> | |
| 261 | 271 | is rendered as : |
| 262 | 272 | <br><center><table style="color: inherit; font-size: inherit;"><tr><td>the polynomial <img src="png/fyKx7xRolFAoYjXkjs4VdbNyRjAQ.png" width="77" height="15" style="vertical-align: -1px"> is of degree 2</td></tr></table></center><br> |
| 263 | 273 | |
| 264 | - <a id="list"></a><a id=toclab20></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$list(text)</span></div></h3> This mark allows to create a list. The argument <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> must be a sequence of <em>items</em>, | |
| 265 | - i.e. texts which are all beginning by the mark <a rel="tag" href="#item"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$item</span></a>. | |
| 274 | + <a id="list"></a><a id=toclab21></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$list(<div style="display: inline; color: rgb(0,80,0)"><items></div>)</span></div></h3> This mark allows to create a list. The argument <div style="display: inline; color: rgb(0,80,0)"><items></div> must be a sequence of <em>items</em>, | |
| 275 | + i.e. texts which are all prefixed by the mark <a rel="tag" href="#item"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$item</span></a>. | |
| 266 | 276 | |
| 267 | - <a id="lpar"></a><a id=toclab21></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$lpar</span></div></h3> This mark inserts a left (opening) parenthese into the text. You must use <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$lpar</span> and/or | |
| 277 | + <a id="lpar"></a><a id=toclab22></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$lpar</span></div></h3> This mark inserts a left (opening) parenthese into the text. You must use <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$lpar</span> and/or | |
| 268 | 278 | <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$rpar</span> if you want to introduce unbalanced parentheses within an argument of a mark. |
| 269 | 279 | |
| 270 | - <a id="mailto"></a><a id=toclab22></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$mailto(address)(text)</span></div></h3> This marks, which appears as <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span>, | |
| 280 | + <a id="mailto"></a><a id=toclab23></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$mailto(<div style="display: inline; color: rgb(0,80,0)"><address></div>)(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> This marks, which appears as <div style="display: inline; color: rgb(0,80,0)"><text></div>, | |
| 271 | 281 | creates a link which is supposed, in the HTML case, to open your mail agent in order to let you |
| 272 | - send an email to the indicated <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">address</div></span>. In the PDF case, the <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">address</div></span> is just indicated between parentheses | |
| 273 | - beside <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span>. | |
| 282 | + send an email to the indicated <div style="display: inline; color: rgb(0,80,0)"><address></div>. In the PDF case, the <div style="display: inline; color: rgb(0,80,0)"><address></div> is just indicated between parentheses | |
| 283 | + beside <div style="display: inline; color: rgb(0,80,0)"><text></div>. | |
| 274 | 284 | For example, |
| 275 | 285 | <br><center><table style="color: inherit; font-size: inherit;"><tr><td><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$blue($mailto(XZ32@planet.mars)(the martian))</span></td></tr></table></center><br> produces: |
| 276 | 286 | <div style="display: inline; color: rgb(0,0,200)"><a href="mailto:XZ32@planet.mars">the martian</a></div> |
| 277 | 287 | |
| 278 | - <a id="note"></a><a id=toclab23></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$note(text)</span></div></h3> This mark produces a footnote containing <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span>. | |
| 288 | + <a id="note"></a><a id=toclab24></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$note(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> This mark produces a footnote containing <div style="display: inline; color: rgb(0,80,0)"><text></div>. | |
| 279 | 289 | In the case of <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px">/PDF this is a usual |
| 280 | 290 | footnote. In the case of HTML, this is a popup which appears at the bottom of the browser's window when the mouse |
| 281 | 291 | passes over this indication : <div class="dropdown"> |
| 282 | 292 | <span>(<sup>note</sup>)</span> |
| 283 | 293 | <div class="drp-content" style="font-size:10px; width:500; padding: 6px 6px 6px 6px;">Here is the note !</div></div>. Try it ! |
| 284 | 294 | |
| 285 | - <a id="par"></a><a id=toclab24></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$par</span></div></h3> This marks generates a line break. You can use several <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$par</span> in order to make some | |
| 295 | + <a id="output"></a><a id=toclab25></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$output(<div style="display: inline; color: rgb(0,80,0)"><file path></div>)(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> This mark does not produce anything in the resulting HTML or PDF files, but outputs | |
| 296 | + <div style="display: inline; color: rgb(0,80,0)"><text></div> (without any modification) into the file <div style="display: inline; color: rgb(0,80,0)"><file path></div>. For security reasons, this mark is not available | |
| 297 | + in the web version of MAML. | |
| 298 | + | |
| 299 | + <a id="par"></a><a id=toclab26></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$par</span></div></h3> This marks generates a line break. You can use several <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$par</span> in order to make some | |
| 286 | 300 | vertical space in your text. |
| 287 | 301 | <br><br> <em>Warning:</em> The MAML parser doesn't take newline characters into account (they are just read as spaces). Hence, |
| 288 | 302 | using <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$par</span> is often necessary. |
| 289 | 303 | |
| 290 | - <a id="ref"></a><a id=toclab25></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ref(name)(text)</span></div></h3> | |
| 304 | + <a id="ref"></a><a id=toclab27></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ref(<div style="display: inline; color: rgb(0,80,0)"><tag></div>)(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> | |
| 291 | 305 | This mark creates an internal hyperlink. When clicked upon, this moves the text |
| 292 | - to the position of the <a rel="tag" href="#label"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$label</span></a> (this is a <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ref</span> !) with the same name. | |
| 306 | + to the position of the <a rel="tag" href="#label"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$label</span></a> (this is a <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$ref</span> !) with the same tag name. | |
| 293 | 307 | |
| 294 | - <a id="rgb"></a><a id=toclab26></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$rgb(color)(text)</span></div></h3> This mark sets the color of characters in <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> to <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">color</div></span>, where | |
| 295 | - <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">color</div></span> has the form of three integers separated by commas, representing the intensities of red, green and blue. | |
| 308 | + <a id="rgb"></a><a id=toclab28></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$rgb(<div style="display: inline; color: rgb(0,80,0)"><color></div>)(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> This mark sets the color of characters in <div style="display: inline; color: rgb(0,80,0)"><text></div> to <div style="display: inline; color: rgb(0,80,0)"><color></div>, where | |
| 309 | + <div style="display: inline; color: rgb(0,80,0)"><color></div> has the form of three integers separated by commas, representing the intensities of red, green and blue. | |
| 296 | 310 | These numbers must be between 0 and 255. For example, |
| 297 | - <br><center><table style="color: inherit; font-size: inherit;"><tr><td><table style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;"><tr><td><pre>$rgb(255,0,0)(the text)</pre></td></tr></table></td></tr></table></center><br> | |
| 311 | + <br><center><table style="color: inherit; font-size: inherit;"><tr><td><pre style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;">$rgb(255,0,0)(the text)</pre></td></tr></table></center><br> | |
| 298 | 312 | produces: |
| 299 | 313 | <br><center><table style="color: inherit; font-size: inherit;"><tr><td><div style="display: inline; color: rgb(255,0,0)">the text</div></td></tr></table></center><br> |
| 300 | 314 | <br> The marks <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$red(...)</span>, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$green(...)</span>, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$blue(...)</span>, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$yellow(...)</span> and |
| 301 | 315 | <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$grey(...)</span> are predefined. |
| 302 | 316 | |
| 303 | - <a id="rpar"></a><a id=toclab27></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$rpar</span></div></h3> This mark inserts a right (closing) parenthese into the text. You must use <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$lpar</span> and/or | |
| 317 | + <a id="rpar"></a><a id=toclab29></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$rpar</span></div></h3> This mark inserts a right (closing) parenthese into the text. You must use <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$lpar</span> and/or | |
| 304 | 318 | <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$rpar</span> if you want to introduce unbalanced parentheses within an argument of a mark. |
| 305 | 319 | |
| 306 | - <a id="section"></a><a id=toclab28></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$section(title)</span></div></h3> This mark defines a <em>section</em> within the text. It is translated into | |
| 307 | - <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><h3><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">title</div></span></h3></span> in HTML and into <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">\section{<span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">title</div></span>}</span> in <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px">, producing a numbered | |
| 308 | - section in the PDF output.<br><br> When it encouters either <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$section</span>, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$subsection</span> or <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$subsubsection</span>, the <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> compiler adds a line to the file with the same name as the source file but with <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">.mamltoc</span> appended. This file contains | |
| 320 | + <a id="section"></a><a id=toclab30></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$section(<div style="display: inline; color: rgb(0,80,0)"><title></div>)</span></div></h3> This mark defines a <em>section</em> within the text. It is translated into | |
| 321 | + <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><h3><div style="display: inline; color: rgb(0,80,0)"><title></div></h3></span> in HTML and into <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">\section{<div style="display: inline; color: rgb(0,80,0)"><title></div>}</span> in <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px">. Sections are automatically numbered. | |
| 322 | + <br><br> When it encouters either <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$section</span>, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$subsection</span> or <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$subsubsection</span>, the <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> compiler adds a line to the file with the same name as the source file but with <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">.mamltoc</span> appended. This file contains | |
| 309 | 323 | marks of the form <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tocsec(label)(text)</span> (and similarly <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tocsubsec</span> and |
| 310 | 324 | <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tocsubsubsec</span>), and it is up to you to define the meaning of these marks. Combined with <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$input</span> this lets |
| 311 | - you make a table of contents for the HTML output. | |
| 325 | + you make a table of contents for the HTML output. Actually, this is how the table of contents of the present tutorial | |
| 326 | + was made. | |
| 312 | 327 | |
| 313 | - <a id="sub"></a><a id=toclab29></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$sub(text)</span></div></h3> This mark lowers <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> and renders it in a smaller size. For example, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">x$sub(1)</span> | |
| 328 | + <a id="sub"></a><a id=toclab31></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$sub(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> This mark lowers <div style="display: inline; color: rgb(0,80,0)"><text></div> and renders it in a smaller size. For example, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">x$sub(1)</span> | |
| 314 | 329 | produces x<sub>1</sub>. |
| 315 | 330 | |
| 316 | - <a id="subsection"></a><a id=toclab30></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$subsection(title)</span></div></h3> This mark defines a <em>subsection</em> within the text. It is translated into | |
| 317 | - <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><h4><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">title</div></span></h4></span> in HTML and into <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">\subsection{<span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">title</div></span>}</span> in <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px">, producing a numbered | |
| 318 | - subsection in the PDF output. | |
| 331 | + <a id="subsection"></a><a id=toclab32></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$subsection(<div style="display: inline; color: rgb(0,80,0)"><title></div>)</span></div></h3> This mark defines a <em>subsection</em> within the text. It is translated into | |
| 332 | + <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><h4><div style="display: inline; color: rgb(0,80,0)"><title></div></h4></span> in HTML and into <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">\subsection{<div style="display: inline; color: rgb(0,80,0)"><title></div>}</span> in <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px">. Subsections are automatically | |
| 333 | + numbered. | |
| 319 | 334 | |
| 320 | - <a id="subsubsection"></a><a id=toclab31></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$subsubsection(title)</span></div></h3> This mark defines a <em>subsubsection</em> within the text. It is translated into | |
| 321 | - <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><h5><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">title</div></span></h5></span> in HTML and into <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">\subsubsection{<span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">title</div></span>}</span> in <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px">, producing a numbered | |
| 322 | - subsubsection in the PDF output. | |
| 335 | + <a id="subsubsection"></a><a id=toclab33></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$subsubsection(<div style="display: inline; color: rgb(0,80,0)"><title></div>)</span></div></h3> This mark defines a <em>subsubsection</em> within the text. It is translated into | |
| 336 | + <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><h5><div style="display: inline; color: rgb(0,80,0)"><title></div></h5></span> in HTML and into <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">\subsubsection{<div style="display: inline; color: rgb(0,80,0)"><title></div>}</span> in <img src="png/fNScTnBA4MH-qH_w0pRfArXeeKE8.png" width="36" height="14" style="vertical-align: -3px">. Subsubsections are automatically | |
| 337 | + numbered. | |
| 323 | 338 | |
| 324 | - <a id="sup"></a><a id=toclab32></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$sup(text)</span></div></h3> This mark raises <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> and renders it in a smaller size. For example, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">x$sup(1)</span> | |
| 339 | + <a id="sup"></a><a id=toclab34></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$sup(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> This mark raises <div style="display: inline; color: rgb(0,80,0)"><text></div> and renders it in a smaller size. For example, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">x$sup(1)</span> | |
| 325 | 340 | produces x<sup>1</sup>. |
| 326 | 341 | |
| 327 | - <a id="tbgc"></a><a id=toclab33></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tbgc(color)(text)</span></div></h3> This mark (<em>text background color</em>) shows <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> over a background of color | |
| 328 | - <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">color</div></span>. For example, | |
| 329 | - <br><center><table style="color: inherit; font-size: inherit;"><tr><td><table style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;"><tr><td><pre>$tbgc(255,200,200)(Some text.)</pre></td></tr></table></td></tr></table></center><br> | |
| 330 | - produces: <div style="display: inline; background-color: rgb(255,200,200); ">Some text.</div> <em>Warning:</em> This will force <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> to be on a single line, so that | |
| 331 | - it is valuable only for very short texts. | |
| 342 | + <a id="tbgc"></a><a id=toclab35></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tbgc(<div style="display: inline; color: rgb(0,80,0)"><color></div>)(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> This mark (<em>text background color</em>) shows <div style="display: inline; color: rgb(0,80,0)"><text></div> over a background of color | |
| 343 | + <div style="display: inline; color: rgb(0,80,0)"><color></div>. For example, | |
| 344 | + <br><center><table style="color: inherit; font-size: inherit;"><tr><td><pre style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;">$tbgc(255,200,200)(Some text.)</pre></td></tr></table></center><br> | |
| 345 | + produces: <div style="display: inline; background-color: rgb(255,200,200); ">Some text.</div> <em>Warning:</em> This will force <div style="display: inline; color: rgb(0,80,0)"><text></div> to be on a single line, so that | |
| 346 | + it is valuable only for very short texts. See also <a rel="tag" href="#code"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$code(...)</span></a>. | |
| 332 | 347 | |
| 333 | - <a id="tlink"></a><a id=toclab34></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tlink(text)(url)</span></div></h3> This mark creates an hypertext link targeting the <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">url</div></span>, and shown as the clickable | |
| 334 | - <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> (which can also be an image). | |
| 348 | + <a id="tlink"></a><a id=toclab36></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tlink(<div style="display: inline; color: rgb(0,80,0)"><text></div>)(<div style="display: inline; color: rgb(0,80,0)"><url></div>)</span></div></h3> This mark creates an hypertext link targeting the <div style="display: inline; color: rgb(0,80,0)"><url></div>, and shown as the clickable | |
| 349 | + <div style="display: inline; color: rgb(0,80,0)"><text></div> (which can also be an image). | |
| 335 | 350 | |
| 336 | - <a id="tt"></a><a id=toclab35></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tt(text)</span></div></h3> This mark renders <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> in fixed width (typewriter) font. It is similar to | |
| 337 | - <a rel="tag" href="#code"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$code(...)</span></a>, with the difference that <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> is put inline instead of as a separate block. | |
| 338 | - For example, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tt(This) is $code(an) example.</span> | |
| 339 | - produces: <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">This</span> is <table style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;"><tr><td><pre>an</pre></td></tr></table> example. | |
| 351 | + <a id="tt"></a><a id=toclab37></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tt(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> This mark renders <div style="display: inline; color: rgb(0,80,0)"><text></div> in fixed width (typewriter) font. It is similar to | |
| 352 | + <a rel="tag" href="#code"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$code(...)</span></a>, with the difference that <div style="display: inline; color: rgb(0,80,0)"><text></div> is put inline instead of as a separate block. | |
| 353 | + For example, <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tt(This) is $code(255,255,255)(an) example.</span> | |
| 354 | + produces: <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">This</span> is <pre style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;">an</pre> example. | |
| 340 | 355 | <br> See also <a rel="tag" href="#code"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$code(...)</span></a> and <a rel="tag" href="#verbatim"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$verbatim(...)</span></a>. |
| 341 | 356 | |
| 342 | - <a id="verbatim"></a><a id=toclab36></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$verbatim(text)</span></div></h3> This marks reproduces its content without any change with two exceptions. | |
| 357 | + <a id="verbatim"></a><a id=toclab38></a><h3><div style="display: inline; color: rgb(220,0,0)"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$verbatim(<div style="display: inline; color: rgb(0,80,0)"><text></div>)</span></div></h3> This marks reproduces its content without any change with two exceptions. | |
| 343 | 358 | Indeed, <strong><div style="display: inline; color: rgb(220,0,0)">MAML</div></strong> marks within |
| 344 | - <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> are not interpreted, except the two marks <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$lpar</span> and <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$rpar</span>, which allows you | |
| 345 | - to produce unbalanced parentheses in <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span> despite the fact that actual parentheses <em>must</em> be | |
| 346 | - balanced in <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;"><div style="display: inline; color: rgb(220,0,0)">text</div></span>. Example: | |
| 347 | - <br> <table style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;"><tr><td><pre>$verbatim( | |
| 359 | + <div style="display: inline; color: rgb(0,80,0)"><text></div> are not interpreted, except the two marks <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$lpar</span> and <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$rpar</span>, which allows you | |
| 360 | + to produce unbalanced parentheses in <div style="display: inline; color: rgb(0,80,0)"><text></div> despite the fact that actual parentheses <em>must</em> be | |
| 361 | + balanced in <div style="display: inline; color: rgb(0,80,0)"><text></div>. Example: | |
| 362 | + <br> <pre style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;">$verbatim( | |
| 348 | 363 | In this ($blue(text))(), ((parentheses) are) $rpar$rpar$lpar balanced. |
| 349 | - )</pre></td></tr></table> | |
| 364 | + )</pre> | |
| 350 | 365 | <br> produces: |
| 351 | 366 | <br><pre> |
| 352 | 367 | In this ($blue(text))(), ((parentheses) are) ))( balanced. |
| 353 | 368 | </pre><br> |
| 354 | 369 | Nevertheless, colors are applied if <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$verbatim(...)</span> is within a <span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$rgb(...)(...)</span>. Indeed, |
| 355 | - <table style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;"><tr><td><pre>$rgb(255,0,0)($verbatim(Red verbatim text))</pre></td></tr></table> | |
| 370 | + <pre style="color: inherit; font-size: inherit; background-color: rgb(255,255,255); width: 600px;">$rgb(255,0,0)($verbatim(Red verbatim text))</pre> | |
| 356 | 371 | produces: |
| 357 | 372 | <div style="display: inline; color: rgb(255,0,0)"><br><pre>Red verbatim text</pre><br></div> |
| 358 | 373 | <br> See also <a rel="tag" href="#code"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$code(...)</span></a> and <a rel="tag" href="#tt"><span style="font-family:'Lucida Console', monospace; font-size:inherit; font-style: normal;">$tt(...)</span></a>. |
| ... | ... | @@ -363,4 +378,5 @@ $red(define) $blue(Int) |
| 363 | 378 | |
| 364 | 379 | |
| 365 | 380 | |
| 381 | + | |
| 366 | 382 | </div></td></tr></table></center></body></html> |
| 367 | 383 | \ No newline at end of file | ... | ... |
anubis_dev/library/doc_tools/maml3_tutorial.maml.pdf
No preview for this file type
anubis_dev/library/network/metaprotocol.anubis
| ... | ... | @@ -34,12 +34,28 @@ public type Protocol:... |
| 34 | 34 | states are always of opposite kinds. |
| 35 | 35 | |
| 36 | 36 | |
| 37 | - | |
| 38 | - | |
| 39 | - | |
| 40 | - | |
| 41 | - | |
| 42 | - | |
| 37 | + *** Description of a state. | |
| 38 | + | |
| 39 | + Execution in a given state (should it be a server state or a client state) is as follows: | |
| 40 | + | |
| 41 | + - for the initial state (on one side only): | |
| 42 | + -- create a first state and send the initial message. | |
| 43 | + | |
| 44 | + - for all other states: | |
| 45 | + -- wait for the message, | |
| 46 | + -- apply a function to this message and the previous state. This function returns either: | |
| 47 | + - a pair made of the message to be sent and a new state (in this case, send the message), or | |
| 48 | + - nothing (in this case, close the connection). | |
| 49 | + | |
| 50 | +public type ProtocolState: | |
| 51 | + initial (String state_name, | |
| 52 | + List(String) state_types, | |
| 53 | + List(String) initial_values, | |
| 54 | + String function_name), | |
| 55 | + | |
| 56 | + other (String state_name, | |
| 57 | + List(String) state_names, | |
| 58 | + String function_name). | |
| 43 | 59 | |
| 44 | 60 | |
| 45 | 61 | ... | ... |
anubis_dev/library/predefined.anubis
| ... | ... | @@ -4612,7 +4612,8 @@ public define SQLite3QueryResult |
| 4612 | 4612 | *** (13) Fast lexical analysis. |
| 4613 | 4613 | |
| 4614 | 4614 | We provide a small tool for compiling lexers described using lists into 'fast |
| 4615 | - lexers'. Here we have only low level tools. High level tools (to be used preferably) | |
| 4615 | + lexers'. Here we have only low level tools. High level tools, including an LEX/FLEX-like algorithm | |
| 4616 | + for constructing a low level lexer from a set of regular expressions (to be used preferably) | |
| 4616 | 4617 | are in 'library/lexical_analysis/'. |
| 4617 | 4618 | |
| 4618 | 4619 | |
| ... | ... | @@ -4620,7 +4621,7 @@ public define SQLite3QueryResult |
| 4620 | 4621 | |
| 4621 | 4622 | A 'lexer' is an automaton made of 'states' and 'transitions'. To each state is |
| 4622 | 4623 | attached a set of 'transitions' (having this state as their 'source state'). A |
| 4623 | - transition is a pair made of a character (Word8) and a state (Word16) (the 'target' | |
| 4624 | + transition is a pair made of a character (Word8) and a state name (Word16) (the 'target' | |
| 4624 | 4625 | state for this transition). |
| 4625 | 4626 | |
| 4626 | 4627 | public type FastLexerTransition: |
| ... | ... | @@ -4630,7 +4631,9 @@ public type FastLexerTransition: |
| 4630 | 4631 | There are three sorts of states: 'accepting' states, 'rejecting' states and 'ignoring' |
| 4631 | 4632 | states. By convention, the lexer returns a result if it cannot read more in an |
| 4632 | 4633 | accepting or rejecting state, and restarts from state 0 (without stopping) if it |
| 4633 | - cannot read more in an ignoring state. | |
| 4634 | + cannot read more in an ignoring state. It also returns when it reaches the end of | |
| 4635 | + the input buffer. The automatic reloading of this buffer and restarting of the lexer | |
| 4636 | + is written in 'library/lexical_analysis/fast_lexer_5.anubis'. | |
| 4634 | 4637 | |
| 4635 | 4638 | public type FastLexerState: // description of states (names of states are generated automatically) |
| 4636 | 4639 | rejecting (List(FastLexerTransition) transitions), |
| ... | ... | @@ -4658,11 +4661,11 @@ public type FastLexerState: // description of states (names of states are gene |
| 4658 | 4661 | +---------+ |
| 4659 | 4662 | |
| 4660 | 4663 | The automaton starts in state 0 and reads a character. If it is white it goes to state |
| 4661 | - 2. In this state the automaton ignores the result obtained so far and restarts from | |
| 4662 | - state 0. If it reads a lowercase letter, it goes to state 1, otherwise it rejects the | |
| 4663 | - input. While in state 1, the automaton reads as many lower case letters as possible | |
| 4664 | - and accepts the input. This automaton may be represented as the following datum of | |
| 4665 | - type 'List(FastLexerState)': | |
| 4664 | + 2. In this state (Whixh has no transition) the automaton ignores the result obtained | |
| 4665 | + so far and restarts from state 0. If it reads a lowercase letter, it goes to state 1, | |
| 4666 | + otherwise it rejects the input. While in state 1, the automaton reads as many lower case | |
| 4667 | + letters as possible and accepts the input. This automaton may be represented as the following | |
| 4668 | + datum of type 'List(FastLexerState)': | |
| 4666 | 4669 | |
| 4667 | 4670 | [ |
| 4668 | 4671 | /* state 0 */ |
| ... | ... | @@ -4681,7 +4684,7 @@ public type FastLexerState: // description of states (names of states are gene |
| 4681 | 4684 | |
| 4682 | 4685 | Notice that a state is identified by its rank in the list. The starting state is always state 0. |
| 4683 | 4686 | Also notice that ignoring states may have transitions. Indeed, if we want to |
| 4684 | - detect sequences of at least two 'a' and ignore anything else, we may have an automaton | |
| 4687 | + accept sequences of at least two 'a' and ignore anything else, we may have an automaton | |
| 4685 | 4688 | like this one: |
| 4686 | 4689 | |
| 4687 | 4690 | 'a' 'a' |
| ... | ... | @@ -4704,64 +4707,100 @@ public type FastLexerState: // description of states (names of states are gene |
| 4704 | 4707 | The automaton always tries to read the longuest possible sequence. Hence, transitions |
| 4705 | 4708 | always have precedence over the sort of the state (rejecting, accepting, ignoring). |
| 4706 | 4709 | |
| 4707 | - Of course, it is possible to write down an Anubis function for running this automaton. | |
| 4710 | + Of course, it is possible to write down Anubis functions for running this automaton. | |
| 4708 | 4711 | But this may work quite slowly. This is the reason why we provide a sort of 'compiler' |
| 4709 | 4712 | for this kind of automaton. This 'compiler' produces a 'fast lexer', which is actually |
| 4710 | 4713 | made of two byte arrays which are used as decision and transition tables by an automaton |
| 4711 | - written in C (this is a primitive of the virtual machine). | |
| 4714 | + written in C (which is a single instruction of the virtual machine). | |
| 4712 | 4715 | |
| 4713 | 4716 | Also notice that lexer descriptions as above don't have to be written by hand. They are |
| 4714 | 4717 | generated from sets of regular expressions by Anubis programs that you can find in |
| 4715 | - 'library/lexical_analysis'. | |
| 4718 | + 'library/lexical_analysis/fast_lexer_5.anubis'. | |
| 4716 | 4719 | |
| 4717 | 4720 | |
| 4718 | 4721 | *** (13.2) Compiling a description. |
| 4719 | 4722 | |
| 4720 | - Each (low level) fast lexer is actually a function taking several arguments (see below) | |
| 4721 | - and returning a result of the following type: | |
| 4723 | + Each (low level) fast lexer is actually seen as a function taking several arguments | |
| 4724 | + (see below). | |
| 4722 | 4725 | |
| 4723 | -public type FastLexerOutput: | |
| 4724 | - rejected(Word16 where, Int start, Int end), | |
| 4725 | - accepted(Word16 where, Int start, Int end), | |
| 4726 | - ignored_to_end. | |
| 4726 | + During its execution the fast lexer doesn't return until one of the following conditions is met: | |
| 4727 | 4727 | |
| 4728 | - The lexer tries to accept the longest possible lexeme. Consequently, it remembers the | |
| 4729 | - last position (if any) at which a lexeme was accepted (this is actually the end of | |
| 4730 | - the accepted lexeme not its beginning), and tries to accept a | |
| 4731 | - longer one. If at some point nothing longer can be accepted, the lexer proceeds as | |
| 4732 | - follows: | |
| 4733 | - | |
| 4734 | - (1) there is a last accepted position: it returns: accepted(w,s,e) where 'w' is | |
| 4735 | - the state reached when the lexeme was accepted, 's' and 'e' the starting | |
| 4736 | - and end positions of this last accepted lexeme within the input byte array. | |
| 4737 | - | |
| 4738 | - (2) there is no last accepted position: it returns: rejected(w,s,e) where | |
| 4739 | - 's' and 'e' are the starting and end positions of what has been read, | |
| 4740 | - and where 'w' is the state currently reached. | |
| 4741 | - | |
| 4742 | - If the end of the input is not reached (i.e. if e < length(input_buffer)), the above | |
| 4743 | - must be interpreted textually, i.e. 'accepted' means accepted, and 'rejected' means | |
| 4744 | - rejected. However, if e = length(input_buffer), the result must be different if we | |
| 4745 | - can provide more input. Indeed, a initial segment of an acceptable lexeme can be | |
| 4746 | - non acceptable. In this case, we want to enlarge the input (adding new bytes to | |
| 4747 | - the input buffer, from which only an end is kept) and restart the lexer. This is | |
| 4748 | - done in the high level part ('library/lexical_analysis'). When restarting the lexer, | |
| 4749 | - we must eventually provide a last accepted position, hence the argument 'last_accepted' | |
| 4750 | - of type 'FastLexerLastAccepted', containing (maybe) a position in the source byte | |
| 4751 | - array and a state. | |
| 4752 | - | |
| 4753 | - The lexer returns 'ignored_to_end' when it ignores everything until the end of the input. This | |
| 4754 | - means that it has reached the end of the input, that it has not found any acceptable lexeme | |
| 4755 | - nor any sequence to be rejected. | |
| 4728 | + - (1) no transition is possible and the current state is a not an ignoring state, | |
| 4729 | + - (2) the end of the input is reached (no character to read). | |
| 4730 | + | |
| 4731 | + Notice that if no transition is possible (we have read the longest possible lexeme) and if the current | |
| 4732 | + state is 'ignoring', the lexer doesn't return but instead restarts in state 0. This is the reason | |
| 4733 | + why no action (in the sens of 'fast_lexer_5.anubis') can be attached to an ignoring state. | |
| 4756 | 4734 | |
| 4735 | + Also notice that if in some state 's' a lexeme is accepted, and if there is a possible transition, | |
| 4736 | + the lexer continues to read. However, it is possible that no longer lexeme can be accepted, and in | |
| 4737 | + this case, the lexeme accepted in state 's' must be returned. This is why the lexer maintains a | |
| 4738 | + 'possible last accepted lexeme' of the type below: | |
| 4739 | + | |
| 4757 | 4740 | public type FastLexerLastAccepted: |
| 4758 | - none, | |
| 4759 | - last(Word16 state, | |
| 4760 | - Int position). // position in the input where the last accepted lexeme ends | |
| 4741 | + none, // nothing was previously accepted | |
| 4742 | + last(Word16 state, // something was accepted in this state | |
| 4743 | + Int ending_position). // position in the input buffer where the last accepted lexeme ends | |
| 4744 | + | |
| 4745 | + The starting position of the accepted token is not a component in the alternative 'last' because, | |
| 4746 | + it can be recovered by other means. Also the role of the component 'state' in the alternative 'last' | |
| 4747 | + is mainly to allow the recovering of the corresponding action. | |
| 4748 | + | |
| 4749 | + The type below describes all possible situations when the lexer returns: | |
| 4750 | + | |
| 4751 | +public type FastLexerOutput: | |
| 4752 | + rejected (Word16 where, Int start, Int end), | |
| 4753 | + accepted (Word16 where, Int start, Int end, Int current), | |
| 4754 | + ignored_to_end. | |
| 4755 | + | |
| 4756 | + 'start' and 'end' delimit a sequence of characters in the input buffer, precisely the characters whose | |
| 4757 | + offsets are between 'start' included and 'end' not included. | |
| 4758 | + | |
| 4759 | + Notice that when the lexer is called, a current position of reading is given together with a state. | |
| 4760 | + This is because it can be necessary to resume a reading which was interrupted by the necessity to | |
| 4761 | + reload the input buffer. | |
| 4762 | + | |
| 4763 | + rejected(where,start,end) means: | |
| 4764 | + - nothing was accepted (in particular, there was no 'last accepted') | |
| 4765 | + - the current state is 'where', | |
| 4766 | + - 'start' and 'end' delimit a lexeme which cannot be accepted (to be used in an error message), | |
| 4767 | + - 'end' is also the current position of reading. | |
| 4768 | + In this case, we can know if we are at the end of the input buffer by comparing 'end' with | |
| 4769 | + the length of the buffer. We can also check that 'where' is a rejecting state, which it is necessarily. | |
| 4770 | + The component 'where' is necessary in order to resume reading if we have to reload the buffer. Indeed, | |
| 4771 | + despite the fact that the sequence delimited by 'start' and 'end' was rejected, it is still possible | |
| 4772 | + that it is the beginning of an acceptable token that can be recognized only after the buffer is reloaded. | |
| 4773 | + | |
| 4774 | + accepted(where,start,end,current) means: | |
| 4775 | + - a token is accepted which is delimited by 'start' and 'end', | |
| 4776 | + - 'current' is the current position of reading (it is always greater then or equal to 'end'), | |
| 4777 | + - 'where' is the state which was current when the token was accepted. | |
| 4778 | + In this case, the reason why we need to know the current position of reading is the following. | |
| 4779 | + Assume that "a" is an acceptable token, that "abc" is another acceptable token, but not "ab", and that the last | |
| 4780 | + two bytes of the input are "ab". In other words, "abc" could be accepted after the buffer is reloaded. In | |
| 4781 | + this case, the lexer reads "a" and "b" and is obliged to return because at the end of the input buffer. It | |
| 4782 | + had first accepted "a" as a token, so that there is a last accepted token, and it returns: | |
| 4783 | + | |
| 4784 | + accepted(w,s,e,c) | |
| 4785 | + | |
| 4786 | + where 'w' is the state which was current just at the moment the token "a" was accepted, and where | |
| 4787 | + 's' and 'e' delimit this token "a". In other words, assuming that the length of the buffer is 10, "a" is | |
| 4788 | + at position 8 and "b" at position 9. We have 's' = 8 and 'e' = 9. But we also have 'current' = 10, because | |
| 4789 | + the buffer was read to its end. Here, we need to know 'current' because if we knew only 'end', we could not | |
| 4790 | + know that the buffer must be reloaded. Notice that despite the fact that the lexer returns accepted, the state | |
| 4791 | + reached after reading "b" is rejecting. However, the state 'w' is an accepting state because it is the state | |
| 4792 | + which was current just after reading "a". | |
| 4793 | + | |
| 4794 | + ignored_to_end means: | |
| 4795 | + The lexer did not accept not reject anything but saw only tokens to be ignored (maybe many of them, since | |
| 4796 | + it doesn't return when ignoring tokens), and reached the end of the input buffer. | |
| 4761 | 4797 | |
| 4798 | + The above informations were of course essential for the writting of 'library/fast_lexer_5.anubis'. | |
| 4799 | + | |
| 4762 | 4800 | Now, here is the tool for making a fast lexer. First, the return type of 'make_fast_lexer': |
| 4763 | 4801 | |
| 4764 | 4802 | public type MakeFastLexerResult: |
| 4803 | + // error conditions: | |
| 4765 | 4804 | unknown_state(Word16), // found a transition to a non existing state |
| 4766 | 4805 | too_many_states, // maximum is 65530 |
| 4767 | 4806 | // otherwise, the fast lexer itself (this is a function discussed below): |
| ... | ... | @@ -4787,28 +4826,31 @@ public define MakeFastLexerResult |
| 4787 | 4826 | -> FastLexerOutput |
| 4788 | 4827 | |
| 4789 | 4828 | The arguments are: - the input buffer |
| 4790 | - - the state into which a token has been previously accepted (if any) together | |
| 4791 | - with the position (within the buffer) where this token ends | |
| 4792 | - - the current position of reading within the buffer (where to start reading) | |
| 4793 | - - the position where the currently read token starts within the buffer | |
| 4794 | - (actually, this is always 0 when we call this function in | |
| 4795 | - 'library/lexical_analysis/fast_lexer_2.anubis', this is due to how the | |
| 4796 | - buffer is reloaded) | |
| 4797 | - - the state at which reading must begin | |
| 4829 | + - a possible last accepted token position | |
| 4830 | + - the current position of reading within the buffer (where to resume reading) | |
| 4831 | + - the position where the currently read token candidate starts within the buffer | |
| 4832 | + - the state into which to resume reading | |
| 4833 | + | |
| 4834 | + 'token_start' is where the currently read token begins in the input buffer. Actually, this will be actual | |
| 4835 | + beginning of the returned token if a token is recognized and if nothing is ignored before a token is recognized. | |
| 4836 | + If nothing is ignored, this will be the beginning of either a recognized token or of a rejected lexeme. | |
| 4798 | 4837 | |
| 4799 | - The reason for this is mainly that when the low level lexer is called again, a token may have been already | |
| 4800 | - partially read. For example, we can have this ("abracad" was already read by a previous call): | |
| 4838 | + The reason for the above arguments is mainly that when the low level lexer is called again, a token | |
| 4839 | + was maybe already partially read. For example, we can have this ("abracad" was already read by a previous call): | |
| 4801 | 4840 | |
| 4802 | - "abracadabra ..." | |
| 4803 | - ^ ^ ^ | |
| 4804 | - | | | | |
| 4841 | + "abracadabrantesque ..." | |
| 4842 | + ^ ^ ^ ^ | |
| 4843 | + | | | | | |
| 4844 | + | | | c | |
| 4805 | 4845 | | | reading position |
| 4806 | 4846 | | last accepted |
| 4807 | 4847 | start of token currently read |
| 4808 | 4848 | |
| 4809 | 4849 | which means that we have already read "abracad", that "abra" was accepted (that "abrac", "abraca" and "abracad" |
| 4810 | 4850 | were not accepted) and that we restart reading after "abracad". If we cannot accept a token longer |
| 4811 | - than "abra", accepted(s,0,4) will be returned. | |
| 4851 | + than "abra", accepted(s,0,4,c) will be returned (where c is the curent position of reading when the call returns) | |
| 4852 | + and at the next call, we have to read form position 'last_accepted' in the state 's' which was current when this | |
| 4853 | + token was accepted). | |
| 4812 | 4854 | |
| 4813 | 4855 | |
| 4814 | 4856 | *** (13.3) Precompiled fast lexers. |
| ... | ... | @@ -4840,7 +4882,7 @@ public define PrecompiledFastLexerResult |
| 4840 | 4882 | stored into a file for example, or send accross the network. It is also possible to |
| 4841 | 4883 | transform a precomplied fast lexer into an Anubis source text, since there is the |
| 4842 | 4884 | { ... } notation for 'lexical' byte arrays. This possibility is used |
| 4843 | - in 'library/lexical_analysis/fast_lexer_2.anubis'. | |
| 4885 | + in 'library/lexical_analysis/fast_lexer_5.anubis'. | |
| 4844 | 4886 | |
| 4845 | 4887 | For retrieving a fast lexer from a precompiled fast lexer, use the following: |
| 4846 | 4888 | ... | ... |
anubis_dev/library/syntactic_analysis/anubis_output.anubis
| ... | ... | @@ -27,7 +27,7 @@ |
| 27 | 27 | *Public* |
| 28 | 28 | |
| 29 | 29 | read common.anubis |
| 30 | -read tools/streams.anubis | |
| 30 | +read tools/streams.anubis | |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | |
| ... | ... | @@ -1013,6 +1013,17 @@ define One |
| 1013 | 1013 | |
| 1014 | 1014 | |
| 1015 | 1015 | *** [3.1.5] Outputing the parser function. |
| 1016 | + | |
| 1017 | +define String | |
| 1018 | + comma_extra | |
| 1019 | + ( | |
| 1020 | + Maybe(Extra) mb_extra | |
| 1021 | + ) = | |
| 1022 | + if mb_extra is | |
| 1023 | + { | |
| 1024 | + failure then "", | |
| 1025 | + success(e) then ","+name(e) | |
| 1026 | + }. | |
| 1016 | 1027 | |
| 1017 | 1028 | define One |
| 1018 | 1029 | print_parser_function |
| ... | ... | @@ -1054,8 +1065,8 @@ define One |
| 1054 | 1065 | print(s," error(e) then error(e),\n"); |
| 1055 | 1066 | print(s," end_ret(r) then if r is start(value)\n"); |
| 1056 | 1067 | print(s," then ok(value)\n"); |
| 1057 | - print(s," else should_not_happen(error(syntactic(eof(unique),[]))),\n"); | |
| 1058 | - print(s," do_ret(_) then should_not_happen(error(syntactic(eof(unique),[])))\n"); | |
| 1068 | + print(s," else should_not_happen(error(syntactic(end_of_input(unique),[]"+comma_extra(mb_extra)+"))),\n"); | |
| 1069 | + print(s," do_ret(_) then should_not_happen(error(syntactic(end_of_input(unique),[]"+comma_extra(mb_extra)+")))\n"); | |
| 1059 | 1070 | print(s," }."). |
| 1060 | 1071 | |
| 1061 | 1072 | |
| ... | ... | @@ -1084,19 +1095,48 @@ define One |
| 1084 | 1095 | |
| 1085 | 1096 | *** [3.2] Outputing the declaration of the function 'vmsg'. |
| 1086 | 1097 | |
| 1087 | - When the 'trace' option is used, APG outputs terms of the form 'vmsg("..."). These | |
| 1098 | + When the 'trace' option is used, APG outputs terms of the form 'vmsg("...")' or 'vmsg(extra,"...")'. These | |
| 1088 | 1099 | terms send messages which allow to follow the behavior of the parser. This is used only |
| 1089 | 1100 | for debugging purpose. The function 'vmsg' must be provided by the user. The next |
| 1090 | 1101 | function outputs the declaration of 'vmsg'. |
| 1091 | 1102 | |
| 1103 | +define String | |
| 1104 | + vmsgea // vmsg extra argument declaration | |
| 1105 | + ( | |
| 1106 | + Maybe(Extra) mb_e | |
| 1107 | + ) = | |
| 1108 | + if mb_e is | |
| 1109 | + { | |
| 1110 | + failure then "", | |
| 1111 | + success(e) then if e is extra(type,name) then type+" "+name+", " | |
| 1112 | + }. | |
| 1113 | + | |
| 1114 | +define String | |
| 1115 | + vmsgen // vmsg extra name | |
| 1116 | + ( | |
| 1117 | + Maybe(Extra) mb_e | |
| 1118 | + ) = | |
| 1119 | + if mb_e is | |
| 1120 | + { | |
| 1121 | + failure then "", | |
| 1122 | + success(e) then if e is extra(type,name) then name+", " | |
| 1123 | + }. | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1092 | 1127 | define One |
| 1093 | 1128 | print_vmsg_declaration |
| 1094 | 1129 | ( |
| 1095 | - Stream s | |
| 1130 | + Stream s, | |
| 1131 | + Maybe(Extra) mb_extra | |
| 1096 | 1132 | ) = |
| 1097 | 1133 | print(s, |
| 1098 | 1134 | "\n\n Declaration of 'vmsg'. This function must be provided by the user of APG. "); |
| 1099 | - print(s,"\n\ndefine One vmsg(String text)."). | |
| 1135 | + print(s,if mb_extra is | |
| 1136 | + { | |
| 1137 | + failure then "\n\ndefine One vmsg(String text).", | |
| 1138 | + success(e) then "\n\ndefine One vmsg("+vmsgea(mb_extra)+"String text)." | |
| 1139 | + }). | |
| 1100 | 1140 | |
| 1101 | 1141 | |
| 1102 | 1142 | |
| ... | ... | @@ -1167,7 +1207,7 @@ define One |
| 1167 | 1207 | [ ] then |
| 1168 | 1208 | print(s," ) =\n"); |
| 1169 | 1209 | (if trace:options |
| 1170 | - then print(s," vmsg(\"Reducing using rule "+to_decimal(id)+"\");\n") | |
| 1210 | + then print(s," vmsg("+vmsgen(mb_extra)+"\"Reducing using rule "+to_decimal(id)+"\");\n") | |
| 1171 | 1211 | else unique); |
| 1172 | 1212 | print(s," end_ret("+name+"("+val+")).\n"), |
| 1173 | 1213 | |
| ... | ... | @@ -1175,7 +1215,7 @@ define One |
| 1175 | 1215 | print_reduce_function_args(s,reverse(body),type_table); |
| 1176 | 1216 | print(s," ) =\n"); |
| 1177 | 1217 | (if trace:options |
| 1178 | - then print(s," vmsg(\"Reducing using rule "+to_decimal(id)+"\");\n") | |
| 1218 | + then print(s," vmsg("+vmsgen(mb_extra)+"\"Reducing using rule "+to_decimal(id)+"\");\n") | |
| 1179 | 1219 | else unique); |
| 1180 | 1220 | print(s," "+put_do_ret(name+"("+val+")", |
| 1181 | 1221 | length(symbols_only(body)))+".\n") |
| ... | ... | @@ -1423,13 +1463,13 @@ define One |
| 1423 | 1463 | [h . t] then |
| 1424 | 1464 | print(s,"\n "+right_pad(h+"(value)",30)+" then"); |
| 1425 | 1465 | (if trace:options |
| 1426 | - then print(s,"\n vmsg(\"Got a '"+h+"'\");") | |
| 1466 | + then print(s,"\n vmsg("+vmsgen(mb_extra)+"\"Got a '"+h+"'\");") | |
| 1427 | 1467 | else unique); |
| 1428 | 1468 | if find_transition(h,transitions) is |
| 1429 | 1469 | { |
| 1430 | 1470 | failure then if (state_id = 0 & h = "start") |
| 1431 | 1471 | then print(s," end_ret(start(value))") |
| 1432 | - else print(s," should_not_happen(error(syntactic(eof(unique),[])))"), | |
| 1472 | + else print(s," should_not_happen(error(syntactic(end_of_input(unique),[]"+comma_extra(mb_extra)+")))"), | |
| 1433 | 1473 | |
| 1434 | 1474 | success(target_id) then |
| 1435 | 1475 | with n = length(get_longuest_stack_for(h,scs)), |
| ... | ... | @@ -1488,7 +1528,7 @@ define One |
| 1488 | 1528 | print_restart_args(s,stack,type_table,0); |
| 1489 | 1529 | print(s,"\n ) ="); |
| 1490 | 1530 | (if trace:options |
| 1491 | - then unique // print(s,"\n vmsg(\"Restarting\");") | |
| 1531 | + then unique // print(s,"\n vmsg("+vmsgen(mb_extra)+"\"Restarting\");") | |
| 1492 | 1532 | else unique); |
| 1493 | 1533 | print(s,"\n if result is"); |
| 1494 | 1534 | print(s,"\n {"); |
| ... | ... | @@ -1627,9 +1667,9 @@ define One |
| 1627 | 1667 | if find_reduction(token,scs) is |
| 1628 | 1668 | { |
| 1629 | 1669 | failure then (if trace:options |
| 1630 | - then print(s," vmsg(\"Unexpected token '"+token+"'\");\n") | |
| 1670 | + then print(s," vmsg("+vmsgen(mb_extra)+"\"Unexpected token '"+token+"'\");\n") | |
| 1631 | 1671 | else unique); |
| 1632 | - print(s," error(syntactic(next,token_list_"+state_id+"))"), | |
| 1672 | + print(s," error(syntactic(next,token_list_"+state_id+comma_extra(mb_extra)+"))"), | |
| 1633 | 1673 | |
| 1634 | 1674 | success(sc) then if sc is scenario(rid,_,bd,_,_,_,_) then |
| 1635 | 1675 | print(s,"\n unput_token(input)(next);\n"); |
| ... | ... | @@ -1707,7 +1747,7 @@ define One |
| 1707 | 1747 | failure then print_reduce_body(s,tok1,scs,state_id,options,mb_extra), |
| 1708 | 1748 | success(target_state_id) then |
| 1709 | 1749 | (if trace:options |
| 1710 | - then print(s," vmsg(\"Shifting token '"+tok1+"'\");\n") | |
| 1750 | + then print(s," vmsg("+vmsgen(mb_extra)+"\"Shifting token '"+tok1+"'\");\n") | |
| 1711 | 1751 | else unique); |
| 1712 | 1752 | with n = length(get_longuest_stack_for(tok1,scs)), |
| 1713 | 1753 | print(s,"\n if state_"+target_state_id+"("+ |
| ... | ... | @@ -1730,10 +1770,10 @@ define One |
| 1730 | 1770 | }+"input,value1"+ |
| 1731 | 1771 | (if m = 0 then "" else ",")+ |
| 1732 | 1772 | format_restart_case_args(m-1)+"),\n") |
| 1733 | - else print(s," end_ret(value1) then should_not_happen(error(syntactic(eof(unique),[]))),\n")); | |
| 1773 | + else print(s," end_ret(value1) then should_not_happen(error(syntactic(end_of_input(unique),[]"+comma_extra(mb_extra)+"))),\n")); | |
| 1734 | 1774 | print(s," do_ret(value1) then "); |
| 1735 | 1775 | (if trace:options |
| 1736 | - then unique //print(s,"vmsg(\"Ignoring state "+state_id+ | |
| 1776 | + then unique //print(s,"vmsg("+vmsgen(mb_extra)+"\"Ignoring state "+state_id+ | |
| 1737 | 1777 | // "\");\n ") |
| 1738 | 1778 | else unique); |
| 1739 | 1779 | print(s,"value1\n"); |
| ... | ... | @@ -1788,14 +1828,14 @@ define One |
| 1788 | 1828 | print_state_function_beginning(s,state_id,parser_name,symbols_only(stack),type_table,mb_extra); |
| 1789 | 1829 | print(s," =\n"); |
| 1790 | 1830 | (if trace:options |
| 1791 | - then print(s," vmsg(\"Entering state "+state_id+"\");\n") | |
| 1831 | + then print(s," vmsg("+vmsgen(mb_extra)+"\"Entering state "+state_id+"\");\n") | |
| 1792 | 1832 | else unique); |
| 1793 | 1833 | if has_immediate_action(scs) is |
| 1794 | 1834 | { |
| 1795 | 1835 | failure then unique, |
| 1796 | 1836 | success(text) then print(s," // immediate action\n"); |
| 1797 | 1837 | (if trace:options |
| 1798 | - then print(s," vmsg(\"Executing immediate command: "+ | |
| 1838 | + then print(s," vmsg("+vmsgen(mb_extra)+"\"Executing immediate command: "+ | |
| 1799 | 1839 | inhibit_double_quotes(text)+"\");\n") |
| 1800 | 1840 | else unique); |
| 1801 | 1841 | print(s," ("+text+");\n") |
| ... | ... | @@ -1806,7 +1846,7 @@ define One |
| 1806 | 1846 | print(s," ok(next) then "); |
| 1807 | 1847 | ( |
| 1808 | 1848 | if trace:options |
| 1809 | - then unique // print(s,"vmsg(\"Reading token: '\"+token_name_"+parser_name+"(next)+\"'\");\n ") | |
| 1849 | + then unique // print(s,"vmsg("+vmsgen(mb_extra)+"\"Reading token: '\"+token_name_"+parser_name+"(next)+\"'\");\n ") | |
| 1810 | 1850 | else unique |
| 1811 | 1851 | ); |
| 1812 | 1852 | print(s,"if next is\n"); |
| ... | ... | @@ -1872,13 +1912,21 @@ define One |
| 1872 | 1912 | define One |
| 1873 | 1913 | print_apg_error_type |
| 1874 | 1914 | ( |
| 1875 | - Stream s, | |
| 1876 | - String parser_name | |
| 1915 | + Stream s, | |
| 1916 | + String parser_name, | |
| 1917 | + Maybe(Extra) mb_extra | |
| 1877 | 1918 | ) = |
| 1878 | 1919 | print(s,"\n\npublic type APG_Error_"+parser_name+"($LE):\n"); |
| 1879 | 1920 | print(s," lexical ($LE lexical_error),\n"); |
| 1880 | 1921 | print(s," syntactic (Token_Value_"+parser_name+" token_read,\n"); |
| 1881 | - print(s," List(Token_"+parser_name+") expected).\n"). | |
| 1922 | + if mb_extra is | |
| 1923 | + { | |
| 1924 | + failure then | |
| 1925 | + print(s," List(Token_"+parser_name+") expected).\n") | |
| 1926 | + success(e) then | |
| 1927 | + print(s," List(Token_"+parser_name+") expected,\n"); | |
| 1928 | + print(s," "+type(e)+" "+name(e)+").\n") | |
| 1929 | + }. | |
| 1882 | 1930 | |
| 1883 | 1931 | |
| 1884 | 1932 | |
| ... | ... | @@ -1997,7 +2045,7 @@ define One |
| 1997 | 2045 | mb_extra, |
| 1998 | 2046 | postambule) then |
| 1999 | 2047 | with non_terminals = (List(String))["start" . all_non_terminals(rules)], |
| 2000 | - all_tokens = (List(String))["eof" . all_symbols(rules) - non_terminals], | |
| 2048 | + all_tokens = (List(String))["end_of_input" . all_symbols(rules) - non_terminals], | |
| 2001 | 2049 | prec_table = make_precedence_table(prec_decs), |
| 2002 | 2050 | assoc_table = make_association_table(prec_decs), |
| 2003 | 2051 | _A = if get_rule(1,rules) is grammar_rule(_,_A,_,_) then _A, |
| ... | ... | @@ -2023,9 +2071,17 @@ define One |
| 2023 | 2071 | print(s,private_preambule); |
| 2024 | 2072 | print(s,"\n --- End of private preambule ---\n"); |
| 2025 | 2073 | |
| 2026 | - print(ds,"\n\npublic type Token_"+parser_name+":..."); | |
| 2027 | - print(ds,"\npublic type Token_Value_"+parser_name+":...\n"); | |
| 2028 | - print(ds,"\npublic type APG_Error_"+parser_name+"($LE):...\n"); | |
| 2074 | + //print(ds,"\n\npublic type Token_"+parser_name+":..."); | |
| 2075 | + //print(ds,"\npublic type Token_Value_"+parser_name+":...\n"); | |
| 2076 | + //print(ds,"\npublic type APG_Error_"+parser_name+"($LE):...\n"); | |
| 2077 | + print(ds,"\n\n The type of tokens without the values:"); | |
| 2078 | + print_token_type(ds,parser_name,all_tokens); | |
| 2079 | + | |
| 2080 | + print(ds,"\n\n The same one with the values:"); | |
| 2081 | + print_token_value_type(ds,parser_name,all_tokens,type_table); | |
| 2082 | + | |
| 2083 | + print(ds,"\n\n A type for lexical and syntactic errors:"); | |
| 2084 | + print_apg_error_type(ds,parser_name,mb_extra); | |
| 2029 | 2085 | |
| 2030 | 2086 | if mb_properties is |
| 2031 | 2087 | { |
| ... | ... | @@ -2059,7 +2115,7 @@ define One |
| 2059 | 2115 | print_type_Ret(s,parser_name); |
| 2060 | 2116 | print_Lexer_type(s,parser_name); |
| 2061 | 2117 | |
| 2062 | - (if trace:options then print_vmsg_declaration(s) else unique); | |
| 2118 | + (if trace:options then print_vmsg_declaration(s,mb_extra) else unique); | |
| 2063 | 2119 | |
| 2064 | 2120 | print_reduce_functions(s, |
| 2065 | 2121 | [grammar_rule(0,symbol_value("start","_0"), |
| ... | ... | @@ -2098,15 +2154,6 @@ define One |
| 2098 | 2154 | |
| 2099 | 2155 | print(s,postambule); |
| 2100 | 2156 | |
| 2101 | - print(ds,"\n\n The type of tokens without the values:"); | |
| 2102 | - print_token_type(ds,parser_name,all_tokens); | |
| 2103 | - | |
| 2104 | - print(ds,"\n\n The same one with the values:"); | |
| 2105 | - print_token_value_type(ds,parser_name,all_tokens,type_table); | |
| 2106 | - | |
| 2107 | - print(ds,"\n\n A type for lexical and syntactic errors:"); | |
| 2108 | - print_apg_error_type(ds,parser_name); | |
| 2109 | - | |
| 2110 | 2157 | (if verbose:options |
| 2111 | 2158 | then print("Done. \n") |
| 2112 | 2159 | else unique); | ... | ... |
anubis_dev/library/syntactic_analysis/make_automaton.anubis
| ... | ... | @@ -151,7 +151,7 @@ define List(FirstEntry) |
| 151 | 151 | List(String) tokens, // list of all tokens |
| 152 | 152 | List(String) non_terminals // list of all non terminals |
| 153 | 153 | ) = |
| 154 | - [first_entry("eof",["eof"])] + | |
| 154 | + [first_entry("end_of_input",["end_of_input"])] + | |
| 155 | 155 | map((String s) |-> first_entry(s,[s]),tokens) + |
| 156 | 156 | map((String s) |-> first_entry(s,[ ]),non_terminals). |
| 157 | 157 | |
| ... | ... | @@ -1119,7 +1119,7 @@ define One |
| 1119 | 1119 | |
| 1120 | 1120 | start -> .A |
| 1121 | 1121 | |
| 1122 | - for which the set of lookaheads is ["eof"]. | |
| 1122 | + for which the set of lookaheads is ["end_of_input"]. | |
| 1123 | 1123 | |
| 1124 | 1124 | We must also consider immediate actions (written $(<action>) in a grammar rule) as |
| 1125 | 1125 | transparent. |
| ... | ... | @@ -1160,7 +1160,7 @@ define One |
| 1160 | 1160 | [sc1 . others] then |
| 1161 | 1161 | if sc1 is scenario(_,head,bd,ad,prop,hg,lh_v) then |
| 1162 | 1162 | if (head = "start" & bd = []) |
| 1163 | - then lh_v <- ["eof"] | |
| 1163 | + then lh_v <- ["end_of_input"] | |
| 1164 | 1164 | else add_initial_lookahead(others) |
| 1165 | 1165 | }. |
| 1166 | 1166 | ... | ... |
anubis_dev/library/syntactic_analysis/parser_generator.anubis
| ... | ... | @@ -32,7 +32,7 @@ |
| 32 | 32 | *Description* This is the parser generator itself as a command line tool. It is |
| 33 | 33 | invoked by the following command line: |
| 34 | 34 | |
| 35 | - `apg [options] <filename>` | |
| 35 | + `anbexec apg [options] <filename>` | |
| 36 | 36 | |
| 37 | 37 | The argument `<filename>` is the name of the file containing the grammar. This file |
| 38 | 38 | name normally has the extension `.apg` (for Anubis Parser Generator). The precise | ... | ... |
anubis_dev/library/syntactic_analysis/read_grammar.anubis
| ... | ... | @@ -168,7 +168,7 @@ |
| 168 | 168 | ) = |
| 169 | 169 | if tok is |
| 170 | 170 | { |
| 171 | - eof(_0) then false, | |
| 171 | + end_of_input(_0) then false, | |
| 172 | 172 | ... |
| 173 | 173 | _gaga(_0) then true, |
| 174 | 174 | ... |
| ... | ... | @@ -181,7 +181,7 @@ |
| 181 | 181 | ) = |
| 182 | 182 | if tok is |
| 183 | 183 | { |
| 184 | - eof(_0) then "none", | |
| 184 | + end_of_input(_0) then "none", | |
| 185 | 185 | ... |
| 186 | 186 | _gaga(_0) then "none", |
| 187 | 187 | ... | ... | ... |
anubis_dev/library/tools/ANSI-colors.anubis
| ... | ... | @@ -22,7 +22,9 @@ |
| 22 | 22 | Not all ANSI sequences are supported by all terminals. We made a selection of most common |
| 23 | 23 | and useful things. |
| 24 | 24 | |
| 25 | - | |
| 25 | +read tools/basis.anubis | |
| 26 | +read tools/printable_tree.anubis | |
| 27 | + | |
| 26 | 28 | The following functions can be nested: |
| 27 | 29 | |
| 28 | 30 | Foreground color: |
| ... | ... | @@ -54,7 +56,7 @@ public define String blink (String s). |
| 54 | 56 | public define Printable_tree green (String s). |
| 55 | 57 | public define Printable_tree yellow (String s). |
| 56 | 58 | public define Printable_tree blue (String s). |
| 57 | - public define Printable_tree magenta (String s). | |
| 59 | +public define Printable_tree magenta (Printable_tree t). | |
| 58 | 60 | public define Printable_tree cyan (String s). |
| 59 | 61 | public define Printable_tree white (String s). |
| 60 | 62 | |
| ... | ... | @@ -101,4 +103,21 @@ public define String bold (String s) = "[1m"+s+"[0m". |
| 101 | 103 | public define String blink (String s) = "[5m"+s+"[25m". |
| 102 | 104 | |
| 103 | 105 | |
| 106 | +define Printable_tree | |
| 107 | + map_color | |
| 108 | + ( | |
| 109 | + String -> String color, | |
| 110 | + Printable_tree t | |
| 111 | + ) = | |
| 112 | + if t is | |
| 113 | + { | |
| 114 | + [] then [], | |
| 115 | + str_pt(_0,_1) then [color(_0),map_color(color,_1)], | |
| 116 | + ba_pt(_0,_1) then [color(to_string(_0)),map_color(color,_1)], | |
| 117 | + int_pt(_0,_1) then [color(to_decimal(_0)),map_color(color,_1)], | |
| 118 | + pt_pt(_0,_1) then [map_color(color,_0),map_color(color,_1)] | |
| 119 | + }. | |
| 120 | + | |
| 121 | +public define Printable_tree | |
| 122 | + magenta (Printable_tree t) = map_color(magenta,t). | |
| 104 | 123 | ... | ... |
anubis_dev/library/widgets4/desktop_example.anubis
| ... | ... | @@ -169,7 +169,8 @@ global define One |
| 169 | 169 | with support4 = support(200, 200, my_support("flowers.jpg"), var(show)), |
| 170 | 170 | forget( |
| 171 | 171 | open_host_window( |
| 172 | - transient, | |
| 172 | + //transient, | |
| 173 | + managed(resizable), | |
| 173 | 174 | create_desktop(var(sw),var(sh), |
| 174 | 175 | color(rgb(100,200,0)), |
| 175 | 176 | (One u) |-> u, | ... | ... |
anubis_dev/manuals/en/Anubis-doc-1-14.pdf
No preview for this file type
anubis_dev/manuals/en/Anubis-doc-1-14.tex
| ... | ... | @@ -637,7 +637,7 @@ in the same program written in another language. |
| 637 | 637 | |
| 638 | 638 | How such a safety is achieved is explained in this manual, but the best way to understand |
| 639 | 639 | the reasons why it works is to practice Anubis programming. The safety has several interesting |
| 640 | -consequences. First of all, it is agreable for the programmer because in general he doesn't like | |
| 640 | +consequences. First of all, it is agreable for the programmer because in general the programmer doesn't like | |
| 641 | 641 | to debug. Of course, writting Anubis programs may require some efforts, or at least some forbearance, |
| 642 | 642 | just because the language paradigm of Anubis is more demanding than most other paradigms, but the counterpart is that in most |
| 643 | 643 | cases your program works well after the first successful compilation. So, programming with Anubis is cool. Another |
| ... | ... | @@ -673,6 +673,97 @@ the safety of the Anubis programming paradigm. Hence, it is just forbidden. |
| 673 | 673 | |
| 674 | 674 | |
| 675 | 675 | |
| 676 | +\chapter{Main features of the Anubis programming language} | |
| 677 | +The main objective which led to the creation of the Anubis language is \emph{safety}, in other words a design which | |
| 678 | +forbids programming errors (bugs) as much as possible. This is acheived through several principles. | |
| 679 | + | |
| 680 | + | |
| 681 | +\section{The type system} | |
| 682 | +The most important one is to have a well behaved type system. It is well known that the simple fact of introducing types | |
| 683 | +in a programming language leads to the automatic elimination of many possible errors, typically half of them. It's not | |
| 684 | +difficult to understand why. For example, typing forbids the application of a function to a datum which is meaningless | |
| 685 | +for this function. In general, if you use a non typed language, such an error is detected only during the execution of | |
| 686 | +the program, that is to say at a moment where it's actually \emph{too late}. Detecting such an error at compile time is | |
| 687 | +of course much better. | |
| 688 | + | |
| 689 | +The type system of Anubis is directly comming from the theory of \emph{bicartesian closed categories}. This | |
| 690 | +documentation is not the place for explaining this theory,(\footnote{This theory is explained in full details (but in | |
| 691 | + French) in my Master 2 course in categorical logic ({\tt http://www.logique.jussieu.fr/$\sim$alp/cours\_2010.pdf}), | |
| 692 | + where the link with functional programming languages is explained in section 2.2.6.}) | |
| 693 | +but I'm going to give an idea of it using words which are commonly | |
| 694 | +used by programmers. | |
| 695 | + | |
| 696 | +From a theoretical point of view, there are in Anubis essentially three ways of constructing new types, which are | |
| 697 | +the possibility to define types with \emph{alternatives}, i.e. types containing data of several different types, the | |
| 698 | +possibility of aggregating data of different types (this is similar to the notion of \emph{structure} in the language C), | |
| 699 | + and the possibility to define functional types (types whose data are functions). | |
| 700 | +They correspond | |
| 701 | +to the categorical notions of \emph{sum}, \emph{product} and \emph{exponentials}. A category with products is called | |
| 702 | +\emph{cartesian}, a category with sums is called \emph{cocartesian}, a category with both sums and products is called | |
| 703 | +\emph{bicartesian}, and if furthermore it has exponentials, it is called \emph{bicartesian closed}. | |
| 704 | + | |
| 705 | +The reason why | |
| 706 | +category theory is pertinent as far as programming languages are concerned is that category theory defines concepts | |
| 707 | +by uniquely characterizing their \emph{behavior} instead of explicitely constructing them. This approach implies that the | |
| 708 | +concepts are defined abstractly regardeless of any manner of implementing them, and this ensures that no tool can be | |
| 709 | +forgotten concerning their use, because of this \emph{unique} characterization. Here, by \emph{unique characterization} | |
| 710 | +we mean that that any two realizations of the concept are behavioristically equivalent.(\footnote{The situation is even | |
| 711 | + better than this because category theory shows that this equivalence is \emph{canonical}. Such a characterization | |
| 712 | + is called a \emph{universal problem}.}) | |
| 713 | + | |
| 714 | +It appears that the categorical notion of sum is \emph{dual} to the categorical notion of product. Without entering too | |
| 715 | +many details, it roughly means that a sum is something like \emph{a product seen trough a mirror}. In other words, a sum | |
| 716 | +cannot be more complicated than a product, but because it is seen topsy-turvy, it looks quite strange and more difficult to | |
| 717 | +understand intuitively. Actually, I really think that category theory, because of its natural notion of \emph{duality}, is the only | |
| 718 | +way for really understanding sums, and it is a fact that most programmers, and even most programming language designers, don't | |
| 719 | +actually understand sums. It must be noted that there are sum types in most functionnal programming languages, but that | |
| 720 | +the compilers of these languages don't treat them as categorical sums. | |
| 721 | + | |
| 722 | + | |
| 723 | +\suc | |
| 724 | + | |
| 725 | + | |
| 726 | +\section{Anubis abhors a vacuum} | |
| 727 | +Just like mother nature, Anubis abhors a vacuum. This means that Anubis will never let you create a datum which is only | |
| 728 | +\emph{partly constructed}. The reason is that a partly constructed datum (a datum with missing parts) must be | |
| 729 | +considered as \emph{meaningless}. How Anubis acheives the obligation to construct only \emph{complete} data is simple. | |
| 730 | +The various \emph{parts} needed for constructing the datum must be constructed \emph{before} the datum itself is | |
| 731 | +constructed, and the datum itself is then constructed by a single (atomic) operation. | |
| 732 | + | |
| 733 | +So, in Anubis, you can never have something like a \emph{dandeling reference}, for example a pointer which points to non | |
| 734 | +significant data. In the language C for example, you can create pointers of type {\tt void*}. This means pointers pointing | |
| 735 | +to \emph{nothing}. They are clearly partly defined data, in the sens that they are waiting for a cast which will give | |
| 736 | +them an actual meaning. | |
| 737 | +A C programmer (including myself) uses such a pointer only after a cast to some | |
| 738 | +significant pointer type. This is indeed necessary in C to use such pointers of type {\tt void*} in many situations. | |
| 739 | +However, the reason why it is necessary in C but not in Anubis is that C has no good notion of sum type (C unions are | |
| 740 | + not sum types). | |
| 741 | + | |
| 742 | +As another example, consider a \emph{variable}, i.e. some position in memory where a datum can be written and read. | |
| 743 | +In the language C, you can declare such a variable without giving it an \emph{initial value}. Such an \emph{uninstantiated | |
| 744 | +variable} is of course a meaningless object. It becomes meaningfull only when an actual datum (of the right type) is | |
| 745 | +written into it. | |
| 746 | + | |
| 747 | +In Anubis, there is only one sort of such variables. They are called \emph{dynamic variables} and are created at run | |
| 748 | +time. These variables can be read and written. However, you cannot create such a variable without providing an initial | |
| 749 | +value for it. Thus, a dynamic variable is never incomplete, i.e. there is no vacuum in it. You can also never write into | |
| 750 | +a dynamic variable a datum which is not of the right type (this is actually also the case in C, unless you use a cast). | |
| 751 | + | |
| 752 | +As another example, consider the following function taken from {\tt predefined.anubis}~: | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | +\section{Memory management} | |
| 757 | +Memory managment in Anubis is automatic. You never have to worry about it. This feature was necessary in order to ensure | |
| 758 | +that meaningless data can never be seen in a program. | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 676 | 767 | \chapter{Quick start} |
| 677 | 768 | When you learn a programming language you need to test each new concept immediately. |
| 678 | 769 | Hence, we begin by explaining how to use the Anubis compiler. |
| ... | ... | @@ -3564,7 +3655,7 @@ EXPR(x*y): EXPR(x) times EXPR(y) |
| 3564 | 3655 | Let’s consider for example the rule \cod{EXPR(x+y): EXPR(x) plus EXPR(y).} which was originally written \cod{EXPR: |
| 3565 | 3656 | EXPR plus EXPR.}. We have declared names for the values of some symbols of the body (\cod{EXPR} was replaced |
| 3566 | 3657 | either by \cod{EXPR(x)} or \cod{EXPR(y)}), and we have written a formula \cod{(x+y)} for computing a value for the head of rule. |
| 3567 | -At the time the automaton reduces via this rule, it computes the sum of the values of \cod{x} and \cod{y}, and he result | |
| 3658 | +At the time the automaton reduces via this rule, it computes the sum of the values of \cod{x} and \cod{y}, and the result | |
| 3568 | 3659 | will be the value of the head of rule. |
| 3569 | 3660 | |
| 3570 | 3661 | In this example, of course, we do not construct a syntax tree. We compute only numerical values for the | ... | ... |
anubis_dev/vm/src/anbexec.cpp
| ... | ... | @@ -803,7 +803,7 @@ void schedul(void) |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | /* generate a tick if needed */ |
| 806 | -/* gettimeofday(¤t_time,NULL); | |
| 806 | + gettimeofday(¤t_time,NULL); | |
| 807 | 807 | if (timevalless(&next_tick,¤t_time)) |
| 808 | 808 | { |
| 809 | 809 | #ifdef _WITH_GRAPHISM_ |
| ... | ... | @@ -818,7 +818,7 @@ void schedul(void) |
| 818 | 818 | next_tick.tv_usec -= 1000000; |
| 819 | 819 | } |
| 820 | 820 | } |
| 821 | -*/ | |
| 821 | + | |
| 822 | 822 | #ifdef _WITH_GRAPHISM_ |
| 823 | 823 | /* get all window events and dispatch them to the windows */ |
| 824 | 824 | if (the_primary_module.flags & mf_using_graphism) |
| ... | ... | @@ -955,7 +955,7 @@ void schedul(void) |
| 955 | 955 | waiting_for_completion_machines++; |
| 956 | 956 | |
| 957 | 957 | TheAnubisProcessList->SetRunningProcess(NULL); |
| 958 | - } | |
| 958 | + } // end of the loop running all processes once | |
| 959 | 959 | |
| 960 | 960 | |
| 961 | 961 | if(compute_perf) | ... | ... |
anubis_dev/vm/src/syscall.cpp
| ... | ... | @@ -11975,7 +11975,7 @@ Note: the string is read from the end towards the beginning. */ |
| 11975 | 11975 | |
| 11976 | 11976 | public type FastLexerOutput: |
| 11977 | 11977 | rejected(Word16 where, Int start, Int end), |
| 11978 | - accepted(Word16 where, Int start, Int end), | |
| 11978 | + accepted(Word16 where, Int start, Int end, Int current), | |
| 11979 | 11979 | ignored_to_end. |
| 11980 | 11980 | |
| 11981 | 11981 | */ |
| ... | ... | @@ -12002,7 +12002,17 @@ public type FastLexerOutput: |
| 12002 | 12002 | U32 last_accepted_state = 0; // idem |
| 12003 | 12003 | |
| 12004 | 12004 | #ifdef debug_fast_lexer |
| 12005 | - printf("\nrun_fast_lexer: last_accepted:%d",last_accepted); | |
| 12005 | + // print behaviors: | |
| 12006 | + { | |
| 12007 | + U32 i; | |
| 12008 | + printf("\nBehaviors: (0=rejecting, 1=accepting, 2=ignoring)"); | |
| 12009 | + for(i = 0; i < ((U32*)(*(MAM(m_SP)-1)))[1]; i++) | |
| 12010 | + { | |
| 12011 | + if ((i&15) == 0) printf("\n "); | |
| 12012 | + printf("%d:%d ",i,behaviors[i]); | |
| 12013 | + } | |
| 12014 | + printf("\n"); | |
| 12015 | + } | |
| 12006 | 12016 | #endif |
| 12007 | 12017 | |
| 12008 | 12018 | /* record last accepted position and state (if any). Recall that: |
| ... | ... | @@ -12033,22 +12043,22 @@ public type FastLexerOutput: |
| 12033 | 12043 | |
| 12034 | 12044 | public type FastLexerOutput: |
| 12035 | 12045 | rejected(Word16 where, Int start, Int end), |
| 12036 | - accepted(Word16 where, Int start, Int end), | |
| 12046 | + accepted(Word16 where, Int start, Int end, Int current), | |
| 12037 | 12047 | ignored_to_end. |
| 12038 | 12048 | |
| 12039 | 12049 | |
| 12040 | - * (accepted or rejected) (larges alternatives) | |
| 12050 | + * (accepted or rejected) (largest alternative is 'accepted') | |
| 12041 | 12051 | | |
| 12042 | 12052 | V |
| 12043 | - +---------+-----+-------+-------+ | |
| 12044 | - | cnt |where| start | end | | |
| 12045 | - +---------+-----+-------+-------+ | |
| 12046 | - 0 4 6 10 14 | |
| 12053 | + +---------+-----+-------+-------+-------+ | |
| 12054 | + | cnt |where| start | end | curre | | |
| 12055 | + +---------+-----+-------+-------+-------+ | |
| 12056 | + 0 4 6 10 14 18 | |
| 12047 | 12057 | |
| 12048 | - 14 byte => requires 4 words (16 bytes). | |
| 12058 | + 18 byte => requires 5 words (20 bytes). | |
| 12049 | 12059 | |
| 12050 | 12060 | */ |
| 12051 | - if ((result = MAM(m_R) = MAM(m_allocator)->AllocateDataSegment(4)) == 0) | |
| 12061 | + if ((result = MAM(m_R) = MAM(m_allocator)->AllocateDataSegment(5)) == 0) | |
| 12052 | 12062 | { |
| 12053 | 12063 | MAM(m_status) = need_more_memory; |
| 12054 | 12064 | { MAM(m_steps) = 0; return; } |
| ... | ... | @@ -12144,9 +12154,11 @@ public type FastLexerOutput: |
| 12144 | 12154 | printf("\n*** The lexer (word16_lexer_length:%d) ***\n",word16_lexer_length); |
| 12145 | 12155 | for (i = 0; i < (word16_lexer_length>>8); i ++) |
| 12146 | 12156 | { |
| 12147 | - printf("\n------- state %d ---\n",i); | |
| 12157 | + printf("\n------- state %d (%s) ---\n",i, | |
| 12158 | + behaviors[i]==0 ? "rejecting" : behaviors[i]==1 ? "accepting" : "ignoring"); | |
| 12148 | 12159 | for (j = 32; j < 126; j++) |
| 12149 | - printf("%c:%d ",j,lexer[(i<<8)+j]); | |
| 12160 | + if (lexer[(i<<8)+j] != 65535) | |
| 12161 | + printf("%c:%d ",j,lexer[(i<<8)+j]); | |
| 12150 | 12162 | } |
| 12151 | 12163 | printf("\n"); |
| 12152 | 12164 | fflush(stdout); |
| ... | ... | @@ -12174,7 +12186,8 @@ public type FastLexerOutput: |
| 12174 | 12186 | *((U16 *)(((U8 *)result)+4)) = (U16)last_accepted_state; |
| 12175 | 12187 | *((U32 *)(((U8 *)result)+6)) = (token_start<<2)|1; /* Word32 to Int */ |
| 12176 | 12188 | *((U32 *)(((U8 *)result)+10)) = (last_accepted_position<<2)|1; /* Word32 to Int */ |
| 12177 | - MAM(m_R) |= 1; | |
| 12189 | + *((U32 *)(((U8 *)result)+14)) = (start<<2)|1; /* Word32 to Int */ | |
| 12190 | + MAM(m_R) |= 1; /* accepted */ | |
| 12178 | 12191 | MAM(m_IP) += 1+2; |
| 12179 | 12192 | /* accepted */ |
| 12180 | 12193 | return; |
| ... | ... | @@ -12184,6 +12197,7 @@ public type FastLexerOutput: |
| 12184 | 12197 | *((U16 *)(((U8 *)result)+4)) = (U16)old_state; |
| 12185 | 12198 | *((U32 *)(((U8 *)result)+6)) = (token_start<<2)|1; /* Word32 to Int */ |
| 12186 | 12199 | *((U32 *)(((U8 *)result)+10)) = ((start+1)<<2)|1; /* Word32 to Int */ |
| 12200 | + /* rejected */ | |
| 12187 | 12201 | MAM(m_IP) += 1+2; |
| 12188 | 12202 | /* rejected */ |
| 12189 | 12203 | return; |
| ... | ... | @@ -12193,33 +12207,17 @@ public type FastLexerOutput: |
| 12193 | 12207 | *((U16 *)(((U8 *)result)+4)) = (U16)old_state; |
| 12194 | 12208 | *((U32 *)(((U8 *)result)+6)) = (token_start<<2)|1; /* Word32 to Int */ |
| 12195 | 12209 | *((U32 *)(((U8 *)result)+10)) = (start<<2)|1; /* Word32 to Int */ |
| 12196 | - MAM(m_R) |= 1; | |
| 12210 | + *((U32 *)(((U8 *)result)+14)) = (start<<2)|1; /* Word32 to Int */ | |
| 12211 | + MAM(m_R) |= 1; /* accepted */ | |
| 12197 | 12212 | MAM(m_IP) += 1+2; |
| 12198 | 12213 | /* accepted */ |
| 12199 | 12214 | return; |
| 12200 | 12215 | |
| 12201 | 12216 | case 2: /* ignoring and no transition */ |
| 12202 | - /* inhibited this case because the longest lexeme prevails even if it is to be ignored | |
| 12203 | - and the shortest one accepted. */ | |
| 12204 | -#if 0 | |
| 12205 | - if (has_last_accepted) | |
| 12206 | - { | |
| 12207 | - *((U16 *)(((U8 *)result)+4)) = (U16)last_accepted_state; | |
| 12208 | - *((U32 *)(((U8 *)result)+6)) = (token_start<<2)|1; /* Word32 to Int */ | |
| 12209 | - *((U32 *)(((U8 *)result)+10)) = (last_accepted_position<<2)|1; /* Word32 to Int */ | |
| 12210 | - MAM(m_R) |= 1; | |
| 12211 | - MAM(m_IP) += 1+2; | |
| 12212 | -#ifdef debug_fast_lexer | |
| 12213 | - printf("ignoring no transition with last accepted\n"); fflush(stdout); | |
| 12214 | -#endif | |
| 12215 | - return; | |
| 12216 | - } | |
| 12217 | - else | |
| 12218 | -#endif | |
| 12219 | 12217 | { |
| 12220 | 12218 | /* ignoring and no last accepted: restart from state 0 */ |
| 12221 | 12219 | state = 0; |
| 12222 | - // has_last_accepted = 0; // redondant | |
| 12220 | + has_last_accepted = 0; | |
| 12223 | 12221 | token_start = start; |
| 12224 | 12222 | #ifdef debug_fast_lexer |
| 12225 | 12223 | printf("continuing after ignoring (new token start = %u)\n",start); |
| ... | ... | @@ -12227,7 +12225,8 @@ public type FastLexerOutput: |
| 12227 | 12225 | continue; |
| 12228 | 12226 | } |
| 12229 | 12227 | |
| 12230 | - default: assert(0); | |
| 12228 | + default: printf("state = %d, behaviors[state] = %d\n",state,behaviors[state]); | |
| 12229 | + internal_error("Invalid behavior (should be 0, 1 or 2)\n"); | |
| 12231 | 12230 | } |
| 12232 | 12231 | } |
| 12233 | 12232 | /* we have transited into a new state */ |
| ... | ... | @@ -12256,14 +12255,14 @@ public type FastLexerOutput: |
| 12256 | 12255 | case 0: /* rejecting and at end of input */ |
| 12257 | 12256 | if (has_last_accepted) |
| 12258 | 12257 | { |
| 12259 | - *((U16 *)(((U8 *)result)+4)) = (U16)state; | |
| 12258 | + *((U16 *)(((U8 *)result)+4)) = (U16)last_accepted_state; | |
| 12260 | 12259 | *((U32 *)(((U8 *)result)+6)) = (token_start<<2)|1; /* Word32 to Int */ |
| 12261 | 12260 | *((U32 *)(((U8 *)result)+10)) = (last_accepted_position<<2)|1; /* Word32 to Int */ |
| 12262 | - MAM(m_R) |= 1; | |
| 12261 | + *((U32 *)(((U8 *)result)+14)) = (start<<2)|1; /* Word32 to Int */ | |
| 12262 | + MAM(m_R) |= 1; /* accepted */ | |
| 12263 | 12263 | MAM(m_IP) += 1+2; |
| 12264 | - /* accepted */ | |
| 12265 | 12264 | #ifdef debug_fast_lexer |
| 12266 | - printf("accepting at end of input with last accepted\n"); fflush(stdout); | |
| 12265 | + printf("rejecting state at end of input with last accepted (accepting)\n"); fflush(stdout); | |
| 12267 | 12266 | #endif |
| 12268 | 12267 | return; |
| 12269 | 12268 | } |
| ... | ... | @@ -12284,7 +12283,8 @@ public type FastLexerOutput: |
| 12284 | 12283 | *((U16 *)(((U8 *)result)+4)) = (U16)state; |
| 12285 | 12284 | *((U32 *)(((U8 *)result)+6)) = (token_start<<2)|1; /* Word32 to Int */ |
| 12286 | 12285 | *((U32 *)(((U8 *)result)+10)) = (start<<2)|1; /* Word32 to Int */ |
| 12287 | - MAM(m_R) |= 1; | |
| 12286 | + *((U32 *)(((U8 *)result)+14)) = (start<<2)|1; /* Word32 to Int */ | |
| 12287 | + MAM(m_R) |= 1; /* accepted */ | |
| 12288 | 12288 | MAM(m_IP) += 1+2; |
| 12289 | 12289 | /* accepted */ |
| 12290 | 12290 | #ifdef debug_fast_lexer |
| ... | ... | @@ -12295,10 +12295,11 @@ public type FastLexerOutput: |
| 12295 | 12295 | case 2: /* ignoring state */ |
| 12296 | 12296 | if (has_last_accepted) |
| 12297 | 12297 | { |
| 12298 | - *((U16 *)(((U8 *)result)+4)) = (U16)state; | |
| 12298 | + *((U16 *)(((U8 *)result)+4)) = (U16)last_accepted_state; | |
| 12299 | 12299 | *((U32 *)(((U8 *)result)+6)) = (token_start<<2)|1; /* Word32 to Int */ |
| 12300 | 12300 | *((U32 *)(((U8 *)result)+10)) = (last_accepted_position<<2)|1; /* Word32 to Int */ |
| 12301 | - MAM(m_R) |= 1; | |
| 12301 | + *((U32 *)(((U8 *)result)+14)) = (start<<2)|1; /* Word32 to Int */ | |
| 12302 | + MAM(m_R) |= 1; /* accepted */ | |
| 12302 | 12303 | MAM(m_IP) += 1+2; |
| 12303 | 12304 | /* accepted */ |
| 12304 | 12305 | #ifdef debug_fast_lexer | ... | ... |
-
mentioned in commit e9e8a9fc1aa4ac0cee301997a20afdbf1c6df49f