7a08f3 | 2000-01-25 | Henrik Grubbström (Grubba) | | /* -*- C -*- */
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | /*\
||| This file a part of Pike, and is copyright by Fredrik Hubinette
||| Pike is distributed as GPL (General Public License)
||| See the files COPYING and DISCLAIMER for more information.
\*/
|
7a08f3 | 2000-01-25 | Henrik Grubbström (Grubba) | | /**/
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | %pure_parser
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | |
%token TOK_ARROW
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
/*
* Basic value pushing
*/
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | %token TOK_CONSTANT TOK_FLOAT TOK_STRING
%token TOK_NUMBER
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | /*
* These are the predefined functions that can be accessed from Pike.
*/
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | %token TOK_INC TOK_DEC
%token TOK_RETURN
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | %token TOK_EQ TOK_GE TOK_LE TOK_NE
%token TOK_NOT
%token TOK_LSH TOK_RSH
%token TOK_LAND TOK_LOR
%token TOK_SWITCH TOK_SSCANF TOK_CATCH
%token TOK_FOREACH
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | /* This is the end of file marker used by the lexer
* to enable nicer EOF in error handling.
*/
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | %token TOK_LEX_EOF
%token TOK_ADD_EQ
%token TOK_AND_EQ
%token TOK_ARRAY_ID
%token TOK_BREAK
%token TOK_CASE
%token TOK_CLASS
%token TOK_COLON_COLON
%token TOK_CONTINUE
%token TOK_DEFAULT
%token TOK_DIV_EQ
%token TOK_DO
%token TOK_DOT_DOT
%token TOK_DOT_DOT_DOT
%token TOK_ELSE
%token TOK_EXTERN
%token TOK_FLOAT_ID
%token TOK_FOR
%token TOK_FUNCTION_ID
%token TOK_GAUGE
%token TOK_IDENTIFIER
%token TOK_IF
%token TOK_IMPORT
%token TOK_INHERIT
%token TOK_INLINE
%token TOK_LOCAL_ID
%token TOK_FINAL_ID
%token TOK_INT_ID
%token TOK_LAMBDA
%token TOK_MULTISET_ID
%token TOK_MULTISET_END
%token TOK_MULTISET_START
%token TOK_LSH_EQ
%token TOK_MAPPING_ID
%token TOK_MIXED_ID
%token TOK_MOD_EQ
%token TOK_MULT_EQ
%token TOK_NO_MASK
%token TOK_OBJECT_ID
%token TOK_OR_EQ
%token TOK_PRIVATE
%token TOK_PROGRAM_ID
%token TOK_PROTECTED
%token TOK_PREDEF
%token TOK_PUBLIC
%token TOK_RSH_EQ
%token TOK_STATIC
%token TOK_STRING_ID
%token TOK_SUB_EQ
%token TOK_TYPEOF
%token TOK_VOID_ID
%token TOK_WHILE
%token TOK_XOR_EQ
%token TOK_OPTIONAL
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
%right '='
%right '?'
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | %left TOK_LOR
%left TOK_LAND
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | %left '|'
%left '^'
%left '&'
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | %left TOK_EQ TOK_NE
%left '>' TOK_GE '<' TOK_LE /* nonassoc? */
%left TOK_LSH TOK_RSH
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | %left '+' '-'
|
413c8e | 1996-11-01 | Fredrik Hübinette (Hubbe) | | %left '*' '%' '/'
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | %right TOK_NOT '~'
%nonassoc TOK_INC TOK_DEC
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
%{
/* This is the grammar definition of Pike. */
#include "global.h"
|
82e1b7 | 2000-06-22 | Henrik Grubbström (Grubba) | | RCSID("$Id: language.yacc,v 1.190 2000/06/22 17:31:39 grubba Exp $");
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | #ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#include "interpret.h"
#include "array.h"
#include "object.h"
#include "stralloc.h"
#include "las.h"
#include "interpret.h"
#include "program.h"
#include "pike_types.h"
#include "constants.h"
|
bb55f8 | 1997-03-16 | Fredrik Hübinette (Hubbe) | | #include "pike_macros.h"
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | #include "error.h"
#include "docode.h"
|
4868db | 1997-05-07 | Per Hedbor | | #include "machine.h"
|
b9188f | 1999-12-13 | Henrik Grubbström (Grubba) | | #include "main.h"
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | #include "opcodes.h"
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | #define YYMAXDEPTH 1000
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | #ifndef YYDEBUG
/* May also be defined by machine.h */
|
189fd0 | 1997-01-28 | Fredrik Hübinette (Hubbe) | | #define YYDEBUG 1
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | #endif /* YYDEBUG */
|
189fd0 | 1997-01-28 | Fredrik Hübinette (Hubbe) | | #endif
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | int add_local_name(struct pike_string *,struct pike_string *,node *);
int low_add_local_name(struct compiler_frame *,
struct pike_string *,struct pike_string *,node *);
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | static node *lexical_islocal(struct pike_string *);
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
static int varargs;
static INT32 current_modifiers;
|
8d7bda | 1997-02-10 | Fredrik Hübinette (Hubbe) | | static struct pike_string *last_identifier=0;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
cd89d7 | 1997-09-10 | Henrik Grubbström (Grubba) | | /*
* Kludge for Bison not using prototypes.
*/
#ifndef __GNUC__
#ifndef __cplusplus
|
a12235 | 2000-02-02 | Fredrik Hübinette (Hubbe) | | static void __yy_memcpy(char *to, char *from, unsigned int count);
|
cd89d7 | 1997-09-10 | Henrik Grubbström (Grubba) | | #endif /* !__cplusplus */
#endif /* !__GNUC__ */
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | %}
|
e2acf7 | 1997-04-23 | Henrik Grubbström (Grubba) | |
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | %union
{
int number;
FLOAT_TYPE fnum;
struct node_s *n;
|
315aa8 | 1999-12-17 | Fredrik Hübinette (Hubbe) | | char *str;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | }
|
4b974c | 1999-02-20 | Henrik Grubbström (Grubba) | | %{
/* Needs to be included after YYSTYPE is defined. */
#include "lex.h"
%}
|
e2acf7 | 1997-04-23 | Henrik Grubbström (Grubba) | | %{
|
7ee380 | 1998-11-10 | Henrik Grubbström (Grubba) | | /* Include <stdio.h> our selves, so that we can do our magic
* without being disturbed... */
#include <stdio.h>
|
e2acf7 | 1997-04-23 | Henrik Grubbström (Grubba) | | int yylex(YYSTYPE *yylval);
|
7ee380 | 1998-11-10 | Henrik Grubbström (Grubba) | | /* Bison is stupid, and tries to optimize for space... */
#ifdef YYBISON
#define short int
#endif /* YYBISON */
|
e2acf7 | 1997-04-23 | Henrik Grubbström (Grubba) | | %}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | %type <fnum> TOK_FLOAT
%type <number> TOK_ARRAY_ID
%type <number> TOK_BREAK
%type <number> TOK_CASE
%type <number> TOK_CATCH
%type <number> TOK_CONTINUE
%type <number> TOK_DEFAULT
%type <number> TOK_DO
%type <number> TOK_ELSE
%type <number> TOK_FLOAT_ID
%type <number> TOK_FOR
%type <number> TOK_FOREACH
%type <number> TOK_FUNCTION_ID
%type <number> TOK_GAUGE
%type <number> TOK_IF
%type <number> TOK_INHERIT
%type <number> TOK_INLINE
%type <number> TOK_INT_ID
%type <number> TOK_LAMBDA
%type <number> TOK_LOCAL_ID
%type <number> TOK_MAPPING_ID
%type <number> TOK_MIXED_ID
%type <number> TOK_MULTISET_ID
%type <number> TOK_NO_MASK
%type <number> TOK_OBJECT_ID
%type <number> TOK_PREDEF
%type <number> TOK_PRIVATE
%type <number> TOK_PROGRAM_ID
%type <number> TOK_PROTECTED
%type <number> TOK_PUBLIC
%type <number> TOK_RETURN
%type <number> TOK_SSCANF
%type <number> TOK_STATIC
%type <number> TOK_STRING_ID
%type <number> TOK_SWITCH
%type <number> TOK_VOID_ID
%type <number> TOK_WHILE
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | %type <number> arguments
%type <number> arguments2
|
febbc8 | 1997-04-22 | Fredrik Hübinette (Hubbe) | | %type <number> func_args
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | %type <number> assign
%type <number> modifier
%type <number> modifier_list
%type <number> modifiers
|
cbae7e | 2000-03-30 | Henrik Grubbström (Grubba) | | %type <number> function_type_list
%type <number> function_type_list2
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | %type <number> optional_dot_dot_dot
|
cbae7e | 2000-03-30 | Henrik Grubbström (Grubba) | | %type <number> optional_comma
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | %type <number> optional_stars
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
315aa8 | 1999-12-17 | Fredrik Hübinette (Hubbe) | | %type <str> magic_identifiers
%type <str> magic_identifiers1
%type <str> magic_identifiers2
%type <str> magic_identifiers3
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | /* The following symbols return type information */
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
011ad3 | 1999-10-22 | Fredrik Hübinette (Hubbe) | | %type <n> number_or_minint
%type <n> number_or_maxint
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | %type <n> cast
|
1d73ef | 1999-11-23 | Henrik Grubbström (Grubba) | | %type <n> soft_cast
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | %type <n> simple_type
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | %type <n> simple_type2
%type <n> simple_identifier_type
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | %type <n> string_constant
%type <n> string
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | %type <n> TOK_STRING
%type <n> TOK_NUMBER
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | %type <n> optional_rename_inherit
%type <n> optional_identifier
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | %type <n> TOK_IDENTIFIER
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | %type <n> assoc_pair
%type <n> block
|
01d3e2 | 1997-04-23 | Fredrik Hübinette (Hubbe) | | %type <n> failsafe_block
|
bb213c | 1999-12-27 | Henrik Grubbström (Grubba) | | %type <n> close_paren_or_missing
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | %type <n> block_or_semi
%type <n> break
%type <n> case
%type <n> catch
%type <n> catch_arg
%type <n> class
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | %type <n> safe_comma_expr
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | %type <n> comma_expr
%type <n> comma_expr2
%type <n> comma_expr_or_maxint
%type <n> comma_expr_or_zero
%type <n> cond
%type <n> continue
%type <n> default
%type <n> do
|
998e1f | 1998-04-15 | Henrik Grubbström (Grubba) | | %type <n> safe_expr0
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | %type <n> expr00
%type <n> expr01
%type <n> expr1
%type <n> expr2
%type <n> expr3 expr0
%type <n> expr4
%type <n> expr_list
%type <n> expr_list2
%type <n> for
%type <n> for_expr
%type <n> foreach
%type <n> gauge
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | %type <n> idents
|
71d970 | 2000-06-21 | Henrik Grubbström (Grubba) | | %type <n> idents2
|
82e1b7 | 2000-06-22 | Henrik Grubbström (Grubba) | | %type <n> inherit_specifier
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | %type <n> lambda
%type <n> local_name_list
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | %type <n> local_name_list2
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | %type <n> low_idents
|
998e1f | 1998-04-15 | Henrik Grubbström (Grubba) | | %type <n> safe_lvalue
|
3ddb53 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | %type <n> lvalue
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | %type <n> lvalue_list
|
2a3269 | 1998-01-31 | Fredrik Hübinette (Hubbe) | | %type <n> low_lvalue_list
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | %type <n> m_expr_list
%type <n> m_expr_list2
%type <n> new_local_name
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | %type <n> new_local_name2
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | %type <n> optional_else_part
%type <n> return
%type <n> sscanf
%type <n> statement
%type <n> statements
%type <n> switch
%type <n> typeof
%type <n> unused
%type <n> unused2
%type <n> while
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | %type <n> optional_comma_expr
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | %type <n> low_program_ref
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | %type <n> local_function
%type <n> local_function2
|
315aa8 | 1999-12-17 | Fredrik Hübinette (Hubbe) | | %type <n> magic_identifier
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | %%
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | all: program { YYACCEPT; }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | program TOK_LEX_EOF { YYACCEPT; }
/* | error TOK_LEX_EOF { YYABORT; } */
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
97b849 | 2000-03-16 | Martin Stjernholm | | program: program def optional_semi_colons
|
bdacd9 | 1998-04-15 | Henrik Grubbström (Grubba) | | /* | error { yyerrok; } */
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | /* empty */
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
97b849 | 2000-03-16 | Martin Stjernholm | | optional_semi_colons: /* empty */
| optional_semi_colons ';'
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | string_constant: string
| string_constant '+' string
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | struct pike_string *a,*b;
copy_shared_string(a,$1->u.sval.u.string);
copy_shared_string(b,$3->u.sval.u.string);
free_node($1);
free_node($3);
a=add_and_free_shared_strings(a,b);
$$=mkstrnode(a);
free_string(a);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | optional_rename_inherit: ':' TOK_IDENTIFIER { $$=$2; }
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | | ':' bad_identifier { $$=0; }
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | | ':' error { $$=0; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | { $$=0; }
;
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | |
|
66c236 | 1998-08-29 | Henrik Grubbström (Grubba) | | /* NOTE: This rule pushes a string "name" on the stack in addition
* to resolving the program reference.
*/
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | low_program_ref: string_constant
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | {
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | ref_push_string($1->u.sval.u.string);
ref_push_string($1->u.sval.u.string);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | ref_push_string(lex.current_file);
|
10e16f | 1999-11-04 | Henrik Grubbström (Grubba) | |
if (error_handler && error_handler->prog) {
ref_push_object(error_handler);
SAFE_APPLY_MASTER("handle_inherit", 3);
} else {
SAFE_APPLY_MASTER("handle_inherit", 2);
}
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | |
if(sp[-1].type != T_PROGRAM)
|
66c236 | 1998-08-29 | Henrik Grubbström (Grubba) | | my_yyerror("Couldn't cast string \"%s\" to program",
$1->u.sval.u.string->str);
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_node($1);
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | $$=mksvaluenode(sp-1);
|
43fc17 | 1999-09-19 | Fredrik Hübinette (Hubbe) | | if($$->name) free_string($$->name);
|
454d54 | 1999-09-18 | Fredrik Hübinette (Hubbe) | | add_ref( $$->name=sp[-2].u.string );
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | pop_stack();
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | }
| idents
{
|
8d7bda | 1997-02-10 | Fredrik Hübinette (Hubbe) | | if(last_identifier)
{
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | ref_push_string(last_identifier);
|
8d7bda | 1997-02-10 | Fredrik Hübinette (Hubbe) | | }else{
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | push_constant_text("");
|
8d7bda | 1997-02-10 | Fredrik Hübinette (Hubbe) | | }
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | $$=$1;
}
;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
66c236 | 1998-08-29 | Henrik Grubbström (Grubba) | | /* NOTE: Pushes the resolved program on the stack. */
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | program_ref: low_program_ref
{
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | resolv_program($1);
free_node($1);
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | }
;
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | inheritance: modifiers TOK_INHERIT low_program_ref optional_rename_inherit ';'
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
8fd931 | 1999-12-30 | Henrik Grubbström (Grubba) | | if (($1 & ID_EXTERN) && (compiler_pass == 1)) {
yywarning("Extern declared inherit.");
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(!(new_program->flags & PROGRAM_PASS_1_DONE))
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | {
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | struct pike_string *s=sp[-1].u.string;
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | if($4) s=$4->u.sval.u.string;
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | compiler_do_inherit($3,$1,s);
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | }
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | if($4) free_node($4);
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | pop_n_elems(1);
free_node($3);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | modifiers TOK_INHERIT low_program_ref error ';'
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | {
free_node($3); yyerrok;
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | modifiers TOK_INHERIT low_program_ref error TOK_LEX_EOF
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
free_node($3);
yyerror("Missing ';'.");
yyerror("Unexpected end of file.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | modifiers TOK_INHERIT low_program_ref error '}'
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
free_node($3); yyerror("Missing ';'.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | modifiers TOK_INHERIT error ';' { yyerrok; }
| modifiers TOK_INHERIT error TOK_LEX_EOF
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
yyerror("Missing ';'.");
yyerror("Unexpected end of file.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | modifiers TOK_INHERIT error '}' { yyerror("Missing ';'."); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | import: TOK_IMPORT idents ';'
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | {
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | resolv_constant($2);
free_node($2);
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | use_module(sp-1);
|
45e8a8 | 1997-01-26 | Fredrik Hübinette (Hubbe) | | pop_stack();
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_IMPORT string ';'
|
eb5c90 | 1998-04-19 | Fredrik Hübinette (Hubbe) | | {
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | ref_push_string($2->u.sval.u.string);
free_node($2);
|
eb5c90 | 1998-04-19 | Fredrik Hübinette (Hubbe) | | ref_push_string(lex.current_file);
|
10e16f | 1999-11-04 | Henrik Grubbström (Grubba) | | if (error_handler && error_handler->prog) {
ref_push_object(error_handler);
SAFE_APPLY_MASTER("handle_import", 3);
} else {
SAFE_APPLY_MASTER("handle_import", 2);
}
|
eb5c90 | 1998-04-19 | Fredrik Hübinette (Hubbe) | | use_module(sp-1);
pop_stack();
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_IMPORT error ';' { yyerrok; }
| TOK_IMPORT error TOK_LEX_EOF
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
yyerror("Missing ';'.");
yyerror("Unexpected end of file.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_IMPORT error '}' { yyerror("Missing ';'."); }
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | ;
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | constant_name: TOK_IDENTIFIER '=' safe_expr0
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | {
int tmp;
/* This can be made more lenient in the future */
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
/* Ugly hack to make sure that $3 is optimized */
tmp=compiler_pass;
|
3d7882 | 1999-11-06 | Henrik Grubbström (Grubba) | | $3=mknode(F_COMMA_EXPR,$3,0);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | compiler_pass=tmp;
|
8fd931 | 1999-12-30 | Henrik Grubbström (Grubba) | | if ((current_modifiers & ID_EXTERN) && (compiler_pass == 1)) {
yywarning("Extern declared constant.");
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(!is_const($3))
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | {
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(compiler_pass==2)
yyerror("Constant definition is not constant.");
|
a78643 | 1999-11-18 | Martin Stjernholm | | else
|
8fd931 | 1999-12-30 | Henrik Grubbström (Grubba) | | add_constant($1->u.sval.u.string, 0, current_modifiers & ~ID_EXTERN);
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | } else {
|
57cddc | 1998-04-19 | Per Hedbor | | if(!num_parse_error)
|
c6ae0c | 1996-11-26 | Fredrik Hübinette (Hubbe) | | {
|
57cddc | 1998-04-19 | Per Hedbor | | tmp=eval_low($3);
if(tmp < 1)
{
yyerror("Error in constant definition.");
}else{
pop_n_elems(tmp-1);
|
8fd931 | 1999-12-30 | Henrik Grubbström (Grubba) | | add_constant($1->u.sval.u.string, sp-1,
current_modifiers & ~ID_EXTERN);
|
57cddc | 1998-04-19 | Per Hedbor | | pop_stack();
}
|
c6ae0c | 1996-11-26 | Fredrik Hübinette (Hubbe) | | }
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | }
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if($3) free_node($3);
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_node($1);
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | }
|
998e1f | 1998-04-15 | Henrik Grubbström (Grubba) | | | bad_identifier '=' safe_expr0 { if ($3) free_node($3); }
| error '=' safe_expr0 { if ($3) free_node($3); }
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | ;
constant_list: constant_name
| constant_list ',' constant_name
;
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | constant: modifiers TOK_CONSTANT constant_list ';' {}
| modifiers TOK_CONSTANT error ';' { yyerrok; }
| modifiers TOK_CONSTANT error TOK_LEX_EOF
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
yyerror("Missing ';'.");
yyerror("Unexpected end of file.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | modifiers TOK_CONSTANT error '}' { yyerror("Missing ';'."); }
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | ;
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | block_or_semi: block
{
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$ = check_node_hash(mknode(F_COMMA_EXPR,$1,mknode(F_RETURN,mkintnode(0),0)));
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
76b449 | 1999-12-09 | Henrik Grubbström (Grubba) | | | ';' { $$ = NULL; }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_LEX_EOF { yyerror("Expected ';'."); $$ = NULL; }
|
76b449 | 1999-12-09 | Henrik Grubbström (Grubba) | | | error { $$ = NULL; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
type_or_error: simple_type
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | #ifdef PIKE_DEBUG
check_type_string(check_node_hash($1)->u.sval.u.string);
#endif /* PIKE_DEBUG */
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(compiler_frame->current_type)
free_string(compiler_frame->current_type);
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | copy_shared_string(compiler_frame->current_type,$1->u.sval.u.string);
free_node($1);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | ;
|
76b449 | 1999-12-09 | Henrik Grubbström (Grubba) | |
close_paren_or_missing: ')'
|
bb213c | 1999-12-27 | Henrik Grubbström (Grubba) | | {
/* Used to hold line-number info */
$$ = mkintnode(0);
}
|
76b449 | 1999-12-09 | Henrik Grubbström (Grubba) | | | /* empty */
{
yyerror("Missing ')'.");
|
bb213c | 1999-12-27 | Henrik Grubbström (Grubba) | | /* Used to hold line-number info */
$$ = mkintnode(0);
|
76b449 | 1999-12-09 | Henrik Grubbström (Grubba) | | }
;
close_brace_or_missing: '}'
| /* empty */
{
yyerror("Missing '}'.");
}
;
close_bracket_or_missing: ']'
| /* empty */
{
yyerror("Missing ']'.");
}
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | push_compiler_frame0: /* empty */
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
|
8322b6 | 2000-05-08 | Fredrik Hübinette (Hubbe) | | push_compiler_frame(SCOPE_LOCAL);
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(!compiler_frame->previous ||
!compiler_frame->previous->current_type)
{
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | yyerror("Internal compiler fault.");
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | copy_shared_string(compiler_frame->current_type,
mixed_type_string);
}else{
copy_shared_string(compiler_frame->current_type,
compiler_frame->previous->current_type);
}
}
|
3ec3df | 1999-12-16 | Henrik Grubbström (Grubba) | | ;
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | def: modifiers type_or_error optional_stars TOK_IDENTIFIER push_compiler_frame0
|
76b449 | 1999-12-09 | Henrik Grubbström (Grubba) | | '(' arguments close_paren_or_missing
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
int e;
/* construct the function type */
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | push_finished_type(compiler_frame->current_type);
|
67abdc | 2000-02-17 | Henrik Grubbström (Grubba) | | if ($3 && (compiler_pass == 2)) {
|
66f771 | 2000-02-17 | Henrik Grubbström (Grubba) | | yywarning("The *-syntax in types is obsolete. Use array instead.");
}
|
febbc8 | 1997-04-22 | Fredrik Hübinette (Hubbe) | | while(--$3>=0) push_type(T_ARRAY);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(compiler_frame->current_return_type)
free_string(compiler_frame->current_return_type);
|
4142a6 | 1998-05-19 | Fredrik Hübinette (Hubbe) | | compiler_frame->current_return_type=compiler_pop_type();
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | push_finished_type(compiler_frame->current_return_type);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | |
|
3ec3df | 1999-12-16 | Henrik Grubbström (Grubba) | | e=$7-1;
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | if(varargs)
{
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | push_finished_type(compiler_frame->variable[e].type);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | e--;
varargs=0;
pop_type_stack();
}else{
push_type(T_VOID);
}
push_type(T_MANY);
for(; e>=0; e--)
{
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | push_finished_type(compiler_frame->variable[e].type);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
push_type(T_FUNCTION);
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | |
{
|
4142a6 | 1998-05-19 | Fredrik Hübinette (Hubbe) | | struct pike_string *s=compiler_pop_type();
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | $<n>$=mkstrnode(s);
free_string(s);
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
6fd517 | 2000-04-25 | Fredrik Hübinette (Hubbe) | | /* if(compiler_pass==1) */
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
|
6fd517 | 2000-04-25 | Fredrik Hübinette (Hubbe) | | /* FIXME:
* set current_function_number for local functions as well
*/
compiler_frame->current_function_number=
define_function(check_node_hash($4)->u.sval.u.string,
check_node_hash($<n>$)->u.sval.u.string,
$1 & (~ID_EXTERN),
IDENTIFIER_PIKE_FUNCTION,
0);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
block_or_semi
{
int e;
|
3ec3df | 1999-12-16 | Henrik Grubbström (Grubba) | | if($10)
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
22edc2 | 1998-01-29 | Fredrik Hübinette (Hubbe) | | int f;
|
b9188f | 1999-12-13 | Henrik Grubbström (Grubba) | | node *check_args = NULL;
|
bb213c | 1999-12-27 | Henrik Grubbström (Grubba) | | int save_line = lex.current_line;
#ifdef PIKE_DEBUG
struct pike_string *save_file = lex.current_file;
lex.current_file = $8->current_file;
#endif /* PIKE_DEBUG */
lex.current_line = $8->line_number;
|
b9188f | 1999-12-13 | Henrik Grubbström (Grubba) | |
|
8fd931 | 1999-12-30 | Henrik Grubbström (Grubba) | | if (($1 & ID_EXTERN) && (compiler_pass == 1)) {
yywarning("Extern declared function definition.");
}
|
3ec3df | 1999-12-16 | Henrik Grubbström (Grubba) | | for(e=0; e<$7; e++)
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(!compiler_frame->variable[e].name ||
!compiler_frame->variable[e].name->len)
|
b9188f | 1999-12-13 | Henrik Grubbström (Grubba) | | {
my_yyerror("Missing name for argument %d.",e);
} else {
/* FIXME: Should probably use some other flag. */
|
7d955e | 1999-12-13 | Henrik Grubbström (Grubba) | | if ((runtime_options & RUNTIME_CHECK_TYPES) &&
(compiler_pass == 2) &&
|
b9188f | 1999-12-13 | Henrik Grubbström (Grubba) | | (compiler_frame->variable[e].type != mixed_type_string)) {
node *local_node;
/* fprintf(stderr, "Creating soft cast node for local #%d\n", e);*/
local_node = mklocalnode(e, 0);
/* The following is needed to go around the optimization in
* mksoftcastnode().
*/
free_string(local_node->type);
copy_shared_string(local_node->type, mixed_type_string);
check_args =
mknode(F_COMMA_EXPR, check_args,
mksoftcastnode(compiler_frame->variable[e].type,
local_node));
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
b9188f | 1999-12-13 | Henrik Grubbström (Grubba) | | }
}
if (check_args) {
/* Prepend the arg checking code. */
|
3ec3df | 1999-12-16 | Henrik Grubbström (Grubba) | | $10 = mknode(F_COMMA_EXPR, mknode(F_POP_VALUE, check_args, NULL), $10);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
329cc0 | 1997-02-17 | Fredrik Hübinette (Hubbe) | |
|
bb213c | 1999-12-27 | Henrik Grubbström (Grubba) | | lex.current_line = save_line;
#ifdef PIKE_DEBUG
lex.current_file = save_file;
#endif /* PIKE_DEBUG */
|
6fd517 | 2000-04-25 | Fredrik Hübinette (Hubbe) | | f=dooptcode(check_node_hash($4)->u.sval.u.string,
check_node_hash($10),
check_node_hash($<n>9)->u.sval.u.string,
$1);
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
294dc5 | 1997-08-03 | Fredrik Hübinette (Hubbe) | | if(recoveries && sp-evaluator_stack < recoveries->sp)
fatal("Stack error (underflow)\n");
|
ae9503 | 1999-04-07 | Fredrik Hübinette (Hubbe) | |
|
6fd517 | 2000-04-25 | Fredrik Hübinette (Hubbe) | | if(compiler_pass == 1 && f!=compiler_frame->current_function_number)
fatal("define_function screwed up! %d != %d\n",f,compiler_frame->current_function_number);
|
294dc5 | 1997-08-03 | Fredrik Hübinette (Hubbe) | | #endif
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | pop_compiler_frame();
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_node($4);
|
bb213c | 1999-12-27 | Henrik Grubbström (Grubba) | | free_node($8);
|
3ec3df | 1999-12-16 | Henrik Grubbström (Grubba) | | free_node($<n>9);
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | modifiers type_or_error optional_stars TOK_IDENTIFIER push_compiler_frame0
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | error
{
pop_compiler_frame();
free_node($4);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | | modifiers type_or_error optional_stars bad_identifier
{
|
4142a6 | 1998-05-19 | Fredrik Hübinette (Hubbe) | | free_string(compiler_pop_type());
|
33b82c | 1999-12-19 | Henrik Grubbström (Grubba) | | }
'(' arguments ')' block_or_semi
{
if ($9) free_node($9);
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | modifiers type_or_error name_list ';' {}
| inheritance {}
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | | import {}
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | | constant {}
|
121d49 | 1996-11-27 | Fredrik Hübinette (Hubbe) | | | class { free_node($1); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | error TOK_LEX_EOF
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
reset_type_stack();
yyerror("Missing ';'.");
yyerror("Unexpected end of file");
}
|
07f33e | 1998-11-05 | Henrik Grubbström (Grubba) | | | error ';'
{
reset_type_stack();
yyerrok;
/* if(num_parse_error>5) YYACCEPT; */
}
|
296836 | 1998-04-14 | Henrik Grubbström (Grubba) | | | error '}'
{
reset_type_stack();
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | yyerror("Missing ';'.");
|
eb5c90 | 1998-04-19 | Fredrik Hübinette (Hubbe) | | /* yychar = '}'; */ /* Put the '}' back on the input stream */
|
296836 | 1998-04-14 | Henrik Grubbström (Grubba) | | }
|
21b2c9 | 1999-12-17 | Fredrik Hübinette (Hubbe) | | | modifiers
'{'
{
$<number>$=lex.pragmas;
lex.pragmas|=$1;
}
program
'}'
{
lex.pragmas=$<number>3;
}
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | optional_dot_dot_dot: TOK_DOT_DOT_DOT { $$=1; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | /* empty */ { $$=0; }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | optional_identifier: TOK_IDENTIFIER
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | | bad_identifier { $$=0; }
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | | /* empty */ { $$=0; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | new_arg_name: type7 optional_dot_dot_dot optional_identifier
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
if(varargs) yyerror("Can't define more arguments after ...");
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | if($2)
{
push_type(T_ARRAY);
varargs=1;
}
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | |
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(!$3)
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | {
struct pike_string *s;
MAKE_CONSTANT_SHARED_STRING(s,"");
$3=mkstrnode(s);
free_string(s);
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
96ab24 | 1998-02-28 | Fredrik Hübinette (Hubbe) | | if($3->u.sval.u.string->len &&
islocal($3->u.sval.u.string) >= 0)
|
c01239 | 1997-03-11 | Henrik Grubbström (Grubba) | | my_yyerror("Variable '%s' appears twice in argument list.",
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | $3->u.sval.u.string->str);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | |
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | add_local_name($3->u.sval.u.string, compiler_pop_type(),0);
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_node($3);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
bb213c | 1999-12-27 | Henrik Grubbström (Grubba) | | func_args: '(' arguments close_paren_or_missing
{
free_node($3);
$$=$2;
}
;
|
febbc8 | 1997-04-22 | Fredrik Hübinette (Hubbe) | |
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | arguments: /* empty */ optional_comma { $$=0; }
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | | arguments2 optional_comma
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
arguments2: new_arg_name { $$ = 1; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | arguments2 ',' new_arg_name { $$ = $1 + 1; }
|
76b449 | 1999-12-09 | Henrik Grubbström (Grubba) | | | arguments2 ':' new_arg_name
{
yyerror("Unexpected ':' in argument list.");
$$ = $1 + 1;
}
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | modifier: TOK_NO_MASK { $$ = ID_NOMASK; }
| TOK_FINAL_ID { $$ = ID_NOMASK; }
| TOK_STATIC { $$ = ID_STATIC; }
| TOK_EXTERN { $$ = ID_EXTERN; }
| TOK_OPTIONAL { $$ = ID_OPTIONAL; }
| TOK_PRIVATE { $$ = ID_PRIVATE | ID_STATIC; }
| TOK_LOCAL_ID { $$ = ID_INLINE; }
| TOK_PUBLIC { $$ = ID_PUBLIC; }
| TOK_PROTECTED { $$ = ID_PROTECTED; }
| TOK_INLINE { $$ = ID_INLINE; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
315aa8 | 1999-12-17 | Fredrik Hübinette (Hubbe) | | magic_identifiers1:
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | TOK_NO_MASK { $$ = "nomask"; }
| TOK_FINAL_ID { $$ = "final"; }
| TOK_STATIC { $$ = "static"; }
| TOK_EXTERN { $$ = "extern"; }
| TOK_PRIVATE { $$ = "private"; }
| TOK_LOCAL_ID { $$ = "local"; }
| TOK_PUBLIC { $$ = "public"; }
| TOK_PROTECTED { $$ = "protected"; }
| TOK_INLINE { $$ = "inline"; }
| TOK_OPTIONAL { $$ = "optional"; }
|
315aa8 | 1999-12-17 | Fredrik Hübinette (Hubbe) | | ;
magic_identifiers2:
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | TOK_VOID_ID { $$ = "void"; }
| TOK_MIXED_ID { $$ = "mixed"; }
| TOK_ARRAY_ID { $$ = "array"; }
| TOK_MAPPING_ID { $$ = "mapping"; }
| TOK_MULTISET_ID { $$ = "multiset"; }
| TOK_OBJECT_ID { $$ = "object"; }
| TOK_FUNCTION_ID { $$ = "function"; }
| TOK_PROGRAM_ID { $$ = "program"; }
| TOK_STRING_ID { $$ = "string"; }
| TOK_FLOAT_ID { $$ = "float"; }
| TOK_INT_ID { $$ = "int"; }
|
315aa8 | 1999-12-17 | Fredrik Hübinette (Hubbe) | | ;
magic_identifiers3:
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | TOK_IF { $$ = "if"; }
| TOK_DO { $$ = "do"; }
| TOK_FOR { $$ = "for"; }
| TOK_WHILE { $$ = "while"; }
| TOK_ELSE { $$ = "else"; }
| TOK_FOREACH { $$ = "foreach"; }
| TOK_CATCH { $$ = "catch"; }
| TOK_GAUGE { $$ = "gauge"; }
| TOK_CLASS { $$ = "class"; }
| TOK_BREAK { $$ = "break"; }
| TOK_CASE { $$ = "case"; }
| TOK_CONSTANT { $$ = "constant"; }
| TOK_CONTINUE { $$ = "continue"; }
| TOK_DEFAULT { $$ = "default"; }
| TOK_IMPORT { $$ = "import"; }
| TOK_INHERIT { $$ = "inherit"; }
| TOK_LAMBDA { $$ = "lambda"; }
| TOK_PREDEF { $$ = "predef"; }
| TOK_RETURN { $$ = "return"; }
| TOK_SSCANF { $$ = "sscanf"; }
| TOK_SWITCH { $$ = "switch"; }
| TOK_TYPEOF { $$ = "typeof"; }
|
315aa8 | 1999-12-17 | Fredrik Hübinette (Hubbe) | | ;
|
21b2c9 | 1999-12-17 | Fredrik Hübinette (Hubbe) | | magic_identifiers: magic_identifiers1 | magic_identifiers2 | magic_identifiers3 ;
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | magic_identifier: TOK_IDENTIFIER
|
21b2c9 | 1999-12-17 | Fredrik Hübinette (Hubbe) | | | magic_identifiers
|
315aa8 | 1999-12-17 | Fredrik Hübinette (Hubbe) | | {
struct pike_string *tmp=make_shared_string($1);
$$=mkstrnode(tmp);
free_string(tmp);
}
;
|
1d73ef | 1999-11-23 | Henrik Grubbström (Grubba) | | modifiers: modifier_list
{
$$=current_modifiers=$1 | (lex.pragmas & ID_MODIFIER_MASK);
}
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
modifier_list: /* empty */ { $$ = 0; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | modifier modifier_list { $$ = $1 | $2; }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
optional_stars: optional_stars '*' { $$=$1 + 1; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | /* empty */ { $$=0; }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | cast: '(' type ')'
{
|
4142a6 | 1998-05-19 | Fredrik Hübinette (Hubbe) | | struct pike_string *s=compiler_pop_type();
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | $$=mkstrnode(s);
free_string(s);
}
|
2e4e45 | 1997-02-13 | Fredrik Hübinette (Hubbe) | | ;
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | |
|
1d73ef | 1999-11-23 | Henrik Grubbström (Grubba) | | soft_cast: '[' type ']'
{
struct pike_string *s=compiler_pop_type();
$$=mkstrnode(s);
free_string(s);
}
;
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | type6: type | identifier_type ;
|
2e4e45 | 1997-02-13 | Fredrik Hübinette (Hubbe) | |
|
66f771 | 2000-02-17 | Henrik Grubbström (Grubba) | | type: type '*'
{
|
67abdc | 2000-02-17 | Henrik Grubbström (Grubba) | | if (compiler_pass == 2) {
yywarning("The *-syntax in types is obsolete. Use array instead.");
}
|
66f771 | 2000-02-17 | Henrik Grubbström (Grubba) | | push_type(T_ARRAY);
}
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | type2
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
66f771 | 2000-02-17 | Henrik Grubbström (Grubba) | | type7: type7 '*'
{
|
67abdc | 2000-02-17 | Henrik Grubbström (Grubba) | | if (compiler_pass == 2) {
yywarning("The *-syntax in types is obsolete. Use array instead.");
}
|
66f771 | 2000-02-17 | Henrik Grubbström (Grubba) | | push_type(T_ARRAY);
}
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | | type4
;
simple_type: type4
{
|
4142a6 | 1998-05-19 | Fredrik Hübinette (Hubbe) | | struct pike_string *s=compiler_pop_type();
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | $$=mkstrnode(s);
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | #ifdef PIKE_DEBUG
if ($$->u.sval.u.string != s) {
fatal("mkstrnode(%p:\"%s\") created node with %p:\"%s\"\n",
s, s->str, $$->u.sval.u.string, $$->u.sval.u.string->str);
}
#endif /* PIKE_DEBUG */
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | free_string(s);
}
;
simple_type2: type2
{
|
4142a6 | 1998-05-19 | Fredrik Hübinette (Hubbe) | | struct pike_string *s=compiler_pop_type();
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | $$=mkstrnode(s);
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | #ifdef PIKE_DEBUG
if ($$->u.sval.u.string != s) {
fatal("mkstrnode(%p:\"%s\") created node with %p:\"%s\"\n",
s, s->str, $$->u.sval.u.string, $$->u.sval.u.string->str);
}
#endif /* PIKE_DEBUG */
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | free_string(s);
}
;
simple_identifier_type: identifier_type
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | {
|
4142a6 | 1998-05-19 | Fredrik Hübinette (Hubbe) | | struct pike_string *s=compiler_pop_type();
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | $$=mkstrnode(s);
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | #ifdef PIKE_DEBUG
if ($$->u.sval.u.string != s) {
fatal("mkstrnode(%p:\"%s\") created node with %p:\"%s\"\n",
s, s->str, $$->u.sval.u.string, $$->u.sval.u.string->str);
}
#endif /* PIKE_DEBUG */
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_string(s);
}
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | identifier_type: idents
|
7a08f3 | 2000-01-25 | Henrik Grubbström (Grubba) | | {
resolv_constant($1);
if (sp[-1].type == T_TYPE) {
/* "typedef" */
push_finished_type(sp[-1].u.string);
} else {
/* object type */
struct program *p = NULL;
if (sp[-1].type == T_OBJECT) {
if(!sp[-1].u.object->prog)
{
pop_stack();
push_int(0);
yyerror("Destructed object used as program identifier.");
}else{
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | extern void f_object_program(INT32);
|
7a08f3 | 2000-01-25 | Henrik Grubbström (Grubba) | | f_object_program(1);
}
}
switch(sp[-1].type) {
case T_FUNCTION:
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | if((p = program_from_function(sp-1)))
|
7a08f3 | 2000-01-25 | Henrik Grubbström (Grubba) | | break;
default:
if (compiler_pass!=1)
yyerror("Illegal program identifier.");
pop_stack();
push_int(0);
break;
case T_PROGRAM:
p = sp[-1].u.program;
break;
}
if(p) {
push_type_int(p->id);
}else{
push_type_int(0);
}
push_type(0);
push_type(T_OBJECT);
}
pop_stack();
free_node($1);
}
;
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | |
|
7e0f82 | 1999-11-15 | Martin Stjernholm | | type4: type4 '|' type8 { push_type(T_OR); }
| type8
;
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | |
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | type2: type2 '|' type3 { push_type(T_OR); }
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | | type3
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | type3: TOK_INT_ID opt_int_range { push_type(T_INT); }
| TOK_FLOAT_ID { push_type(T_FLOAT); }
| TOK_PROGRAM_ID { push_type(T_PROGRAM); }
| TOK_VOID_ID { push_type(T_VOID); }
| TOK_MIXED_ID { push_type(T_MIXED); }
| TOK_STRING_ID { push_type(T_STRING); }
| TOK_OBJECT_ID opt_object_type { push_type(T_OBJECT); }
| TOK_MAPPING_ID opt_mapping_type { push_type(T_MAPPING); }
| TOK_ARRAY_ID opt_array_type { push_type(T_ARRAY); }
| TOK_MULTISET_ID opt_array_type { push_type(T_MULTISET); }
| TOK_FUNCTION_ID opt_function_type { push_type(T_FUNCTION); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
7e0f82 | 1999-11-15 | Martin Stjernholm | | type8: type3 | identifier_type ;
|
f5fd53 | 1999-03-29 | Henrik Grubbström (Grubba) | | number_or_maxint: /* Empty */
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | {
|
011ad3 | 1999-10-22 | Fredrik Hübinette (Hubbe) | | $$ = mkintnode(MAX_INT32);
|
f5fd53 | 1999-03-29 | Henrik Grubbström (Grubba) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_NUMBER
| '-' TOK_NUMBER
|
3dc856 | 1999-12-30 | Henrik Grubbström (Grubba) | | {
#ifdef PIKE_DEBUG
if (($2->token != F_CONSTANT) || ($2->u.sval.type != T_INT)) {
fatal("Unexpected number in negative int-range.\n");
}
#endif /* PIKE_DEBUG */
$$ = mkintnode(-($2->u.sval.u.integer));
free_node($2);
}
|
f5fd53 | 1999-03-29 | Henrik Grubbström (Grubba) | | ;
number_or_minint: /* Empty */
{
|
011ad3 | 1999-10-22 | Fredrik Hübinette (Hubbe) | | $$ = mkintnode(MIN_INT32);
|
f5fd53 | 1999-03-29 | Henrik Grubbström (Grubba) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_NUMBER
| '-' TOK_NUMBER
|
3dc856 | 1999-12-30 | Henrik Grubbström (Grubba) | | {
#ifdef PIKE_DEBUG
if (($2->token != F_CONSTANT) || ($2->u.sval.type != T_INT)) {
fatal("Unexpected number in negative int-range.\n");
}
#endif /* PIKE_DEBUG */
$$ = mkintnode(-($2->u.sval.u.integer));
free_node($2);
}
|
f5fd53 | 1999-03-29 | Henrik Grubbström (Grubba) | | ;
opt_int_range: /* Empty */
{
push_type_int(MAX_INT32);
push_type_int(MIN_INT32);
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | '(' number_or_minint TOK_DOT_DOT number_or_maxint ')'
|
f5fd53 | 1999-03-29 | Henrik Grubbström (Grubba) | | {
/* FIXME: Check that $4 is >= $2. */
|
1e00c1 | 2000-06-09 | Martin Stjernholm | | if($4->token == F_CONSTANT && $4->u.sval.type == T_INT)
|
011ad3 | 1999-10-22 | Fredrik Hübinette (Hubbe) | | {
push_type_int($4->u.sval.u.integer);
}else{
push_type_int(MAX_INT32);
}
|
6bbfee | 1999-11-21 | Henrik Grubbström (Grubba) | | if($2->token == F_CONSTANT && $2->u.sval.type == T_INT)
|
011ad3 | 1999-10-22 | Fredrik Hübinette (Hubbe) | | {
|
6bbfee | 1999-11-21 | Henrik Grubbström (Grubba) | | push_type_int($2->u.sval.u.integer);
|
011ad3 | 1999-10-22 | Fredrik Hübinette (Hubbe) | | }else{
push_type_int(MIN_INT32);
}
free_node($2);
free_node($4);
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | }
|
3803c2 | 1998-11-11 | Henrik Grubbström (Grubba) | | ;
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | |
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | opt_object_type: /* Empty */ { push_type_int(0); push_type(0); }
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | | '(' program_ref ')'
{
|
66c236 | 1998-08-29 | Henrik Grubbström (Grubba) | | /* NOTE: On entry, there are two items on the stack:
* sp-2: Name of the program reference (string).
* sp-1: The resolved program (program|function|zero).
*/
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | struct program *p=program_from_svalue(sp-1);
if(p)
|
1532e6 | 1996-11-16 | Fredrik Hübinette (Hubbe) | | {
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | push_type_int(p->id);
|
1532e6 | 1996-11-16 | Fredrik Hübinette (Hubbe) | | }else{
|
a78643 | 1999-11-18 | Martin Stjernholm | | if (compiler_pass!=1) {
if ((sp[-2].type == T_STRING) && (sp[-2].u.string->len > 0) &&
(sp[-2].u.string->len < 256)) {
my_yyerror("Not a valid program specifier: '%s'",
sp[-2].u.string->str);
} else {
yyerror("Not a valid program specifier.");
}
|
66c236 | 1998-08-29 | Henrik Grubbström (Grubba) | | }
|
1532e6 | 1996-11-16 | Fredrik Hübinette (Hubbe) | | push_type_int(0);
}
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | pop_n_elems(2);
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | push_type(0);
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | opt_function_type: '('
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
type_stack_mark();
type_stack_mark();
}
function_type_list optional_dot_dot_dot ':'
{
if ($4)
{
|
7e71da | 2000-03-30 | Henrik Grubbström (Grubba) | | if ($3) {
push_type(T_MANY);
type_stack_reverse();
} else {
/* function_type_list ends with a comma, or is empty.
* FIXME: Should this be a syntax error or not?
*/
|
85fb3d | 2000-03-30 | Henrik Grubbström (Grubba) | | if (compiler_pass == 1) {
|
6deabd | 2000-03-30 | Henrik Grubbström (Grubba) | | yyerror("Missing type before ... .");
|
85fb3d | 2000-03-30 | Henrik Grubbström (Grubba) | | }
|
7e71da | 2000-03-30 | Henrik Grubbström (Grubba) | | type_stack_reverse();
push_type(T_MANY);
push_type(T_MIXED);
|
cbae7e | 2000-03-30 | Henrik Grubbström (Grubba) | | }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }else{
type_stack_reverse();
push_type(T_MANY);
push_type(T_VOID);
}
type_stack_mark();
}
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | type7 ')'
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
type_stack_reverse();
type_stack_reverse();
}
| /* empty */
{
push_type(T_MIXED);
|
327c05 | 1999-11-24 | Fredrik Hübinette (Hubbe) | | push_type(T_VOID);
push_type(T_OR);
|
2401c7 | 2000-01-03 | Martin Stjernholm | | push_type(T_ZERO);
|
327c05 | 1999-11-24 | Fredrik Hübinette (Hubbe) | | push_type(T_VOID);
push_type(T_OR);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | push_type(T_MANY);
}
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
cbae7e | 2000-03-30 | Henrik Grubbström (Grubba) | | function_type_list: /* Empty */ optional_comma { $$=0; }
| function_type_list2 optional_comma { $$=!$2; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
cbae7e | 2000-03-30 | Henrik Grubbström (Grubba) | | function_type_list2: type7 { $$=1; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | function_type_list2 ','
{
type_stack_reverse();
type_stack_mark();
}
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | type7
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | opt_array_type: '(' type7 ')'
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | { push_type(T_MIXED); }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
opt_mapping_type: '('
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
type_stack_mark();
type_stack_mark();
}
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | type7 ':'
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
type_stack_reverse();
type_stack_mark();
}
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | type7
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
type_stack_reverse();
type_stack_reverse();
}
')'
| /* empty */
{
push_type(T_MIXED);
push_type(T_MIXED);
}
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
name_list: new_name
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | name_list ',' new_name
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | new_name: optional_stars TOK_IDENTIFIER
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
struct pike_string *type;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | push_finished_type(compiler_frame->current_type);
|
67abdc | 2000-02-17 | Henrik Grubbström (Grubba) | | if ($1 && (compiler_pass == 2)) {
|
66f771 | 2000-02-17 | Henrik Grubbström (Grubba) | | yywarning("The *-syntax in types is obsolete. Use array instead.");
}
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | while($1--) push_type(T_ARRAY);
|
4142a6 | 1998-05-19 | Fredrik Hübinette (Hubbe) | | type=compiler_pop_type();
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | define_variable($2->u.sval.u.string, type, current_modifiers);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | free_string(type);
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_node($2);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | | optional_stars bad_identifier {}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | optional_stars TOK_IDENTIFIER '='
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
struct pike_string *type;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | push_finished_type(compiler_frame->current_type);
|
67abdc | 2000-02-17 | Henrik Grubbström (Grubba) | | if ($1 && (compiler_pass == 2)) {
|
66f771 | 2000-02-17 | Henrik Grubbström (Grubba) | | yywarning("The *-syntax in types is obsolete. Use array instead.");
}
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | while($1--) push_type(T_ARRAY);
|
4142a6 | 1998-05-19 | Fredrik Hübinette (Hubbe) | | type=compiler_pop_type();
|
8fd931 | 1999-12-30 | Henrik Grubbström (Grubba) | | if ((current_modifiers & ID_EXTERN) && (compiler_pass == 1)) {
yywarning("Extern declared variable has initializer.");
}
$<number>$=define_variable($2->u.sval.u.string, type,
current_modifiers & (~ID_EXTERN));
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | free_string(type);
}
expr0
{
|
3d7882 | 1999-11-06 | Henrik Grubbström (Grubba) | | init_node=mknode(F_COMMA_EXPR,init_node,
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | mkcastnode(void_type_string,
mknode(F_ASSIGN,$5,
mkidentifiernode($<number>4))));
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_node($2);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | optional_stars TOK_IDENTIFIER '=' error
|
296836 | 1998-04-14 | Henrik Grubbström (Grubba) | | {
free_node($2);
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | optional_stars TOK_IDENTIFIER '=' TOK_LEX_EOF
|
e67c86 | 1998-08-01 | Henrik Grubbström (Grubba) | | {
yyerror("Unexpected end of file in variable definition.");
free_node($2);
}
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | | optional_stars bad_identifier '=' expr0
{
free_node($4);
}
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | new_local_name: optional_stars TOK_IDENTIFIER
|
6bbfee | 1999-11-21 | Henrik Grubbström (Grubba) | | {
|
4943aa | 1998-04-09 | Fredrik Hübinette (Hubbe) | | push_finished_type($<n>0->u.sval.u.string);
|
67abdc | 2000-02-17 | Henrik Grubbström (Grubba) | | if ($1 && (compiler_pass == 2)) {
|
66f771 | 2000-02-17 | Henrik Grubbström (Grubba) | | yywarning("The *-syntax in types is obsolete. Use array instead.");
}
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | while($1--) push_type(T_ARRAY);
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | add_local_name($2->u.sval.u.string, compiler_pop_type(),0);
|
1c858f | 1999-11-14 | Henrik Grubbström (Grubba) | | $$=mknode(F_ASSIGN,mkintnode(0),mklocalnode(islocal($2->u.sval.u.string),0));
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_node($2);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
5b6acd | 1998-04-30 | Fredrik Hübinette (Hubbe) | | | optional_stars bad_identifier { $$=0; }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | optional_stars TOK_IDENTIFIER '=' expr0
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
4943aa | 1998-04-09 | Fredrik Hübinette (Hubbe) | | push_finished_type($<n>0->u.sval.u.string);
|
67abdc | 2000-02-17 | Henrik Grubbström (Grubba) | | if ($1 && (compiler_pass == 2)) {
|
66f771 | 2000-02-17 | Henrik Grubbström (Grubba) | | yywarning("The *-syntax in types is obsolete. Use array instead.");
}
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | while($1--) push_type(T_ARRAY);
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | add_local_name($2->u.sval.u.string, compiler_pop_type(),0);
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | $$=mknode(F_ASSIGN,$4,mklocalnode(islocal($2->u.sval.u.string),0));
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_node($2);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | | optional_stars bad_identifier '=' expr0
{
free_node($4);
|
5b6acd | 1998-04-30 | Fredrik Hübinette (Hubbe) | | $$=0;
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | optional_stars TOK_IDENTIFIER '=' error
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | {
free_node($2);
/* No yyerok here since we aren't done yet. */
|
5b6acd | 1998-04-30 | Fredrik Hübinette (Hubbe) | | $$=0;
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | optional_stars TOK_IDENTIFIER '=' TOK_LEX_EOF
|
e67c86 | 1998-08-01 | Henrik Grubbström (Grubba) | | {
yyerror("Unexpected end of file in local variable definition.");
free_node($2);
/* No yyerok here since we aren't done yet. */
$$=0;
}
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | new_local_name2: TOK_IDENTIFIER
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | {
|
e73dae | 1998-04-17 | Fredrik Hübinette (Hubbe) | | add_ref($<n>0->u.sval.u.string);
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | add_local_name($1->u.sval.u.string, $<n>0->u.sval.u.string, 0);
|
1c858f | 1999-11-14 | Henrik Grubbström (Grubba) | | $$=mknode(F_ASSIGN,mkintnode(0),mklocalnode(islocal($1->u.sval.u.string),0));
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | free_node($1);
}
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | | bad_identifier { $$=0; }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_IDENTIFIER '=' safe_expr0
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | {
|
e73dae | 1998-04-17 | Fredrik Hübinette (Hubbe) | | add_ref($<n>0->u.sval.u.string);
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | add_local_name($1->u.sval.u.string, $<n>0->u.sval.u.string, 0);
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | $$=mknode(F_ASSIGN,$3, mklocalnode(islocal($1->u.sval.u.string),0));
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | free_node($1);
}
|
998e1f | 1998-04-15 | Henrik Grubbström (Grubba) | | | bad_identifier '=' safe_expr0 { $$=$3; }
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | block:'{'
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | $<number>1=num_used_modules;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | $<number>$=compiler_frame->current_number_of_locals;
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | statements end_block
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | unuse_modules(num_used_modules - $<number>1);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | pop_local_variables($<number>2);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | $$=$3;
}
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | end_block: '}'
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_LEX_EOF
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | {
yyerror("Missing '}'.");
yyerror("Unexpected end of file.");
}
;
|
01d3e2 | 1997-04-23 | Fredrik Hübinette (Hubbe) | | failsafe_block: block
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | | error { $$=0; }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_LEX_EOF { yyerror("Unexpected end of file."); $$=0; }
|
01d3e2 | 1997-04-23 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | local_name_list: new_local_name
|
612647 | 2000-03-02 | Fredrik Hübinette (Hubbe) | | | local_name_list ',' { $<n>$=$<n>0; } new_local_name { $$=mknode(F_COMMA_EXPR,mkcastnode(void_type_string,$1),$4); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | local_name_list2: new_local_name2
|
612647 | 2000-03-02 | Fredrik Hübinette (Hubbe) | | | local_name_list2 ',' { $<n>$=$<n>0; } new_local_name { $$=mknode(F_COMMA_EXPR,mkcastnode(void_type_string,$1),$4); }
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | statements: { $$=0; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | statements statement
{
|
3d7882 | 1999-11-06 | Henrik Grubbström (Grubba) | | $$=mknode(F_COMMA_EXPR,$1,mkcastnode(void_type_string,$2));
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | statement: unused2 ';'
| import { $$=0; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | cond
| while
| do
| for
| switch
| case
| default
|
586b8a | 1998-04-28 | Henrik Grubbström (Grubba) | | | return expected_semicolon
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | | block
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | foreach
|
586b8a | 1998-04-28 | Henrik Grubbström (Grubba) | | | break expected_semicolon
| continue expected_semicolon
|
e2acf7 | 1997-04-23 | Henrik Grubbström (Grubba) | | | error ';' { reset_type_stack(); $$=0; yyerrok; }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | error TOK_LEX_EOF
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
reset_type_stack();
yyerror("Missing ';'.");
yyerror("Unexpected end of file.");
$$=0;
}
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | | error '}'
{
reset_type_stack();
|
998e1f | 1998-04-15 | Henrik Grubbström (Grubba) | | yyerror("Missing ';'.");
|
eb5c90 | 1998-04-19 | Fredrik Hübinette (Hubbe) | | /* yychar = '}'; */ /* Put the '}' back on the input stream. */
$$=0;
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | ';' { $$=0; }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | break: TOK_BREAK { $$=mknode(F_BREAK,0,0); } ;
default: TOK_DEFAULT ':' { $$=mknode(F_DEFAULT,0,0); }
| TOK_DEFAULT
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | {
$$=mknode(F_DEFAULT,0,0); yyerror("Expected ':' after default.");
}
;
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | continue: TOK_CONTINUE { $$=mknode(F_CONTINUE,0,0); } ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | push_compiler_frame1: /* empty */
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
8322b6 | 2000-05-08 | Fredrik Hübinette (Hubbe) | | push_compiler_frame(SCOPE_LOCAL);
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | }
;
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | lambda: TOK_LAMBDA push_compiler_frame1
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | {
debug_malloc_touch(compiler_frame->current_return_type);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(compiler_frame->current_return_type)
free_string(compiler_frame->current_return_type);
copy_shared_string(compiler_frame->current_return_type,any_type_string);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
01d3e2 | 1997-04-23 | Fredrik Hübinette (Hubbe) | | func_args failsafe_block
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
struct pike_string *type;
char buf[40];
|
329cc0 | 1997-02-17 | Fredrik Hübinette (Hubbe) | | int f,e;
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | struct pike_string *name;
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | debug_malloc_touch($5);
$5=mknode(F_COMMA_EXPR,$5,mknode(F_RETURN,mkintnode(0),0));
type=find_return_type($5);
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | |
|
b0ef31 | 1999-12-14 | Henrik Grubbström (Grubba) | | if(type) {
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | push_finished_type(type);
|
b0ef31 | 1999-12-14 | Henrik Grubbström (Grubba) | | free_string(type);
} else
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | push_type(T_MIXED);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | |
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | e=$4-1;
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | if(varargs)
{
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | push_finished_type(compiler_frame->variable[e].type);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | e--;
varargs=0;
pop_type_stack();
}else{
push_type(T_VOID);
}
push_type(T_MANY);
for(; e>=0; e--)
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | push_finished_type(compiler_frame->variable[e].type);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | |
push_type(T_FUNCTION);
|
4142a6 | 1998-05-19 | Fredrik Hübinette (Hubbe) | | type=compiler_pop_type();
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
22edc2 | 1998-01-29 | Fredrik Hübinette (Hubbe) | | sprintf(buf,"__lambda_%ld_%ld",
(long)new_program->id,
|
c4d468 | 1998-06-06 | Henrik Grubbström (Grubba) | | (long)(local_class_counter++ & 0xffffffff)); /* OSF/1 cc bug. */
|
8267f4 | 1998-01-28 | Fredrik Hübinette (Hubbe) | | name=make_shared_string(buf);
|
c4d468 | 1998-06-06 | Henrik Grubbström (Grubba) | |
#ifdef LAMBDA_DEBUG
fprintf(stderr, "%d: LAMBDA: %s 0x%08lx 0x%08lx\n",
compiler_pass, buf, (long)new_program->id, local_class_counter-1);
#endif /* LAMBDA_DEBUG */
|
8267f4 | 1998-01-28 | Fredrik Hübinette (Hubbe) | |
f=dooptcode(name,
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | $5,
|
8267f4 | 1998-01-28 | Fredrik Hübinette (Hubbe) | | type,
|
c6eb96 | 1999-12-14 | Fredrik Hübinette (Hubbe) | | ID_STATIC | ID_PRIVATE | ID_INLINE);
|
22edc2 | 1998-01-29 | Fredrik Hübinette (Hubbe) | |
|
8322b6 | 2000-05-08 | Fredrik Hübinette (Hubbe) | | if(compiler_frame->lexical_scope & SCOPE_SCOPED) {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$ = mktrampolinenode(f);
} else {
$$ = mkidentifiernode(f);
}
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | free_string(name);
free_string(type);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | pop_compiler_frame();
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_LAMBDA push_compiler_frame1 error
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | {
pop_compiler_frame();
}
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | local_function: TOK_IDENTIFIER push_compiler_frame1 func_args
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | {
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | char buf[40];
struct pike_string *name,*type;
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | int id,e;
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | node *n;
struct identifier *i=0;
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | debug_malloc_touch(compiler_frame->current_return_type);
if(compiler_frame->current_return_type)
free_string(compiler_frame->current_return_type);
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | copy_shared_string(compiler_frame->current_return_type,
$<n>0->u.sval.u.string);
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | |
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | |
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | /***/
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | push_finished_type(compiler_frame->current_return_type);
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | e=$3-1;
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | if(varargs)
{
push_finished_type(compiler_frame->variable[e].type);
e--;
varargs=0;
pop_type_stack();
}else{
push_type(T_VOID);
}
push_type(T_MANY);
for(; e>=0; e--)
push_finished_type(compiler_frame->variable[e].type);
push_type(T_FUNCTION);
type=compiler_pop_type();
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | /***/
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | |
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | sprintf(buf,"__lambda_%ld_%ld",
(long)new_program->id,
(long)(local_class_counter++ & 0xffffffff)); /* OSF/1 cc bug. */
#ifdef LAMBDA_DEBUG
fprintf(stderr, "%d: LAMBDA: %s 0x%08lx 0x%08lx\n",
compiler_pass, buf, (long)new_program->id, local_class_counter-1);
#endif /* LAMBDA_DEBUG */
name=make_shared_string(buf);
id=define_function(name,
type,
0,
IDENTIFIER_PIKE_FUNCTION,
0);
n=0;
#if 0
if(compiler_pass > 1 &&
(i=ID_FROM_INT(new_program, id)))
if(!(i->identifier_flags & IDENTIFIER_SCOPED))
n = mkidentifiernode(id);
#endif
low_add_local_name(compiler_frame->previous,
$1->u.sval.u.string, type, n);
$<number>$=id;
free_string(name);
}
failsafe_block
{
int localid;
struct identifier *i=ID_FROM_INT(new_program, $<number>4);
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | $5=mknode(F_COMMA_EXPR,$5,mknode(F_RETURN,mkintnode(0),0));
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | |
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | debug_malloc_touch($5);
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | dooptcode(i->name,
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | $5,
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | i->type,
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | ID_STATIC | ID_PRIVATE | ID_INLINE);
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | |
pop_compiler_frame();
free_node($1);
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | |
/* WARNING: If the local function adds more variables we are screwed */
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | /* WARNING2: if add_local_name stops adding local variables at the end,
* this has to be fixed.
*/
localid=compiler_frame->current_number_of_locals-1;
if(compiler_frame->variable[localid].def)
{
$$=copy_node(compiler_frame->variable[localid].def);
}else{
|
d18707 | 2000-06-20 | Fredrik Hübinette (Hubbe) | | if(compiler_frame->lexical_scope & SCOPE_SCOPE_USED)
{
$$ = mknode(F_ASSIGN, mktrampolinenode($<number>3),
mklocalnode(localid,0));
}else{
$$ = mknode(F_ASSIGN, mkidentifiernode($<number>3),
mklocalnode(localid,0));
}
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | }
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_IDENTIFIER push_compiler_frame1 error
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | {
pop_compiler_frame();
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | $$=mkintnode(0);
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | }
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | ;
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | local_function2: optional_stars TOK_IDENTIFIER push_compiler_frame1 func_args
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | {
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | char buf[40];
struct pike_string *name,*type;
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | int id,e;
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | node *n;
struct identifier *i=0;
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | /***/
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | debug_malloc_touch(compiler_frame->current_return_type);
push_finished_type($<n>0->u.sval.u.string);
|
67abdc | 2000-02-17 | Henrik Grubbström (Grubba) | | if ($1 && (compiler_pass == 2)) {
|
66f771 | 2000-02-17 | Henrik Grubbström (Grubba) | | yywarning("The *-syntax in types is obsolete. Use array instead.");
}
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | while($1--) push_type(T_ARRAY);
if(compiler_frame->current_return_type)
free_string(compiler_frame->current_return_type);
compiler_frame->current_return_type=compiler_pop_type();
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | |
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | /***/
push_finished_type(compiler_frame->current_return_type);
e=$4-1;
if(varargs)
{
push_finished_type(compiler_frame->variable[e].type);
e--;
varargs=0;
pop_type_stack();
}else{
push_type(T_VOID);
}
push_type(T_MANY);
for(; e>=0; e--)
push_finished_type(compiler_frame->variable[e].type);
push_type(T_FUNCTION);
type=compiler_pop_type();
/***/
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | |
sprintf(buf,"__lambda_%ld_%ld",
(long)new_program->id,
(long)(local_class_counter++ & 0xffffffff)); /* OSF/1 cc bug. */
#ifdef LAMBDA_DEBUG
fprintf(stderr, "%d: LAMBDA: %s 0x%08lx 0x%08lx\n",
compiler_pass, buf, (long)new_program->id, local_class_counter-1);
#endif /* LAMBDA_DEBUG */
name=make_shared_string(buf);
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | |
id=define_function(name,
type,
0,
IDENTIFIER_PIKE_FUNCTION,
0);
n=0;
#if 0
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | if(compiler_pass > 1 &&
(i=ID_FROM_INT(new_program, id)))
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | if(!(i->identifier_flags & IDENTIFIER_SCOPED))
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | n = mkidentifiernode(id);
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | #endif
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | |
low_add_local_name(compiler_frame->previous,
$2->u.sval.u.string, type, n);
$<number>$=id;
free_string(name);
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | }
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | failsafe_block
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | {
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | int localid;
struct identifier *i=ID_FROM_INT(new_program, $<number>5);
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | |
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | debug_malloc_touch($6);
$6=mknode(F_COMMA_EXPR,$6,mknode(F_RETURN,mkintnode(0),0));
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | |
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | debug_malloc_touch($6);
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | dooptcode(i->name,
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | $6,
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | i->type,
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | ID_STATIC | ID_PRIVATE | ID_INLINE);
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | |
pop_compiler_frame();
free_node($2);
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | |
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | /* WARNING: If the local function adds more variables we are screwed */
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | /* WARNING2: if add_local_name stops adding local variables at the end,
* this has to be fixed.
*/
localid=compiler_frame->current_number_of_locals-1;
if(compiler_frame->variable[localid].def)
{
$$=copy_node(compiler_frame->variable[localid].def);
}else{
|
d18707 | 2000-06-20 | Fredrik Hübinette (Hubbe) | | if(compiler_frame->lexical_scope & SCOPE_SCOPE_USED)
{
$$ = mknode(F_ASSIGN, mktrampolinenode($<number>5),
mklocalnode(localid,0));
}else{
$$ = mknode(F_ASSIGN, mkidentifiernode($<number>5),
mklocalnode(localid,0));
}
|
5fb9b0 | 2000-04-06 | Fredrik Hübinette (Hubbe) | | }
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | optional_stars TOK_IDENTIFIER push_compiler_frame1 error
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | {
pop_compiler_frame();
free_node($2);
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | $$=mkintnode(0);
|
b5aa65 | 1999-12-16 | Henrik Grubbström (Grubba) | | }
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | ;
|
586b8a | 1998-04-28 | Henrik Grubbström (Grubba) | | failsafe_program: '{' program end_block
|
e2acf7 | 1997-04-23 | Henrik Grubbström (Grubba) | | | error { yyerrok; }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_LEX_EOF
|
e67c86 | 1998-08-01 | Henrik Grubbström (Grubba) | | {
yyerror("End of file where program definition expected.");
}
|
febbc8 | 1997-04-22 | Fredrik Hübinette (Hubbe) | | ;
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | class: modifiers TOK_CLASS optional_identifier
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
23eecd | 1999-08-06 | Fredrik Hübinette (Hubbe) | | extern int num_parse_error;
int num_errors=num_parse_error;
|
51ffdb | 1998-01-19 | Fredrik Hübinette (Hubbe) | | if(!$3)
{
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | struct pike_string *s;
|
51ffdb | 1998-01-19 | Fredrik Hübinette (Hubbe) | | char buffer[42];
|
22edc2 | 1998-01-29 | Fredrik Hübinette (Hubbe) | | sprintf(buffer,"__class_%ld_%ld",(long)new_program->id,
local_class_counter++);
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | s=make_shared_string(buffer);
$3=mkstrnode(s);
free_string(s);
|
c6eb96 | 1999-12-14 | Fredrik Hübinette (Hubbe) | | $1|=ID_STATIC | ID_PRIVATE | ID_INLINE;
|
51ffdb | 1998-01-19 | Fredrik Hübinette (Hubbe) | | }
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | /* fprintf(stderr, "LANGUAGE.YACC: CLASS start\n"); */
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(compiler_pass==1)
{
|
8fd931 | 1999-12-30 | Henrik Grubbström (Grubba) | | if ($1 & ID_EXTERN) {
yywarning("Extern declared class definition.");
}
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | low_start_new_program(0, $3->u.sval.u.string,
$1,
&$<number>$);
|
58ef5e | 1999-10-19 | Fredrik Hübinette (Hubbe) | | if(lex.current_file)
{
store_linenumber(lex.current_line, lex.current_file);
|
8fd931 | 1999-12-30 | Henrik Grubbström (Grubba) | | debug_malloc_name(new_program, lex.current_file->str,
lex.current_line);
|
58ef5e | 1999-10-19 | Fredrik Hübinette (Hubbe) | | }
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }else{
int i;
struct program *p;
struct identifier *id;
|
e37a3e | 1999-10-09 | Fredrik Hübinette (Hubbe) | | int tmp=compiler_pass;
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | i=isidentifier($3->u.sval.u.string);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(i<0)
{
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | low_start_new_program(new_program,0,
$1,
&$<number>$);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | yyerror("Pass 2: program not defined!");
}else{
id=ID_FROM_INT(new_program, i);
if(IDENTIFIER_IS_CONSTANT(id->identifier_flags))
{
struct svalue *s;
|
43fc17 | 1999-09-19 | Fredrik Hübinette (Hubbe) | | s=&PROG_FROM_INT(new_program,i)->constants[id->func.offset].sval;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(s->type==T_PROGRAM)
{
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | low_start_new_program(s->u.program,
$3->u.sval.u.string,
$1,
&$<number>$);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }else{
yyerror("Pass 2: constant redefined!");
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | low_start_new_program(new_program, 0,
$1,
&$<number>$);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
}else{
yyerror("Pass 2: class constant no longer constant!");
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | low_start_new_program(new_program, 0,
$1,
&$<number>$);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
}
|
e37a3e | 1999-10-09 | Fredrik Hübinette (Hubbe) | | compiler_pass=tmp;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
23eecd | 1999-08-06 | Fredrik Hübinette (Hubbe) | | num_parse_error=num_errors; /* Kluge to prevent gazillion error messages */
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
febbc8 | 1997-04-22 | Fredrik Hübinette (Hubbe) | | failsafe_program
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | struct program *p;
if(compiler_pass == 1)
p=end_first_pass(0);
else
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | p=end_first_pass(1);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | /* fprintf(stderr, "LANGUAGE.YACC: CLASS end\n"); */
|
2401c7 | 2000-01-03 | Martin Stjernholm | | if(!p) {
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | yyerror("Class definition failed.");
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | }else{
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | free_program(p);
|
2401c7 | 2000-01-03 | Martin Stjernholm | | }
|
993ba7 | 2000-02-15 | Fredrik Hübinette (Hubbe) | | $$=mkidentifiernode($<number>4);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_node($3);
check_tree($$,0);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
;
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | cond: TOK_IF
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
$<number>$=compiler_frame->current_number_of_locals;
}
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | '(' safe_comma_expr end_cond statement optional_else_part
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | $$=mknode('?',$4,mknode(':',$6,$7));
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | $$->line_number=$1;
$$=mkcastnode(void_type_string,$$);
$$->line_number=$1;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | pop_local_variables($<number>2);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | end_cond: ')'
| '}' { yyerror("Missing ')'."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_LEX_EOF
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | {
yyerror("Missing ')'.");
yyerror("Unexpected end of file.");
}
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | optional_else_part: { $$=0; }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_ELSE statement { $$=$2; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
998e1f | 1998-04-15 | Henrik Grubbström (Grubba) | | safe_lvalue: lvalue
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | | error { $$=0; }
|
998e1f | 1998-04-15 | Henrik Grubbström (Grubba) | | ;
safe_expr0: expr0
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_LEX_EOF { yyerror("Unexpected end of file."); $$=0; }
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | | error { $$=0; }
|
998e1f | 1998-04-15 | Henrik Grubbström (Grubba) | | ;
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | foreach: TOK_FOREACH
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
$<number>$=compiler_frame->current_number_of_locals;
}
|
902c29 | 1998-07-31 | Fredrik Hübinette (Hubbe) | | '(' expr0 ',' safe_lvalue end_cond statement
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
998e1f | 1998-04-15 | Henrik Grubbström (Grubba) | | if ($6) {
$$=mknode(F_FOREACH, mknode(F_VAL_LVAL,$4,$6),$8);
$$->line_number=$1;
} else {
/* Error in lvalue */
free_node($4);
$$=$8;
}
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | pop_local_variables($<number>2);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | do: TOK_DO statement TOK_WHILE '(' safe_comma_expr end_cond expected_semicolon
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
$$=mknode(F_DO,$2,$5);
$$->line_number=$1;
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_DO statement TOK_WHILE TOK_LEX_EOF
|
07f33e | 1998-11-05 | Henrik Grubbström (Grubba) | | {
$$=0;
yyerror("Missing '(' in do-while loop.");
yyerror("Unexpected end of file.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_DO statement TOK_LEX_EOF
|
07f33e | 1998-11-05 | Henrik Grubbström (Grubba) | | {
$$=0;
yyerror("Missing 'while' in do-while loop.");
yyerror("Unexpected end of file.");
}
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | expected_semicolon: ';'
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_LEX_EOF
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | {
yyerror("Missing ';'.");
yyerror("Unexpected end of file.");
}
;
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | for: TOK_FOR
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | $<number>$=compiler_frame->current_number_of_locals;
}
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | '(' unused expected_semicolon for_expr expected_semicolon unused end_cond
statement
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
int i=lex.current_line;
lex.current_line=$1;
|
3d7882 | 1999-11-06 | Henrik Grubbström (Grubba) | | $$=mknode(F_COMMA_EXPR, mkcastnode(void_type_string,$4),
mknode(F_FOR,$6,mknode(':',$10,$8)));
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | lex.current_line=i;
pop_local_variables($<number>2);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | while: TOK_WHILE
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
$<number>$=compiler_frame->current_number_of_locals;
}
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | '(' safe_comma_expr end_cond statement
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | int i=lex.current_line;
lex.current_line=$1;
$$=mknode(F_FOR,$4,mknode(':',$6,NULL));
lex.current_line=i;
pop_local_variables($<number>2);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
for_expr: /* EMPTY */ { $$=mkintnode(1); }
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | | safe_comma_expr
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | switch: TOK_SWITCH
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
$<number>$=compiler_frame->current_number_of_locals;
}
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | '(' safe_comma_expr end_cond statement
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | $$=mknode(F_SWITCH,$4,$6);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | $$->line_number=$1;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | pop_local_variables($<number>2);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | case: TOK_CASE safe_comma_expr expected_colon
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
$$=mknode(F_CASE,$2,0);
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_CASE safe_comma_expr TOK_DOT_DOT optional_comma_expr expected_colon
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | $$=mknode(F_CASE,$4?$2:0,$4?$4:$2);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | expected_colon: ':'
|
76b449 | 1999-12-09 | Henrik Grubbström (Grubba) | | | ';'
{
yyerror("Missing ':'.");
}
| '{'
{
yyerror("Missing ':'.");
}
| '}'
{
yyerror("Missing ':'.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_LEX_EOF
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | {
|
3d7882 | 1999-11-06 | Henrik Grubbström (Grubba) | | yyerror("Missing ':'.");
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | yyerror("Unexpected end of file.");
}
;
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | return: TOK_RETURN
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(!match_types(compiler_frame->current_return_type,
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | void_type_string))
{
yyerror("Must return a value for a non-void function.");
}
$$=mknode(F_RETURN,mkintnode(0),0);
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_RETURN safe_comma_expr
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
$$=mknode(F_RETURN,$2,0);
}
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
unused: { $$=0; }
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | | safe_comma_expr { $$=mkcastnode(void_type_string,$1); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
unused2: comma_expr { $$=mkcastnode(void_type_string,$1); } ;
|
ba62cf | 1997-09-18 | Fredrik Hübinette (Hubbe) | | optional_comma_expr: { $$=0; }
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | | safe_comma_expr
;
safe_comma_expr: comma_expr
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | | error { $$=0; }
|
ba62cf | 1997-09-18 | Fredrik Hübinette (Hubbe) | | ;
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | comma_expr: comma_expr2
|
6bc928 | 1998-04-10 | Fredrik Hübinette (Hubbe) | | | simple_type2 local_name_list { $$=$2; free_node($1); }
| simple_identifier_type local_name_list2 { $$=$2; free_node($1); }
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | | simple_identifier_type local_function { $$=$2; free_node($1); }
| simple_type2 local_function2 { $$=$2; free_node($1); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
comma_expr2: expr0
| comma_expr2 ',' expr0
{
|
3d7882 | 1999-11-06 | Henrik Grubbström (Grubba) | | $$ = mknode(F_COMMA_EXPR,mkcastnode(void_type_string,$1),$3);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
expr00: expr0
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | '@' expr0 { $$=mknode(F_PUSH_ARRAY,$2,0); };
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
expr0: expr01
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | expr4 '=' expr0 { $$=mknode(F_ASSIGN,$3,$1); }
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | | expr4 '=' error { $$=$1; reset_type_stack(); yyerrok; }
|
a66319 | 1998-04-17 | Henrik Grubbström (Grubba) | | | bad_expr_ident '=' expr0 { $$=$3; }
|
2a3269 | 1998-01-31 | Fredrik Hübinette (Hubbe) | | | '[' low_lvalue_list ']' '=' expr0 { $$=mknode(F_ASSIGN,$5,mknode(F_ARRAY_LVALUE,$2,0)); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | expr4 assign expr0 { $$=mknode($2,$1,$3); }
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | | expr4 assign error { $$=$1; reset_type_stack(); yyerrok; }
|
a66319 | 1998-04-17 | Henrik Grubbström (Grubba) | | | bad_expr_ident assign expr0 { $$=$3; }
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | | '[' low_lvalue_list ']' assign expr0 { $$=mknode($4,mknode(F_ARRAY_LVALUE,$2,0),$5); }
|
bdacd9 | 1998-04-15 | Henrik Grubbström (Grubba) | | | '[' low_lvalue_list ']' error { $$=$2; reset_type_stack(); yyerrok; }
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | /* | error { $$=0; reset_type_stack(); } */
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | expr01: expr1
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | expr1 '?' expr01 ':' expr01 { $$=mknode('?',$1,mknode(':',$3,$5)); }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | assign: TOK_AND_EQ { $$=F_AND_EQ; }
| TOK_OR_EQ { $$=F_OR_EQ; }
| TOK_XOR_EQ { $$=F_XOR_EQ; }
| TOK_LSH_EQ { $$=F_LSH_EQ; }
| TOK_RSH_EQ { $$=F_RSH_EQ; }
| TOK_ADD_EQ { $$=F_ADD_EQ; }
| TOK_SUB_EQ { $$=F_SUB_EQ; }
| TOK_MULT_EQ{ $$=F_MULT_EQ; }
| TOK_MOD_EQ { $$=F_MOD_EQ; }
| TOK_DIV_EQ { $$=F_DIV_EQ; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
cbae7e | 2000-03-30 | Henrik Grubbström (Grubba) | | optional_comma: { $$=0; } | ',' { $$=1; };
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
expr_list: { $$=0; }
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | | expr_list2 optional_comma
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
expr_list2: expr00
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | expr_list2 ',' expr00 { $$=mknode(F_ARG_LIST,$1,$3); }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
m_expr_list: { $$=0; }
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | | m_expr_list2 optional_comma
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
m_expr_list2: assoc_pair
|
998e1f | 1998-04-15 | Henrik Grubbström (Grubba) | | | m_expr_list2 ',' assoc_pair
{
if ($3) {
$$=mknode(F_ARG_LIST,$1,$3);
} else {
/* Error in assoc_pair */
$$=$1;
}
}
| m_expr_list2 ',' error
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
73a2a1 | 1998-04-27 | Henrik Grubbström (Grubba) | | assoc_pair: expr0 expected_colon expr1 { $$=mknode(F_ARG_LIST,$1,$3); }
| expr0 expected_colon error { free_node($1); $$=0; }
|
998e1f | 1998-04-15 | Henrik Grubbström (Grubba) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
expr1: expr2
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | expr1 TOK_LOR expr1 { $$=mknode(F_LOR,$1,$3); }
| expr1 TOK_LAND expr1 { $$=mknode(F_LAND,$1,$3); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | expr1 '|' expr1 { $$=mkopernode("`|",$1,$3); }
| expr1 '^' expr1 { $$=mkopernode("`^",$1,$3); }
| expr1 '&' expr1 { $$=mkopernode("`&",$1,$3); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | expr1 TOK_EQ expr1 { $$=mkopernode("`==",$1,$3); }
| expr1 TOK_NE expr1 { $$=mkopernode("`!=",$1,$3); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | expr1 '>' expr1 { $$=mkopernode("`>",$1,$3); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | expr1 TOK_GE expr1 { $$=mkopernode("`>=",$1,$3); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | expr1 '<' expr1 { $$=mkopernode("`<",$1,$3); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | expr1 TOK_LE expr1 { $$=mkopernode("`<=",$1,$3); }
| expr1 TOK_LSH expr1 { $$=mkopernode("`<<",$1,$3); }
| expr1 TOK_RSH expr1 { $$=mkopernode("`>>",$1,$3); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | expr1 '+' expr1 { $$=mkopernode("`+",$1,$3); }
| expr1 '-' expr1 { $$=mkopernode("`-",$1,$3); }
| expr1 '*' expr1 { $$=mkopernode("`*",$1,$3); }
| expr1 '%' expr1 { $$=mkopernode("`%",$1,$3); }
| expr1 '/' expr1 { $$=mkopernode("`/",$1,$3); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | expr1 TOK_LOR error
| expr1 TOK_LAND error
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | | expr1 '|' error
| expr1 '^' error
| expr1 '&' error
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | expr1 TOK_EQ error
| expr1 TOK_NE error
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | | expr1 '>' error
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | expr1 TOK_GE error
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | | expr1 '<' error
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | expr1 TOK_LE error
| expr1 TOK_LSH error
| expr1 TOK_RSH error
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | | expr1 '+' error
| expr1 '-' error
| expr1 '*' error
| expr1 '%' error
| expr1 '/' error
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
expr2: expr3
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | cast expr2
{
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | $$=mkcastnode($1->u.sval.u.string,$2);
free_node($1);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
1d73ef | 1999-11-23 | Henrik Grubbström (Grubba) | | | soft_cast expr2
{
$$=mksoftcastnode($1->u.sval.u.string,$2);
free_node($1);
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_INC expr4 { $$=mknode(F_INC,$2,0); }
| TOK_DEC expr4 { $$=mknode(F_DEC,$2,0); }
| TOK_NOT expr2 { $$=mkopernode("`!",$2,0); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | '~' expr2 { $$=mkopernode("`~",$2,0); }
| '-' expr2 { $$=mkopernode("`-",$2,0); }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
expr3: expr4
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | expr4 TOK_INC { $$=mknode(F_POST_INC,$1,0); }
| expr4 TOK_DEC { $$=mknode(F_POST_DEC,$1,0); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
expr4: string
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_NUMBER
| TOK_FLOAT { $$=mkfloatnode((FLOAT_TYPE)$1); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | catch
| gauge
| typeof
| sscanf
| lambda
| class
|
71d970 | 2000-06-21 | Henrik Grubbström (Grubba) | | | idents2
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | | expr4 '(' expr_list ')' { $$=mkapplynode($1,$3); }
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | | expr4 '(' error ')' { $$=mkapplynode($1, NULL); yyerrok; }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | expr4 '(' error TOK_LEX_EOF
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
yyerror("Missing ')'."); $$=mkapplynode($1, NULL);
yyerror("Unexpected end of file.");
}
| expr4 '(' error ';' { yyerror("Missing ')'."); $$=mkapplynode($1, NULL); }
| expr4 '(' error '}' { yyerror("Missing ')'."); $$=mkapplynode($1, NULL); }
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | | expr4 '[' expr0 ']' { $$=mknode(F_INDEX,$1,$3); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | expr4 '[' comma_expr_or_zero TOK_DOT_DOT comma_expr_or_maxint ']'
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | {
$$=mknode(F_RANGE,$1,mknode(F_ARG_LIST,$3,$5));
}
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | | expr4 '[' error ']' { $$=$1; yyerrok; }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | expr4 '[' error TOK_LEX_EOF
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
$$=$1; yyerror("Missing ']'.");
yyerror("Unexpected end of file.");
}
| expr4 '[' error ';' { $$=$1; yyerror("Missing ']'."); }
| expr4 '[' error '}' { $$=$1; yyerror("Missing ']'."); }
| expr4 '[' error ')' { $$=$1; yyerror("Missing ']'."); }
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | | '(' comma_expr2 ')' { $$=$2; }
|
76b449 | 1999-12-09 | Henrik Grubbström (Grubba) | | | '(' '{' expr_list close_brace_or_missing ')'
|
42d8c4 | 1998-03-04 | Fredrik Hübinette (Hubbe) | | { $$=mkefuncallnode("aggregate",$3); }
|
76b449 | 1999-12-09 | Henrik Grubbström (Grubba) | | | '(' '[' m_expr_list close_bracket_or_missing ')'
|
3803c2 | 1998-11-11 | Henrik Grubbström (Grubba) | | { $$=mkefuncallnode("aggregate_mapping",$3); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_MULTISET_START expr_list TOK_MULTISET_END
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | { $$=mkefuncallnode("aggregate_multiset",$2); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_MULTISET_START expr_list ')'
|
76b449 | 1999-12-09 | Henrik Grubbström (Grubba) | | {
yyerror("Missing '>'.");
$$=mkefuncallnode("aggregate_multiset",$2);
}
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | | '(' error ')' { $$=0; yyerrok; }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | '(' error TOK_LEX_EOF
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0; yyerror("Missing ')'.");
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | yyerror("Unexpected end of file.");
}
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | | '(' error ';' { $$=0; yyerror("Missing ')'."); }
| '(' error '}' { $$=0; yyerror("Missing ')'."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_MULTISET_START error TOK_MULTISET_END { $$=0; yyerrok; }
| TOK_MULTISET_START error ')' {
|
76b449 | 1999-12-09 | Henrik Grubbström (Grubba) | | yyerror("Missing '>'.");
$$=0; yyerrok;
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_MULTISET_START error TOK_LEX_EOF
|
76b449 | 1999-12-09 | Henrik Grubbström (Grubba) | | {
$$=0; yyerror("Missing '>)'.");
yyerror("Unexpected end of file.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_MULTISET_START error ';' { $$=0; yyerror("Missing '>)'."); }
| TOK_MULTISET_START error '}' { $$=0; yyerror("Missing '>)'."); }
| expr4 TOK_ARROW magic_identifier
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | {
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | $$=mknode(F_ARROW,$1,$3);
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | expr4 TOK_ARROW error {}
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | ;
|
71d970 | 2000-06-21 | Henrik Grubbström (Grubba) | | idents2: idents
| TOK_LOCAL_ID TOK_COLON_COLON TOK_IDENTIFIER
{
int i;
if(last_identifier) free_string(last_identifier);
copy_shared_string(last_identifier, $3->u.sval.u.string);
if (((i = find_shared_string_identifier(last_identifier,
new_program)) >= 0) ||
((i = really_low_find_shared_string_identifier(last_identifier,
new_program,
SEE_STATIC|
SEE_PRIVATE)) >= 0)) {
if (!(new_program->identifier_references[i].id_flags & ID_HIDDEN)) {
/* We need to generate a new reference. */
int d;
struct reference funp = new_program->identifier_references[i];
funp.id_flags |= ID_HIDDEN;
i = -1;
for(d = 0; d < (int)new_program->num_identifier_references; d++) {
struct reference *fp;
fp = new_program->identifier_references + d;
if(!MEMCMP((char *)fp,(char *)&funp,sizeof funp)) {
i = d;
break;
}
}
if (i < 0) {
add_to_identifier_references(funp);
i = new_program->num_identifier_references - 1;
}
}
$$ = mkidentifiernode(i);
} else {
if (!num_parse_error) {
if (compiler_pass == 2) {
my_yyerror("'%s' not defined in local scope.", last_identifier->str);
$$ = 0;
} else {
$$ = mknode(F_UNDEFINED, 0, 0);
}
} else {
$$ = mkintnode(0);
}
}
free_node($3);
}
| TOK_LOCAL_ID TOK_COLON_COLON bad_identifier
{
$$=0;
}
;
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | idents: low_idents
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | idents '.' TOK_IDENTIFIER
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | {
|
fae37d | 1998-08-30 | Henrik Grubbström (Grubba) | | $$=index_node($1, last_identifier?last_identifier->str:NULL,
$3->u.sval.u.string);
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | free_node($1);
|
e319bb | 1997-02-28 | Fredrik Hübinette (Hubbe) | | if(last_identifier) free_string(last_identifier);
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | copy_shared_string(last_identifier, $3->u.sval.u.string);
free_node($3);
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | '.' TOK_IDENTIFIER
|
eb5c90 | 1998-04-19 | Fredrik Hübinette (Hubbe) | | {
node *tmp;
push_text(".");
|
b47b11 | 1998-04-20 | Henrik Grubbström (Grubba) | | ref_push_string(lex.current_file);
|
10e16f | 1999-11-04 | Henrik Grubbström (Grubba) | | if (error_handler && error_handler->prog) {
ref_push_object(error_handler);
SAFE_APPLY_MASTER("handle_import", 3);
} else {
SAFE_APPLY_MASTER("handle_import", 2);
}
|
eb5c90 | 1998-04-19 | Fredrik Hübinette (Hubbe) | | tmp=mkconstantsvaluenode(sp-1);
pop_stack();
|
fae37d | 1998-08-30 | Henrik Grubbström (Grubba) | | $$=index_node(tmp, ".", $2->u.sval.u.string);
|
eb5c90 | 1998-04-19 | Fredrik Hübinette (Hubbe) | | free_node(tmp);
if(last_identifier) free_string(last_identifier);
copy_shared_string(last_identifier, $2->u.sval.u.string);
free_node($2);
}
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | | idents '.' bad_identifier {}
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | | idents '.' error {}
|
591c0c | 1997-01-19 | Fredrik Hübinette (Hubbe) | | ;
|
82e1b7 | 2000-06-22 | Henrik Grubbström (Grubba) | | inherit_specifier: TOK_IDENTIFIER TOK_COLON_COLON
{
/* FIXME: The following doesn't work...
struct program *p = find_named_inherit(new_program, $1->u.sval.u.string);
if (!p) {
my_yyerror("No such inherit \"%s\".", $1->u.sval.u.string->str);
$$ = 0;
} else {
struct svalue s;
s.type = T_PROGRAM;
s.subtype = 0;
s.u.program = p;
$$ = mkconstantsvaluenode(&s);
}
free_node($1);
*/
}
| inherit_specifier TOK_IDENTIFIER TOK_COLON_COLON
{
/* FIXME: This doesn't work either...
if ($1) {
struct program *p = find_named_inherit($1->u.sval.u.program,
$2->u.sval.u.string);
if (!p) {
my_yyerror("No such inherit \"%s\".", $2->u.sval.u.string->str);
free_node($1);
$$ = 0;
} else {
struct svalue s;
s.type = T_PROGRAM;
s.subtype = 0;
s.u.program = p;
$$ = mkconstantsvaluenode(&s);
}
}
*/
yywarning("Multi-level ::-resolving not yet supported.");
free_node($2);
}
;
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | low_idents: TOK_IDENTIFIER
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
int i;
struct efun *f;
|
8d7bda | 1997-02-10 | Fredrik Hübinette (Hubbe) | | if(last_identifier) free_string(last_identifier);
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | copy_shared_string(last_identifier, $1->u.sval.u.string);
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | |
|
01bf37 | 2000-03-09 | Henrik Grubbström (Grubba) | | if(($$=lexical_islocal(last_identifier)))
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | /* done, nothing to do here */
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | }else if((i=isidentifier(last_identifier))>=0){
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | $$=mkidentifiernode(i);
|
281605 | 2000-03-30 | Fredrik Hübinette (Hubbe) | | }else if(!($$=find_module_identifier(last_identifier,1))){
|
d43aff | 1997-08-03 | Fredrik Hübinette (Hubbe) | | if(!num_parse_error)
|
dffa01 | 1997-01-15 | Fredrik Hübinette (Hubbe) | | {
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | if(compiler_pass==2)
{
my_yyerror("'%s' undefined.", last_identifier->str);
$$=0;
}else{
$$=mknode(F_UNDEFINED,0,0);
}
}else{
|
1c858f | 1999-11-14 | Henrik Grubbström (Grubba) | | $$=mkintnode(0);
|
dffa01 | 1997-01-15 | Fredrik Hübinette (Hubbe) | | }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_node($1);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_PREDEF TOK_COLON_COLON TOK_IDENTIFIER
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
45e8a8 | 1997-01-26 | Fredrik Hübinette (Hubbe) | | struct svalue tmp;
node *tmp2;
tmp.type=T_MAPPING;
|
94a297 | 1997-03-01 | Henrik Grubbström (Grubba) | | #ifdef __CHECKER__
tmp.subtype=0;
#endif /* __CHECKER__ */
|
fae37d | 1998-08-30 | Henrik Grubbström (Grubba) | | if(last_identifier) free_string(last_identifier);
copy_shared_string(last_identifier, $3->u.sval.u.string);
|
45e8a8 | 1997-01-26 | Fredrik Hübinette (Hubbe) | | tmp.u.mapping=get_builtin_constants();
tmp2=mkconstantsvaluenode(&tmp);
|
fae37d | 1998-08-30 | Henrik Grubbström (Grubba) | | $$=index_node(tmp2, "predef", $3->u.sval.u.string);
|
43fc17 | 1999-09-19 | Fredrik Hübinette (Hubbe) | | if(!$$->name)
add_ref( $$->name=$3->u.sval.u.string );
|
45e8a8 | 1997-01-26 | Fredrik Hübinette (Hubbe) | | free_node(tmp2);
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_node($3);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_PREDEF TOK_COLON_COLON bad_identifier
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0;
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | }
|
82e1b7 | 2000-06-22 | Henrik Grubbström (Grubba) | | | inherit_specifier TOK_IDENTIFIER
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
fae37d | 1998-08-30 | Henrik Grubbström (Grubba) | | if(last_identifier) free_string(last_identifier);
|
82e1b7 | 2000-06-22 | Henrik Grubbström (Grubba) | | copy_shared_string(last_identifier, $2->u.sval.u.string);
|
fae37d | 1998-08-30 | Henrik Grubbström (Grubba) | |
|
82e1b7 | 2000-06-22 | Henrik Grubbström (Grubba) | | $$ = reference_inherited_identifier($1->u.sval.u.string,
$2->u.sval.u.string);
|
a005eb | 1999-03-04 | Fredrik Hübinette (Hubbe) | |
|
d429a7 | 1998-02-24 | Fredrik Hübinette (Hubbe) | | if (!$$)
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
82e1b7 | 2000-06-22 | Henrik Grubbström (Grubba) | | my_yyerror("Undefined identifier %s::%s.",
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | $1->u.sval.u.string->str,
|
82e1b7 | 2000-06-22 | Henrik Grubbström (Grubba) | | $2->u.sval.u.string->str);
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0;
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_node($1);
|
82e1b7 | 2000-06-22 | Henrik Grubbström (Grubba) | | free_node($2);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
82e1b7 | 2000-06-22 | Henrik Grubbström (Grubba) | | | inherit_specifier bad_identifier
| inherit_specifier error
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_COLON_COLON TOK_IDENTIFIER
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
int e,i;
|
fae37d | 1998-08-30 | Henrik Grubbström (Grubba) | | if(last_identifier) free_string(last_identifier);
copy_shared_string(last_identifier, $2->u.sval.u.string);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | $$=0;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | for(e=1;e<(int)new_program->num_inherits;e++)
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | if(new_program->inherits[e].inherit_level!=1) continue;
|
8aae6d | 1999-08-19 | Fredrik Hübinette (Hubbe) | | i=low_reference_inherited_identifier(0,e,$2->u.sval.u.string,SEE_STATIC);
|
45e8a8 | 1997-01-26 | Fredrik Hübinette (Hubbe) | | if(i==-1) continue;
if($$)
{
$$=mknode(F_ARG_LIST,$$,mkidentifiernode(i));
}else{
$$=mkidentifiernode(i);
}
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
if(!$$)
{
|
a5787d | 1999-03-03 | Fredrik Hübinette (Hubbe) | | if(ISCONSTSTR($2->u.sval.u.string,"`->") ||
ISCONSTSTR($2->u.sval.u.string,"`[]") )
{
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=mknode(F_MAGIC_INDEX,mknewintnode(0),mknewintnode(0));
|
a5787d | 1999-03-03 | Fredrik Hübinette (Hubbe) | | }
else if(ISCONSTSTR($2->u.sval.u.string,"`->=") ||
ISCONSTSTR($2->u.sval.u.string,"`[]=") )
{
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=mknode(F_MAGIC_SET_INDEX,mknewintnode(0),mknewintnode(0));
|
a5787d | 1999-03-03 | Fredrik Hübinette (Hubbe) | | }
else
{
|
1c858f | 1999-11-14 | Henrik Grubbström (Grubba) | | $$=mkintnode(0);
|
a5787d | 1999-03-03 | Fredrik Hübinette (Hubbe) | | }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }else{
|
45e8a8 | 1997-01-26 | Fredrik Hübinette (Hubbe) | | if($$->token==F_ARG_LIST) $$=mkefuncallnode("aggregate",$$);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_node($2);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_COLON_COLON bad_identifier
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0;
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
1c858f | 1999-11-14 | Henrik Grubbström (Grubba) | | comma_expr_or_zero: /* empty */ { $$=mkintnode(0); }
|
55356e | 1999-05-26 | Fredrik Hübinette (Hubbe) | | | comma_expr
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_LEX_EOF { yyerror("Unexpected end of file."); $$=0; }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
1c858f | 1999-11-14 | Henrik Grubbström (Grubba) | | comma_expr_or_maxint: /* empty */ { $$=mkintnode(0x7fffffff); }
|
55356e | 1999-05-26 | Fredrik Hübinette (Hubbe) | | | comma_expr
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_LEX_EOF { yyerror("Unexpected end of file."); $$=mkintnode(0x7fffffff); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | gauge: TOK_GAUGE catch_arg
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | {
|
4868db | 1997-05-07 | Per Hedbor | | #ifdef HAVE_GETHRVTIME
|
ee2f20 | 1999-10-10 | Fredrik Noring | | $$=mkefuncallnode("abs",
|
4868db | 1997-05-07 | Per Hedbor | | mkopernode("`/",
mkopernode("`-", mkefuncallnode("gethrvtime",0),
|
3d7882 | 1999-11-06 | Henrik Grubbström (Grubba) | | mknode(F_COMMA_EXPR,$2,
|
4868db | 1997-05-07 | Per Hedbor | | mkefuncallnode("gethrvtime",0))),
|
ee2f20 | 1999-10-10 | Fredrik Noring | | mkfloatnode((FLOAT_TYPE)1000000.0)));
|
4868db | 1997-05-07 | Per Hedbor | | #else
|
ee2f20 | 1999-10-10 | Fredrik Noring | | $$=mkefuncallnode("abs",
mkopernode("`/",
mkopernode("`-",
mknode(F_INDEX,mkefuncallnode("rusage",0),
mkintnode(GAUGE_RUSAGE_INDEX)),
|
3d7882 | 1999-11-06 | Henrik Grubbström (Grubba) | | mknode(F_COMMA_EXPR,$2,
|
ee2f20 | 1999-10-10 | Fredrik Noring | | mknode(F_INDEX,mkefuncallnode("rusage",0),
mkintnode(GAUGE_RUSAGE_INDEX)))),
mkfloatnode((FLOAT_TYPE)1000.0)));
|
4868db | 1997-05-07 | Per Hedbor | | #endif
};
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | typeof: TOK_TYPEOF '(' expr0 ')'
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | struct pike_string *s;
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | node *tmp;
|
3d7882 | 1999-11-06 | Henrik Grubbström (Grubba) | |
/* FIXME: Why build the node at all? */
|
b98c61 | 2000-05-17 | Henrik Grubbström (Grubba) | | tmp=mknode(F_COMMA_EXPR, $3, 0);
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | |
|
b98c61 | 2000-05-17 | Henrik Grubbström (Grubba) | | s=(tmp && CAR(tmp) && CAR(tmp)->type ? CAR(tmp)->type : mixed_type_string);
$$ = mktypenode(s);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | free_node(tmp);
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_TYPEOF '(' error ')' { $$=0; yyerrok; }
| TOK_TYPEOF '(' error '}' { $$=0; yyerror("Missing ')'."); }
| TOK_TYPEOF '(' error TOK_LEX_EOF
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0; yyerror("Missing ')'.");
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | yyerror("Unexpected end of file.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_TYPEOF '(' error ';' { $$=0; yyerror("Missing ')'."); }
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | ;
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | |
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | catch_arg: '(' comma_expr ')' { $$=$2; }
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | | '(' error ')' { $$=0; yyerrok; }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | '(' error TOK_LEX_EOF
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0; yyerror("Missing ')'.");
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | yyerror("Unexpected end of file.");
}
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | | '(' error '}' { $$=0; yyerror("Missing ')'."); }
| '(' error ';' { $$=0; yyerror("Missing ')'."); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | block
|
4cb7d9 | 1999-12-10 | Henrik Grubbström (Grubba) | | | error { $$=0; yyerror("Bad expression for catch."); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | catch: TOK_CATCH
|
964949 | 1998-02-27 | Fredrik Hübinette (Hubbe) | | {
catch_level++;
}
catch_arg
{
$$=mknode(F_CATCH,$3,NULL);
catch_level--;
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | sscanf: TOK_SSCANF '(' expr0 ',' expr0 lvalue_list ')'
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
$$=mknode(F_SSCANF,mknode(F_ARG_LIST,$3,$5),$6);
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_SSCANF '(' expr0 ',' expr0 error ')'
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0;
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | free_node($3);
free_node($5);
yyerrok;
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_SSCANF '(' expr0 ',' expr0 error TOK_LEX_EOF
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0;
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | free_node($3);
free_node($5);
yyerror("Missing ')'.");
yyerror("Unexpected end of file.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_SSCANF '(' expr0 ',' expr0 error '}'
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0;
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | free_node($3);
free_node($5);
yyerror("Missing ')'.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_SSCANF '(' expr0 ',' expr0 error ';'
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0;
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | free_node($3);
free_node($5);
yyerror("Missing ')'.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_SSCANF '(' expr0 error ')'
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0;
|
4d2133 | 1998-04-14 | Henrik Grubbström (Grubba) | | free_node($3);
yyerrok;
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_SSCANF '(' expr0 error TOK_LEX_EOF
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0;
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | free_node($3);
yyerror("Missing ')'.");
yyerror("Unexpected end of file.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_SSCANF '(' expr0 error '}'
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0;
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | free_node($3);
yyerror("Missing ')'.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_SSCANF '(' expr0 error ';'
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0;
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | free_node($3);
yyerror("Missing ')'.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_SSCANF '(' error ')' { $$=0; yyerrok; }
| TOK_SSCANF '(' error TOK_LEX_EOF
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | $$=0; yyerror("Missing ')'.");
|
db271d | 1998-04-27 | Henrik Grubbström (Grubba) | | yyerror("Unexpected end of file.");
}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_SSCANF '(' error '}' { $$=0; yyerror("Missing ')'."); }
| TOK_SSCANF '(' error ';' { $$=0; yyerror("Missing ')'."); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
3ddb53 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | lvalue: expr4
|
2a3269 | 1998-01-31 | Fredrik Hübinette (Hubbe) | | | '[' low_lvalue_list ']' { $$=mknode(F_ARRAY_LVALUE, $2,0); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | type6 TOK_IDENTIFIER
|
3ddb53 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | add_local_name($2->u.sval.u.string,compiler_pop_type(),0);
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | $$=mklocalnode(islocal($2->u.sval.u.string),0);
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | free_node($2);
|
3ddb53 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
|
1d73ef | 1999-11-23 | Henrik Grubbström (Grubba) | | | bad_expr_ident
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | { $$=mknewintnode(0); }
|
39245b | 1998-04-17 | Henrik Grubbström (Grubba) | | ;
|
bdacd9 | 1998-04-15 | Henrik Grubbström (Grubba) | | low_lvalue_list: lvalue lvalue_list { $$=mknode(F_LVALUE_LIST,$1,$2); }
|
2a3269 | 1998-01-31 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | lvalue_list: /* empty */ { $$ = 0; }
|
3ddb53 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | | ',' lvalue lvalue_list { $$ = mknode(F_LVALUE_LIST,$2,$3); }
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | ;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | string: TOK_STRING
| string TOK_STRING
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | {
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | struct pike_string *a,*b;
copy_shared_string(a,$1->u.sval.u.string);
copy_shared_string(b,$2->u.sval.u.string);
free_node($1);
free_node($2);
a=add_and_free_shared_strings(a,b);
$$=mkstrnode(a);
free_string(a);
|
7e5057 | 1996-11-02 | Fredrik Hübinette (Hubbe) | | }
;
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | /*
* Some error-handling
*/
|
07f85b | 1998-08-30 | Henrik Grubbström (Grubba) | | /* FIXME: Should probably set last_identifier. */
|
1d73ef | 1999-11-23 | Henrik Grubbström (Grubba) | | bad_identifier: bad_expr_ident
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_CLASS
|
39245b | 1998-04-17 | Henrik Grubbström (Grubba) | | { yyerror("class is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_ARRAY_ID
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("array is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_FLOAT_ID
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("float is a reserved word.");}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_FUNCTION_ID
|
39245b | 1998-04-17 | Henrik Grubbström (Grubba) | | { yyerror("function is a reserved word.");}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_INT_ID
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("int is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_MAPPING_ID
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("mapping is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_MIXED_ID
|
39245b | 1998-04-17 | Henrik Grubbström (Grubba) | | { yyerror("mixed is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_MULTISET_ID
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("multiset is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_OBJECT_ID
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | { yyerror("object is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_PROGRAM_ID
|
97358e | 1998-04-23 | Fredrik Hübinette (Hubbe) | | { yyerror("program is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_STRING_ID
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("string is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_VOID_ID
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("void is a reserved word."); }
|
a66319 | 1998-04-17 | Henrik Grubbström (Grubba) | | ;
bad_expr_ident:
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | TOK_INLINE
|
a66319 | 1998-04-17 | Henrik Grubbström (Grubba) | | { yyerror("inline is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_LOCAL_ID
|
a66319 | 1998-04-17 | Henrik Grubbström (Grubba) | | { yyerror("local is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_NO_MASK
|
a66319 | 1998-04-17 | Henrik Grubbström (Grubba) | | { yyerror("nomask is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_PREDEF
|
a66319 | 1998-04-17 | Henrik Grubbström (Grubba) | | { yyerror("predef is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_PRIVATE
|
a66319 | 1998-04-17 | Henrik Grubbström (Grubba) | | { yyerror("private is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_PROTECTED
|
a66319 | 1998-04-17 | Henrik Grubbström (Grubba) | | { yyerror("protected is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_PUBLIC
|
a66319 | 1998-04-17 | Henrik Grubbström (Grubba) | | { yyerror("public is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_OPTIONAL
|
21b2c9 | 1999-12-17 | Fredrik Hübinette (Hubbe) | | { yyerror("optional is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_STATIC
|
a66319 | 1998-04-17 | Henrik Grubbström (Grubba) | | { yyerror("static is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_EXTERN
|
1c379c | 1999-12-30 | Henrik Grubbström (Grubba) | | { yyerror("extern is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_FINAL_ID
|
a66319 | 1998-04-17 | Henrik Grubbström (Grubba) | | { yyerror("final is a reserved word.");}
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_DO
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("do is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_ELSE
|
2a7c7c | 1999-07-18 | Fredrik Hübinette (Hubbe) | | { yyerror("else without if."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_RETURN
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("return is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_CONSTANT
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("constant is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_IMPORT
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("import is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_INHERIT
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("inherit is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_CATCH
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("catch is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_GAUGE
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("gauge is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_LAMBDA
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("lambda is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_SSCANF
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("sscanf is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_SWITCH
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("switch is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_TYPEOF
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("typeof is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_BREAK
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("break is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_CASE
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("case is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_CONTINUE
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("continue is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_DEFAULT
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("default is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_FOR
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("for is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_FOREACH
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("foreach is a reserved word."); }
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | | TOK_IF
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | { yyerror("if is a reserved word."); }
;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | %%
void yyerror(char *str)
{
extern int num_parse_error;
|
523e64 | 1996-12-10 | David Hedbor | | extern int cumulative_parse_error;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
294dc5 | 1997-08-03 | Fredrik Hübinette (Hubbe) | | if(recoveries && sp-evaluator_stack < recoveries->sp)
fatal("Stack error (underflow)\n");
#endif
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | if (num_parse_error > 10) return;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | num_parse_error++;
|
c3c703 | 1996-12-04 | Fredrik Hübinette (Hubbe) | | cumulative_parse_error++;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | |
|
10e16f | 1999-11-04 | Henrik Grubbström (Grubba) | | if ((error_handler && error_handler->prog) || get_master())
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | {
|
52b45e | 1999-06-20 | Henrik Grubbström (Grubba) | | if (lex.current_file) {
ref_push_string(lex.current_file);
} else {
/* yyerror() can be called from define_function(), which
* can be called by the C module initialization code.
*/
push_constant_text("");
}
|
2416d8 | 1998-01-27 | Fredrik Hübinette (Hubbe) | | push_int(lex.current_line);
push_text(str);
|
10e16f | 1999-11-04 | Henrik Grubbström (Grubba) | | if (error_handler && error_handler->prog) {
safe_apply(error_handler, "compile_error", 3);
} else {
SAFE_APPLY_MASTER("compile_error", 3);
}
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | pop_stack();
}else{
|
52b45e | 1999-06-20 | Henrik Grubbström (Grubba) | | if (lex.current_file) {
(void)fprintf(stderr, "%s:%ld: %s\n",
lex.current_file->str,
(long)lex.current_line,
str);
} else {
(void)fprintf(stderr, "NULL:%ld: %s\n",
(long)lex.current_line,
str);
}
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | fflush(stderr);
}
}
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | |
int low_add_local_name(struct compiler_frame *frame,
struct pike_string *str,
struct pike_string *type,
node *def)
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | {
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | debug_malloc_touch(def);
debug_malloc_touch(type);
debug_malloc_touch(str);
|
3c0c28 | 1998-01-26 | Fredrik Hübinette (Hubbe) | | reference_shared_string(str);
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | if (frame->current_number_of_locals == MAX_LOCAL)
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | {
|
8c77b6 | 1998-04-13 | Henrik Grubbström (Grubba) | | yyerror("Too many local variables.");
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | return 0;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | }else {
|
498ec1 | 1999-11-12 | Henrik Grubbström (Grubba) | | #ifdef PIKE_DEBUG
check_type_string(type);
#endif /* PIKE_DEBUG */
|
df13b7 | 1999-12-18 | Henrik Grubbström (Grubba) | | if (pike_types_le(type, void_type_string)) {
|
119124 | 1999-12-18 | Henrik Grubbström (Grubba) | | if (compiler_pass != 1) {
yywarning("Declaring local variable with type void "
"(converted to type zero).");
}
|
5fdb4d | 1999-12-18 | Henrik Grubbström (Grubba) | | free_string(type);
copy_shared_string(type, zero_type_string);
}
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | frame->variable[frame->current_number_of_locals].type = type;
frame->variable[frame->current_number_of_locals].name = str;
frame->variable[frame->current_number_of_locals].def = def;
frame->current_number_of_locals++;
if(frame->current_number_of_locals >
frame->max_number_of_locals)
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | {
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | | frame->max_number_of_locals=
frame->current_number_of_locals;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | }
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | |
return frame->current_number_of_locals-1;
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | }
}
|
97f628 | 2000-03-07 | Fredrik Hübinette (Hubbe) | |
/* argument must be a shared string */
/* Note that this function eats a reference to 'type' */
/* If def is nonzero, it also eats a ref to def */
int add_local_name(struct pike_string *str,
struct pike_string *type,
node *def)
{
return low_add_local_name(compiler_frame,
str,
type,
def);
}
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | /* argument must be a shared string */
int islocal(struct pike_string *str)
{
int e;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | for(e=compiler_frame->current_number_of_locals-1;e>=0;e--)
if(compiler_frame->variable[e].name==str)
|
215bed | 1996-09-28 | Fredrik Hübinette (Hubbe) | | return e;
return -1;
}
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | |
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | /* argument must be a shared string */
static node *lexical_islocal(struct pike_string *str)
{
int e,depth=0;
struct compiler_frame *f=compiler_frame;
while(1)
{
for(e=f->current_number_of_locals-1;e>=0;e--)
{
if(f->variable[e].name==str)
{
struct compiler_frame *q=compiler_frame;
|
a566ca | 1999-12-14 | Fredrik Hübinette (Hubbe) | | if(f->variable[e].def)
return copy_node(f->variable[e].def);
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | while(q!=f)
{
|
8322b6 | 2000-05-08 | Fredrik Hübinette (Hubbe) | | q->lexical_scope|=SCOPE_SCOPED;
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | q=q->previous;
}
|
8322b6 | 2000-05-08 | Fredrik Hübinette (Hubbe) | |
if(depth)
q->lexical_scope|=SCOPE_SCOPE_USED;
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | return mklocalnode(e,depth);
}
}
|
8322b6 | 2000-05-08 | Fredrik Hübinette (Hubbe) | | if(!(f->lexical_scope & SCOPE_LOCAL)) return 0;
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | depth++;
f=f->previous;
}
}
|
61e9a0 | 1998-01-25 | Fredrik Hübinette (Hubbe) | | void cleanup_compiler(void)
{
if(last_identifier)
{
free_string(last_identifier);
last_identifier=0;
}
}
|