4 * (C) Copyright 2014, Stephen M. Cameron.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #define YYSTYPE PARSER_VALUE_TYPE
27 extern int lexer_input(char* buffer, int *nbytes, int buffersize);
30 #define YY_INPUT(buffer, bytes_read, bytes_requested) \
31 lexer_input((buffer), &(bytes_read), (bytes_requested))
33 extern int yyerror(long long *result, double *dresult,
34 int *has_error, int *bye, const char *msg);
36 static void __attribute__((unused)) yyunput(int c,char *buf_ptr);
37 static int __attribute__((unused)) input(void);
45 [ \t] ; /* ignore whitespace */
46 #.+ ; /* ignore comments */
51 rc = sscanf(yytext, "%lf", &dval);
54 yylval.v.ival = (long long) dval;
55 yylval.v.has_dval = 1;
56 yylval.v.has_error = 0;
59 yyerror(0, 0, 0, 0, "bad number\n");
60 yylval.v.has_error = 1;
66 rc = sscanf(yytext, "%x", &intval);
68 yylval.v.ival = intval;
69 yylval.v.dval = (double) intval;
70 yylval.v.has_dval = 0;
71 yylval.v.has_error = 0;
74 yyerror(0, 0, 0, 0, "bad number\n");
75 yylval.v.has_error = 1;
81 rc = sscanf(yytext, "%d", &intval);
83 yylval.v.ival = intval;
84 yylval.v.dval = (double) intval;
85 yylval.v.has_dval = 0;
86 yylval.v.has_error = 0;
89 yyerror(0, 0, 0, 0, "bad number\n");
90 yylval.v.has_error = 1;
95 [+-/*()] return yytext[0];
97 yylval.v.has_error = 1;