-
Notifications
You must be signed in to change notification settings - Fork 0
/
p6.y
54 lines (49 loc) · 996 Bytes
/
p6.y
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
%{
#include <stdio.h>
char car='\0';
int error=1;
%}
%%
axioma : noters '+' noters {error=0;}
| axioma '*' {error=0;}
| noters {error=0;}
;
noters : noters '.' noterp
| noterp
;
noterp : '(' axioma ')'
| 'a'
| 'b'
| 'c'
;
%%
yylex() {
char c;
c=getchar();
if ((c=='\n') && (car!='$')) {if (car=='\n') exit(0);
else {if (car!='\0') {
if (error) printf("\nEntrada no valida\n\n");
else {
printf("\nEntrada valida\n\n");
error=1;
}
}
c=getchar();
if (c=='\n') exit(0);
}
}
if (c=='$'){
if (error) printf("\nEntrada no valida\n\n");
else {
printf("\nEntrada valida\n\n");
error=1;
}
c=getchar();
if (c=='\n') {
c=getchar();
if (c=='\n') exit(0);
}
}
car=c;
return c;
}