"SfR Fresh" - the SfR Freeware/Shareware Archive 
Member "xlab-0.8.3/parse.y" of archive xlab-0.8.3.tar.gz:
As a special service "SfR Fresh" has tried to format the requested source page into HTML format using source code syntax highlighting with prefixed line numbers.
Alternatively you can here view or download the uninterpreted source code file.
That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
1 /*
2 * $Id: parse.y,v 1.4 1998/07/24 11:59:15 marc Exp $
3 *
4 * xlab command parser grammar
5 *
6 * (c) Marc Vertes 1997
7 *
8 */
9
10 /* Definitions section */
11
12 %{
13 #include <stdio.h>
14 #include <stdlib.h>
15
16 #include "fd.h"
17 #include "record.h"
18 #include "scope.h"
19
20 #if __STDC__ || defined(__cplusplus)
21 #define P_(s) s
22 #else
23 #define P_(s) ()
24 #endif
25
26 int yylex P_((void));
27 int yyerror P_((char *));
28
29 #undef P_
30 extern int replay_counter;
31 %}
32
33 %union {
34 char *string; /* quoted string (quotes removed by lex scanner) */
35 char *name; /* filename */
36 int intval; /* integer */
37 }
38
39 %token EXIT
40 %token RECORD
41 %token REPLAY
42 %token EXTREP
43 %token STOP
44 %token SET
45 %token TRACE
46 %token DEBUG
47 %token SPEED
48 %token NL
49 %token <name> FILENAME
50 %token <string> SYSSTR
51 %token <string> QSTRING
52 %token <intval> NATURAL
53
54 %%
55
56 /* Rules section */
57
58 command:
59 exit_command
60 | set_command
61 | record_command
62 | replay_command
63 | stop_record_command
64 | stop_replay_command
65 | shell_command
66 ;
67
68 set_command:
69 set_speed_command
70 | set_trace_command
71 | set_debug_command
72 ;
73
74 set_speed_command:
75 SET SPEED NATURAL
76 {
77 printf("speed: %d\n", $3);
78 }
79 ;
80
81 set_debug_command:
82 SET DEBUG NATURAL
83 {
84 printf("debug: %d\n", $3);
85 }
86 ;
87
88 set_trace_command:
89 SET TRACE NATURAL
90 {
91 printf("trace: %d\n", $3);
92 }
93 ;
94
95 exit_command:
96 EXIT
97 {
98 printf("Bye!\n");
99 ReportAndExit();
100 }
101 ;
102
103 record_command:
104 RECORD FILENAME
105 {
106 start_record($2);
107 }
108 ;
109
110 replay_command:
111 REPLAY FILENAME
112 {
113 printf("Start replay\n");
114 replay_counter = 1;
115 start_replay($2);
116 }
117 | REPLAY FILENAME NATURAL
118 {
119 printf("Start replay\n");
120 replay_counter = $3;
121 start_replay($2);
122 }
123 ;
124
125 stop_record_command: STOP RECORD
126 {
127 printf("Stop record\n");
128 stop_record();
129 }
130 ;
131
132 stop_replay_command:
133 STOP REPLAY
134 {
135 printf("command: stop replay\n");
136 }
137 ;
138
139 shell_command:
140 SYSSTR { printf("%s\n", $1); system($1); }
141 ;
142
143 /* null_command: NL {printf("> "); fflush(stdout); }; */
144 %%
145
146 /* user subroutines section */
147
148 int yyerror(s)
149 char *s;
150 {
151 fprintf(stderr, "%s\n", s);
152 return(0);
153 }