pike.git/
src/
language.yacc
Branch:
Tag:
Non-build tags
All tags
No tags
1999-12-16
1999-12-16 21:02:30 by Henrik Grubbström (Grubba) <grubba@grubba.org>
b5aa657b5890e8c8e956e6e095a4a777c59ed271 (
97
lines) (+
62
/-
35
)
[
Show
|
Annotate
]
Branch:
7.9
Improved error-recovery?
Rev: src/language.yacc:1.147
184:
/* This is the grammar definition of Pike. */ #include "global.h"
-
RCSID("$Id: language.yacc,v 1.
146
1999/12/
14
14
:
56
:
13
hubbe
Exp $");
+
RCSID("$Id: language.yacc,v 1.
147
1999/12/
16
21
:
02
:
30
grubba
Exp $");
#ifdef HAVE_MEMORY_H #include <memory.h> #endif
618:
} ;
-
def: modifiers type
_
or
_
error
optional_stars
F_IDENTIFIER
+
push
_
compiler
_
frame0:
/*
empty
*/
{ push_compiler_frame(0);
-
+
}
+
;
+
+
def: modifiers type_or_error optional_stars F_IDENTIFIER push_compiler_frame0
+
{
if(!compiler_frame->previous || !compiler_frame->previous->current_type) {
645:
push_finished_type(compiler_frame->current_return_type);
-
e=
$7
-1;
+
e=
$8
-1;
if(varargs) { push_finished_type(compiler_frame->variable[e].type);
670:
if(compiler_pass==1) {
-
$<number>
5
=define_function(check_node_hash($4)->u.sval.u.string,
+
$<number>
6
=define_function(check_node_hash($4)->u.sval.u.string,
check_node_hash($<n>$)->u.sval.u.string, $1, IDENTIFIER_PIKE_FUNCTION,
680:
block_or_semi { int e;
-
if(
$10
)
+
if(
$11
)
{ int f; node *check_args = NULL;
-
for(e=0; e<
$7
; e++)
+
for(e=0; e<
$8
; e++)
{ if(!compiler_frame->variable[e].name || !compiler_frame->variable[e].name->len)
718:
if (check_args) { /* Prepend the arg checking code. */
-
$10
= mknode(F_COMMA_EXPR, mknode(F_POP_VALUE, check_args, NULL),
$10
);
+
$11
= mknode(F_COMMA_EXPR, mknode(F_POP_VALUE, check_args, NULL),
$11
);
}
-
f=dooptcode(check_node_hash($4)->u.sval.u.string, check_node_hash(
$10
),
-
check_node_hash($<n>
9
)->u.sval.u.string, $1);
+
f=dooptcode(check_node_hash($4)->u.sval.u.string, check_node_hash(
$11
),
+
check_node_hash($<n>
10
)->u.sval.u.string, $1);
#ifdef PIKE_DEBUG if(recoveries && sp-evaluator_stack < recoveries->sp) fatal("Stack error (underflow)\n");
-
if(compiler_pass == 1 && f!=$<number>
5
)
-
fatal("define_function screwed up! %d != %d\n",f,$<number>
5
);
+
if(compiler_pass == 1 && f!=$<number>
6
)
+
fatal("define_function screwed up! %d != %d\n",f,$<number>
6
);
#endif } pop_compiler_frame(); free_node($4);
-
free_node($<n>
9
);
+
free_node($<n>
10
);
}
-
+
| modifiers type_or_error optional_stars F_IDENTIFIER push_compiler_frame0
+
error
+
{
+
pop_compiler_frame();
+
free_node($4);
+
}
| modifiers type_or_error optional_stars bad_identifier '(' arguments ')' block_or_semi {
803:
; func_args: '(' arguments close_paren_or_missing { $$=$2; }
-
| error { $$=0; yyerrok; }
+
; arguments: /* empty */ optional_comma { $$=0; }
1287:
continue: F_CONTINUE { $$=mknode(F_CONTINUE,0,0); } ;
-
lambda
:
F_LAMBDA
+
push_compiler_frame1
:
/* empty */
{ push_compiler_frame(1);
-
+
}
+
;
-
+
lambda: F_LAMBDA push_compiler_frame1
+
{
+
debug_malloc_touch(compiler_frame->current_return_type);
if(compiler_frame->current_return_type) free_string(compiler_frame->current_return_type); copy_shared_string(compiler_frame->current_return_type,any_type_string);
1302:
int f,e; struct pike_string *name;
-
debug_malloc_touch(
$4
);
-
$4
=mknode(F_COMMA_EXPR,
$4
,mknode(F_RETURN,mkintnode(0),0));
-
type=find_return_type(
$4
);
+
debug_malloc_touch(
$5
);
+
$5
=mknode(F_COMMA_EXPR,
$5
,mknode(F_RETURN,mkintnode(0),0));
+
type=find_return_type(
$5
);
if(type) { push_finished_type(type);
1312:
} else push_type(T_MIXED);
-
e=
$3
-1;
+
e=
$4
-1;
if(varargs) { push_finished_type(compiler_frame->variable[e].type);
1341:
#endif /* LAMBDA_DEBUG */ f=dooptcode(name,
-
$4
,
+
$5
,
type, ID_STATIC | ID_PRIVATE | ID_INLINE);
1354:
free_string(type); pop_compiler_frame(); }
+
| F_LAMBDA push_compiler_frame1 error
+
{
+
pop_compiler_frame();
+
}
;
-
local_function: F_IDENTIFIER
+
local_function: F_IDENTIFIER
push_compiler_frame1
{
-
push_compiler_frame(1);
-
+
debug_malloc_touch(compiler_frame->current_return_type); if(compiler_frame->current_return_type) free_string(compiler_frame->current_return_type);
-
copy_shared_string(compiler_frame->current_return_type,$<n>0->u.sval.u.string);
+
copy_shared_string(compiler_frame->current_return_type,
+
$<n>0->u.sval.u.string);
} func_args failsafe_block {
1372:
int f,e; struct pike_string *name;
-
$4
=mknode(F_COMMA_EXPR,
$4
,mknode(F_RETURN,mkintnode(0),0));
+
$5
=mknode(F_COMMA_EXPR,
$5
,mknode(F_RETURN,mkintnode(0),0));
push_finished_type(compiler_frame->current_return_type);
-
e=
$3
-1;
+
e=
$4
-1;
if(varargs) { push_finished_type(compiler_frame->variable[e].type);
1403:
fprintf(stderr, "%d: LAMBDA: %s 0x%08lx 0x%08lx\n", compiler_pass, buf, (long)new_program->id, local_class_counter-1); #endif /* LAMBDA_DEBUG */
-
debug_malloc_touch(
$4
);
+
debug_malloc_touch(
$5
);
f=dooptcode(name,
-
$4
,
+
$5
,
type, ID_STATIC | ID_PRIVATE | ID_INLINE);
1420:
free_node($1); free_string(name); }
+
| F_IDENTIFIER push_compiler_frame1 error
+
{
+
pop_compiler_frame();
+
}
;
-
local_function2: optional_stars F_IDENTIFIER
+
local_function2: optional_stars F_IDENTIFIER
push_compiler_frame1
{
-
push_compiler_frame(1);
+
debug_malloc_touch(compiler_frame->current_return_type); push_finished_type($<n>0->u.sval.u.string);
1441:
int f,e; struct pike_string *name;
-
debug_malloc_touch(
$5
);
-
$5
=mknode(F_COMMA_EXPR,
$5
,mknode(F_RETURN,mkintnode(0),0));
+
debug_malloc_touch(
$6
);
+
$6
=mknode(F_COMMA_EXPR,
$6
,mknode(F_RETURN,mkintnode(0),0));
push_finished_type(compiler_frame->current_return_type);
-
e=
$4
-1;
+
e=
$5
-1;
if(varargs) { push_finished_type(compiler_frame->variable[e].type);
1474:
compiler_pass, buf, (long)new_program->id, local_class_counter-1); #endif /* LAMBDA_DEBUG */
-
debug_malloc_touch(
$5
);
+
debug_malloc_touch(
$6
);
f=dooptcode(name,
-
$5
,
+
$6
,
type, ID_STATIC | ID_PRIVATE | ID_INLINE);
1491:
free_node($2); free_string(name); }
+
| optional_stars F_IDENTIFIER push_compiler_frame1 error
+
{
+
pop_compiler_frame();
+
free_node($2);
+
}
;