summaryrefslogtreecommitdiff
path: root/src/webidl-ast.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2012-09-10 00:22:34 +0100
committerVincent Sanders <vince@kyllikki.org>2012-09-10 00:22:34 +0100
commit74e143bf3a9cd1cf6748cf1462f8e0fb161d126e (patch)
tree8526a61b4f6735c7fa0fad17113ae3baee6d6e59 /src/webidl-ast.c
parent640ed1da81d909bb3c2f01a481e7e8d3336f336c (diff)
downloadnsgenbind-74e143bf3a9cd1cf6748cf1462f8e0fb161d126e.tar.gz
nsgenbind-74e143bf3a9cd1cf6748cf1462f8e0fb161d126e.tar.bz2
clean up AST building for both parsers
Diffstat (limited to 'src/webidl-ast.c')
-rw-r--r--src/webidl-ast.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/src/webidl-ast.c b/src/webidl-ast.c
index 1eddd68..e19fb80 100644
--- a/src/webidl-ast.c
+++ b/src/webidl-ast.c
@@ -18,19 +18,8 @@
extern int webidl_debug;
extern int webidl__flex_debug;
extern void webidl_restart(FILE*);
-extern int webidl_parse(void);
+extern int webidl_parse(struct webidl_node **webidl_ast);
-struct webidl_node *webidl_root;
-
-struct webidl_node *webidl_new_node(enum webidl_node_type type)
-{
- struct webidl_node *nnode;
- nnode = calloc(1, sizeof(struct webidl_node));
- if (nnode != NULL) {
- nnode->type = type;
- }
- return nnode;
-}
static FILE *idlopen(const char *filename)
{
@@ -55,10 +44,32 @@ static FILE *idlopen(const char *filename)
return idlfile;
}
-int webidl_parsefile(char *filename)
+struct webidl_node *
+webidl_node_link(struct webidl_node *tgt, struct webidl_node *src)
{
- /* set flex to read from file */
+ if (tgt != NULL) {
+ tgt->l = src;
+ return tgt;
+ }
+ return src;
+}
+
+struct webidl_node *webidl_node_new(int type, struct webidl_node *l, void *r)
+{
+ struct webidl_node *nn;
+ nn = calloc(1, sizeof(struct webidl_node));
+ nn->type = type;
+ nn->l = l;
+ nn->r.text = r;
+ return nn;
+}
+
+
+int webidl_parsefile(char *filename, struct webidl_node **webidl_ast)
+{
+
FILE *idlfile;
+
idlfile = idlopen(filename);
if (!idlfile) {
fprintf(stderr, "Error opening %s: %s\n",
@@ -72,8 +83,9 @@ int webidl_parsefile(char *filename)
webidl__flex_debug = 1;
}
+ /* set flex to read from file */
webidl_restart(idlfile);
/* parse the file */
- return webidl_parse();
+ return webidl_parse(webidl_ast);
}