Wide Coverage Translation Demo: draw abstract trees and parse trees

You can now click on a tree to toggle between the abstract syntax tree and
the parse tree.

Also, the implementation now uses the new C run-time requests, e.g.

	App14.pgf?command=c-abstrtree&tree=...

so no need to install AppEng.pgf on the server any more.
This commit is contained in:
hallgren
2015-03-19 15:26:18 +00:00
parent 374da1f0b0
commit de1437d3c4

View File

@@ -114,9 +114,22 @@ wc.translate=function() {
e.innerHTML=prob+"<br>"
if(r.tree) {
var t=wrap("span",text(r.tree))
var imgurl="/robust/AppEng.pgf?command=abstrtree&tree="+encodeURIComponent(r.tree)+"&format=svg"
e.appendChild(t)
if(!r.img) r.img=node("img",{src:imgurl},[])
var g=gftranslate.jsonurl
var u="format=svg&tree="+encodeURIComponent(r.tree)
var from="&from="+gftranslate.grammar+f.to.value
r.imgurls=[g+"?command=c-abstrtree&"+u,
g+"?command=c-parsetree&"+u+from]
if(!r.img) {
r.img=node("img",{src:r.imgurls[0]},[])
r.img_ix=0
r.img.onclick=function() {
r.img_ix=1-r.img_ix
r.img.src=r.imgurls[r.img_ix]
}
}
else if(r.img.src!=r.imgurls[r.img_ix]) // language change?
r.img.src=r.imgurls[r.img_ix]
e.appendChild(empty("br"))
e.appendChild(r.img)
}