summaryrefslogtreecommitdiff
path: root/src/genjsbind-parser.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/genjsbind-parser.y')
-rw-r--r--src/genjsbind-parser.y47
1 files changed, 43 insertions, 4 deletions
diff --git a/src/genjsbind-parser.y b/src/genjsbind-parser.y
index 5c5bed5..48ea1d2 100644
--- a/src/genjsbind-parser.y
+++ b/src/genjsbind-parser.y
@@ -10,7 +10,8 @@
#include "genjsbind-parser.h"
#include "genjsbind-lexer.h"
-#include "genjsbind.h"
+#include "webidl-ast.h"
+#include "jsapi-binding.h"
static void genjsbind_error(const char *str)
{
@@ -35,29 +36,67 @@ int genjsbind_wrap()
}
%token TOK_IDLFILE
+%token TOK_HDR_COMMENT
+%token TOK_INTERFACE
-%token <text> TOK_STRING_LITERAL
+%token <text> TOK_STRING_LITERAL
+
+%type <text> Strings
%%
/* [1] start with Statements */
Statements
: Statement
- | Statement Statements
+ | Statements Statement
;
Statement
: IdlFile
+ | HdrComment
+ | Interface
;
/* [3] load a web IDL file */
IdlFile
: TOK_IDLFILE TOK_STRING_LITERAL ';'
{
- if (loadwebidl($2) != 0) {
+ if (webidl_parsefile($2) != 0) {
YYABORT;
}
}
;
+HdrComment
+ : TOK_HDR_COMMENT Strings ';'
+ {
+ genjsbind_header_comment($2);
+ }
+ ;
+
+Strings
+ : TOK_STRING_LITERAL
+ {
+ $$ = $1;
+ }
+ | Strings TOK_STRING_LITERAL
+ {
+ char *fullstr;
+ int fulllen;
+ fulllen = strlen($1) + strlen($2) + 2;
+ fullstr = malloc(fulllen);
+ snprintf(fullstr, fulllen, "%s\n%s", $1, $2);
+ free($1);
+ free($2);
+ $$ = fullstr;
+ }
+ ;
+
+Interface
+ : TOK_INTERFACE TOK_STRING_LITERAL ';'
+ {
+ genjsbind_output_interface($2);
+ }
+ ;
+
%%