4 * Copyright (C) 2004-2007 Sami Pietila
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 #include "ce_parser.h"
25 #include "functions.h" /* FIXME: Needed for gc_strdup() */
27 /* TODO: This file is almost identical to lr-parser. */
30 ce_parse_(char *expression
, int result
[MP_SIZE
], int flags
)
34 if (!(expression
&& result
)) {
38 memset(&parser_state
, 0, sizeof(struct parser_state
));
40 if (strlen(expression
)) {
42 parser_state
.buff
= gc_strdup(expression
);
45 free(parser_state
.buff
);
48 ret
= (parser_state
.error
) ? parser_state
.error
: ret
;
53 if ((flags
& ANS
) != (parser_state
.flags
& ANS
)) {
62 memcpy(result
, parser_state
.ret
, sizeof(int)*MP_SIZE
);
71 ce_parse(char *expression
, int result
[MP_SIZE
])
73 return(ce_parse_(expression
, result
, ANS
));
78 ce_udf_parse(char *expression
)
82 return(ce_parse_(expression
, dummy
, 0));