Remove building with NOCRYPTO option
[minix3.git] / external / bsd / flex / dist / examples / manual / front.y
blob77b5ca140a9c4998602e6e8ddf60a112a45dcd41
1 /* C code supplied at the beginning of the file. */
3 %{
5 #include <stdio.h>
6 #include <string.h>
8 extern int yylexlinenum; /* these are in YYlex */
9 extern char *yytext; /* current token */
14 /* Keywords and reserved words begin here. */
16 %union{ /* this is the data union */
17 char name[128]; /* names */
20 /*-------------------- the reserved words -----------------------------*/
22 %token PERIOD
23 %token NEWLINE
24 %token POSITIONAL
26 %token VERB
27 %token ADVERB
29 %token PROPER_NOUN
30 %token NOUN
32 %token DECLARATIVE
33 %token CONDITIONAL
36 %type <name> declarative
37 %type <name> verb_phrase
38 %type <name> noun_phrase
39 %type <name> position_phrase
40 %type <name> adverb
42 %type <name> POSITIONAL VERB ADVERB PROPER_NOUN
43 %type <name> NOUN DECLARATIVE CONDITIONAL
47 sentence_list : sentence
48 | sentence_list NEWLINE sentence
52 sentence : verb_phrase noun_phrase position_phrase adverb period
54 printf("I understand that sentence.\n");
55 printf("VP = %s \n",$1);
56 printf("NP = %s \n",$2);
57 printf("PP = %s \n",$3);
58 printf("AD = %s \n",$4);
60 | { yyerror("That's a strange sentence !!"); }
63 position_phrase : POSITIONAL declarative PROPER_NOUN
65 sprintf($$,"%s %s %s",$1,$2,$3);
67 | /* empty */ { strcpy($$,""); }
71 verb_phrase : VERB { strcpy($$,$1); strcat($$," "); }
72 | adverb VERB
74 sprintf($$,"%s %s",$1,$2);
78 adverb : ADVERB { strcpy($$,$1); }
79 | /* empty */ { strcpy($$,""); }
82 noun_phrase : DECLARATIVE NOUN
84 sprintf($$,"%s %s",$1,$2);
86 | CONDITIONAL declarative NOUN
88 sprintf($$,"%s %s %s",$1,$2,$3);
90 | NOUN { strcpy($$,$1); strcat($$," "); }
93 declarative : DECLARATIVE { strcpy($$,$1); }
94 | /* empty */ { strcpy($$,""); }
97 period : /* empty */
98 | PERIOD
104 /* Supplied main() and yyerror() functions. */
106 int main(int argc, char *argv[])
108 yyparse(); /* parse the file */
109 return(0);
112 int yyerror(char *message)
114 extern FILE *yyout;
116 fprintf(yyout,"\nError at line %5d. (%s) \n",
117 yylexlinenum,message);