Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.05 KB | None | 0 0
  1. /*(Y-A) слова, глас-е в алф-м порядке. BL.y*/
  2. %{
  3.     #include <stdio.h>
  4. %}
  5. %token SOGL
  6. %%
  7. s: { printf("Enter the line\n"); }
  8.     | s q5 '\n' { printf("Correct\n"); }
  9.     | s q4 '\n' { printf("Correct\n"); }
  10.     | s q3 '\n' { printf("Correct\n"); }
  11.     | s q2 '\n' { printf("Correct\n"); }
  12.     | s q1 '\n' { printf("Correct\n"); }
  13.     | s error '\n' { yyerrok; }
  14. ;
  15. q5: 'u'
  16.     | SOGL
  17.     | q5 'u'
  18.     | q5 SOGL
  19.     | q4 'u'
  20.     | q3 'u'
  21.     | q2 'u'
  22.     | q1 'u'
  23. ;
  24. q4: 'o'
  25.     | SOGL
  26.     | q4 'o'
  27.     | q4 SOGL
  28.     | q3 'o'
  29.     | q2 'o'
  30.     | q1 'o'
  31. ;
  32. q3: 'i'
  33.     | SOGL
  34.     | q3 'i'
  35.     | q3 SOGL
  36.     | q2 'i'
  37.     | q1 'i'
  38. ;
  39. q2: 'e'
  40.     | SOGL
  41.     | q2 'e'
  42.     | q2 SOGL
  43.     | q1 'e'
  44. ;
  45. q1: 'a'
  46.     | SOGL
  47.     | q1 'a'
  48.     | q1 SOGL
  49. %%
  50. main(){ return(yyparse()); }
  51. yylex(){
  52.     int c = getchar();
  53.     if (c=='q' | c=='w' | c=='r' | c=='t' | c=='y' | c=='p' | c=='s' | c=='d'| c=='f' | c=='g' | c=='h' | c=='j' |
  54.         c=='k' | c=='l' | c=='z' | c=='x' | c=='c' | c=='v' | c=='b' | c=='n' | c=='m')
  55.         return(SOGL);return c;
  56. }
  57. yyerror(const char* s){ fprintf(stderr, "%s\n",s); }
  58. yywrap(){ return 1; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement