File: run_str.y

package info (click to toggle)
clif 0.93-9.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 4,228 kB
  • sloc: ansic: 31,464; yacc: 5,067; lex: 819; makefile: 383; sh: 48
file content (185 lines) | stat: -rw-r--r-- 3,436 bytes parent folder | download | duplicates (5)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*  -*-c-*-
    Clif - A C-like Interpreter Framework
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997 T. Hruz, L. Koren
    1998 L. Koren

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

/*
 * run_str_y
 *
 * grammar for run string parsing (yacc specification)
 */
%union {
	int myyint;
	char *myystring;
	}
%token <myyint> NUMBER 		/* integer constant */
%token <myystring> STRING
%token BGC HELP 
%token COMPILE WARNING
%token WARRANTY COPYING
%token VERBOSE VERSION
%token '='
%token WARNING_INHIBIT
%token WARNING_COMMENT WARNING_FORMAT WARNING_IMPLICIT WARNING_RETURN_TYPE
%token WARNING_TRIGRAPHS
%token WARNING_UNUSED WARNING_UNINITIALIZED
%token WARNING_EXTRA WARNING_AGGREGATE_RETURN
%token WARNING_ERROR
%token HANDLE_MAIN
%token CALL_BY_REFERENCE CALL_BY_VALUE
%token NO_CALL_BY_REFERENCE NO_CALL_BY_VALUE
%token DUMP_YACC DBG_INFO

%start list_stat_0

%{
#include <stdio.h>
#include "flags.h"
int argc_counter = 0;
extern int bc;
char *argvv[100];

#ifndef PROTO
#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined(__STDC__)
#define PROTO(ARGS) ARGS
#else
#define PROTO(ARGS) ()
#endif 
#endif
extern int help PROTO((int));
int yylex PROTO((void));
void error_message PROTO((int));
int yyerror PROTO((char *));

int 
yyerror (s)
  char *s;
{
  return (0);
}

%}
%% /* beginnig of rules section */

list_stat_0 : list_stat_0  stat_0

	    |
	    ;

stat_0 : BGC '=' NUMBER
		{bc = $3;}

	| CALL_BY_REFERENCE
		{call_by_reference = 1;}
	| NO_CALL_BY_REFERENCE
		{call_by_reference = 0;}
	| CALL_BY_VALUE
		{call_by_value = 1;}
	| NO_CALL_BY_VALUE
		{call_by_value = 0;}
	| COMPILE
		{no_compile_only = 0;}

	| COPYING
		{
		  if (help (2) == -1)
		    return (-1);
		}
	| DUMP_YACC
		{
		  extern void dump_yacc PROTO((void));
		  dump_yacc ();
		}

	| DBG_INFO
		{dbg_symbols = 1;}

	| HANDLE_MAIN
		{handle_main = 1;}

	| HELP
		{
		  if (help (1) == -1)
		    return (-1);
	       	}

	| STRING
		{argvv[++argc_counter] = $1;}

	| VERBOSE
		{
		  if (help (4) == -1)
		    return (-1);
		}

	| VERSION
		{
		  if (help (5) == -1)
		    return (-1);
		}

	| WARNING
		{warning_yes = 1;}

	| WARNING_AGGREGATE_RETURN
		{warning_aggregate_return = 1;}

	| WARNING_COMMENT
		{warning_comment = 1;}

	| WARNING_ERROR
		{warnings_are_errors = 1;}

	| WARNING_EXTRA
		{warning_extra = 1;}

	| WARNING_FORMAT
		{warning_format = 1;}

	| WARNING_IMPLICIT
		{warning_implicit = 1;}

	| WARNING_INHIBIT
		{warning_inhibit = 1;}

	| WARNING_RETURN_TYPE
		{warning_return_type = 1;}

	| WARNING_TRIGRAPHS
		{warning_trigraphs = 1;}

	| WARNING_UNINITIALIZED
		{warning_uninitialized = 1;}

	| WARNING_UNUSED
		{warning_unused = 1;}

	| WARRANTY
		{
		  if (help (3) == -1)
		    return (-1);
		}

	| error
		{
		  error_message (7000); return (-1);
		}
       ;

%%