static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
-#include <stdlib.h>
-#include <string.h>
-
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#endif /* yyrule */
#define YYPREFIX "calc_"
+#define YYPURE 0
+
+#line 2 "calc.y"
+# include <stdio.h>
+# include <ctype.h>
+
+int regs[26];
+int base;
+
+#line 106 "calc.tab.c"
+
+#ifndef YYSTYPE
+typedef int YYSTYPE;
+#endif
+
/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
-#ifdef YYPARSE_PARAM_TYPE
-#define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# ifdef YYPARSE_PARAM_TYPE
+# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
+# else
+# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# endif
#else
-#define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
+# define YYPARSE_DECL() yyparse(void)
#endif
-#else
-#define YYPARSE_DECL() yyparse(void)
-#endif /* YYPARSE_PARAM */
-extern int YYPARSE_DECL();
+/* Parameters sent to lex. */
+#ifdef YYLEX_PARAM
+# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
+# define YYLEX yylex(YYLEX_PARAM)
+#else
+# define YYLEX_DECL() yylex(void)
+# define YYLEX yylex()
+#endif
-#line 2 "calc.y"
-# include <stdio.h>
-# include <ctype.h>
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
-int regs[26];
-int base;
+extern int YYPARSE_DECL();
+extern int YYLEX_DECL();
-#line 121 "calc.tab.c"
#define DIGIT 257
#define LETTER 258
#define UMINUS 259
};
#endif
-#ifndef YYSTYPE
-typedef int YYSTYPE;
-#endif
-#if YYDEBUG
-#include <stdio.h>
-#endif
-
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
-
-#define YYPURE 0
-
int yyerrflag;
int yychar;
YYSTYPE yyval;
#line 63 "calc.y"
/* start of programs */
-main ()
-
+int
+main (void)
{
while(!feof(stdin)) {
- yyparse();
- }
+ yyparse();
+ }
+ return 0;
}
-yyerror(char *s)
-{
- fprintf(stderr, "%s\n", s);
+static void
+yyerror(const char *s)
+{
+ fprintf(stderr, "%s\n", s);
}
+int
+yylex(void)
+{
+ /* lexical analysis routine */
+ /* returns LETTER for a lower case letter, yylval = 0 through 25 */
+ /* return DIGIT for a digit, yylval = 0 through 9 */
+ /* all other characters are returned immediately */
+
+ int c;
-yylex() { /* lexical analysis routine */
- /* returns LETTER for a lower case letter, yylval = 0 through 25 */
- /* return DIGIT for a digit, yylval = 0 through 9 */
- /* all other characters are returned immediately */
+ while( (c=getchar()) == ' ' ) { /* skip blanks */ }
- int c;
+ /* c is now nonblank */
- while( (c=getchar()) == ' ' ) { /* skip blanks */ }
+ if( islower( c )) {
+ yylval = c - 'a';
+ return ( LETTER );
+ }
+ if( isdigit( c )) {
+ yylval = c - '0';
+ return ( DIGIT );
+ }
+ return( c );
+}
+#line 340 "calc.tab.c"
+
+#if YYDEBUG
+#include <stdio.h> /* needed for printf */
+#endif
- /* c is now nonblank */
+#include <stdlib.h> /* needed for malloc, etc */
+#include <string.h> /* needed for memset */
- if( islower( c )) {
- yylval = c - 'a';
- return ( LETTER );
- }
- if( isdigit( c )) {
- yylval = c - '0';
- return ( DIGIT );
- }
- return( c );
- }
-#line 328 "calc.tab.c"
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(YYSTACKDATA *data)
{
if (newss == 0)
return -1;
- data->s_base = newss;
+ data->s_base = newss;
data->s_mark = newss + i;
newvs = (data->l_base != 0)
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0)
{
- if ((yychar = yylex()) < 0) yychar = 0;
+ if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
#line 60 "calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
-#line 590 "calc.tab.c"
+#line 610 "calc.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
*++yystack.l_mark = yyval;
if (yychar < 0)
{
- if ((yychar = yylex()) < 0) yychar = 0;
+ if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{