From: George Lebl Date: Tue, 25 Jan 2000 16:17:00 +0000 (-0800) Subject: Release 0.92.2 X-Git-Tag: v0.92.2 X-Git-Url: http://git.draconx.ca/gitweb/gob-dx.git/commitdiff_plain/e10d6e307623d0952f6e1f5d9fee8720ddab4808 Release 0.92.2 --- diff --git a/ChangeLog b/ChangeLog index 1348d62..f8eb15f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,43 @@ +Mon Jan 24 22:52:47 2000 George Lebl + + * Release 0.92.2 + +Mon Jan 24 22:23:47 2000 George Lebl + + * src/main.c: add a protecting define before the object typedef + + * doc/gob.1.in: add docs for the new stuff + +Sun Jan 23 16:19:54 2000 George Lebl + + * src/{lexer.l,parse.y,tree.[ch],main.c}: make more types of header + %{ %} blocks, "headertop" and "privateheader" and made short as + well as long names possible. + + * src/main.c: add an --no-extern-c option to not put entern "C" into + the output, which is now put in by default even if --for-cpp is + on so that it is possible to call those from C by default + +Thu Jan 20 01:50:45 2000 George Lebl + + * src/main.c: put the _real_ functions in our normal private + namespace of ___* to be more consistent. + +Mon Jan 10 00:16:43 2000 George Lebl + + * src/{main.[ch],util.[ch],checks.[ch]}: offload some functionality to + extra files + + * src/main.c: cleanup the generation routine by spliting it up into + more functions + + * src/{main.h,lexer.l,parse.y,out.c}: put some needed externs into the + main.h file and include that rather then doing it in the .c files + +Thu Jan 06 18:33:44 2000 George Lebl + + * src/main.c: use ___ for the signal marshalling typedefs as well + Thu Jan 06 17:32:46 2000 George Lebl * Release 0.92.1 diff --git a/NEWS b/NEWS index 52beb5c..dacb5f3 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +0.92.2 + * more header code sections + * some code restructuring + * always extern "C" the header (unless --no-extern-c is used) + * object typedef protecting define for avoiding circular includes + 0.92.1 * typesafe macros for argument setting/getting * generated code will take advantage of GNU C extentions if compiled diff --git a/TODO b/TODO index 7a7cce2..3b2a8e7 100644 --- a/TODO +++ b/TODO @@ -2,4 +2,10 @@ Somehow transfer comments from .gob to .h and .c files to make gtk-doc possible. Alternatively make gob act as gtk-doc, or generate a gtk-doc ready stub file. -Figure out how to work with the complex types on signal prototypes +.defs file generation + +signal RUN_ flags. Auto add GTK_RUN_ACTION for public signals, but add +a way to specify other flags + +a connect_full function for each signal with typesafe function pointer +argument and macros for the other (simpler) connect types. diff --git a/configure b/configure index 32150cf..b81bbf6 100755 --- a/configure +++ b/configure @@ -703,7 +703,7 @@ fi PACKAGE=gob -VERSION=0.92.1 +VERSION=0.92.2 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } diff --git a/configure.in b/configure.in index ea9f23f..c38fbb1 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.2) AC_INIT(src/tree.h) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(gob,0.92.1) +AM_INIT_AUTOMAKE(gob,0.92.2) if test -f ../NOINST_GOB ; then DOINSTGOB= diff --git a/doc/gob.1.in b/doc/gob.1.in index be027ac..40916fd 100644 --- a/doc/gob.1.in +++ b/doc/gob.1.in @@ -43,6 +43,9 @@ Exit with an error only on errors, not on warnings, this is the default. .B --for-cpp Generate C++ code. .TP +.B --no-extern-c +Never add the extern "C" to the header. +.TP .B --no-gnu Never generate any code with GNU C extensions. However all the GNU C extensions are always wrapped in #ifdef __GNUC__, so code using them compiles @@ -98,11 +101,25 @@ you should only edit the .gob file. .SH INCLUDING NORMAL C CODE IN THE OUTPUT FILES .PP To include some code directly in the output C file begin with '%{' -on an empty line and end the code with a '%}' on an empty line. To -put the code in the output header file, start the code with a '%h{'. -For example: +on an empty line and end the code with a '%}' on an empty line. These +sections will appear in the output files in the order they are given. +There are several other \fIsections\fR to which you can put code. You can +put it in the 'header' section (which can be abbreviated 'h') and it will +go into the public header file. You can also put it in the 'privateheader' +section (abbreviated 'ph') which will make the code go into the private +header file. Sometimes you want some code (other includes) to appear before +the extern "C" and the protecting define. To do this you can put them +into the 'headertop' (or 'ht') section. For example: .nf + %headertop{ + /* this will be on top of the public header */ + %} + + %privateheader{ + /* this will go into the private header file */ + %} + %h{ /* will be included in the header */ void somefunc(int i); @@ -531,6 +548,31 @@ argument lists and virtual and signal method names as it might confuse the PARENT_HANDLER macro. In fact avoiding all names with three underscores is the best policy when working with gob. +.SH DEALING WITH CIRCULAR HEADERS +.PP +Sometimes you may need to use an object of type MyObjectA in the MyObjectB +class and vice versa. Obviously you can't include headers for both. So you +need to just declare the typedef in the header of A for B, and the other way +around as well. The headers generated since v0.92.2 include a protecting +define before it declares the typedef. This define is the +__TYPEDEF___. So inside my-object-a.h there will be +this: +.nf + + #ifndef __TYPEDEF_MY_OBJECT_A__ + #define __TYPEDEF_MY_OBJECT_A__ + typedef struct _MyObjectA MyObjectA; + #endif + +.fi +Now instead of including my-object-a.h in the header section of +my-object-b.gob, just copy the above code there and you're set for using +MyObjectA as a type in the method parameters and public types. +.PP +Another way to get out of this problem is if you can use those types only +in the private members, in which case they won't be in the generated public +header. + .SH BUGS .PP Also the lexer does not actually parse the C code, so I'm sure that some corner diff --git a/gob.spec b/gob.spec index 56b168b..d1a0ba9 100644 --- a/gob.spec +++ b/gob.spec @@ -1,4 +1,4 @@ -%define ver 0.92.1 +%define ver 0.92.2 %define rel 1 %define prefix /usr diff --git a/src/Makefile.am b/src/Makefile.am index 7b43ada..504fcf0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,10 @@ gob_SOURCES = \ tree.h \ out.c \ out.h \ + util.c \ + util.h \ + checks.c \ + checks.h \ parse.y \ lexer.l diff --git a/src/Makefile.in b/src/Makefile.in index 071a0f2..6dddce3 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -88,7 +88,7 @@ bin_PROGRAMS = @DOINSTGOB@ noinst_PROGRAMS = @NOINSTGOB@ EXTRA_PROGRAMS = gob -gob_SOURCES = main.c main.h tree.c tree.h out.c out.h parse.y lexer.l +gob_SOURCES = main.c main.h tree.c tree.h out.c out.h util.c util.h checks.c checks.h parse.y lexer.l gob_LDADD = -lm $(GLIB_LIBS) @LEXLIB@ @@ -110,7 +110,7 @@ PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) DEFS = @DEFS@ -I. -I$(srcdir) -I.. LIBS = @LIBS@ -gob_OBJECTS = main.o tree.o out.o parse.o lexer.o +gob_OBJECTS = main.o tree.o out.o util.o checks.o parse.o lexer.o gob_DEPENDENCIES = gob_LDFLAGS = LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ @@ -318,11 +318,13 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done -lexer.o: lexer.c ../config.h parse.h main.h -main.o: main.c ../config.h tree.h parse.h out.h main.h -out.o: out.c out.h -parse.o: parse.c ../config.h tree.h main.h +checks.o: checks.c ../config.h tree.h main.h util.h checks.h +lexer.o: lexer.c ../config.h parse.h main.h util.h +main.o: main.c ../config.h tree.h parse.h out.h util.h checks.h main.h +out.o: out.c main.h out.h +parse.o: parse.c ../config.h tree.h main.h util.h tree.o: tree.c ../config.h tree.h +util.o: util.c ../config.h main.h util.h info-am: info: info-recursive diff --git a/src/checks.c b/src/checks.c new file mode 100644 index 0000000..73b10d8 --- /dev/null +++ b/src/checks.c @@ -0,0 +1,398 @@ +/* GOB C Preprocessor + * Copyright (C) 1999-2000 the Free Software Foundation. + * + * Author: George Lebl + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + +#include "config.h" +#include +#include +#include + +#include "tree.h" +#include "main.h" +#include "util.h" + +#include "checks.h" + +void +check_duplicate(Class *c, Node *node, char *id, int line_no) +{ + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + char *nid; + int nline_no; + char *s; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + nid = m->id; + nline_no = m->line_no; + } else if(n->type == VARIABLE_NODE) { + Variable *v = (Variable *)n; + nid = v->id; + nline_no = v->line_no; + } else + continue; + if(n==node || + line_no>=nline_no || + strcmp(nid,id)!=0 || + n->type != node->type) + continue; + s = g_strdup_printf("symbol '%s' redefined, " + "first defined on line %d", + id,line_no); + print_error(FALSE,s,nline_no); + } +} + +void +check_duplicate_symbols(Class *c) +{ + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + check_duplicate(c,n,m->id,m->line_no); + } else if(n->type == VARIABLE_NODE) { + Variable *v = (Variable *)n; + check_duplicate(c,n,v->id,v->line_no); + } + } +} + +void +check_bad_symbols(Class *c) +{ + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + if((m->method == SIGNAL_LAST_METHOD || + m->method == SIGNAL_FIRST_METHOD || + m->method == VIRTUAL_METHOD) && + strcmp(m->id,"__parent__")==0) { + char *s; + s = g_strdup_printf("'%s' not allowed as an " + "identifier of signal " + "or virtual methods", + m->id); + print_error(FALSE,s,m->line_no); + g_free(s); + } + if(m->method != INIT_METHOD && + m->method != CLASS_INIT_METHOD && + (strcmp(m->id,"init")==0 || + strcmp(m->id,"class_init")==0)) { + print_error(FALSE,"init, or class_init not " + "allowed as an " + "identifier of non-" + "constructor methods",m->line_no); + } + } else if(n->type == VARIABLE_NODE) { + Variable *v = (Variable *)n; + if(strcmp(v->id,"_priv")==0 || + strcmp(v->id,"__parent__")==0) { + char *s; + s = g_strdup_printf("'%s' not allowed as a " + "data member name",v->id); + print_error(FALSE,s,v->line_no); + g_free(s); + } + } + } +} + + +void +check_duplicate_named(Class *c,Node *node,char *id, int line_no) +{ + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + char *nid; + int nline_no; + char *s; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + if(m->method == SIGNAL_LAST_METHOD || + m->method == SIGNAL_FIRST_METHOD) { + nid = m->id; + nline_no = m->line_no; + } else + continue; + } else if(n->type == ARGUMENT_NODE) { + Argument *a = (Argument *)n; + nid = a->name; + nline_no = a->line_no; + } else + continue; + if(n==node || + line_no>=nline_no || + strcmp(nid,id)!=0) + continue; + s = g_strdup_printf("named symbol (argument or signal) '%s' " + "redefined, first defined on line %d", + id,line_no); + print_error(FALSE,s,nline_no); + } +} + +void +check_duplicate_signals_args(Class *c) +{ + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + if(m->method == SIGNAL_LAST_METHOD || + m->method == SIGNAL_FIRST_METHOD) + check_duplicate_named(c,n,m->id,m->line_no); + } else if(n->type == ARGUMENT_NODE) { + Argument *a = (Argument *)n; + check_duplicate_named(c,n,a->name,a->line_no); + } + } +} + +void +check_public_new(Class *c) +{ + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + if((strcmp(m->id,"new")==0) && + (m->method != REGULAR_METHOD || + m->scope != PUBLIC_SCOPE)) + print_error(TRUE, + "'new' should be a regular\n" + "public method", + m->line_no); + } + } +} + +void +check_vararg(Class *c) +{ + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + if(!m->vararg) + continue; + if(m->method == OVERRIDE_METHOD || + m->method == SIGNAL_LAST_METHOD || + m->method == SIGNAL_FIRST_METHOD || + m->method == VIRTUAL_METHOD) { + print_error(FALSE, + "signals, overrides and virtuals, " + "can't have variable argument " + "lists", + m->line_no); + } + } + } +} + +void +check_firstarg(Class *c) +{ + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + if(m->args) + continue; + if(m->method == OVERRIDE_METHOD || + m->method == SIGNAL_LAST_METHOD || + m->method == SIGNAL_FIRST_METHOD || + m->method == VIRTUAL_METHOD) { + print_error(FALSE, + "signals, overrides and virtuals, " + "can't have no arguments", + m->line_no); + } + } + } +} + +void +check_nonvoidempty(Class *c) +{ + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + if(m->method != REGULAR_METHOD) + continue; + if(!(strcmp(m->mtype->name,"void")==0 && + m->mtype->stars == 0) && + !m->cbuf) { + print_error(TRUE, + "non-void empty method found, " + "regular non-void function should " + "not be empty.", + m->line_no); + /* add a body here, so that the user will also + get a warning from gcc, and so that it will + at least point him to the prototype of the + function in the .gob file */ + m->cbuf = g_strdup("/*empty*/"); + m->ccode_line = m->line_no; + } + } + } +} + +void +check_signal_args(Class *c) +{ + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + GList *l; + if(m->method != SIGNAL_LAST_METHOD && + m->method != SIGNAL_FIRST_METHOD) + continue; + + for(l=m->gtktypes;l;l=l->next) { + char *s; + if(get_cast(l->data,FALSE)) + continue; + s = g_strdup_printf("Unknown GTK+ type '%s' " + "among signal types", + (char *)l->data); + print_error(FALSE, s, m->line_no); + g_free(s); + } + } + } +} + +void +check_argument_types(Class *c) +{ + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == ARGUMENT_NODE) { + Argument *a = (Argument *)n; + char *s; + if(get_cast(a->gtktype,FALSE)) + continue; + s = g_strdup_printf("Unknown GTK+ type '%s' " + "as argument type", + a->gtktype); + /* this could perhaps be a warning, but + can there really be a type beyond the + fundementals? */ + print_error(FALSE, s, a->line_no); + g_free(s); + } + } +} + +int +count_signals(Class *c) +{ + int num = 0; + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + if(m->method == SIGNAL_LAST_METHOD || + m->method == SIGNAL_FIRST_METHOD) + num++; + } + } + return num; +} + +int +count_arguments(Class *c) +{ + int num = 0; + GList *li; + + for(li=c->nodes;li;li=g_list_next(li)) { + Node *n = li->data; + if(n->type == ARGUMENT_NODE) + num ++; + } + return num; +} + +int +count_overrides(Class *c) +{ + int num = 0; + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + if(m->method == OVERRIDE_METHOD) + num++; + } + } + return num; +} + +int +count_privates(Class *c) +{ + int num = 0; + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == VARIABLE_NODE) { + Variable *v = (Variable *)n; + if(v->scope == PRIVATE_SCOPE) + num++; + } + } + return num; +} + +int +count_protecteds(Class *c) +{ + int num = 0; + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + if(m->scope == PROTECTED_SCOPE) + num++; + } + } + return num; +} diff --git a/src/checks.h b/src/checks.h new file mode 100644 index 0000000..53d19d5 --- /dev/null +++ b/src/checks.h @@ -0,0 +1,43 @@ +/* GOB C Preprocessor + * Copyright (C) 1999-2000 the Free Software Foundation. + * + * Author: George Lebl + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + +#ifndef _CHECKS_H_ +#define _CHECKS_H_ + +void check_duplicate(Class *c, Node *node, char *id, int line_no); +void check_duplicate_symbols(Class *c); +void check_bad_symbols(Class *c); +void check_duplicate_named(Class *c,Node *node,char *id, int line_no); +void check_duplicate_signals_args(Class *c); +void check_public_new(Class *c); +void check_vararg(Class *c); +void check_firstarg(Class *c); +void check_nonvoidempty(Class *c); +void check_signal_args(Class *c); +void check_argument_types(Class *c); + +int count_signals(Class *c); +int count_arguments(Class *c); +int count_overrides(Class *c); +int count_privates(Class *c); +int count_protecteds(Class *c); + +#endif diff --git a/src/lexer.c b/src/lexer.c index eecf02b..d9990cd 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -284,52 +284,52 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); *yy_cp = '\0'; \ yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 70 -#define YY_END_OF_BUFFER 71 -static yyconst short int yy_acclist[357] = +#define YY_NUM_RULES 72 +#define YY_END_OF_BUFFER 73 +static yyconst short int yy_acclist[359] = { 0, - 71, 68, 70, 67, 68, 70, 1, 69, 70, 68, - 69, 70, 68, 70, 68, 70, 68, 70, 67, 68, - 70, 68, 70, 68, 70, 13, 68, 70, 1, 14, - 69, 70, 13, 68, 69, 70, 13, 68, 70, 13, - 68, 70, 32, 68, 70, 1, 33, 69, 70, 32, - 68, 69, 70, 25, 32, 68, 70, 32, 68, 70, - 32, 68, 70, 32, 68, 70, 32, 68, 70, 30, - 32, 68, 70, 31, 32, 68, 70, 32, 68, 70, - 32, 68, 70, 28, 68, 70, 1, 29, 69, 70, - 28, 68, 69, 70, 27, 28, 68, 70, 28, 68, - - 70, 28, 68, 70, 68, 70, 68, 70, 62, 68, - 70, 62, 68, 70, 62, 68, 70, 62, 68, 70, - 62, 68, 70, 64, 68, 70, 68, 70, 68, 70, - 60, 68, 70, 60, 68, 70, 68, 70, 62, 68, - 70, 62, 68, 70, 62, 68, 70, 62, 68, 70, - 62, 68, 70, 62, 68, 70, 62, 68, 70, 62, - 68, 70, 62, 68, 70, 62, 68, 70, 62, 68, - 70, 62, 68, 70, 65, 68, 70, 66, 68, 70, - 8, 16, 12, 9, 24, 17, 26, 10, 62, 61, - 62, 62, 62, 62, 60, 11, 60, 60, 63, 62, - - 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 62, 62, 3, 15, 22, - 18, 20, 5, 6, 61, 62, 62, 62, 62, 51, - 60, 7, 60, 60, 62, 62, 62, 62, 62, 62, - 46, 62, 62, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 23, 19, 21, 62, 62, - 37, 62, 36, 62, 62, 49, 62, 62, 62, 41, - 62, 62, 44, 62, 62, 62, 62, 62, 62, 62, - 62, 62, 62, 62, 62, 38, 62, 34, 62, 62, - 50, 62, 62, 47, 62, 62, 62, 62, 62, 62, - - 45, 62, 62, 62, 62, 40, 62, 62, 62, 62, - 62, 48, 62, 62, 62, 62, 62, 52, 62, 57, - 62, 42, 62, 39, 62, 62, 62, 62, 62, 59, - 62, 62, 53, 62, 62, 62, 56, 62, 62, 55, - 62, 58, 62, 62, 43, 62, 62, 54, 62, 62, - 4, 62, 2, 2, 62, 35 + 73, 70, 72, 69, 70, 72, 1, 71, 72, 70, + 71, 72, 70, 72, 70, 72, 70, 72, 69, 70, + 72, 70, 72, 70, 72, 13, 70, 72, 1, 14, + 71, 72, 13, 70, 71, 72, 13, 70, 72, 13, + 70, 72, 34, 70, 72, 1, 35, 71, 72, 34, + 70, 71, 72, 27, 34, 70, 72, 34, 70, 72, + 34, 70, 72, 34, 70, 72, 34, 70, 72, 32, + 34, 70, 72, 33, 34, 70, 72, 34, 70, 72, + 34, 70, 72, 30, 70, 72, 1, 31, 71, 72, + 30, 70, 71, 72, 29, 30, 70, 72, 30, 70, + + 72, 30, 70, 72, 70, 72, 70, 72, 64, 70, + 72, 64, 70, 72, 64, 70, 72, 64, 70, 72, + 64, 70, 72, 66, 70, 72, 70, 72, 70, 72, + 62, 70, 72, 62, 70, 72, 70, 72, 64, 70, + 72, 64, 70, 72, 64, 70, 72, 64, 70, 72, + 64, 70, 72, 64, 70, 72, 64, 70, 72, 64, + 70, 72, 64, 70, 72, 64, 70, 72, 64, 70, + 72, 64, 70, 72, 67, 70, 72, 68, 70, 72, + 8, 18, 12, 9, 26, 19, 28, 10, 64, 63, + 64, 64, 64, 64, 62, 11, 62, 62, 65, 64, + + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 3, 17, 24, + 20, 22, 5, 6, 63, 64, 64, 64, 64, 53, + 62, 7, 62, 62, 64, 64, 64, 64, 64, 64, + 48, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 15, 16, 25, 21, 23, + 64, 64, 39, 64, 38, 64, 64, 51, 64, 64, + 64, 43, 64, 64, 46, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 40, 64, 36, + 64, 64, 52, 64, 64, 49, 64, 64, 64, 64, + + 64, 64, 47, 64, 64, 64, 64, 42, 64, 64, + 64, 64, 64, 50, 64, 64, 64, 64, 64, 54, + 64, 59, 64, 44, 64, 41, 64, 64, 64, 64, + 64, 61, 64, 64, 55, 64, 64, 64, 58, 64, + 64, 57, 64, 60, 64, 64, 45, 64, 64, 56, + 64, 64, 4, 64, 2, 2, 64, 37 } ; -static yyconst short int yy_accept[292] = +static yyconst short int yy_accept[315] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 7, 10, 13, 15, 17, @@ -339,31 +339,33 @@ static yyconst short int yy_accept[292] = 115, 118, 121, 124, 127, 129, 131, 134, 137, 139, 142, 145, 148, 151, 154, 157, 160, 163, 166, 169, 172, 175, 178, 181, 182, 182, 182, 182, 182, 182, - 182, 183, 183, 184, 184, 184, 184, 184, 185, 185, - 186, 186, 186, 187, 188, 189, 189, 189, 190, 191, - - 192, 193, 194, 195, 195, 196, 197, 197, 197, 198, - 198, 198, 199, 199, 200, 201, 202, 203, 204, 205, - 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, - 216, 217, 218, 218, 219, 219, 219, 220, 220, 221, - 221, 221, 221, 222, 223, 223, 224, 224, 224, 225, - 225, 226, 227, 228, 229, 230, 231, 232, 232, 233, - 234, 235, 235, 236, 237, 238, 239, 240, 241, 243, - 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, - 254, 255, 256, 256, 256, 256, 257, 258, 259, 259, - 260, 261, 263, 265, 266, 268, 269, 270, 272, 273, - - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 288, 288, 289, 289, 289, 290, 291, 293, - 294, 296, 297, 298, 299, 300, 301, 303, 304, 305, - 306, 308, 309, 310, 310, 310, 310, 311, 312, 314, - 315, 316, 317, 318, 320, 322, 324, 326, 327, 328, - 328, 328, 328, 329, 330, 332, 333, 335, 336, 337, - 339, 339, 339, 339, 340, 342, 344, 345, 347, 347, - 347, 347, 348, 350, 350, 350, 350, 351, 351, 351, - 351, 352, 353, 354, 354, 356, 356, 356, 356, 357, - 357 - + 182, 182, 183, 183, 184, 184, 184, 184, 184, 185, + 185, 186, 186, 186, 187, 188, 189, 189, 189, 190, + + 191, 192, 193, 194, 195, 195, 196, 197, 197, 197, + 198, 198, 198, 199, 199, 200, 201, 202, 203, 204, + 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, + 215, 216, 217, 218, 218, 219, 219, 219, 219, 219, + 220, 220, 220, 220, 221, 221, 221, 221, 222, 223, + 223, 224, 224, 224, 225, 225, 226, 227, 228, 229, + 230, 231, 232, 232, 233, 234, 235, 235, 236, 237, + 238, 239, 240, 241, 243, 244, 245, 246, 247, 248, + 249, 250, 251, 252, 253, 254, 255, 256, 256, 256, + 256, 257, 258, 258, 258, 259, 260, 261, 261, 262, + + 263, 265, 267, 268, 270, 271, 272, 274, 275, 277, + 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, + 288, 290, 290, 291, 291, 291, 291, 291, 292, 293, + 295, 296, 298, 299, 300, 301, 302, 303, 305, 306, + 307, 308, 310, 311, 312, 312, 312, 312, 312, 312, + 313, 314, 316, 317, 318, 319, 320, 322, 324, 326, + 328, 329, 330, 330, 330, 330, 330, 330, 331, 332, + 334, 335, 337, 338, 339, 341, 341, 341, 341, 341, + 341, 342, 344, 346, 347, 349, 349, 349, 349, 349, + 349, 350, 352, 352, 352, 352, 352, 353, 353, 353, + + 353, 353, 354, 355, 356, 356, 356, 358, 358, 358, + 358, 358, 359, 359 } ; static yyconst int yy_ec[256] = @@ -408,236 +410,248 @@ static yyconst int yy_meta[56] = 6, 6, 6, 1, 1 } ; -static yyconst short int yy_base[307] = +static yyconst short int yy_base[330] = { 0, 0, 3, 9, 12, 49, 102, 19, 36, 157, 0, - 203, 0, 624, 625, 625, 625, 625, 8, 597, 580, - 7, 2, 584, 625, 625, 625, 609, 593, 625, 625, - 625, 625, 15, 18, 592, 0, 625, 625, 6, 562, - 625, 625, 625, 625, 590, 0, 21, 0, 600, 33, - 16, 18, 28, 625, 63, 53, 69, 74, 79, 30, - 56, 50, 70, 21, 74, 57, 79, 84, 75, 82, - 97, 625, 625, 625, 611, 585, 579, 98, 574, 556, - 625, 562, 625, 600, 213, 599, 598, 625, 602, 625, - 218, 560, 625, 625, 625, 600, 587, 586, 585, 102, - - 104, 105, 106, 589, 127, 625, 595, 131, 139, 209, - 0, 214, 218, 567, 109, 121, 219, 210, 214, 227, - 220, 222, 232, 236, 238, 228, 231, 241, 245, 249, - 256, 114, 593, 625, 572, 545, 625, 542, 625, 584, - 583, 582, 625, 625, 586, 625, 553, 584, 625, 571, - 570, 259, 260, 262, 263, 625, 272, 581, 625, 275, - 0, 282, 266, 276, 277, 282, 284, 285, 568, 286, - 287, 288, 291, 292, 295, 293, 296, 298, 300, 305, - 304, 308, 562, 532, 539, 625, 625, 625, 537, 313, - 306, 563, 562, 307, 561, 314, 315, 560, 316, 559, - - 317, 319, 323, 324, 332, 333, 337, 336, 338, 345, - 343, 558, 545, 625, 523, 519, 348, 344, 554, 353, - 553, 347, 354, 357, 361, 362, 552, 363, 364, 365, - 551, 370, 371, 544, 527, 527, 113, 372, 547, 373, - 374, 376, 378, 546, 545, 544, 539, 383, 384, 522, - 458, 464, 388, 386, 457, 387, 456, 393, 391, 455, - 450, 466, 465, 403, 441, 433, 396, 423, 401, 421, - 424, 422, 397, 389, 429, 414, 429, 22, 438, 440, - 625, 432, 625, 448, 11, 441, 461, 463, 625, 625, - 475, 481, 487, 493, 499, 505, 507, 511, 517, 523, - - 529, 533, 537, 543, 547, 552 + 203, 0, 650, 651, 651, 651, 651, 8, 623, 606, + 7, 2, 610, 651, 651, 651, 635, 619, 651, 651, + 651, 651, 15, 18, 618, 0, 651, 651, 6, 588, + 651, 651, 651, 651, 616, 0, 21, 0, 626, 47, + 16, 11, 28, 651, 65, 54, 71, 76, 79, 18, + 56, 49, 72, 30, 82, 67, 84, 87, 80, 85, + 99, 651, 651, 651, 637, 611, 605, 74, 600, 95, + 75, 651, 589, 651, 627, 213, 626, 625, 651, 629, + 651, 218, 587, 651, 651, 651, 627, 614, 613, 612, + + 21, 104, 102, 110, 616, 129, 651, 622, 140, 209, + 214, 0, 250, 218, 594, 116, 210, 222, 214, 219, + 103, 227, 231, 232, 236, 238, 246, 241, 256, 257, + 259, 261, 263, 620, 651, 599, 572, 587, 565, 651, + 564, 576, 565, 651, 607, 606, 605, 651, 651, 609, + 651, 576, 607, 651, 594, 593, 266, 267, 269, 270, + 651, 278, 604, 651, 284, 0, 289, 272, 278, 273, + 279, 284, 291, 591, 292, 295, 296, 299, 300, 303, + 305, 302, 310, 313, 314, 315, 318, 585, 555, 567, + 651, 651, 550, 560, 651, 651, 651, 558, 119, 317, + + 584, 583, 319, 582, 320, 321, 581, 322, 580, 323, + 325, 324, 327, 326, 332, 341, 333, 337, 344, 334, + 579, 566, 651, 555, 558, 542, 538, 360, 354, 573, + 361, 572, 345, 362, 364, 365, 369, 571, 371, 373, + 374, 570, 377, 378, 563, 535, 532, 544, 544, 380, + 379, 564, 381, 382, 390, 384, 563, 562, 561, 560, + 391, 393, 545, 96, 536, 523, 534, 387, 392, 555, + 395, 554, 400, 397, 553, 548, 521, 525, 562, 561, + 407, 547, 542, 402, 539, 486, 458, 438, 434, 414, + 416, 459, 453, 439, 431, 434, 405, 444, 434, 440, + + 444, 651, 435, 651, 423, 445, 441, 187, 451, 464, + 466, 651, 651, 478, 484, 490, 496, 502, 508, 510, + 514, 520, 526, 532, 536, 540, 546, 550, 555 } ; -static yyconst short int yy_def[307] = +static yyconst short int yy_def[330] = { 0, - 291, 291, 292, 292, 293, 293, 294, 294, 290, 9, - 9, 11, 290, 290, 290, 290, 290, 290, 290, 290, - 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - 290, 290, 290, 290, 290, 295, 290, 290, 290, 290, - 290, 290, 290, 290, 290, 296, 290, 297, 298, 298, - 298, 298, 298, 290, 290, 290, 290, 290, 290, 298, - 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, - 298, 290, 290, 290, 299, 290, 290, 290, 290, 290, - 290, 290, 290, 290, 290, 290, 290, 290, 300, 290, - 290, 290, 290, 290, 290, 301, 302, 298, 303, 298, - - 298, 298, 298, 290, 290, 290, 304, 290, 290, 290, - 305, 290, 290, 290, 298, 298, 298, 298, 298, 298, - 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, - 298, 298, 299, 290, 290, 290, 290, 290, 290, 290, - 290, 290, 290, 290, 300, 290, 290, 301, 290, 302, - 303, 298, 298, 298, 298, 290, 290, 304, 290, 290, - 305, 290, 298, 298, 298, 298, 298, 298, 298, 298, - 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, - 298, 298, 290, 290, 290, 290, 290, 290, 290, 298, - 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, - - 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, - 298, 298, 290, 290, 290, 290, 298, 298, 298, 298, - 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, - 298, 298, 298, 290, 290, 290, 298, 298, 298, 298, - 298, 298, 298, 298, 298, 298, 298, 298, 298, 290, - 290, 290, 298, 298, 298, 298, 298, 298, 298, 298, - 290, 290, 290, 298, 298, 298, 298, 298, 290, 290, - 290, 298, 298, 290, 290, 306, 298, 290, 290, 306, - 290, 298, 290, 290, 298, 290, 290, 290, 290, 0, - 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - - 290, 290, 290, 290, 290, 290 + 314, 314, 315, 315, 316, 316, 317, 317, 313, 9, + 9, 11, 313, 313, 313, 313, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 318, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 319, 313, 320, 321, 321, + 321, 321, 321, 313, 313, 313, 313, 313, 313, 321, + 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, + 321, 313, 313, 313, 322, 313, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 313, 323, + 313, 313, 313, 313, 313, 313, 324, 325, 321, 326, + + 321, 321, 321, 321, 313, 313, 313, 327, 313, 313, + 313, 328, 313, 313, 313, 321, 321, 321, 321, 321, + 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, + 321, 321, 321, 322, 313, 313, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 313, 323, + 313, 313, 324, 313, 325, 326, 321, 321, 321, 321, + 313, 313, 327, 313, 313, 328, 313, 321, 321, 321, + 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, + 321, 321, 321, 321, 321, 321, 321, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 321, 321, + + 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, + 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, + 321, 313, 313, 313, 313, 313, 313, 321, 321, 321, + 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, + 321, 321, 321, 321, 313, 313, 313, 313, 313, 321, + 321, 321, 321, 321, 321, 321, 321, 321, 321, 321, + 321, 321, 313, 313, 313, 313, 313, 321, 321, 321, + 321, 321, 321, 321, 321, 313, 313, 313, 313, 313, + 321, 321, 321, 321, 321, 313, 313, 313, 313, 313, + 321, 321, 313, 313, 313, 329, 321, 313, 313, 313, + + 329, 313, 321, 313, 313, 313, 321, 313, 313, 313, + 313, 313, 0, 313, 313, 313, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 313 } ; -static yyconst short int yy_nxt[681] = +static yyconst short int yy_nxt[707] = { 0, - 290, 15, 16, 17, 21, 16, 17, 91, 78, 22, - 18, 25, 26, 18, 25, 26, 74, 27, 75, 84, - 27, 42, 43, 44, 19, 99, 88, 19, 89, 95, - 99, 96, 99, 28, 20, 99, 28, 20, 42, 43, - 44, 80, 99, 45, 99, 85, 92, 99, 283, 46, - 23, 30, 31, 32, 79, 81, 33, 101, 100, 34, - 45, 106, 120, 107, 99, 102, 46, 103, 86, 87, - 99, 99, 104, 35, 105, 105, 105, 115, 108, 36, - 109, 109, 110, 108, 99, 112, 112, 112, 99, 99, - 113, 113, 113, 99, 118, 116, 99, 101, 99, 78, - - 117, 122, 37, 38, 30, 31, 32, 39, 40, 33, - 114, 99, 34, 119, 127, 128, 99, 121, 99, 99, - 99, 111, 123, 99, 129, 130, 35, 99, 99, 152, - 124, 125, 36, 253, 126, 99, 153, 131, 157, 157, - 157, 132, 160, 160, 160, 79, 155, 163, 108, 154, - 109, 109, 110, 164, 182, 37, 38, 14, 15, 16, + 313, 15, 16, 17, 21, 16, 17, 92, 78, 22, + 18, 25, 26, 18, 25, 26, 74, 27, 75, 85, + 27, 42, 43, 44, 19, 100, 89, 19, 90, 96, + 100, 97, 100, 28, 20, 100, 28, 20, 42, 43, + 44, 80, 100, 45, 100, 86, 93, 81, 157, 46, + 23, 30, 31, 32, 79, 82, 33, 102, 103, 34, + 45, 100, 107, 100, 108, 116, 46, 104, 87, 88, + 100, 121, 101, 35, 105, 78, 106, 106, 106, 36, + 109, 100, 110, 110, 111, 109, 100, 113, 113, 113, + 114, 114, 114, 119, 100, 117, 100, 102, 100, 100, + + 118, 100, 37, 38, 30, 31, 32, 39, 40, 33, + 115, 123, 34, 100, 141, 120, 100, 100, 100, 128, + 129, 79, 142, 112, 100, 122, 35, 124, 131, 130, + 100, 138, 36, 100, 126, 125, 158, 127, 228, 132, + 162, 162, 162, 133, 139, 277, 159, 173, 140, 140, + 160, 165, 165, 165, 168, 37, 38, 14, 15, 16, 17, 14, 14, 14, 14, 14, 14, 47, 14, 14, 14, 48, 14, 14, 49, 49, 49, 49, 49, 49, 49, 50, 49, 49, 49, 49, 14, 14, 14, 49, 49, 51, 49, 49, 52, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 53, 49, 49, 49, - 54, 14, 55, 56, 57, 58, 58, 140, 108, 91, - 110, 110, 110, 108, 99, 112, 112, 112, 99, 113, - 113, 113, 59, 99, 99, 60, 99, 61, 62, 63, - 64, 99, 99, 65, 66, 99, 99, 67, 68, 114, - 99, 69, 99, 70, 71, 99, 72, 73, 92, 99, - 166, 175, 165, 99, 167, 170, 141, 142, 171, 169, - 99, 168, 172, 99, 99, 176, 99, 99, 173, 177, - 99, 190, 174, 157, 157, 157, 160, 160, 160, 179, - 99, 99, 178, 113, 113, 113, 99, 180, 99, 99, - - 99, 99, 99, 181, 192, 99, 99, 99, 191, 99, - 99, 193, 99, 114, 99, 197, 194, 199, 99, 99, - 99, 99, 99, 195, 200, 196, 198, 99, 99, 99, - 99, 99, 217, 99, 201, 202, 205, 99, 99, 207, - 206, 204, 203, 212, 209, 210, 99, 99, 208, 218, - 99, 99, 99, 211, 193, 224, 220, 99, 99, 99, - 225, 99, 99, 219, 222, 221, 223, 99, 99, 228, - 230, 99, 226, 229, 237, 99, 99, 99, 99, 99, - 238, 231, 227, 232, 99, 99, 99, 99, 99, 239, - 99, 240, 99, 233, 241, 243, 244, 99, 99, 246, - - 99, 99, 99, 249, 245, 99, 242, 99, 278, 256, - 99, 99, 257, 248, 247, 254, 264, 99, 281, 259, - 255, 272, 270, 266, 274, 260, 268, 258, 276, 267, - 281, 273, 275, 275, 275, 265, 99, 99, 279, 276, - 275, 275, 275, 99, 281, 277, 99, 99, 282, 284, - 284, 284, 287, 287, 287, 99, 281, 286, 285, 284, - 284, 284, 288, 289, 288, 289, 271, 270, 269, 99, - 99, 99, 287, 287, 287, 14, 14, 14, 14, 14, - 14, 24, 24, 24, 24, 24, 24, 29, 29, 29, - 29, 29, 29, 41, 41, 41, 41, 41, 41, 90, - - 263, 90, 90, 90, 90, 94, 262, 94, 94, 94, - 94, 97, 97, 98, 98, 98, 98, 133, 133, 133, - 133, 133, 133, 145, 145, 145, 145, 145, 145, 148, - 148, 148, 148, 148, 148, 150, 150, 150, 150, 151, - 151, 151, 151, 158, 158, 158, 158, 158, 158, 161, - 261, 161, 280, 99, 280, 280, 280, 280, 99, 99, - 99, 99, 252, 251, 250, 99, 99, 99, 99, 236, - 235, 234, 99, 99, 99, 99, 99, 99, 216, 215, - 214, 213, 99, 159, 99, 99, 149, 189, 146, 188, - 187, 186, 185, 184, 183, 134, 162, 159, 156, 99, - - 99, 99, 149, 147, 146, 144, 143, 139, 138, 137, - 82, 136, 135, 134, 99, 76, 93, 76, 76, 83, - 82, 77, 76, 290, 13, 290, 290, 290, 290, 290, - 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - 290, 290, 290, 290, 290, 290, 290, 290, 290, 290 + 54, 14, 55, 56, 57, 58, 58, 145, 109, 92, + 110, 110, 111, 109, 100, 111, 111, 111, 100, 114, + 114, 114, 59, 100, 141, 60, 100, 61, 62, 63, + 64, 100, 169, 65, 66, 100, 100, 67, 68, 115, + 100, 69, 100, 70, 71, 100, 72, 73, 93, 109, + 100, 113, 113, 113, 171, 170, 146, 147, 176, 172, + 100, 100, 177, 100, 175, 100, 174, 100, 178, 180, + 100, 100, 179, 100, 100, 181, 100, 100, 199, 162, + 162, 162, 100, 100, 182, 165, 165, 165, 100, 184, + + 114, 114, 114, 187, 183, 100, 100, 185, 186, 100, + 100, 201, 206, 100, 100, 200, 100, 100, 202, 100, + 115, 205, 203, 208, 100, 204, 207, 100, 100, 100, + 209, 100, 100, 100, 100, 100, 100, 100, 100, 100, + 100, 100, 210, 211, 214, 216, 100, 100, 100, 213, + 212, 100, 215, 221, 219, 100, 235, 218, 100, 100, + 217, 229, 231, 236, 220, 202, 237, 241, 100, 230, + 233, 232, 234, 239, 100, 100, 100, 240, 100, 100, + 242, 238, 243, 100, 244, 100, 250, 100, 100, 253, + 251, 100, 100, 100, 100, 100, 100, 252, 100, 256, + + 268, 100, 254, 257, 100, 100, 100, 100, 259, 100, + 262, 100, 258, 255, 100, 281, 100, 271, 296, 100, + 261, 100, 269, 260, 303, 291, 272, 274, 270, 296, + 100, 283, 285, 273, 275, 289, 284, 292, 302, 297, + 300, 282, 295, 295, 295, 295, 295, 295, 302, 100, + 302, 306, 306, 306, 309, 100, 306, 306, 306, 308, + 302, 307, 310, 310, 310, 311, 312, 311, 312, 305, + 304, 299, 298, 100, 294, 310, 310, 310, 14, 14, + 14, 14, 14, 14, 24, 24, 24, 24, 24, 24, + 29, 29, 29, 29, 29, 29, 41, 41, 41, 41, + + 41, 41, 91, 139, 91, 91, 91, 91, 95, 293, + 95, 95, 95, 95, 98, 98, 99, 99, 99, 99, + 134, 134, 134, 134, 134, 134, 150, 150, 150, 150, + 150, 150, 153, 153, 153, 153, 153, 153, 155, 155, + 155, 155, 156, 156, 156, 156, 163, 163, 163, 163, + 163, 163, 166, 100, 166, 301, 100, 301, 301, 301, + 301, 100, 290, 289, 288, 287, 286, 100, 100, 100, + 280, 279, 278, 276, 100, 100, 100, 100, 100, 267, + 266, 265, 264, 263, 100, 100, 100, 100, 249, 248, + 247, 246, 245, 100, 100, 100, 100, 100, 100, 227, + + 226, 225, 224, 223, 222, 100, 164, 100, 100, 154, + 198, 151, 197, 196, 195, 194, 193, 192, 191, 190, + 189, 188, 135, 167, 164, 161, 100, 100, 100, 154, + 152, 151, 149, 148, 144, 143, 83, 137, 136, 135, + 100, 76, 94, 76, 76, 84, 83, 77, 76, 313, + 13, 313, 313, 313, 313, 313, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, + + 313, 313, 313, 313, 313, 313 } ; -static yyconst short int yy_chk[681] = +static yyconst short int yy_chk[707] = { 0, 0, 1, 1, 1, 2, 2, 2, 39, 21, 2, 1, 3, 3, 2, 4, 4, 18, 3, 18, 33, - 4, 7, 7, 7, 1, 285, 34, 2, 34, 47, - 51, 47, 52, 3, 1, 64, 4, 2, 8, 8, - 8, 22, 53, 7, 60, 33, 39, 50, 278, 7, - 2, 5, 5, 5, 21, 22, 5, 51, 50, 5, - 8, 56, 64, 56, 62, 52, 8, 53, 33, 33, - 61, 66, 55, 5, 55, 55, 55, 60, 57, 5, - 57, 57, 57, 58, 63, 58, 58, 58, 65, 69, - 59, 59, 59, 67, 62, 61, 70, 61, 68, 78, - - 61, 66, 5, 5, 6, 6, 6, 6, 6, 6, - 59, 71, 6, 63, 69, 69, 100, 65, 101, 102, - 103, 57, 67, 115, 69, 70, 6, 237, 132, 100, - 67, 68, 6, 237, 68, 116, 101, 71, 105, 105, - 105, 71, 108, 108, 108, 78, 103, 115, 109, 102, - 109, 109, 109, 116, 132, 6, 6, 9, 9, 9, + 4, 7, 7, 7, 1, 52, 34, 2, 34, 47, + 51, 47, 60, 3, 1, 101, 4, 2, 8, 8, + 8, 22, 53, 7, 64, 33, 39, 22, 101, 7, + 2, 5, 5, 5, 21, 22, 5, 51, 52, 5, + 8, 50, 56, 62, 56, 60, 8, 53, 33, 33, + 61, 64, 50, 5, 55, 78, 55, 55, 55, 5, + 57, 66, 57, 57, 57, 58, 63, 58, 58, 58, + 59, 59, 59, 62, 69, 61, 65, 61, 67, 70, + + 61, 68, 5, 5, 6, 6, 6, 6, 6, 6, + 59, 66, 6, 71, 81, 63, 103, 121, 102, 69, + 69, 78, 81, 57, 104, 65, 6, 67, 70, 69, + 116, 80, 6, 199, 68, 67, 102, 68, 199, 71, + 106, 106, 106, 71, 80, 264, 103, 121, 80, 264, + 104, 109, 109, 109, 116, 6, 6, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 11, 11, 11, 11, 11, 85, 110, 91, - 110, 110, 110, 112, 118, 112, 112, 112, 119, 113, - 113, 113, 11, 117, 121, 11, 122, 11, 11, 11, - 11, 120, 126, 11, 11, 127, 123, 11, 11, 113, - 124, 11, 125, 11, 11, 128, 11, 11, 91, 129, - 118, 126, 117, 130, 119, 122, 85, 85, 123, 121, - 131, 120, 124, 152, 153, 127, 154, 155, 125, 128, - 163, 152, 125, 157, 157, 157, 160, 160, 160, 130, - 164, 165, 129, 162, 162, 162, 166, 130, 167, 168, - - 170, 171, 172, 131, 154, 173, 174, 176, 153, 175, - 177, 155, 178, 162, 179, 166, 163, 168, 181, 180, - 191, 194, 182, 164, 170, 165, 167, 190, 196, 197, - 199, 201, 190, 202, 171, 172, 175, 203, 204, 177, - 176, 174, 173, 182, 179, 180, 205, 206, 178, 194, - 208, 207, 209, 181, 191, 203, 197, 211, 218, 210, - 204, 222, 217, 196, 201, 199, 202, 220, 223, 207, - 208, 224, 205, 207, 217, 225, 226, 228, 229, 230, - 218, 209, 206, 210, 232, 233, 238, 240, 241, 220, - 242, 222, 243, 211, 223, 225, 226, 248, 249, 229, - - 254, 256, 253, 233, 228, 259, 224, 258, 274, 241, - 267, 273, 242, 232, 230, 238, 253, 264, 276, 248, - 240, 264, 270, 256, 269, 249, 259, 243, 271, 258, - 276, 267, 270, 270, 270, 254, 272, 268, 275, 271, - 275, 275, 275, 277, 280, 272, 282, 266, 277, 279, - 279, 279, 286, 286, 286, 265, 280, 284, 282, 284, - 284, 284, 287, 287, 288, 288, 263, 262, 261, 260, - 257, 255, 287, 287, 287, 291, 291, 291, 291, 291, - 291, 292, 292, 292, 292, 292, 292, 293, 293, 293, - 293, 293, 293, 294, 294, 294, 294, 294, 294, 295, - - 252, 295, 295, 295, 295, 296, 251, 296, 296, 296, - 296, 297, 297, 298, 298, 298, 298, 299, 299, 299, - 299, 299, 299, 300, 300, 300, 300, 300, 300, 301, - 301, 301, 301, 301, 301, 302, 302, 302, 302, 303, - 303, 303, 303, 304, 304, 304, 304, 304, 304, 305, - 250, 305, 306, 247, 306, 306, 306, 306, 246, 245, - 244, 239, 236, 235, 234, 231, 227, 221, 219, 216, - 215, 213, 212, 200, 198, 195, 193, 192, 189, 185, - 184, 183, 169, 158, 151, 150, 148, 147, 145, 142, - 141, 140, 138, 136, 135, 133, 114, 107, 104, 99, - - 98, 97, 96, 92, 89, 87, 86, 84, 82, 80, - 79, 77, 76, 75, 49, 45, 40, 35, 28, 27, - 23, 20, 19, 13, 290, 290, 290, 290, 290, 290, - 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - 290, 290, 290, 290, 290, 290, 290, 290, 290, 290 + 9, 9, 11, 11, 11, 11, 11, 86, 110, 92, + 110, 110, 110, 111, 117, 111, 111, 111, 119, 114, + 114, 114, 11, 120, 308, 11, 118, 11, 11, 11, + 11, 122, 117, 11, 11, 123, 124, 11, 11, 114, + 125, 11, 126, 11, 11, 128, 11, 11, 92, 113, + 127, 113, 113, 113, 119, 118, 86, 86, 124, 120, + 129, 130, 125, 131, 123, 132, 122, 133, 126, 127, + 157, 158, 126, 159, 160, 128, 168, 170, 157, 162, + 162, 162, 169, 171, 129, 165, 165, 165, 172, 131, + + 167, 167, 167, 133, 130, 173, 175, 131, 132, 176, + 177, 159, 171, 178, 179, 158, 182, 180, 160, 181, + 167, 170, 168, 173, 183, 169, 172, 184, 185, 186, + 175, 200, 187, 203, 205, 206, 208, 210, 212, 211, + 214, 213, 176, 177, 180, 182, 215, 217, 220, 179, + 178, 218, 181, 187, 185, 216, 212, 184, 219, 233, + 183, 203, 206, 213, 186, 200, 214, 217, 229, 205, + 210, 208, 211, 216, 228, 231, 234, 216, 235, 236, + 218, 215, 219, 237, 220, 239, 228, 240, 241, 233, + 229, 243, 244, 251, 250, 253, 254, 231, 256, 236, + + 250, 268, 234, 237, 255, 261, 269, 262, 240, 271, + 244, 274, 239, 235, 273, 268, 284, 254, 290, 297, + 243, 281, 251, 241, 297, 281, 255, 261, 253, 290, + 291, 271, 274, 256, 262, 289, 273, 284, 296, 291, + 295, 269, 295, 295, 295, 289, 289, 289, 301, 303, + 296, 300, 300, 300, 306, 307, 306, 306, 306, 305, + 301, 303, 309, 309, 309, 310, 310, 311, 311, 299, + 298, 294, 293, 292, 288, 310, 310, 310, 314, 314, + 314, 314, 314, 314, 315, 315, 315, 315, 315, 315, + 316, 316, 316, 316, 316, 316, 317, 317, 317, 317, + + 317, 317, 318, 287, 318, 318, 318, 318, 319, 286, + 319, 319, 319, 319, 320, 320, 321, 321, 321, 321, + 322, 322, 322, 322, 322, 322, 323, 323, 323, 323, + 323, 323, 324, 324, 324, 324, 324, 324, 325, 325, + 325, 325, 326, 326, 326, 326, 327, 327, 327, 327, + 327, 327, 328, 285, 328, 329, 283, 329, 329, 329, + 329, 282, 280, 279, 278, 277, 276, 275, 272, 270, + 267, 266, 265, 263, 260, 259, 258, 257, 252, 249, + 248, 247, 246, 245, 242, 238, 232, 230, 227, 226, + 225, 224, 222, 221, 209, 207, 204, 202, 201, 198, + + 194, 193, 190, 189, 188, 174, 163, 156, 155, 153, + 152, 150, 147, 146, 145, 143, 142, 141, 139, 138, + 137, 136, 134, 115, 108, 105, 100, 99, 98, 97, + 93, 90, 88, 87, 85, 83, 79, 77, 76, 75, + 49, 45, 40, 35, 28, 27, 23, 20, 19, 13, + 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, + + 313, 313, 313, 313, 313, 313 } ; static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr; @@ -684,13 +698,12 @@ char *yytext; #include "parse.h" #include "main.h" - -extern gboolean for_cpp; +#include "util.h" static int parenth_depth = 0; static int before_comment = INITIAL; -static int class_after_c = FALSE; -static int header_c = FALSE; +static gboolean class_after_c = FALSE; +static int code_type = CCODE; static GString *cbuf = NULL; int ccode_line = 1; @@ -731,7 +744,7 @@ add_to_cbuf(char *s) #define CLASS_CODE_I 5 -#line 735 "lex.yy.c" +#line 748 "lex.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -885,10 +898,10 @@ YY_DECL register char *yy_cp = NULL, *yy_bp = NULL; register int yy_act; -#line 74 "lexer.l" +#line 73 "lexer.l" -#line 892 "lex.yy.c" +#line 905 "lex.yy.c" if ( yy_init ) { @@ -937,14 +950,14 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 291 ) + if ( yy_current_state >= 314 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; *yy_state_ptr++ = yy_current_state; ++yy_cp; } - while ( yy_base[yy_current_state] != 625 ); + while ( yy_base[yy_current_state] != 651 ); yy_find_action: yy_current_state = *--yy_state_ptr; @@ -975,12 +988,12 @@ do_action: /* This label is used only to access EOF actions. */ { /* beginning of action switch */ case 1: YY_RULE_SETUP -#line 76 "lexer.l" +#line 75 "lexer.l" { line_no++; REJECT; } YY_BREAK case 2: YY_RULE_SETUP -#line 78 "lexer.l" +#line 77 "lexer.l" { fprintf(stderr,"You are a bad bad person!\n"); REJECT; } YY_BREAK case 3: @@ -988,12 +1001,12 @@ case 3: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 80 "lexer.l" +#line 79 "lexer.l" { ; /*comment, ignore*/ } YY_BREAK case 4: YY_RULE_SETUP -#line 81 "lexer.l" +#line 80 "lexer.l" { if(look_for_includes==1) { char *p; @@ -1016,7 +1029,7 @@ case 5: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 98 "lexer.l" +#line 97 "lexer.l" { add_to_cbuf(yytext); /*comment, ignore*/ } YY_BREAK case 6: @@ -1024,7 +1037,7 @@ case 6: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 99 "lexer.l" +#line 98 "lexer.l" { ; /*comment, ignore*/ } YY_BREAK case 7: @@ -1032,17 +1045,17 @@ case 7: yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 100 "lexer.l" +#line 99 "lexer.l" { ; /*comment, ignore*/ } YY_BREAK case 8: YY_RULE_SETUP -#line 101 "lexer.l" +#line 100 "lexer.l" {BEGIN(COMMENT); before_comment = INITIAL; } YY_BREAK case 9: YY_RULE_SETUP -#line 102 "lexer.l" +#line 101 "lexer.l" { add_to_cbuf(yytext); BEGIN(COMMENT); @@ -1051,17 +1064,17 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 107 "lexer.l" +#line 106 "lexer.l" {BEGIN(COMMENT); before_comment = CLASS_CODE; } YY_BREAK case 11: YY_RULE_SETUP -#line 108 "lexer.l" +#line 107 "lexer.l" {BEGIN(COMMENT); before_comment = CLASS_CODE_I; } YY_BREAK case 12: YY_RULE_SETUP -#line 109 "lexer.l" +#line 108 "lexer.l" { if(before_comment == C_CODE) add_to_cbuf(yytext); BEGIN(before_comment); @@ -1069,7 +1082,7 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -#line 113 "lexer.l" +#line 112 "lexer.l" { /* comment, ignore */ if(before_comment == C_CODE) add_to_cbuf(yytext); @@ -1077,7 +1090,7 @@ YY_RULE_SETUP YY_BREAK case 14: YY_RULE_SETUP -#line 117 "lexer.l" +#line 116 "lexer.l" { /* comment, ignore */ if(before_comment == C_CODE) add_to_cbuf(yytext); @@ -1085,122 +1098,143 @@ YY_RULE_SETUP YY_BREAK case 15: YY_RULE_SETUP -#line 122 "lexer.l" +#line 121 "lexer.l" { BEGIN(C_CODE); parenth_depth = 1; class_after_c = FALSE; - header_c = TRUE; + code_type = HTCODE; clear_cbuf(); ccode_line = line_no; } YY_BREAK case 16: YY_RULE_SETUP -#line 130 "lexer.l" +#line 129 "lexer.l" { BEGIN(C_CODE); parenth_depth = 1; class_after_c = FALSE; - header_c = FALSE; + code_type = PHCODE; clear_cbuf(); ccode_line = line_no; - if(look_for_includes==0) - look_for_includes=1; } YY_BREAK case 17: YY_RULE_SETUP -#line 140 "lexer.l" +#line 137 "lexer.l" { - BEGIN(INITIAL); - yylval.cbuf = cbuf; - cbuf = NULL; - if(look_for_includes==1) - look_for_includes=0; - if(header_c) - return HCODE; - else - return CCODE; + BEGIN(C_CODE); + parenth_depth = 1; + class_after_c = FALSE; + code_type = HCODE; + clear_cbuf(); + ccode_line = line_no; } YY_BREAK case 18: YY_RULE_SETUP -#line 152 "lexer.l" -{ add_to_cbuf(yytext); } +#line 145 "lexer.l" +{ + BEGIN(C_CODE); + parenth_depth = 1; + class_after_c = FALSE; + code_type = CCODE; + clear_cbuf(); + ccode_line = line_no; + if(look_for_includes==0) + look_for_includes=1; + } YY_BREAK case 19: YY_RULE_SETUP -#line 153 "lexer.l" -{ add_to_cbuf(yytext); } +#line 155 "lexer.l" +{ + BEGIN(INITIAL); + yylval.cbuf = cbuf; + cbuf = NULL; + if(look_for_includes==1) + look_for_includes=0; + return code_type; + } YY_BREAK case 20: YY_RULE_SETUP -#line 154 "lexer.l" +#line 164 "lexer.l" { add_to_cbuf(yytext); } YY_BREAK case 21: YY_RULE_SETUP -#line 155 "lexer.l" +#line 165 "lexer.l" { add_to_cbuf(yytext); } YY_BREAK case 22: YY_RULE_SETUP -#line 156 "lexer.l" +#line 166 "lexer.l" { add_to_cbuf(yytext); } YY_BREAK case 23: YY_RULE_SETUP -#line 157 "lexer.l" +#line 167 "lexer.l" { add_to_cbuf(yytext); } YY_BREAK case 24: YY_RULE_SETUP -#line 159 "lexer.l" +#line 168 "lexer.l" { add_to_cbuf(yytext); } YY_BREAK case 25: YY_RULE_SETUP -#line 160 "lexer.l" +#line 169 "lexer.l" +{ add_to_cbuf(yytext); } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 171 "lexer.l" +{ add_to_cbuf(yytext); } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 172 "lexer.l" { BEGIN(C_CODE_STRING); add_to_cbuf(yytext); } YY_BREAK -case 26: +case 28: YY_RULE_SETUP -#line 164 "lexer.l" +#line 176 "lexer.l" { add_to_cbuf(yytext); } YY_BREAK -case 27: +case 29: YY_RULE_SETUP -#line 165 "lexer.l" +#line 177 "lexer.l" { BEGIN(C_CODE); add_to_cbuf(yytext); } YY_BREAK -case 28: +case 30: YY_RULE_SETUP -#line 169 "lexer.l" +#line 181 "lexer.l" { add_to_cbuf(yytext); } YY_BREAK -case 29: +case 31: YY_RULE_SETUP -#line 170 "lexer.l" +#line 182 "lexer.l" { add_to_cbuf(yytext); } YY_BREAK -case 30: +case 32: YY_RULE_SETUP -#line 172 "lexer.l" +#line 184 "lexer.l" { parenth_depth++; add_to_cbuf(yytext); } YY_BREAK -case 31: +case 33: YY_RULE_SETUP -#line 176 "lexer.l" +#line 188 "lexer.l" { parenth_depth--; if(parenth_depth<0) { @@ -1214,31 +1248,31 @@ YY_RULE_SETUP add_to_cbuf(yytext); } YY_BREAK -case 32: +case 34: YY_RULE_SETUP -#line 189 "lexer.l" +#line 201 "lexer.l" { add_to_cbuf(yytext); } YY_BREAK -case 33: +case 35: YY_RULE_SETUP -#line 190 "lexer.l" +#line 202 "lexer.l" { add_to_cbuf(yytext); } YY_BREAK -case 34: +case 36: YY_RULE_SETUP -#line 192 "lexer.l" +#line 204 "lexer.l" { look_for_includes = 2; BEGIN(CLASS_CODE); return CLASS; } YY_BREAK -case 35: +case 37: *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 198 "lexer.l" +#line 210 "lexer.l" { int maj = 0,min = 0,pl = 0; int rmaj = 0,rmin = 0,rpl = 0; @@ -1263,9 +1297,9 @@ YY_RULE_SETUP } } YY_BREAK -case 36: +case 38: YY_RULE_SETUP -#line 222 "lexer.l" +#line 234 "lexer.l" { if(for_cpp) { char *s; @@ -1278,164 +1312,164 @@ YY_RULE_SETUP REJECT; } YY_BREAK -case 37: +case 39: YY_RULE_SETUP -#line 234 "lexer.l" +#line 246 "lexer.l" {return FROM;} YY_BREAK -case 38: +case 40: YY_RULE_SETUP -#line 236 "lexer.l" +#line 248 "lexer.l" {return VOID;} YY_BREAK -case 39: +case 41: YY_RULE_SETUP -#line 237 "lexer.l" +#line 249 "lexer.l" {return STRUCT;} YY_BREAK -case 40: +case 42: YY_RULE_SETUP -#line 238 "lexer.l" +#line 250 "lexer.l" {return UNION;} YY_BREAK -case 41: +case 43: YY_RULE_SETUP -#line 239 "lexer.l" +#line 251 "lexer.l" {return ENUM;} YY_BREAK -case 42: +case 44: YY_RULE_SETUP -#line 240 "lexer.l" +#line 252 "lexer.l" {return SIGNED;} YY_BREAK -case 43: +case 45: YY_RULE_SETUP -#line 241 "lexer.l" +#line 253 "lexer.l" {return UNSIGNED;} YY_BREAK -case 44: +case 46: YY_RULE_SETUP -#line 242 "lexer.l" +#line 254 "lexer.l" {return LONG;} YY_BREAK -case 45: +case 47: YY_RULE_SETUP -#line 243 "lexer.l" +#line 255 "lexer.l" {return SHORT;} YY_BREAK -case 46: +case 48: YY_RULE_SETUP -#line 244 "lexer.l" +#line 256 "lexer.l" {return INT;} YY_BREAK -case 47: +case 49: YY_RULE_SETUP -#line 245 "lexer.l" +#line 257 "lexer.l" {return FLOAT;} YY_BREAK -case 48: +case 50: YY_RULE_SETUP -#line 246 "lexer.l" +#line 258 "lexer.l" {return DOUBLE;} YY_BREAK -case 49: +case 51: YY_RULE_SETUP -#line 247 "lexer.l" +#line 259 "lexer.l" {return CHAR;} YY_BREAK -case 50: +case 52: YY_RULE_SETUP -#line 248 "lexer.l" +#line 260 "lexer.l" {return CONST;} YY_BREAK -case 51: +case 53: YY_RULE_SETUP -#line 250 "lexer.l" +#line 262 "lexer.l" {return THREEDOTS;} YY_BREAK -case 52: +case 54: YY_RULE_SETUP -#line 252 "lexer.l" +#line 264 "lexer.l" {yylval.line = line_no; return PUBLIC;} YY_BREAK -case 53: +case 55: YY_RULE_SETUP -#line 253 "lexer.l" +#line 265 "lexer.l" {yylval.line = line_no; return PRIVATE;} YY_BREAK -case 54: +case 56: YY_RULE_SETUP -#line 254 "lexer.l" +#line 266 "lexer.l" {yylval.line = line_no; return PROTECTED;} YY_BREAK -case 55: +case 57: YY_RULE_SETUP -#line 255 "lexer.l" +#line 267 "lexer.l" {yylval.line = line_no; return ARGUMENT;} YY_BREAK -case 56: +case 58: YY_RULE_SETUP -#line 256 "lexer.l" +#line 268 "lexer.l" {yylval.line = line_no; return VIRTUAL;} YY_BREAK -case 57: +case 59: YY_RULE_SETUP -#line 257 "lexer.l" +#line 269 "lexer.l" {yylval.line = line_no; return SIGNAL;} YY_BREAK -case 58: +case 60: YY_RULE_SETUP -#line 258 "lexer.l" +#line 270 "lexer.l" {yylval.line = line_no; return OVERRIDE;} YY_BREAK -case 59: +case 61: YY_RULE_SETUP -#line 259 "lexer.l" +#line 271 "lexer.l" {return ONERROR;} YY_BREAK -case 60: +case 62: YY_RULE_SETUP -#line 260 "lexer.l" +#line 272 "lexer.l" { yylval.id = g_strdup(yytext); return NUMBER; } YY_BREAK -case 61: +case 63: YY_RULE_SETUP -#line 264 "lexer.l" +#line 276 "lexer.l" { yylval.id = g_strdup(yytext); return TYPETOKEN; } YY_BREAK -case 62: +case 64: YY_RULE_SETUP -#line 268 "lexer.l" +#line 280 "lexer.l" { yylval.id = g_strdup(yytext); return TOKEN; } YY_BREAK -case 63: +case 65: YY_RULE_SETUP -#line 273 "lexer.l" +#line 285 "lexer.l" { yylval.id = g_strdup(yytext); return ARRAY_DIM; } YY_BREAK -case 64: +case 66: YY_RULE_SETUP -#line 278 "lexer.l" +#line 290 "lexer.l" { BEGIN(CLASS_CODE_I); return '{'; } YY_BREAK -case 65: +case 67: YY_RULE_SETUP -#line 282 "lexer.l" +#line 294 "lexer.l" { BEGIN(C_CODE); parenth_depth=1; @@ -1446,38 +1480,38 @@ YY_RULE_SETUP return '{'; } YY_BREAK -case 66: +case 68: YY_RULE_SETUP -#line 291 "lexer.l" +#line 303 "lexer.l" { BEGIN(INITIAL); return '}'; } YY_BREAK -case 67: +case 69: YY_RULE_SETUP -#line 296 "lexer.l" +#line 308 "lexer.l" ; /*ignore*/ YY_BREAK -case 68: +case 70: YY_RULE_SETUP -#line 298 "lexer.l" +#line 310 "lexer.l" { yylval.line = line_no; return yytext[0]; } YY_BREAK -case 69: +case 71: YY_RULE_SETUP -#line 303 "lexer.l" +#line 315 "lexer.l" ; /*ignore*/ YY_BREAK -case 70: +case 72: YY_RULE_SETUP -#line 304 "lexer.l" +#line 316 "lexer.l" ECHO; YY_BREAK -#line 1481 "lex.yy.c" +#line 1515 "lex.yy.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(COMMENT): case YY_STATE_EOF(C_CODE): @@ -1772,7 +1806,7 @@ static yy_state_type yy_get_previous_state() while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 291 ) + if ( yy_current_state >= 314 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1802,11 +1836,11 @@ yy_state_type yy_current_state; while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 291 ) + if ( yy_current_state >= 314 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 290); + yy_is_jam = (yy_current_state == 313); if ( ! yy_is_jam ) *yy_state_ptr++ = yy_current_state; @@ -2364,4 +2398,4 @@ int main() return 0; } #endif -#line 304 "lexer.l" +#line 316 "lexer.l" diff --git a/src/lexer.l b/src/lexer.l index 392a636..d896eb2 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -26,13 +26,12 @@ #include "parse.h" #include "main.h" - -extern gboolean for_cpp; +#include "util.h" static int parenth_depth = 0; static int before_comment = INITIAL; -static int class_after_c = FALSE; -static int header_c = FALSE; +static gboolean class_after_c = FALSE; +static int code_type = CCODE; static GString *cbuf = NULL; int ccode_line = 1; @@ -119,11 +118,27 @@ add_to_cbuf(char *s) if(before_comment == C_CODE) add_to_cbuf(yytext); } -^\%h\{ { +^\%(ht|headertop)\{ { + BEGIN(C_CODE); + parenth_depth = 1; + class_after_c = FALSE; + code_type = HTCODE; + clear_cbuf(); + ccode_line = line_no; + } +^\%(ph|privateheader)\{ { BEGIN(C_CODE); parenth_depth = 1; class_after_c = FALSE; - header_c = TRUE; + code_type = PHCODE; + clear_cbuf(); + ccode_line = line_no; + } +^\%(h|header)\{ { + BEGIN(C_CODE); + parenth_depth = 1; + class_after_c = FALSE; + code_type = HCODE; clear_cbuf(); ccode_line = line_no; } @@ -131,7 +146,7 @@ add_to_cbuf(char *s) BEGIN(C_CODE); parenth_depth = 1; class_after_c = FALSE; - header_c = FALSE; + code_type = CCODE; clear_cbuf(); ccode_line = line_no; if(look_for_includes==0) @@ -143,10 +158,7 @@ add_to_cbuf(char *s) cbuf = NULL; if(look_for_includes==1) look_for_includes=0; - if(header_c) - return HCODE; - else - return CCODE; + return code_type; } \'\{\' { add_to_cbuf(yytext); } diff --git a/src/main.c b/src/main.c index d58aef4..d86697d 100644 --- a/src/main.c +++ b/src/main.c @@ -21,9 +21,6 @@ #include "config.h" #include -#if 0 -#include -#endif #include #include #include @@ -33,6 +30,9 @@ #include "tree.h" #include "parse.h" #include "out.h" +#include "util.h" +#include "checks.h" + #include "main.h" char *filename = NULL; @@ -77,95 +77,7 @@ gboolean exit_on_error = TRUE; gboolean got_error = FALSE; gboolean always_private_header = FALSE; gboolean no_private_header = FALSE; - -void -print_error(int is_warn, char *error,int line) -{ - char *w; - if(is_warn) - w = "Warning:"; - else { - w = "Error:"; - got_error = TRUE; - } - if(line>0) - fprintf(stderr,"%s:%d: %s %s\n",filename,line,w,error); - else - fprintf(stderr,"%s: %s %s\n",filename,w,error); - if((!is_warn || exit_on_warn) && exit_on_error) - exit(1); -} - -static char * -remove_sep(char *base) -{ - char *p; - char *s = g_strdup(base); - while((p=strchr(s,':'))) - strcpy(p,p+1); - return s; -} - -static char * -replace_sep(char *base, char r) -{ - char *p; - char *s = g_strdup(base); - while((p=strchr(s,':'))) - *p = r; - if(*s == r) { - p = g_strdup(s+1); - g_free(s); - return p; - } - return s; -} - -/*separate the namespace part and then replace rest of - separators with r*/ -static void -separns_replace_sep(char *base, char **ns, char **name, char r) -{ - char *p; - char *s = g_strdup(base); - *ns = NULL; - if((p=strchr(s,':')) && p!=s) { - *p = '\0'; - *ns = g_strdup(s); - p = g_strdup(p+1); - g_free(s); - s = p; - } - while((p=strchr(s,':'))) - *p = r; - if(*s == r) { - *name = g_strdup(s+1); - g_free(s); - } else - *name = s; -} - -/* make a macro with some prefix before the name but after - namespace */ -static char * -make_pre_macro(char *base, char *pre) -{ - char *s1,*s2; - char *s; - - separns_replace_sep(base,&s1,&s2,'_'); - if(s1) - s = g_strconcat(s1,"_",pre,"_",s2,NULL); - else - s = g_strconcat(pre,"_",s2,NULL); - - g_strup(s); - - g_free(s1); - g_free(s2); - - return s; -} +gboolean no_extern_c = FALSE; static void make_bases(void) @@ -425,7 +337,7 @@ put_priv_method_prot(Method *m) m->method == SIGNAL_FIRST_METHOD || m->method == VIRTUAL_METHOD) { if(m->cbuf) - print_method(out,"static ","_real_"," ",";\n",m,FALSE); + print_method(out,"static ","___real_"," ",";\n",m,FALSE); } if(m->scope == PRIVATE_SCOPE || @@ -533,54 +445,6 @@ make_finalize(Class *cl) } } -/* here we will find out how inconsistent gtk really is :) */ -/* the commented out types mean that these types don't actually - exist. so we "emulate them" with an equivalent */ -const struct { - gboolean simple; - char *gtkname; - char *typename; -} our_gtk_type_table[] = { - { TRUE, "NONE", "void " }, - { TRUE, "CHAR", "gchar " }, - { TRUE, "UCHAR", "guchar " }, - { TRUE, "BOOL", "gboolean " }, - { TRUE, "INT", "gint " }, - { TRUE, "UINT", "guint " }, - { TRUE, "LONG", "glong " }, - { TRUE, "ULONG", "gulong " }, - { TRUE, "FLOAT", "gfloat " }, - { TRUE, "DOUBLE", "gdouble " }, - { TRUE, "STRING", /*"GtkString"*/"gchar *" }, - { TRUE, "ENUM", /*"GtkEnum"*/"gint " }, - { TRUE, "FLAGS", /*"GtkFlags"*/"guint " }, - { TRUE, "BOXED", /*"GtkBoxed"*/"gpointer " }, - { TRUE, "POINTER", "gpointer " }, - { TRUE, "OBJECT", "GtkObject *" }, - { FALSE, "SIGNAL", /*"GtkSignal"*/"___twopointertype " }, - { FALSE, "ARGS", /*"GtkArgs"*/"___twopointertype " }, - { FALSE, "CALLBACK", /*"GtkCallback"*/"___threepointertype " }, - { FALSE, "C_CALLBACK", /*"GtkCCallback"*/"___twopointertype " }, - { FALSE, "FOREIGN", /*"GtkForeign"*/"___twopointertype " }, - - { FALSE, NULL, NULL } -}; - -static const char * -get_cast(char *type, gboolean simple_only) -{ - int i; - for(i=0;our_gtk_type_table[i].gtkname;i++) { - if(strcmp(our_gtk_type_table[i].gtkname,type)==0) { - if(simple_only && - !our_gtk_type_table[i].simple) - return NULL; - return our_gtk_type_table[i].typename; - } - } - return NULL; -} - /* hash of method -> name of signal prototype */ static GHashTable *marsh = NULL; @@ -673,7 +537,7 @@ add_signal_prots(Method *m) eq_signal_methods = g_list_prepend(eq_signal_methods,m); /* we know that we'll know all the gtktypes (so get_cast can't fail) */ - out_printf(out,"\ntypedef %s (*%s) (%s *, ", + out_printf(out,"\ntypedef %s (*___%s) (%s *, ", get_cast(m->gtktypes->data,FALSE),s, typebase); for(li=m->gtktypes->next;li;li=g_list_next(li)) @@ -688,14 +552,14 @@ add_signal_prots(Method *m) "{\n",s); if(strcmp(m->gtktypes->data,"NONE")==0) { - out_printf(out, "\t%s rfunc;\n\n" - "\trfunc = (%s)func;\n\n" + out_printf(out, "\t___%s rfunc;\n\n" + "\trfunc = (___%s)func;\n\n" "\t(*rfunc)((%s *)object",s,s,typebase); } else { - out_printf(out, "\t%s rfunc;\n\t",s); + out_printf(out, "\t___%s rfunc;\n\t",s); print_type(out,m->mtype,TRUE); out_printf(out, " *retval;\n\n" - "\trfunc = (%s)func;\n\n" + "\trfunc = (___%s)func;\n\n" "\tretval = GTK_RETLOC_%s(args[%d]);\n\n" "\t*retval = (*rfunc)((%s *)object", s,(char *)m->gtktypes->data, @@ -906,7 +770,7 @@ set_def_handlers(Class *c, char *oname) s,m->id); } else { if(m->cbuf) - out_printf(out,"\t%s->%s = _real_%s_%s;\n", + out_printf(out,"\t%s->%s = ___real_%s_%s;\n", oname,m->id,funcbase,m->id); else out_printf(out,"\t%s->%s = NULL;\n", @@ -1324,7 +1188,7 @@ put_method(Method *m) break; if(m->line_no>0) out_addline_infile(out,m->line_no); - print_method(out,"static ","\n_real_"," ","\n",m,FALSE); + print_method(out,"static ","\n___real_"," ","\n",m,FALSE); print_method_body(m,FALSE); break; case VIRTUAL_METHOD: @@ -1371,7 +1235,7 @@ put_method(Method *m) break; if(m->line_no>0) out_addline_infile(out,m->line_no); - print_method(out,"static ","\n_real_"," ","\n",m,FALSE); + print_method(out,"static ","\n___real_"," ","\n",m,FALSE); print_method_body(m,FALSE); break; case OVERRIDE_METHOD: @@ -1409,374 +1273,6 @@ put_method(Method *m) } } -static void -check_duplicate(Class *c, Node *node, char *id, int line_no) -{ - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - char *nid; - int nline_no; - char *s; - if(n->type == METHOD_NODE) { - Method *m = (Method *)n; - nid = m->id; - nline_no = m->line_no; - } else if(n->type == VARIABLE_NODE) { - Variable *v = (Variable *)n; - nid = v->id; - nline_no = v->line_no; - } else - continue; - if(n==node || - line_no>=nline_no || - strcmp(nid,id)!=0 || - n->type != node->type) - continue; - s = g_strdup_printf("symbol '%s' redefined, " - "first defined on line %d", - id,line_no); - print_error(FALSE,s,nline_no); - } -} - -static void -check_duplicate_symbols(Class *c) -{ - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) { - Method *m = (Method *)n; - check_duplicate(c,n,m->id,m->line_no); - } else if(n->type == VARIABLE_NODE) { - Variable *v = (Variable *)n; - check_duplicate(c,n,v->id,v->line_no); - } - } -} - -static void -check_bad_symbols(Class *c) -{ - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) { - Method *m = (Method *)n; - if((m->method == SIGNAL_LAST_METHOD || - m->method == SIGNAL_FIRST_METHOD || - m->method == VIRTUAL_METHOD) && - strcmp(m->id,"__parent__")==0) { - char *s; - s = g_strdup_printf("'%s' not allowed as an " - "identifier of signal " - "or virtual methods", - m->id); - print_error(FALSE,s,m->line_no); - g_free(s); - } - if(m->method != INIT_METHOD && - m->method != CLASS_INIT_METHOD && - (strcmp(m->id,"init")==0 || - strcmp(m->id,"class_init")==0)) { - print_error(FALSE,"init, or class_init not " - "allowed as an " - "identifier of non-" - "constructor methods",m->line_no); - } - } else if(n->type == VARIABLE_NODE) { - Variable *v = (Variable *)n; - if(strcmp(v->id,"_priv")==0 || - strcmp(v->id,"__parent__")==0) { - char *s; - s = g_strdup_printf("'%s' not allowed as a " - "data member name",v->id); - print_error(FALSE,s,v->line_no); - g_free(s); - } - } - } -} - - -static void -check_duplicate_named(Class *c,Node *node,char *id, int line_no) -{ - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - char *nid; - int nline_no; - char *s; - if(n->type == METHOD_NODE) { - Method *m = (Method *)n; - if(m->method == SIGNAL_LAST_METHOD || - m->method == SIGNAL_FIRST_METHOD) { - nid = m->id; - nline_no = m->line_no; - } else - continue; - } else if(n->type == ARGUMENT_NODE) { - Argument *a = (Argument *)n; - nid = a->name; - nline_no = a->line_no; - } else - continue; - if(n==node || - line_no>=nline_no || - strcmp(nid,id)!=0) - continue; - s = g_strdup_printf("named symbol (argument or signal) '%s' " - "redefined, first defined on line %d", - id,line_no); - print_error(FALSE,s,nline_no); - } -} - -static void -check_duplicate_signals_args(Class *c) -{ - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) { - Method *m = (Method *)n; - if(m->method == SIGNAL_LAST_METHOD || - m->method == SIGNAL_FIRST_METHOD) - check_duplicate_named(c,n,m->id,m->line_no); - } else if(n->type == ARGUMENT_NODE) { - Argument *a = (Argument *)n; - check_duplicate_named(c,n,a->name,a->line_no); - } - } -} - -static void -check_public_new(Class *c) -{ - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) { - Method *m = (Method *)n; - if((strcmp(m->id,"new")==0) && - (m->method != REGULAR_METHOD || - m->scope != PUBLIC_SCOPE)) - print_error(TRUE, - "'new' should be a regular\n" - "public method", - m->line_no); - } - } -} - -static void -check_vararg(Class *c) -{ - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) { - Method *m = (Method *)n; - if(!m->vararg) - continue; - if(m->method == OVERRIDE_METHOD || - m->method == SIGNAL_LAST_METHOD || - m->method == SIGNAL_FIRST_METHOD || - m->method == VIRTUAL_METHOD) { - print_error(FALSE, - "signals, overrides and virtuals, " - "can't have variable argument " - "lists", - m->line_no); - } - } - } -} - -static void -check_firstarg(Class *c) -{ - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) { - Method *m = (Method *)n; - if(m->args) - continue; - if(m->method == OVERRIDE_METHOD || - m->method == SIGNAL_LAST_METHOD || - m->method == SIGNAL_FIRST_METHOD || - m->method == VIRTUAL_METHOD) { - print_error(FALSE, - "signals, overrides and virtuals, " - "can't have no arguments", - m->line_no); - } - } - } -} - -static void -check_nonvoidempty(Class *c) -{ - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) { - Method *m = (Method *)n; - if(m->method != REGULAR_METHOD) - continue; - if(!(strcmp(m->mtype->name,"void")==0 && - m->mtype->stars == 0) && - !m->cbuf) { - print_error(TRUE, - "non-void empty method found, " - "regular non-void function should " - "not be empty.", - m->line_no); - /* add a body here, so that the user will also - get a warning from gcc, and so that it will - at least point him to the prototype of the - function in the .gob file */ - m->cbuf = g_strdup("/*empty*/"); - m->ccode_line = m->line_no; - } - } - } -} - -static void -check_signal_args(Class *c) -{ - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) { - Method *m = (Method *)n; - GList *l; - if(m->method != SIGNAL_LAST_METHOD && - m->method != SIGNAL_FIRST_METHOD) - continue; - - for(l=m->gtktypes;l;l=l->next) { - char *s; - if(get_cast(l->data,FALSE)) - continue; - s = g_strdup_printf("Unknown GTK+ type '%s' " - "among signal types", - (char *)l->data); - print_error(FALSE, s, m->line_no); - g_free(s); - } - } - } -} - -static void -check_argument_types(Class *c) -{ - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == ARGUMENT_NODE) { - Argument *a = (Argument *)n; - char *s; - if(get_cast(a->gtktype,FALSE)) - continue; - s = g_strdup_printf("Unknown GTK+ type '%s' " - "as argument type", - a->gtktype); - /* this could perhaps be a warning, but - can there really be a type beyond the - fundementals? */ - print_error(FALSE, s, a->line_no); - g_free(s); - } - } -} - -static int -count_signals(Class *c) -{ - int num = 0; - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) { - Method *m = (Method *)n; - if(m->method == SIGNAL_LAST_METHOD || - m->method == SIGNAL_FIRST_METHOD) - num++; - } - } - return num; -} - -static int -count_arguments(Class *c) -{ - int num = 0; - GList *li; - - for(li=c->nodes;li;li=g_list_next(li)) { - Node *n = li->data; - if(n->type == ARGUMENT_NODE) - num ++; - } - return num; -} - -static int -count_overrides(Class *c) -{ - int num = 0; - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) { - Method *m = (Method *)n; - if(m->method == OVERRIDE_METHOD) - num++; - } - } - return num; -} - -static int -count_privates(Class *c) -{ - int num = 0; - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == VARIABLE_NODE) { - Variable *v = (Variable *)n; - if(v->scope == PRIVATE_SCOPE) - num++; - } - } - return num; -} - -static int -count_protecteds(Class *c) -{ - int num = 0; - GList *l; - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) { - Method *m = (Method *)n; - if(m->scope == PROTECTED_SCOPE) - num++; - } - } - return num; -} - - static void open_files(void) { @@ -1906,13 +1402,237 @@ put_argument_gnu_wrappers(Class *c) } static void -generate_outfiles(void) +print_ccode_block(CCode *cc) +{ + FILE *fp; + switch(cc->cctype) { + case HT_CCODE: + /* HT code is printed exactly like normal header + code but is printed before */ + case H_CCODE: + fp = outh; + out_printf(fp,"\n"); + break; + default: + case C_CCODE: + fp = out; + out_printf(fp,"\n"); + out_addline_infile(fp,cc->line_no); + break; + case PH_CCODE: + if(outph) + fp = outph; + else + fp = out; + out_printf(fp,"\n"); + out_addline_infile(fp,cc->line_no); + break; + } + out_printf(fp,"%s\n",cc->cbuf); + if(cc->cctype == C_CCODE || + cc->cctype == PH_CCODE) + out_addline_outfile(fp); +} + +static void +print_class_block(Class *c) { - char *p; - GList *li; - time_t curtime; - gboolean found_header; + GList *l; + char *s; + + out_printf(out,"/* utility types we may need */\n"); + out_printf(out,"typedef struct { " + "gpointer a; gpointer b; " + "} ___twopointertype;\n"); + out_printf(out,"typedef struct { " + "gpointer a; gpointer b; " + "gpointer c; " + "} ___threepointertype;\n"); + + out_printf(outh,"\n#define %s\t" + "(%s_get_type())\n", + macrotype,funcbase); + out_printf(outh,"#define %s(obj)\t" + "GTK_CHECK_CAST((obj),%s_get_type(),%s)\n", + macrobase,funcbase,typebase); + out_printf(outh,"#define %s_CLASS(klass)\t" + "GTK_CHECK_CLASS_CAST((klass),%s_get_type(),%sClass)\n", + macrobase,funcbase,typebase); + out_printf(outh,"#define %s(obj)\t" + "GTK_CHECK_TYPE((obj), %s_get_type ())\n\n", + macrois,funcbase); + + /* argument wrapping macros */ + if(arguments>0 && !no_gnu) { + out_printf(outh,"\n#ifdef __GNUC__\n"); + put_argument_gnu_wrappers(c); + out_printf(outh,"#else /* __GNUC__ */\n"); + put_argument_nongnu_wrappers(c); + out_printf(outh,"#endif /* __GNUC__ */\n\n"); + } else if(arguments>0 && no_gnu) { + put_argument_nongnu_wrappers(c); + } + + if(privates>0) + out_printf(outh,"\ntypedef struct _%sPrivate %sPrivate;\n",typebase,typebase); + + s = replace_sep(c->otype,'_'); + g_strup(s); + out_printf(outh,"#ifndef __TYPEDEF_%s__\n" + "#define __TYPEDEF_%s__\n",s,s); + g_free(s); + out_printf(outh,"typedef struct _%s %s;\n" + "#endif\n",typebase,typebase); + out_printf(outh,"struct _%s {\n\t%s __parent__;\n", + typebase,ptypebase); + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + Variable *v = (Variable *)n; + if(n->type == VARIABLE_NODE && + v->scope == PUBLIC_SCOPE) + put_variable((Variable *)n,outh); + } + /* put protecteds always AFTER publics */ + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + Variable *v = (Variable *)n; + if(n->type == VARIABLE_NODE && + v->scope == PROTECTED_SCOPE) + put_variable((Variable *)n,outh); + } + if(privates>0) + out_printf(outh,"\t%sPrivate *_priv;\n",typebase); + out_printf(outh,"};\n"); + + if(privates>0) { + FILE *outfp; + + /* if we are to stick this into the private + header, if not stick it directly into the + C file */ + if(outph) + outfp = outph; + else + outfp = out; + + out_printf(outfp,"struct _%sPrivate {\n", + typebase); + for(l=c->nodes;l;l=l->next) { + Node *n = l->data; + Variable *v = (Variable *)n; + if(n->type == VARIABLE_NODE && + v->scope == PRIVATE_SCOPE) { + out_addline_infile(outfp,v->line_no); + put_variable(v,outfp); + } + } + out_addline_outfile(outfp); + out_printf(outfp,"};\n"); + } + + out_printf(outh,"\ntypedef struct _%sClass %sClass;\n", + typebase,typebase); + out_printf(outh, + "struct _%sClass {\n\t%sClass __parent__;\n", + typebase,ptypebase); + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) + put_vs_method((Method *)n); + } + out_printf(outh,"};\n\n"); + + out_printf(outh,"guint\t%s_get_type\t(void);\n",funcbase); + + out_printf(out,"/* here are local prototypes */\n"); + if(!no_gnu) { + out_printf(out,"#ifdef __GNUC__\n" + "#define ___NO_UNUSED_WARNING " + "__attribute__ ((__unused__))\n" + "#else /* __GNUC__ */\n" + "#define ___NO_UNUSED_WARNING\n" + "#endif /* __GNUC__ */\n"); + } + if(arguments>0) { + out_printf(out,"static void ___object_set_arg " + "(GtkObject *object, GtkArg *arg, " + "guint arg_id);\n" + "static void ___object_get_arg " + "(GtkObject *object, GtkArg *arg, " + "guint arg_id);\n"); + } + + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + put_pub_method((Method *)n); + put_prot_method((Method *)n); + put_priv_method_prot((Method *)n); + } + } + + if(signals>0) { + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) + add_signal_prots((Method *)n); + } + } + + if(!no_gnu) + out_printf(out,"#undef ___NO_UNUSED_WARNING\n"); + + add_enums(c); + + add_get_type(); + + if(no_gnu) + make_method_nongnu_aliases(c); + else { + out_printf(out,"\n#ifdef __GNUC__\n"); + make_method_gnu_aliases(c); + out_printf(out,"#else /* __GNUC__ */\n"); + make_method_nongnu_aliases(c); + out_printf(out,"#endif /* __GNUC__ */\n\n"); + } + out_printf(out,"#define GET_NEW (gtk_type_new(%s_get_type()))\n", + funcbase); + + add_inits(c); + + if(arguments>0) { + add_getset_arg(c, TRUE); + add_getset_arg(c, FALSE); + } + + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + put_method((Method *)n); + } + } + + out_printf(out,"#undef GET_NEW\n"); + + add_bad_hack_to_avoid_unused_warnings(c); +} + +static void +print_version_macros(void) +{ + int major=0,minor=0,pl=0; + sscanf(VERSION,"%d.%d.%d",&major,&minor,&pl); + + out_printf(out,"#define GOB_VERSION_MAJOR %d\n", major); + out_printf(out,"#define GOB_VERSION_MINOR %d\n", minor); + out_printf(out,"#define GOB_VERSION_PATCHLEVEL %d\n\n", pl); +} + +static void +print_file_comments(void) +{ + time_t curtime; time(&curtime); out_printf(outh,"/* Generated by GOB (v%s)" " (do not edit directly) */\n\n",VERSION); @@ -1921,36 +1641,14 @@ generate_outfiles(void) " (do not edit directly) */\n\n",VERSION); out_printf(out,"/* Generated by GOB (v%s) on %s" " (do not edit directly) */\n\n",VERSION,ctime(&curtime)); +} - { - int major=0,minor=0,pl=0; - sscanf(VERSION,"%d.%d.%d",&major,&minor,&pl); - - out_printf(out,"#define GOB_VERSION_MAJOR %d\n", major); - out_printf(out,"#define GOB_VERSION_MINOR %d\n", minor); - out_printf(out,"#define GOB_VERSION_PATCHLEVEL %d\n\n", pl); - } - - p = replace_sep(((Class *)class)->otype,'_'); - g_strup(p); - out_printf(outh,"#ifndef __%s_H__\n#define __%s_H__\n\n" - "#include \n\n",p,p); - if(outph) - out_printf(outph,"#ifndef __%s_PRIVATE_H__\n" - "#define __%s_PRIVATE_H__\n\n" - "#include \"%s.h\"\n\n",p,p,filebase); - g_free(p); +static void +print_includes(void) +{ + gboolean found_header; + char *p; - if(!for_cpp) { - out_printf(outh,"#ifdef __cplusplus\n" - "extern \"C\" {\n" - "#endif /* __cplusplus */\n\n"); - if(outph) - out_printf(outph,"#ifdef __cplusplus\n" - "extern \"C\" {\n" - "#endif /* __cplusplus */\n\n"); - } - p = g_strconcat(filebase,".h",NULL); found_header = TRUE; if(!g_list_find_custom(include_files,p,(GCompareFunc)strcmp)) { @@ -1978,208 +1676,43 @@ generate_outfiles(void) } g_free(p); } +} - for(li=nodes;li;li=g_list_next(li)) { - Node *node = li->data; - if(node->type == CCODE_NODE) { - CCode *cc = (CCode *)node; - FILE *fp; - if(cc->header) { - fp = outh; - out_printf(fp,"\n"); - } else { - fp = out; - out_printf(fp,"\n"); - out_addline_infile(fp,cc->line_no); - } - out_printf(fp,"%s\n",cc->cbuf); - if(!cc->header) - out_addline_outfile(fp); - } else if(node->type == CLASS_NODE) { - Class *c = (Class *)class; - GList *l; - - out_printf(out,"/* utility types we may need */\n"); - out_printf(out,"typedef struct { " - "gpointer a; gpointer b; " - "} ___twopointertype;\n"); - out_printf(out,"typedef struct { " - "gpointer a; gpointer b; " - "gpointer c; " - "} ___threepointertype;\n"); - - out_printf(outh,"\n#define %s\t" - "(%s_get_type())\n", - macrotype,funcbase); - out_printf(outh,"#define %s(obj)\t" - "GTK_CHECK_CAST((obj),%s_get_type(),%s)\n", - macrobase,funcbase,typebase); - out_printf(outh,"#define %s_CLASS(klass)\t" - "GTK_CHECK_CLASS_CAST((klass),%s_get_type(),%sClass)\n", - macrobase,funcbase,typebase); - out_printf(outh,"#define %s(obj)\t" - "GTK_CHECK_TYPE((obj), %s_get_type ())\n\n", - macrois,funcbase); - - /* argument wrapping macros */ - if(arguments>0 && !no_gnu) { - out_printf(outh,"\n#ifdef __GNUC__\n"); - put_argument_gnu_wrappers(c); - out_printf(outh,"#else /* __GNUC__ */\n"); - put_argument_nongnu_wrappers(c); - out_printf(outh,"#endif /* __GNUC__ */\n\n"); - } else if(arguments>0 && no_gnu) { - put_argument_nongnu_wrappers(c); - } - - if(privates>0) - out_printf(outh,"\ntypedef struct _%sPrivate %sPrivate;\n",typebase,typebase); - - out_printf(outh,"\ntypedef struct _%s %s;\n",typebase,typebase); - out_printf(outh,"struct _%s {\n\t%s __parent__;\n", - typebase,ptypebase); - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - Variable *v = (Variable *)n; - if(n->type == VARIABLE_NODE && - v->scope == PUBLIC_SCOPE) - put_variable((Variable *)n,outh); - } - /* put protecteds always AFTER publics */ - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - Variable *v = (Variable *)n; - if(n->type == VARIABLE_NODE && - v->scope == PROTECTED_SCOPE) - put_variable((Variable *)n,outh); - } - if(privates>0) - out_printf(outh,"\t%sPrivate *_priv;\n",typebase); - out_printf(outh,"};\n"); - - if(privates>0) { - FILE *outfp; - - /* if we are to stick this into the private - header, if not stick it directly into the - C file */ - if(outph) - outfp = outph; - else - outfp = out; - - out_printf(outfp,"struct _%sPrivate {\n", - typebase); - for(l=c->nodes;l;l=l->next) { - Node *n = l->data; - Variable *v = (Variable *)n; - if(n->type == VARIABLE_NODE && - v->scope == PRIVATE_SCOPE) { - out_addline_infile(outfp,v->line_no); - put_variable(v,outfp); - } - } - out_addline_outfile(outfp); - out_printf(outfp,"};\n"); - } - - out_printf(outh,"\ntypedef struct _%sClass %sClass;\n", - typebase,typebase); - out_printf(outh, - "struct _%sClass {\n\t%sClass __parent__;\n", - typebase,ptypebase); - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) - put_vs_method((Method *)n); - } - out_printf(outh,"};\n\n"); - - out_printf(outh,"guint\t%s_get_type\t(void);\n",funcbase); - - out_printf(out,"/* here are local prototypes */\n"); - if(!no_gnu) { - out_printf(out,"#ifdef __GNUC__\n" - "#define ___NO_UNUSED_WARNING " - "__attribute__ ((__unused__))\n" - "#else /* __GNUC__ */\n" - "#define ___NO_UNUSED_WARNING\n" - "#endif /* __GNUC__ */\n"); - } - if(arguments>0) { - out_printf(out,"static void ___object_set_arg " - "(GtkObject *object, GtkArg *arg, " - "guint arg_id);\n" - "static void ___object_get_arg " - "(GtkObject *object, GtkArg *arg, " - "guint arg_id);\n"); - } - - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) { - put_pub_method((Method *)n); - put_prot_method((Method *)n); - put_priv_method_prot((Method *)n); - } - } - - if(signals>0) { - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) - add_signal_prots((Method *)n); - } - } - - if(!no_gnu) - out_printf(out,"#undef ___NO_UNUSED_WARNING\n"); - - add_enums(c); - - add_get_type(); - - if(no_gnu) - make_method_nongnu_aliases(c); - else { - out_printf(out,"\n#ifdef __GNUC__\n"); - make_method_gnu_aliases(c); - out_printf(out,"#else /* __GNUC__ */\n"); - make_method_nongnu_aliases(c); - out_printf(out,"#endif /* __GNUC__ */\n\n"); - } - - out_printf(out,"#define GET_NEW (gtk_type_new(%s_get_type()))\n", - funcbase); - - add_inits(c); - - if(arguments>0) { - add_getset_arg(c, TRUE); - add_getset_arg(c, FALSE); - } - - for(l=c->nodes;l;l=g_list_next(l)) { - Node *n = l->data; - if(n->type == METHOD_NODE) { - put_method((Method *)n); - } - } +static void +print_header_prefixes(void) +{ + char *p; - out_printf(out,"#undef GET_NEW\n"); + p = replace_sep(((Class *)class)->otype,'_'); + g_strup(p); + out_printf(outh,"#ifndef __%s_H__\n#define __%s_H__\n\n",p,p); + if(outph) + out_printf(outph,"#ifndef __%s_PRIVATE_H__\n" + "#define __%s_PRIVATE_H__\n\n" + "#include \"%s.h\"\n\n",p,p,filebase); + g_free(p); - add_bad_hack_to_avoid_unused_warnings(c); - } else - g_assert_not_reached(); + if(!no_extern_c) { + out_printf(outh,"#ifdef __cplusplus\n" + "extern \"C\" {\n" + "#endif /* __cplusplus */\n\n"); + if(outph) + out_printf(outph,"#ifdef __cplusplus\n" + "extern \"C\" {\n" + "#endif /* __cplusplus */\n\n"); } +} - if(!for_cpp) +static void +print_header_postfixes(void) +{ + if(!no_extern_c) out_printf(outh,"\n#ifdef __cplusplus\n" "}\n" "#endif /* __cplusplus */\n"); out_printf(outh,"\n#endif"); if(outph) { - if(!for_cpp) + if(!no_extern_c) out_printf(outph,"\n#ifdef __cplusplus\n" "}\n" "#endif /* __cplusplus */\n"); @@ -2187,15 +1720,54 @@ generate_outfiles(void) } } -#if 0 static void -usage(poptContext optCon, int exitcode, char *error, char *addl) +print_header_top(void) +{ + GList *li; + + /* mandatory include */ + out_printf(outh,"#include \n\n"); + + /* print the HT_CCODE blocks */ + for(li=nodes;li;li=g_list_next(li)) { + Node *node = li->data; + if(node->type == CCODE_NODE) { + CCode *cc = (CCode *)node; + if(cc->cctype==HT_CCODE) + print_ccode_block((CCode *)node); + } + } +} + +static void +generate_outfiles(void) { - poptPrintUsage(optCon, stderr, 0); - if (error) fprintf(stderr, "%s: %s", error, addl); - exit(exitcode); + GList *li; + + print_file_comments(); + + print_header_top(); + + print_header_prefixes(); + + print_version_macros(); + + print_includes(); + + for(li=nodes;li;li=g_list_next(li)) { + Node *node = li->data; + if(node->type == CCODE_NODE) { + CCode *cc = (CCode *)node; + if(cc->cctype!=HT_CCODE) + print_ccode_block((CCode *)node); + } else if(node->type == CLASS_NODE) { + print_class_block((Class *)node); + } else + g_assert_not_reached(); + } + + print_header_postfixes(); } -#endif static void print_help(void) @@ -2207,6 +1779,8 @@ print_help(void) "\t--exit-on-warn,-w Exit with an error on warnings\n" "\t--no-exit-on-warn Don't exit on warnings [default]\n" "\t--for-cpp Create C++ files\n" + "\t--no-extern-c Never print extern \"C\" into the " + "header\n" "\t--no-gnu Never use GNU extentions\n" "\t--no-touch-headers Don't touch headers unless they " "really changed\n" @@ -2260,6 +1834,8 @@ parse_options(int argc, char *argv[]) no_private_header = TRUE; } else if(strcmp(argv[i],"--no-gnu")==0) { no_gnu = TRUE; + } else if(strcmp(argv[i],"--no-extern-c")==0) { + no_extern_c = TRUE; } else if(strcmp(argv[i],"--")==0) { /*further arguments are files*/ no_opts = TRUE; @@ -2323,37 +1899,6 @@ compare_and_move_header(void) int main(int argc, char *argv[]) { -#if 0 - int c; - poptContext optCon; - - struct poptOption optionsTable[] = { - { "exit-on-warn", 'w', 0, &exit_on_warn, 0, - "exit on warnings" }, - POPT_AUTOHELP - { NULL, 0, 0, NULL, 0 } - }; - - optCon = poptGetContext(NULL, argc, argv, optionsTable, 0); - poptSetOtherOptionHelp(optCon, "[OPTIONS]* [filename]"); - - while ((c = poptGetNextOpt(optCon)) >= 0) - ; - - filename = poptGetArg(optCon); - if(!(poptPeekArg(optCon) == NULL)) - usage(optCon, 1, "Specify only one file", - ".e.g., filename.gob"); - - if (c < -1) { - /* an error occurred during option processing */ - fprintf(stderr, "%s: %s\n", - poptBadOption(optCon, POPT_BADOPTION_NOALIAS), - poptStrerror(c)); - return 1; - } -#endif - parse_options(argc,argv); if(filename) { @@ -2410,8 +1955,5 @@ main(int argc, char *argv[]) if(no_touch_headers) compare_and_move_header(); -#if 0 - poptFreeContext(optCon); -#endif return 0; } diff --git a/src/main.h b/src/main.h index 404e693..b9f2c83 100644 --- a/src/main.h +++ b/src/main.h @@ -1,10 +1,23 @@ #ifndef _MAIN_H_ #define _MAIN_H_ -extern int exit_on_warn; -extern int exit_on_error; -extern int got_error; +extern gboolean no_touch_headers; +extern gboolean for_cpp; +extern gboolean no_gnu; +extern gboolean exit_on_warn; +extern gboolean exit_on_error; +extern gboolean got_error; +extern gboolean always_private_header; +extern gboolean no_private_header; +extern gboolean no_extern_c; + +extern char *filename; +extern char *filebase; + +extern FILE *out; +extern FILE *outh; +extern FILE *outph; + -void print_error(int is_warn, char *error,int line); #endif diff --git a/src/out.c b/src/out.c index 3fdf7cf..77dabd1 100644 --- a/src/out.c +++ b/src/out.c @@ -2,16 +2,9 @@ #include #include -#include "out.h" - -extern FILE *out; -extern FILE *outh; -extern FILE *outph; +#include "main.h" -extern gboolean for_cpp; - -extern char *filename; -extern char *filebase; +#include "out.h" int outline = 1; static gboolean in_out = TRUE; diff --git a/src/parse.c b/src/parse.c index 783037d..8aa1e4b 100644 --- a/src/parse.c +++ b/src/parse.c @@ -26,14 +26,16 @@ #define TYPETOKEN 276 #define ARRAY_DIM 277 #define CCODE 278 -#define HCODE 279 -#define PUBLIC 280 -#define PRIVATE 281 -#define PROTECTED 282 -#define ARGUMENT 283 -#define VIRTUAL 284 -#define SIGNAL 285 -#define OVERRIDE 286 +#define HTCODE 279 +#define PHCODE 280 +#define HCODE 281 +#define PUBLIC 282 +#define PRIVATE 283 +#define PROTECTED 284 +#define ARGUMENT 285 +#define VIRTUAL 286 +#define SIGNAL 287 +#define OVERRIDE 288 #line 21 "parse.y" @@ -45,11 +47,10 @@ #include "tree.h" #include "main.h" +#include "util.h" #define _(x) (x) -extern char *filename; - GList *nodes = NULL; static GList *class_nodes = NULL; @@ -216,7 +217,7 @@ push_self(char *id) } -#line 202 "parse.y" +#line 201 "parse.y" typedef union { char *id; GString *cbuf; @@ -238,26 +239,26 @@ typedef union { -#define YYFINAL 219 +#define YYFINAL 221 #define YYFLAG -32768 -#define YYNTBASE 46 +#define YYNTBASE 48 -#define YYTRANSLATE(x) ((unsigned)(x) <= 286 ? yytranslate[x] : 77) +#define YYTRANSLATE(x) ((unsigned)(x) <= 288 ? yytranslate[x] : 80) static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 44, 2, 2, 2, 2, 2, 2, 36, - 37, 39, 2, 40, 45, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 35, 42, - 43, 41, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 46, 2, 2, 2, 2, 2, 2, 38, + 39, 41, 2, 42, 47, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 37, 44, + 45, 43, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 33, 38, 34, 2, 2, 2, 2, 2, + 2, 2, 35, 40, 36, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -273,79 +274,80 @@ static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32 + 27, 28, 29, 30, 31, 32, 33, 34 }; #if YYDEBUG != 0 static const short yyprhs[] = { 0, - 0, 4, 7, 10, 12, 15, 18, 20, 22, 27, - 31, 36, 39, 42, 45, 47, 49, 51, 53, 55, - 57, 62, 68, 80, 89, 95, 97, 101, 102, 106, - 108, 110, 113, 115, 118, 121, 124, 126, 129, 132, - 134, 136, 138, 140, 143, 145, 147, 150, 152, 155, - 157, 159, 161, 163, 165, 168, 170, 173, 175, 179, - 183, 186, 188, 193, 197, 199, 202, 204, 214, 225, - 235, 245, 254, 266, 275, 281, 284, 288, 289, 291, - 293, 297, 299, 303, 305, 309, 311, 314, 318, 325, - 333, 336, 338, 340, 343, 346, 350, 354, 358, 362, - 364, 367 + 0, 4, 7, 10, 12, 14, 16, 18, 20, 23, + 25, 30, 34, 39, 42, 45, 48, 50, 52, 54, + 56, 58, 60, 65, 71, 83, 92, 98, 100, 104, + 105, 109, 111, 113, 116, 118, 121, 124, 127, 129, + 132, 135, 137, 139, 141, 143, 146, 148, 150, 153, + 155, 158, 160, 162, 164, 166, 168, 171, 173, 176, + 178, 182, 186, 189, 191, 196, 200, 202, 205, 207, + 217, 228, 238, 248, 257, 269, 278, 284, 287, 291, + 292, 294, 296, 300, 302, 306, 308, 312, 314, 317, + 321, 328, 336, 339, 341, 343, 346, 349, 353, 357, + 361, 365, 367, 370 }; -static const short yyrhs[] = { 47, - 48, 47, 0, 48, 47, 0, 47, 48, 0, 48, - 0, 47, 24, 0, 47, 25, 0, 24, 0, 25, - 0, 49, 33, 50, 34, 0, 49, 33, 34, 0, - 3, 22, 4, 22, 0, 50, 68, 0, 50, 52, - 0, 50, 53, 0, 68, 0, 52, 0, 53, 0, - 26, 0, 27, 0, 28, 0, 51, 57, 20, 35, - 0, 51, 57, 20, 23, 35, 0, 29, 55, 54, - 20, 20, 33, 24, 20, 33, 24, 35, 0, 29, - 55, 54, 20, 20, 33, 24, 35, 0, 20, 36, - 20, 57, 37, 0, 20, 0, 36, 56, 37, 0, - 0, 20, 38, 56, 0, 20, 0, 58, 0, 5, - 58, 0, 59, 0, 59, 62, 0, 12, 60, 0, - 11, 60, 0, 60, 0, 12, 18, 0, 11, 18, - 0, 18, 0, 17, 0, 16, 0, 20, 0, 61, - 20, 0, 22, 0, 6, 0, 13, 15, 0, 13, - 0, 14, 15, 0, 14, 0, 15, 0, 9, 0, - 8, 0, 7, 0, 39, 62, 0, 39, 0, 20, - 65, 0, 65, 0, 51, 20, 65, 0, 20, 51, - 65, 0, 51, 65, 0, 63, 0, 20, 36, 66, - 37, 0, 66, 40, 20, 0, 20, 0, 33, 24, - 0, 35, 0, 31, 64, 57, 20, 36, 70, 37, - 69, 67, 0, 51, 31, 63, 57, 20, 36, 70, - 37, 69, 67, 0, 30, 51, 57, 20, 36, 70, - 37, 69, 67, 0, 51, 30, 57, 20, 36, 70, - 37, 69, 67, 0, 30, 57, 20, 36, 70, 37, - 69, 67, 0, 32, 36, 22, 37, 57, 20, 36, - 70, 37, 69, 67, 0, 51, 57, 20, 36, 70, - 37, 69, 67, 0, 20, 36, 20, 37, 67, 0, - 19, 76, 0, 19, 33, 24, 0, 0, 6, 0, - 20, 0, 20, 40, 71, 0, 71, 0, 72, 40, - 10, 0, 72, 0, 72, 40, 73, 0, 73, 0, - 57, 20, 0, 57, 20, 23, 0, 57, 20, 36, - 20, 74, 37, 0, 57, 20, 23, 36, 20, 74, - 37, 0, 74, 75, 0, 75, 0, 20, 0, 41, - 76, 0, 42, 76, 0, 41, 43, 76, 0, 42, - 43, 76, 0, 43, 43, 76, 0, 44, 43, 76, - 0, 21, 0, 45, 21, 0, 20, 0 +static const short yyrhs[] = { 50, + 51, 50, 0, 51, 50, 0, 50, 51, 0, 51, + 0, 24, 0, 27, 0, 25, 0, 26, 0, 50, + 49, 0, 49, 0, 52, 35, 53, 36, 0, 52, + 35, 36, 0, 3, 22, 4, 22, 0, 53, 71, + 0, 53, 55, 0, 53, 56, 0, 71, 0, 55, + 0, 56, 0, 28, 0, 29, 0, 30, 0, 54, + 60, 20, 37, 0, 54, 60, 20, 23, 37, 0, + 31, 58, 57, 20, 20, 35, 24, 20, 35, 24, + 37, 0, 31, 58, 57, 20, 20, 35, 24, 37, + 0, 20, 38, 20, 60, 39, 0, 20, 0, 38, + 59, 39, 0, 0, 20, 40, 59, 0, 20, 0, + 61, 0, 5, 61, 0, 62, 0, 62, 65, 0, + 12, 63, 0, 11, 63, 0, 63, 0, 12, 18, + 0, 11, 18, 0, 18, 0, 17, 0, 16, 0, + 20, 0, 64, 20, 0, 22, 0, 6, 0, 13, + 15, 0, 13, 0, 14, 15, 0, 14, 0, 15, + 0, 9, 0, 8, 0, 7, 0, 41, 65, 0, + 41, 0, 20, 68, 0, 68, 0, 54, 20, 68, + 0, 20, 54, 68, 0, 54, 68, 0, 66, 0, + 20, 38, 69, 39, 0, 69, 42, 20, 0, 20, + 0, 35, 24, 0, 37, 0, 33, 67, 60, 20, + 38, 73, 39, 72, 70, 0, 54, 33, 66, 60, + 20, 38, 73, 39, 72, 70, 0, 32, 54, 60, + 20, 38, 73, 39, 72, 70, 0, 54, 32, 60, + 20, 38, 73, 39, 72, 70, 0, 32, 60, 20, + 38, 73, 39, 72, 70, 0, 34, 38, 22, 39, + 60, 20, 38, 73, 39, 72, 70, 0, 54, 60, + 20, 38, 73, 39, 72, 70, 0, 20, 38, 20, + 39, 70, 0, 19, 79, 0, 19, 35, 24, 0, + 0, 6, 0, 20, 0, 20, 42, 74, 0, 74, + 0, 75, 42, 10, 0, 75, 0, 75, 42, 76, + 0, 76, 0, 60, 20, 0, 60, 20, 23, 0, + 60, 20, 38, 20, 77, 39, 0, 60, 20, 23, + 38, 20, 77, 39, 0, 77, 78, 0, 78, 0, + 20, 0, 43, 79, 0, 44, 79, 0, 43, 45, + 79, 0, 44, 45, 79, 0, 45, 45, 79, 0, + 46, 45, 79, 0, 21, 0, 47, 21, 0, 20, + 0 }; #endif #if YYDEBUG != 0 static const short yyrline[] = { 0, - 221, 222, 223, 224, 227, 233, 238, 244, 251, 256, - 263, 268, 269, 270, 271, 272, 273, 276, 277, 278, - 281, 284, 288, 323, 353, 362, 368, 369, 372, 375, - 381, 382, 390, 394, 401, 404, 407, 410, 413, 416, - 419, 422, 425, 428, 432, 435, 440, 443, 446, 449, - 452, 457, 460, 463, 468, 469, 473, 485, 491, 503, - 515, 518, 524, 529, 532, 537, 538, 542, 552, 562, - 572, 582, 592, 598, 603, 624, 625, 629, 632, 633, - 644, 654, 657, 658, 661, 662, 665, 668, 671, 679, - 689, 690, 693, 706, 710, 714, 718, 722, 726, 732, - 733, 737 + 220, 221, 222, 223, 226, 232, 238, 244, 252, 253, + 256, 261, 268, 273, 274, 275, 276, 277, 278, 281, + 282, 283, 286, 289, 293, 328, 358, 367, 373, 374, + 377, 380, 386, 387, 395, 399, 406, 409, 412, 415, + 418, 421, 424, 427, 430, 433, 437, 440, 445, 448, + 451, 454, 457, 462, 465, 468, 473, 474, 478, 490, + 496, 508, 520, 523, 529, 534, 537, 542, 543, 547, + 557, 567, 577, 587, 597, 603, 608, 629, 630, 634, + 637, 638, 649, 659, 662, 663, 666, 667, 670, 673, + 676, 684, 694, 695, 698, 711, 715, 719, 723, 727, + 731, 737, 738, 742 }; #endif @@ -355,178 +357,188 @@ static const short yyrline[] = { 0, static const char * const yytname[] = { "$","error","$undefined.","CLASS", "FROM","CONST","VOID","STRUCT","UNION","ENUM","THREEDOTS","SIGNED","UNSIGNED", "LONG","SHORT","INT","FLOAT","DOUBLE","CHAR","ONERROR","TOKEN","NUMBER","TYPETOKEN", -"ARRAY_DIM","CCODE","HCODE","PUBLIC","PRIVATE","PROTECTED","ARGUMENT","VIRTUAL", -"SIGNAL","OVERRIDE","'{'","'}'","';'","'('","')'","'|'","'*'","','","'>'","'<'", -"'='","'!'","'-'","prog","ccodes","class","classdec","classcode","scope","variable", -"argument","argtype","argflags","flaglist","type","type1","type2","integer", -"tspecifier","stars","simplesigtype","fullsigtype","sigtype","tokenlist","codenocode", -"method","onerror","funcargs","arglist","arglist1","arg","checklist","check", -"numtok", NULL +"ARRAY_DIM","CCODE","HTCODE","PHCODE","HCODE","PUBLIC","PRIVATE","PROTECTED", +"ARGUMENT","VIRTUAL","SIGNAL","OVERRIDE","'{'","'}'","';'","'('","')'","'|'", +"'*'","','","'>'","'<'","'='","'!'","'-'","prog","ccode","ccodes","class","classdec", +"classcode","scope","variable","argument","argtype","argflags","flaglist","type", +"type1","type2","integer","tspecifier","stars","simplesigtype","fullsigtype", +"sigtype","tokenlist","codenocode","method","onerror","funcargs","arglist","arglist1", +"arg","checklist","check","numtok", NULL }; #endif static const short yyr1[] = { 0, - 46, 46, 46, 46, 47, 47, 47, 47, 48, 48, - 49, 50, 50, 50, 50, 50, 50, 51, 51, 51, - 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, - 57, 57, 58, 58, 59, 59, 59, 59, 59, 59, - 59, 59, 59, 59, 59, 59, 60, 60, 60, 60, - 60, 61, 61, 61, 62, 62, 63, 63, 64, 64, - 64, 64, 65, 66, 66, 67, 67, 68, 68, 68, - 68, 68, 68, 68, 68, 69, 69, 69, 70, 70, - 70, 70, 71, 71, 72, 72, 73, 73, 73, 73, - 74, 74, 75, 75, 75, 75, 75, 75, 75, 76, - 76, 76 + 48, 48, 48, 48, 49, 49, 49, 49, 50, 50, + 51, 51, 52, 53, 53, 53, 53, 53, 53, 54, + 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, + 59, 59, 60, 60, 61, 61, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 63, 63, + 63, 63, 63, 64, 64, 64, 65, 65, 66, 66, + 67, 67, 67, 67, 68, 69, 69, 70, 70, 71, + 71, 71, 71, 71, 71, 71, 71, 72, 72, 72, + 73, 73, 73, 73, 74, 74, 75, 75, 76, 76, + 76, 76, 77, 77, 78, 78, 78, 78, 78, 78, + 78, 79, 79, 79 }; static const short yyr2[] = { 0, - 3, 2, 2, 1, 2, 2, 1, 1, 4, 3, - 4, 2, 2, 2, 1, 1, 1, 1, 1, 1, - 4, 5, 11, 8, 5, 1, 3, 0, 3, 1, - 1, 2, 1, 2, 2, 2, 1, 2, 2, 1, - 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, - 1, 1, 1, 1, 2, 1, 2, 1, 3, 3, - 2, 1, 4, 3, 1, 2, 1, 9, 10, 9, - 9, 8, 11, 8, 5, 2, 3, 0, 1, 1, - 3, 1, 3, 1, 3, 1, 2, 3, 6, 7, - 2, 1, 1, 2, 2, 3, 3, 3, 3, 1, - 2, 1 + 3, 2, 2, 1, 1, 1, 1, 1, 2, 1, + 4, 3, 4, 2, 2, 2, 1, 1, 1, 1, + 1, 1, 4, 5, 11, 8, 5, 1, 3, 0, + 3, 1, 1, 2, 1, 2, 2, 2, 1, 2, + 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, + 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, + 3, 3, 2, 1, 4, 3, 1, 2, 1, 9, + 10, 9, 9, 8, 11, 8, 5, 2, 3, 0, + 1, 1, 3, 1, 3, 1, 3, 1, 2, 3, + 6, 7, 2, 1, 1, 2, 2, 3, 3, 3, + 3, 1, 2, 1 }; static const short yydefact[] = { 0, - 0, 7, 8, 0, 4, 0, 0, 5, 6, 3, - 2, 0, 0, 1, 0, 18, 19, 20, 28, 0, - 0, 0, 10, 0, 0, 16, 17, 15, 11, 0, - 0, 0, 0, 46, 54, 53, 52, 0, 0, 48, - 50, 51, 42, 41, 40, 43, 45, 0, 0, 31, - 33, 37, 0, 0, 0, 62, 0, 58, 0, 9, - 13, 14, 12, 0, 0, 0, 0, 30, 0, 26, - 0, 32, 39, 36, 38, 35, 47, 49, 0, 0, - 56, 34, 44, 0, 0, 0, 57, 0, 61, 0, - 0, 0, 0, 0, 0, 0, 0, 27, 0, 0, - 0, 0, 55, 65, 0, 60, 59, 0, 0, 0, - 0, 0, 21, 0, 0, 67, 75, 29, 0, 0, - 0, 46, 43, 0, 0, 82, 84, 86, 63, 0, - 0, 0, 0, 0, 22, 0, 66, 0, 0, 0, - 0, 87, 78, 0, 64, 0, 0, 0, 0, 78, - 25, 0, 78, 81, 88, 0, 0, 0, 83, 85, - 78, 0, 78, 0, 0, 0, 24, 0, 0, 0, - 102, 100, 0, 0, 76, 72, 0, 0, 0, 78, - 74, 0, 70, 0, 93, 0, 0, 0, 0, 0, - 92, 77, 101, 68, 78, 71, 0, 0, 0, 0, - 94, 0, 95, 0, 0, 89, 91, 0, 69, 23, - 90, 96, 97, 98, 99, 73, 0, 0, 0 + 0, 5, 7, 8, 6, 10, 0, 4, 0, 0, + 9, 3, 2, 0, 0, 1, 0, 20, 21, 22, + 30, 0, 0, 0, 12, 0, 0, 18, 19, 17, + 13, 0, 0, 0, 0, 48, 56, 55, 54, 0, + 0, 50, 52, 53, 44, 43, 42, 45, 47, 0, + 0, 33, 35, 39, 0, 0, 0, 64, 0, 60, + 0, 11, 15, 16, 14, 0, 0, 0, 0, 32, + 0, 28, 0, 34, 41, 38, 40, 37, 49, 51, + 0, 0, 58, 36, 46, 0, 0, 0, 59, 0, + 63, 0, 0, 0, 0, 0, 0, 0, 0, 29, + 0, 0, 0, 0, 57, 67, 0, 62, 61, 0, + 0, 0, 0, 0, 23, 0, 0, 69, 77, 31, + 0, 0, 0, 48, 45, 0, 0, 84, 86, 88, + 65, 0, 0, 0, 0, 0, 24, 0, 68, 0, + 0, 0, 0, 89, 80, 0, 66, 0, 0, 0, + 0, 80, 27, 0, 80, 83, 90, 0, 0, 0, + 85, 87, 80, 0, 80, 0, 0, 0, 26, 0, + 0, 0, 104, 102, 0, 0, 78, 74, 0, 0, + 0, 80, 76, 0, 72, 0, 95, 0, 0, 0, + 0, 0, 94, 79, 103, 70, 80, 73, 0, 0, + 0, 0, 96, 0, 97, 0, 0, 91, 93, 0, + 71, 25, 92, 98, 99, 100, 101, 75, 0, 0, + 0 }; -static const short yydefgoto[] = { 217, - 4, 5, 6, 24, 25, 26, 27, 71, 32, 69, - 124, 50, 51, 52, 53, 82, 56, 57, 58, 105, - 117, 28, 158, 125, 126, 127, 128, 190, 191, 175 +static const short yydefgoto[] = { 219, + 6, 7, 8, 9, 26, 27, 28, 29, 73, 34, + 71, 126, 52, 53, 54, 55, 84, 58, 59, 60, + 107, 119, 30, 160, 127, 128, 129, 130, 192, 193, + 177 }; -static const short yypact[] = { 69, - -13,-32768,-32768, 73, 89, -19, 17,-32768,-32768, 89, - 125, 216, 11, 125, 6,-32768,-32768,-32768, 46, 115, - 120, 50,-32768, 229, 53,-32768,-32768,-32768,-32768, 68, - 76, 81, 206,-32768,-32768,-32768,-32768, 251, 257, 92, - 110,-32768,-32768,-32768,-32768,-32768,-32768, 171, 131,-32768, - 114,-32768, 135, 205, 152,-32768, 171,-32768, 159,-32768, --32768,-32768,-32768, 171, 154, 170, 155, 161, 173, 172, - 196,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 207, 193, - 114,-32768,-32768, 194, 214, 215,-32768, -10,-32768, 217, - 201, 219, -10, 171, 56, 101, 76,-32768, 220, 231, - 218, 189,-32768,-32768, -5,-32768,-32768, 226, 171, 232, - 233, 238,-32768, 189, 228,-32768,-32768,-32768, 171, 234, - 189, 237, 16, 256, 240,-32768, 239,-32768,-32768, 258, - 189, 260, 189, 245,-32768, 246,-32768, 247, 261, 249, - 171, -7, 263, 153,-32768, 250, 252, 253, 189, 263, --32768, -8, 263,-32768, 255, 269, 10, 101,-32768,-32768, - 263, 189, 263, 259, 101, 262,-32768, 101, 272, 4, --32768,-32768, 270, 276,-32768,-32768, 101, 264, 101, 263, --32768, 274,-32768, 4,-32768, 57, 60, 265, 266, 67, --32768,-32768,-32768,-32768, 263,-32768, 101, 267, 75, 18, --32768, 18,-32768, 18, 18,-32768,-32768, 101,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768, 293, 299,-32768 +static const short yypact[] = { 21, + -12,-32768,-32768,-32768,-32768,-32768, 21, 238, 0, 39, +-32768, 238, 238, 202, 41, 238, 84,-32768,-32768,-32768, + 100, 112, 117, 101,-32768, 217, 53,-32768,-32768,-32768, +-32768, 74, 81, 123, 203,-32768,-32768,-32768,-32768, 226, + 241, 129, 133,-32768,-32768,-32768,-32768,-32768,-32768, 168, + 130,-32768, 111,-32768, 149, 1, 151,-32768, 168,-32768, + 156,-32768,-32768,-32768,-32768, 168, 167, 169, 157, 165, + 174, 188, 187,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + 208, 191, 111,-32768,-32768, 204, 223, 237,-32768, -6, +-32768, 240, 227, 247, -6, 168, 55, 96, 81,-32768, + 248, 249, 232, 186,-32768,-32768, -30,-32768,-32768, 233, + 168, 234, 253, 239,-32768, 186, 250,-32768,-32768,-32768, + 168, 242, 186, 236, 185, 258, 243,-32768, 244,-32768, +-32768, 259, 186, 260, 186, 246,-32768, 251,-32768, 252, + 257, 254, 168, 64, 264, 150,-32768, 255, 261, 256, + 186, 264,-32768, -4, 264,-32768, 262, 265, 56, 96, +-32768,-32768, 264, 186, 264, 263, 96, 266,-32768, 96, + 267, 52,-32768,-32768, 268, 275,-32768,-32768, 96, 269, + 96, 264,-32768, 273,-32768, 52,-32768, 35, 63, 270, + 271, 61,-32768,-32768,-32768,-32768, 264,-32768, 96, 272, + 70, 6,-32768, 6,-32768, 6, 6,-32768,-32768, 96, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 288, 289, +-32768 }; static const short yypgoto[] = {-32768, - 80, 296,-32768,-32768, -18, 279, 280,-32768,-32768, 208, - -20, 273,-32768, 106,-32768, 230, 242,-32768, -36,-32768, - -157, 286, -146, -108, 174,-32768, 168, 129, -84, -48 + 245, 30, 291,-32768,-32768, -20, 277, 278,-32768,-32768, + 206, -22, 276,-32768, 71,-32768, 224, 274,-32768, -38, +-32768, -159, 280, -148, -110, 170,-32768, 164, 126, -113, + -53 }; -#define YYLAST 315 - - -static const short yytable[] = { 49, - 176, 48, 55, 165, 66, 136, 168, 181, 7, 84, - 183, 166, 140, 12, 177, 155, 179, 87, 89, 194, - 13, 196, 146, 185, 148, 85, 167, 79, 156, 171, - 172, 129, 29, 197, 130, 86, 90, 171, 172, 209, - 164, 30, 173, 92, 186, 187, 188, 189, 208, 106, - 216, 107, -80, 178, 174, 141, 87, 33, 34, 35, - 36, 37, 174, 38, 39, 40, 41, 42, 43, 44, - 45, 1, 46, 111, 47, 1, 171, 172, 112, 171, - 172, 31, 64, 65, 11, 59, 185, 67, 132, 14, - 113, 114, 2, 3, 185, 68, 8, 9, 138, 200, - 70, 174, 202, 206, 174, 207, 77, 186, 187, 188, - 189, 211, 2, 3, 207, 186, 187, 188, 189, 33, - 34, 35, 36, 37, 78, 38, 39, 40, 41, 42, - 43, 44, 45, 115, 46, 116, 47, 201, 203, 54, - 16, 17, 18, 74, 76, 16, 17, 18, 8, 9, - 80, 212, 81, 213, 83, 214, 215, 33, 34, 35, - 36, 37, 159, 38, 39, 40, 41, 42, 43, 44, - 45, 88, 46, 93, 47, 33, 34, 35, 36, 37, - 91, 38, 39, 40, 41, 42, 43, 44, 45, 95, - 46, 96, 47, 33, 122, 35, 36, 37, 97, 38, - 39, 40, 41, 42, 43, 44, 45, 99, 123, 98, - 47, 34, 35, 36, 37, 100, 38, 39, 40, 41, - 42, 43, 44, 45, 84, 46, 101, 47, 102, 85, - 16, 17, 18, 104, 84, 15, 108, 109, 110, 119, - 85, 16, 17, 18, 19, 20, 21, 22, 15, 23, - 120, 137, 134, 121, 16, 17, 18, 19, 20, 21, - 22, 131, 60, 40, 41, 42, 139, 133, 73, 40, - 41, 42, 135, -79, 75, 142, 143, 145, 144, 147, - 149, 157, 150, 151, 152, 153, 161, 162, 170, 163, - 169, 184, 218, 192, 182, 180, 193, 198, 219, 10, - 195, 210, 61, 62, 118, 72, 94, 204, 205, 63, - 103, 160, 199, 0, 154 +#define YYLAST 341 + + +static const short yytable[] = { 51, + 178, 50, 57, 167, 68, 138, 170, 183, 131, 10, + 185, 132, 142, 86, 179, 168, 181, 89, 91, 196, + 86, 198, 148, 1, 150, 173, 174, 81, 18, 19, + 20, 87, 169, 199, 14, 88, 92, 13, 87, 211, + 166, 16, 15, 94, 2, 3, 4, 5, 210, 108, + 218, 109, 176, 180, 173, 174, 89, 35, 36, 37, + 38, 39, 31, 40, 41, 42, 43, 44, 45, 46, + 47, 187, 48, 113, 49, 173, 174, 114, 209, 202, + 187, 176, 173, 174, 66, 67, 157, 209, 134, 187, + 175, 115, 116, 69, 188, 189, 190, 191, 140, 208, + 70, 158, 176, 188, 189, 190, 191, 204, 213, 176, + 76, 78, 188, 189, 190, 191, 35, 36, 37, 38, + 39, 32, 40, 41, 42, 43, 44, 45, 46, 47, + 117, 48, 118, 49, 203, 205, 56, 33, 61, 18, + 19, 20, 72, 79, 18, 19, 20, 80, 214, 82, + 215, 83, 216, 217, 35, 36, 37, 38, 39, 161, + 40, 41, 42, 43, 44, 45, 46, 47, 85, 48, + 90, 49, 35, 36, 37, 38, 39, 93, 40, 41, + 42, 43, 44, 45, 46, 47, 95, 48, 97, 49, + 35, 124, 37, 38, 39, 98, 40, 41, 42, 43, + 44, 45, 46, 47, 99, 125, 102, 49, 36, 37, + 38, 39, 100, 40, 41, 42, 43, 44, 45, 46, + 47, 17, 48, -82, 49, 101, 143, 103, 104, 18, + 19, 20, 21, 22, 23, 24, 17, 25, 42, 43, + 44, 87, 106, 75, 18, 19, 20, 21, 22, 23, + 24, 11, 62, 42, 43, 44, 86, 11, 77, 110, + 11, 2, 3, 4, 5, 111, 112, 121, 122, 123, + 133, 135, 136, 139, -81, 137, 141, 144, 147, 149, + 154, 145, 159, 151, 172, 146, 186, 220, 221, 152, + 153, 194, 155, 163, 165, 195, 200, 12, 164, 171, + 184, 182, 63, 64, 120, 65, 105, 197, 212, 162, + 74, 201, 156, 0, 206, 207, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 96 }; -static const short yycheck[] = { 20, - 158, 20, 21, 150, 25, 114, 153, 165, 22, 20, - 168, 20, 121, 33, 161, 23, 163, 54, 55, 177, - 4, 179, 131, 20, 133, 36, 35, 48, 36, 20, - 21, 37, 22, 180, 40, 54, 57, 20, 21, 197, - 149, 36, 33, 64, 41, 42, 43, 44, 195, 86, - 208, 88, 37, 162, 45, 40, 93, 5, 6, 7, - 8, 9, 45, 11, 12, 13, 14, 15, 16, 17, - 18, 3, 20, 94, 22, 3, 20, 21, 23, 20, - 21, 36, 30, 31, 5, 36, 20, 20, 109, 10, - 35, 36, 24, 25, 20, 20, 24, 25, 119, 43, - 20, 45, 43, 37, 45, 190, 15, 41, 42, 43, - 44, 37, 24, 25, 199, 41, 42, 43, 44, 5, - 6, 7, 8, 9, 15, 11, 12, 13, 14, 15, - 16, 17, 18, 33, 20, 35, 22, 186, 187, 20, - 26, 27, 28, 38, 39, 26, 27, 28, 24, 25, - 20, 200, 39, 202, 20, 204, 205, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 20, 20, 20, 22, 5, 6, 7, 8, 9, - 22, 11, 12, 13, 14, 15, 16, 17, 18, 20, - 20, 37, 22, 5, 6, 7, 8, 9, 38, 11, - 12, 13, 14, 15, 16, 17, 18, 36, 20, 37, - 22, 6, 7, 8, 9, 20, 11, 12, 13, 14, - 15, 16, 17, 18, 20, 20, 20, 22, 36, 36, - 26, 27, 28, 20, 20, 20, 20, 37, 20, 20, - 36, 26, 27, 28, 29, 30, 31, 32, 20, 34, - 20, 24, 20, 36, 26, 27, 28, 29, 30, 31, - 32, 36, 34, 13, 14, 15, 33, 36, 18, 13, - 14, 15, 35, 37, 18, 20, 37, 20, 40, 20, - 36, 19, 37, 37, 24, 37, 37, 36, 20, 37, - 36, 20, 0, 24, 33, 37, 21, 24, 0, 4, - 37, 35, 24, 24, 97, 33, 65, 43, 43, 24, - 81, 144, 184, -1, 141 +static const short yycheck[] = { 22, + 160, 22, 23, 152, 27, 116, 155, 167, 39, 22, + 170, 42, 123, 20, 163, 20, 165, 56, 57, 179, + 20, 181, 133, 3, 135, 20, 21, 50, 28, 29, + 30, 38, 37, 182, 35, 56, 59, 8, 38, 199, + 151, 12, 4, 66, 24, 25, 26, 27, 197, 88, + 210, 90, 47, 164, 20, 21, 95, 5, 6, 7, + 8, 9, 22, 11, 12, 13, 14, 15, 16, 17, + 18, 20, 20, 96, 22, 20, 21, 23, 192, 45, + 20, 47, 20, 21, 32, 33, 23, 201, 111, 20, + 35, 37, 38, 20, 43, 44, 45, 46, 121, 39, + 20, 38, 47, 43, 44, 45, 46, 45, 39, 47, + 40, 41, 43, 44, 45, 46, 5, 6, 7, 8, + 9, 38, 11, 12, 13, 14, 15, 16, 17, 18, + 35, 20, 37, 22, 188, 189, 20, 38, 38, 28, + 29, 30, 20, 15, 28, 29, 30, 15, 202, 20, + 204, 41, 206, 207, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 20, 20, + 20, 22, 5, 6, 7, 8, 9, 22, 11, 12, + 13, 14, 15, 16, 17, 18, 20, 20, 20, 22, + 5, 6, 7, 8, 9, 39, 11, 12, 13, 14, + 15, 16, 17, 18, 40, 20, 20, 22, 6, 7, + 8, 9, 39, 11, 12, 13, 14, 15, 16, 17, + 18, 20, 20, 39, 22, 38, 42, 20, 38, 28, + 29, 30, 31, 32, 33, 34, 20, 36, 13, 14, + 15, 38, 20, 18, 28, 29, 30, 31, 32, 33, + 34, 7, 36, 13, 14, 15, 20, 13, 18, 20, + 16, 24, 25, 26, 27, 39, 20, 20, 20, 38, + 38, 38, 20, 24, 39, 37, 35, 20, 20, 20, + 24, 39, 19, 38, 20, 42, 20, 0, 0, 39, + 39, 24, 39, 39, 39, 21, 24, 7, 38, 38, + 35, 39, 26, 26, 99, 26, 83, 39, 37, 146, + 35, 186, 143, -1, 45, 45, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 67 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "/usr/lib/bison.simple" @@ -1072,34 +1084,35 @@ yyreduce: switch (yyn) { case 1: -#line 221 "parse.y" +#line 220 "parse.y" { ; ; break;} case 2: -#line 222 "parse.y" +#line 221 "parse.y" { ; ; break;} case 3: -#line 223 "parse.y" +#line 222 "parse.y" { ; ; break;} case 4: -#line 224 "parse.y" +#line 223 "parse.y" { ; ; break;} case 5: -#line 227 "parse.y" +#line 226 "parse.y" { - Node *node = new_ccode(FALSE,(yyvsp[0].cbuf)->str, + Node *node = new_ccode(C_CCODE,(yyvsp[0].cbuf)->str, ccode_line); nodes = g_list_append(nodes,node); g_string_free(yyvsp[0].cbuf,FALSE); ; break;} case 6: -#line 233 "parse.y" +#line 232 "parse.y" { - Node *node = new_ccode(TRUE,(yyvsp[0].cbuf)->str,ccode_line); + Node *node = new_ccode(H_CCODE,(yyvsp[0].cbuf)->str, + ccode_line); nodes = g_list_append(nodes,node); g_string_free(yyvsp[0].cbuf,FALSE); ; @@ -1107,7 +1120,7 @@ case 6: case 7: #line 238 "parse.y" { - Node *node = new_ccode(FALSE,(yyvsp[0].cbuf)->str, + Node *node = new_ccode(HT_CCODE,(yyvsp[0].cbuf)->str, ccode_line); nodes = g_list_append(nodes,node); g_string_free(yyvsp[0].cbuf,FALSE); @@ -1116,83 +1129,92 @@ case 7: case 8: #line 244 "parse.y" { - Node *node = new_ccode(TRUE,(yyvsp[0].cbuf)->str,ccode_line); + Node *node = new_ccode(PH_CCODE,(yyvsp[0].cbuf)->str, + ccode_line); nodes = g_list_append(nodes,node); g_string_free(yyvsp[0].cbuf,FALSE); ; break;} case 9: -#line 251 "parse.y" +#line 252 "parse.y" +{ ; ; + break;} +case 10: +#line 253 "parse.y" +{ ; ; + break;} +case 11: +#line 256 "parse.y" { ((Class *)class)->nodes = class_nodes; class_nodes = NULL; nodes = g_list_append(nodes,class); ; break;} -case 10: -#line 256 "parse.y" +case 12: +#line 261 "parse.y" { ((Class *)class)->nodes = NULL; class_nodes = NULL; nodes = g_list_append(nodes,class); ; break;} -case 11: -#line 263 "parse.y" +case 13: +#line 268 "parse.y" { class = new_class(yyvsp[-2].id,yyvsp[0].id,NULL); ; break;} -case 12: -#line 268 "parse.y" -{ ; ; - break;} -case 13: -#line 269 "parse.y" -{ ; ; - break;} case 14: -#line 270 "parse.y" +#line 273 "parse.y" { ; ; break;} case 15: -#line 271 "parse.y" +#line 274 "parse.y" { ; ; break;} case 16: -#line 272 "parse.y" +#line 275 "parse.y" { ; ; break;} case 17: -#line 273 "parse.y" +#line 276 "parse.y" { ; ; break;} case 18: -#line 276 "parse.y" -{ the_scope = PUBLIC_SCOPE; ; +#line 277 "parse.y" +{ ; ; break;} case 19: -#line 277 "parse.y" -{ the_scope = PRIVATE_SCOPE; ; +#line 278 "parse.y" +{ ; ; break;} case 20: -#line 278 "parse.y" -{ the_scope = PROTECTED_SCOPE; ; +#line 281 "parse.y" +{ the_scope = PUBLIC_SCOPE; ; break;} case 21: -#line 281 "parse.y" +#line 282 "parse.y" +{ the_scope = PRIVATE_SCOPE; ; + break;} +case 22: +#line 283 "parse.y" +{ the_scope = PROTECTED_SCOPE; ; + break;} +case 23: +#line 286 "parse.y" { push_variable(yyvsp[-1].id,the_scope,yyvsp[-3].line,NULL); ; break;} -case 22: -#line 284 "parse.y" +case 24: +#line 289 "parse.y" { push_variable(yyvsp[-2].id,the_scope,yyvsp[-4].line,yyvsp[-1].id); ; break;} -case 23: -#line 288 "parse.y" +case 25: +#line 293 "parse.y" { if(strcmp(yyvsp[-6].id,"get")==0 && strcmp(yyvsp[-3].id,"set")==0) { @@ -1229,8 +1251,8 @@ case 23: } ; break;} -case 24: -#line 323 "parse.y" +case 26: +#line 328 "parse.y" { if(strcmp(yyvsp[-3].id,"get")==0) { Node *node; @@ -1260,8 +1282,8 @@ case 24: } ; break;} -case 25: -#line 353 "parse.y" +case 27: +#line 358 "parse.y" { if(strcmp(yyvsp[-2].id,"type")!=0) { g_free(yyvsp[-4].id); @@ -1272,39 +1294,39 @@ case 25: yyval.id = yyvsp[-4].id; ; break;} -case 26: -#line 362 "parse.y" +case 28: +#line 367 "parse.y" { yyval.id = yyvsp[0].id; typestack = g_list_prepend(typestack,NULL); ; break;} -case 27: -#line 368 "parse.y" +case 29: +#line 373 "parse.y" { yyval.list = yyvsp[-1].list; ; break;} -case 28: -#line 369 "parse.y" +case 30: +#line 374 "parse.y" { yyval.list = NULL; ; break;} -case 29: -#line 372 "parse.y" +case 31: +#line 377 "parse.y" { yyval.list = g_list_append(yyvsp[0].list,yyvsp[-2].id); ; break;} -case 30: -#line 375 "parse.y" +case 32: +#line 380 "parse.y" { yyval.list = g_list_append(NULL,yyvsp[0].id); ; break;} -case 31: -#line 381 "parse.y" +case 33: +#line 386 "parse.y" { ; ; break;} -case 32: -#line 382 "parse.y" +case 34: +#line 387 "parse.y" { Type *type = typestack->data; char *oldname = type->name; @@ -1312,152 +1334,152 @@ case 32: g_free(oldname); ; break;} -case 33: -#line 390 "parse.y" +case 35: +#line 395 "parse.y" { Node *node = new_type(0,yyvsp[0].id,NULL); typestack = g_list_prepend(typestack,node); ; break;} -case 34: -#line 394 "parse.y" +case 36: +#line 399 "parse.y" { Node *node = new_type(stars,yyvsp[-1].id,NULL); stars = 0; typestack = g_list_prepend(typestack,node); ; break;} -case 35: -#line 401 "parse.y" +case 37: +#line 406 "parse.y" { yyval.id = g_strconcat("unsigned ",yyvsp[0].id,NULL); ; break;} -case 36: -#line 404 "parse.y" +case 38: +#line 409 "parse.y" { yyval.id = g_strconcat("signed ",yyvsp[0].id,NULL); ; break;} -case 37: -#line 407 "parse.y" +case 39: +#line 412 "parse.y" { yyval.id = g_strdup(yyvsp[0].id); ; break;} -case 38: -#line 410 "parse.y" +case 40: +#line 415 "parse.y" { yyval.id = g_strdup("unsigned char"); ; break;} -case 39: -#line 413 "parse.y" +case 41: +#line 418 "parse.y" { yyval.id = g_strdup("signed char"); ; break;} -case 40: -#line 416 "parse.y" +case 42: +#line 421 "parse.y" { yyval.id = g_strdup("char"); ; break;} -case 41: -#line 419 "parse.y" +case 43: +#line 424 "parse.y" { yyval.id = g_strdup("double"); ; break;} -case 42: -#line 422 "parse.y" +case 44: +#line 427 "parse.y" { yyval.id = g_strdup("float"); ; break;} -case 43: -#line 425 "parse.y" +case 45: +#line 430 "parse.y" { yyval.id = yyvsp[0].id; ; break;} -case 44: -#line 428 "parse.y" +case 46: +#line 433 "parse.y" { yyval.id = g_strconcat(yyvsp[-1].id,yyvsp[0].id,NULL); g_free(yyvsp[0].id); ; break;} -case 45: -#line 432 "parse.y" +case 47: +#line 437 "parse.y" { yyval.id = yyvsp[0].id; ; break;} -case 46: -#line 435 "parse.y" +case 48: +#line 440 "parse.y" { yyval.id = g_strdup("void"); ; break;} -case 47: -#line 440 "parse.y" +case 49: +#line 445 "parse.y" { yyval.id = "long int"; ; break;} -case 48: -#line 443 "parse.y" +case 50: +#line 448 "parse.y" { yyval.id = "long"; ; break;} -case 49: -#line 446 "parse.y" +case 51: +#line 451 "parse.y" { yyval.id = "short int"; ; break;} -case 50: -#line 449 "parse.y" +case 52: +#line 454 "parse.y" { yyval.id = "short"; ; break;} -case 51: -#line 452 "parse.y" +case 53: +#line 457 "parse.y" { yyval.id = "int"; ; break;} -case 52: -#line 457 "parse.y" +case 54: +#line 462 "parse.y" { yyval.id = "enum "; ; break;} -case 53: -#line 460 "parse.y" +case 55: +#line 465 "parse.y" { yyval.id = "union "; ; break;} -case 54: -#line 463 "parse.y" +case 56: +#line 468 "parse.y" { yyval.id = "struct "; ; break;} -case 55: -#line 468 "parse.y" +case 57: +#line 473 "parse.y" { stars++; ; break;} -case 56: -#line 469 "parse.y" +case 58: +#line 474 "parse.y" { stars++; ; break;} -case 57: -#line 473 "parse.y" +case 59: +#line 478 "parse.y" { if(strcmp(yyvsp[-1].id,"first")==0) yyval.sigtype = SIGNAL_FIRST_METHOD; @@ -1471,14 +1493,14 @@ case 57: g_free(yyvsp[-1].id); ; break;} -case 58: -#line 485 "parse.y" +case 60: +#line 490 "parse.y" { yyval.sigtype = SIGNAL_LAST_METHOD; ; break;} -case 59: -#line 491 "parse.y" +case 61: +#line 496 "parse.y" { if(strcmp(yyvsp[-1].id,"first")==0) yyval.sigtype = SIGNAL_FIRST_METHOD; @@ -1492,8 +1514,8 @@ case 59: g_free(yyvsp[-1].id); ; break;} -case 60: -#line 503 "parse.y" +case 62: +#line 508 "parse.y" { if(strcmp(yyvsp[-2].id,"first")==0) yyval.sigtype = SIGNAL_FIRST_METHOD; @@ -1507,47 +1529,47 @@ case 60: g_free(yyvsp[-2].id); ; break;} -case 61: -#line 515 "parse.y" +case 63: +#line 520 "parse.y" { yyval.sigtype = SIGNAL_LAST_METHOD; ; break;} -case 62: -#line 518 "parse.y" +case 64: +#line 523 "parse.y" { /* the_scope was default thus public */ the_scope = PUBLIC_SCOPE; ; break;} -case 63: -#line 524 "parse.y" +case 65: +#line 529 "parse.y" { gtktypes = g_list_prepend(gtktypes,yyvsp[-3].id); ; break;} -case 64: -#line 529 "parse.y" +case 66: +#line 534 "parse.y" { gtktypes = g_list_append(gtktypes,yyvsp[0].id); ; break;} -case 65: -#line 532 "parse.y" +case 67: +#line 537 "parse.y" { gtktypes = g_list_append(gtktypes,yyvsp[0].id); ; break;} -case 66: -#line 537 "parse.y" +case 68: +#line 542 "parse.y" { yyval.cbuf = yyvsp[0].cbuf; ; break;} -case 67: -#line 538 "parse.y" +case 69: +#line 543 "parse.y" { yyval.cbuf = NULL; ; break;} -case 68: -#line 542 "parse.y" +case 70: +#line 547 "parse.y" { if(!has_self) { yyerror(_("signal without 'self' as " @@ -1559,8 +1581,8 @@ case 68: ccode_line,vararg); ; break;} -case 69: -#line 552 "parse.y" +case 71: +#line 557 "parse.y" { if(!has_self) { yyerror(_("signal without 'self' as " @@ -1572,8 +1594,8 @@ case 69: ccode_line,vararg); ; break;} -case 70: -#line 562 "parse.y" +case 72: +#line 567 "parse.y" { if(!has_self) { yyerror(_("virtual method without 'self' as " @@ -1585,8 +1607,8 @@ case 70: ccode_line,vararg); ; break;} -case 71: -#line 572 "parse.y" +case 73: +#line 577 "parse.y" { if(!has_self) { yyerror(_("virtual method without 'self' as " @@ -1598,8 +1620,8 @@ case 71: ccode_line,vararg); ; break;} -case 72: -#line 582 "parse.y" +case 74: +#line 587 "parse.y" { if(!has_self) { yyerror(_("virtual method without 'self' as " @@ -1611,8 +1633,8 @@ case 72: ccode_line,vararg); ; break;} -case 73: -#line 592 "parse.y" +case 75: +#line 597 "parse.y" { push_function(NO_SCOPE, OVERRIDE_METHOD, yyvsp[-8].id, yyvsp[-5].id, yyvsp[-1].id, yyvsp[0].cbuf, @@ -1620,16 +1642,16 @@ case 73: vararg); ; break;} -case 74: -#line 598 "parse.y" +case 76: +#line 603 "parse.y" { push_function(the_scope, REGULAR_METHOD, NULL, yyvsp[-5].id, yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-7].line,ccode_line, vararg); ; break;} -case 75: -#line 603 "parse.y" +case 77: +#line 608 "parse.y" { if(strcmp(yyvsp[-4].id,"init")==0) { push_init_arg(yyvsp[-2].id,FALSE); @@ -1650,27 +1672,27 @@ case 75: } ; break;} -case 76: -#line 624 "parse.y" +case 78: +#line 629 "parse.y" { yyval.id = yyvsp[0].id; ; break;} -case 77: -#line 625 "parse.y" +case 79: +#line 630 "parse.y" { yyval.id = (yyvsp[0].cbuf)->str; g_string_free(yyvsp[0].cbuf,FALSE); ; break;} -case 78: -#line 629 "parse.y" +case 80: +#line 634 "parse.y" { yyval.id = NULL; ; break;} -case 79: -#line 632 "parse.y" +case 81: +#line 637 "parse.y" { vararg = FALSE; has_self = FALSE; ; break;} -case 80: -#line 633 "parse.y" +case 82: +#line 638 "parse.y" { vararg = FALSE; has_self = TRUE; @@ -1683,8 +1705,8 @@ case 80: } ; break;} -case 81: -#line 644 "parse.y" +case 83: +#line 649 "parse.y" { has_self = TRUE; if(strcmp(yyvsp[-2].id,"self")==0) @@ -1696,40 +1718,40 @@ case 81: } ; break;} -case 82: -#line 654 "parse.y" +case 84: +#line 659 "parse.y" { has_self = FALSE; ; break;} -case 83: -#line 657 "parse.y" +case 85: +#line 662 "parse.y" { vararg = TRUE; ; break;} -case 84: -#line 658 "parse.y" +case 86: +#line 663 "parse.y" { vararg = FALSE; ; break;} -case 85: -#line 661 "parse.y" +case 87: +#line 666 "parse.y" { ; ; break;} -case 86: -#line 662 "parse.y" +case 88: +#line 667 "parse.y" { ; ; break;} -case 87: -#line 665 "parse.y" +case 89: +#line 670 "parse.y" { push_funcarg(yyvsp[0].id,NULL); ; break;} -case 88: -#line 668 "parse.y" +case 90: +#line 673 "parse.y" { push_funcarg(yyvsp[-1].id,yyvsp[0].id); ; break;} -case 89: -#line 671 "parse.y" +case 91: +#line 676 "parse.y" { if(strcmp(yyvsp[-2].id,"check")!=0) { yyerror(_("parse error")); @@ -1739,8 +1761,8 @@ case 89: push_funcarg(yyvsp[-4].id,NULL); ; break;} -case 90: -#line 679 "parse.y" +case 92: +#line 684 "parse.y" { if(strcmp(yyvsp[-2].id,"check")!=0) { yyerror(_("parse error")); @@ -1750,16 +1772,16 @@ case 90: push_funcarg(yyvsp[-5].id,yyvsp[-4].id); ; break;} -case 91: -#line 689 "parse.y" +case 93: +#line 694 "parse.y" { ; ; break;} -case 92: -#line 690 "parse.y" +case 94: +#line 695 "parse.y" { ; ; break;} -case 93: -#line 693 "parse.y" +case 95: +#line 698 "parse.y" { if(strcmp(yyvsp[0].id,"type")==0) { Node *node = new_check(TYPE_CHECK,NULL); @@ -1774,61 +1796,61 @@ case 93: g_free(yyvsp[0].id); ; break;} -case 94: -#line 706 "parse.y" +case 96: +#line 711 "parse.y" { Node *node = new_check(GT_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 95: -#line 710 "parse.y" +case 97: +#line 715 "parse.y" { Node *node = new_check(LT_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 96: -#line 714 "parse.y" +case 98: +#line 719 "parse.y" { Node *node = new_check(GE_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 97: -#line 718 "parse.y" +case 99: +#line 723 "parse.y" { Node *node = new_check(LE_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 98: -#line 722 "parse.y" +case 100: +#line 727 "parse.y" { Node *node = new_check(EQ_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 99: -#line 726 "parse.y" +case 101: +#line 731 "parse.y" { Node *node = new_check(NE_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 100: -#line 732 "parse.y" +case 102: +#line 737 "parse.y" { yyval.id = yyvsp[0].id; ; break;} -case 101: -#line 733 "parse.y" +case 103: +#line 738 "parse.y" { yyval.id = g_strconcat("-",yyvsp[0].id,NULL); g_free(yyvsp[0].id); ; break;} -case 102: -#line 737 "parse.y" +case 104: +#line 742 "parse.y" { yyval.id = yyvsp[0].id; ; break;} } @@ -2053,5 +2075,5 @@ yyerrhandle: } return 1; } -#line 740 "parse.y" +#line 745 "parse.y" diff --git a/src/parse.y b/src/parse.y index c2c4253..a6892e9 100644 --- a/src/parse.y +++ b/src/parse.y @@ -27,11 +27,10 @@ #include "tree.h" #include "main.h" +#include "util.h" #define _(x) (x) -extern char *filename; - GList *nodes = NULL; static GList *class_nodes = NULL; @@ -213,7 +212,7 @@ push_self(char *id) %token ONERROR %token TOKEN NUMBER TYPETOKEN ARRAY_DIM -%token CCODE HCODE +%token CCODE HTCODE PHCODE HCODE %token PUBLIC PRIVATE PROTECTED ARGUMENT VIRTUAL SIGNAL OVERRIDE %% @@ -224,30 +223,36 @@ prog: ccodes class ccodes { ; } | class { ; } ; -ccodes: ccodes CCODE { - Node *node = new_ccode(FALSE,($2)->str, +ccode: CCODE { + Node *node = new_ccode(C_CCODE,($1)->str, ccode_line); nodes = g_list_append(nodes,node); - g_string_free($2,FALSE); + g_string_free($1,FALSE); } - | ccodes HCODE { - Node *node = new_ccode(TRUE,($2)->str,ccode_line); + | HCODE { + Node *node = new_ccode(H_CCODE,($1)->str, + ccode_line); nodes = g_list_append(nodes,node); - g_string_free($2,FALSE); + g_string_free($1,FALSE); } - | CCODE { - Node *node = new_ccode(FALSE,($1)->str, + | HTCODE { + Node *node = new_ccode(HT_CCODE,($1)->str, ccode_line); nodes = g_list_append(nodes,node); g_string_free($1,FALSE); } - | HCODE { - Node *node = new_ccode(TRUE,($1)->str,ccode_line); + | PHCODE { + Node *node = new_ccode(PH_CCODE,($1)->str, + ccode_line); nodes = g_list_append(nodes,node); g_string_free($1,FALSE); } ; +ccodes: ccodes ccode { ; } + | ccode { ; } + ; + class: classdec '{' classcode '}' { ((Class *)class)->nodes = class_nodes; class_nodes = NULL; diff --git a/src/test.gob b/src/test.gob index 181b92d..3adbd25 100644 --- a/src/test.gob +++ b/src/test.gob @@ -5,6 +5,20 @@ requires 0.92.1 +%headertop{ +/* this should go on the very top of the header */ +%} +%ht{ +/* this should go on the very top of the header as well */ +%} +%ph{ +/* this should go into the private header */ +%} +%privateheader{ +/* this should go into the private header as well*/ +%} + + %{ #include /* the next line is not mandatory, but if gob finds an include in one of @@ -25,6 +39,9 @@ static void jjjj(void); %h{ void bubu(void); %} +%header{ +/* this should be in the header, just under bubu prototype */ +%} class Gtk:Weird:Button from Gtk:Button { public int i; diff --git a/src/tree.c b/src/tree.c index 414ba43..d695b45 100644 --- a/src/tree.c +++ b/src/tree.c @@ -24,11 +24,11 @@ #include "tree.h" Node * -new_ccode(int header, char *cbuf, int line_no) +new_ccode(int cctype, char *cbuf, int line_no) { CCode *node = (CCode *)g_new(Node,1); node->type = CCODE_NODE; - node->header = header; + node->cctype = cctype; node->cbuf = cbuf; node->line_no = line_no; return (Node *)node; @@ -78,7 +78,7 @@ new_funcarg(Type *atype, char *name, GList *checks) } Node * -new_method(int scope, int method, Type *mtype, char *otype, GList *gtktypes, char *id, GList *args, char *onerror, char *cbuf, int line_no,int ccode_line, int vararg) +new_method(int scope, int method, Type *mtype, char *otype, GList *gtktypes, char *id, GList *args, char *onerror, char *cbuf, int line_no, int ccode_line, gboolean vararg) { Method *node = (Method *)g_new(Node,1); node->type = METHOD_NODE; diff --git a/src/tree.h b/src/tree.h index 814ce02..9d85329 100644 --- a/src/tree.h +++ b/src/tree.h @@ -35,12 +35,20 @@ enum { VARIABLE_NODE }; +/* for ccode type */ +enum { + C_CCODE, + H_CCODE, + HT_CCODE, + PH_CCODE +}; + typedef union _Node Node; typedef struct _CCode CCode; struct _CCode { int type; - int header; + int cctype; char *cbuf; int line_no; }; @@ -134,7 +142,7 @@ struct _Method { char *cbuf; int line_no; int ccode_line; - int vararg; + gboolean vararg; }; typedef struct _Variable Variable; @@ -157,12 +165,12 @@ union _Node { Variable variable; }; -Node *new_ccode(int header, char *cbuf, int line_no); +Node *new_ccode(int cctype, char *cbuf, int line_no); Node *new_class(char *otype, char *ptype, GList *nodes); Node *new_type(int stars, char *name, char *postfix); Node *new_check(int chtype, char *number); Node *new_funcarg(Type *atype, char *name, GList *checks); -Node *new_method(int scope, int method, Type *mtype, char *otype, GList *gtktypes, char *id, GList *args, char *onerror, char *cbuf,int line_no,int ccode_line, int vararg); +Node *new_method(int scope, int method, Type *mtype, char *otype, GList *gtktypes, char *id, GList *args, char *onerror, char *cbuf, int line_no, int ccode_line, gboolean vararg); Node *new_argument(char *gtktype, Type *atype, GList *flags, char *name, char *get, int get_line, char *set, int set_line, int line_no); Node *new_variable(int scope, Type *vtype, char *id,int line_no); diff --git a/src/util.c b/src/util.c new file mode 100644 index 0000000..2eda8b0 --- /dev/null +++ b/src/util.c @@ -0,0 +1,167 @@ +/* GOB C Preprocessor + * Copyright (C) 1999-2000 the Free Software Foundation. + * + * Author: George Lebl + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + +#include "config.h" +#include +#include +#include + +#include "main.h" + +#include "util.h" + +void +print_error(int is_warn, char *error,int line) +{ + char *w; + if(is_warn) + w = "Warning:"; + else { + w = "Error:"; + got_error = TRUE; + } + if(line>0) + fprintf(stderr,"%s:%d: %s %s\n",filename,line,w,error); + else + fprintf(stderr,"%s: %s %s\n",filename,w,error); + if((!is_warn || exit_on_warn) && exit_on_error) + exit(1); +} + +char * +remove_sep(char *base) +{ + char *p; + char *s = g_strdup(base); + while((p=strchr(s,':'))) + strcpy(p,p+1); + return s; +} + +char * +replace_sep(char *base, char r) +{ + char *p; + char *s = g_strdup(base); + while((p=strchr(s,':'))) + *p = r; + if(*s == r) { + p = g_strdup(s+1); + g_free(s); + return p; + } + return s; +} + +/*separate the namespace part and then replace rest of + separators with r*/ +void +separns_replace_sep(char *base, char **ns, char **name, char r) +{ + char *p; + char *s = g_strdup(base); + *ns = NULL; + if((p=strchr(s,':')) && p!=s) { + *p = '\0'; + *ns = g_strdup(s); + p = g_strdup(p+1); + g_free(s); + s = p; + } + while((p=strchr(s,':'))) + *p = r; + if(*s == r) { + *name = g_strdup(s+1); + g_free(s); + } else + *name = s; +} + +/* make a macro with some prefix before the name but after + namespace */ +char * +make_pre_macro(char *base, char *pre) +{ + char *s1,*s2; + char *s; + + separns_replace_sep(base,&s1,&s2,'_'); + if(s1) + s = g_strconcat(s1,"_",pre,"_",s2,NULL); + else + s = g_strconcat(pre,"_",s2,NULL); + + g_strup(s); + + g_free(s1); + g_free(s2); + + return s; +} + +/* here we will find out how inconsistent gtk really is :) */ +/* the commented out types mean that these types don't actually + exist. so we "emulate them" with an equivalent */ +const struct { + gboolean simple; + char *gtkname; + char *typename; +} our_gtk_type_table[] = { + { TRUE, "NONE", "void " }, + { TRUE, "CHAR", "gchar " }, + { TRUE, "UCHAR", "guchar " }, + { TRUE, "BOOL", "gboolean " }, + { TRUE, "INT", "gint " }, + { TRUE, "UINT", "guint " }, + { TRUE, "LONG", "glong " }, + { TRUE, "ULONG", "gulong " }, + { TRUE, "FLOAT", "gfloat " }, + { TRUE, "DOUBLE", "gdouble " }, + { TRUE, "STRING", /*"GtkString"*/"gchar *" }, + { TRUE, "ENUM", /*"GtkEnum"*/"gint " }, + { TRUE, "FLAGS", /*"GtkFlags"*/"guint " }, + { TRUE, "BOXED", /*"GtkBoxed"*/"gpointer " }, + { TRUE, "POINTER", "gpointer " }, + { TRUE, "OBJECT", "GtkObject *" }, + { FALSE, "SIGNAL", /*"GtkSignal"*/"___twopointertype " }, + { FALSE, "ARGS", /*"GtkArgs"*/"___twopointertype " }, + { FALSE, "CALLBACK", /*"GtkCallback"*/"___threepointertype " }, + { FALSE, "C_CALLBACK", /*"GtkCCallback"*/"___twopointertype " }, + { FALSE, "FOREIGN", /*"GtkForeign"*/"___twopointertype " }, + + { FALSE, NULL, NULL } +}; + +const char * +get_cast(char *type, gboolean simple_only) +{ + int i; + for(i=0;our_gtk_type_table[i].gtkname;i++) { + if(strcmp(our_gtk_type_table[i].gtkname,type)==0) { + if(simple_only && + !our_gtk_type_table[i].simple) + return NULL; + return our_gtk_type_table[i].typename; + } + } + return NULL; +} + diff --git a/src/util.h b/src/util.h new file mode 100644 index 0000000..9d0d0cb --- /dev/null +++ b/src/util.h @@ -0,0 +1,45 @@ +/* GOB C Preprocessor + * Copyright (C) 1999-2000 the Free Software Foundation. + * + * Author: George Lebl + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + +#ifndef _UTIL_H_ +#define _UTIL_H_ + +/* print an error, or warning (if 'is_warn') referring to 'line' */ +void print_error(int is_warn, char *error, int line); + +/* remove the : separator from a typename */ +char * remove_sep(char *base); +/* replace the : separator from a typename with a different character*/ +char * replace_sep(char *base, char r); + +/*separate the namespace part and then replace rest of + separators with r*/ +void separns_replace_sep(char *base, char **ns, char **name, char r); + +/* make a macro with some prefix before the name but after + namespace */ +char * make_pre_macro(char *base, char *pre); + +/* get a name usable for a cast from a GTK+ type (without GTK_TYPE_)*/ +const char * get_cast(char *type, gboolean simple_only); + +#endif +