diff options
author | Vincent Sanders <vince@kyllikki.org> | 2012-09-06 02:59:31 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2012-09-06 02:59:31 +0100 |
commit | c1db25526a6990263e9703634401178975cf9d61 (patch) | |
tree | ba737f0e32cfa287c5f4a746fa0679924adaf80a /src/genjsbind-parser.y | |
parent | da234bc3e4e44693a6464140d2dee91a948a6145 (diff) | |
download | nsgenbind-c1db25526a6990263e9703634401178975cf9d61.tar.gz nsgenbind-c1db25526a6990263e9703634401178975cf9d61.tar.bz2 |
initial output generation
Diffstat (limited to 'src/genjsbind-parser.y')
-rw-r--r-- | src/genjsbind-parser.y | 47 |
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); + } + ; + %% |