void free(void *ptr);
int yylex(void);
+extern int ccode_line;
extern int line_no;
extern char *yytext;
static void
push_function(int scope, char *oid, char *id, char *onerror,
- GString *cbuf,int line_no)
+ GString *cbuf,int line_no, int ccode_line)
{
Node *node;
Type *type;
}
node = new_method(scope,type,oid,gtktypes,id,funcargs,
- onerror,cbuf,line_no);
+ onerror,cbuf,line_no,ccode_line);
gtktypes = NULL;
funcargs = NULL;
%token CLASS FROM
%token VOID STRUCT UNION ENUM SIGNED UNSIGNED LONG SHORT INT FLOAT DOUBLE CHAR
%token FIRST LAST
-%token CHECK CNULL TYPE ONERROR
+%token ONERROR
%token <id> TOKEN NUMBER TYPETOKEN
%token <cbuf> CCODE HCODE
;
ccodes: ccodes CCODE {
- Node *node = new_ccode(FALSE,$<cbuf>2);
+ Node *node = new_ccode(FALSE,$<cbuf>2,ccode_line);
nodes = g_list_append(nodes,node);
}
| ccodes HCODE {
- Node *node = new_ccode(TRUE,$<cbuf>2);
+ Node *node = new_ccode(TRUE,$<cbuf>2,ccode_line);
nodes = g_list_append(nodes,node);
}
| CCODE {
- Node *node = new_ccode(FALSE,$<cbuf>1);
+ Node *node = new_ccode(FALSE,$<cbuf>1,ccode_line);
nodes = g_list_append(nodes,node);
}
| HCODE {
- Node *node = new_ccode(TRUE,$<cbuf>1);
+ Node *node = new_ccode(TRUE,$<cbuf>1,ccode_line);
nodes = g_list_append(nodes,node);
}
;
Node *node;
g_free($<id>5); g_free($<id>8);
node = new_argument($<id>3,$<list>2,$<id>4,
- $<cbuf>7,$<cbuf>10);
+ $<cbuf>7,$<line>6,
+ $<cbuf>10,$<line>9);
class_nodes = g_list_append(class_nodes,node);
} else if(strcmp($<id>5,"set")==0 &&
strcmp($<id>8,"get")==0) {
Node *node;
g_free($<id>5); g_free($<id>8);
node = new_argument($<id>3,$<list>2,$<id>4,
- $<cbuf>10,$<cbuf>7);
+ $<cbuf>10,$<line>9,
+ $<cbuf>7,$<line>6);
class_nodes = g_list_append(class_nodes,node);
} else {
g_free($<id>3); g_free($<id>4);
Node *node;
g_free($<id>5);
node = new_argument($<id>3,$<list>2,$<id>4,
- $<cbuf>7,NULL);
+ $<cbuf>7,$<line>6,NULL,0);
class_nodes = g_list_append(class_nodes,node);
} else if(strcmp($<id>5,"set")==0) {
Node *node;
g_free($<id>5);
node = new_argument($<id>3,$<list>2,$<id>4,
- NULL,$<cbuf>7);
+ NULL,0,$<cbuf>7,$<line>6);
class_nodes = g_list_append(class_nodes,node);
} else {
g_free($<id>5); g_free($<id>3);
;
/*here CCODE will include the ending '}' */
-method: SIGNAL LAST sigtype type TOKEN '(' funcargs ')' onerror '{' CCODE {
- if(!has_this) {
- yyerror(_("signal without 'this' as "
- "first parameter"));
+method: SIGNAL TOKEN sigtype type TOKEN '(' funcargs ')' onerror '{' CCODE {
+ int sigtype = SIGNAL_LAST_METHOD;
+ if(strcmp($<id>2,"first")==0)
+ sigtype = SIGNAL_FIRST_METHOD;
+ else if(strcmp($<id>2,"last")==0)
+ sigtype = SIGNAL_LAST_METHOD;
+ else {
+ yyerror(_("signal must be 'first' or 'last'"));
+ g_free($<id>2);
YYERROR;
}
- push_function(SIGNAL_LAST_METHOD,NULL,
- $<id>5, $<id>9, $<cbuf>11,$<line>1);
- }
- | SIGNAL LAST sigtype type TOKEN '(' funcargs ')' onerror ';' {
+ g_free($<id>2);
+
if(!has_this) {
yyerror(_("signal without 'this' as "
"first parameter"));
YYERROR;
}
- push_function(SIGNAL_LAST_METHOD, NULL,
- $<id>5, $<id>9, NULL,$<line>1);
+ push_function(sigtype,NULL,
+ $<id>5, $<id>9, $<cbuf>11,$<line>1,$<line>10);
}
- | SIGNAL FIRST sigtype type TOKEN '(' funcargs ')' onerror '{' CCODE {
- if(!has_this) {
- yyerror(_("signal without 'this' as "
- "first parameter"));
+ | SIGNAL TOKEN sigtype type TOKEN '(' funcargs ')' onerror ';' {
+ int sigtype = SIGNAL_LAST_METHOD;
+ if(strcmp($<id>2,"first")==0)
+ sigtype = SIGNAL_FIRST_METHOD;
+ else if(strcmp($<id>2,"last")==0)
+ sigtype = SIGNAL_LAST_METHOD;
+ else {
+ yyerror(_("signal must be 'first' or 'last'"));
+ g_free($<id>2);
YYERROR;
}
- push_function(SIGNAL_FIRST_METHOD, NULL,
- $<id>5, $<id>9, $<cbuf>11,$<line>1);
- }
- | SIGNAL FIRST sigtype type TOKEN '(' funcargs ')' onerror ';' {
+ g_free($<id>2);
if(!has_this) {
yyerror(_("signal without 'this' as "
"first parameter"));
YYERROR;
}
- push_function(SIGNAL_FIRST_METHOD, NULL, $<id>5,
- $<id>9, NULL,$<line>1);
+ push_function(sigtype, NULL,
+ $<id>5, $<id>9, NULL,$<line>1,0);
}
| SIGNAL sigtype type TOKEN '(' funcargs ')' onerror '{' CCODE {
if(!has_this) {
YYERROR;
}
push_function(SIGNAL_LAST_METHOD, NULL,
- $<id>4, $<id>8, $<cbuf>10,$<line>1);
+ $<id>4, $<id>8, $<cbuf>10,$<line>1,$<line>9);
}
| SIGNAL sigtype type TOKEN '(' funcargs ')' onerror ';' {
if(!has_this) {
YYERROR;
}
push_function(SIGNAL_LAST_METHOD, NULL, $<id>4,
- $<id>8, NULL,$<line>1);
+ $<id>8, NULL,$<line>1,0);
}
| VIRTUAL type TOKEN '(' funcargs ')' onerror '{' CCODE {
push_function(VIRTUAL_METHOD, NULL, $<id>3,
- $<id>7, $<cbuf>9,$<line>1);
+ $<id>7, $<cbuf>9,$<line>1,$<line>8);
}
| VIRTUAL type TOKEN '(' funcargs ')' onerror ';' {
push_function(VIRTUAL_METHOD, NULL, $<id>3,
- $<id>7, NULL,$<line>1);
+ $<id>7, NULL,$<line>1,0);
}
| OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' onerror '{' CCODE {
push_function(OVERRIDE_METHOD, $<id>3,
- $<id>6, $<id>10, $<cbuf>12,$<line>1);
+ $<id>6, $<id>10, $<cbuf>12,$<line>1,$<line>11);
}
| PUBLIC type TOKEN '(' funcargs ')' onerror '{' CCODE {
push_function(PUBLIC_SCOPE, NULL, $<id>3,
- $<id>7, $<cbuf>9,$<line>1);
+ $<id>7, $<cbuf>9,$<line>1,$<line>8);
}
| PRIVATE type TOKEN '(' funcargs ')' onerror '{' CCODE {
push_function(PRIVATE_SCOPE, NULL, $<id>3,
- $<id>7, $<cbuf>9,$<line>1);
+ $<id>7, $<cbuf>9,$<line>1,$<line>8);
}
| TOKEN '(' TOKEN ')' ';' {
if(strcmp($<id>1,"init")==0) {
push_init_arg($<id>3,FALSE);
push_function(INIT_METHOD, NULL, $<id>1,
- NULL, NULL,$<line>2);
+ NULL, NULL,$<line>2,0);
} else if(strcmp($<id>1,"class_init")==0) {
push_init_arg($<id>3,TRUE);
push_function(CLASS_INIT_METHOD, NULL,
- $<id>1, NULL, NULL,$<line>2);
+ $<id>1, NULL, NULL,$<line>2,0);
} else {
g_free($<id>1);
g_free($<id>3);
if(strcmp($<id>1,"init")==0) {
push_init_arg($<id>3,FALSE);
push_function(INIT_METHOD, NULL,
- $<id>1, NULL, $<cbuf>6,$<line>2);
+ $<id>1, NULL, $<cbuf>6,$<line>2,
+ $<line>5);
} else if(strcmp($<id>1,"class_init")==0) {
push_init_arg($<id>3,TRUE);
push_function(CLASS_INIT_METHOD, NULL,
- $<id>1, NULL, $<cbuf>6,$<line>2);
+ $<id>1, NULL, $<cbuf>6,$<line>2,
+ $<line>5);
} else {
g_free($<id>1);
g_free($<id>3);
arg: type TOKEN {
push_funcarg($<id>2);
}
- | type TOKEN '(' CHECK checklist ')' {
+ | type TOKEN '(' TOKEN checklist ')' {
+ if(strcmp($<id>4,"check")!=0) {
+ yyerror(_("parse error"));
+ YYERROR;
+ }
+ g_free($<id>4);
push_funcarg($<id>2);
}
;
| check { ; }
;
-check: CNULL {
- Node *node = new_check(NULL_CHECK,NULL);
- checks = g_list_append(checks,node);
- }
- | TYPE {
- Node *node = new_check(TYPE_CHECK,NULL);
- checks = g_list_append(checks,node);
+check: TOKEN {
+ if(strcmp($<id>1,"type")==0) {
+ Node *node = new_check(TYPE_CHECK,NULL);
+ checks = g_list_append(checks,node);
+ } else if(strcmp($<id>1,"null")==0) {
+ Node *node = new_check(NULL_CHECK,NULL);
+ checks = g_list_append(checks,node);
+ } else {
+ yyerror(_("parse error"));
+ YYERROR;
+ }
+ g_free($<id>1);
}
| '>' number {
Node *node = new_check(GT_CHECK,$<id>2);