Permalink
Browse files

minor, use a dexpr_t pointer for the parser

Signed-off-by: Sebastian Freundt <freundt@ga-group.nl>
  • Loading branch information...
1 parent c2c7ea4 commit 901d6b7a23596aedecefda3bd48375f583dca169 @hroptatyr committed Oct 31, 2011
Showing with 10 additions and 9 deletions.
  1. +3 −4 src/dexpr-parser.y
  2. +1 −1 src/dexpr-scanner.l
  3. +3 −3 src/dexpr.c
  4. +3 −1 src/dexpr.h
View
@@ -38,7 +38,7 @@
%defines
%output="y.tab.c"
%pure-parser
-%parse-param{dexpr_t cur}
+%parse-param{dexpr_t *cur}
%{
#include <stdlib.h>
@@ -49,7 +49,7 @@ extern int yylex();
extern int yyerror();
int
-yyerror(dexpr_t __attribute__((unused)) cur, const char *errmsg)
+yyerror(dexpr_t *__attribute__((unused)) cur, const char *errmsg)
{
fputs(errmsg, stderr);
fputc('\n', stderr);
@@ -88,8 +88,7 @@ yyerror(dexpr_t __attribute__((unused)) cur, const char *errmsg)
root:
stmt {
- cur->type = DEX_UNK;
- cur->left = $$;
+ *cur = $$;
YYACCEPT;
}
View
@@ -93,7 +93,7 @@
%%
int
-dexpr_parse(dexpr_t root, char *s, size_t l)
+dexpr_parse(dexpr_t *root, char *s, size_t l)
{
YY_BUFFER_STATE buf;
int res;
View
@@ -98,11 +98,11 @@ __pr(dexpr_t root, size_t ind)
int
main(int argc, char *argv[])
{
- struct dexpr_s root[1];
+ dexpr_t root;
for (int i = 1; i < argc; i++) {
- memset(root, 0, sizeof(root));
- dexpr_parse(root, argv[i], strlen(argv[i]));
+ root = NULL;
+ dexpr_parse(&root, argv[i], strlen(argv[i]));
__pr(root, 0);
free_dexpr(root);
}
View
@@ -23,7 +23,9 @@ struct dexpr_s {
};
/* parser routine */
-extern int dexpr_parse(dexpr_t root, char *s, size_t l);
+extern int dexpr_parse(dexpr_t *root, char *s, size_t l);
+
+extern int yyparse(dexpr_t *cur);
#define YYSTYPE dexpr_t

0 comments on commit 901d6b7

Please sign in to comment.