Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. bool accept(automaton *am, int dep, char *word, state_t act_st) {
  2. if (dep == strlen(word)) {
  3. return am->acc[act_st]; // true if accepting
  4. }
  5. bool res;
  6. int idx = alph_idx(word[dep]);
  7. if (is_existential(am, act_st)) {
  8. res = false;
  9. int i = 0;
  10. while (!res && am->T[act_st][idx][i] != (char) -1) {
  11. if (accept(am, dep + 1, word, (state_t) am->T[act_st][idx][i]))
  12. res = true;
  13. i++;
  14. }
  15. }
  16. else { // universal
  17. res = true;
  18. int i = 0;
  19. while (res && am->T[act_st][idx][i] != (char) -1) {
  20. if (accept(am, dep + 1, word, (state_t) am->T[act_st][idx][i]))
  21. res = false;
  22. i++;
  23. }
  24. }
  25. return res;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement