diff --git a/tutorial/wmmltohtml2 b/tutorial/wmmltohtml2 index a14f3f641d636134c095513ffec2b61c5fd932fe..40ff6041c7b5cf4f1c8f120b64e2f9ec154e9d72 100755 --- a/tutorial/wmmltohtml2 +++ b/tutorial/wmmltohtml2 @@ -6,24 +6,61 @@ import Stdio; int main(int argc, string *argv) { - program output=(program)argv[1]; - werror("Reading "); - mixed data=stdin->read(0x7fffffff); - werror("Lexing "); - data=Sgml.lex(data); - werror("Grouping "); - data=Sgml.group(data); - werror("Including "); - data=Wmml.handle_include(data); - werror("Verifying\n"); - Wmml.verify(data); - werror("Collecting TOC "); - SGML toc=Wmml.collect_toc(data); - werror("index "); - INDEX_DATA index=Wmml.collect_index(data); - // write(sprintf("%O\n",Wmml.group_index(Wmml.collect_index(data)))); - werror("\nWriting output\n"); - output()->output(argv[2],data,toc,index); - write("Ok\n"); - exit(0); + mixed *ER=catch { + program output=(program)argv[1]; + werror("Reading "); + mixed data=stdin->read(0x7fffffff); + werror("Lexing "); + data=Sgml.lex(data,"stdin"); + werror("Grouping "); + data=Sgml.group(data); + werror("Verifying\n"); + Wmml.verify(data); + werror("Concretizing\n"); + data=Wmml.make_concrete_wmml(data); + werror("Verifying (again)\n"); + Wmml.verify(data); + werror("Collecting TOC "); + SGML toc=Wmml.collect_toc(data); + werror("index "); + INDEX_DATA index=Wmml.collect_index(data); + // write(sprintf("%O\n",Wmml.group_index(Wmml.collect_index(data)))); + werror("\nWriting output\n"); + output()->output(argv[2],data,toc,index); + write("Ok\n"); + exit(0); + }; + + if(ER) + { + catch { + if(arrayp(ER) && sizeof(ER)>1 && arrayp(ER[1])) + { + mixed x; + x=ER[1]; + x=reverse(x); + foreach(x,x) + { + for(int e=3;e<sizeof(x);e++) + { + mixed s=x[e]; + if(!arrayp(s)) s=({s}); + foreach(s,s) + { + if(object_program(s)==Sgml.Tag) + { + if(s->pos) + { + werror("This error occured close to tag "+s->tag+" near pos "+ + s->pos+".\n"); + throw(0); + } + } + } + } + } + } + }; + throw(ER); + } }