summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/.gitignore7
-rw-r--r--src/Makefile37
-rw-r--r--src/genbind-lexer.l55
-rw-r--r--src/genbind-parser.y62
-rw-r--r--src/genjsbind.c52
-rw-r--r--src/webidl-ast.h2
-rw-r--r--src/webidl-lexer.l284
-rw-r--r--src/webidl-parser.y762
-rw-r--r--test/document.idl37
-rw-r--r--test/eventtarget.idl5
-rw-r--r--test/htmldocument.bnd3
-rw-r--r--test/htmldocument.idl108
-rw-r--r--test/window.idl119
13 files changed, 1533 insertions, 0 deletions
diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644
index 0000000..dd7ead0
--- /dev/null
+++ b/src/.gitignore
@@ -0,0 +1,7 @@
+*.o
+genbind
+webidl-lexer.c
+webidl-lexer.h
+webidl-parser.c
+webidl-parser.h
+
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..c0feb20
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,37 @@
+#
+
+CFLAGS+=-Wall
+
+.PHONY: all clean
+
+all: genjsbind
+
+genjsbind: genjsbind.o genbind-parser.o genbind-lexer.o webidl-parser.o webidl-lexer.o
+ $(CC) -o $@ $^
+
+webidl-parser.o: webidl-parser.c webidl-parser.h webidl-lexer.h
+
+webidl-parser.h webidl-parser.c: webidl-parser.y
+ bison -t $<
+
+webidl-lexer.h: webidl-lexer.c
+
+webidl-lexer.c: webidl-lexer.l
+ flex $<
+
+
+genbind-parser.o: genbind-parser.c genbind-parser.h genbind-lexer.h
+
+genbind-parser.h genbind-parser.c: genbind-parser.y
+ bison -t $<
+
+genbind-lexer.h: genbind-lexer.c
+
+genbind-lexer.c: genbind-lexer.l
+ flex $<
+
+
+genjsbind.o: webidl-parser.h genbind-parser.h
+
+clean:
+ $(RM) genjsbind genjsbind.o webidl-parser.c webidl-lexer.c webidl-lexer.h webidl-parser.h genbind-parser.c genbind-lexer.c genbind-lexer.h genbind-parser.h *.o
diff --git a/src/genbind-lexer.l b/src/genbind-lexer.l
new file mode 100644
index 0000000..010a384
--- /dev/null
+++ b/src/genbind-lexer.l
@@ -0,0 +1,55 @@
+/*
+ * binding generator lexer
+ */
+
+/* lexer options */
+%option outfile="genbind-lexer.c"
+%option header-file="genbind-lexer.h"
+%option never-interactive
+%option bison-bridge
+%option nodefault
+%option warn
+%option debug
+%option prefix="genbind_"
+%option nounput
+
+/* header block */
+%{
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "genbind-parser.h"
+
+%}
+
+ /* other Unicode “space separator” */
+USP (\xe1\x9a\x80)|(\xe1\xa0\x8e)|(\xe2\x80[\x80-\x8a])|(\xe2\x80\xaf)|(\xe2\x81\x9f)|(\xe3\x80\x80)
+
+/* non breaking space \u00A0 */
+NBSP (\xc2\xa0)
+
+whitespace ([ \t\v\f\n]|{NBSP}|{USP})
+
+multicomment \/\*(([^*])|(\*[^/]))*\*\/
+
+quotedstring [^\"\\\n\r]
+
+other [^\t\n\r 0-9A-Z_a-z]
+
+%%
+
+{whitespace} /* nothing */
+
+webidlfile return TOK_IDLFILE;
+
+\"{quotedstring}*\" yylval->text = strndup(yytext + 1,strlen(yytext+1) - 1 ); return TOK_STRING_LITERAL;
+
+{multicomment} /* nothing */
+
+{other} return (int) yytext[0];
+
+. /* nothing */
+
+%% \ No newline at end of file
diff --git a/src/genbind-parser.y b/src/genbind-parser.y
new file mode 100644
index 0000000..309f01e
--- /dev/null
+++ b/src/genbind-parser.y
@@ -0,0 +1,62 @@
+/*
+ * This is a bison parser for genbind
+ *
+ */
+
+%{
+
+#include <stdio.h>
+#include <string.h>
+
+#include "genbind-parser.h"
+#include "genbind-lexer.h"
+
+ extern int loadwebidl(char *filename);
+
+void genbind_error(const char *str)
+{
+ fprintf(stderr,"error: %s\n",str);
+}
+
+
+int genbind_wrap()
+{
+ return 1;
+}
+
+
+
+%}
+
+%output "genbind-parser.c"
+%defines "genbind-parser.h"
+
+%define api.pure
+%name-prefix "genbind_"
+
+%union
+{
+ char* text;
+}
+
+%token TOK_IDLFILE
+
+%token <text> TOK_STRING_LITERAL
+
+%%
+
+ /* [1] start with instructions */
+Instructions:
+ /* empty */
+ |
+ IdlFile
+ ;
+
+IdlFile:
+ TOK_IDLFILE TOK_STRING_LITERAL
+ {
+ loadwebidl($2);
+ }
+ ;
+
+%%
diff --git a/src/genjsbind.c b/src/genjsbind.c
new file mode 100644
index 0000000..150c780
--- /dev/null
+++ b/src/genjsbind.c
@@ -0,0 +1,52 @@
+#include <stdio.h>
+
+#include "webidl-ast.h"
+
+#include "webidl-parser.h"
+#include "genbind-parser.h"
+
+extern int webidl_debug;
+extern FILE* webidl_in;
+extern int webidl_parse();
+
+extern int genbind_debug;
+extern FILE* genbind_in;
+extern int genbind_parse();
+
+int loadwebidl(char *filename)
+{
+ FILE *myfile = fopen(filename, "r");
+ if (!myfile) {
+ perror(filename);
+ return 2;
+ }
+ /* set flex to read from file */
+ webidl_in = myfile;
+
+ webidl_debug = 1;
+
+ /* parse through the input until there is no more: */
+ while (!feof(webidl_in)) {
+ webidl_parse();
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ FILE *myfile = fopen("htmldocument.bnd", "r");
+ if (!myfile) {
+ perror(NULL);
+ return 2;
+ }
+ /* set flex to read from file */
+ genbind_in = myfile;
+
+ genbind_debug = 1;
+
+ /* parse through the input until there is no more: */
+ while (!feof(genbind_in)) {
+ genbind_parse();
+ }
+ return 0;
+}
diff --git a/src/webidl-ast.h b/src/webidl-ast.h
new file mode 100644
index 0000000..96d7c2a
--- /dev/null
+++ b/src/webidl-ast.h
@@ -0,0 +1,2 @@
+ struct ifmembers_s {
+ };
diff --git a/src/webidl-lexer.l b/src/webidl-lexer.l
new file mode 100644
index 0000000..f605575
--- /dev/null
+++ b/src/webidl-lexer.l
@@ -0,0 +1,284 @@
+/*
+ * This is a unicode capable lexer for web IDL mostly derived from:
+ *
+ * W3C WEB IDL - http://www.w3.org/TR/WebIDL/ (especially the grammar
+ * in apendix A)
+ *
+ * The ECMA script spec -
+ * http://ecma-international.org/ecma-262/5.1/#sec-7.2 (expecially
+ * section 7.2 for unicode value handling)
+ */
+
+/* lexer options */
+%option outfile="webidl-lexer.c"
+%option header-file="webidl-lexer.h"
+%option never-interactive
+%option yylineno
+%option bison-bridge
+%option bison-locations
+%option nodefault
+%option warn
+%option debug
+%option prefix="webidl_"
+%option nounput
+
+/* header block */
+%{
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "webidl-parser.h"
+
+#define YY_USER_ACTION yylloc->first_line = yylloc->last_line; \
+ yylloc->first_column = yylloc->last_column + 1; \
+ yylloc->last_column += yyleng;
+
+%}
+
+/* regular definitions */
+
+ /* ecmascript section 7.2 defines whitespace http://ecma-international.org/ecma-262/5.1/#sec-7.2
+ * Web IDL appendix A has the IDL grammar http://www.w3.org/TR/WebIDL/#idl-grammar
+ */
+
+ /* we do not define space, line feed, carriage return, tab, vertical
+ * tab or form feed here as they are the standard C escapes
+ */
+
+ /* other Unicode “space separator” */
+USP (\xe1\x9a\x80)|(\xe1\xa0\x8e)|(\xe2\x80[\x80-\x8a])|(\xe2\x80\xaf)|(\xe2\x81\x9f)|(\xe3\x80\x80)
+
+/* Line separator \u2028 */
+LS (\xe2\x80\xa8)
+
+/* paragraph separator \u2029 */
+PS (\xe2\x80\xa9)
+
+/* non breaking space \u00A0 */
+NBSP (\xc2\xa0)
+
+/* web idl grammar for whitespace matches single and multiline
+ * comments too. Here there are separate definitions for both single
+ * and multiline comments.
+ */
+whitespace ([ \t\v\f]|{NBSP}|{USP})
+multicomment \/\*(([^*])|(\*[^/]))*\*\/
+singlecomment \/\/
+lineend ([\n\r]|{LS}|{PS})
+
+/* integer numbers in hexidecimal, decimal and octal, slight extension
+ * to spec which only allows for decimal values
+ */
+hexdigit [0-9A-Fa-f]
+hexint 0(x|X){hexdigit}+
+
+decimalint 0|([1-9][0-9]*)
+
+octalint (0[0-8]+)
+
+/* decimal floating point number */
+decimalexponent (e|E)[\+\-]?[0-9]+
+decimalfloat ({decimalint}\.[0-9]*{decimalexponent}?)|(\.[0-9]+{decimalexponent}?)|({decimalint}{decimalexponent}?)
+
+/* quoted string. spec simply has "[^"]*" but here escapes are allowed for */
+hexescseq x{hexdigit}{2}
+unicodeescseq u{hexdigit}{4}
+characterescseq ['\"\\bfnrtv]|[^'\"\\bfnrtv\n\r]
+escseq {characterescseq}|0|{hexescseq}|{unicodeescseq}
+quotedstring ([^\"\\\n\r]|\\{escseq})
+
+/* web idl identifier direct from spec */
+Identifier [A-Z_a-z][0-9A-Z_a-z]*
+
+/* web idl other direct from spec */
+other [^\t\n\r 0-9A-Z_a-z]
+
+/* used for #include directive - not part of web idl spec */
+poundsign ^{whitespace}*#
+
+%x incl
+%%
+
+{whitespace} ++yylloc->last_column; /* skip whitespace */
+
+{lineend} if (yytext[0] == '\n') {
+ /* update position counts */
+ ++yylloc->last_line;
+ yylloc->last_column = 0;
+ }
+
+ /* Simple text terminals */
+
+boolean return TOK_BOOLEAN;
+
+byte return TOK_BYTE;
+
+octet return TOK_OCTET;
+
+attribute return TOK_ATTRIBUTE;
+
+callback return TOK_CALLBACK;
+
+const return TOK_CONST;
+
+creator return TOK_CREATOR;
+
+deleter return TOK_DELETER;
+
+dictionary return TOK_DICTIONARY;
+
+enum return TOK_ENUM;
+
+exception return TOK_EXCEPTION;
+
+getter return TOK_GETTER;
+
+implements return TOK_IMPLEMENTS;
+
+inherit return TOK_INHERIT;
+
+interface return TOK_INTERFACE;
+
+legacycaller return TOK_LEGACYCALLER;
+
+partial return TOK_PARTIAL;
+
+setter return TOK_SETTER;
+
+static return TOK_STATIC;
+
+stringifier return TOK_STRINGIFIER;
+
+typedef return TOK_TYPEDEF;
+
+unrestricted return TOK_UNRESTRICTED;
+
+"..." return TOK_ELLIPSIS;
+
+Date return TOK_DATE;
+
+DOMString return TOK_STRING; /* dom strings are just strings */
+
+Infinity return TOK_INFINITY;
+
+NaN return TOK_NAN;
+
+any return TOK_ANY;
+
+double return TOK_DOUBLE;
+
+false return TOK_FALSE;
+
+float return TOK_FLOAT;
+
+long return TOK_LONG;
+
+null return TOK_NULL_LITERAL;
+
+object yylval->text = strdup(yytext); return TOK_IDENTIFIER;
+
+or return TOK_OR;
+
+optional return TOK_OPTIONAL;
+
+sequence return TOK_SEQUENCE;
+
+short return TOK_SHORT;
+
+true return TOK_TRUE;
+
+unsigned return TOK_UNSIGNED;
+
+void return TOK_VOID;
+
+readonly return TOK_READONLY;
+
+
+{Identifier} {
+ // A leading "_" is used to escape an identifier from looking like a reserved word terminal.
+ yylval->text = (yytext[0] == '_') ? strdup(yytext + 1) : strdup(yytext);
+ return TOK_IDENTIFIER;
+ }
+
+{decimalint} yylval->value = strtol(yytext, NULL, 10); return TOK_INT_LITERAL;
+
+{octalint} yylval->value = strtol(yytext, NULL, 8); return TOK_INT_LITERAL;
+
+{hexint} yylval->value = strtol(yytext, NULL, 16); return TOK_INT_LITERAL;
+
+{decimalfloat} yylval->text = strdup(yytext); return TOK_FLOAT_LITERAL;
+
+\"{quotedstring}*\" yylval->text = strdup(yytext); return TOK_STRING_LITERAL;
+
+{multicomment} {
+ /* multicomment */
+ char* s = yytext;
+ for (; *s; ++s)
+ {
+ if (*s == '\n')
+ {
+ ++yylloc->last_line;
+ yylloc->last_column = 0;
+ }
+ else
+ {
+ ++yylloc->last_column;
+ }
+ }
+ if (strncmp(yytext, "/**", 3) == 0)
+ {
+ /* Javadoc style comment */
+ yylval->text = strdup(yytext);
+ return TOK_JAVADOC;
+ }
+ }
+
+{singlecomment} {
+ /* singlecomment */
+ int c;
+
+ do {
+ c = input();
+ } while (c != '\n' && c != '\r' && c != EOF);
+ ++yylloc->last_line;
+ yylloc->last_column = 0;
+ }
+
+
+
+{poundsign}include BEGIN(incl);
+
+{other} return (int) yytext[0];
+
+<incl>[ \t]*\" /* eat the whitespace and open quotes */
+
+<incl>[^\t\n\"]+ {
+ /* got the include file name */
+ yyin = fopen( yytext, "r" );
+
+ if ( ! yyin ) {
+ fprintf(stderr, "Unable to open include %s\n", yytext);
+ exit(3);
+ }
+ yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE ));
+
+ BEGIN(INITIAL);
+ }
+
+<incl>\n BEGIN(INITIAL);
+
+<<EOF>> {
+ yypop_buffer_state();
+
+ if ( !YY_CURRENT_BUFFER ) {
+ yyterminate();
+ } else {
+ BEGIN(incl);
+ }
+
+ }
+
+
+%%
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
new file mode 100644
index 0000000..d5859ff
--- /dev/null
+++ b/src/webidl-parser.y
@@ -0,0 +1,762 @@
+/*
+ * This is a bison parser for web IDL derived from the the grammar in
+ * apendix A of W3C WEB IDL - http://www.w3.org/TR/WebIDL/
+ *
+ */
+
+%{
+
+#include <stdio.h>
+#include <string.h>
+
+#include "webidl-ast.h"
+
+#include "webidl-parser.h"
+#include "webidl-lexer.h"
+
+
+
+void webidl_error(const char *str)
+{
+ fprintf(stderr,"error: %s\n",str);
+}
+
+int webidl_wrap()
+{
+ return 1;
+}
+
+
+
+%}
+
+%output "webidl-parser.c"
+%defines "webidl-parser.h"
+
+%locations
+%define api.pure
+%name-prefix "webidl_"
+
+%union
+{
+ int attr;
+ char* text;
+ long value;
+ struct ifmember_s **ifmember;
+}
+
+
+%token TOK_ANY
+%token TOK_ATTRIBUTE
+%token TOK_BOOLEAN
+%token TOK_BYTE
+%token TOK_CALLBACK
+%token TOK_LEGACYCALLER
+%token TOK_CONST
+%token TOK_CREATOR
+%token TOK_DATE
+%token TOK_DELETER
+%token TOK_DICTIONARY
+%token TOK_DOUBLE
+%token TOK_ELLIPSIS
+%token TOK_ENUM
+%token TOK_EOL
+%token TOK_EXCEPTION
+%token TOK_FALSE
+%token TOK_FLOAT
+%token TOK_GETRAISES
+%token TOK_GETTER
+%token TOK_IMPLEMENTS
+%token TOK_IN
+%token TOK_INFINITY
+%token TOK_INHERIT
+%token TOK_INTERFACE
+%token TOK_LONG
+%token TOK_MODULE
+%token TOK_NAN
+%token TOK_NATIVE
+%token TOK_NULL_LITERAL
+%token TOK_OBJECT
+%token TOK_OCTET
+%token TOK_OMITTABLE
+%token TOK_OPTIONAL
+%token TOK_OR
+%token TOK_PARTIAL
+%token TOK_RAISES
+%token TOK_READONLY
+%token TOK_SETRAISES
+%token TOK_SETTER
+%token TOK_SEQUENCE
+%token TOK_SHORT
+%token TOK_STATIC
+%token TOK_STRING
+%token TOK_STRINGIFIER
+%token TOK_TRUE
+%token TOK_TYPEDEF
+%token TOK_UNRESTRICTED
+%token TOK_UNSIGNED
+%token TOK_VOID
+
+%token TOK_POUND_SIGN
+
+%token <text> TOK_IDENTIFIER
+%token <value> TOK_INT_LITERAL
+%token <text> TOK_FLOAT_LITERAL
+%token <text> TOK_STRING_LITERAL
+%token <text> TOK_OTHER_LITERAL
+%token <text> TOK_JAVADOC
+
+%type <text> Inheritance
+%type <ifmember> InterfaceMembers
+
+%%
+
+ /* [1] start with definitions */
+Definitions:
+ /* empty */
+ |
+ ExtendedAttributeList Definition Definitions
+ ;
+
+ /* [2] */
+Definition:
+ CallbackOrInterface
+ |
+ Partial
+ |
+ Dictionary
+ |
+ Exception
+ |
+ Enum
+ |
+ Typedef
+ |
+ ImplementsStatement
+ ;
+
+ /* [3] */
+CallbackOrInterface:
+ TOK_CALLBACK CallbackRestOrInterface
+ |
+ Interface
+ ;
+
+ /* [4] */
+CallbackRestOrInterface:
+ CallbackRest
+ |
+ Interface
+ ;
+
+ /* [5] */
+Interface:
+ TOK_INTERFACE TOK_IDENTIFIER Inheritance '{' InterfaceMembers '}' ';'
+ {
+ }
+ ;
+
+ /* [6] */
+Partial:
+ TOK_PARTIAL PartialDefinition
+ ;
+
+ /* [7] */
+PartialDefinition:
+ PartialInterface
+ |
+ PartialDictionary
+ ;
+
+ /* [8] */
+PartialInterface:
+ TOK_INTERFACE TOK_IDENTIFIER '{' InterfaceMembers '}' ';'
+ ;
+
+ /* [9] */
+InterfaceMembers:
+ /* empty */
+ {
+ $$ = NULL;
+ }
+ |
+ ExtendedAttributeList InterfaceMember InterfaceMembers
+ {
+ $$ = NULL;
+ }
+ ;
+
+ /* [10] */
+InterfaceMember:
+ Const
+ |
+ AttributeOrOperation
+ ;
+
+ /* [11] */
+Dictionary:
+ TOK_DICTIONARY TOK_IDENTIFIER Inheritance '{' DictionaryMembers '}' ';'
+ ;
+
+ /* [12] */
+DictionaryMembers:
+ /* empty */
+ |
+ ExtendedAttributeList DictionaryMember DictionaryMembers
+ ;
+
+ /* [13] */
+DictionaryMember:
+ Type TOK_IDENTIFIER Default ";"
+ ;
+
+ /* [14] */
+PartialDictionary:
+ TOK_DICTIONARY TOK_IDENTIFIER '{' DictionaryMembers '}' ';'
+
+ /* [15] */
+Default:
+ /* empty */
+ |
+ '=' DefaultValue
+ ;
+
+
+ /* [16] */
+DefaultValue:
+ ConstValue
+ |
+ TOK_STRING_LITERAL
+ ;
+
+ /* [17] */
+Exception:
+ /* empty */
+ |
+ TOK_EXCEPTION TOK_IDENTIFIER Inheritance '{' ExceptionMembers '}' ';'
+ ;
+
+ /* [18] */
+ExceptionMembers:
+ /* empty */
+ |
+ ExtendedAttributeList ExceptionMember ExceptionMembers
+ ;
+
+ /* [19] returns a string */
+Inheritance:
+ /* empty */
+ {
+ $$ = NULL;
+ }
+ |
+ ':' TOK_IDENTIFIER
+ {
+ $$ = $2;
+ }
+ ;
+
+/* [20] */
+Enum:
+ TOK_ENUM TOK_IDENTIFIER '{' EnumValueList '}' ';'
+ ;
+
+/* [21] */
+EnumValueList:
+ TOK_STRING_LITERAL EnumValues
+ ;
+
+/* [22] */
+EnumValues:
+ /* empty */
+ |
+ ',' TOK_STRING_LITERAL EnumValues
+ ;
+
+ /* [23] - bug in w3c grammar? it doesnt list the equals as a terminal */
+CallbackRest:
+ TOK_IDENTIFIER '=' ReturnType '(' ArgumentList ')' ';'
+
+ /* [24] */
+Typedef:
+ TOK_TYPEDEF ExtendedAttributeList Type TOK_IDENTIFIER ';'
+ ;
+
+ /* [25] */
+ImplementsStatement:
+ TOK_IDENTIFIER TOK_IMPLEMENTS TOK_IDENTIFIER ';'
+ ;
+
+ /* [26] */
+Const:
+ TOK_CONST ConstType TOK_IDENTIFIER '=' ConstValue ';'
+ ;
+
+ /* [27] */
+ConstValue:
+ BooleanLiteral
+ |
+ FloatLiteral
+ |
+ TOK_INT_LITERAL
+ |
+ TOK_NULL_LITERAL
+ ;
+
+ /* [28] */
+BooleanLiteral:
+ TOK_TRUE
+ |
+ TOK_FALSE
+ ;
+
+ /* [29] */
+FloatLiteral:
+ TOK_FLOAT_LITERAL
+ |
+ '-' TOK_INFINITY
+ |
+ TOK_INFINITY
+ |
+ TOK_NAN
+ ;
+
+ /* [30] */
+AttributeOrOperation:
+ TOK_STRINGIFIER StringifierAttributeOrOperation
+ |
+ Attribute
+ |
+ Operation
+ ;
+
+ /* [31] */
+StringifierAttributeOrOperation:
+ Attribute
+ |
+ OperationRest
+ |
+ ';'
+ ;
+
+ /* [32] */
+Attribute:
+ Inherit ReadOnly TOK_ATTRIBUTE Type TOK_IDENTIFIER ';'
+ ;
+
+ /* [33] */
+Inherit:
+ /* empty */
+ |
+ TOK_INHERIT
+ ;
+
+ /* [34] */
+ReadOnly:
+ /* empty */
+ |
+ TOK_READONLY
+ ;
+
+ /* [35] */
+Operation:
+ Qualifiers OperationRest
+ ;
+
+ /* [36] */
+Qualifiers:
+ TOK_STATIC
+ |
+ Specials
+ ;
+
+ /* [37] */
+Specials:
+ /* empty */
+ |
+ Special Specials
+ ;
+
+ /* [38] */
+Special:
+ TOK_GETTER
+ |
+ TOK_SETTER
+ |
+ TOK_CREATOR
+ |
+ TOK_DELETER
+ |
+ TOK_LEGACYCALLER
+ ;
+
+ /* [39] */
+OperationRest:
+ ReturnType OptionalIdentifier '(' ArgumentList ')' ';'
+ ;
+
+ /* [40] */
+OptionalIdentifier:
+ /* empty */
+ |
+ TOK_IDENTIFIER
+ ;
+
+
+ /* [41] */
+ArgumentList:
+ /* empty */
+ |
+ Argument Arguments
+ ;
+
+ /* [42] */
+Arguments:
+ /* empty */
+ |
+ ',' Argument Arguments
+ ;
+
+
+ /* [43] */
+Argument:
+ ExtendedAttributeList OptionalOrRequiredArgument
+ ;
+
+ /* [44] */
+OptionalOrRequiredArgument:
+ TOK_OPTIONAL Type ArgumentName Default
+ |
+ Type Ellipsis ArgumentName
+ ;
+
+ /* [45] */
+ArgumentName:
+ ArgumentNameKeyword
+ |
+ TOK_IDENTIFIER
+ ;
+
+ /* [46] */
+Ellipsis:
+ /* empty */
+ |
+ TOK_ELLIPSIS
+ ;
+
+ /* [47] */
+ExceptionMember:
+ Const
+ |
+ ExceptionField
+ ;
+
+ /* [48] */
+ExceptionField:
+ Type TOK_IDENTIFIER ';'
+ ;
+
+ /* [49] extended attribute list inside square brackets */
+ExtendedAttributeList:
+ /* empty */
+ |
+ '[' ExtendedAttribute ExtendedAttributes ']'
+ ;
+
+ /* [50] extended attributes are separated with a comma */
+ExtendedAttributes:
+ /* empty */
+ |
+ ',' ExtendedAttribute ExtendedAttributes
+ ;
+
+ /* [51] extended attributes are nested with normal, square and curly braces */
+ExtendedAttribute:
+ '(' ExtendedAttributeInner ')' ExtendedAttributeRest
+ |
+ '[' ExtendedAttributeInner ']' ExtendedAttributeRest
+ |
+ '{' ExtendedAttributeInner '}' ExtendedAttributeRest
+ |
+ Other ExtendedAttributeRest
+ ;
+
+ /* [52] extended attributes can be space separated too */
+ExtendedAttributeRest:
+ /* empty */
+ |
+ ExtendedAttribute
+ ;
+
+ /* [53] extended attributes are nested with normal, square and curly braces */
+ExtendedAttributeInner:
+ /* empty */
+ |
+ '(' ExtendedAttributeInner ')' ExtendedAttributeInner
+ |
+ '[' ExtendedAttributeInner ']' ExtendedAttributeInner
+ |
+ '{' ExtendedAttributeInner '}' ExtendedAttributeInner
+ |
+ OtherOrComma ExtendedAttributeInner
+ ;
+
+ /* [54] */
+Other:
+ TOK_INT_LITERAL
+ |
+ TOK_FLOAT_LITERAL
+ |
+ TOK_IDENTIFIER
+ |
+ TOK_STRING_LITERAL
+ |
+ TOK_OTHER_LITERAL
+ |
+ '-'
+ |
+ '.'
+ |
+ TOK_ELLIPSIS
+ |
+ ':'
+ |
+ ';'
+ |
+ '<'
+ |
+ '='
+ |
+ '>'
+ |
+ '?'
+ |
+ TOK_DATE
+ |
+ TOK_STRING
+ |
+ TOK_INFINITY
+ |
+ TOK_NAN
+ |
+ TOK_ANY
+ |
+ TOK_BOOLEAN
+ |
+ TOK_BYTE
+ |
+ TOK_DOUBLE
+ |
+ TOK_FALSE
+ |
+ TOK_FLOAT
+ |
+ TOK_LONG
+ |
+ TOK_NULL_LITERAL
+ |
+ TOK_OBJECT
+ |
+ TOK_OCTET
+ |
+ TOK_OR
+ |
+ TOK_OPTIONAL
+ |
+ TOK_SEQUENCE
+ |
+ TOK_SHORT
+ |
+ TOK_TRUE
+ |
+ TOK_UNSIGNED
+ |
+ TOK_VOID
+ |
+ ArgumentNameKeyword
+ ;
+
+ /* [55] */
+ArgumentNameKeyword:
+ TOK_ATTRIBUTE
+ |
+ TOK_CALLBACK
+ |
+ TOK_CONST
+ |
+ TOK_CREATOR
+ |
+ TOK_DELETER
+ |
+ TOK_DICTIONARY
+ |
+ TOK_ENUM
+ |
+ TOK_EXCEPTION
+ |
+ TOK_GETTER
+ |
+ TOK_IMPLEMENTS
+ |
+ TOK_INHERIT
+ |
+ TOK_INTERFACE
+ |
+ TOK_LEGACYCALLER
+ |
+ TOK_PARTIAL
+ |
+ TOK_SETTER
+ |
+ TOK_STATIC
+ |
+ TOK_STRINGIFIER
+ |
+ TOK_TYPEDEF
+ |
+ TOK_UNRESTRICTED
+ ;
+
+ /* [56] as it says an other element or a comma */
+OtherOrComma:
+ Other
+ |
+ ','
+ ;
+
+ /* [57] */
+Type:
+ SingleType
+ |
+ UnionType TypeSuffix
+ ;
+
+ /* [58] */
+SingleType:
+ NonAnyType
+ |
+ TOK_ANY TypeSuffixStartingWithArray
+ ;
+
+ /* [59] */
+UnionType:
+ '(' UnionMemberType TOK_OR UnionMemberType UnionMemberTypes ')'
+ ;
+
+ /* [60] */
+UnionMemberType:
+ NonAnyType
+ |
+ UnionType TypeSuffix
+ |
+ TOK_ANY '[' ']' TypeSuffix
+ ;
+
+ /* [61] */
+UnionMemberTypes:
+ /* empty */
+ |
+ TOK_OR UnionMemberType UnionMemberTypes
+ ;
+
+ /* [62] */
+NonAnyType:
+ PrimitiveType TypeSuffix
+ |
+ TOK_STRING TypeSuffix
+ |
+ TOK_IDENTIFIER TypeSuffix
+ |
+ TOK_SEQUENCE '<' Type '>' Null
+ |
+ TOK_OBJECT TypeSuffix
+ |
+ TOK_DATE TypeSuffix
+ ;
+
+ /* [63] */
+ConstType:
+ PrimitiveType Null
+ |
+ TOK_IDENTIFIER Null
+ ;
+
+ /* [64] */
+PrimitiveType:
+ UnsignedIntegerType
+ |
+ UnrestrictedFloatType
+ |
+ TOK_BOOLEAN
+ |
+ TOK_BYTE
+ |
+ TOK_OCTET
+ ;
+
+ /* [65] */
+UnrestrictedFloatType:
+ TOK_UNRESTRICTED FloatType
+ |
+ FloatType
+ ;
+
+ /* [66] */
+FloatType:
+ TOK_FLOAT
+ |
+ TOK_DOUBLE
+ ;
+
+ /* [67] */
+UnsignedIntegerType:
+ TOK_UNSIGNED IntegerType
+ |
+ IntegerType
+ ;
+
+ /* [68] */
+IntegerType:
+ TOK_SHORT
+ |
+ TOK_LONG OptionalLong
+ ;
+
+ /* [69] */
+OptionalLong:
+ /* empty */
+ |
+ TOK_LONG
+ ;
+
+ /* [70] */
+TypeSuffix:
+ /* empty */
+ |
+ '[' ']' TypeSuffix
+ |
+ '?' TypeSuffixStartingWithArray
+ ;
+
+ /* [71] */
+TypeSuffixStartingWithArray:
+ /* empty */
+ |
+ '[' ']' TypeSuffix
+ ;
+
+ /* [72] */
+Null:
+ /* empty */
+ |
+ '?'
+ ;
+
+ /* [73] */
+ReturnType:
+ Type
+ |
+ TOK_VOID
+ ;
+
+%%
diff --git a/test/document.idl b/test/document.idl
new file mode 100644
index 0000000..afab566
--- /dev/null
+++ b/test/document.idl
@@ -0,0 +1,37 @@
+interface Document : Node {
+ readonly attribute DOMImplementation implementation;
+ readonly attribute DOMString URL;
+ readonly attribute DOMString documentURI;
+ readonly attribute DOMString compatMode;
+ readonly attribute DOMString characterSet;
+ readonly attribute DOMString contentType;
+
+ readonly attribute DocumentType? doctype;
+ readonly attribute Element? documentElement;
+ HTMLCollection getElementsByTagName(DOMString localName);
+ HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
+ HTMLCollection getElementsByClassName(DOMString classNames);
+ Element? getElementById(DOMString elementId);
+
+ Element createElement(DOMString localName);
+ Element createElementNS(DOMString? namespace, DOMString qualifiedName);
+ DocumentFragment createDocumentFragment();
+ Text createTextNode(DOMString data);
+ Comment createComment(DOMString data);
+ ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
+
+ Node importNode(Node node, optional boolean deep = true);
+ Node adoptNode(Node node);
+
+ Event createEvent(DOMString interface);
+
+ Range createRange();
+
+ // NodeFilter.SHOW_ALL = 0xFFFFFFFF
+ NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
+ TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
+
+ // NEW
+ void prepend((Node or DOMString)... nodes);
+ void append((Node or DOMString)... nodes);
+};
diff --git a/test/eventtarget.idl b/test/eventtarget.idl
new file mode 100644
index 0000000..2cfd15e
--- /dev/null
+++ b/test/eventtarget.idl
@@ -0,0 +1,5 @@
+interface EventTarget {
+ void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false);
+ void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false);
+ boolean dispatchEvent(Event event);
+};
diff --git a/test/htmldocument.bnd b/test/htmldocument.bnd
new file mode 100644
index 0000000..6f02c75
--- /dev/null
+++ b/test/htmldocument.bnd
@@ -0,0 +1,3 @@
+/* test binding docuemnt */
+
+webidlfile "htmldocument.idl"
diff --git a/test/htmldocument.idl b/test/htmldocument.idl
new file mode 100644
index 0000000..923aa08
--- /dev/null
+++ b/test/htmldocument.idl
@@ -0,0 +1,108 @@
+[OverrideBuiltins]
+partial interface Document {
+ // resource metadata management
+ [PutForwards=href] readonly attribute Location? location;
+ attribute DOMString domain;
+ readonly attribute DOMString referrer;
+ attribute DOMString cookie;
+ readonly attribute DOMString lastModified;
+ readonly attribute DOMString readyState;
+
+ // DOM tree accessors
+ getter object (DOMString name);
+ attribute DOMString title;
+ attribute DOMString dir;
+ attribute HTMLElement? body;
+ readonly attribute HTMLHeadElement? head;
+ readonly attribute HTMLCollection images;
+ readonly attribute HTMLCollection embeds;
+ readonly attribute HTMLCollection plugins;
+ readonly attribute HTMLCollection links;
+ readonly attribute HTMLCollection forms;
+ readonly attribute HTMLCollection scripts;
+ NodeList getElementsByName(DOMString elementName);
+ NodeList getItems(optional DOMString typeNames); // microdata
+ readonly attribute DOMElementMap cssElementMap;
+
+ // dynamic markup insertion
+ Document open(optional DOMString type, optional DOMString replace);
+ WindowProxy open(DOMString url, DOMString name, DOMString features, optional boolean replace);
+ void close();
+ void write(DOMString... text);
+ void writeln(DOMString... text);
+
+ // user interaction
+ readonly attribute WindowProxy? defaultView;
+ readonly attribute Element? activeElement;
+ boolean hasFocus();
+ attribute DOMString designMode;
+ boolean execCommand(DOMString commandId);
+ boolean execCommand(DOMString commandId, boolean showUI);
+ boolean execCommand(DOMString commandId, boolean showUI, DOMString value);
+ boolean queryCommandEnabled(DOMString commandId);
+ boolean queryCommandIndeterm(DOMString commandId);
+ boolean queryCommandState(DOMString commandId);
+ boolean queryCommandSupported(DOMString commandId);
+ DOMString queryCommandValue(DOMString commandId);
+ readonly attribute HTMLCollection commands;
+
+ // event handler IDL attributes
+ attribute EventHandler onabort;
+ attribute EventHandler onblur;
+ attribute EventHandler oncancel;
+ attribute EventHandler oncanplay;
+ attribute EventHandler oncanplaythrough;
+ attribute EventHandler onchange;
+ attribute EventHandler onclick;
+ attribute EventHandler onclose;
+ attribute EventHandler oncontextmenu;
+ attribute EventHandler oncuechange;
+ attribute EventHandler ondblclick;
+ attribute EventHandler ondrag;
+ attribute EventHandler ondragend;
+ attribute EventHandler ondragenter;
+ attribute EventHandler ondragleave;
+ attribute EventHandler ondragover;
+ attribute EventHandler ondragstart;
+ attribute EventHandler ondrop;
+ attribute EventHandler ondurationchange;
+ attribute EventHandler onemptied;
+ attribute EventHandler onended;
+ attribute OnErrorEventHandler onerror;
+ attribute EventHandler onfocus;
+ attribute EventHandler oninput;
+ attribute EventHandler oninvalid;
+ attribute EventHandler onkeydown;
+ attribute EventHandler onkeypress;
+ attribute EventHandler onkeyup;
+ attribute EventHandler onload;
+ attribute EventHandler onloadeddata;
+ attribute EventHandler onloadedmetadata;
+ attribute EventHandler onloadstart;
+ attribute EventHandler onmousedown;
+ attribute EventHandler onmousemove;
+ attribute EventHandler onmouseout;
+ attribute EventHandler onmouseover;
+ attribute EventHandler onmouseup;
+ attribute EventHandler onmousewheel;
+ attribute EventHandler onpause;
+ attribute EventHandler onplay;
+ attribute EventHandler onplaying;
+ attribute EventHandler onprogress;
+ attribute EventHandler onratechange;
+ attribute EventHandler onreset;
+ attribute EventHandler onscroll;
+ attribute EventHandler onseeked;
+ attribute EventHandler onseeking;
+ attribute EventHandler onselect;
+ attribute EventHandler onshow;
+ attribute EventHandler onstalled;
+ attribute EventHandler onsubmit;
+ attribute EventHandler onsuspend;
+ attribute EventHandler ontimeupdate;
+ attribute EventHandler onvolumechange;
+ attribute EventHandler onwaiting;
+
+ // special event handler IDL attributes that only apply to Document objects
+ [LenientThis] attribute EventHandler onreadystatechange;
+};
diff --git a/test/window.idl b/test/window.idl
new file mode 100644
index 0000000..7114709
--- /dev/null
+++ b/test/window.idl
@@ -0,0 +1,119 @@
+#include "eventtarget.idl"
+
+[NamedPropertiesObject]
+interface Window : EventTarget {
+ // the current browsing context
+ [Unforgeable] readonly attribute WindowProxy window;
+ [Replaceable] readonly attribute WindowProxy self;
+ [Unforgeable] readonly attribute Document document;
+ attribute DOMString name;
+ [PutForwards=href, Unforgeable] readonly attribute Location location;
+ readonly attribute History history;
+ [Replaceable] readonly attribute BarProp locationbar;
+ [Replaceable] readonly attribute BarProp menubar;
+ [Replaceable] readonly attribute BarProp personalbar;
+ [Replaceable] readonly attribute BarProp scrollbars;
+ [Replaceable] readonly attribute BarProp statusbar;
+ [Replaceable] readonly attribute BarProp toolbar;
+ attribute DOMString status;
+ void close();
+ void stop();
+ void focus();
+ void blur();
+
+ // other browsing contexts
+ [Replaceable] readonly attribute WindowProxy frames;
+ [Replaceable] readonly attribute unsigned long length;
+ [Unforgeable] readonly attribute WindowProxy top;
+ attribute WindowProxy? opener;
+ readonly attribute WindowProxy parent;
+ readonly attribute Element? frameElement;
+ WindowProxy open(optional DOMString url, optional DOMString target, optional DOMString features, optional boolean replace);
+ getter WindowProxy (unsigned long index);
+ getter object (DOMString name);
+
+ // the user agent
+ readonly attribute Navigator navigator;
+ readonly attribute External external;
+ readonly attribute ApplicationCache applicationCache;
+
+ // user prompts
+ void alert(DOMString message);
+ boolean confirm(DOMString message);
+ DOMString? prompt(DOMString message, optional DOMString default);
+ void print();
+ any showModalDialog(DOMString url, optional any argument);
+
+ // cross-document messaging
+ void postMessage(any message, DOMString targetOrigin, optional sequence<Transferable> transfer);
+
+ // event handler IDL attributes
+ attribute EventHandler onabort;
+ attribute EventHandler onafterprint;
+ attribute EventHandler onbeforeprint;
+ attribute EventHandler onbeforeunload;
+ attribute EventHandler onblur;
+ attribute EventHandler oncancel;
+ attribute EventHandler oncanplay;
+ attribute EventHandler oncanplaythrough;
+ attribute EventHandler onchange;
+ attribute EventHandler onclick;
+ attribute EventHandler onclose;
+ attribute EventHandler oncontextmenu;
+ attribute EventHandler oncuechange;
+ attribute EventHandler ondblclick;
+ attribute EventHandler ondrag;
+ attribute EventHandler ondragend;
+ attribute EventHandler ondragenter;
+ attribute EventHandler ondragleave;
+ attribute EventHandler ondragover;
+ attribute EventHandler ondragstart;
+ attribute EventHandler ondrop;
+ attribute EventHandler ondurationchange;
+ attribute EventHandler onemptied;
+ attribute EventHandler onended;
+ attribute OnErrorEventHandler onerror;
+ attribute EventHandler onfocus;
+ attribute EventHandler onhashchange;
+ attribute EventHandler oninput;
+ attribute EventHandler oninvalid;
+ attribute EventHandler onkeydown;
+ attribute EventHandler onkeypress;
+ attribute EventHandler onkeyup;
+ attribute EventHandler onload;
+ attribute EventHandler onloadeddata;
+ attribute EventHandler onloadedmetadata;
+ attribute EventHandler onloadstart;
+ attribute EventHandler onmessage;
+ attribute EventHandler onmousedown;
+ attribute EventHandler onmousemove;
+ attribute EventHandler onmouseout;
+ attribute EventHandler onmouseover;
+ attribute EventHandler onmouseup;
+ attribute EventHandler onmousewheel;
+ attribute EventHandler onoffline;
+ attribute EventHandler ononline;
+ attribute EventHandler onpause;
+ attribute EventHandler onplay;
+ attribute EventHandler onplaying;
+ attribute EventHandler onpagehide;
+ attribute EventHandler onpageshow;
+ attribute EventHandler onpopstate;
+ attribute EventHandler onprogress;
+ attribute EventHandler onratechange;
+ attribute EventHandler onreset;
+ attribute EventHandler onresize;
+ attribute EventHandler onscroll;
+ attribute EventHandler onseeked;
+ attribute EventHandler onseeking;
+ attribute EventHandler onselect;
+ attribute EventHandler onshow;
+ attribute EventHandler onstalled;
+ attribute EventHandler onstorage;
+ attribute EventHandler onsubmit;
+ attribute EventHandler onsuspend;
+ attribute EventHandler ontimeupdate;
+ attribute EventHandler onunload;
+ attribute EventHandler onvolumechange;
+ attribute EventHandler onwaiting;
+};