Cell, cmd.smbTo); (cmd.stTo); (cmd.mvTo) { L :( idxTMCurrentCell - 1) ;; R :( idxTMCurrentCell + 1 ) ;; H :;: tmCompileError ( Непередбачена помилка при виконанні переміщення в команді для символу + smbCurrent + і стану + strTMCurrentState + ) ;
} true;
} tmStart () {ids=[ btnStep raquo ;, btnStart raquo ;, btnSetState raquo ;, btnSetConfig raquo ;, btnShowNextCommand ]; (var i=0; i lt ; ids.length; i ++). getElementById (ids [i]). disabled=true; .getElementById ( btnStop ). disabled=false;=false; () ;. setTimeout (tmRepeatStep, ctlSpeed.value);
} tmRepeatStep () {(! flTMDoStop amp; amp; tmStep ()) {() ;. setTimeout (tmRepeatStep, ctlSpeed.value) ;;
}. getElementById ( btnStop ). disabled=true; ids=[ btnStep raquo ;, btnStart raquo ;, btnSetState raquo ;, btnSetConfig raquo ;, btnShowNextCommand ] ; (var i=ids.length; i--;) .getElementById (ids [i]). disabled=false;
} tmStop () {= true;
} tmSetAlphabet () {(); alphabet={}; [ B ]= B raquo ;; ids=(chkDigitIds + + chkAlphaIds + + chkSymbolIds) .split ( ); smbs=(smbDigit + smbAlpha + smbSymbol); (var i=0; i lt; ids.length; i ++) (document.getElementById ( symbol + ids [i] ) ecked) [smbsarAt (i)]=smbsarAt (i); (var i=0; i lt; nExtraSymbolNumber; i ++) {smb=document.getElementById ( extraSymbol + i) .value; (! smb); (smb in alphabet)
return tmCompileError ( Неможливо включити символ ' + smb +
в алфавіт двічі ); (smb.length!=1) tmCompileError ( Неможливо включити в алфавіт + smb.length + -літерні слово + smb + ');
alphabet [smb]=smb;
}=alphabet; true;
} tmSetStates () {(); states={}; [ STOP ]= STOP raquo ;; ids=chkStateIds.split ( ); (var i=0 ; i lt; ids.length; i ++) (document.getElementById ( state + ids [i]). checked) [stState [i]]=stState [i]; (var i=0; i lt; nExtraStateNumber ; i ++) {st=document.getElementById ( extraState + i) .value; (! st); (st in states)
return tmCompileError ( Неможливо включити стан ' + st +
' в безліч станів машини Тьюринга двічі );
//if(!st.match(/^[a-zA-Z0-9][a-zA-GI-KM-QS-Z0-9_^*]*$/))(!st.match(/^[a-zA-Z0-9][^s-gt;]*$/))
return tmCompileError ( Некоректне ім'я для стану: + st + );
states [st]=st;
}=states; true;
} tmAddStateInput (trParent, tdBefore) {td=document.createElement ( td ); input=document.createElement ( input ) ;. setAttribute ( type raquo ;, textbox ) ;. setAttribute ( id raquo ;, extraState + nExtraStateNumber ++) ;. setAttribute ( class raquo ;, extraState ) ;. appendChild (input); (tdBefore)=trParent.insertBefore (td, tdBefore);=trParent.appendChild (td) ;. firstChild.className= extraState raquo ;; td;
} tmMoreStates () {tdMoreStates=document.getElementById ( tdMoreStates ); parent=tdMoreStates.parentNode; colsNumber=Math.ceil (nExtraStateNumber/10) + 4; percentWidth=Math.floor ( 100/colsNumber); (var td=parent.firstChild; td!=tdMoreStates; td=td.nextSibling) (td.nodeName.toLowerCase () == td ). setAttribute ( width raquo ;, percentWidth + laquo ;% ) ;. setAttribute ( width raquo ;, 100 - colsNumber * percentWidth + % ); tdStateInput=tmAddStateInput (parent, tdMoreStates) ;. setAttribute ( width raquo ;, percentWidth + % raquo ;); (var tr=parent.nextSibling; tr; tr=tr.nextSibling) (tr.nodeName.toLowerCase () == tr ) td=tmAddStateInput (tr);
} tmShowNextCommand () {(); prefix= + TmGetCellValue (idxTMCurrentCell) + strTMCurrentState; (! SetTMProgram ||! (Prefix in setTMProgram)); cmd=setTMProgram [prefix]; txt=prefix + - gt; + Cmd.smbTo + cmd.stTo + cmd.mvTo; tn=document.createTextNode (txt) ;. appendChild (tn);
} tmClearNextCommand () {(ctlNextCommandildNodes.length) .removeChild (ctlNextCommand.lastChild);
} btnShowNextCommand_click () {(); text=ctlProgram.value; (! (tmSetAlphabet () amp; amp; tmSetStates ())); (! tmSetState (strTMCurrentState)); (tmCompile (text )) ();
} btnStep_click () {(); text=ctlProgram.value; (! (tmSetAlphabet () amp; amp; tmSetStates ())); (! tmSetState (strTMCurrentState)); (tmCompile (text ) amp; amp; tmStep ()) ();
} btnStart_click () {(); text=ctlProgram.value; (! (tmSetAlphabet () amp; amp; tmSetStates ())); (! tmSetState (strTMCurrentState)); (tmCompile (text )) ();
} btnStop_click () {();
} btnSetConfig_click () {(); strConfig=ctlConfig.value; (tmSetAlphabet () amp; amp; tmSetConfig (strConfig)) ();
} btn...