pike.git/
src/
language.yacc
Branch:
Tag:
Non-build tags
All tags
No tags
2008-05-06
2008-05-06 19:42:29 by Henrik Grubbström (Grubba) <grubba@grubba.org>
9aee970cd948522bb09b9b7d4877b224fa1420d1 (
26
lines) (+
23
/-
3
)
[
Show
|
Annotate
]
Branch:
7.9
Implemented __func__.
Not working for all lambda-class functions yet.
Rev: src/language.yacc:1.418
2:
|| This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
-
|| $Id: language.yacc,v 1.
417
2008/05/
03
15
:
51
:
50
grubba Exp $
+
|| $Id: language.yacc,v 1.
418
2008/05/
06
19
:
42
:
29
grubba Exp $
*/ %pure_parser
281:
%type <n> simple_type2 %type <n> simple_identifier_type %type <n> string_constant
+
%type <n> string_segment
%type <n> string %type <n> TOK_STRING %type <n> TOK_NUMBER
4185:
} ;
-
string: TOK_STRING
-
|
string
TOK_
STRING
+
string
_segment
: TOK_STRING
+
| TOK_
FUNCTION_NAME
{
-
+
struct compiler_frame *f = Pike_compiler->compiler_frame;
+
if (!f) {
+
yyerror("Invalid use of __func__.");
+
$$ = mkstrnode(empty_pike_string);
+
} else if (f->current_function_number < 0) {
+
yyerror("No function defined yet.");
+
$$ = mkstrnode(empty_pike_string);
+
} else {
+
struct identifier *id =
+
ID_FROM_INT(Pike_compiler->new_program, f->current_function_number);
+
$$ = mkstrnode(id->name);
+
}
+
}
+
;
+
+
string: string_segment
+
| string string_segment
+
{
struct pike_string *a,*b; copy_shared_string(a,$1->u.sval.u.string); copy_shared_string(b,$2->u.sval.u.string);