Skip to content

Instantly share code, notes, and snippets.

@sonishc
Created June 5, 2018 15:14
Show Gist options
  • Select an option

  • Save sonishc/f3f2b60d86f68d24b634c20586ebb3bd to your computer and use it in GitHub Desktop.

Select an option

Save sonishc/f3f2b60d86f68d24b634c20586ebb3bd to your computer and use it in GitHub Desktop.
Na
$('#expression').keyup(function () {
$('#display').text($(this).val());
});
function getText() {
var test = document.getElementById("expression").value
var exp_str = test.toUpperCase(); //.replace(/\s/g,'');
var input_character = exp_str.split("");
var acces = null;
var f_state_mashine = input_character;
var current_state = 1;
f_state_mashine.forEach(function(element) {
alert(current_state);
switch (current_state){
case 1 :
if (element == 0 ){
current_state = 2;
}
else {
current_state = 1;
}
break;
case 2 :
if (element == 0 ){
current_state = 3;
}
else {
current_state = 1;
}
break;
case 3 :
if (element == 0 ){
current_state = 3;
}
else {
current_state = 4;
}
break;
case 4 :
if (element == 0 ){
current_state = 1;
}
else {
current_state = 5;
}
break;
case 5 :
if (element == 0 ){
current_state = 1;
}
else {
current_state = 6;
}
break;
case 6 :
if (element == 0 ){
current_state = 7;
acces = current_state;
}
else {
current_state = 7;
acces = current_state;
}
break;
case 7 :
if (element == 0 ){
current_state = 1;
}
else {
current_state = 1;
}
;
break;
}
});
if (f_state_mashine.toString().match(/[a-zA-Z]/) || f_state_mashine.toString().match(/[2-9]/)) {
alert('Символ не входить до алфавіту виразу доступний алфавіт {0,1}');
f_state_mashine = 'Помилка';
}
else if (acces == 7)
{
acces = "Допустити";
}
else acces= "Не допускати";
document.getElementById('result').innerHTML = "<h1>" + acces + "</h1>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment