summaryrefslogtreecommitdiff
path: root/src/webidl-parser.y
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-parser.y
parent640ed1da81d909bb3c2f01a481e7e8d3336f336c (diff)
downloadnsgenbind-74e143bf3a9cd1cf6748cf1462f8e0fb161d126e.tar.gz
nsgenbind-74e143bf3a9cd1cf6748cf1462f8e0fb161d126e.tar.bz2
clean up AST building for both parsers
Diffstat (limited to 'src/webidl-parser.y')
-rw-r--r--src/webidl-parser.y50
1 files changed, 27 insertions, 23 deletions
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index db10ab7..b45a8bd 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -21,24 +21,20 @@
char *errtxt;
-static void webidl_error(const char *str)
+static void
+webidl_error(YYLTYPE *locp, struct webidl_node **winbind_ast, const char *str)
{
+ locp = locp;
+ winbind_ast = winbind_ast;
errtxt = strdup(str);
}
-int webidl_wrap()
-{
- return 1;
-}
-
%}
%locations
%define api.pure
%error-verbose
-
- /* the w3c grammar results in 19 shift/reduce conficts */
-%expect 19
+%parse-param { struct webidl_node **webidl_ast }
%union
{
@@ -46,6 +42,7 @@ int webidl_wrap()
char* text;
long value;
struct ifmember_s **ifmember;
+ struct webidl_node *node;
}
@@ -112,27 +109,36 @@ int webidl_wrap()
%type <text> Inheritance
%type <ifmember> InterfaceMembers
+%type <node> Definitions
+%type <node> Definition
+
%%
- /* [1] altered from original grammar to be left recusive, avoid reduce/reduce
- * conficts and have an error term.
- *
- * By omitting the empty term from here reduce/reduce conficts are removed as
- * both ExtendedAttributeList and Definition (by way of Exception) can end
- * up with an empty term anyhow.
- */
-Definitions:
- ExtendedAttributeList Definition
- |
- Definitions ExtendedAttributeList Definition
+ /* default rule to add built AST to passed in one */
+Input:
+ Definitions
+ { *webidl_ast = webidl_node_link(*webidl_ast, $1); }
|
- error ';'
+ error
{
fprintf(stderr, "%d: %s\n", yylloc.first_line, errtxt);
free(errtxt);
YYABORT ;
}
;
+
+ /* [1] altered from original grammar to be left recusive, */
+Definitions:
+ /* empty */
+ {
+ $$ = NULL;
+ }
+ |
+ Definitions ExtendedAttributeList Definition
+ {
+ $$ = webidl_node_link($1, $3);
+ }
+ ;
/* [2] */
Definition:
@@ -247,8 +253,6 @@ DefaultValue:
/* [17] */
Exception:
- /* empty */
- |
TOK_EXCEPTION TOK_IDENTIFIER Inheritance '{' ExceptionMembers '}' ';'
;