summaryrefslogtreecommitdiffabout
path: root/src/grecs-gram.y
Side-by-side diff
Diffstat (limited to 'src/grecs-gram.y') (more/less context) (ignore whitespace changes)
-rw-r--r--src/grecs-gram.y80
1 files changed, 6 insertions, 74 deletions
diff --git a/src/grecs-gram.y b/src/grecs-gram.y
index 9f8d000..3452074 100644
--- a/src/grecs-gram.y
+++ b/src/grecs-gram.y
@@ -18,7 +18,6 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "yygrecs.h"
#include <grecs.h>
#include <grecs-gram.h>
#include <stdlib.h>
@@ -26,11 +25,10 @@
#include <string.h>
#include <errno.h>
-static struct grecs_node *parse_tree;
-int grecs_error_count;
-
-int grecs_default_port = 0;
+int yylex(void);
+int yyerror(char *s);
+static struct grecs_node *parse_tree;
%}
%union {
@@ -239,74 +237,13 @@ yyerror(char *s)
return 0;
}
-int
-grecs_vasprintf(char **pbuf, size_t *psize, const char *fmt, va_list ap)
-{
- char *buf = *pbuf;
- size_t buflen = *psize;
- int rc = 0;
-
- if (!buf) {
- if (buflen == 0)
- buflen = 512; /* Initial allocation */
-
- buf = calloc(1, buflen);
- if (buf == NULL)
- return ENOMEM;
- }
-
- for (;;) {
- ssize_t n = vsnprintf(buf, buflen, fmt, ap);
- if (n < 0 || n >= buflen || !memchr(buf, '\0', n + 1)) {
- char *newbuf;
- size_t newlen = buflen * 2;
- if (newlen < buflen) {
- rc = ENOMEM;
- break;
- }
- newbuf = realloc(buf, newlen);
- if (newbuf == NULL) {
- rc = ENOMEM;
- break;
- }
- buflen = newlen;
- buf = newbuf;
- } else
- break;
- }
-
- if (rc) {
- if (!*pbuf) {
- /* We made first allocation, now free it */
- free(buf);
- buf = NULL;
- buflen = 0;
- }
- }
-
- *pbuf = buf;
- *psize = buflen;
- return rc;
-}
-
-int
-grecs_asprintf(char **pbuf, size_t *psize, const char *fmt, ...)
-{
- int rc;
- va_list ap;
-
- va_start(ap, fmt);
- rc = grecs_vasprintf(pbuf, psize, fmt, ap);
- va_end(ap);
- return rc;
-}
-
struct grecs_node *
-grecs_parse(const char *name)
+grecs_grecs_parser(const char *name, int traceflags)
{
int rc;
- if (grecs_lex_begin(name))
+ if (grecs_lex_begin(name, traceflags & GRECS_TRACE_LEX))
return NULL;
+ yydebug = traceflags & GRECS_TRACE_GRAM;
parse_tree = NULL;
rc = yyparse();
if (grecs_error_count)
@@ -319,11 +256,6 @@ grecs_parse(const char *name)
return parse_tree;
}
-void
-grecs_gram_trace(int n)
-{
- yydebug = n;
-}

Return to:

Send suggestions and report system problems to the System administrator.