nsgenjsbind: branch master updated. 751839d208b02af3d0a2329e6d75a90d51a247ff
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/751839d208b02af3d...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/751839d208b02af3d0a...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/751839d208b02af3d0a23...
The branch, master has been updated
via 751839d208b02af3d0a2329e6d75a90d51a247ff (commit)
via 141796f3e78e8b134a6a44709a6f349e83bdf04d (commit)
via 74e143bf3a9cd1cf6748cf1462f8e0fb161d126e (commit)
via 640ed1da81d909bb3c2f01a481e7e8d3336f336c (commit)
from 03d0a9abbd49e099e4ef522bf60d621b9092ecc5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/751839d208b02af...
commit 751839d208b02af3d0a2329e6d75a90d51a247ff
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
make comment header output work
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 3d07161..c925ef9 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -14,10 +14,11 @@
#include "webidl-ast.h"
#include "jsapi-libdom.h"
-/*
#define HDR_COMMENT_SEP "\n * "
+#define HDR_COMMENT_PREABLE "Generated by nsgenjsapi"
+
+/*
#define HDR_COMMENT_SEP_LEN 4
-#define HDR_COMMENT_PREABLE "Generated by nsgenjsapi"HDR_COMMENT_SEP
int genbind_header_comment(char *comment)
{
@@ -45,6 +46,37 @@ int genbind_header_comment(char *comment)
*/
+static int webidl_hdrcomments_cb(struct genbind_node *node, void *ctx)
+{
+ FILE *outfile = ctx;
+ char *txt;
+ txt = genbind_node_gettext(node);
+ fprintf(outfile, HDR_COMMENT_SEP"%s",txt);
+ return 0;
+}
+
+static int webidl_hdrcomment_cb(struct genbind_node *node, void *ctx)
+{
+ FILE *outfile = ctx;
+ genbind_node_for_each_type(genbind_node_getnode(node),
+ GENBIND_NODE_TYPE_STRING,
+ webidl_hdrcomments_cb,
+ ctx);
+ return 0;
+}
+
+static int
+output_header_comments(FILE *outfile, struct genbind_node *genbind_ast)
+{
+ fprintf(outfile, "/* "HDR_COMMENT_PREABLE);
+ genbind_node_for_each_type(genbind_ast,
+ GENBIND_NODE_TYPE_HDRCOMMENT,
+ webidl_hdrcomment_cb,
+ outfile);
+ fprintf(outfile,"\n */\n\n");
+ return 0;
+}
+
static int webidl_file_cb(struct genbind_node *node, void *ctx)
{
struct webidl_node **webidl_ast = ctx;
@@ -70,9 +102,13 @@ int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
{
FILE *outfile = NULL;
struct webidl_node *webidl_ast = NULL;
+ int res;
- read_webidl(genbind_ast, &webidl_ast);
-
+ res = read_webidl(genbind_ast, &webidl_ast);
+ if (res != 0) {
+ fprintf(stderr, "Error reading Web IDL files\n");
+ return 5;
+ }
/* open output file */
if (outfilename == NULL) {
@@ -88,6 +124,8 @@ int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
return 4;
}
+ output_header_comments(outfile, genbind_ast);
+
/* fprintf(outfile, " %s\n \n\n", genbind_ast->hdr_comments);
fprintf(outfile, "%s", genbind_ast->preamble);
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/141796f3e78e8b1...
commit 141796f3e78e8b134a6a44709a6f349e83bdf04d
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
implement node search which makes webidl loading work
diff --git a/src/genjsbind-ast.c b/src/genjsbind-ast.c
index e722c7c..1645f78 100644
--- a/src/genjsbind-ast.c
+++ b/src/genjsbind-ast.c
@@ -71,6 +71,21 @@ genbind_node_for_each_type(struct genbind_node *node,
genbind_callback_t *cb,
void *ctx)
{
+ int ret;
+
+ if (node == NULL) {
+ return -1;
+ }
+ if (node->l != NULL) {
+ ret = genbind_node_for_each_type(node->l, type, cb, ctx);
+ if (ret != 0) {
+ return ret;
+ }
+ }
+ if (node->type == type) {
+ return cb(node, ctx);
+ }
+
return 0;
}
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/74e143bf3a9cd1c...
commit 74e143bf3a9cd1cf6748cf1462f8e0fb161d126e
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
clean up AST building for both parsers
diff --git a/src/genjsbind-ast.c b/src/genjsbind-ast.c
index a2e17df..e722c7c 100644
--- a/src/genjsbind-ast.c
+++ b/src/genjsbind-ast.c
@@ -16,78 +16,170 @@
#include <string.h>
#include "genjsbind-ast.h"
-#include "webidl-ast.h"
#include "options.h"
/* parser and lexer interface */
extern int genjsbind_debug;
extern int genjsbind__flex_debug;
extern void genjsbind_restart(FILE*);
-extern int genjsbind_parse(void);
+extern int genjsbind_parse(struct genbind_node **genbind_ast);
+/* terminal nodes have a value only */
+struct genbind_node {
+ enum genbind_node_type type;
+ struct genbind_node *l;
+ union {
+ void *value;
+ struct genbind_node *node;
+ char *text;
+ } r;
+};
-#define HDR_COMMENT_SEP "\n * "
-#define HDR_COMMENT_SEP_LEN 4
-#define HDR_COMMENT_PREABLE "Generated by nsgenjsapi"HDR_COMMENT_SEP
-/* current state */
-struct genbind_ast *genbind_ast;
-
-int genbind_header_comment(char *comment)
+char *genbind_strapp(char *a, char *b)
{
char *fullstr;
int fulllen;
- fulllen = strlen(genbind_ast->hdr_comments) +
- strlen(comment) + HDR_COMMENT_SEP_LEN + 1;
+ fulllen = strlen(a) + strlen(b) + 1;
fullstr = malloc(fulllen);
- snprintf(fullstr, fulllen, "%s"HDR_COMMENT_SEP"%s", genbind_ast->hdr_comments , comment);
- free(genbind_ast->hdr_comments);
- free(comment);
- genbind_ast->hdr_comments = fullstr;
-
- return 0;
+ snprintf(fullstr, fulllen, "%s%s", a, b);
+ free(a);
+ free(b);
+ return fullstr;
}
-int genbind_preamble(char *ccode)
+struct genbind_node *genbind_node_link(struct genbind_node *tgt, struct genbind_node *src)
{
- char *fullstr;
- int fulllen;
- fulllen = strlen(genbind_ast->preamble) + strlen(ccode) + 1;
- fullstr = malloc(fulllen);
- snprintf(fullstr, fulllen, "%s%s", genbind_ast->preamble , ccode);
- free(genbind_ast->preamble);
- free(ccode);
- genbind_ast->preamble = fullstr;
+ tgt->l = src;
+ return tgt;
+}
- return 0;
+struct genbind_node *
+genbind_new_node(enum genbind_node_type type, struct genbind_node *l, void *r)
+{
+ struct genbind_node *nn;
+ nn = calloc(1, sizeof(struct genbind_node));
+ nn->type = type;
+ nn->l = l;
+ nn->r.value = r;
+ return nn;
}
-int genbind_interface(char *interface)
+int
+genbind_node_for_each_type(struct genbind_node *node,
+ enum genbind_node_type type,
+ genbind_callback_t *cb,
+ void *ctx)
{
- genbind_ast->ifname = interface;
return 0;
}
-static void init_state(void)
+char *genbind_node_gettext(struct genbind_node *node)
{
- /* allocate state */
- genbind_ast = calloc(1, sizeof(struct genbind_ast));
+ switch(node->type) {
+ case GENBIND_NODE_TYPE_WEBIDLFILE:
+ case GENBIND_NODE_TYPE_STRING:
+ case GENBIND_NODE_TYPE_PREAMBLE:
+ case GENBIND_NODE_TYPE_BINDING_IDENT:
+ case GENBIND_NODE_TYPE_TYPE_IDENT:
+ case GENBIND_NODE_TYPE_TYPE_NODE:
+ case GENBIND_NODE_TYPE_TYPE_INTERFACE:
+ return node->r.text;
+
+ default:
+ return NULL;
+ }
+}
- /* initialise root IDL node */
- webidl_root = webidl_new_node(WEBIDL_NODE_TYPE_ROOT);
+struct genbind_node *genbind_node_getnode(struct genbind_node *node)
+{
+ switch(node->type) {
+ case GENBIND_NODE_TYPE_HDRCOMMENT:
+ case GENBIND_NODE_TYPE_BINDING:
+ case GENBIND_NODE_TYPE_TYPE:
+ case GENBIND_NODE_TYPE_TYPE_EXTRA:
+ return node->r.node;
+
+ default:
+ return NULL;
+ }
+}
- /* set default comment header text */
- genbind_ast->hdr_comments = strdup(HDR_COMMENT_PREABLE);
+int genbind_ast_dump(struct genbind_node *node)
+{
+ char *txt;
+ while (node != NULL) {
+ switch(node->type) {
+ case GENBIND_NODE_TYPE_ROOT:
+ printf("root\n");
+ break;
+
+ case GENBIND_NODE_TYPE_WEBIDLFILE:
+ printf("webidlfile\n");
+ break;
+
+ case GENBIND_NODE_TYPE_HDRCOMMENT:
+ printf("hdrcomment\n");
+ break;
+
+ case GENBIND_NODE_TYPE_STRING:
+ printf("string\n");
+ break;
+
+ case GENBIND_NODE_TYPE_PREAMBLE:
+ printf("preamble\n");
+ break;
+
+ case GENBIND_NODE_TYPE_BINDING:
+ printf("binding\n");
+ break;
+
+ case GENBIND_NODE_TYPE_BINDING_IDENT:
+ printf("binding ident\n");
+ break;
+
+ case GENBIND_NODE_TYPE_TYPE:
+ printf("type\n");
+ break;
+
+ case GENBIND_NODE_TYPE_TYPE_IDENT:
+ printf("type ident\n");
+ break;
+
+ case GENBIND_NODE_TYPE_TYPE_NODE:
+ printf("type node\n");
+ break;
+
+ case GENBIND_NODE_TYPE_TYPE_EXTRA:
+ printf("type extra\n");
+ break;
+
+ case GENBIND_NODE_TYPE_TYPE_INTERFACE:
+ printf("\n");
+ break;
+
+ default:
+ printf("Unknown node type!\n");
+ break;
+ }
- genbind_ast->preamble = strdup("");
+ txt = genbind_node_gettext(node);
+ if (txt == NULL) {
+ genbind_ast_dump(genbind_node_getnode(node));
+ } else {
+ printf(" %s\n", txt);
+ }
+ node = node->l;
+ }
+ return 0;
}
-int genbind_parsefile(char *infilename)
+int genbind_parsefile(char *infilename, struct genbind_node **ast)
{
FILE *infile;
- /* open input file */
- if ((infilename[0] == '-') &&
+ /* open input file */
+ if ((infilename[0] == '-') &&
(infilename[1] == 0)) {
if (options->verbose) {
printf("Using stdin for input\n");
@@ -99,17 +191,14 @@ int genbind_parsefile(char *infilename)
}
infile = fopen(infilename, "r");
}
-
+
if (!infile) {
fprintf(stderr, "Error opening %s: %s\n",
- infilename,
+ infilename,
strerror(errno));
return 3;
}
- /* initialise internal state */
- init_state();
-
if (options->debug) {
genjsbind_debug = 1;
genjsbind__flex_debug = 1;
@@ -119,8 +208,6 @@ int genbind_parsefile(char *infilename)
genjsbind_restart(infile);
/* process binding */
- return genjsbind_parse();
+ return genjsbind_parse(ast);
}
-
-
diff --git a/src/genjsbind-ast.h b/src/genjsbind-ast.h
index 0f7c2d2..20ee028 100644
--- a/src/genjsbind-ast.h
+++ b/src/genjsbind-ast.h
@@ -9,17 +9,38 @@
#ifndef genjsbind_genjsbind_ast_h
#define genjsbind_genjsbind_ast_h
-int genbind_parsefile(char *infilename);
-int genbind_header_comment(char *);
-int genbind_interface(char *);
-int genbind_preamble(char *ccode);
-
-struct genbind_ast {
- char *hdr_comments;
- char *preamble;
- char *ifname;
+enum genbind_node_type {
+ GENBIND_NODE_TYPE_ROOT = 0,
+ GENBIND_NODE_TYPE_WEBIDLFILE,
+ GENBIND_NODE_TYPE_HDRCOMMENT,
+ GENBIND_NODE_TYPE_STRING,
+ GENBIND_NODE_TYPE_PREAMBLE,
+ GENBIND_NODE_TYPE_BINDING,
+ GENBIND_NODE_TYPE_BINDING_IDENT,
+ GENBIND_NODE_TYPE_TYPE,
+ GENBIND_NODE_TYPE_TYPE_IDENT,
+ GENBIND_NODE_TYPE_TYPE_NODE,
+ GENBIND_NODE_TYPE_TYPE_EXTRA,
+ GENBIND_NODE_TYPE_TYPE_INTERFACE,
};
-extern struct genbind_ast *genbind_ast;
+
+struct genbind_node;
+
+int genbind_parsefile(char *infilename, struct genbind_node **ast);
+
+char *genbind_strapp(char *a, char *b);
+
+struct genbind_node *genbind_new_node(enum genbind_node_type type, struct genbind_node *l, void *r);
+struct genbind_node *genbind_node_link(struct genbind_node *tgt, struct genbind_node *src);
+
+typedef int (genbind_callback_t)(struct genbind_node *node, void *ctx);
+
+int genbind_node_for_each_type(struct genbind_node *node, enum genbind_node_type type, genbind_callback_t *cb, void *ctx);
+
+char *genbind_node_gettext(struct genbind_node *node);
+struct genbind_node *genbind_node_getnode(struct genbind_node *node);
+
+int genbind_ast_dump(struct genbind_node *ast);
#endif
diff --git a/src/genjsbind-lexer.l b/src/genjsbind-lexer.l
index 5044c04..89796ad 100644
--- a/src/genjsbind-lexer.l
+++ b/src/genjsbind-lexer.l
@@ -30,6 +30,7 @@
%option prefix="genjsbind_"
%option nounput
%option noinput
+%option noyywrap
/* other Unicode “space separator” */
USP (\xe1\x9a\x80)|(\xe1\xa0\x8e)|(\xe2\x80[\x80-\x8a])|(\xe2\x80\xaf)|(\xe2\x81\x9f)|(\xe3\x80\x80)
diff --git a/src/genjsbind-parser.y b/src/genjsbind-parser.y
index 0e68a47..17d1850 100644
--- a/src/genjsbind-parser.y
+++ b/src/genjsbind-parser.y
@@ -17,26 +17,23 @@
char *errtxt;
-static void genjsbind_error(const char *str)
+ static void genjsbind_error(YYLTYPE *locp, struct genbind_node **genbind_ast, const char *str)
{
errtxt = strdup(str);
}
-int genjsbind_wrap()
-{
- return 1;
-}
-
%}
%locations
%define api.pure
%error-verbose
+%parse-param { struct genbind_node **genbind_ast }
%union
{
char* text;
+ struct genbind_node *node;
}
%token TOK_IDLFILE
@@ -50,19 +47,42 @@ int genjsbind_wrap()
%token TOK_NODE
%token <text> TOK_IDENTIFIER
-
%token <text> TOK_STRING_LITERAL
%token <text> TOK_CCODE_LITERAL
+%type <text> CBlock
+
+%type <node> Statement
+%type <node> Statements
+%type <node> IdlFile
+%type <node> Preamble
+%type <node> HdrComment
+%type <node> Strings
+%type <node> Binding
+%type <node> BindingArgs
+%type <node> BindingArg
+%type <node> Type
+%type <node> TypeArgs
+%type <node> Extra
+%type <node> Interface
+%type <node> Node
%%
- /* [1] start with Statements */
+Input
+ :
+ Statements { *genbind_ast = $1 }
+ ;
+
+
Statements
:
Statement
|
Statements Statement
+ {
+ $$ = genbind_node_link($2, $1);
+ }
|
error ';'
{
@@ -85,55 +105,60 @@ Statement
/* [3] load a web IDL file */
IdlFile
- : TOK_IDLFILE TOK_STRING_LITERAL ';'
+ :
+ TOK_IDLFILE TOK_STRING_LITERAL ';'
{
- if (webidl_parsefile($2) != 0) {
- YYABORT;
- }
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_WEBIDLFILE, NULL, $2);
}
;
HdrComment
- : TOK_HDR_COMMENT HdrStrings ';'
+ :
+ TOK_HDR_COMMENT Strings ';'
{
-
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_HDRCOMMENT, NULL, $2);
}
;
-HdrStrings
+Strings
:
TOK_STRING_LITERAL
{
- genbind_header_comment($1);
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_STRING, NULL, $1);
}
|
- HdrStrings TOK_STRING_LITERAL
+ Strings TOK_STRING_LITERAL
{
- genbind_header_comment($2);
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_STRING, $1, $2);
}
;
Preamble
:
TOK_PREAMBLE CBlock ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_PREAMBLE, NULL, $2);
+ }
;
CBlock
:
TOK_CCODE_LITERAL
- {
- genbind_preamble($1);
- }
|
CBlock TOK_CCODE_LITERAL
{
- genbind_preamble($2);
+ $$ = genbind_strapp($1, $2);
}
;
Binding
:
TOK_BINDING TOK_IDENTIFIER '{' BindingArgs '}' ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING,
+ NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_BINDING_IDENT, $4, $2));
+ }
;
BindingArgs
@@ -141,6 +166,9 @@ BindingArgs
BindingArg
|
BindingArgs BindingArg
+ {
+ $$ = genbind_node_link($2, $1);
+ }
;
BindingArg
@@ -155,23 +183,44 @@ BindingArg
Type
:
TOK_TYPE TOK_IDENTIFIER '{' TypeArgs '}' ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_TYPE,
+ NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_TYPE_IDENT, $4, $2));
+ }
;
TypeArgs
:
+ /* empty */
+ {
+ $$ = NULL;
+ }
+ |
+ Node
+ ;
+
+Node
+ :
TOK_NODE TOK_IDENTIFIER ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_TYPE_NODE, NULL, $2);
+ }
;
Extra
:
- TOK_EXTRA TOK_STRING_LITERAL ';'
+ TOK_EXTRA Strings ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_TYPE_EXTRA, NULL, $2);
+ }
;
Interface
:
TOK_INTERFACE TOK_IDENTIFIER ';'
{
- genbind_interface($2);
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_TYPE_INTERFACE, NULL, $2);
}
;
diff --git a/src/genjsbind.c b/src/genjsbind.c
index 21bf8b1..559602b 100644
--- a/src/genjsbind.c
+++ b/src/genjsbind.c
@@ -73,6 +73,7 @@ static struct options* process_cmdline(int argc, char **argv)
int main(int argc, char **argv)
{
int res;
+ struct genbind_node *genbind_root;
options = process_cmdline(argc, argv);
if (options == NULL) {
@@ -86,13 +87,17 @@ int main(int argc, char **argv)
return 2;
}
- res = genbind_parsefile(options->infilename);
+ res = genbind_parsefile(options->infilename, &genbind_root);
if (res != 0) {
fprintf(stderr, "Error: parse failed with code %d\n", res);
return res;
}
- res = jsapi_libdom_output(options->outfilename);
+ if (options->verbose) {
+ genbind_ast_dump(genbind_root);
+ }
+
+ res = jsapi_libdom_output(options->outfilename, genbind_root);
if (res != 0) {
fprintf(stderr, "Error: output failed with code %d\n", res);
unlink(options->outfilename);
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
index 02033e1..3d07161 100644
--- a/src/jsapi-libdom.c
+++ b/src/jsapi-libdom.c
@@ -11,11 +11,69 @@
#include <string.h>
#include "genjsbind-ast.h"
+#include "webidl-ast.h"
#include "jsapi-libdom.h"
-int jsapi_libdom_output(char *outfilename)
+/*
+#define HDR_COMMENT_SEP "\n * "
+#define HDR_COMMENT_SEP_LEN 4
+#define HDR_COMMENT_PREABLE "Generated by nsgenjsapi"HDR_COMMENT_SEP
+
+int genbind_header_comment(char *comment)
+{
+ char *fullstr;
+ int fulllen;
+ fulllen = strlen(genbind_ast->hdr_comments) +
+ strlen(comment) + HDR_COMMENT_SEP_LEN + 1;
+ fullstr = malloc(fulllen);
+ snprintf(fullstr, fulllen, "%s"HDR_COMMENT_SEP"%s", genbind_ast->hdr_comments , comment);
+ free(genbind_ast->hdr_comments);
+ free(comment);
+ genbind_ast->hdr_comments = fullstr;
+
+ return 0;
+}
+
+{
+ if (webidl_parsefile($2) != 0) {
+ YYABORT;
+}
+}
+*/
+ /* initialise root IDL node */
+/* webidl_root =
+
+*/
+
+static int webidl_file_cb(struct genbind_node *node, void *ctx)
+{
+ struct webidl_node **webidl_ast = ctx;
+ char *filename;
+
+ filename = genbind_node_gettext(node);
+
+ return webidl_parsefile(filename, webidl_ast);
+
+}
+
+static int
+read_webidl(struct genbind_node *genbind_ast, struct webidl_node **webidl_ast)
+{
+ return genbind_node_for_each_type(genbind_ast,
+ GENBIND_NODE_TYPE_WEBIDLFILE,
+ webidl_file_cb,
+ webidl_ast);
+
+}
+
+int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
{
FILE *outfile = NULL;
+ struct webidl_node *webidl_ast = NULL;
+
+ read_webidl(genbind_ast, &webidl_ast);
+
+
/* open output file */
if (outfilename == NULL) {
outfile = stdout;
@@ -30,12 +88,12 @@ int jsapi_libdom_output(char *outfilename)
return 4;
}
- fprintf(outfile, "/* %s\n */\n\n", genbind_ast->hdr_comments);
+ /* fprintf(outfile, " %s\n \n\n", genbind_ast->hdr_comments);
fprintf(outfile, "%s", genbind_ast->preamble);
- fprintf(outfile, "/* interface %s */\n\n", genbind_ast->ifname);
-
+ fprintf(outfile, " interface %s \n\n", genbind_ast->ifname);
+*/
fclose(outfile);
return 0;
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
index 6ee8db7..fe28723 100644
--- a/src/jsapi-libdom.h
+++ b/src/jsapi-libdom.h
@@ -1 +1,14 @@
-int jsapi_libdom_output(char *outfile);
+/* binding generator output
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
+#ifndef genjsbind_jsapi_libdom_h
+#define genjsbind_jsapi_libdom_h
+
+int jsapi_libdom_output(char *outfile, struct genbind_node *genbind_root);
+
+#endif
diff --git a/src/webidl-ast.c b/src/webidl-ast.c
index 1eddd68..e19fb80 100644
--- a/src/webidl-ast.c
+++ b/src/webidl-ast.c
@@ -18,19 +18,8 @@
extern int webidl_debug;
extern int webidl__flex_debug;
extern void webidl_restart(FILE*);
-extern int webidl_parse(void);
+extern int webidl_parse(struct webidl_node **webidl_ast);
-struct webidl_node *webidl_root;
-
-struct webidl_node *webidl_new_node(enum webidl_node_type type)
-{
- struct webidl_node *nnode;
- nnode = calloc(1, sizeof(struct webidl_node));
- if (nnode != NULL) {
- nnode->type = type;
- }
- return nnode;
-}
static FILE *idlopen(const char *filename)
{
@@ -55,10 +44,32 @@ static FILE *idlopen(const char *filename)
return idlfile;
}
-int webidl_parsefile(char *filename)
+struct webidl_node *
+webidl_node_link(struct webidl_node *tgt, struct webidl_node *src)
{
- /* set flex to read from file */
+ if (tgt != NULL) {
+ tgt->l = src;
+ return tgt;
+ }
+ return src;
+}
+
+struct webidl_node *webidl_node_new(int type, struct webidl_node *l, void *r)
+{
+ struct webidl_node *nn;
+ nn = calloc(1, sizeof(struct webidl_node));
+ nn->type = type;
+ nn->l = l;
+ nn->r.text = r;
+ return nn;
+}
+
+
+int webidl_parsefile(char *filename, struct webidl_node **webidl_ast)
+{
+
FILE *idlfile;
+
idlfile = idlopen(filename);
if (!idlfile) {
fprintf(stderr, "Error opening %s: %s\n",
@@ -72,8 +83,9 @@ int webidl_parsefile(char *filename)
webidl__flex_debug = 1;
}
+ /* set flex to read from file */
webidl_restart(idlfile);
/* parse the file */
- return webidl_parse();
+ return webidl_parse(webidl_ast);
}
diff --git a/src/webidl-ast.h b/src/webidl-ast.h
index 5dfd2a8..3c93305 100644
--- a/src/webidl-ast.h
+++ b/src/webidl-ast.h
@@ -9,35 +9,23 @@
#ifndef genjsbind_webidl_ast_h
#define genjsbind_webidl_ast_h
-enum webidl_node_type {
- WEBIDL_NODE_TYPE_ROOT,
- WEBIDL_NODE_TYPE_INTERFACE,
-};
-
-struct webidl_ifmember {
- char *name;
-};
-
-struct webidl_if {
- char *name;
- struct webidl_ifmember* members;
-};
-
+#define WEBIDL_NODE_TYPE_ROOT 0
struct webidl_node {
- enum webidl_node_type type;
+ int type;
+ struct webidl_node *l;
union {
- struct webidl_node *nodes;
- struct webidl_if interface;
- } data;
+ struct webidl_node *node;
+ char *text;
+ } r;
};
-extern struct webidl_node *webidl_root;
-
/** parse web idl file */
-int webidl_parsefile(char *filename);
+int webidl_parsefile(char *filename, struct webidl_node **webidl_ast);
+
+struct webidl_node *webidl_node_new(int type, struct webidl_node *l, void *r);
-struct webidl_node *webidl_new_node(enum webidl_node_type type);
+struct webidl_node *webidl_node_link(struct webidl_node *tgt, struct webidl_node *src);
#endif
diff --git a/src/webidl-lexer.l b/src/webidl-lexer.l
index 5c8234c..bfa4fb5 100644
--- a/src/webidl-lexer.l
+++ b/src/webidl-lexer.l
@@ -38,6 +38,7 @@
%option warn
%option prefix="webidl_"
%option nounput
+%option noyywrap
/* regular definitions */
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 '}' ';'
;
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/640ed1da81d909b...
commit 640ed1da81d909bb3c2f01a481e7e8d3336f336c
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
split out output geenration
diff --git a/src/Makefile b/src/Makefile
index 1116400..530dd4b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,7 +1,7 @@
CFLAGS := $(CFLAGS) -I$(BUILDDIR) -Isrc/ -g
# Sources in this directory
-DIR_SOURCES := genjsbind.c webidl-ast.c genjsbind-ast.c
+DIR_SOURCES := genjsbind.c webidl-ast.c genjsbind-ast.c jsapi-libdom.c
SOURCES := $(SOURCES) $(BUILDDIR)/genjsbind-parser.c $(BUILDDIR)/genjsbind-lexer.c $(BUILDDIR)/webidl-parser.c $(BUILDDIR)/webidl-lexer.c
diff --git a/src/genjsbind-ast.c b/src/genjsbind-ast.c
index ccadc7f..a2e17df 100644
--- a/src/genjsbind-ast.c
+++ b/src/genjsbind-ast.c
@@ -31,56 +31,58 @@ extern int genjsbind_parse(void);
#define HDR_COMMENT_PREABLE "Generated by nsgenjsapi"HDR_COMMENT_SEP
/* current state */
-static char *hdr_comments = NULL;
-static char *preamble = NULL;
-static char *ifname;
+struct genbind_ast *genbind_ast;
-int genjsbind_header_comment(char *comment)
+int genbind_header_comment(char *comment)
{
char *fullstr;
int fulllen;
- fulllen = strlen(hdr_comments) + strlen(comment) + HDR_COMMENT_SEP_LEN + 1;
+ fulllen = strlen(genbind_ast->hdr_comments) +
+ strlen(comment) + HDR_COMMENT_SEP_LEN + 1;
fullstr = malloc(fulllen);
- snprintf(fullstr, fulllen, "%s"HDR_COMMENT_SEP"%s", hdr_comments , comment);
- free(hdr_comments);
+ snprintf(fullstr, fulllen, "%s"HDR_COMMENT_SEP"%s", genbind_ast->hdr_comments , comment);
+ free(genbind_ast->hdr_comments);
free(comment);
- hdr_comments = fullstr;
+ genbind_ast->hdr_comments = fullstr;
return 0;
}
-int genjsbind_preamble(char *ccode)
+int genbind_preamble(char *ccode)
{
char *fullstr;
int fulllen;
- fulllen = strlen(preamble) + strlen(ccode) + 1;
+ fulllen = strlen(genbind_ast->preamble) + strlen(ccode) + 1;
fullstr = malloc(fulllen);
- snprintf(fullstr, fulllen, "%s%s", preamble , ccode);
- free(preamble);
+ snprintf(fullstr, fulllen, "%s%s", genbind_ast->preamble , ccode);
+ free(genbind_ast->preamble);
free(ccode);
- preamble = fullstr;
+ genbind_ast->preamble = fullstr;
return 0;
}
-int genjsbind_interface(char *interface)
+int genbind_interface(char *interface)
{
- ifname = interface;
+ genbind_ast->ifname = interface;
return 0;
}
static void init_state(void)
{
- /* initialise root node */
+ /* allocate state */
+ genbind_ast = calloc(1, sizeof(struct genbind_ast));
+
+ /* initialise root IDL node */
webidl_root = webidl_new_node(WEBIDL_NODE_TYPE_ROOT);
/* set default comment header text */
- hdr_comments = strdup(HDR_COMMENT_PREABLE);
+ genbind_ast->hdr_comments = strdup(HDR_COMMENT_PREABLE);
- preamble = strdup("");
+ genbind_ast->preamble = strdup("");
}
-int genjsbind_parsefile(char *infilename)
+int genbind_parsefile(char *infilename)
{
FILE *infile;
@@ -121,31 +123,4 @@ int genjsbind_parsefile(char *infilename)
}
-int genjsbind_output(char *outfilename)
-{
- FILE *outfile = NULL;
- /* open output file */
- if (outfilename == NULL) {
- outfile = stdout;
- } else {
- outfile = fopen(outfilename, "w");
- }
-
- if (!outfile) {
- fprintf(stderr, "Error opening output %s: %s\n",
- outfilename,
- strerror(errno));
- return 4;
- }
-
- fprintf(outfile, "/* %s\n */\n\n", hdr_comments);
-
- fprintf(outfile, "%s", preamble);
-
- fprintf(outfile, "/* interface %s */\n\n", ifname);
-
- fclose(outfile);
-
- return 0;
-}
diff --git a/src/genjsbind-ast.h b/src/genjsbind-ast.h
index d94eda6..0f7c2d2 100644
--- a/src/genjsbind-ast.h
+++ b/src/genjsbind-ast.h
@@ -9,10 +9,17 @@
#ifndef genjsbind_genjsbind_ast_h
#define genjsbind_genjsbind_ast_h
-int genjsbind_parsefile(char *infilename);
-int genjsbind_output(char *outfilename);
-int genjsbind_header_comment(char *);
-int genjsbind_interface(char *);
-int genjsbind_preamble(char *ccode);
+int genbind_parsefile(char *infilename);
+int genbind_header_comment(char *);
+int genbind_interface(char *);
+int genbind_preamble(char *ccode);
+
+struct genbind_ast {
+ char *hdr_comments;
+ char *preamble;
+ char *ifname;
+};
+
+extern struct genbind_ast *genbind_ast;
#endif
diff --git a/src/genjsbind-parser.y b/src/genjsbind-parser.y
index 9ed4f21..0e68a47 100644
--- a/src/genjsbind-parser.y
+++ b/src/genjsbind-parser.y
@@ -104,12 +104,12 @@ HdrStrings
:
TOK_STRING_LITERAL
{
- genjsbind_header_comment($1);
+ genbind_header_comment($1);
}
|
HdrStrings TOK_STRING_LITERAL
{
- genjsbind_header_comment($2);
+ genbind_header_comment($2);
}
;
@@ -122,12 +122,12 @@ CBlock
:
TOK_CCODE_LITERAL
{
- genjsbind_preamble($1);
+ genbind_preamble($1);
}
|
CBlock TOK_CCODE_LITERAL
{
- genjsbind_preamble($2);
+ genbind_preamble($2);
}
;
@@ -171,7 +171,7 @@ Interface
:
TOK_INTERFACE TOK_IDENTIFIER ';'
{
- genjsbind_interface($2);
+ genbind_interface($2);
}
;
diff --git a/src/genjsbind.c b/src/genjsbind.c
index dd5b242..21bf8b1 100644
--- a/src/genjsbind.c
+++ b/src/genjsbind.c
@@ -15,6 +15,7 @@
#include <errno.h>
#include "genjsbind-ast.h"
+#include "jsapi-libdom.h"
#include "options.h"
struct options *options;
@@ -85,13 +86,13 @@ int main(int argc, char **argv)
return 2;
}
- res = genjsbind_parsefile(options->infilename);
+ res = genbind_parsefile(options->infilename);
if (res != 0) {
fprintf(stderr, "Error: parse failed with code %d\n", res);
return res;
}
- res = genjsbind_output(options->outfilename);
+ res = jsapi_libdom_output(options->outfilename);
if (res != 0) {
fprintf(stderr, "Error: output failed with code %d\n", res);
unlink(options->outfilename);
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
new file mode 100644
index 0000000..02033e1
--- /dev/null
+++ b/src/jsapi-libdom.c
@@ -0,0 +1,42 @@
+/* binding output generator for jsapi(spidermonkey) to libdom
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include "genjsbind-ast.h"
+#include "jsapi-libdom.h"
+
+int jsapi_libdom_output(char *outfilename)
+{
+ FILE *outfile = NULL;
+ /* open output file */
+ if (outfilename == NULL) {
+ outfile = stdout;
+ } else {
+ outfile = fopen(outfilename, "w");
+ }
+
+ if (!outfile) {
+ fprintf(stderr, "Error opening output %s: %s\n",
+ outfilename,
+ strerror(errno));
+ return 4;
+ }
+
+ fprintf(outfile, "/* %s\n */\n\n", genbind_ast->hdr_comments);
+
+ fprintf(outfile, "%s", genbind_ast->preamble);
+
+ fprintf(outfile, "/* interface %s */\n\n", genbind_ast->ifname);
+
+ fclose(outfile);
+
+ return 0;
+}
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
new file mode 100644
index 0000000..6ee8db7
--- /dev/null
+++ b/src/jsapi-libdom.h
@@ -0,0 +1 @@
+int jsapi_libdom_output(char *outfile);
-----------------------------------------------------------------------
Summary of changes:
src/Makefile | 2 +-
src/genjsbind-ast.c | 223 ++++++++++++++++++++++++++++++++----------------
src/genjsbind-ast.h | 38 +++++++-
src/genjsbind-lexer.l | 1 +
src/genjsbind-parser.y | 97 ++++++++++++++++-----
src/genjsbind.c | 10 ++-
src/jsapi-libdom.c | 138 ++++++++++++++++++++++++++++++
src/jsapi-libdom.h | 14 +++
src/webidl-ast.c | 42 ++++++---
src/webidl-ast.h | 32 ++-----
src/webidl-lexer.l | 1 +
src/webidl-parser.y | 50 ++++++-----
12 files changed, 483 insertions(+), 165 deletions(-)
create mode 100644 src/jsapi-libdom.c
create mode 100644 src/jsapi-libdom.h
diff --git a/src/Makefile b/src/Makefile
index 1116400..530dd4b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,7 +1,7 @@
CFLAGS := $(CFLAGS) -I$(BUILDDIR) -Isrc/ -g
# Sources in this directory
-DIR_SOURCES := genjsbind.c webidl-ast.c genjsbind-ast.c
+DIR_SOURCES := genjsbind.c webidl-ast.c genjsbind-ast.c jsapi-libdom.c
SOURCES := $(SOURCES) $(BUILDDIR)/genjsbind-parser.c $(BUILDDIR)/genjsbind-lexer.c $(BUILDDIR)/webidl-parser.c $(BUILDDIR)/webidl-lexer.c
diff --git a/src/genjsbind-ast.c b/src/genjsbind-ast.c
index ccadc7f..1645f78 100644
--- a/src/genjsbind-ast.c
+++ b/src/genjsbind-ast.c
@@ -16,76 +16,185 @@
#include <string.h>
#include "genjsbind-ast.h"
-#include "webidl-ast.h"
#include "options.h"
/* parser and lexer interface */
extern int genjsbind_debug;
extern int genjsbind__flex_debug;
extern void genjsbind_restart(FILE*);
-extern int genjsbind_parse(void);
+extern int genjsbind_parse(struct genbind_node **genbind_ast);
+/* terminal nodes have a value only */
+struct genbind_node {
+ enum genbind_node_type type;
+ struct genbind_node *l;
+ union {
+ void *value;
+ struct genbind_node *node;
+ char *text;
+ } r;
+};
-#define HDR_COMMENT_SEP "\n * "
-#define HDR_COMMENT_SEP_LEN 4
-#define HDR_COMMENT_PREABLE "Generated by nsgenjsapi"HDR_COMMENT_SEP
-/* current state */
-static char *hdr_comments = NULL;
-static char *preamble = NULL;
-static char *ifname;
-
-int genjsbind_header_comment(char *comment)
+char *genbind_strapp(char *a, char *b)
{
char *fullstr;
int fulllen;
- fulllen = strlen(hdr_comments) + strlen(comment) + HDR_COMMENT_SEP_LEN + 1;
+ fulllen = strlen(a) + strlen(b) + 1;
fullstr = malloc(fulllen);
- snprintf(fullstr, fulllen, "%s"HDR_COMMENT_SEP"%s", hdr_comments , comment);
- free(hdr_comments);
- free(comment);
- hdr_comments = fullstr;
+ snprintf(fullstr, fulllen, "%s%s", a, b);
+ free(a);
+ free(b);
+ return fullstr;
+}
- return 0;
+struct genbind_node *genbind_node_link(struct genbind_node *tgt, struct genbind_node *src)
+{
+ tgt->l = src;
+ return tgt;
}
-int genjsbind_preamble(char *ccode)
+struct genbind_node *
+genbind_new_node(enum genbind_node_type type, struct genbind_node *l, void *r)
{
- char *fullstr;
- int fulllen;
- fulllen = strlen(preamble) + strlen(ccode) + 1;
- fullstr = malloc(fulllen);
- snprintf(fullstr, fulllen, "%s%s", preamble , ccode);
- free(preamble);
- free(ccode);
- preamble = fullstr;
+ struct genbind_node *nn;
+ nn = calloc(1, sizeof(struct genbind_node));
+ nn->type = type;
+ nn->l = l;
+ nn->r.value = r;
+ return nn;
+}
+
+int
+genbind_node_for_each_type(struct genbind_node *node,
+ enum genbind_node_type type,
+ genbind_callback_t *cb,
+ void *ctx)
+{
+ int ret;
+
+ if (node == NULL) {
+ return -1;
+ }
+ if (node->l != NULL) {
+ ret = genbind_node_for_each_type(node->l, type, cb, ctx);
+ if (ret != 0) {
+ return ret;
+ }
+ }
+ if (node->type == type) {
+ return cb(node, ctx);
+ }
return 0;
}
-int genjsbind_interface(char *interface)
+char *genbind_node_gettext(struct genbind_node *node)
{
- ifname = interface;
- return 0;
+ switch(node->type) {
+ case GENBIND_NODE_TYPE_WEBIDLFILE:
+ case GENBIND_NODE_TYPE_STRING:
+ case GENBIND_NODE_TYPE_PREAMBLE:
+ case GENBIND_NODE_TYPE_BINDING_IDENT:
+ case GENBIND_NODE_TYPE_TYPE_IDENT:
+ case GENBIND_NODE_TYPE_TYPE_NODE:
+ case GENBIND_NODE_TYPE_TYPE_INTERFACE:
+ return node->r.text;
+
+ default:
+ return NULL;
+ }
}
-static void init_state(void)
+struct genbind_node *genbind_node_getnode(struct genbind_node *node)
{
- /* initialise root node */
- webidl_root = webidl_new_node(WEBIDL_NODE_TYPE_ROOT);
+ switch(node->type) {
+ case GENBIND_NODE_TYPE_HDRCOMMENT:
+ case GENBIND_NODE_TYPE_BINDING:
+ case GENBIND_NODE_TYPE_TYPE:
+ case GENBIND_NODE_TYPE_TYPE_EXTRA:
+ return node->r.node;
+
+ default:
+ return NULL;
+ }
+}
- /* set default comment header text */
- hdr_comments = strdup(HDR_COMMENT_PREABLE);
+int genbind_ast_dump(struct genbind_node *node)
+{
+ char *txt;
+ while (node != NULL) {
+ switch(node->type) {
+ case GENBIND_NODE_TYPE_ROOT:
+ printf("root\n");
+ break;
+
+ case GENBIND_NODE_TYPE_WEBIDLFILE:
+ printf("webidlfile\n");
+ break;
+
+ case GENBIND_NODE_TYPE_HDRCOMMENT:
+ printf("hdrcomment\n");
+ break;
+
+ case GENBIND_NODE_TYPE_STRING:
+ printf("string\n");
+ break;
+
+ case GENBIND_NODE_TYPE_PREAMBLE:
+ printf("preamble\n");
+ break;
+
+ case GENBIND_NODE_TYPE_BINDING:
+ printf("binding\n");
+ break;
+
+ case GENBIND_NODE_TYPE_BINDING_IDENT:
+ printf("binding ident\n");
+ break;
+
+ case GENBIND_NODE_TYPE_TYPE:
+ printf("type\n");
+ break;
+
+ case GENBIND_NODE_TYPE_TYPE_IDENT:
+ printf("type ident\n");
+ break;
+
+ case GENBIND_NODE_TYPE_TYPE_NODE:
+ printf("type node\n");
+ break;
+
+ case GENBIND_NODE_TYPE_TYPE_EXTRA:
+ printf("type extra\n");
+ break;
+
+ case GENBIND_NODE_TYPE_TYPE_INTERFACE:
+ printf("\n");
+ break;
+
+ default:
+ printf("Unknown node type!\n");
+ break;
+ }
- preamble = strdup("");
+ txt = genbind_node_gettext(node);
+ if (txt == NULL) {
+ genbind_ast_dump(genbind_node_getnode(node));
+ } else {
+ printf(" %s\n", txt);
+ }
+ node = node->l;
+ }
+ return 0;
}
-int genjsbind_parsefile(char *infilename)
+int genbind_parsefile(char *infilename, struct genbind_node **ast)
{
FILE *infile;
- /* open input file */
- if ((infilename[0] == '-') &&
+ /* open input file */
+ if ((infilename[0] == '-') &&
(infilename[1] == 0)) {
if (options->verbose) {
printf("Using stdin for input\n");
@@ -97,17 +206,14 @@ int genjsbind_parsefile(char *infilename)
}
infile = fopen(infilename, "r");
}
-
+
if (!infile) {
fprintf(stderr, "Error opening %s: %s\n",
- infilename,
+ infilename,
strerror(errno));
return 3;
}
- /* initialise internal state */
- init_state();
-
if (options->debug) {
genjsbind_debug = 1;
genjsbind__flex_debug = 1;
@@ -117,35 +223,6 @@ int genjsbind_parsefile(char *infilename)
genjsbind_restart(infile);
/* process binding */
- return genjsbind_parse();
-
-}
-
-int genjsbind_output(char *outfilename)
-{
- FILE *outfile = NULL;
- /* open output file */
- if (outfilename == NULL) {
- outfile = stdout;
- } else {
- outfile = fopen(outfilename, "w");
- }
-
- if (!outfile) {
- fprintf(stderr, "Error opening output %s: %s\n",
- outfilename,
- strerror(errno));
- return 4;
- }
-
- fprintf(outfile, "/* %s\n */\n\n", hdr_comments);
+ return genjsbind_parse(ast);
- fprintf(outfile, "%s", preamble);
-
- fprintf(outfile, "/* interface %s */\n\n", ifname);
-
- fclose(outfile);
-
- return 0;
}
-
diff --git a/src/genjsbind-ast.h b/src/genjsbind-ast.h
index d94eda6..20ee028 100644
--- a/src/genjsbind-ast.h
+++ b/src/genjsbind-ast.h
@@ -9,10 +9,38 @@
#ifndef genjsbind_genjsbind_ast_h
#define genjsbind_genjsbind_ast_h
-int genjsbind_parsefile(char *infilename);
-int genjsbind_output(char *outfilename);
-int genjsbind_header_comment(char *);
-int genjsbind_interface(char *);
-int genjsbind_preamble(char *ccode);
+enum genbind_node_type {
+ GENBIND_NODE_TYPE_ROOT = 0,
+ GENBIND_NODE_TYPE_WEBIDLFILE,
+ GENBIND_NODE_TYPE_HDRCOMMENT,
+ GENBIND_NODE_TYPE_STRING,
+ GENBIND_NODE_TYPE_PREAMBLE,
+ GENBIND_NODE_TYPE_BINDING,
+ GENBIND_NODE_TYPE_BINDING_IDENT,
+ GENBIND_NODE_TYPE_TYPE,
+ GENBIND_NODE_TYPE_TYPE_IDENT,
+ GENBIND_NODE_TYPE_TYPE_NODE,
+ GENBIND_NODE_TYPE_TYPE_EXTRA,
+ GENBIND_NODE_TYPE_TYPE_INTERFACE,
+};
+
+
+struct genbind_node;
+
+int genbind_parsefile(char *infilename, struct genbind_node **ast);
+
+char *genbind_strapp(char *a, char *b);
+
+struct genbind_node *genbind_new_node(enum genbind_node_type type, struct genbind_node *l, void *r);
+struct genbind_node *genbind_node_link(struct genbind_node *tgt, struct genbind_node *src);
+
+typedef int (genbind_callback_t)(struct genbind_node *node, void *ctx);
+
+int genbind_node_for_each_type(struct genbind_node *node, enum genbind_node_type type, genbind_callback_t *cb, void *ctx);
+
+char *genbind_node_gettext(struct genbind_node *node);
+struct genbind_node *genbind_node_getnode(struct genbind_node *node);
+
+int genbind_ast_dump(struct genbind_node *ast);
#endif
diff --git a/src/genjsbind-lexer.l b/src/genjsbind-lexer.l
index 5044c04..89796ad 100644
--- a/src/genjsbind-lexer.l
+++ b/src/genjsbind-lexer.l
@@ -30,6 +30,7 @@
%option prefix="genjsbind_"
%option nounput
%option noinput
+%option noyywrap
/* other Unicode “space separator” */
USP (\xe1\x9a\x80)|(\xe1\xa0\x8e)|(\xe2\x80[\x80-\x8a])|(\xe2\x80\xaf)|(\xe2\x81\x9f)|(\xe3\x80\x80)
diff --git a/src/genjsbind-parser.y b/src/genjsbind-parser.y
index 9ed4f21..17d1850 100644
--- a/src/genjsbind-parser.y
+++ b/src/genjsbind-parser.y
@@ -17,26 +17,23 @@
char *errtxt;
-static void genjsbind_error(const char *str)
+ static void genjsbind_error(YYLTYPE *locp, struct genbind_node **genbind_ast, const char *str)
{
errtxt = strdup(str);
}
-int genjsbind_wrap()
-{
- return 1;
-}
-
%}
%locations
%define api.pure
%error-verbose
+%parse-param { struct genbind_node **genbind_ast }
%union
{
char* text;
+ struct genbind_node *node;
}
%token TOK_IDLFILE
@@ -50,19 +47,42 @@ int genjsbind_wrap()
%token TOK_NODE
%token <text> TOK_IDENTIFIER
-
%token <text> TOK_STRING_LITERAL
%token <text> TOK_CCODE_LITERAL
+%type <text> CBlock
+
+%type <node> Statement
+%type <node> Statements
+%type <node> IdlFile
+%type <node> Preamble
+%type <node> HdrComment
+%type <node> Strings
+%type <node> Binding
+%type <node> BindingArgs
+%type <node> BindingArg
+%type <node> Type
+%type <node> TypeArgs
+%type <node> Extra
+%type <node> Interface
+%type <node> Node
%%
- /* [1] start with Statements */
+Input
+ :
+ Statements { *genbind_ast = $1 }
+ ;
+
+
Statements
:
Statement
|
Statements Statement
+ {
+ $$ = genbind_node_link($2, $1);
+ }
|
error ';'
{
@@ -85,55 +105,60 @@ Statement
/* [3] load a web IDL file */
IdlFile
- : TOK_IDLFILE TOK_STRING_LITERAL ';'
+ :
+ TOK_IDLFILE TOK_STRING_LITERAL ';'
{
- if (webidl_parsefile($2) != 0) {
- YYABORT;
- }
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_WEBIDLFILE, NULL, $2);
}
;
HdrComment
- : TOK_HDR_COMMENT HdrStrings ';'
+ :
+ TOK_HDR_COMMENT Strings ';'
{
-
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_HDRCOMMENT, NULL, $2);
}
;
-HdrStrings
+Strings
:
TOK_STRING_LITERAL
{
- genjsbind_header_comment($1);
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_STRING, NULL, $1);
}
|
- HdrStrings TOK_STRING_LITERAL
+ Strings TOK_STRING_LITERAL
{
- genjsbind_header_comment($2);
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_STRING, $1, $2);
}
;
Preamble
:
TOK_PREAMBLE CBlock ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_PREAMBLE, NULL, $2);
+ }
;
CBlock
:
TOK_CCODE_LITERAL
- {
- genjsbind_preamble($1);
- }
|
CBlock TOK_CCODE_LITERAL
{
- genjsbind_preamble($2);
+ $$ = genbind_strapp($1, $2);
}
;
Binding
:
TOK_BINDING TOK_IDENTIFIER '{' BindingArgs '}' ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_BINDING,
+ NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_BINDING_IDENT, $4, $2));
+ }
;
BindingArgs
@@ -141,6 +166,9 @@ BindingArgs
BindingArg
|
BindingArgs BindingArg
+ {
+ $$ = genbind_node_link($2, $1);
+ }
;
BindingArg
@@ -155,23 +183,44 @@ BindingArg
Type
:
TOK_TYPE TOK_IDENTIFIER '{' TypeArgs '}' ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_TYPE,
+ NULL,
+ genbind_new_node(GENBIND_NODE_TYPE_TYPE_IDENT, $4, $2));
+ }
;
TypeArgs
:
+ /* empty */
+ {
+ $$ = NULL;
+ }
+ |
+ Node
+ ;
+
+Node
+ :
TOK_NODE TOK_IDENTIFIER ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_TYPE_NODE, NULL, $2);
+ }
;
Extra
:
- TOK_EXTRA TOK_STRING_LITERAL ';'
+ TOK_EXTRA Strings ';'
+ {
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_TYPE_EXTRA, NULL, $2);
+ }
;
Interface
:
TOK_INTERFACE TOK_IDENTIFIER ';'
{
- genjsbind_interface($2);
+ $$ = genbind_new_node(GENBIND_NODE_TYPE_TYPE_INTERFACE, NULL, $2);
}
;
diff --git a/src/genjsbind.c b/src/genjsbind.c
index dd5b242..559602b 100644
--- a/src/genjsbind.c
+++ b/src/genjsbind.c
@@ -15,6 +15,7 @@
#include <errno.h>
#include "genjsbind-ast.h"
+#include "jsapi-libdom.h"
#include "options.h"
struct options *options;
@@ -72,6 +73,7 @@ static struct options* process_cmdline(int argc, char **argv)
int main(int argc, char **argv)
{
int res;
+ struct genbind_node *genbind_root;
options = process_cmdline(argc, argv);
if (options == NULL) {
@@ -85,13 +87,17 @@ int main(int argc, char **argv)
return 2;
}
- res = genjsbind_parsefile(options->infilename);
+ res = genbind_parsefile(options->infilename, &genbind_root);
if (res != 0) {
fprintf(stderr, "Error: parse failed with code %d\n", res);
return res;
}
- res = genjsbind_output(options->outfilename);
+ if (options->verbose) {
+ genbind_ast_dump(genbind_root);
+ }
+
+ res = jsapi_libdom_output(options->outfilename, genbind_root);
if (res != 0) {
fprintf(stderr, "Error: output failed with code %d\n", res);
unlink(options->outfilename);
diff --git a/src/jsapi-libdom.c b/src/jsapi-libdom.c
new file mode 100644
index 0000000..c925ef9
--- /dev/null
+++ b/src/jsapi-libdom.c
@@ -0,0 +1,138 @@
+/* binding output generator for jsapi(spidermonkey) to libdom
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include "genjsbind-ast.h"
+#include "webidl-ast.h"
+#include "jsapi-libdom.h"
+
+#define HDR_COMMENT_SEP "\n * "
+#define HDR_COMMENT_PREABLE "Generated by nsgenjsapi"
+
+/*
+#define HDR_COMMENT_SEP_LEN 4
+
+int genbind_header_comment(char *comment)
+{
+ char *fullstr;
+ int fulllen;
+ fulllen = strlen(genbind_ast->hdr_comments) +
+ strlen(comment) + HDR_COMMENT_SEP_LEN + 1;
+ fullstr = malloc(fulllen);
+ snprintf(fullstr, fulllen, "%s"HDR_COMMENT_SEP"%s", genbind_ast->hdr_comments , comment);
+ free(genbind_ast->hdr_comments);
+ free(comment);
+ genbind_ast->hdr_comments = fullstr;
+
+ return 0;
+}
+
+{
+ if (webidl_parsefile($2) != 0) {
+ YYABORT;
+}
+}
+*/
+ /* initialise root IDL node */
+/* webidl_root =
+
+*/
+
+static int webidl_hdrcomments_cb(struct genbind_node *node, void *ctx)
+{
+ FILE *outfile = ctx;
+ char *txt;
+ txt = genbind_node_gettext(node);
+ fprintf(outfile, HDR_COMMENT_SEP"%s",txt);
+ return 0;
+}
+
+static int webidl_hdrcomment_cb(struct genbind_node *node, void *ctx)
+{
+ FILE *outfile = ctx;
+ genbind_node_for_each_type(genbind_node_getnode(node),
+ GENBIND_NODE_TYPE_STRING,
+ webidl_hdrcomments_cb,
+ ctx);
+ return 0;
+}
+
+static int
+output_header_comments(FILE *outfile, struct genbind_node *genbind_ast)
+{
+ fprintf(outfile, "/* "HDR_COMMENT_PREABLE);
+ genbind_node_for_each_type(genbind_ast,
+ GENBIND_NODE_TYPE_HDRCOMMENT,
+ webidl_hdrcomment_cb,
+ outfile);
+ fprintf(outfile,"\n */\n\n");
+ return 0;
+}
+
+static int webidl_file_cb(struct genbind_node *node, void *ctx)
+{
+ struct webidl_node **webidl_ast = ctx;
+ char *filename;
+
+ filename = genbind_node_gettext(node);
+
+ return webidl_parsefile(filename, webidl_ast);
+
+}
+
+static int
+read_webidl(struct genbind_node *genbind_ast, struct webidl_node **webidl_ast)
+{
+ return genbind_node_for_each_type(genbind_ast,
+ GENBIND_NODE_TYPE_WEBIDLFILE,
+ webidl_file_cb,
+ webidl_ast);
+
+}
+
+int jsapi_libdom_output(char *outfilename, struct genbind_node *genbind_ast)
+{
+ FILE *outfile = NULL;
+ struct webidl_node *webidl_ast = NULL;
+ int res;
+
+ res = read_webidl(genbind_ast, &webidl_ast);
+ if (res != 0) {
+ fprintf(stderr, "Error reading Web IDL files\n");
+ return 5;
+ }
+
+ /* open output file */
+ if (outfilename == NULL) {
+ outfile = stdout;
+ } else {
+ outfile = fopen(outfilename, "w");
+ }
+
+ if (!outfile) {
+ fprintf(stderr, "Error opening output %s: %s\n",
+ outfilename,
+ strerror(errno));
+ return 4;
+ }
+
+ output_header_comments(outfile, genbind_ast);
+
+ /* fprintf(outfile, " %s\n \n\n", genbind_ast->hdr_comments);
+
+ fprintf(outfile, "%s", genbind_ast->preamble);
+
+ fprintf(outfile, " interface %s \n\n", genbind_ast->ifname);
+*/
+ fclose(outfile);
+
+ return 0;
+}
diff --git a/src/jsapi-libdom.h b/src/jsapi-libdom.h
new file mode 100644
index 0000000..fe28723
--- /dev/null
+++ b/src/jsapi-libdom.h
@@ -0,0 +1,14 @@
+/* binding generator output
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
+#ifndef genjsbind_jsapi_libdom_h
+#define genjsbind_jsapi_libdom_h
+
+int jsapi_libdom_output(char *outfile, struct genbind_node *genbind_root);
+
+#endif
diff --git a/src/webidl-ast.c b/src/webidl-ast.c
index 1eddd68..e19fb80 100644
--- a/src/webidl-ast.c
+++ b/src/webidl-ast.c
@@ -18,19 +18,8 @@
extern int webidl_debug;
extern int webidl__flex_debug;
extern void webidl_restart(FILE*);
-extern int webidl_parse(void);
+extern int webidl_parse(struct webidl_node **webidl_ast);
-struct webidl_node *webidl_root;
-
-struct webidl_node *webidl_new_node(enum webidl_node_type type)
-{
- struct webidl_node *nnode;
- nnode = calloc(1, sizeof(struct webidl_node));
- if (nnode != NULL) {
- nnode->type = type;
- }
- return nnode;
-}
static FILE *idlopen(const char *filename)
{
@@ -55,10 +44,32 @@ static FILE *idlopen(const char *filename)
return idlfile;
}
-int webidl_parsefile(char *filename)
+struct webidl_node *
+webidl_node_link(struct webidl_node *tgt, struct webidl_node *src)
{
- /* set flex to read from file */
+ if (tgt != NULL) {
+ tgt->l = src;
+ return tgt;
+ }
+ return src;
+}
+
+struct webidl_node *webidl_node_new(int type, struct webidl_node *l, void *r)
+{
+ struct webidl_node *nn;
+ nn = calloc(1, sizeof(struct webidl_node));
+ nn->type = type;
+ nn->l = l;
+ nn->r.text = r;
+ return nn;
+}
+
+
+int webidl_parsefile(char *filename, struct webidl_node **webidl_ast)
+{
+
FILE *idlfile;
+
idlfile = idlopen(filename);
if (!idlfile) {
fprintf(stderr, "Error opening %s: %s\n",
@@ -72,8 +83,9 @@ int webidl_parsefile(char *filename)
webidl__flex_debug = 1;
}
+ /* set flex to read from file */
webidl_restart(idlfile);
/* parse the file */
- return webidl_parse();
+ return webidl_parse(webidl_ast);
}
diff --git a/src/webidl-ast.h b/src/webidl-ast.h
index 5dfd2a8..3c93305 100644
--- a/src/webidl-ast.h
+++ b/src/webidl-ast.h
@@ -9,35 +9,23 @@
#ifndef genjsbind_webidl_ast_h
#define genjsbind_webidl_ast_h
-enum webidl_node_type {
- WEBIDL_NODE_TYPE_ROOT,
- WEBIDL_NODE_TYPE_INTERFACE,
-};
-
-struct webidl_ifmember {
- char *name;
-};
-
-struct webidl_if {
- char *name;
- struct webidl_ifmember* members;
-};
-
+#define WEBIDL_NODE_TYPE_ROOT 0
struct webidl_node {
- enum webidl_node_type type;
+ int type;
+ struct webidl_node *l;
union {
- struct webidl_node *nodes;
- struct webidl_if interface;
- } data;
+ struct webidl_node *node;
+ char *text;
+ } r;
};
-extern struct webidl_node *webidl_root;
-
/** parse web idl file */
-int webidl_parsefile(char *filename);
+int webidl_parsefile(char *filename, struct webidl_node **webidl_ast);
+
+struct webidl_node *webidl_node_new(int type, struct webidl_node *l, void *r);
-struct webidl_node *webidl_new_node(enum webidl_node_type type);
+struct webidl_node *webidl_node_link(struct webidl_node *tgt, struct webidl_node *src);
#endif
diff --git a/src/webidl-lexer.l b/src/webidl-lexer.l
index 5c8234c..bfa4fb5 100644
--- a/src/webidl-lexer.l
+++ b/src/webidl-lexer.l
@@ -38,6 +38,7 @@
%option warn
%option prefix="webidl_"
%option nounput
+%option noyywrap
/* regular definitions */
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 '}' ';'
;
--
NetSurf Generator for JavaScript bindings
11 years, 2 months
netsurf: branch master updated. f8b2e2233278e8087adece20908bec8e5823a900
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/f8b2e2233278e8087adec...
...commit http://git.netsurf-browser.org/netsurf.git/commit/f8b2e2233278e8087adece2...
...tree http://git.netsurf-browser.org/netsurf.git/tree/f8b2e2233278e8087adece209...
The branch, master has been updated
via f8b2e2233278e8087adece20908bec8e5823a900 (commit)
via 5852693cca72af863df4120c2b9de2f3e1f2deb1 (commit)
from 3e549fde3eb07bf9bc696a701035de29d8b2cd96 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/f8b2e2233278e8087ad...
commit f8b2e2233278e8087adece20908bec8e5823a900
Merge: 5852693 3e549fd
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Merge branch 'master' of git://git.netsurf-browser.org/netsurf
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/5852693cca72af863df...
commit 5852693cca72af863df4120c2b9de2f3e1f2deb1
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Expor tthe correct messages when packaging
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index bb2b1c7..c3b75cd 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -103,7 +103,8 @@ install-amiga:
package-amiga: netsurf.lha
-AMIGA_LANGUAGES := de en fr it ja nl
+AMIGA_LANGUAGES_MESSAGES := de en fr it nl
+AMIGA_LANGUAGES := $(AMIGA_LANGUAGES_MESSAGES) ja
AMIGA_PLATFORM_RESOURCES := Pointers Themes default.css default.css.info favicon.png LangNames mimetypes Resource.map SearchEngines splash.png
AMIGA_GENERIC_RESOURCES := $(AMIGA_LANGUAGES) ca-bundle
AMIGA_RESOURCES := $(addprefix amiga/resources/,$(AMIGA_PLATFORM_RESOURCES)) $(addprefix \!NetSurf/Resources/,$(AMIGA_GENERIC_RESOURCES))
@@ -130,6 +131,7 @@ netsurf.lha: $(EXETARGET)
$(Q)cp amiga/pkg/fitr $(AMIGA_INSTALL_TARGET_DIR)/NetSurf
$(Q)cp amiga/pkg/drawer.info $(AMIGA_INSTALL_TARGET_DIR)/NetSurf.info
$(Q)cp amiga/pkg/AutoInstall $(AMIGA_INSTALL_TARGET_DIR)
+ $(Q)$(foreach AMIGA_LANGUAGE, $(AMIGA_LANGUAGES_MESSAGES), perl utils/split-messages.pl $(AMIGA_LANGUAGE) ami < resources/FatMessages >$(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources/$(AMIGA_LANGUAGE)/Messages;)
ifeq ($(HOST),amiga)
$(Q)mkdir $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Libs
$(Q)cp $(AMIGA_LIBS) $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Libs
-----------------------------------------------------------------------
Summary of changes:
amiga/Makefile.target | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/amiga/Makefile.target b/amiga/Makefile.target
index bb2b1c7..c3b75cd 100644
--- a/amiga/Makefile.target
+++ b/amiga/Makefile.target
@@ -103,7 +103,8 @@ install-amiga:
package-amiga: netsurf.lha
-AMIGA_LANGUAGES := de en fr it ja nl
+AMIGA_LANGUAGES_MESSAGES := de en fr it nl
+AMIGA_LANGUAGES := $(AMIGA_LANGUAGES_MESSAGES) ja
AMIGA_PLATFORM_RESOURCES := Pointers Themes default.css default.css.info favicon.png LangNames mimetypes Resource.map SearchEngines splash.png
AMIGA_GENERIC_RESOURCES := $(AMIGA_LANGUAGES) ca-bundle
AMIGA_RESOURCES := $(addprefix amiga/resources/,$(AMIGA_PLATFORM_RESOURCES)) $(addprefix \!NetSurf/Resources/,$(AMIGA_GENERIC_RESOURCES))
@@ -130,6 +131,7 @@ netsurf.lha: $(EXETARGET)
$(Q)cp amiga/pkg/fitr $(AMIGA_INSTALL_TARGET_DIR)/NetSurf
$(Q)cp amiga/pkg/drawer.info $(AMIGA_INSTALL_TARGET_DIR)/NetSurf.info
$(Q)cp amiga/pkg/AutoInstall $(AMIGA_INSTALL_TARGET_DIR)
+ $(Q)$(foreach AMIGA_LANGUAGE, $(AMIGA_LANGUAGES_MESSAGES), perl utils/split-messages.pl $(AMIGA_LANGUAGE) ami < resources/FatMessages >$(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Resources/$(AMIGA_LANGUAGE)/Messages;)
ifeq ($(HOST),amiga)
$(Q)mkdir $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Libs
$(Q)cp $(AMIGA_LIBS) $(AMIGA_INSTALL_TARGET_DIR)/NetSurf/Libs
--
NetSurf Browser
11 years, 2 months
netsurf: branch master updated. 3e549fde3eb07bf9bc696a701035de29d8b2cd96
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/3e549fde3eb07bf9bc696...
...commit http://git.netsurf-browser.org/netsurf.git/commit/3e549fde3eb07bf9bc696a7...
...tree http://git.netsurf-browser.org/netsurf.git/tree/3e549fde3eb07bf9bc696a701...
The branch, master has been updated
via 3e549fde3eb07bf9bc696a701035de29d8b2cd96 (commit)
from ba7fba824d8b3dfcaa7da4c74a3d7d5c75c811e6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commitdiff/3e549fde3eb07bf9bc6...
commit 3e549fde3eb07bf9bc696a701035de29d8b2cd96
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Update to use latest libdom. Fixes handling of text input with no maxlength set.
diff --git a/render/form.c b/render/form.c
index f0596b3..05d4042 100644
--- a/render/form.c
+++ b/render/form.c
@@ -200,9 +200,6 @@ struct form_control *form_new_control(void *node, form_control_type type)
control->node = node;
control->type = type;
- /* Default max length of input to something insane */
- control->maxlength = UINT_MAX;
-
return control;
}
diff --git a/render/html_forms.c b/render/html_forms.c
index fc2bcaf..f5c6600 100644
--- a/render/html_forms.c
+++ b/render/html_forms.c
@@ -332,10 +332,21 @@ parse_input_element(struct form *forms, dom_html_input_element *input)
if (control->type == GADGET_PASSWORD ||
control->type == GADGET_TEXTBOX) {
- unsigned long maxlength;
+ long maxlength;
if (dom_html_input_element_get_max_length(
- input, &maxlength) == DOM_NO_ERR) {
+ input, &maxlength) != DOM_NO_ERR) {
+ maxlength = -1;
+ }
+
+ if (maxlength >= 0) {
+ /* Got valid maxlength */
control->maxlength = maxlength;
+ } else {
+ /* Input has no maxlength attr, or
+ * dom_html_input_element_get_max_length failed.
+ *
+ * Set it to something insane. */
+ control->maxlength = UINT_MAX;
}
}
-----------------------------------------------------------------------
Summary of changes:
render/form.c | 3 ---
render/html_forms.c | 15 +++++++++++++--
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/render/form.c b/render/form.c
index f0596b3..05d4042 100644
--- a/render/form.c
+++ b/render/form.c
@@ -200,9 +200,6 @@ struct form_control *form_new_control(void *node, form_control_type type)
control->node = node;
control->type = type;
- /* Default max length of input to something insane */
- control->maxlength = UINT_MAX;
-
return control;
}
diff --git a/render/html_forms.c b/render/html_forms.c
index fc2bcaf..f5c6600 100644
--- a/render/html_forms.c
+++ b/render/html_forms.c
@@ -332,10 +332,21 @@ parse_input_element(struct form *forms, dom_html_input_element *input)
if (control->type == GADGET_PASSWORD ||
control->type == GADGET_TEXTBOX) {
- unsigned long maxlength;
+ long maxlength;
if (dom_html_input_element_get_max_length(
- input, &maxlength) == DOM_NO_ERR) {
+ input, &maxlength) != DOM_NO_ERR) {
+ maxlength = -1;
+ }
+
+ if (maxlength >= 0) {
+ /* Got valid maxlength */
control->maxlength = maxlength;
+ } else {
+ /* Input has no maxlength attr, or
+ * dom_html_input_element_get_max_length failed.
+ *
+ * Set it to something insane. */
+ control->maxlength = UINT_MAX;
}
}
--
NetSurf Browser
11 years, 2 months
libdom: branch master updated. c733e0fbd053ffa80b83839c4114a2a28b3ed2ec
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/c733e0fbd053ffa80b8383...
...commit http://git.netsurf-browser.org/libdom.git/commit/c733e0fbd053ffa80b83839c...
...tree http://git.netsurf-browser.org/libdom.git/tree/c733e0fbd053ffa80b83839c41...
The branch, master has been updated
via c733e0fbd053ffa80b83839c4114a2a28b3ed2ec (commit)
from e9f991799dd6ee22dcb8af367c72f58ac31e66ca (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libdom.git/commitdiff/c733e0fbd053ffa80b83...
commit c733e0fbd053ffa80b83839c4114a2a28b3ed2ec
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Return value of -1 when asked to get value of long property that doesn't exist on the html element.
diff --git a/include/dom/html/html_button_element.h b/include/dom/html/html_button_element.h
index 46376b2..9bbd562 100644
--- a/include/dom/html/html_button_element.h
+++ b/include/dom/html/html_button_element.h
@@ -37,7 +37,7 @@ dom_exception dom_html_button_element_set_name(
dom_html_button_element *button, dom_string *name);
dom_exception dom_html_button_element_get_tab_index(
- dom_html_button_element *button, unsigned long *tab_index);
+ dom_html_button_element *button, long *tab_index);
dom_exception dom_html_button_element_set_tab_index(
dom_html_button_element *button, unsigned long tab_index);
diff --git a/include/dom/html/html_input_element.h b/include/dom/html/html_input_element.h
index 60de08e..6d87bd9 100644
--- a/include/dom/html/html_input_element.h
+++ b/include/dom/html/html_input_element.h
@@ -67,7 +67,7 @@ dom_exception dom_html_input_element_set_disabled(
dom_html_input_element *input, bool disabled);
dom_exception dom_html_input_element_get_max_length(
- dom_html_input_element *input, unsigned long *max_length);
+ dom_html_input_element *input, long *max_length);
dom_exception dom_html_input_element_set_max_length(
dom_html_input_element *input, unsigned long max_length);
@@ -97,7 +97,7 @@ dom_exception dom_html_input_element_set_src(
dom_html_input_element *input, dom_string *src);
dom_exception dom_html_input_element_get_tab_index(
- dom_html_input_element *input, unsigned long *tab_index);
+ dom_html_input_element *input, long *tab_index);
dom_exception dom_html_input_element_set_tab_index(
dom_html_input_element *input, unsigned long tab_index);
diff --git a/include/dom/html/html_text_area_element.h b/include/dom/html/html_text_area_element.h
index 37264cf..ce610ad 100644
--- a/include/dom/html/html_text_area_element.h
+++ b/include/dom/html/html_text_area_element.h
@@ -37,13 +37,13 @@ dom_exception dom_html_text_area_element_set_disabled(
dom_html_text_area_element *text_area, bool disabled);
dom_exception dom_html_text_area_element_get_cols(
- dom_html_text_area_element *text_area, unsigned long *cols);
+ dom_html_text_area_element *text_area, long *cols);
dom_exception dom_html_text_area_element_set_cols(
dom_html_text_area_element *text_area, unsigned long cols);
dom_exception dom_html_text_area_element_get_rows(
- dom_html_text_area_element *text_area, unsigned long *rows);
+ dom_html_text_area_element *text_area, long *rows);
dom_exception dom_html_text_area_element_set_rows(
dom_html_text_area_element *text_area, unsigned long rows);
@@ -61,7 +61,7 @@ dom_exception dom_html_text_area_element_set_read_only(
dom_html_text_area_element *text_area, bool read_only);
dom_exception dom_html_text_area_element_get_tab_index(
- dom_html_text_area_element *text_area, unsigned long *tab_index);
+ dom_html_text_area_element *text_area, long *tab_index);
dom_exception dom_html_text_area_element_set_tab_index(
dom_html_text_area_element *text_area, unsigned long tab_index);
diff --git a/src/html/html_button_element.c b/src/html/html_button_element.c
index 68cb1a5..47fdb7b 100644
--- a/src/html/html_button_element.c
+++ b/src/html/html_button_element.c
@@ -196,7 +196,7 @@ SIMPLE_GET(type);
SIMPLE_GET_SET(value);
dom_exception dom_html_button_element_get_tab_index(
- dom_html_button_element *button, unsigned long *tab_index)
+ dom_html_button_element *button, long *tab_index)
{
return dom_html_element_get_long_property(&button->base, "tabindex",
SLEN("tabindex"), tab_index);
diff --git a/src/html/html_element.c b/src/html/html_element.c
index c2a4899..b3b3bfc 100644
--- a/src/html/html_element.c
+++ b/src/html/html_element.c
@@ -330,11 +330,11 @@ static char *_strndup(const char *s, size_t n)
* \param ele The dom_html_element object
* \param name The name of the attribute
* \param len The length of ::name
- * \param value The returned value
+ * \param value The returned value, or -1 if prop. not set
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception dom_html_element_get_long_property(dom_html_element *ele,
- const char *name, unsigned long len, unsigned long *value)
+ const char *name, unsigned long len, long *value)
{
dom_string *str = NULL, *s2 = NULL;
dom_attr *a = NULL;
@@ -358,7 +358,8 @@ dom_exception dom_html_element_get_long_property(dom_html_element *ele,
dom_string_unref(s2);
}
} else {
- *value = 0;
+ /* Property is not set on this node */
+ *value = -1;
}
dom_node_unref(a);
diff --git a/src/html/html_element.h b/src/html/html_element.h
index 2ac4b17..140e3f1 100644
--- a/src/html/html_element.h
+++ b/src/html/html_element.h
@@ -118,7 +118,7 @@ dom_exception dom_html_element_set_bool_property(dom_html_element *ele,
const char *name, unsigned long len, bool has);
dom_exception dom_html_element_get_long_property(dom_html_element *ele,
- const char *name, unsigned long len, unsigned long *value);
+ const char *name, unsigned long len, long *value);
dom_exception dom_html_element_set_long_property(dom_html_element *ele,
const char *name, unsigned long len, unsigned long value);
diff --git a/src/html/html_input_element.c b/src/html/html_input_element.c
index aa3e05f..694eb22 100644
--- a/src/html/html_input_element.c
+++ b/src/html/html_input_element.c
@@ -356,7 +356,7 @@ SIMPLE_GET_SET(use_map);
SIMPLE_GET_SET(value);
dom_exception dom_html_input_element_get_tab_index(
- dom_html_input_element *input, unsigned long *tab_index)
+ dom_html_input_element *input, long *tab_index)
{
return dom_html_element_get_long_property(&input->base, "tabindex",
SLEN("tabindex"), tab_index);
@@ -370,7 +370,7 @@ dom_exception dom_html_input_element_set_tab_index(
}
dom_exception dom_html_input_element_get_max_length(
- dom_html_input_element *input, unsigned long *max_length)
+ dom_html_input_element *input, long *max_length)
{
return dom_html_element_get_long_property(&input->base, "maxlength",
SLEN("maxlength"), max_length);
diff --git a/src/html/html_text_area_element.c b/src/html/html_text_area_element.c
index cb95920..887a2c0 100644
--- a/src/html/html_text_area_element.c
+++ b/src/html/html_text_area_element.c
@@ -365,7 +365,7 @@ dom_exception dom_html_text_area_element_get_type(
}
dom_exception dom_html_text_area_element_get_tab_index(
- dom_html_text_area_element *text_area, unsigned long *tab_index)
+ dom_html_text_area_element *text_area, long *tab_index)
{
return dom_html_element_get_long_property(&text_area->base, "tabindex",
SLEN("tabindex"), tab_index);
@@ -379,7 +379,7 @@ dom_exception dom_html_text_area_element_set_tab_index(
}
dom_exception dom_html_text_area_element_get_cols(
- dom_html_text_area_element *text_area, unsigned long *cols)
+ dom_html_text_area_element *text_area, long *cols)
{
return dom_html_element_get_long_property(&text_area->base, "cols",
SLEN("cols"), cols);
@@ -393,7 +393,7 @@ dom_exception dom_html_text_area_element_set_cols(
}
dom_exception dom_html_text_area_element_get_rows(
- dom_html_text_area_element *text_area, unsigned long *rows)
+ dom_html_text_area_element *text_area, long *rows)
{
return dom_html_element_get_long_property(&text_area->base, "rows",
SLEN("rows"), rows);
-----------------------------------------------------------------------
Summary of changes:
include/dom/html/html_button_element.h | 2 +-
include/dom/html/html_input_element.h | 4 ++--
include/dom/html/html_text_area_element.h | 6 +++---
src/html/html_button_element.c | 2 +-
src/html/html_element.c | 7 ++++---
src/html/html_element.h | 2 +-
src/html/html_input_element.c | 4 ++--
src/html/html_text_area_element.c | 6 +++---
8 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/include/dom/html/html_button_element.h b/include/dom/html/html_button_element.h
index 46376b2..9bbd562 100644
--- a/include/dom/html/html_button_element.h
+++ b/include/dom/html/html_button_element.h
@@ -37,7 +37,7 @@ dom_exception dom_html_button_element_set_name(
dom_html_button_element *button, dom_string *name);
dom_exception dom_html_button_element_get_tab_index(
- dom_html_button_element *button, unsigned long *tab_index);
+ dom_html_button_element *button, long *tab_index);
dom_exception dom_html_button_element_set_tab_index(
dom_html_button_element *button, unsigned long tab_index);
diff --git a/include/dom/html/html_input_element.h b/include/dom/html/html_input_element.h
index 60de08e..6d87bd9 100644
--- a/include/dom/html/html_input_element.h
+++ b/include/dom/html/html_input_element.h
@@ -67,7 +67,7 @@ dom_exception dom_html_input_element_set_disabled(
dom_html_input_element *input, bool disabled);
dom_exception dom_html_input_element_get_max_length(
- dom_html_input_element *input, unsigned long *max_length);
+ dom_html_input_element *input, long *max_length);
dom_exception dom_html_input_element_set_max_length(
dom_html_input_element *input, unsigned long max_length);
@@ -97,7 +97,7 @@ dom_exception dom_html_input_element_set_src(
dom_html_input_element *input, dom_string *src);
dom_exception dom_html_input_element_get_tab_index(
- dom_html_input_element *input, unsigned long *tab_index);
+ dom_html_input_element *input, long *tab_index);
dom_exception dom_html_input_element_set_tab_index(
dom_html_input_element *input, unsigned long tab_index);
diff --git a/include/dom/html/html_text_area_element.h b/include/dom/html/html_text_area_element.h
index 37264cf..ce610ad 100644
--- a/include/dom/html/html_text_area_element.h
+++ b/include/dom/html/html_text_area_element.h
@@ -37,13 +37,13 @@ dom_exception dom_html_text_area_element_set_disabled(
dom_html_text_area_element *text_area, bool disabled);
dom_exception dom_html_text_area_element_get_cols(
- dom_html_text_area_element *text_area, unsigned long *cols);
+ dom_html_text_area_element *text_area, long *cols);
dom_exception dom_html_text_area_element_set_cols(
dom_html_text_area_element *text_area, unsigned long cols);
dom_exception dom_html_text_area_element_get_rows(
- dom_html_text_area_element *text_area, unsigned long *rows);
+ dom_html_text_area_element *text_area, long *rows);
dom_exception dom_html_text_area_element_set_rows(
dom_html_text_area_element *text_area, unsigned long rows);
@@ -61,7 +61,7 @@ dom_exception dom_html_text_area_element_set_read_only(
dom_html_text_area_element *text_area, bool read_only);
dom_exception dom_html_text_area_element_get_tab_index(
- dom_html_text_area_element *text_area, unsigned long *tab_index);
+ dom_html_text_area_element *text_area, long *tab_index);
dom_exception dom_html_text_area_element_set_tab_index(
dom_html_text_area_element *text_area, unsigned long tab_index);
diff --git a/src/html/html_button_element.c b/src/html/html_button_element.c
index 68cb1a5..47fdb7b 100644
--- a/src/html/html_button_element.c
+++ b/src/html/html_button_element.c
@@ -196,7 +196,7 @@ SIMPLE_GET(type);
SIMPLE_GET_SET(value);
dom_exception dom_html_button_element_get_tab_index(
- dom_html_button_element *button, unsigned long *tab_index)
+ dom_html_button_element *button, long *tab_index)
{
return dom_html_element_get_long_property(&button->base, "tabindex",
SLEN("tabindex"), tab_index);
diff --git a/src/html/html_element.c b/src/html/html_element.c
index c2a4899..b3b3bfc 100644
--- a/src/html/html_element.c
+++ b/src/html/html_element.c
@@ -330,11 +330,11 @@ static char *_strndup(const char *s, size_t n)
* \param ele The dom_html_element object
* \param name The name of the attribute
* \param len The length of ::name
- * \param value The returned value
+ * \param value The returned value, or -1 if prop. not set
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception dom_html_element_get_long_property(dom_html_element *ele,
- const char *name, unsigned long len, unsigned long *value)
+ const char *name, unsigned long len, long *value)
{
dom_string *str = NULL, *s2 = NULL;
dom_attr *a = NULL;
@@ -358,7 +358,8 @@ dom_exception dom_html_element_get_long_property(dom_html_element *ele,
dom_string_unref(s2);
}
} else {
- *value = 0;
+ /* Property is not set on this node */
+ *value = -1;
}
dom_node_unref(a);
diff --git a/src/html/html_element.h b/src/html/html_element.h
index 2ac4b17..140e3f1 100644
--- a/src/html/html_element.h
+++ b/src/html/html_element.h
@@ -118,7 +118,7 @@ dom_exception dom_html_element_set_bool_property(dom_html_element *ele,
const char *name, unsigned long len, bool has);
dom_exception dom_html_element_get_long_property(dom_html_element *ele,
- const char *name, unsigned long len, unsigned long *value);
+ const char *name, unsigned long len, long *value);
dom_exception dom_html_element_set_long_property(dom_html_element *ele,
const char *name, unsigned long len, unsigned long value);
diff --git a/src/html/html_input_element.c b/src/html/html_input_element.c
index aa3e05f..694eb22 100644
--- a/src/html/html_input_element.c
+++ b/src/html/html_input_element.c
@@ -356,7 +356,7 @@ SIMPLE_GET_SET(use_map);
SIMPLE_GET_SET(value);
dom_exception dom_html_input_element_get_tab_index(
- dom_html_input_element *input, unsigned long *tab_index)
+ dom_html_input_element *input, long *tab_index)
{
return dom_html_element_get_long_property(&input->base, "tabindex",
SLEN("tabindex"), tab_index);
@@ -370,7 +370,7 @@ dom_exception dom_html_input_element_set_tab_index(
}
dom_exception dom_html_input_element_get_max_length(
- dom_html_input_element *input, unsigned long *max_length)
+ dom_html_input_element *input, long *max_length)
{
return dom_html_element_get_long_property(&input->base, "maxlength",
SLEN("maxlength"), max_length);
diff --git a/src/html/html_text_area_element.c b/src/html/html_text_area_element.c
index cb95920..887a2c0 100644
--- a/src/html/html_text_area_element.c
+++ b/src/html/html_text_area_element.c
@@ -365,7 +365,7 @@ dom_exception dom_html_text_area_element_get_type(
}
dom_exception dom_html_text_area_element_get_tab_index(
- dom_html_text_area_element *text_area, unsigned long *tab_index)
+ dom_html_text_area_element *text_area, long *tab_index)
{
return dom_html_element_get_long_property(&text_area->base, "tabindex",
SLEN("tabindex"), tab_index);
@@ -379,7 +379,7 @@ dom_exception dom_html_text_area_element_set_tab_index(
}
dom_exception dom_html_text_area_element_get_cols(
- dom_html_text_area_element *text_area, unsigned long *cols)
+ dom_html_text_area_element *text_area, long *cols)
{
return dom_html_element_get_long_property(&text_area->base, "cols",
SLEN("cols"), cols);
@@ -393,7 +393,7 @@ dom_exception dom_html_text_area_element_set_cols(
}
dom_exception dom_html_text_area_element_get_rows(
- dom_html_text_area_element *text_area, unsigned long *rows)
+ dom_html_text_area_element *text_area, long *rows)
{
return dom_html_element_get_long_property(&text_area->base, "rows",
SLEN("rows"), rows);
--
Document Object Model library
11 years, 2 months
nsgenjsbind: branch master updated. c7493cf58c439bb3b9d2cf2cd989d3dc6f7ebb39
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/c7493cf58c439bb3b...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/c7493cf58c439bb3b9d...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/c7493cf58c439bb3b9d2c...
The branch, master has been updated
via c7493cf58c439bb3b9d2cf2cd989d3dc6f7ebb39 (commit)
from 686b84a6ccd64015c0de4e542504fa44424fb987 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/c7493cf58c439bb...
commit c7493cf58c439bb3b9d2cf2cd989d3dc6f7ebb39
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
alter InterfaceMembers to be left recusrsive
Document accurately the changes from the w3c grammar
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index 7425a21..db10ab7 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -114,7 +114,13 @@ int webidl_wrap()
%%
- /* [1] start with definitions */
+ /* [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
|
@@ -183,14 +189,14 @@ PartialInterface:
TOK_INTERFACE TOK_IDENTIFIER '{' InterfaceMembers '}' ';'
;
- /* [9] */
+ /* [9] slightly altered from original grammar to be left recursive */
InterfaceMembers:
/* empty */
{
$$ = NULL;
}
|
- ExtendedAttributeList InterfaceMember InterfaceMembers
+ InterfaceMembers ExtendedAttributeList InterfaceMember
{
$$ = NULL;
}
diff --git a/test/data/bindings/blankidl.bnd b/test/data/bindings/blankidl.bnd
new file mode 100644
index 0000000..dfd7a4a
--- /dev/null
+++ b/test/data/bindings/blankidl.bnd
@@ -0,0 +1 @@
+webidlfile "blank.idl";
diff --git a/test/data/bindings/emptyidl.bnd b/test/data/bindings/emptyidl.bnd
new file mode 100644
index 0000000..e746325
--- /dev/null
+++ b/test/data/bindings/emptyidl.bnd
@@ -0,0 +1 @@
+webidlfile "empty.idl";
diff --git a/test/data/idl/blank.idl b/test/data/idl/blank.idl
new file mode 100644
index 0000000..4661728
--- /dev/null
+++ b/test/data/idl/blank.idl
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/test/data/idl/empty.idl b/test/data/idl/empty.idl
new file mode 100644
index 0000000..e69de29
-----------------------------------------------------------------------
Summary of changes:
src/webidl-parser.y | 12 +++++++++---
test/data/bindings/blankidl.bnd | 1 +
test/data/bindings/emptyidl.bnd | 1 +
test/data/idl/blank.idl | 4 ++++
4 files changed, 15 insertions(+), 3 deletions(-)
create mode 100644 test/data/bindings/blankidl.bnd
create mode 100644 test/data/bindings/emptyidl.bnd
create mode 100644 test/data/idl/blank.idl
create mode 100644 test/data/idl/empty.idl
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index 7425a21..db10ab7 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -114,7 +114,13 @@ int webidl_wrap()
%%
- /* [1] start with definitions */
+ /* [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
|
@@ -183,14 +189,14 @@ PartialInterface:
TOK_INTERFACE TOK_IDENTIFIER '{' InterfaceMembers '}' ';'
;
- /* [9] */
+ /* [9] slightly altered from original grammar to be left recursive */
InterfaceMembers:
/* empty */
{
$$ = NULL;
}
|
- ExtendedAttributeList InterfaceMember InterfaceMembers
+ InterfaceMembers ExtendedAttributeList InterfaceMember
{
$$ = NULL;
}
diff --git a/test/data/bindings/blankidl.bnd b/test/data/bindings/blankidl.bnd
new file mode 100644
index 0000000..dfd7a4a
--- /dev/null
+++ b/test/data/bindings/blankidl.bnd
@@ -0,0 +1 @@
+webidlfile "blank.idl";
diff --git a/test/data/bindings/emptyidl.bnd b/test/data/bindings/emptyidl.bnd
new file mode 100644
index 0000000..e746325
--- /dev/null
+++ b/test/data/bindings/emptyidl.bnd
@@ -0,0 +1 @@
+webidlfile "empty.idl";
diff --git a/test/data/idl/blank.idl b/test/data/idl/blank.idl
new file mode 100644
index 0000000..4661728
--- /dev/null
+++ b/test/data/idl/blank.idl
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/test/data/idl/empty.idl b/test/data/idl/empty.idl
new file mode 100644
index 0000000..e69de29
--
NetSurf Generator for JavaScript bindings
11 years, 2 months
nsgenjsbind: branch master updated. 686b84a6ccd64015c0de4e542504fa44424fb987
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/686b84a6ccd64015c...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/686b84a6ccd64015c0d...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/686b84a6ccd64015c0de4...
The branch, master has been updated
via 686b84a6ccd64015c0de4e542504fa44424fb987 (commit)
from 3e84190d4874e1c97091758fe65756da51b4209b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/686b84a6ccd6401...
commit 686b84a6ccd64015c0de4e542504fa44424fb987
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
slightly rearrange Web IDL start term to be left recusrsive and not have reduce/reduce conflicts
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index ef119c9..7425a21 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -37,11 +37,8 @@ int webidl_wrap()
%define api.pure
%error-verbose
- /* the w3c grammar results in 10 shift/reduce, 2 reduce/reduce conflicts
- * The reduce/reduce error are both the result of empty sequences
- */
- /* %expect 10 */
- /* %expect-rr 2 */
+ /* the w3c grammar results in 19 shift/reduce conficts */
+%expect 19
%union
{
@@ -119,9 +116,9 @@ int webidl_wrap()
/* [1] start with definitions */
Definitions:
- /* empty */
+ ExtendedAttributeList Definition
|
- ExtendedAttributeList Definition Definitions
+ Definitions ExtendedAttributeList Definition
|
error ';'
{
-----------------------------------------------------------------------
Summary of changes:
src/webidl-parser.y | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index ef119c9..7425a21 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -37,11 +37,8 @@ int webidl_wrap()
%define api.pure
%error-verbose
- /* the w3c grammar results in 10 shift/reduce, 2 reduce/reduce conflicts
- * The reduce/reduce error are both the result of empty sequences
- */
- /* %expect 10 */
- /* %expect-rr 2 */
+ /* the w3c grammar results in 19 shift/reduce conficts */
+%expect 19
%union
{
@@ -119,9 +116,9 @@ int webidl_wrap()
/* [1] start with definitions */
Definitions:
- /* empty */
+ ExtendedAttributeList Definition
|
- ExtendedAttributeList Definition Definitions
+ Definitions ExtendedAttributeList Definition
|
error ';'
{
--
NetSurf Generator for JavaScript bindings
11 years, 2 months
nsgenjsbind: branch master updated. 3e84190d4874e1c97091758fe65756da51b4209b
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/3e84190d4874e1c97...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/3e84190d4874e1c9709...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/3e84190d4874e1c970917...
The branch, master has been updated
via 3e84190d4874e1c97091758fe65756da51b4209b (commit)
from 53a218f08e4a0ab7a2042b774a871eb93f17c90f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/3e84190d4874e1c...
commit 3e84190d4874e1c97091758fe65756da51b4209b
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
fix braino while moving filename
diff --git a/src/Makefile b/src/Makefile
index 62fb23b..1116400 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,7 +1,7 @@
CFLAGS := $(CFLAGS) -I$(BUILDDIR) -Isrc/ -g
# Sources in this directory
-DIR_SOURCES := genjsbind.c webidl-ast.c jsapi-binding.c
+DIR_SOURCES := genjsbind.c webidl-ast.c genjsbind-ast.c
SOURCES := $(SOURCES) $(BUILDDIR)/genjsbind-parser.c $(BUILDDIR)/genjsbind-lexer.c $(BUILDDIR)/webidl-parser.c $(BUILDDIR)/webidl-lexer.c
-----------------------------------------------------------------------
Summary of changes:
src/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/Makefile b/src/Makefile
index 62fb23b..1116400 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,7 +1,7 @@
CFLAGS := $(CFLAGS) -I$(BUILDDIR) -Isrc/ -g
# Sources in this directory
-DIR_SOURCES := genjsbind.c webidl-ast.c jsapi-binding.c
+DIR_SOURCES := genjsbind.c webidl-ast.c genjsbind-ast.c
SOURCES := $(SOURCES) $(BUILDDIR)/genjsbind-parser.c $(BUILDDIR)/genjsbind-lexer.c $(BUILDDIR)/webidl-parser.c $(BUILDDIR)/webidl-lexer.c
--
NetSurf Generator for JavaScript bindings
11 years, 2 months
nsgenjsbind: branch master updated. 53a218f08e4a0ab7a2042b774a871eb93f17c90f
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/53a218f08e4a0ab7a...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/53a218f08e4a0ab7a20...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/53a218f08e4a0ab7a2042...
The branch, master has been updated
via 53a218f08e4a0ab7a2042b774a871eb93f17c90f (commit)
via 7ba968e4c33d3a05ff9b23b8e593b400e34a4cad (commit)
from f60d94623e676bb80670b465b1bed7ad4559581d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/53a218f08e4a0ab...
commit 53a218f08e4a0ab7a2042b774a871eb93f17c90f
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
add copyright and licence notices
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..59700b0
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,19 @@
+Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+ * The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/src/genjsbind-ast.c b/src/genjsbind-ast.c
new file mode 100644
index 0000000..ccadc7f
--- /dev/null
+++ b/src/genjsbind-ast.c
@@ -0,0 +1,151 @@
+/* binding generator AST implementation for parser
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
+/** @todo this currently stuffs everything in one global tree, not very nice
+ */
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+
+#include "genjsbind-ast.h"
+#include "webidl-ast.h"
+#include "options.h"
+
+/* parser and lexer interface */
+extern int genjsbind_debug;
+extern int genjsbind__flex_debug;
+extern void genjsbind_restart(FILE*);
+extern int genjsbind_parse(void);
+
+
+#define HDR_COMMENT_SEP "\n * "
+#define HDR_COMMENT_SEP_LEN 4
+#define HDR_COMMENT_PREABLE "Generated by nsgenjsapi"HDR_COMMENT_SEP
+
+/* current state */
+static char *hdr_comments = NULL;
+static char *preamble = NULL;
+static char *ifname;
+
+int genjsbind_header_comment(char *comment)
+{
+ char *fullstr;
+ int fulllen;
+ fulllen = strlen(hdr_comments) + strlen(comment) + HDR_COMMENT_SEP_LEN + 1;
+ fullstr = malloc(fulllen);
+ snprintf(fullstr, fulllen, "%s"HDR_COMMENT_SEP"%s", hdr_comments , comment);
+ free(hdr_comments);
+ free(comment);
+ hdr_comments = fullstr;
+
+ return 0;
+}
+
+int genjsbind_preamble(char *ccode)
+{
+ char *fullstr;
+ int fulllen;
+ fulllen = strlen(preamble) + strlen(ccode) + 1;
+ fullstr = malloc(fulllen);
+ snprintf(fullstr, fulllen, "%s%s", preamble , ccode);
+ free(preamble);
+ free(ccode);
+ preamble = fullstr;
+
+ return 0;
+}
+
+int genjsbind_interface(char *interface)
+{
+ ifname = interface;
+ return 0;
+}
+
+static void init_state(void)
+{
+ /* initialise root node */
+ webidl_root = webidl_new_node(WEBIDL_NODE_TYPE_ROOT);
+
+ /* set default comment header text */
+ hdr_comments = strdup(HDR_COMMENT_PREABLE);
+
+ preamble = strdup("");
+}
+
+int genjsbind_parsefile(char *infilename)
+{
+ FILE *infile;
+
+ /* open input file */
+ if ((infilename[0] == '-') &&
+ (infilename[1] == 0)) {
+ if (options->verbose) {
+ printf("Using stdin for input\n");
+ }
+ infile = stdin;
+ } else {
+ if (options->verbose) {
+ printf("Opening binding file %s\n", options->infilename);
+ }
+ infile = fopen(infilename, "r");
+ }
+
+ if (!infile) {
+ fprintf(stderr, "Error opening %s: %s\n",
+ infilename,
+ strerror(errno));
+ return 3;
+ }
+
+ /* initialise internal state */
+ init_state();
+
+ if (options->debug) {
+ genjsbind_debug = 1;
+ genjsbind__flex_debug = 1;
+ }
+
+ /* set flex to read from file */
+ genjsbind_restart(infile);
+
+ /* process binding */
+ return genjsbind_parse();
+
+}
+
+int genjsbind_output(char *outfilename)
+{
+ FILE *outfile = NULL;
+ /* open output file */
+ if (outfilename == NULL) {
+ outfile = stdout;
+ } else {
+ outfile = fopen(outfilename, "w");
+ }
+
+ if (!outfile) {
+ fprintf(stderr, "Error opening output %s: %s\n",
+ outfilename,
+ strerror(errno));
+ return 4;
+ }
+
+ fprintf(outfile, "/* %s\n */\n\n", hdr_comments);
+
+ fprintf(outfile, "%s", preamble);
+
+ fprintf(outfile, "/* interface %s */\n\n", ifname);
+
+ fclose(outfile);
+
+ return 0;
+}
+
diff --git a/src/genjsbind-ast.h b/src/genjsbind-ast.h
new file mode 100644
index 0000000..d94eda6
--- /dev/null
+++ b/src/genjsbind-ast.h
@@ -0,0 +1,18 @@
+/* binding file AST interface
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
+#ifndef genjsbind_genjsbind_ast_h
+#define genjsbind_genjsbind_ast_h
+
+int genjsbind_parsefile(char *infilename);
+int genjsbind_output(char *outfilename);
+int genjsbind_header_comment(char *);
+int genjsbind_interface(char *);
+int genjsbind_preamble(char *ccode);
+
+#endif
diff --git a/src/genjsbind-lexer.l b/src/genjsbind-lexer.l
index 1406872..5044c04 100644
--- a/src/genjsbind-lexer.l
+++ b/src/genjsbind-lexer.l
@@ -1,7 +1,11 @@
%{
-/*
- * binding generator lexer
+/* lexer for the binding generation config file
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
*/
#include <stdbool.h>
diff --git a/src/genjsbind-parser.y b/src/genjsbind-parser.y
index 1a342ae..9ed4f21 100644
--- a/src/genjsbind-parser.y
+++ b/src/genjsbind-parser.y
@@ -1,7 +1,10 @@
%{
-/*
- * This is a bison parser for genbind
+/* parser for the binding generation config file
*
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
*/
#include <stdio.h>
@@ -10,7 +13,7 @@
#include "genjsbind-parser.h"
#include "genjsbind-lexer.h"
#include "webidl-ast.h"
-#include "jsapi-binding.h"
+#include "genjsbind-ast.h"
char *errtxt;
diff --git a/src/genjsbind.c b/src/genjsbind.c
index 6bc84b3..dd5b242 100644
--- a/src/genjsbind.c
+++ b/src/genjsbind.c
@@ -1,3 +1,11 @@
+/* binding generator main and command line parsing
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
@@ -6,7 +14,7 @@
#include <getopt.h>
#include <errno.h>
-#include "jsapi-binding.h"
+#include "genjsbind-ast.h"
#include "options.h"
struct options *options;
diff --git a/src/jsapi-binding.c b/src/jsapi-binding.c
deleted file mode 100644
index 9f1bc7e..0000000
--- a/src/jsapi-binding.c
+++ /dev/null
@@ -1,140 +0,0 @@
-#include <stdio.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-
-#include "jsapi-binding.h"
-#include "webidl-ast.h"
-#include "options.h"
-
-/* parser and lexer interface */
-extern int genjsbind_debug;
-extern int genjsbind__flex_debug;
-extern void genjsbind_restart(FILE*);
-extern int genjsbind_parse(void);
-
-
-#define HDR_COMMENT_SEP "\n * "
-#define HDR_COMMENT_SEP_LEN 4
-#define HDR_COMMENT_PREABLE "Generated by nsgenjsapi"HDR_COMMENT_SEP
-
-/* current state */
-static char *hdr_comments = NULL;
-static char *preamble = NULL;
-static char *ifname;
-
-int genjsbind_header_comment(char *comment)
-{
- char *fullstr;
- int fulllen;
- fulllen = strlen(hdr_comments) + strlen(comment) + HDR_COMMENT_SEP_LEN + 1;
- fullstr = malloc(fulllen);
- snprintf(fullstr, fulllen, "%s"HDR_COMMENT_SEP"%s", hdr_comments , comment);
- free(hdr_comments);
- free(comment);
- hdr_comments = fullstr;
-
- return 0;
-}
-
-int genjsbind_preamble(char *ccode)
-{
- char *fullstr;
- int fulllen;
- fulllen = strlen(preamble) + strlen(ccode) + 1;
- fullstr = malloc(fulllen);
- snprintf(fullstr, fulllen, "%s%s", preamble , ccode);
- free(preamble);
- free(ccode);
- preamble = fullstr;
-
- return 0;
-}
-
-int genjsbind_interface(char *interface)
-{
- ifname = interface;
- return 0;
-}
-
-static void init_state(void)
-{
- /* initialise root node */
- webidl_root = webidl_new_node(WEBIDL_NODE_TYPE_ROOT);
-
- /* set default comment header text */
- hdr_comments = strdup(HDR_COMMENT_PREABLE);
-
- preamble = strdup("");
-}
-
-int genjsbind_parsefile(char *infilename)
-{
- FILE *infile;
-
- /* open input file */
- if ((infilename[0] == '-') &&
- (infilename[1] == 0)) {
- if (options->verbose) {
- printf("Using stdin for input\n");
- }
- infile = stdin;
- } else {
- if (options->verbose) {
- printf("Opening binding file %s\n", options->infilename);
- }
- infile = fopen(infilename, "r");
- }
-
- if (!infile) {
- fprintf(stderr, "Error opening %s: %s\n",
- infilename,
- strerror(errno));
- return 3;
- }
-
- /* initialise internal state */
- init_state();
-
- if (options->debug) {
- genjsbind_debug = 1;
- genjsbind__flex_debug = 1;
- }
-
- /* set flex to read from file */
- genjsbind_restart(infile);
-
- /* process binding */
- return genjsbind_parse();
-
-}
-
-int genjsbind_output(char *outfilename)
-{
- FILE *outfile = NULL;
- /* open output file */
- if (outfilename == NULL) {
- outfile = stdout;
- } else {
- outfile = fopen(outfilename, "w");
- }
-
- if (!outfile) {
- fprintf(stderr, "Error opening output %s: %s\n",
- outfilename,
- strerror(errno));
- return 4;
- }
-
- fprintf(outfile, "/* %s\n */\n\n", hdr_comments);
-
- fprintf(outfile, "%s", preamble);
-
- fprintf(outfile, "/* interface %s */\n\n", ifname);
-
- fclose(outfile);
-
- return 0;
-}
-
diff --git a/src/jsapi-binding.h b/src/jsapi-binding.h
deleted file mode 100644
index 33f9776..0000000
--- a/src/jsapi-binding.h
+++ /dev/null
@@ -1,5 +0,0 @@
-int genjsbind_parsefile(char *infilename);
-int genjsbind_output(char *outfilename);
-int genjsbind_header_comment(char *);
-int genjsbind_interface(char *);
-int genjsbind_preamble(char *ccode);
diff --git a/src/options.h b/src/options.h
index 47f3c11..041f4cd 100644
--- a/src/options.h
+++ b/src/options.h
@@ -1,3 +1,14 @@
+/* binding generator options
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
+#ifndef genjsbind_options_h
+#define genjsbind_options_h
+
struct options {
char *outfilename;
char *infilename;
@@ -8,3 +19,4 @@ struct options {
extern struct options *options;
+#endif
diff --git a/src/webidl-ast.c b/src/webidl-ast.c
index 95b271d..1eddd68 100644
--- a/src/webidl-ast.c
+++ b/src/webidl-ast.c
@@ -1,3 +1,11 @@
+/* AST generator for the WEB IDL parser
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/src/webidl-ast.h b/src/webidl-ast.h
index f49268a..5dfd2a8 100644
--- a/src/webidl-ast.h
+++ b/src/webidl-ast.h
@@ -1,3 +1,14 @@
+/* Web IDL AST interface
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
+#ifndef genjsbind_webidl_ast_h
+#define genjsbind_webidl_ast_h
+
enum webidl_node_type {
WEBIDL_NODE_TYPE_ROOT,
WEBIDL_NODE_TYPE_INTERFACE,
@@ -28,3 +39,5 @@ extern struct webidl_node *webidl_root;
int webidl_parsefile(char *filename);
struct webidl_node *webidl_new_node(enum webidl_node_type type);
+
+#endif
diff --git a/src/webidl-lexer.l b/src/webidl-lexer.l
index d240edc..5c8234c 100644
--- a/src/webidl-lexer.l
+++ b/src/webidl-lexer.l
@@ -1,7 +1,13 @@
%{
-/*
- * This is a unicode capable lexer for web IDL derived from:
+/* This is a unicode tolerant lexer for web IDL
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * Derived from:
*
* W3C WEB IDL - http://www.w3.org/TR/WebIDL/ (especially the grammar
* in apendix A)
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index 1a40e41..ef119c9 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -1,11 +1,16 @@
-/*
- * 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/
+%{
+
+/* This is a bison parser for Web IDL
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
*
+ * Derived from the the grammar in apendix A of W3C WEB IDL
+ * http://www.w3.org/TR/WebIDL/
*/
-%{
-
#include <stdio.h>
#include <string.h>
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/7ba968e4c33d3a0...
commit 7ba968e4c33d3a05ff9b23b8e593b400e34a4cad
Author: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
Commit: Vincent Sanders <vincent.sanders(a)collabora.co.uk>
fixup error reporting to give linenumber
diff --git a/src/genjsbind-lexer.l b/src/genjsbind-lexer.l
index 8bfa391..1406872 100644
--- a/src/genjsbind-lexer.l
+++ b/src/genjsbind-lexer.l
@@ -1,33 +1,47 @@
+%{
+
/*
* binding generator lexer
*/
-/* lexer options */
-%option never-interactive
-%option bison-bridge
-%option nodefault
-%option warn
-%option prefix="genjsbind_"
-%option nounput
-
-/* header block */
-%{
-
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "genjsbind-parser.h"
+#define YY_USER_ACTION yylloc->first_line = yylloc->last_line; \
+ yylloc->first_column = yylloc->last_column + 1; \
+ yylloc->last_column += yyleng;
+
%}
- /* other Unicode “space separator” */
+/* lexer options */
+%option never-interactive
+%option yylineno
+%option bison-bridge
+%option bison-locations
+%option nodefault
+%option warn
+%option prefix="genjsbind_"
+%option nounput
+%option noinput
+
+/* 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})
+/* Line separator \u2028 */
+LS (\xe2\x80\xa8)
+
+/* paragraph separator \u2029 */
+PS (\xe2\x80\xa9)
+
+whitespace ([ \t\v\f]|{NBSP}|{USP})
+
+lineend ([\n\r]|{LS}|{PS})
multicomment \/\*(([^*])|(\*[^/]))*\*\/
@@ -45,7 +59,13 @@ cblockclose \]\]\]
%%
-{whitespace} /* nothing */
+{whitespace} ++yylloc->last_column;/* nothing */
+
+{lineend} if (yytext[0] != '\r') {
+ /* update position counts */
+ ++yylloc->last_line;
+ yylloc->last_column = 0;
+ }
/* terminals */
@@ -75,7 +95,7 @@ node return TOK_NODE;
return TOK_IDENTIFIER;
}
-\"{quotedstring}*\" yylval->text = strndup(yytext + 1,strlen(yytext+1) - 1 ); return TOK_STRING_LITERAL;
+\"{quotedstring}*\" yylval->text = strndup(yytext + 1, yyleng - 2 ); return TOK_STRING_LITERAL;
{multicomment} /* nothing */
diff --git a/src/genjsbind-parser.y b/src/genjsbind-parser.y
index c3122ea..1a342ae 100644
--- a/src/genjsbind-parser.y
+++ b/src/genjsbind-parser.y
@@ -1,10 +1,9 @@
+%{
/*
* This is a bison parser for genbind
*
*/
-%{
-
#include <stdio.h>
#include <string.h>
@@ -13,9 +12,11 @@
#include "webidl-ast.h"
#include "jsapi-binding.h"
+char *errtxt;
+
static void genjsbind_error(const char *str)
{
- fprintf(stderr,"error: %s\n",str);
+ errtxt = strdup(str);
}
@@ -24,11 +25,11 @@ int genjsbind_wrap()
return 1;
}
-
-
%}
+%locations
%define api.pure
+%error-verbose
%union
{
@@ -55,8 +56,17 @@ int genjsbind_wrap()
/* [1] start with Statements */
Statements
- : Statement
- | Statements Statement
+ :
+ Statement
+ |
+ Statements Statement
+ |
+ error ';'
+ {
+ fprintf(stderr, "%d: %s\n", yylloc.first_line, errtxt);
+ free(errtxt);
+ YYABORT ;
+ }
;
Statement
diff --git a/src/webidl-lexer.l b/src/webidl-lexer.l
index 0a0a5df..d240edc 100644
--- a/src/webidl-lexer.l
+++ b/src/webidl-lexer.l
@@ -1,5 +1,7 @@
+%{
+
/*
- * This is a unicode capable lexer for web IDL mostly derived from:
+ * This is a unicode capable lexer for web IDL derived from:
*
* W3C WEB IDL - http://www.w3.org/TR/WebIDL/ (especially the grammar
* in apendix A)
@@ -9,19 +11,6 @@
* section 7.2 for unicode value handling)
*/
-/* lexer options */
-%option never-interactive
-%option yylineno
-%option bison-bridge
-%option bison-locations
-%option nodefault
-%option warn
-%option prefix="webidl_"
-%option nounput
-
-/* header block */
-%{
-
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
@@ -34,6 +23,16 @@
%}
+
+/* lexer options */
+%option never-interactive
+%option yylineno
+%option bison-bridge
+%option bison-locations
+%option warn
+%option prefix="webidl_"
+%option nounput
+
/* regular definitions */
/* ecmascript section 7.2 defines whitespace http://ecma-international.org/ecma-262/5.1/#sec-7.2
@@ -100,7 +99,7 @@ poundsign ^{whitespace}*#
{whitespace} ++yylloc->last_column; /* skip whitespace */
-{lineend} if (yytext[0] == '\n') {
+{lineend} if (yytext[0] != '\r') {
/* update position counts */
++yylloc->last_line;
yylloc->last_column = 0;
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index c4e25f1..1a40e41 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -14,11 +14,11 @@
#include "webidl-parser.h"
#include "webidl-lexer.h"
-
+char *errtxt;
static void webidl_error(const char *str)
{
- fprintf(stderr,"error: %s\n",str);
+ errtxt = strdup(str);
}
int webidl_wrap()
@@ -26,12 +26,11 @@ int webidl_wrap()
return 1;
}
-
-
%}
%locations
%define api.pure
+%error-verbose
/* the w3c grammar results in 10 shift/reduce, 2 reduce/reduce conflicts
* The reduce/reduce error are both the result of empty sequences
@@ -118,6 +117,13 @@ Definitions:
/* empty */
|
ExtendedAttributeList Definition Definitions
+ |
+ error ';'
+ {
+ fprintf(stderr, "%d: %s\n", yylloc.first_line, errtxt);
+ free(errtxt);
+ YYABORT ;
+ }
;
/* [2] */
-----------------------------------------------------------------------
Summary of changes:
COPYING | 19 ++++++++++
src/{jsapi-binding.c => genjsbind-ast.c} | 13 ++++++-
src/genjsbind-ast.h | 18 +++++++++
src/genjsbind-lexer.l | 58 +++++++++++++++++++++---------
src/genjsbind-parser.y | 33 ++++++++++++-----
src/genjsbind.c | 10 +++++-
src/jsapi-binding.h | 5 ---
src/options.h | 12 ++++++
src/webidl-ast.c | 8 ++++
src/webidl-ast.h | 13 +++++++
src/webidl-lexer.l | 37 +++++++++++--------
src/webidl-parser.y | 29 ++++++++++-----
12 files changed, 196 insertions(+), 59 deletions(-)
create mode 100644 COPYING
rename src/{jsapi-binding.c => genjsbind-ast.c} (87%)
create mode 100644 src/genjsbind-ast.h
delete mode 100644 src/jsapi-binding.h
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..59700b0
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,19 @@
+Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+ * The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/src/jsapi-binding.c b/src/genjsbind-ast.c
similarity index 87%
rename from src/jsapi-binding.c
rename to src/genjsbind-ast.c
index 9f1bc7e..ccadc7f 100644
--- a/src/jsapi-binding.c
+++ b/src/genjsbind-ast.c
@@ -1,10 +1,21 @@
+/* binding generator AST implementation for parser
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
+/** @todo this currently stuffs everything in one global tree, not very nice
+ */
+
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
-#include "jsapi-binding.h"
+#include "genjsbind-ast.h"
#include "webidl-ast.h"
#include "options.h"
diff --git a/src/genjsbind-ast.h b/src/genjsbind-ast.h
new file mode 100644
index 0000000..d94eda6
--- /dev/null
+++ b/src/genjsbind-ast.h
@@ -0,0 +1,18 @@
+/* binding file AST interface
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
+#ifndef genjsbind_genjsbind_ast_h
+#define genjsbind_genjsbind_ast_h
+
+int genjsbind_parsefile(char *infilename);
+int genjsbind_output(char *outfilename);
+int genjsbind_header_comment(char *);
+int genjsbind_interface(char *);
+int genjsbind_preamble(char *ccode);
+
+#endif
diff --git a/src/genjsbind-lexer.l b/src/genjsbind-lexer.l
index 8bfa391..5044c04 100644
--- a/src/genjsbind-lexer.l
+++ b/src/genjsbind-lexer.l
@@ -1,33 +1,51 @@
-/*
- * binding generator lexer
- */
-
-/* lexer options */
-%option never-interactive
-%option bison-bridge
-%option nodefault
-%option warn
-%option prefix="genjsbind_"
-%option nounput
-
-/* header block */
%{
+/* lexer for the binding generation config file
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "genjsbind-parser.h"
+#define YY_USER_ACTION yylloc->first_line = yylloc->last_line; \
+ yylloc->first_column = yylloc->last_column + 1; \
+ yylloc->last_column += yyleng;
+
%}
- /* other Unicode “space separator” */
+/* lexer options */
+%option never-interactive
+%option yylineno
+%option bison-bridge
+%option bison-locations
+%option nodefault
+%option warn
+%option prefix="genjsbind_"
+%option nounput
+%option noinput
+
+/* 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})
+/* Line separator \u2028 */
+LS (\xe2\x80\xa8)
+
+/* paragraph separator \u2029 */
+PS (\xe2\x80\xa9)
+
+whitespace ([ \t\v\f]|{NBSP}|{USP})
+
+lineend ([\n\r]|{LS}|{PS})
multicomment \/\*(([^*])|(\*[^/]))*\*\/
@@ -45,7 +63,13 @@ cblockclose \]\]\]
%%
-{whitespace} /* nothing */
+{whitespace} ++yylloc->last_column;/* nothing */
+
+{lineend} if (yytext[0] != '\r') {
+ /* update position counts */
+ ++yylloc->last_line;
+ yylloc->last_column = 0;
+ }
/* terminals */
@@ -75,7 +99,7 @@ node return TOK_NODE;
return TOK_IDENTIFIER;
}
-\"{quotedstring}*\" yylval->text = strndup(yytext + 1,strlen(yytext+1) - 1 ); return TOK_STRING_LITERAL;
+\"{quotedstring}*\" yylval->text = strndup(yytext + 1, yyleng - 2 ); return TOK_STRING_LITERAL;
{multicomment} /* nothing */
diff --git a/src/genjsbind-parser.y b/src/genjsbind-parser.y
index c3122ea..9ed4f21 100644
--- a/src/genjsbind-parser.y
+++ b/src/genjsbind-parser.y
@@ -1,21 +1,25 @@
-/*
- * This is a bison parser for genbind
+%{
+/* parser for the binding generation config file
*
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
*/
-%{
-
#include <stdio.h>
#include <string.h>
#include "genjsbind-parser.h"
#include "genjsbind-lexer.h"
#include "webidl-ast.h"
-#include "jsapi-binding.h"
+#include "genjsbind-ast.h"
+
+char *errtxt;
static void genjsbind_error(const char *str)
{
- fprintf(stderr,"error: %s\n",str);
+ errtxt = strdup(str);
}
@@ -24,11 +28,11 @@ int genjsbind_wrap()
return 1;
}
-
-
%}
+%locations
%define api.pure
+%error-verbose
%union
{
@@ -55,8 +59,17 @@ int genjsbind_wrap()
/* [1] start with Statements */
Statements
- : Statement
- | Statements Statement
+ :
+ Statement
+ |
+ Statements Statement
+ |
+ error ';'
+ {
+ fprintf(stderr, "%d: %s\n", yylloc.first_line, errtxt);
+ free(errtxt);
+ YYABORT ;
+ }
;
Statement
diff --git a/src/genjsbind.c b/src/genjsbind.c
index 6bc84b3..dd5b242 100644
--- a/src/genjsbind.c
+++ b/src/genjsbind.c
@@ -1,3 +1,11 @@
+/* binding generator main and command line parsing
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
@@ -6,7 +14,7 @@
#include <getopt.h>
#include <errno.h>
-#include "jsapi-binding.h"
+#include "genjsbind-ast.h"
#include "options.h"
struct options *options;
diff --git a/src/jsapi-binding.h b/src/jsapi-binding.h
deleted file mode 100644
index 33f9776..0000000
--- a/src/jsapi-binding.h
+++ /dev/null
@@ -1,5 +0,0 @@
-int genjsbind_parsefile(char *infilename);
-int genjsbind_output(char *outfilename);
-int genjsbind_header_comment(char *);
-int genjsbind_interface(char *);
-int genjsbind_preamble(char *ccode);
diff --git a/src/options.h b/src/options.h
index 47f3c11..041f4cd 100644
--- a/src/options.h
+++ b/src/options.h
@@ -1,3 +1,14 @@
+/* binding generator options
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
+#ifndef genjsbind_options_h
+#define genjsbind_options_h
+
struct options {
char *outfilename;
char *infilename;
@@ -8,3 +19,4 @@ struct options {
extern struct options *options;
+#endif
diff --git a/src/webidl-ast.c b/src/webidl-ast.c
index 95b271d..1eddd68 100644
--- a/src/webidl-ast.c
+++ b/src/webidl-ast.c
@@ -1,3 +1,11 @@
+/* AST generator for the WEB IDL parser
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/src/webidl-ast.h b/src/webidl-ast.h
index f49268a..5dfd2a8 100644
--- a/src/webidl-ast.h
+++ b/src/webidl-ast.h
@@ -1,3 +1,14 @@
+/* Web IDL AST interface
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ */
+
+#ifndef genjsbind_webidl_ast_h
+#define genjsbind_webidl_ast_h
+
enum webidl_node_type {
WEBIDL_NODE_TYPE_ROOT,
WEBIDL_NODE_TYPE_INTERFACE,
@@ -28,3 +39,5 @@ extern struct webidl_node *webidl_root;
int webidl_parsefile(char *filename);
struct webidl_node *webidl_new_node(enum webidl_node_type type);
+
+#endif
diff --git a/src/webidl-lexer.l b/src/webidl-lexer.l
index 0a0a5df..5c8234c 100644
--- a/src/webidl-lexer.l
+++ b/src/webidl-lexer.l
@@ -1,5 +1,13 @@
-/*
- * This is a unicode capable lexer for web IDL mostly derived from:
+%{
+
+/* This is a unicode tolerant lexer for web IDL
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * Derived from:
*
* W3C WEB IDL - http://www.w3.org/TR/WebIDL/ (especially the grammar
* in apendix A)
@@ -9,19 +17,6 @@
* section 7.2 for unicode value handling)
*/
-/* lexer options */
-%option never-interactive
-%option yylineno
-%option bison-bridge
-%option bison-locations
-%option nodefault
-%option warn
-%option prefix="webidl_"
-%option nounput
-
-/* header block */
-%{
-
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
@@ -34,6 +29,16 @@
%}
+
+/* lexer options */
+%option never-interactive
+%option yylineno
+%option bison-bridge
+%option bison-locations
+%option warn
+%option prefix="webidl_"
+%option nounput
+
/* regular definitions */
/* ecmascript section 7.2 defines whitespace http://ecma-international.org/ecma-262/5.1/#sec-7.2
@@ -100,7 +105,7 @@ poundsign ^{whitespace}*#
{whitespace} ++yylloc->last_column; /* skip whitespace */
-{lineend} if (yytext[0] == '\n') {
+{lineend} if (yytext[0] != '\r') {
/* update position counts */
++yylloc->last_line;
yylloc->last_column = 0;
diff --git a/src/webidl-parser.y b/src/webidl-parser.y
index c4e25f1..ef119c9 100644
--- a/src/webidl-parser.y
+++ b/src/webidl-parser.y
@@ -1,11 +1,16 @@
-/*
- * 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/
+%{
+
+/* This is a bison parser for Web IDL
+ *
+ * This file is part of nsgenjsbind.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2012 Vincent Sanders <vince(a)netsurf-browser.org>
*
+ * Derived from the the grammar in apendix A of W3C WEB IDL
+ * http://www.w3.org/TR/WebIDL/
*/
-%{
-
#include <stdio.h>
#include <string.h>
@@ -14,11 +19,11 @@
#include "webidl-parser.h"
#include "webidl-lexer.h"
-
+char *errtxt;
static void webidl_error(const char *str)
{
- fprintf(stderr,"error: %s\n",str);
+ errtxt = strdup(str);
}
int webidl_wrap()
@@ -26,12 +31,11 @@ int webidl_wrap()
return 1;
}
-
-
%}
%locations
%define api.pure
+%error-verbose
/* the w3c grammar results in 10 shift/reduce, 2 reduce/reduce conflicts
* The reduce/reduce error are both the result of empty sequences
@@ -118,6 +122,13 @@ Definitions:
/* empty */
|
ExtendedAttributeList Definition Definitions
+ |
+ error ';'
+ {
+ fprintf(stderr, "%d: %s\n", yylloc.first_line, errtxt);
+ free(errtxt);
+ YYABORT ;
+ }
;
/* [2] */
--
NetSurf Generator for JavaScript bindings
11 years, 2 months
nsgenjsbind: branch master updated. f60d94623e676bb80670b465b1bed7ad4559581d
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/nsgenjsbind.git/shortlog/f60d94623e676bb80...
...commit http://git.netsurf-browser.org/nsgenjsbind.git/commit/f60d94623e676bb8067...
...tree http://git.netsurf-browser.org/nsgenjsbind.git/tree/f60d94623e676bb80670b...
The branch, master has been updated
via f60d94623e676bb80670b465b1bed7ad4559581d (commit)
from 3db9b84cd1a23f4718260a6b2487dcedbb7fc526 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/nsgenjsbind.git/commitdiff/f60d94623e676bb...
commit f60d94623e676bb80670b465b1bed7ad4559581d
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
complete binding section parse
diff --git a/src/genjsbind-lexer.l b/src/genjsbind-lexer.l
index af49db9..8bfa391 100644
--- a/src/genjsbind-lexer.l
+++ b/src/genjsbind-lexer.l
@@ -63,7 +63,7 @@ type return TOK_TYPE;
extra return TOK_EXTRA;
-%token <text> TOK_IDENTIFIER
+node return TOK_NODE;
{cblockopen} BEGIN(cblock);
diff --git a/src/genjsbind-parser.y b/src/genjsbind-parser.y
index ce8a1fd..c3122ea 100644
--- a/src/genjsbind-parser.y
+++ b/src/genjsbind-parser.y
@@ -43,6 +43,7 @@ int genjsbind_wrap()
%token TOK_INTERFACE
%token TOK_TYPE
%token TOK_EXTRA
+%token TOK_NODE
%token <text> TOK_IDENTIFIER
@@ -101,7 +102,7 @@ HdrStrings
Preamble
:
- TOK_PREAMBLE CBlock
+ TOK_PREAMBLE CBlock ';'
;
CBlock
@@ -123,12 +124,39 @@ Binding
;
BindingArgs
-:
-;
+ :
+ BindingArg
+ |
+ BindingArgs BindingArg
+ ;
+
+BindingArg
+ :
+ Type
+ |
+ Extra
+ |
+ Interface
+ ;
+
+Type
+ :
+ TOK_TYPE TOK_IDENTIFIER '{' TypeArgs '}' ';'
+ ;
+
+TypeArgs
+ :
+ TOK_NODE TOK_IDENTIFIER ';'
+ ;
+
+Extra
+ :
+ TOK_EXTRA TOK_STRING_LITERAL ';'
+ ;
Interface
:
- TOK_INTERFACE TOK_STRING_LITERAL ';'
+ TOK_INTERFACE TOK_IDENTIFIER ';'
{
genjsbind_interface($2);
}
-----------------------------------------------------------------------
Summary of changes:
src/genjsbind-lexer.l | 2 +-
src/genjsbind-parser.y | 36 ++++++++++++++++++++++++++++++++----
2 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/src/genjsbind-lexer.l b/src/genjsbind-lexer.l
index af49db9..8bfa391 100644
--- a/src/genjsbind-lexer.l
+++ b/src/genjsbind-lexer.l
@@ -63,7 +63,7 @@ type return TOK_TYPE;
extra return TOK_EXTRA;
-%token <text> TOK_IDENTIFIER
+node return TOK_NODE;
{cblockopen} BEGIN(cblock);
diff --git a/src/genjsbind-parser.y b/src/genjsbind-parser.y
index ce8a1fd..c3122ea 100644
--- a/src/genjsbind-parser.y
+++ b/src/genjsbind-parser.y
@@ -43,6 +43,7 @@ int genjsbind_wrap()
%token TOK_INTERFACE
%token TOK_TYPE
%token TOK_EXTRA
+%token TOK_NODE
%token <text> TOK_IDENTIFIER
@@ -101,7 +102,7 @@ HdrStrings
Preamble
:
- TOK_PREAMBLE CBlock
+ TOK_PREAMBLE CBlock ';'
;
CBlock
@@ -123,12 +124,39 @@ Binding
;
BindingArgs
-:
-;
+ :
+ BindingArg
+ |
+ BindingArgs BindingArg
+ ;
+
+BindingArg
+ :
+ Type
+ |
+ Extra
+ |
+ Interface
+ ;
+
+Type
+ :
+ TOK_TYPE TOK_IDENTIFIER '{' TypeArgs '}' ';'
+ ;
+
+TypeArgs
+ :
+ TOK_NODE TOK_IDENTIFIER ';'
+ ;
+
+Extra
+ :
+ TOK_EXTRA TOK_STRING_LITERAL ';'
+ ;
Interface
:
- TOK_INTERFACE TOK_STRING_LITERAL ';'
+ TOK_INTERFACE TOK_IDENTIFIER ';'
{
genjsbind_interface($2);
}
--
NetSurf Generator for JavaScript bindings
11 years, 2 months