@x \def\title{WEAVE} \def\contentspagenumber{15} % should be odd @y \def\title{MWEAVE} \def\contentspagenumber{1} % should be odd @z @x @d banner=='This is WEAVE, Version 2.8' @y For the Modula-2 versions of \.{WEAVE}, we add a second decimal point and number to the main version number, so we can differentiate between changes to the standard \.{WEAVE}\ and changes local to \.{MWEAVE}. @d banner=='This is MWEAVE, Modula-2 WEAVE, Version 2.8.0' @z @x @d do_like=9 {\&{do}, \&{of}, \&{then}} @y @d do_like=9 {\&{do}, \&{then}} @z @x @d for_like=12 {\&{for}, \&{while}, \&{with}} @y @d for_like=12 {\&{for}, \&{if}, \&{while}, \&{with}} @z @x @d goto_like=13 {\&{goto}, \&{packed}} @y @d goto_like=13 {\&{implementation}, \&{definition}, \&{packed}} @z @x @d if_like=14 {\&{if}} @y @d if_like=14 {not used for \.{MWEB} --- see |for_like| } @z @x @d proc_like=17 {\&{function}, \&{procedure}, \&{program}} @y @d proc_like=17 {\&{procedure}, \&{module}} @z @x @d to_like=20 {\&{downto}, \&{to}} @d until_like=21 {\&{until}} @y @d to_like=20 {\&{to}} @d until_like=21 {\&{until}, \&{end}} @z @x @d loop_like=23 {\&{loop}, \&{xclause}} @y @d loop_like=23 {\&{loop} } @z @x @d char_like=24 {\&{and}, \&{or}, \&{not}, \&{in}} @y @d elsif_like=24 {\&{elsif} } @d of_like=25 {\&{of} } @d char_like=26 {\&{and}, \&{or}, \&{not}, \&{in}} @z @x We have to get \PASCAL's reserved words into the hash table, and the @y We have to get Modula-2's reserved words into the hash table, and the @z @x @d sid9(#)==buffer[9]:=#;cur_name:=id_lookup @d sid8(#)==buffer[8]:=#;sid9 @d sid7(#)==buffer[7]:=#;sid8 @d sid6(#)==buffer[6]:=#;sid7 @d sid5(#)==buffer[5]:=#;sid6 @d sid4(#)==buffer[4]:=#;sid5 @d sid3(#)==buffer[3]:=#;sid4 @d sid2(#)==buffer[2]:=#;sid3 @d sid1(#)==buffer[1]:=#;sid2 @d id2==id_first:=8; sid8 @d id3==id_first:=7; sid7 @d id4==id_first:=6; sid6 @d id5==id_first:=5; sid5 @d id6==id_first:=4; sid4 @d id7==id_first:=3; sid3 @d id8==id_first:=2; sid2 @d id9==id_first:=1; sid1 @y @d sid14(#)==buffer[14]:=#;cur_name:=id_lookup @d sid13(#)==buffer[13]:=#;sid14 @d sid12(#)==buffer[12]:=#;sid13 @d sid11(#)==buffer[11]:=#;sid12 @d sid10(#)==buffer[10]:=#;sid11 @d sid9(#)==buffer[9]:=#;sid10 @d sid8(#)==buffer[8]:=#;sid9 @d sid7(#)==buffer[7]:=#;sid8 @d sid6(#)==buffer[6]:=#;sid7 @d sid5(#)==buffer[5]:=#;sid6 @d sid4(#)==buffer[4]:=#;sid5 @d sid3(#)==buffer[3]:=#;sid4 @d sid2(#)==buffer[2]:=#;sid3 @d sid1(#)==buffer[1]:=#;sid2 @d id2==id_first:=13; sid13 @d id3==id_first:=12; sid12 @d id4==id_first:=11; sid11 @d id5==id_first:=10; sid10 @d id6==id_first:=9; sid9 @d id7==id_first:=8; sid8 @d id8==id_first:=7; sid7 @d id9==id_first:=6; sid6 @d id10==id_first:=5; sid5 @d id11==id_first:=4; sid4 @d id12==id_first:=3; sid3 @d id13==id_first:=2; sid2 @d id14==id_first:=1; sid1 @z @x id_loc:=10;@/ @y id_loc:=15;@/ @z @x id5("b")("e")("g")("i")("n")(begin_like);@/ @y id5("b")("e")("g")("i")("n")(begin_like);@/ id2("b")("y")(to_like);@/ @z @x id6("d")("o")("w")("n")("t")("o")(to_like);@/ @y id10("d")("e")("f")("i")("n")("i")("t")("i")("o")("n")(goto_like);@/ @z @x id3("e")("n")("d")(end_like);@/ id4("f")("i")("l")("e")(array_like);@/ id3("f")("o")("r")(for_like);@/ id8("f")("u")("n")("c")("t")("i")("o")("n")(proc_like);@/ id4("g")("o")("t")("o")(goto_like);@/ @y id5("e")("l")("s")("i")("f")(elsif_like);@/ id3("e")("n")("d")(end_like);@/ id4("e")("x")("i")("t")(goto_like);@/ id6("e")("x")("p")("o")("r")("t")(goto_like);@/ id3("f")("o")("r")(for_like);@/ id4("f")("r")("o")("m")(goto_like);@/ @z @x id2("i")("f")(if_like);@/ id2("i")("n")(char_like+set_element_sign);@/ id5("l")("a")("b")("e")("l")(const_like);@/ @y id2("i")("f")(for_like);@/ id14("i")("m")("p")("l")("e")("m")("e")("n")("t")("a")("t")("i")("o")("n")(goto_like);@/ id6("i")("m")("p")("o")("r")("t")(goto_like);@/ id2("i")("n")(char_like+set_element_sign);@/ id5("l")("a")("b")("e")("l")(const_like);@/ id4("l")("o")("o")("p")(loop_like);@/ id6("m")("o")("d")("u")("l")("e")(proc_like);@/ @z @x id2("o")("f")(do_like);@/ @y id2("o")("f")(of_like);@/ @z @x id6("p")("a")("c")("k")("e")("d")(goto_like);@/ @y id7("p")("o")("i")("n")("t")("e")("r")(goto_like);@/ @z @x id7("p")("r")("o")("g")("r")("a")("m")(proc_like);@/ @y id9("q")("u")("a")("l")("i")("f")("i")("e")("d")(goto_like);@/ @z @x id6("r")("e")("p")("e")("a")("t")(repeat_like);@/ @y id6("r")("e")("p")("e")("a")("t")(repeat_like);@/ id6("r")("e")("t")("u")("r")("n")(goto_like);@/ @z @x id7("x")("c")("l")("a")("u")("s")("e")(loop_like);@/ @y @z @x @d force_line=@'3 {extended ASCII beta will not appear} @y @d force_line=@'3 {extended ASCII beta will not appear} @d vertical_bar=15 {control code for vertical bar character} @d begin_regular_comment=16 {control code for beginning of comments} @d end_regular_comment=17 {control code for ending of comments} @z @x else if c="{" then incr(bal) else if c="}" then begin decr(bal); if bal=0 then goto done; end @y else if c=begin_regular_comment then incr(bal) else if c=end_regular_comment then begin decr(bal); if bal=0 then goto done; end else if (c="(") and (buffer[loc]="*") then begin incr(bal); incr(loc); end else if (c="*") and (buffer[loc]=")") then begin decr(bal); incr(loc); c:=end_regular_comment; if bal=0 then goto done; end @z @x @ Note that the following code substitutes \.{@@\{} and \.{@@\}} for the respective combinations `\.{(*}' and `\.{*)}'. Explicit braces should be used for \TeX\ comments in \PASCAL\ text. @y @ Note that the following code converts `\.{(*}' and `\.{*)}' to internal characters which are converted back to ASCII when output. Adjacent vertical bar characters (|'||'|), which represent the Modula-2 usage of that character rather than that of WEB, are handled the same way. @z @x "(": if buffer[loc]="*" then compress(begin_comment) else if buffer[loc]="." then compress("["); "*": if buffer[loc]=")" then compress(end_comment); @y "(": if buffer[loc]="*" then compress(begin_regular_comment) else if buffer[loc]="." then compress("["); "*": if buffer[loc]=")" then compress(end_regular_comment); "|": if buffer[loc]="|" then compress(vertical_bar); @z @x if (next_control="|")or(next_control="{") then return; @y if (next_control="|")or(next_control=begin_regular_comment) then return; @z @x if next_control<>"{" then Pascal_xref @y if next_control<>begin_regular_comment then Pascal_xref @z @x `\.{\\input webmac}'. @y `\.{\\input mwebmac}'. @z @x out_ptr:=1; out_line:=1; out_buf[1]:="c"; write(tex_file,'\input webma'); @y out_ptr:=1; out_line:=1; out_buf[1]:="c"; write(tex_file,'\input mwebma'); @z @x if c="|" then goto done; app_tok(c); @y if c="|" then goto done; if (c="*") and (buffer[loc]=")") then begin incr(loc); c:=end_regular_comment; app_tok("}"); end else begin app_tok(c); end; @z @x else if c="{" then incr(bal) else if c="}" then begin decr(bal); if bal=0 then goto done; end @y else if c=begin_regular_comment then incr(bal) else if c=end_regular_comment then begin decr(bal); if bal=0 then goto done; end else if (c="(") and (buffer[loc]="*") then begin incr(bal); incr(loc); end @z @x repeat app_tok("}"); decr(bal); @y repeat app_tok(end_regular_comment); decr(bal); @z @x if (next_control="|")or(next_control="{") then return; @y if (next_control="|")or(next_control=begin_regular_comment) then return; @z @x "#","$","%","^","_": sc2("\")(next_control)(math); @y "$","%","^","_": sc2("\")(next_control)(math); "#": if in_def_part then begin pound_found := true; sc2("\")("#")(math); end else sc2("\")("I")(math); "~": sc2("\")("R")(math); "&": sc2("\")("W")(math); @z @x ignore,"|",xref_roman,xref_wildcard,xref_typewriter: do_nothing; @y ignore,xref_roman,xref_wildcard,xref_typewriter: do_nothing; @z @x ";": sc1(";")(semi); @y ";": sc1(";")(semi); "{": sc2("\")("{")(open); "}": sc2("\")("}")(close); "|",vertical_bar: sc4("\")("V")("B")(force)(semi); @z @x equivalence_sign: sc2("\")("S")(math); @y equivalence_sign: begin sc2("\")("S")(math); if not pound_found then in_def_part := false; end; @z @x do_like,for_like,goto_like,nil_like,to_like: sub_cases(p); @y of_like,for_like,goto_like,nil_like,to_like: sub_cases(p); @z @x do_like: sc1(res_flag+p)(omega); {\&{do}, \&{of}, \&{then}} @y @z @x for_like: sc2(force)(res_flag+p)(alpha); {\&{for}, \&{while}, \&{with}} @y for_like: sc2(force)(res_flag+p)(alpha); {\&{for}, \&{if}, \&{while}, \&{with}} @z @x goto_like: sc1(res_flag+p)(intro); {\&{goto}, \&{packed}} @y goto_like: sc1(res_flag+p)(intro); {\&{packed}} @z @x to_like: sc3(math_rel)(res_flag+p)("}")(math); {\&{downto}, \&{to}} @y of_like: sc1(res_flag+p)(omega); {\&{of} } to_like: sc3(math_rel)(res_flag+p)("}")(math); {\&{to}} @z @x begin_like: begin sc3(force)(res_flag+p)(cancel)(beginning); sc0(intro); end; {\&{begin}} @y begin_like: begin sc4(force)(backup)(res_flag+p)(force)(beginning); sc0(intro); end; {\&{begin}} @z @x else_like: begin @; sc3(force)(backup)(res_flag+p)(elsie); @y do_like: begin sc2(res_flag+p)(force)(omega); sc0(beginning); sc0(intro); end; {\&{do}, \&{then}} elsif_like: begin @; sc0(close); sc0(terminator); sc1(res_flag+p)(alpha); end; else_like: begin sc4(force)(backup)(res_flag+p)(force)(terminator); @z @x end_like: begin @; sc2(force)(res_flag+p)(close); @y end_like: begin @; sc4(force)(backup)(res_flag+p)(break_space)(close); @z @x if_like: begin sc0(cond); sc2(force)(res_flag+p)(alpha); end; {\&{if}} @y @z @x loop_like: begin sc3(force)("\")("~")(alpha); @y loop_like: begin sc1(force)(alpha); @z @x sc1(res_flag+p)(omega); @y sc2(res_flag+p)(force)(omega); sc0(beginning); sc0(intro); @z @x end; {\&{xclause}} @y end; {\&{loop}} @z @x record_like: begin sc1(res_flag+p)(record_head); sc0(intro); end; {\&{record}} @y record_like: begin sc1(res_flag+p)(alpha); sc0(omega); sc0(beginning); end; {\&{record}} @z @x repeat_like: begin sc4(force)(indent)(res_flag+p)(cancel)(beginning); sc0(intro); @y repeat_like: begin sc4(force)(indent)(res_flag+p)(force)(beginning); sc0(intro); @z @x if next_control<>"{" then Pascal_parse @y if next_control<>begin_regular_comment then Pascal_parse @z @x bal:=copy_comment(1); next_control:="|"; @y bal:=copy_comment(1); next_control:=ignore; @z @x if next_control="|" then bal:=copy_comment(bal) @y if next_control="|" then begin next_control := ignore; bal:=copy_comment(bal); end @z @x save_next_control:=next_control; next_control:="|"; p:=Pascal_translate; @y save_next_control:=next_control; next_control:=ignore; p:=Pascal_translate; @z @x repeat next_control:=copy_TeX; @y in_def_part := false; repeat next_control:=copy_TeX; @z @x "|": begin init_stack; output_Pascal; @y "|": begin next_control := ignore; init_stack; output_Pascal; @z @x begin sc2("\")("D")(intro); {this will produce `\&{define }'} @y begin sc2("\")("D")(intro); {this will produce `\&{define }'} in_def_part := true; pound_found := false; @z @x @=@!this_module:name_pointer; {the current module name, or zero} @y @=@!this_module:name_pointer; {the current module name, or zero} in_def_part, pound_found : boolean; {flags to determine context of use of pound sign and vertical bar} @z @x this_module:=0; @y this_module:=0; in_def_part := false; @z