From c1db25526a6990263e9703634401178975cf9d61 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 6 Sep 2012 02:59:31 +0100 Subject: initial output generation --- src/genjsbind-parser.y | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'src/genjsbind-parser.y') 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 TOK_STRING_LITERAL +%token TOK_STRING_LITERAL + +%type 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); + } + ; + %% -- cgit v1.2.3