| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 | 
							- Namespace.register("U.CD");
 
- // 主函数
 
- U.CD.Error = 1;//判断程序有无错误
 
- U.CD.run=function () {
 
- 	cls();
 
-     lex();//词法分析 入口
 
-     Syntax.run(tokens); //语法分析入口
 
- 	//my('col5').appendChild(Syntax.treeview(Syntax.root));    语法树
 
- 	console(Syntax.error);// 控制台
 
- 	if (U.CD.Error) {
 
- 		//coderesult(Interpreter.Output(Syntax.intercode)); //打印中间代码
 
- 		Interpreter.run(Syntax.intercode); // 制表符 入口
 
- 		if (U.CD.Error) {
 
- 		    showcol('UD_Print', 'UD_Control');
 
- 		}
 
- 		else{
 
- 		    showcol('UD_Control', 'UD_Print');
 
- 		}
 
- 	}
 
- 	else{
 
- 	    showcol('UD_Control', 'UD_Print');
 
- 	}
 
- }
 
- // 打印控制台
 
- function console(str) {
 
- if(str!="")
 
-     U.CD.Error = 0;
 
-     U.CD.Obj('UD_CD_Col6').innerHTML += "<div style='color:red'>"+str+"</div>";
 
- };
 
- // 打印词法分析结果
 
- //function lexresult(str) {
 
- //	my('col3').innerHTML += str;
 
- //};
 
- // 打印输出
 
- function outputresult(str) {
 
-     U.CD.Obj('UD_CD_Col6').innerHTML += str;
 
- };
 
- // 打印语法树
 
- //function treeresult(str) {
 
- //	my('col5').innerHTML += str;
 
- //};
 
- // 打印中间代码
 
- function coderesult(str) {
 
-     U.CD.Obj('UD_CD_Col6').innerHTML += str;
 
- };
 
- // 清屏函数
 
- function cls() {
 
-     U.CD.Obj('UD_CD_Col6').innerHTML = '';
 
-     U.CD.Error = 1
 
- };
 
- // 清空源代码区
 
- function clsource() {
 
-     U.CD.Obj('UD_CD_Source').value = '';
 
- };
 
- // tab函数
 
- function showcol(n,c) {
 
- 	U.CD.Obj(c).style.color = '#999999';
 
- 	U.CD.Obj(c).style.background = '#E1E1E1';
 
- 	U.CD.Obj(n).style.color = 'white';
 
- 	U.CD.Obj(n).style.background = '#038BC7';
 
- };
 
- //// 弹出层
 
- //function dialog() {
 
- //	with (document.documentElement) {
 
- //		var width = (scrollWidth > clientWidth) ? scrollWidth : clientWidth;
 
- //		var height = (scrollHeight > clientHeight) ? scrollHeight
 
- //				: clientHeight;
 
- //	}
 
- //	var left = document.documentElement.clientWidth / 2 - 186;
 
- //	var top = document.documentElement.clientHeight / 2 - 169;
 
- //	document.getElementsByTagName('body')[0].innerHTML += "<div id='copyright' style='width:424px;"
 
- //			+ "height:169px;background:url(images/dialog.png);text-align:center;font-size:13px;position:fixed;"
 
- //			+ "z-index:99;left:"
 
- //			+ left
 
- //			+ "px;top:"
 
- //			+ top
 
- //			+ "px;'>"
 
- //			+ '<p>JCompiler-JavaScript 解释器</p><p>邱旭乐(200732580229)</p><p>张河川(200732580241)</p>'
 
- //			+ '<input type="button" value="知道了" onclick="destroyDg();" /></div>';
 
- //	var div = document.createElement('div');
 
- //	div.style.backgroundColor = "#333333";
 
- //	div.style.width = width + 'px';
 
- //	div.style.width = height + 'px';
 
- //	div.style.left = "0 px";
 
- //	div.style.top = "0 px";
 
- //	div.style.zIndex = 98;
 
- //	div.style.opacity = 0.6;
 
- //	// document.getElementsByTagName('body')[0].innerHTML+=copyright;
 
- //	document.getElementsByTagName('body')[0].innerHTML += "<div id='mask' style='background:#333;position:absolute;left:0px;top:0px;opacity:.6;"
 
- //			+ "width:" + width + "px;height:" + height + "px;'></div>";
 
- //};
 
- //// 关闭层
 
- //function destroyDg() {
 
- //	my('mask').parentNode.removeChild(my('mask'));
 
- //	my('copyright').parentNode.removeChild(my('copyright'));
 
- //};
 
- //function showNode(hotspot) {
 
- //	for ( var n = 0; n != hotspot.childNodes.length; n++) {
 
- //		var node = hotspot.childNodes[n];
 
- //		// li文本不受该动作影响
 
- //		if (node.nodeType == 3) {
 
- //			continue;
 
- //		} else if (node.style.display == 'block' || node.style.display == '') {
 
- //			node.style.display = 'none';
 
- //			node.parentNode.style.backgroundImage = "url(images/plus.gif)";
 
- //		} else {
 
- //			node.style.display = 'block';
 
- //			node.parentNode.style.backgroundImage = "url(images/minus.gif)";
 
- //		}
 
- //	}
 
- //};
 
 
  |