2001-06-12 19:44:26 +00:00
|
|
|
|
%{
|
2001-09-28 07:09:38 +00:00
|
|
|
|
/*
|
2002-11-06 16:32:28 +00:00
|
|
|
|
qc-parse.y
|
2001-09-28 07:09:38 +00:00
|
|
|
|
|
2002-11-06 16:32:28 +00:00
|
|
|
|
parser for quakec
|
2001-09-28 07:09:38 +00:00
|
|
|
|
|
2002-11-06 16:32:28 +00:00
|
|
|
|
Copyright (C) 2001 Bill Currie <bill@taniwha.org>
|
2001-09-28 07:09:38 +00:00
|
|
|
|
|
2002-11-06 16:32:28 +00:00
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
|
Date: 2001/06/12
|
2001-09-28 07:09:38 +00:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
|
|
*/
|
2002-06-01 04:41:25 +00:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
# include "config.h"
|
|
|
|
|
#endif
|
2003-01-14 20:18:29 +00:00
|
|
|
|
|
2002-06-01 04:41:25 +00:00
|
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
|
# include <string.h>
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
|
# include <strings.h>
|
|
|
|
|
#endif
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2001-10-24 22:50:06 +00:00
|
|
|
|
#include <QF/hash.h>
|
|
|
|
|
#include <QF/sys.h>
|
2001-06-15 19:38:43 +00:00
|
|
|
|
|
2002-06-21 20:46:56 +00:00
|
|
|
|
#include "class.h"
|
2002-06-04 21:23:39 +00:00
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "def.h"
|
2011-01-24 12:54:57 +00:00
|
|
|
|
#include "diagnostic.h"
|
2002-07-08 20:31:59 +00:00
|
|
|
|
#include "emit.h"
|
2002-06-01 05:30:16 +00:00
|
|
|
|
#include "expr.h"
|
2002-05-08 05:15:19 +00:00
|
|
|
|
#include "function.h"
|
2002-05-08 21:24:24 +00:00
|
|
|
|
#include "method.h"
|
2002-06-04 18:44:03 +00:00
|
|
|
|
#include "options.h"
|
2002-06-21 20:46:56 +00:00
|
|
|
|
#include "qfcc.h"
|
|
|
|
|
#include "reloc.h"
|
2012-10-26 07:01:41 +00:00
|
|
|
|
#include "shared.h"
|
2011-01-24 12:31:32 +00:00
|
|
|
|
#include "strpool.h"
|
2001-12-08 08:19:48 +00:00
|
|
|
|
#include "struct.h"
|
2001-10-25 06:41:52 +00:00
|
|
|
|
#include "switch.h"
|
2011-01-17 13:33:33 +00:00
|
|
|
|
#include "symtab.h"
|
2002-01-17 16:59:00 +00:00
|
|
|
|
#include "type.h"
|
2011-03-22 03:24:39 +00:00
|
|
|
|
#include "value.h"
|
2001-10-25 06:41:52 +00:00
|
|
|
|
|
2001-06-13 07:16:39 +00:00
|
|
|
|
#define YYDEBUG 1
|
|
|
|
|
#define YYERROR_VERBOSE 1
|
2003-02-25 07:48:12 +00:00
|
|
|
|
#undef YYERROR_VERBOSE
|
2001-06-18 22:51:49 +00:00
|
|
|
|
|
2012-10-26 07:01:41 +00:00
|
|
|
|
extern char *qc_yytext;
|
2001-06-18 22:51:49 +00:00
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
|
static void
|
2001-06-18 22:51:49 +00:00
|
|
|
|
yyerror (const char *s)
|
2001-06-12 20:24:02 +00:00
|
|
|
|
{
|
2003-02-25 07:48:12 +00:00
|
|
|
|
#ifdef YYERROR_VERBOSE
|
2012-10-26 07:01:41 +00:00
|
|
|
|
error (0, "%s %s\n", qc_yytext, s);
|
2003-02-25 07:48:12 +00:00
|
|
|
|
#else
|
2012-10-26 07:01:41 +00:00
|
|
|
|
error (0, "%s before %s", s, qc_yytext);
|
2003-02-25 07:48:12 +00:00
|
|
|
|
#endif
|
2001-06-12 20:24:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
|
static void
|
2002-05-15 19:10:23 +00:00
|
|
|
|
parse_error (void)
|
|
|
|
|
{
|
2012-10-26 07:01:41 +00:00
|
|
|
|
error (0, "parse error before %s", qc_yytext);
|
2002-05-15 19:10:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define PARSE_ERROR do { parse_error (); YYERROR; } while (0)
|
|
|
|
|
|
2001-06-12 20:24:02 +00:00
|
|
|
|
int yylex (void);
|
2001-06-21 07:08:34 +00:00
|
|
|
|
|
2001-06-12 19:44:26 +00:00
|
|
|
|
%}
|
|
|
|
|
|
2001-06-12 20:24:02 +00:00
|
|
|
|
%union {
|
2001-10-19 00:45:56 +00:00
|
|
|
|
int op;
|
2011-02-01 12:23:03 +00:00
|
|
|
|
int size;
|
|
|
|
|
specifier_t spec;
|
2011-01-17 13:33:33 +00:00
|
|
|
|
void *pointer; // for ensuring pointer values are null
|
2004-01-25 08:55:03 +00:00
|
|
|
|
struct type_s *type;
|
|
|
|
|
struct expr_s *expr;
|
2002-06-04 18:44:03 +00:00
|
|
|
|
struct function_s *function;
|
2004-01-25 08:55:03 +00:00
|
|
|
|
struct switch_block_s *switch_block;
|
2002-05-08 05:15:19 +00:00
|
|
|
|
struct param_s *param;
|
2002-05-08 21:24:24 +00:00
|
|
|
|
struct method_s *method;
|
2002-05-10 00:00:23 +00:00
|
|
|
|
struct class_s *class;
|
2002-11-14 18:17:43 +00:00
|
|
|
|
struct category_s *category;
|
|
|
|
|
struct class_type_s *class_type;
|
2002-05-08 21:24:24 +00:00
|
|
|
|
struct protocol_s *protocol;
|
2004-11-11 00:34:00 +00:00
|
|
|
|
struct protocollist_s *protocol_list;
|
2002-05-08 23:12:49 +00:00
|
|
|
|
struct keywordarg_s *keywordarg;
|
2002-05-10 00:00:23 +00:00
|
|
|
|
struct methodlist_s *methodlist;
|
2011-01-17 13:33:33 +00:00
|
|
|
|
struct symbol_s *symbol;
|
|
|
|
|
struct symtab_s *symtab;
|
2001-06-12 20:24:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-04 01:27:41 +00:00
|
|
|
|
// these tokens are common between qc and qp
|
|
|
|
|
%left LOW
|
2007-04-28 08:49:07 +00:00
|
|
|
|
%nonassoc IFX
|
|
|
|
|
%nonassoc ELSE
|
|
|
|
|
%nonassoc BREAK_PRIMARY
|
|
|
|
|
%nonassoc ';'
|
|
|
|
|
%nonassoc CLASS_NOT_CATEGORY
|
2007-05-07 23:44:45 +00:00
|
|
|
|
%nonassoc STORAGEX
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
%left COMMA
|
2011-01-17 13:33:33 +00:00
|
|
|
|
%right <op> '=' ASX PAS /* pointer assign */
|
|
|
|
|
%right '?' ':'
|
|
|
|
|
%left OR
|
|
|
|
|
%left AND
|
|
|
|
|
%left '|'
|
|
|
|
|
%left '^'
|
|
|
|
|
%left '&'
|
|
|
|
|
%left EQ NE
|
|
|
|
|
%left LE GE LT GT
|
2012-11-04 01:27:41 +00:00
|
|
|
|
// end of tokens common between qc and qp
|
|
|
|
|
|
2011-01-17 13:33:33 +00:00
|
|
|
|
%left SHL SHR
|
|
|
|
|
%left '+' '-'
|
|
|
|
|
%left '*' '/' '%'
|
2012-11-04 01:27:41 +00:00
|
|
|
|
%right <op> SIZEOF UNARY INCOP
|
2011-01-17 13:33:33 +00:00
|
|
|
|
%left HYPERUNARY
|
|
|
|
|
%left '.' '(' '['
|
|
|
|
|
|
|
|
|
|
%token <symbol> CLASS_NAME NAME
|
2012-12-18 04:59:45 +00:00
|
|
|
|
%token <expr> VALUE STRING
|
2011-01-17 13:33:33 +00:00
|
|
|
|
|
|
|
|
|
%token LOCAL RETURN WHILE DO IF ELSE FOR BREAK CONTINUE ELLIPSIS
|
|
|
|
|
%token NIL IFBE IFB IFAE IFA SWITCH CASE DEFAULT ENUM TYPEDEF
|
|
|
|
|
%token ARGS EXTERN STATIC SYSTEM SIZEOF OVERLOAD
|
|
|
|
|
%token <op> STRUCT
|
|
|
|
|
%token <type> TYPE
|
2012-12-18 03:49:43 +00:00
|
|
|
|
%token <symbol> OBJECT TYPE_NAME
|
2011-01-17 13:33:33 +00:00
|
|
|
|
%token CLASS DEFS ENCODE END IMPLEMENTATION INTERFACE PRIVATE
|
|
|
|
|
%token PROTECTED PROTOCOL PUBLIC SELECTOR REFERENCE SELF THIS
|
|
|
|
|
|
2011-02-07 12:29:04 +00:00
|
|
|
|
%type <spec> optional_specifiers specifiers local_specifiers
|
2011-03-07 11:51:51 +00:00
|
|
|
|
%type <spec> storage_class save_storage
|
2011-02-01 12:23:03 +00:00
|
|
|
|
%type <spec> type_specifier type_specifier_or_storage_class
|
2011-02-07 23:20:32 +00:00
|
|
|
|
%type <spec> type
|
2011-02-01 12:23:03 +00:00
|
|
|
|
|
|
|
|
|
%type <param> function_params var_list param_declaration
|
2011-02-13 08:07:14 +00:00
|
|
|
|
%type <param> qc_func_params qc_var_list qc_param_decl
|
2011-03-07 01:43:38 +00:00
|
|
|
|
%type <symbol> new_name
|
2011-02-01 12:23:03 +00:00
|
|
|
|
%type <symbol> var_decl function_decl
|
2011-02-02 06:13:34 +00:00
|
|
|
|
%type <symbol> abstract_decl abs_decl
|
2011-02-01 12:23:03 +00:00
|
|
|
|
|
|
|
|
|
%type <symbol> tag optional_tag
|
|
|
|
|
%type <spec> struct_specifier struct_def struct_decl
|
|
|
|
|
%type <spec> enum_specifier
|
|
|
|
|
%type <symbol> optional_enum_list enum_list enumerator_list enumerator
|
|
|
|
|
%type <symbol> enum_init
|
|
|
|
|
%type <size> array_decl
|
|
|
|
|
|
|
|
|
|
%type <spec> func_def_list comma
|
2011-01-17 13:33:33 +00:00
|
|
|
|
|
|
|
|
|
%type <expr> const string
|
|
|
|
|
|
2011-02-07 12:29:04 +00:00
|
|
|
|
%type <spec> ivar_decl decl decl_list
|
2011-02-01 12:23:03 +00:00
|
|
|
|
%type <spec> ivars
|
2011-01-17 13:33:33 +00:00
|
|
|
|
%type <param> param param_list
|
2011-01-25 03:07:02 +00:00
|
|
|
|
%type <symbol> methoddef
|
2011-02-07 12:29:04 +00:00
|
|
|
|
%type <expr> opt_initializer var_initializer local_def
|
|
|
|
|
|
2011-01-25 03:07:02 +00:00
|
|
|
|
%type <expr> opt_expr fexpr expr element_list element
|
2011-02-01 12:23:03 +00:00
|
|
|
|
%type <expr> optional_state_expr think opt_step texpr
|
|
|
|
|
%type <expr> statement statements compound_statement
|
2012-12-01 07:37:38 +00:00
|
|
|
|
%type <expr> else label break_label continue_label
|
2012-11-04 01:27:41 +00:00
|
|
|
|
%type <expr> unary_expr cast_expr opt_arg_list arg_list
|
2001-10-25 06:41:52 +00:00
|
|
|
|
%type <switch_block> switch_block
|
2011-02-01 12:23:03 +00:00
|
|
|
|
%type <symbol> identifier
|
|
|
|
|
|
|
|
|
|
%type <symbol> overloaded_identifier
|
2001-06-12 19:44:26 +00:00
|
|
|
|
|
2011-01-17 13:33:33 +00:00
|
|
|
|
%type <expr> identifier_list
|
|
|
|
|
%type <symbol> selector reserved_word
|
2011-02-01 12:23:03 +00:00
|
|
|
|
%type <param> optional_param_list unaryselector keyworddecl
|
|
|
|
|
%type <param> keywordselector
|
2011-01-17 13:33:33 +00:00
|
|
|
|
%type <method> methodproto methoddecl
|
|
|
|
|
%type <expr> obj_expr obj_messageexpr obj_string receiver
|
2004-11-11 00:34:00 +00:00
|
|
|
|
%type <protocol_list> protocolrefs protocol_list
|
2002-05-08 23:12:49 +00:00
|
|
|
|
%type <keywordarg> messageargs keywordarg keywordarglist selectorarg
|
|
|
|
|
%type <keywordarg> keywordnamelist keywordname
|
2011-01-17 13:33:33 +00:00
|
|
|
|
%type <class> class_name new_class_name class_with_super
|
|
|
|
|
%type <class> classdef new_class_with_super
|
|
|
|
|
%type <category> category_name new_category_name
|
|
|
|
|
%type <protocol> protocol_name
|
2002-05-10 00:00:23 +00:00
|
|
|
|
%type <methodlist> methodprotolist methodprotolist2
|
2011-01-17 13:33:33 +00:00
|
|
|
|
%type <symtab> ivar_decl_list
|
|
|
|
|
%type <op> ci
|
2002-05-08 05:15:19 +00:00
|
|
|
|
|
2001-06-15 07:16:18 +00:00
|
|
|
|
%{
|
|
|
|
|
|
2011-01-17 13:33:33 +00:00
|
|
|
|
static switch_block_t *switch_block;
|
|
|
|
|
static expr_t *break_label;
|
|
|
|
|
static expr_t *continue_label;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
static specifier_t
|
2011-02-03 01:48:12 +00:00
|
|
|
|
make_spec (type_t *type, storage_class_t storage, int is_typedef,
|
|
|
|
|
int is_overload)
|
2011-02-01 12:23:03 +00:00
|
|
|
|
{
|
|
|
|
|
specifier_t spec;
|
|
|
|
|
|
|
|
|
|
memset (&spec, 0, sizeof (spec));
|
|
|
|
|
spec.type = type;
|
|
|
|
|
spec.storage = storage;
|
|
|
|
|
spec.is_typedef = is_typedef;
|
2011-02-03 01:48:12 +00:00
|
|
|
|
spec.is_overload = is_overload;
|
2011-02-01 12:23:03 +00:00
|
|
|
|
if (spec.storage && spec.is_typedef)
|
|
|
|
|
internal_error (0, "setting both storage and is_typedef");
|
|
|
|
|
return spec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static specifier_t
|
|
|
|
|
spec_merge (specifier_t spec, specifier_t new)
|
|
|
|
|
{
|
|
|
|
|
if (new.type) {
|
|
|
|
|
if (spec.type && !spec.multi_type) {
|
|
|
|
|
error (0, "two or more data types in declaration specifiers");
|
|
|
|
|
spec.multi_type = 1;
|
|
|
|
|
}
|
|
|
|
|
spec.type = new.type;
|
|
|
|
|
}
|
|
|
|
|
if (new.is_typedef || new.storage) {
|
|
|
|
|
if ((spec.is_typedef || spec.storage) && !spec.multi_store) {
|
|
|
|
|
error (0, "multiple storage classes in declaration specifiers");
|
|
|
|
|
spec.multi_store = 1;
|
|
|
|
|
}
|
|
|
|
|
spec.storage = new.storage;
|
|
|
|
|
spec.is_typedef = new.is_typedef;
|
|
|
|
|
}
|
2011-02-03 01:48:12 +00:00
|
|
|
|
spec.is_overload |= new.is_overload;
|
2011-02-01 12:23:03 +00:00
|
|
|
|
return spec;
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-15 07:16:18 +00:00
|
|
|
|
%}
|
|
|
|
|
|
2011-02-02 06:13:34 +00:00
|
|
|
|
%expect 0
|
2004-02-08 23:46:40 +00:00
|
|
|
|
|
2001-06-12 19:44:26 +00:00
|
|
|
|
%%
|
|
|
|
|
|
2011-03-24 02:39:34 +00:00
|
|
|
|
program
|
|
|
|
|
: external_def_list
|
|
|
|
|
{
|
|
|
|
|
if (current_class) {
|
|
|
|
|
warning (0, "‘@end’ missing in implementation context");
|
|
|
|
|
class_finish (current_class);
|
|
|
|
|
current_class = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
external_def_list
|
2001-06-12 19:44:26 +00:00
|
|
|
|
: /* empty */
|
2011-01-22 06:52:57 +00:00
|
|
|
|
{
|
|
|
|
|
current_symtab = pr.symtab;
|
2012-12-22 11:04:11 +00:00
|
|
|
|
current_storage = sc_global;
|
2011-01-22 06:52:57 +00:00
|
|
|
|
}
|
2011-02-01 12:23:03 +00:00
|
|
|
|
| external_def_list external_def
|
|
|
|
|
| external_def_list obj_def
|
2012-12-22 11:04:11 +00:00
|
|
|
|
| error END
|
|
|
|
|
{
|
|
|
|
|
yyerrok;
|
|
|
|
|
current_class = 0;
|
|
|
|
|
current_symtab = pr.symtab;
|
|
|
|
|
current_storage = sc_global;
|
|
|
|
|
}
|
|
|
|
|
| error ';'
|
|
|
|
|
{
|
|
|
|
|
yyerrok;
|
2012-12-22 20:57:13 +00:00
|
|
|
|
current_class = 0;
|
2012-12-22 11:04:11 +00:00
|
|
|
|
current_symtab = pr.symtab;
|
|
|
|
|
current_storage = sc_global;
|
|
|
|
|
}
|
|
|
|
|
| error '}'
|
|
|
|
|
{
|
|
|
|
|
yyerrok;
|
2012-12-22 20:57:13 +00:00
|
|
|
|
current_class = 0;
|
2012-12-22 11:04:11 +00:00
|
|
|
|
current_symtab = pr.symtab;
|
|
|
|
|
current_storage = sc_global;
|
|
|
|
|
}
|
2001-06-12 19:44:26 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
external_def
|
|
|
|
|
: optional_specifiers external_decl_list ';' { }
|
|
|
|
|
| optional_specifiers ';' { }
|
2011-02-13 08:07:14 +00:00
|
|
|
|
| optional_specifiers qc_func_params
|
2002-01-23 20:50:25 +00:00
|
|
|
|
{
|
2011-02-21 23:54:01 +00:00
|
|
|
|
type_t **type;
|
2011-02-04 06:25:21 +00:00
|
|
|
|
$<spec>$ = $1; // copy spec bits and storage
|
2011-02-21 23:54:01 +00:00
|
|
|
|
// .float () foo; is a field holding a function variable rather
|
|
|
|
|
// than a function that returns a float field.
|
|
|
|
|
for (type = &$<spec>$.type; *type && (*type)->type == ev_field;
|
|
|
|
|
type = &(*type)->t.fldptr.type)
|
|
|
|
|
;
|
|
|
|
|
*type = parse_params (*type, $2);
|
2011-02-03 01:48:12 +00:00
|
|
|
|
$<spec>$.type = find_type ($<spec>$.type);
|
2011-02-22 03:07:31 +00:00
|
|
|
|
if ($<spec>$.type->type != ev_field)
|
|
|
|
|
$<spec>$.params = $2;
|
2002-01-23 20:50:25 +00:00
|
|
|
|
}
|
2011-02-01 12:23:03 +00:00
|
|
|
|
function_def_list
|
2011-06-21 10:52:47 +00:00
|
|
|
|
{
|
|
|
|
|
(void) ($<spec>3);
|
|
|
|
|
}
|
2011-02-01 12:23:03 +00:00
|
|
|
|
| optional_specifiers function_decl function_body
|
2011-03-07 11:51:51 +00:00
|
|
|
|
| storage_class '{' save_storage
|
|
|
|
|
{
|
|
|
|
|
current_storage = $1.storage;
|
|
|
|
|
}
|
|
|
|
|
external_def_list '}' ';'
|
|
|
|
|
{
|
|
|
|
|
current_storage = $3.storage;
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
save_storage
|
|
|
|
|
: /* emtpy */
|
|
|
|
|
{
|
|
|
|
|
$$.storage = current_storage;
|
|
|
|
|
}
|
2002-01-21 19:09:23 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
function_body
|
|
|
|
|
: optional_state_expr
|
|
|
|
|
{
|
2011-02-02 06:13:34 +00:00
|
|
|
|
symbol_t *sym = $<symbol>0;
|
|
|
|
|
|
2011-03-25 00:59:48 +00:00
|
|
|
|
if (!$<spec>-1.type)
|
|
|
|
|
$<spec>-1.type = type_default;
|
2011-02-03 01:48:12 +00:00
|
|
|
|
sym->type = find_type (append_type (sym->type, $<spec>-1.type));
|
2011-02-09 01:25:23 +00:00
|
|
|
|
$<symbol>$ = function_symbol (sym, $<spec>-1.is_overload, 1);
|
|
|
|
|
}
|
2011-03-07 11:51:51 +00:00
|
|
|
|
save_storage
|
2011-02-09 01:25:23 +00:00
|
|
|
|
{
|
2011-02-01 12:23:03 +00:00
|
|
|
|
$<symtab>$ = current_symtab;
|
2011-02-15 03:38:29 +00:00
|
|
|
|
current_func = begin_function ($<symbol>2, 0, current_symtab, 0);
|
2011-02-01 12:23:03 +00:00
|
|
|
|
current_symtab = current_func->symtab;
|
2012-12-02 01:11:30 +00:00
|
|
|
|
current_storage = sc_local;
|
2011-02-01 12:23:03 +00:00
|
|
|
|
}
|
|
|
|
|
compound_statement
|
|
|
|
|
{
|
2011-03-07 11:51:51 +00:00
|
|
|
|
build_code_function ($<symbol>2, $1, $5);
|
|
|
|
|
current_symtab = $<symtab>4;
|
|
|
|
|
current_storage = $3.storage;
|
2011-02-14 14:08:51 +00:00
|
|
|
|
current_func = 0;
|
2011-02-01 12:23:03 +00:00
|
|
|
|
}
|
|
|
|
|
| '=' '#' expr ';'
|
|
|
|
|
{
|
2011-02-02 06:13:34 +00:00
|
|
|
|
symbol_t *sym = $<symbol>0;
|
|
|
|
|
|
2011-03-25 00:59:48 +00:00
|
|
|
|
if (!$<spec>-1.type)
|
|
|
|
|
$<spec>-1.type = type_default;
|
2011-02-03 01:48:12 +00:00
|
|
|
|
sym->type = find_type (append_type (sym->type, $<spec>-1.type));
|
|
|
|
|
sym = function_symbol (sym, $<spec>-1.is_overload, 1);
|
2011-02-15 03:38:29 +00:00
|
|
|
|
build_builtin_function (sym, $3, 0);
|
2011-02-01 12:23:03 +00:00
|
|
|
|
}
|
2004-02-10 23:20:44 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
external_decl_list
|
|
|
|
|
: external_decl
|
2011-06-21 10:52:47 +00:00
|
|
|
|
| external_decl_list ',' { $<spec>$ = $<spec>0; }
|
|
|
|
|
external_decl { (void) ($<spec>3); }
|
2002-09-12 17:13:19 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
external_decl
|
|
|
|
|
: var_decl
|
2011-02-02 06:13:34 +00:00
|
|
|
|
{
|
2011-02-02 12:58:11 +00:00
|
|
|
|
specifier_t spec = $<spec>0;
|
2011-02-06 05:37:25 +00:00
|
|
|
|
type_t *type;
|
2011-02-02 12:58:11 +00:00
|
|
|
|
|
2011-03-25 00:59:48 +00:00
|
|
|
|
if (!spec.type)
|
|
|
|
|
spec.type = type_default;
|
2011-02-06 05:37:25 +00:00
|
|
|
|
type = find_type (append_type ($1->type, spec.type));
|
2011-02-02 12:58:11 +00:00
|
|
|
|
if (spec.is_typedef) {
|
2011-02-06 05:37:25 +00:00
|
|
|
|
$1->type = type;
|
2011-02-02 12:58:11 +00:00
|
|
|
|
$1->sy_type = sy_type;
|
2011-02-06 05:37:25 +00:00
|
|
|
|
symtab_addsymbol (current_symtab, $1);
|
2011-02-02 12:58:11 +00:00
|
|
|
|
} else {
|
2011-02-06 05:37:25 +00:00
|
|
|
|
initialize_def ($1, type, 0, current_symtab->space,
|
|
|
|
|
spec.storage);
|
2011-02-02 12:58:11 +00:00
|
|
|
|
}
|
2011-02-02 06:13:34 +00:00
|
|
|
|
}
|
2011-02-14 14:31:37 +00:00
|
|
|
|
| var_decl var_initializer
|
|
|
|
|
{
|
|
|
|
|
specifier_t spec = $<spec>0;
|
|
|
|
|
type_t *type;
|
|
|
|
|
|
2011-03-25 00:59:48 +00:00
|
|
|
|
if (!spec.type)
|
|
|
|
|
spec.type = type_default;
|
2011-02-14 14:31:37 +00:00
|
|
|
|
type = find_type (append_type ($1->type, spec.type));
|
|
|
|
|
if (spec.is_typedef) {
|
|
|
|
|
error (0, "typedef %s is initialized", $1->name);
|
|
|
|
|
$1->type = type;
|
|
|
|
|
$1->sy_type = sy_type;
|
|
|
|
|
symtab_addsymbol (current_symtab, $1);
|
|
|
|
|
} else {
|
|
|
|
|
initialize_def ($1, type, $2, current_symtab->space,
|
|
|
|
|
spec.storage);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-02-01 12:23:03 +00:00
|
|
|
|
| function_decl
|
2011-02-03 01:48:12 +00:00
|
|
|
|
{
|
|
|
|
|
specifier_t spec = $<spec>0;
|
2011-03-25 00:59:48 +00:00
|
|
|
|
if (!spec.type)
|
|
|
|
|
spec.type = type_default;
|
2011-02-03 01:48:12 +00:00
|
|
|
|
$1->type = find_type (append_type ($1->type, spec.type));
|
2011-03-02 13:23:24 +00:00
|
|
|
|
if (spec.is_typedef) {
|
|
|
|
|
$1->sy_type = sy_type;
|
|
|
|
|
symtab_addsymbol (current_symtab, $1);
|
|
|
|
|
} else {
|
|
|
|
|
$1 = function_symbol ($1, spec.is_overload, 1);
|
2012-12-23 05:25:09 +00:00
|
|
|
|
// things might be a confused mess from earlier errors
|
|
|
|
|
if ($1->sy_type == sy_func)
|
|
|
|
|
make_function ($1, 0, $1->table->space, spec.storage);
|
2011-03-02 13:23:24 +00:00
|
|
|
|
}
|
2011-02-03 01:48:12 +00:00
|
|
|
|
}
|
2004-02-11 00:36:34 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
storage_class
|
2012-12-02 01:11:30 +00:00
|
|
|
|
: EXTERN { $$ = make_spec (0, sc_extern, 0, 0); }
|
|
|
|
|
| STATIC { $$ = make_spec (0, sc_static, 0, 0); }
|
|
|
|
|
| SYSTEM { $$ = make_spec (0, sc_system, 0, 0); }
|
|
|
|
|
| TYPEDEF { $$ = make_spec (0, sc_global, 1, 0); }
|
2011-02-03 01:48:12 +00:00
|
|
|
|
| OVERLOAD { $$ = make_spec (0, current_storage, 0, 1); }
|
2011-02-01 12:23:03 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
optional_specifiers
|
2011-02-07 23:20:32 +00:00
|
|
|
|
: specifiers
|
2011-03-07 11:51:51 +00:00
|
|
|
|
{
|
|
|
|
|
$$ = $1;
|
|
|
|
|
if (!$$.storage)
|
|
|
|
|
$$.storage = current_storage;
|
|
|
|
|
}
|
2011-02-01 12:23:03 +00:00
|
|
|
|
| /* empty */
|
2011-01-25 00:36:00 +00:00
|
|
|
|
{
|
2011-02-03 01:48:12 +00:00
|
|
|
|
$$ = make_spec (0, current_storage, 0, 0);
|
2011-01-25 00:36:00 +00:00
|
|
|
|
}
|
2002-09-12 17:13:19 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
specifiers
|
|
|
|
|
: type_specifier_or_storage_class
|
|
|
|
|
| specifiers type_specifier_or_storage_class
|
2011-02-02 13:59:08 +00:00
|
|
|
|
{
|
|
|
|
|
$$ = spec_merge ($1, $2);
|
|
|
|
|
}
|
2011-02-01 12:23:03 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
: type_specifier
|
|
|
|
|
| type type_specifier
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
type_specifier_or_storage_class
|
|
|
|
|
: type_specifier
|
|
|
|
|
| storage_class
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
type_specifier
|
|
|
|
|
: TYPE
|
2004-11-13 11:50:00 +00:00
|
|
|
|
{
|
2011-03-07 08:49:01 +00:00
|
|
|
|
$$ = make_spec ($1, 0, 0, 0);
|
2004-11-13 11:50:00 +00:00
|
|
|
|
}
|
2011-02-01 12:23:03 +00:00
|
|
|
|
| enum_specifier
|
|
|
|
|
| struct_specifier
|
2011-02-07 23:20:32 +00:00
|
|
|
|
| TYPE_NAME
|
|
|
|
|
{
|
2011-03-07 08:49:01 +00:00
|
|
|
|
$$ = make_spec ($1->type, 0, 0, 0);
|
2011-02-07 23:20:32 +00:00
|
|
|
|
}
|
2012-12-18 03:49:43 +00:00
|
|
|
|
| OBJECT protocolrefs
|
|
|
|
|
{
|
2012-12-18 11:45:48 +00:00
|
|
|
|
if ($2) {
|
|
|
|
|
type_t type = *type_id.t.fldptr.type;
|
2012-12-20 04:12:05 +00:00
|
|
|
|
type.next = 0;
|
2012-12-18 11:45:48 +00:00
|
|
|
|
type.protos = $2;
|
2012-12-20 04:12:05 +00:00
|
|
|
|
$$ = make_spec (pointer_type (find_type (&type)), 0, 0, 0);
|
2012-12-18 11:45:48 +00:00
|
|
|
|
} else {
|
|
|
|
|
$$ = make_spec (&type_id, 0, 0, 0);
|
|
|
|
|
}
|
2012-12-18 03:49:43 +00:00
|
|
|
|
}
|
|
|
|
|
| CLASS_NAME protocolrefs
|
2011-02-07 23:20:32 +00:00
|
|
|
|
{
|
2012-12-18 11:45:48 +00:00
|
|
|
|
if ($2) {
|
|
|
|
|
type_t type = *$1->type;
|
2012-12-20 04:12:05 +00:00
|
|
|
|
type.next = 0;
|
2012-12-18 11:45:48 +00:00
|
|
|
|
type.protos = $2;
|
|
|
|
|
$$ = make_spec (find_type (&type), 0, 0, 0);
|
|
|
|
|
} else {
|
|
|
|
|
$$ = make_spec ($1->type, 0, 0, 0);
|
|
|
|
|
}
|
2011-02-07 23:20:32 +00:00
|
|
|
|
}
|
2011-02-21 23:54:01 +00:00
|
|
|
|
// NOTE: fields don't parse the way they should. This is not a problem
|
|
|
|
|
// for basic types, but functions need special treatment
|
2011-02-01 12:23:03 +00:00
|
|
|
|
| '.' type_specifier
|
2004-11-13 11:50:00 +00:00
|
|
|
|
{
|
2011-02-21 23:54:01 +00:00
|
|
|
|
// avoid find_type()
|
2011-03-07 08:49:01 +00:00
|
|
|
|
$$ = make_spec (field_type (0), 0, 0, 0);
|
2011-02-21 23:54:01 +00:00
|
|
|
|
$$.type = append_type ($$.type, $2.type);
|
2004-11-13 11:50:00 +00:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
optional_tag
|
|
|
|
|
: tag
|
|
|
|
|
| /* empty */ { $$ = 0; }
|
2002-06-28 17:59:32 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
tag : NAME ;
|
|
|
|
|
|
|
|
|
|
enum_specifier
|
2011-02-03 01:48:12 +00:00
|
|
|
|
: ENUM tag optional_enum_list
|
|
|
|
|
{
|
2011-03-07 08:49:01 +00:00
|
|
|
|
$$ = make_spec ($3->type, 0, 0, 0);
|
2011-02-03 01:48:12 +00:00
|
|
|
|
if (!$3->table)
|
|
|
|
|
symtab_addsymbol (current_symtab, $3);
|
|
|
|
|
}
|
|
|
|
|
| ENUM enum_list
|
|
|
|
|
{
|
2011-03-07 08:49:01 +00:00
|
|
|
|
$$ = make_spec ($2->type, 0, 0, 0);
|
2011-02-03 01:48:12 +00:00
|
|
|
|
if (!$2->table)
|
|
|
|
|
symtab_addsymbol (current_symtab, $2);
|
|
|
|
|
}
|
2006-12-11 09:26:07 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
optional_enum_list
|
2011-02-06 11:07:19 +00:00
|
|
|
|
: enum_list
|
2011-02-01 12:23:03 +00:00
|
|
|
|
| /* empty */ { $$ = find_enum ($<symbol>0); }
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
enum_list
|
|
|
|
|
: '{' enum_init enumerator_list optional_comma '}' { $$ = $3; }
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
enum_init
|
2001-12-08 08:19:48 +00:00
|
|
|
|
: /* empty */
|
2011-02-01 12:23:03 +00:00
|
|
|
|
{
|
|
|
|
|
$$ = find_enum ($<symbol>-1);
|
|
|
|
|
start_enum ($$);
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
enumerator_list
|
|
|
|
|
: enumerator { $$ = $<symbol>0; }
|
|
|
|
|
| enumerator_list ',' { $<symbol>$ = $<symbol>0; }
|
2011-06-21 10:52:47 +00:00
|
|
|
|
enumerator
|
|
|
|
|
{
|
|
|
|
|
$$ = $<symbol>0;
|
|
|
|
|
(void) ($<symbol>3);
|
|
|
|
|
}
|
2011-02-01 12:23:03 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
enumerator
|
|
|
|
|
: identifier { add_enum ($<symbol>0, $1, 0); }
|
|
|
|
|
| identifier '=' fexpr { add_enum ($<symbol>0, $1, $3); }
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
struct_specifier
|
|
|
|
|
: STRUCT optional_tag '{'
|
|
|
|
|
{
|
2011-02-13 11:55:33 +00:00
|
|
|
|
symbol_t *sym;
|
|
|
|
|
sym = find_struct ($1, $2, 0);
|
|
|
|
|
if (!sym->table)
|
|
|
|
|
symtab_addsymbol (current_symtab, sym);
|
2011-02-01 12:23:03 +00:00
|
|
|
|
current_symtab = new_symtab (current_symtab, stab_local);
|
|
|
|
|
}
|
|
|
|
|
struct_defs '}'
|
|
|
|
|
{
|
2011-02-02 13:53:53 +00:00
|
|
|
|
symbol_t *sym;
|
2011-02-01 12:23:03 +00:00
|
|
|
|
symtab_t *symtab = current_symtab;
|
|
|
|
|
current_symtab = symtab->parent;
|
|
|
|
|
|
2011-02-02 13:53:53 +00:00
|
|
|
|
sym = build_struct ($1, $2, symtab, 0);
|
2011-03-07 08:49:01 +00:00
|
|
|
|
$$ = make_spec (sym->type, 0, 0, 0);
|
2011-02-02 13:53:53 +00:00
|
|
|
|
if (!sym->table)
|
|
|
|
|
symtab_addsymbol (current_symtab, sym);
|
2011-02-01 12:23:03 +00:00
|
|
|
|
}
|
2011-02-02 12:57:41 +00:00
|
|
|
|
| STRUCT tag
|
2011-02-01 12:23:03 +00:00
|
|
|
|
{
|
2011-02-02 13:53:53 +00:00
|
|
|
|
symbol_t *sym;
|
|
|
|
|
|
|
|
|
|
sym = find_struct ($1, $2, 0);
|
2011-03-07 08:49:01 +00:00
|
|
|
|
$$ = make_spec (sym->type, 0, 0, 0);
|
2011-02-02 13:53:53 +00:00
|
|
|
|
if (!sym->table)
|
|
|
|
|
symtab_addsymbol (current_symtab, sym);
|
2011-02-01 12:23:03 +00:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
struct_defs
|
2012-12-18 06:54:30 +00:00
|
|
|
|
: struct_def_list ';'
|
2004-11-02 07:02:00 +00:00
|
|
|
|
| DEFS '(' identifier ')'
|
2002-05-10 00:00:23 +00:00
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$3 = check_undefined ($3);
|
2012-12-19 02:53:19 +00:00
|
|
|
|
if (!$3->type || !obj_is_class ($3->type)) {
|
2011-01-17 13:33:33 +00:00
|
|
|
|
error (0, "`%s' is not a class", $3->name);
|
2002-05-10 00:00:23 +00:00
|
|
|
|
} else {
|
2011-01-17 13:33:33 +00:00
|
|
|
|
// replace the struct symbol table with one built from
|
|
|
|
|
// the class ivars and the current struct fields. ivars
|
|
|
|
|
// will replace any fields of the same name.
|
|
|
|
|
current_symtab = class_to_struct ($3->type->t.class,
|
|
|
|
|
current_symtab);
|
2002-05-10 00:00:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-12-08 08:19:48 +00:00
|
|
|
|
;
|
|
|
|
|
|
2012-12-18 06:54:30 +00:00
|
|
|
|
struct_def_list
|
|
|
|
|
: struct_def
|
|
|
|
|
| struct_def_list ';' struct_def
|
|
|
|
|
;
|
|
|
|
|
|
2001-12-08 08:19:48 +00:00
|
|
|
|
struct_def
|
2011-02-01 12:23:03 +00:00
|
|
|
|
: type struct_decl_list
|
|
|
|
|
| type
|
2001-06-12 19:44:26 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
struct_decl_list
|
2011-06-21 10:52:47 +00:00
|
|
|
|
: struct_decl_list ',' { $<spec>$ = $<spec>0; }
|
|
|
|
|
struct_decl { (void) ($<spec>3); }
|
2011-02-01 12:23:03 +00:00
|
|
|
|
| struct_decl
|
2006-12-02 06:49:55 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
struct_decl
|
2011-02-04 14:48:58 +00:00
|
|
|
|
: function_decl
|
|
|
|
|
{
|
2011-03-25 00:59:48 +00:00
|
|
|
|
if (!$<spec>0.type)
|
|
|
|
|
$<spec>0.type = type_default;
|
2011-02-04 14:48:58 +00:00
|
|
|
|
$1->type = append_type ($1->type, $<spec>0.type);
|
|
|
|
|
$1->type = find_type ($1->type);
|
|
|
|
|
symtab_addsymbol (current_symtab, $1);
|
|
|
|
|
}
|
|
|
|
|
| var_decl
|
|
|
|
|
{
|
2011-03-25 00:59:48 +00:00
|
|
|
|
if (!$<spec>0.type)
|
|
|
|
|
$<spec>0.type = type_default;
|
2011-02-04 14:48:58 +00:00
|
|
|
|
$1->type = append_type ($1->type, $<spec>0.type);
|
|
|
|
|
$1->type = find_type ($1->type);
|
|
|
|
|
symtab_addsymbol (current_symtab, $1);
|
|
|
|
|
}
|
2011-02-01 12:23:03 +00:00
|
|
|
|
| var_decl ':' expr %prec COMMA {}
|
|
|
|
|
| ':' expr %prec COMMA {}
|
|
|
|
|
;
|
|
|
|
|
|
2011-03-07 01:43:38 +00:00
|
|
|
|
new_name
|
|
|
|
|
: NAME %prec COMMA
|
2006-12-02 06:49:55 +00:00
|
|
|
|
{
|
2011-02-14 12:25:08 +00:00
|
|
|
|
$$ = $1;
|
|
|
|
|
// due to the way declarations work, we need a new symbol at all
|
|
|
|
|
// times. redelcarations will be checked later
|
|
|
|
|
if ($$->table)
|
|
|
|
|
$$ = new_symbol ($1->name);
|
2011-03-07 01:43:38 +00:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
var_decl
|
|
|
|
|
: new_name
|
|
|
|
|
{
|
|
|
|
|
$$ = $1;
|
2011-02-02 06:13:34 +00:00
|
|
|
|
$$->type = 0;
|
2011-02-01 12:23:03 +00:00
|
|
|
|
}
|
|
|
|
|
| var_decl function_params
|
|
|
|
|
{
|
2011-02-02 06:13:34 +00:00
|
|
|
|
$$->type = append_type ($$->type, parse_params (0, $2));
|
2002-01-21 19:03:29 +00:00
|
|
|
|
}
|
2011-02-01 12:23:03 +00:00
|
|
|
|
| var_decl array_decl
|
|
|
|
|
{
|
2011-02-02 06:13:34 +00:00
|
|
|
|
$$->type = append_type ($$->type, array_type (0, $2));
|
2011-02-01 12:23:03 +00:00
|
|
|
|
}
|
2011-02-02 06:13:34 +00:00
|
|
|
|
| '*' var_decl %prec UNARY
|
2011-02-01 12:23:03 +00:00
|
|
|
|
{
|
2011-02-02 06:13:34 +00:00
|
|
|
|
$$ = $2;
|
|
|
|
|
$$->type = append_type ($$->type, pointer_type (0));
|
2011-02-01 12:23:03 +00:00
|
|
|
|
}
|
2011-02-02 06:13:34 +00:00
|
|
|
|
| '(' var_decl ')' { $$ = $2; }
|
2002-01-21 19:03:29 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
function_decl
|
2011-02-02 06:13:34 +00:00
|
|
|
|
: '*' function_decl
|
2011-02-01 12:23:03 +00:00
|
|
|
|
{
|
2011-02-02 06:13:34 +00:00
|
|
|
|
$$ = $2;
|
|
|
|
|
$$->type = append_type ($$->type, pointer_type (0));
|
2011-02-01 12:23:03 +00:00
|
|
|
|
}
|
|
|
|
|
| function_decl array_decl
|
|
|
|
|
{
|
|
|
|
|
$$ = $1;
|
2011-02-02 06:13:34 +00:00
|
|
|
|
$$->type = append_type ($$->type, array_type (0, $2));
|
2011-02-01 12:23:03 +00:00
|
|
|
|
}
|
2011-02-02 06:13:34 +00:00
|
|
|
|
| '(' function_decl ')' { $$ = $2; }
|
2011-02-01 12:23:03 +00:00
|
|
|
|
| function_decl function_params
|
|
|
|
|
{
|
|
|
|
|
$$ = $1;
|
|
|
|
|
$$->params = $2;
|
2011-02-02 06:13:34 +00:00
|
|
|
|
$$->type = append_type ($$->type, parse_params (0, $2));
|
2011-02-01 12:23:03 +00:00
|
|
|
|
}
|
|
|
|
|
| NAME function_params
|
|
|
|
|
{
|
2011-02-03 01:48:12 +00:00
|
|
|
|
$$ = $1;
|
2011-02-01 12:23:03 +00:00
|
|
|
|
$$->params = $2;
|
2011-02-02 06:13:34 +00:00
|
|
|
|
$$->type = parse_params (0, $2);
|
2011-02-01 12:23:03 +00:00
|
|
|
|
}
|
2004-02-08 23:46:40 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
function_params
|
|
|
|
|
: '(' ')' { $$ = 0; }
|
|
|
|
|
| '(' ps var_list ')' { $$ = check_params ($3); }
|
2004-02-08 23:46:40 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-13 08:07:14 +00:00
|
|
|
|
qc_func_params
|
|
|
|
|
: '(' ')' { $$ = 0; }
|
|
|
|
|
| '(' ps qc_var_list ')' { $$ = check_params ($3); }
|
2011-02-13 08:37:11 +00:00
|
|
|
|
| '(' ps TYPE ')'
|
|
|
|
|
{
|
|
|
|
|
if ($3 != &type_void)
|
|
|
|
|
PARSE_ERROR;
|
|
|
|
|
$$ = 0;
|
|
|
|
|
}
|
2011-02-13 08:07:14 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
ps : ;
|
2002-10-31 22:58:59 +00:00
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
var_list
|
|
|
|
|
: param_declaration
|
|
|
|
|
| var_list ',' param_declaration
|
2002-05-22 17:13:52 +00:00
|
|
|
|
{
|
2011-02-01 12:23:03 +00:00
|
|
|
|
param_t *p;
|
|
|
|
|
|
|
|
|
|
for (p = $1; p->next; p = p->next)
|
|
|
|
|
;
|
|
|
|
|
p->next = $3;
|
|
|
|
|
$$ = $1;
|
2002-05-22 17:13:52 +00:00
|
|
|
|
}
|
2001-11-14 07:16:58 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-13 08:07:14 +00:00
|
|
|
|
qc_var_list
|
|
|
|
|
: qc_param_decl
|
|
|
|
|
| qc_var_list ',' qc_param_decl
|
|
|
|
|
{
|
|
|
|
|
param_t *p;
|
|
|
|
|
|
|
|
|
|
for (p = $1; p->next; p = p->next)
|
|
|
|
|
;
|
|
|
|
|
p->next = $3;
|
|
|
|
|
$$ = $1;
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
param_declaration
|
2011-02-02 06:13:34 +00:00
|
|
|
|
: type var_decl
|
|
|
|
|
{
|
2011-03-25 00:59:48 +00:00
|
|
|
|
if (!$1.type)
|
|
|
|
|
$1.type = type_default;
|
2011-02-03 01:48:12 +00:00
|
|
|
|
$2->type = find_type (append_type ($2->type, $1.type));
|
2011-02-02 06:13:34 +00:00
|
|
|
|
$$ = new_param (0, $2->type, $2->name);
|
|
|
|
|
}
|
|
|
|
|
| abstract_decl { $$ = new_param (0, $1->type, 0); }
|
2011-02-01 12:23:03 +00:00
|
|
|
|
| ELLIPSIS { $$ = new_param (0, 0, 0); }
|
2011-01-17 13:33:33 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
abstract_decl
|
2011-02-02 06:13:34 +00:00
|
|
|
|
: type abs_decl
|
|
|
|
|
{
|
|
|
|
|
$$ = $2;
|
2011-03-25 00:59:48 +00:00
|
|
|
|
if (!$1.type)
|
|
|
|
|
$1.type = type_default;
|
2011-02-03 01:48:12 +00:00
|
|
|
|
$$->type = find_type (append_type ($$->type, $1.type));
|
2011-02-02 06:13:34 +00:00
|
|
|
|
}
|
2011-01-17 13:33:33 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-13 08:07:14 +00:00
|
|
|
|
qc_param_decl
|
2011-03-07 01:43:38 +00:00
|
|
|
|
: type new_name
|
2011-02-13 08:07:14 +00:00
|
|
|
|
{
|
|
|
|
|
$2->type = find_type ($1.type);
|
|
|
|
|
$$ = new_param (0, $2->type, $2->name);
|
|
|
|
|
}
|
2011-03-07 01:43:38 +00:00
|
|
|
|
| type qc_func_params new_name
|
2011-02-13 08:07:14 +00:00
|
|
|
|
{
|
2011-02-21 23:54:01 +00:00
|
|
|
|
type_t **type;
|
|
|
|
|
// .float () foo; is a field holding a function variable rather
|
|
|
|
|
// than a function that returns a float field.
|
|
|
|
|
for (type = &$1.type; *type && (*type)->type == ev_field;
|
|
|
|
|
type = &(*type)->t.fldptr.type)
|
|
|
|
|
;
|
|
|
|
|
*type = parse_params (*type, $2);
|
|
|
|
|
$3->type = find_type ($1.type);
|
2011-02-22 03:07:31 +00:00
|
|
|
|
if ($3->type->type != ev_field)
|
|
|
|
|
$3->params = $2;
|
2011-02-13 08:07:14 +00:00
|
|
|
|
$$ = new_param (0, $3->type, $3->name);
|
|
|
|
|
}
|
|
|
|
|
| ELLIPSIS { $$ = new_param (0, 0, 0); }
|
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
abs_decl
|
2011-02-02 06:13:34 +00:00
|
|
|
|
: /* empty */ { $$ = new_symbol (""); }
|
|
|
|
|
| '(' abs_decl ')' function_params
|
2002-08-18 04:08:02 +00:00
|
|
|
|
{
|
2011-02-02 06:13:34 +00:00
|
|
|
|
$$ = $2;
|
2012-05-22 23:20:56 +00:00
|
|
|
|
$$->type = append_type ($$->type, parse_params (0, $4));
|
2011-01-17 13:33:33 +00:00
|
|
|
|
}
|
2011-02-02 06:13:34 +00:00
|
|
|
|
| '*' abs_decl
|
2011-01-17 13:33:33 +00:00
|
|
|
|
{
|
2011-02-02 06:13:34 +00:00
|
|
|
|
$$ = $2;
|
|
|
|
|
$$->type = append_type ($$->type, pointer_type (0));
|
2011-01-17 13:33:33 +00:00
|
|
|
|
}
|
2011-02-01 12:23:03 +00:00
|
|
|
|
| abs_decl array_decl
|
2011-01-17 13:33:33 +00:00
|
|
|
|
{
|
2011-02-01 12:23:03 +00:00
|
|
|
|
$$ = $1;
|
2011-02-02 06:13:34 +00:00
|
|
|
|
$$->type = append_type ($$->type, array_type (0, $2));
|
2011-02-01 12:23:03 +00:00
|
|
|
|
}
|
2011-02-02 06:13:34 +00:00
|
|
|
|
| '(' abs_decl ')'
|
2011-02-01 12:23:03 +00:00
|
|
|
|
{
|
2011-02-02 06:13:34 +00:00
|
|
|
|
$$ = $2;
|
2002-08-18 04:08:02 +00:00
|
|
|
|
}
|
2011-01-17 13:33:33 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
array_decl
|
|
|
|
|
: '[' fexpr ']'
|
|
|
|
|
{
|
|
|
|
|
$2 = fold_constants ($2);
|
|
|
|
|
if (!is_integer_val ($2) || expr_integer ($2) < 1) {
|
|
|
|
|
error (0, "invalid array size");
|
|
|
|
|
$$ = 0;
|
|
|
|
|
} else {
|
|
|
|
|
$$ = expr_integer ($2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
| '[' ']' { $$ = 0; }
|
2011-01-17 13:33:33 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-07 12:29:04 +00:00
|
|
|
|
local_specifiers
|
2011-02-07 12:41:03 +00:00
|
|
|
|
: LOCAL specifiers { $$ = $2; }
|
|
|
|
|
| specifiers { $$ = $1; }
|
2002-05-01 21:35:39 +00:00
|
|
|
|
;
|
2011-02-07 23:16:36 +00:00
|
|
|
|
|
2002-05-01 21:35:39 +00:00
|
|
|
|
param_list
|
2011-01-22 06:52:57 +00:00
|
|
|
|
: param { $$ = $1; }
|
2011-06-21 10:52:47 +00:00
|
|
|
|
| param_list ',' { $<param>$ = $<param>1; } param
|
|
|
|
|
{
|
|
|
|
|
$$ = $4;
|
|
|
|
|
(void) ($<symbol>3);
|
|
|
|
|
}
|
2002-05-01 21:35:39 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
param
|
2011-01-17 13:33:33 +00:00
|
|
|
|
: type identifier
|
|
|
|
|
{
|
2011-01-25 11:21:41 +00:00
|
|
|
|
$2 = check_redefined ($2);
|
2011-02-01 12:23:03 +00:00
|
|
|
|
$$ = param_append_identifiers ($<param>0, $2, $1.type);
|
2011-01-17 13:33:33 +00:00
|
|
|
|
}
|
2001-06-20 23:32:13 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-03-07 11:04:05 +00:00
|
|
|
|
local_decl_list
|
|
|
|
|
: decl_list
|
|
|
|
|
| qc_func_params
|
|
|
|
|
{
|
|
|
|
|
type_t **type;
|
|
|
|
|
specifier_t spec = $<spec>0; // copy spec bits and storage
|
|
|
|
|
// .float () foo; is a field holding a function variable rather
|
|
|
|
|
// than a function that returns a float field.
|
|
|
|
|
for (type = &spec.type; *type && (*type)->type == ev_field;
|
|
|
|
|
type = &(*type)->t.fldptr.type)
|
|
|
|
|
;
|
|
|
|
|
*type = parse_params (*type, $1);
|
|
|
|
|
spec.type = find_type (spec.type);
|
|
|
|
|
$<spec>$ = spec;
|
|
|
|
|
}
|
|
|
|
|
func_def_list
|
2011-06-21 10:52:47 +00:00
|
|
|
|
{
|
|
|
|
|
(void) ($<spec>2);
|
|
|
|
|
}
|
2011-03-07 11:04:05 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-07 12:29:04 +00:00
|
|
|
|
decl_list
|
2011-06-21 10:52:47 +00:00
|
|
|
|
: decl_list ',' { $<spec>$ = $<spec>0; } decl { (void) ($<spec>3); }
|
2011-02-07 12:29:04 +00:00
|
|
|
|
| decl
|
2001-06-20 23:32:13 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-07 12:29:04 +00:00
|
|
|
|
decl
|
2011-02-07 23:23:25 +00:00
|
|
|
|
: function_decl {}
|
2011-02-07 12:29:04 +00:00
|
|
|
|
| var_decl opt_initializer
|
2001-11-14 22:31:57 +00:00
|
|
|
|
{
|
2011-02-07 12:38:58 +00:00
|
|
|
|
specifier_t spec = $<spec>0;
|
|
|
|
|
type_t *type;
|
2012-12-04 05:25:06 +00:00
|
|
|
|
storage_class_t sc = $<spec>0.storage;
|
|
|
|
|
struct defspace_s *space = current_symtab->space;
|
2011-02-07 12:38:58 +00:00
|
|
|
|
|
2011-03-25 00:59:48 +00:00
|
|
|
|
if (!spec.type)
|
|
|
|
|
spec.type = type_default;
|
2012-12-04 05:25:06 +00:00
|
|
|
|
if (sc == sc_static)
|
|
|
|
|
space = pr.near_data;
|
2011-02-07 12:38:58 +00:00
|
|
|
|
type = find_type (append_type ($1->type, spec.type));
|
2012-12-04 05:25:06 +00:00
|
|
|
|
initialize_def ($1, type, $2, space, sc);
|
2001-11-14 22:31:57 +00:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
function_def_list
|
|
|
|
|
: func_def_list comma func_def_list_term
|
|
|
|
|
| func_def_list_term
|
2004-02-10 23:20:44 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
func_def_list
|
2011-02-01 12:23:03 +00:00
|
|
|
|
: func_def_list comma func_def { $$ = $2; }
|
|
|
|
|
| func_def { $$ = $<spec>0; }
|
2004-02-10 23:20:44 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
/* This rule is used only to get an action before both func_def and
|
|
|
|
|
func_def_list_term so that the function spec can be inherited.
|
|
|
|
|
*/
|
|
|
|
|
comma: ',' { $$ = $<spec>0; }
|
|
|
|
|
|
|
|
|
|
func_def_list_term
|
|
|
|
|
: non_code_funcion ';'
|
|
|
|
|
| code_function ';'
|
|
|
|
|
| code_function %prec IFX
|
2004-02-10 23:20:44 +00:00
|
|
|
|
;
|
|
|
|
|
|
2004-02-10 03:25:24 +00:00
|
|
|
|
func_def
|
2011-02-01 12:23:03 +00:00
|
|
|
|
: non_code_funcion
|
|
|
|
|
| code_function
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
code_function
|
|
|
|
|
: overloaded_identifier code_func
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
non_code_funcion
|
|
|
|
|
: overloaded_identifier non_code_func
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
overloaded_identifier
|
2004-11-13 11:50:00 +00:00
|
|
|
|
: identifier
|
|
|
|
|
{
|
2011-01-22 06:52:57 +00:00
|
|
|
|
$$ = $1;
|
2011-02-01 12:23:03 +00:00
|
|
|
|
$$->type = $<spec>0.type;
|
2011-03-07 11:04:05 +00:00
|
|
|
|
if (!local_expr && $$->type->type != ev_field) {
|
2011-02-22 03:07:31 +00:00
|
|
|
|
$$ = function_symbol ($$, $<spec>0.is_overload, 1);
|
|
|
|
|
$$->params = $<spec>0.params;
|
|
|
|
|
}
|
2004-11-13 11:50:00 +00:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
2004-02-10 23:20:44 +00:00
|
|
|
|
non_code_func
|
|
|
|
|
: '=' '#' fexpr
|
2011-01-22 06:52:57 +00:00
|
|
|
|
{
|
2011-02-15 03:38:29 +00:00
|
|
|
|
build_builtin_function ($<symbol>0, $3, 0);
|
2011-01-22 06:52:57 +00:00
|
|
|
|
}
|
2011-02-22 03:07:31 +00:00
|
|
|
|
| '=' fexpr
|
|
|
|
|
{
|
|
|
|
|
symbol_t *sym = $<symbol>0;
|
|
|
|
|
specifier_t spec = $<spec>-1;
|
|
|
|
|
initialize_def (sym, sym->type, $2, current_symtab->space,
|
|
|
|
|
spec.storage);
|
|
|
|
|
}
|
2004-02-10 23:20:44 +00:00
|
|
|
|
| /* emtpy */
|
2011-01-26 05:48:22 +00:00
|
|
|
|
{
|
2011-02-15 03:38:29 +00:00
|
|
|
|
symbol_t *sym = $<symbol>0;
|
2011-02-22 03:07:31 +00:00
|
|
|
|
specifier_t spec = $<spec>-1;
|
2011-03-07 11:04:05 +00:00
|
|
|
|
if (!local_expr && sym->type->type != ev_field) {
|
2012-12-23 05:25:09 +00:00
|
|
|
|
// things might be a confused mess from earlier errors
|
|
|
|
|
if (sym->sy_type == sy_func)
|
|
|
|
|
make_function (sym, 0, sym->table->space, spec.storage);
|
2011-02-22 03:07:31 +00:00
|
|
|
|
} else {
|
|
|
|
|
initialize_def (sym, sym->type, 0, current_symtab->space,
|
|
|
|
|
spec.storage);
|
|
|
|
|
}
|
2011-01-26 05:48:22 +00:00
|
|
|
|
}
|
2004-02-10 23:20:44 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
code_func
|
2011-02-07 12:41:03 +00:00
|
|
|
|
: '=' optional_state_expr
|
2011-03-07 11:51:51 +00:00
|
|
|
|
save_storage
|
2011-01-22 06:52:57 +00:00
|
|
|
|
{
|
|
|
|
|
$<symtab>$ = current_symtab;
|
2011-02-15 03:38:29 +00:00
|
|
|
|
current_func = begin_function ($<symbol>0, 0, current_symtab, 0);
|
2011-01-22 06:52:57 +00:00
|
|
|
|
current_symtab = current_func->symtab;
|
2012-12-02 01:11:30 +00:00
|
|
|
|
current_storage = sc_local;
|
2011-01-22 06:52:57 +00:00
|
|
|
|
}
|
2011-02-07 12:41:03 +00:00
|
|
|
|
compound_statement
|
2011-01-22 06:52:57 +00:00
|
|
|
|
{
|
2011-03-07 11:51:51 +00:00
|
|
|
|
build_code_function ($<symbol>0, $2, $5);
|
|
|
|
|
current_symtab = $<symtab>4;
|
|
|
|
|
current_storage = $3.storage;
|
2011-02-14 14:08:51 +00:00
|
|
|
|
current_func = 0;
|
2011-01-22 06:52:57 +00:00
|
|
|
|
}
|
2004-02-10 03:25:24 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-01 21:35:39 +00:00
|
|
|
|
opt_initializer
|
2011-02-01 12:23:03 +00:00
|
|
|
|
: /*empty*/ { $$ = 0; }
|
|
|
|
|
| var_initializer { $$ = $1; }
|
2001-11-14 22:31:57 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-01 21:35:39 +00:00
|
|
|
|
var_initializer
|
2011-02-01 12:23:03 +00:00
|
|
|
|
: '=' fexpr { $$ = $2; }
|
|
|
|
|
| '=' '{' element_list optional_comma '}' { $$ = $3; }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
optional_state_expr
|
2011-01-25 03:07:02 +00:00
|
|
|
|
: /* emtpy */ { $$ = 0; }
|
|
|
|
|
| '[' fexpr ',' think opt_step ']' { $$ = build_state_expr ($2, $4, $5); }
|
2004-02-11 08:09:10 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
think
|
2011-02-01 12:23:03 +00:00
|
|
|
|
: identifier
|
2004-02-11 08:09:10 +00:00
|
|
|
|
{
|
2011-03-05 09:01:37 +00:00
|
|
|
|
$$ = think_expr ($1);
|
2004-02-11 08:09:10 +00:00
|
|
|
|
}
|
|
|
|
|
| '(' fexpr ')'
|
|
|
|
|
{
|
|
|
|
|
$$ = $2;
|
2001-06-20 07:02:36 +00:00
|
|
|
|
}
|
2001-06-15 19:38:43 +00:00
|
|
|
|
;
|
|
|
|
|
|
2004-02-11 01:43:33 +00:00
|
|
|
|
opt_step
|
|
|
|
|
: ',' fexpr { $$ = $2; }
|
|
|
|
|
| /* empty */ { $$ = 0; }
|
|
|
|
|
;
|
|
|
|
|
|
2002-05-01 21:35:39 +00:00
|
|
|
|
element_list
|
|
|
|
|
: element
|
|
|
|
|
{
|
2011-01-25 03:07:02 +00:00
|
|
|
|
$$ = new_block_expr ();
|
|
|
|
|
append_expr ($$, $1);
|
2002-05-01 21:35:39 +00:00
|
|
|
|
}
|
2011-01-25 03:07:02 +00:00
|
|
|
|
| element_list ',' element
|
2002-05-01 21:35:39 +00:00
|
|
|
|
{
|
2011-01-25 03:07:02 +00:00
|
|
|
|
append_expr ($$, $3);
|
2002-05-01 21:35:39 +00:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
element
|
2011-02-01 12:23:03 +00:00
|
|
|
|
: '{' element_list optional_comma '}' { $$ = $2; }
|
2011-01-25 03:07:02 +00:00
|
|
|
|
| fexpr { $$ = $1; }
|
2002-05-01 21:35:39 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
optional_comma
|
2002-05-01 21:35:39 +00:00
|
|
|
|
: /* empty */
|
|
|
|
|
| ','
|
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
compound_statement
|
2011-01-06 11:22:30 +00:00
|
|
|
|
: '{'
|
2001-06-20 07:02:36 +00:00
|
|
|
|
{
|
2011-01-25 03:34:45 +00:00
|
|
|
|
if (!options.traditional) {
|
2011-01-17 13:33:33 +00:00
|
|
|
|
current_symtab = new_symtab (current_symtab, stab_local);
|
2011-01-25 03:34:45 +00:00
|
|
|
|
current_symtab->space = current_symtab->parent->space;
|
|
|
|
|
}
|
2001-10-24 06:39:49 +00:00
|
|
|
|
}
|
|
|
|
|
statements '}'
|
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
if (!options.traditional)
|
|
|
|
|
current_symtab = current_symtab->parent;
|
2001-10-24 06:39:49 +00:00
|
|
|
|
$$ = $3;
|
2001-06-20 07:02:36 +00:00
|
|
|
|
}
|
2001-06-12 19:44:26 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
statements
|
|
|
|
|
: /*empty*/
|
2001-06-20 07:02:36 +00:00
|
|
|
|
{
|
2001-06-26 03:33:01 +00:00
|
|
|
|
$$ = new_block_expr ();
|
2001-06-20 07:02:36 +00:00
|
|
|
|
}
|
2001-06-13 07:16:39 +00:00
|
|
|
|
| statements statement
|
2001-06-20 07:02:36 +00:00
|
|
|
|
{
|
2001-06-26 03:33:01 +00:00
|
|
|
|
$$ = append_expr ($1, $2);
|
2001-06-20 07:02:36 +00:00
|
|
|
|
}
|
2001-06-12 19:44:26 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-07 12:29:04 +00:00
|
|
|
|
local_def
|
|
|
|
|
: local_specifiers
|
2011-01-17 13:33:33 +00:00
|
|
|
|
{
|
2011-03-07 08:49:01 +00:00
|
|
|
|
if (!$1.storage)
|
2012-12-02 01:11:30 +00:00
|
|
|
|
$1.storage = sc_local;
|
2011-02-07 12:29:04 +00:00
|
|
|
|
$<spec>$ = $1;
|
2011-01-17 13:33:33 +00:00
|
|
|
|
local_expr = new_block_expr ();
|
|
|
|
|
}
|
2011-03-07 11:04:05 +00:00
|
|
|
|
local_decl_list ';'
|
2011-01-17 13:33:33 +00:00
|
|
|
|
{
|
|
|
|
|
$$ = local_expr;
|
|
|
|
|
local_expr = 0;
|
2011-06-21 10:52:47 +00:00
|
|
|
|
(void) ($<spec>2);
|
2011-01-17 13:33:33 +00:00
|
|
|
|
}
|
2012-11-20 08:11:39 +00:00
|
|
|
|
;
|
2011-02-07 12:29:04 +00:00
|
|
|
|
|
|
|
|
|
statement
|
|
|
|
|
: ';' { $$ = 0; }
|
|
|
|
|
| error ';' { $$ = 0; yyerrok; }
|
|
|
|
|
| compound_statement { $$ = $1; }
|
|
|
|
|
| local_def { $$ = $1; }
|
2010-12-30 07:05:50 +00:00
|
|
|
|
| RETURN opt_expr ';'
|
2001-06-25 20:52:04 +00:00
|
|
|
|
{
|
2001-07-23 02:27:46 +00:00
|
|
|
|
$$ = return_expr (current_func, $2);
|
2001-06-25 20:52:04 +00:00
|
|
|
|
}
|
2001-10-24 18:57:29 +00:00
|
|
|
|
| BREAK ';'
|
|
|
|
|
{
|
2001-10-25 06:41:52 +00:00
|
|
|
|
$$ = 0;
|
2001-10-24 18:57:29 +00:00
|
|
|
|
if (break_label)
|
2011-03-03 06:28:49 +00:00
|
|
|
|
$$ = goto_expr (break_label);
|
2001-10-24 18:57:29 +00:00
|
|
|
|
else
|
2001-10-25 06:41:52 +00:00
|
|
|
|
error (0, "break outside of loop or switch");
|
2001-10-24 18:57:29 +00:00
|
|
|
|
}
|
|
|
|
|
| CONTINUE ';'
|
|
|
|
|
{
|
2001-10-25 06:41:52 +00:00
|
|
|
|
$$ = 0;
|
2001-10-24 18:57:29 +00:00
|
|
|
|
if (continue_label)
|
2011-03-03 06:28:49 +00:00
|
|
|
|
$$ = goto_expr (continue_label);
|
2001-10-24 18:57:29 +00:00
|
|
|
|
else
|
2001-10-25 06:41:52 +00:00
|
|
|
|
error (0, "continue outside of loop");
|
|
|
|
|
}
|
2004-01-25 21:36:44 +00:00
|
|
|
|
| CASE fexpr ':'
|
2001-10-25 06:41:52 +00:00
|
|
|
|
{
|
|
|
|
|
$$ = case_label_expr (switch_block, $2);
|
|
|
|
|
}
|
|
|
|
|
| DEFAULT ':'
|
|
|
|
|
{
|
|
|
|
|
$$ = case_label_expr (switch_block, 0);
|
|
|
|
|
}
|
2011-03-05 15:29:29 +00:00
|
|
|
|
| SWITCH break_label '(' fexpr switch_block ')' compound_statement
|
2001-10-25 06:41:52 +00:00
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$$ = switch_expr (switch_block, break_label, $7);
|
2011-03-05 15:29:29 +00:00
|
|
|
|
switch_block = $5;
|
2001-10-25 06:41:52 +00:00
|
|
|
|
break_label = $2;
|
2001-10-24 18:57:29 +00:00
|
|
|
|
}
|
2011-01-17 13:33:33 +00:00
|
|
|
|
| IF '(' texpr ')' statement %prec IFX
|
2001-06-25 20:52:04 +00:00
|
|
|
|
{
|
2012-12-01 07:37:38 +00:00
|
|
|
|
$$ = build_if_statement ($3, $5, 0, 0);
|
2001-06-25 20:52:04 +00:00
|
|
|
|
}
|
2012-12-01 07:37:38 +00:00
|
|
|
|
| IF '(' texpr ')' statement else statement
|
2001-06-25 20:52:04 +00:00
|
|
|
|
{
|
2012-12-01 07:37:38 +00:00
|
|
|
|
$$ = build_if_statement ($3, $5, $6, $7);
|
2001-07-15 01:51:01 +00:00
|
|
|
|
}
|
2011-01-17 13:33:33 +00:00
|
|
|
|
| FOR break_label continue_label
|
|
|
|
|
'(' opt_expr ';' opt_expr ';' opt_expr ')' statement
|
2001-06-25 20:52:04 +00:00
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$$ = build_for_statement ($5, $7, $9, $11,
|
|
|
|
|
break_label, continue_label);
|
|
|
|
|
break_label = $2;
|
|
|
|
|
continue_label = $3;
|
2001-06-25 20:52:04 +00:00
|
|
|
|
}
|
2011-01-17 13:33:33 +00:00
|
|
|
|
| WHILE break_label continue_label '(' texpr ')' statement
|
2001-10-18 23:06:39 +00:00
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$$ = build_while_statement ($5, $7, break_label, continue_label);
|
|
|
|
|
break_label = $2;
|
|
|
|
|
continue_label = $3;
|
2001-10-18 23:06:39 +00:00
|
|
|
|
}
|
2011-01-17 13:33:33 +00:00
|
|
|
|
| DO break_label continue_label statement WHILE '(' texpr ')' ';'
|
2001-06-25 20:52:04 +00:00
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$$ = build_do_while_statement ($4, $7,
|
|
|
|
|
break_label, continue_label);
|
2001-10-24 18:57:29 +00:00
|
|
|
|
break_label = $2;
|
|
|
|
|
continue_label = $3;
|
2001-06-25 20:52:04 +00:00
|
|
|
|
}
|
2004-01-25 21:36:44 +00:00
|
|
|
|
| fexpr ';'
|
2001-06-25 20:52:04 +00:00
|
|
|
|
{
|
|
|
|
|
$$ = $1;
|
|
|
|
|
}
|
2001-06-12 19:44:26 +00:00
|
|
|
|
;
|
|
|
|
|
|
2012-12-01 07:37:38 +00:00
|
|
|
|
else
|
|
|
|
|
: ELSE
|
|
|
|
|
{
|
|
|
|
|
// this is only to get the the file and line number info
|
|
|
|
|
$$ = new_nil_expr ();
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
2003-10-22 08:05:17 +00:00
|
|
|
|
label
|
|
|
|
|
: /* empty */
|
|
|
|
|
{
|
|
|
|
|
$$ = new_label_expr ();
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
2001-10-24 18:57:29 +00:00
|
|
|
|
break_label
|
|
|
|
|
: /* empty */
|
|
|
|
|
{
|
|
|
|
|
$$ = break_label;
|
|
|
|
|
break_label = new_label_expr ();
|
|
|
|
|
}
|
2002-04-27 02:51:00 +00:00
|
|
|
|
;
|
2001-10-24 18:57:29 +00:00
|
|
|
|
|
|
|
|
|
continue_label
|
|
|
|
|
: /* empty */
|
|
|
|
|
{
|
|
|
|
|
$$ = continue_label;
|
|
|
|
|
continue_label = new_label_expr ();
|
2001-10-25 06:41:52 +00:00
|
|
|
|
}
|
2002-04-27 02:51:00 +00:00
|
|
|
|
;
|
2001-10-25 06:41:52 +00:00
|
|
|
|
|
|
|
|
|
switch_block
|
|
|
|
|
: /* empty */
|
|
|
|
|
{
|
|
|
|
|
$$ = switch_block;
|
|
|
|
|
switch_block = new_switch_block ();
|
2011-03-05 15:29:29 +00:00
|
|
|
|
switch_block->test = $<expr>0;
|
2001-10-24 18:57:29 +00:00
|
|
|
|
}
|
2002-04-27 02:51:00 +00:00
|
|
|
|
;
|
2001-10-24 18:57:29 +00:00
|
|
|
|
|
2001-08-01 06:29:09 +00:00
|
|
|
|
opt_expr
|
2004-01-25 21:36:44 +00:00
|
|
|
|
: fexpr
|
2001-08-01 06:29:09 +00:00
|
|
|
|
| /* empty */
|
|
|
|
|
{
|
|
|
|
|
$$ = 0;
|
|
|
|
|
}
|
2002-04-27 02:51:00 +00:00
|
|
|
|
;
|
2001-08-01 06:29:09 +00:00
|
|
|
|
|
2002-10-31 22:58:59 +00:00
|
|
|
|
unary_expr
|
2012-11-04 01:27:41 +00:00
|
|
|
|
: NAME { $$ = new_symbol_expr ($1); }
|
|
|
|
|
| ARGS { $$ = new_name_expr (".args"); }
|
|
|
|
|
| SELF { $$ = new_self_expr (); }
|
|
|
|
|
| THIS { $$ = new_this_expr (); }
|
|
|
|
|
| const { $$ = $1; }
|
|
|
|
|
| '(' expr ')' { $$ = $2; $$->paren = 1; }
|
|
|
|
|
| unary_expr '(' opt_arg_list ')' { $$ = function_expr ($1, $3); }
|
|
|
|
|
| unary_expr '[' expr ']' { $$ = array_expr ($1, $3); }
|
|
|
|
|
| unary_expr '.' unary_expr { $$ = binary_expr ('.', $1, $3); }
|
|
|
|
|
| INCOP unary_expr { $$ = incop_expr ($1, $2, 0); }
|
|
|
|
|
| unary_expr INCOP { $$ = incop_expr ($2, $1, 1); }
|
2002-10-31 22:58:59 +00:00
|
|
|
|
| '+' cast_expr %prec UNARY { $$ = $2; }
|
|
|
|
|
| '-' cast_expr %prec UNARY { $$ = unary_expr ('-', $2); }
|
|
|
|
|
| '!' cast_expr %prec UNARY { $$ = unary_expr ('!', $2); }
|
|
|
|
|
| '~' cast_expr %prec UNARY { $$ = unary_expr ('~', $2); }
|
|
|
|
|
| '&' cast_expr %prec UNARY { $$ = address_expr ($2, 0, 0); }
|
2010-01-13 06:31:41 +00:00
|
|
|
|
| '*' cast_expr %prec UNARY { $$ = pointer_expr ($2); }
|
2004-11-02 07:02:00 +00:00
|
|
|
|
| SIZEOF unary_expr %prec UNARY { $$ = sizeof_expr ($2, 0); }
|
2011-02-03 01:53:59 +00:00
|
|
|
|
| SIZEOF '(' abstract_decl ')' %prec HYPERUNARY
|
2011-02-01 12:23:03 +00:00
|
|
|
|
{
|
2011-02-03 01:53:59 +00:00
|
|
|
|
$$ = sizeof_expr (0, $3->type);
|
2011-02-01 12:23:03 +00:00
|
|
|
|
}
|
2002-10-31 22:58:59 +00:00
|
|
|
|
| obj_expr { $$ = $1; }
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
cast_expr
|
2012-11-04 01:27:41 +00:00
|
|
|
|
: '(' abstract_decl ')' cast_expr
|
2011-02-03 01:53:59 +00:00
|
|
|
|
{
|
|
|
|
|
$$ = cast_expr ($2->type, $4);
|
|
|
|
|
}
|
2012-11-04 01:27:41 +00:00
|
|
|
|
| unary_expr %prec LOW
|
2002-10-31 22:58:59 +00:00
|
|
|
|
;
|
|
|
|
|
|
2001-06-12 19:44:26 +00:00
|
|
|
|
expr
|
2002-10-31 22:58:59 +00:00
|
|
|
|
: cast_expr
|
|
|
|
|
| expr '=' expr { $$ = assign_expr ($1, $3); }
|
2001-08-20 06:22:28 +00:00
|
|
|
|
| expr ASX expr { $$ = asx_expr ($2, $1, $3); }
|
2001-08-11 21:15:24 +00:00
|
|
|
|
| expr '?' expr ':' expr { $$ = conditional_expr ($1, $3, $5); }
|
2003-10-22 08:05:17 +00:00
|
|
|
|
| expr AND label expr { $$ = bool_expr (AND, $3, $1, $4); }
|
|
|
|
|
| expr OR label expr { $$ = bool_expr (OR, $3, $1, $4); }
|
2001-08-11 21:15:24 +00:00
|
|
|
|
| expr EQ expr { $$ = binary_expr (EQ, $1, $3); }
|
|
|
|
|
| expr NE expr { $$ = binary_expr (NE, $1, $3); }
|
|
|
|
|
| expr LE expr { $$ = binary_expr (LE, $1, $3); }
|
|
|
|
|
| expr GE expr { $$ = binary_expr (GE, $1, $3); }
|
|
|
|
|
| expr LT expr { $$ = binary_expr (LT, $1, $3); }
|
|
|
|
|
| expr GT expr { $$ = binary_expr (GT, $1, $3); }
|
|
|
|
|
| expr SHL expr { $$ = binary_expr (SHL, $1, $3); }
|
|
|
|
|
| expr SHR expr { $$ = binary_expr (SHR, $1, $3); }
|
|
|
|
|
| expr '+' expr { $$ = binary_expr ('+', $1, $3); }
|
|
|
|
|
| expr '-' expr { $$ = binary_expr ('-', $1, $3); }
|
|
|
|
|
| expr '*' expr { $$ = binary_expr ('*', $1, $3); }
|
|
|
|
|
| expr '/' expr { $$ = binary_expr ('/', $1, $3); }
|
|
|
|
|
| expr '&' expr { $$ = binary_expr ('&', $1, $3); }
|
|
|
|
|
| expr '|' expr { $$ = binary_expr ('|', $1, $3); }
|
|
|
|
|
| expr '^' expr { $$ = binary_expr ('^', $1, $3); }
|
|
|
|
|
| expr '%' expr { $$ = binary_expr ('%', $1, $3); }
|
2002-10-31 22:58:59 +00:00
|
|
|
|
;
|
|
|
|
|
|
2004-01-25 21:36:44 +00:00
|
|
|
|
fexpr
|
|
|
|
|
: expr { $$ = fold_constants ($1); }
|
2004-01-27 04:41:20 +00:00
|
|
|
|
;
|
2004-01-25 21:36:44 +00:00
|
|
|
|
|
2007-05-13 08:39:07 +00:00
|
|
|
|
texpr
|
|
|
|
|
: fexpr { $$ = convert_bool ($1, 1); }
|
|
|
|
|
;
|
|
|
|
|
|
2002-10-31 22:58:59 +00:00
|
|
|
|
opt_arg_list
|
|
|
|
|
: /* emtpy */ { $$ = 0; }
|
|
|
|
|
| arg_list { $$ = $1; }
|
2001-06-12 19:44:26 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
arg_list
|
2004-01-25 21:36:44 +00:00
|
|
|
|
: fexpr
|
|
|
|
|
| arg_list ',' fexpr
|
2001-06-20 21:18:04 +00:00
|
|
|
|
{
|
|
|
|
|
$3->next = $1;
|
|
|
|
|
$$ = $3;
|
|
|
|
|
}
|
2001-06-12 19:44:26 +00:00
|
|
|
|
;
|
|
|
|
|
|
2001-06-13 07:16:39 +00:00
|
|
|
|
const
|
2012-12-18 04:59:45 +00:00
|
|
|
|
: VALUE
|
2002-09-11 16:21:26 +00:00
|
|
|
|
| NIL { $$ = new_nil_expr (); }
|
2011-01-17 13:33:33 +00:00
|
|
|
|
| string
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
string
|
|
|
|
|
: STRING
|
|
|
|
|
| string STRING { $$ = binary_expr ('+', $1, $2); }
|
2002-04-26 21:42:50 +00:00
|
|
|
|
;
|
|
|
|
|
|
2004-11-02 07:02:00 +00:00
|
|
|
|
identifier
|
|
|
|
|
: NAME
|
2012-12-18 03:49:43 +00:00
|
|
|
|
| OBJECT
|
2004-11-02 07:02:00 +00:00
|
|
|
|
| CLASS_NAME
|
2011-01-17 13:33:33 +00:00
|
|
|
|
| TYPE_NAME
|
2004-11-02 07:02:00 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// Objective-QC stuff
|
|
|
|
|
|
2002-05-08 21:24:24 +00:00
|
|
|
|
obj_def
|
2002-11-15 17:12:16 +00:00
|
|
|
|
: classdef { }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
| classdecl
|
|
|
|
|
| protocoldef
|
2002-05-15 19:10:23 +00:00
|
|
|
|
| { if (!current_class) PARSE_ERROR; } methoddef
|
2002-05-07 16:55:54 +00:00
|
|
|
|
| END
|
2002-05-15 19:10:23 +00:00
|
|
|
|
{
|
|
|
|
|
if (!current_class)
|
|
|
|
|
PARSE_ERROR;
|
2002-05-15 23:24:19 +00:00
|
|
|
|
else
|
|
|
|
|
class_finish (current_class);
|
2002-05-15 19:10:23 +00:00
|
|
|
|
current_class = 0;
|
|
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 21:24:24 +00:00
|
|
|
|
identifier_list
|
2004-11-02 07:02:00 +00:00
|
|
|
|
: identifier
|
2002-05-08 21:24:24 +00:00
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$$ = append_expr (new_block_expr (), new_symbol_expr ($1));
|
2002-05-08 21:24:24 +00:00
|
|
|
|
}
|
2004-11-02 07:02:00 +00:00
|
|
|
|
| identifier_list ',' identifier
|
2002-05-08 21:24:24 +00:00
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$$ = append_expr ($1, new_symbol_expr ($3));
|
2002-05-08 21:24:24 +00:00
|
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-10 00:00:23 +00:00
|
|
|
|
classdecl
|
2002-08-20 21:13:18 +00:00
|
|
|
|
: CLASS identifier_list ';'
|
2002-05-08 21:24:24 +00:00
|
|
|
|
{
|
|
|
|
|
expr_t *e;
|
2011-02-03 06:21:09 +00:00
|
|
|
|
for (e = $2->e.block.head; e; e = e->next) {
|
2011-01-17 13:33:33 +00:00
|
|
|
|
get_class (e->e.symbol, 1);
|
2011-02-03 06:21:09 +00:00
|
|
|
|
if (!e->e.symbol->table)
|
|
|
|
|
symtab_addsymbol (current_symtab, e->e.symbol);
|
|
|
|
|
}
|
2002-05-08 21:24:24 +00:00
|
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-08-18 04:08:02 +00:00
|
|
|
|
class_name
|
2007-04-28 08:49:07 +00:00
|
|
|
|
: identifier %prec CLASS_NOT_CATEGORY
|
2002-05-08 21:24:24 +00:00
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$1 = check_undefined ($1);
|
2012-12-19 02:53:19 +00:00
|
|
|
|
if (!$1->type || !obj_is_class ($1->type)) {
|
2011-02-03 06:21:09 +00:00
|
|
|
|
error (0, "`%s' is not a class %p", $1->name, $1->type);
|
2002-05-10 00:00:23 +00:00
|
|
|
|
$$ = get_class (0, 1);
|
2011-01-17 13:33:33 +00:00
|
|
|
|
} else {
|
|
|
|
|
$$ = $1->type->t.class;
|
2002-05-10 00:00:23 +00:00
|
|
|
|
}
|
2002-05-08 21:24:24 +00:00
|
|
|
|
}
|
2002-05-10 00:00:23 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
new_class_name
|
2004-11-02 07:02:00 +00:00
|
|
|
|
: identifier
|
2002-05-08 21:24:24 +00:00
|
|
|
|
{
|
2011-03-24 02:39:34 +00:00
|
|
|
|
if (current_class) {
|
|
|
|
|
warning (0, "‘@end’ missing in implementation context");
|
|
|
|
|
class_finish (current_class);
|
|
|
|
|
current_class = 0;
|
|
|
|
|
}
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$$ = get_class ($1, 0);
|
|
|
|
|
if (!$$) {
|
|
|
|
|
$1 = check_redefined ($1);
|
2011-02-03 06:21:09 +00:00
|
|
|
|
$$ = get_class ($1, 1);
|
2002-05-10 00:00:23 +00:00
|
|
|
|
}
|
2010-12-31 06:56:31 +00:00
|
|
|
|
current_class = &$$->class_type;
|
2011-02-03 06:21:09 +00:00
|
|
|
|
if (!$1->table)
|
|
|
|
|
symtab_addsymbol (current_symtab, $1);
|
2002-05-08 21:24:24 +00:00
|
|
|
|
}
|
2002-05-30 21:18:58 +00:00
|
|
|
|
;
|
2002-05-10 00:00:23 +00:00
|
|
|
|
|
2002-05-15 19:10:23 +00:00
|
|
|
|
class_with_super
|
|
|
|
|
: class_name ':' class_name
|
|
|
|
|
{
|
|
|
|
|
if ($1->super_class != $3)
|
2002-11-12 19:52:43 +00:00
|
|
|
|
error (0, "%s is not a super class of %s", $3->name, $1->name);
|
2002-05-15 19:10:23 +00:00
|
|
|
|
$$ = $1;
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
new_class_with_super
|
|
|
|
|
: new_class_name ':' class_name
|
|
|
|
|
{
|
|
|
|
|
$1->super_class = $3;
|
|
|
|
|
$$ = $1;
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
category_name
|
2004-11-02 07:02:00 +00:00
|
|
|
|
: identifier '(' identifier ')'
|
2002-05-15 19:10:23 +00:00
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$$ = get_category ($1, $3->name, 0);
|
2002-05-15 19:10:23 +00:00
|
|
|
|
if (!$$) {
|
2011-01-17 13:33:33 +00:00
|
|
|
|
error (0, "undefined category `%s (%s)'", $1->name, $3->name);
|
2002-05-15 19:10:23 +00:00
|
|
|
|
$$ = get_category (0, 0, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
new_category_name
|
2004-11-02 07:02:00 +00:00
|
|
|
|
: identifier '(' identifier ')'
|
2002-05-15 19:10:23 +00:00
|
|
|
|
{
|
2011-03-24 02:39:34 +00:00
|
|
|
|
if (current_class) {
|
|
|
|
|
warning (0, "‘@end’ missing in implementation context");
|
|
|
|
|
class_finish (current_class);
|
|
|
|
|
current_class = 0;
|
|
|
|
|
}
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$$ = get_category ($1, $3->name, 1);
|
2002-05-15 19:10:23 +00:00
|
|
|
|
if ($$->defined) {
|
2011-01-17 13:33:33 +00:00
|
|
|
|
error (0, "redefinition of category `%s (%s)'",
|
|
|
|
|
$1->name, $3->name);
|
2002-05-15 19:10:23 +00:00
|
|
|
|
$$ = get_category (0, 0, 1);
|
|
|
|
|
}
|
2010-12-31 06:56:31 +00:00
|
|
|
|
current_class = &$$->class_type;
|
2002-05-15 19:10:23 +00:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
2010-12-12 11:27:56 +00:00
|
|
|
|
class_reference
|
|
|
|
|
: identifier
|
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
emit_class_ref ($1->name);
|
2010-12-12 11:27:56 +00:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
category_reference
|
|
|
|
|
: identifier '(' identifier ')'
|
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
emit_category_ref ($1->name, $3->name);
|
2010-12-12 11:27:56 +00:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
2002-05-10 00:00:23 +00:00
|
|
|
|
protocol_name
|
2004-11-02 07:02:00 +00:00
|
|
|
|
: identifier
|
2002-05-08 21:24:24 +00:00
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$$ = get_protocol ($1->name, 0);
|
2002-05-15 19:10:23 +00:00
|
|
|
|
if ($$) {
|
2011-01-17 13:33:33 +00:00
|
|
|
|
error (0, "redefinition of %s", $1->name);
|
2002-05-10 00:00:23 +00:00
|
|
|
|
$$ = get_protocol (0, 1);
|
2002-05-15 19:10:23 +00:00
|
|
|
|
} else {
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$$ = get_protocol ($1->name, 1);
|
2002-05-10 00:00:23 +00:00
|
|
|
|
}
|
2010-12-31 06:56:31 +00:00
|
|
|
|
current_class = &$$->class_type;
|
2002-05-08 21:24:24 +00:00
|
|
|
|
}
|
2002-05-30 21:18:58 +00:00
|
|
|
|
;
|
2002-05-10 00:00:23 +00:00
|
|
|
|
|
2002-05-15 19:10:23 +00:00
|
|
|
|
classdef
|
2002-05-22 17:13:52 +00:00
|
|
|
|
: INTERFACE new_class_name
|
2006-12-01 08:17:55 +00:00
|
|
|
|
protocolrefs { class_add_protocols ($2, $3); }
|
2009-12-21 05:53:00 +00:00
|
|
|
|
'{' { $<class>$ = $2; }
|
|
|
|
|
ivar_decl_list '}'
|
|
|
|
|
{
|
|
|
|
|
class_add_ivars ($2, $7);
|
|
|
|
|
$<class>$ = $2;
|
|
|
|
|
}
|
2002-11-14 18:17:43 +00:00
|
|
|
|
methodprotolist { class_add_methods ($2, $10); }
|
2006-12-01 08:17:55 +00:00
|
|
|
|
END
|
|
|
|
|
{
|
|
|
|
|
current_class = 0;
|
|
|
|
|
(void) ($<class>6);
|
|
|
|
|
(void) ($<class>9);
|
|
|
|
|
}
|
2002-05-22 17:13:52 +00:00
|
|
|
|
| INTERFACE new_class_name
|
2011-02-03 06:21:09 +00:00
|
|
|
|
protocolrefs { class_add_protocols ($2, $3); }
|
2009-12-21 05:53:00 +00:00
|
|
|
|
{
|
|
|
|
|
class_add_ivars ($2, class_new_ivars ($2));
|
|
|
|
|
$<class>$ = $2;
|
|
|
|
|
}
|
2003-07-30 04:11:45 +00:00
|
|
|
|
methodprotolist { class_add_methods ($2, $6); }
|
2006-12-01 08:17:55 +00:00
|
|
|
|
END
|
|
|
|
|
{
|
|
|
|
|
current_class = 0;
|
|
|
|
|
(void) ($<class>5);
|
|
|
|
|
}
|
2002-05-22 17:13:52 +00:00
|
|
|
|
| INTERFACE new_class_with_super
|
2004-11-11 00:34:00 +00:00
|
|
|
|
protocolrefs { class_add_protocols ($2, $3);}
|
2009-12-21 05:53:00 +00:00
|
|
|
|
'{' { $<class>$ = $2; }
|
|
|
|
|
ivar_decl_list '}'
|
|
|
|
|
{
|
|
|
|
|
class_add_ivars ($2, $7);
|
|
|
|
|
$<class>$ = $2;
|
|
|
|
|
}
|
2002-11-14 18:17:43 +00:00
|
|
|
|
methodprotolist { class_add_methods ($2, $10); }
|
2006-12-01 08:17:55 +00:00
|
|
|
|
END
|
|
|
|
|
{
|
|
|
|
|
current_class = 0;
|
|
|
|
|
(void) ($<class>6);
|
|
|
|
|
(void) ($<class>9);
|
|
|
|
|
}
|
2002-05-22 17:13:52 +00:00
|
|
|
|
| INTERFACE new_class_with_super
|
2004-11-11 00:34:00 +00:00
|
|
|
|
protocolrefs { class_add_protocols ($2, $3); }
|
2009-12-21 05:53:00 +00:00
|
|
|
|
{
|
|
|
|
|
class_add_ivars ($2, class_new_ivars ($2));
|
|
|
|
|
$<class>$ = $2;
|
|
|
|
|
}
|
2003-07-30 04:11:45 +00:00
|
|
|
|
methodprotolist { class_add_methods ($2, $6); }
|
2006-12-01 08:17:55 +00:00
|
|
|
|
END
|
|
|
|
|
{
|
|
|
|
|
current_class = 0;
|
|
|
|
|
(void) ($<class>5);
|
|
|
|
|
}
|
2002-05-22 17:13:52 +00:00
|
|
|
|
| INTERFACE new_category_name
|
2009-12-21 05:53:00 +00:00
|
|
|
|
protocolrefs
|
|
|
|
|
{
|
|
|
|
|
category_add_protocols ($2, $3);
|
|
|
|
|
$<class>$ = $2->class;
|
|
|
|
|
}
|
2002-11-14 18:17:43 +00:00
|
|
|
|
methodprotolist { category_add_methods ($2, $5); }
|
2006-12-01 08:17:55 +00:00
|
|
|
|
END
|
|
|
|
|
{
|
|
|
|
|
current_class = 0;
|
|
|
|
|
(void) ($<class>4);
|
|
|
|
|
}
|
2002-11-14 18:17:43 +00:00
|
|
|
|
| IMPLEMENTATION class_name { class_begin (&$2->class_type); }
|
2009-12-21 05:53:00 +00:00
|
|
|
|
'{' { $<class>$ = $2; }
|
2006-12-01 08:17:55 +00:00
|
|
|
|
ivar_decl_list '}'
|
|
|
|
|
{
|
|
|
|
|
class_check_ivars ($2, $6);
|
|
|
|
|
(void) ($<class>5);
|
|
|
|
|
}
|
2002-11-14 18:17:43 +00:00
|
|
|
|
| IMPLEMENTATION class_name { class_begin (&$2->class_type); }
|
|
|
|
|
| IMPLEMENTATION class_with_super { class_begin (&$2->class_type); }
|
2009-12-21 05:53:00 +00:00
|
|
|
|
'{' { $<class>$ = $2; }
|
2006-12-01 08:17:55 +00:00
|
|
|
|
ivar_decl_list '}'
|
|
|
|
|
{
|
|
|
|
|
class_check_ivars ($2, $6);
|
|
|
|
|
(void) ($<class>5);
|
|
|
|
|
}
|
2002-11-14 18:17:43 +00:00
|
|
|
|
| IMPLEMENTATION class_with_super { class_begin (&$2->class_type); }
|
|
|
|
|
| IMPLEMENTATION category_name { class_begin (&$2->class_type); }
|
2010-12-12 11:27:56 +00:00
|
|
|
|
| REFERENCE class_reference ';' { }
|
|
|
|
|
| REFERENCE category_reference ';' { }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-10 00:00:23 +00:00
|
|
|
|
protocoldef
|
2011-03-24 02:55:17 +00:00
|
|
|
|
: PROTOCOL { $<class_type>$ = current_class; }
|
|
|
|
|
protocol_name
|
|
|
|
|
protocolrefs { protocol_add_protocols ($3, $4); $<class>$ = 0; }
|
|
|
|
|
methodprotolist { protocol_add_methods ($3, $6); }
|
|
|
|
|
END
|
|
|
|
|
{
|
|
|
|
|
current_class = $<class_type>2;
|
|
|
|
|
(void) ($<class>5);
|
|
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-10 00:00:23 +00:00
|
|
|
|
protocolrefs
|
|
|
|
|
: /* emtpy */ { $$ = 0; }
|
2009-12-21 05:53:00 +00:00
|
|
|
|
| LT { $<protocol_list>$ = new_protocol_list (); }
|
2006-12-01 08:17:55 +00:00
|
|
|
|
protocol_list GT { $$ = $3; (void) ($<protocol_list>2); }
|
2003-07-25 20:34:24 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
protocol_list
|
2004-11-02 07:02:00 +00:00
|
|
|
|
: identifier
|
2003-07-25 20:34:24 +00:00
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$$ = add_protocol ($<protocol_list>0, $1->name);
|
2003-07-25 20:34:24 +00:00
|
|
|
|
}
|
2004-11-02 07:02:00 +00:00
|
|
|
|
| protocol_list ',' identifier
|
2003-07-25 20:34:24 +00:00
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$$ = add_protocol ($1, $3->name);
|
2003-07-25 20:34:24 +00:00
|
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-10 00:00:23 +00:00
|
|
|
|
ivar_decl_list
|
2011-02-03 09:02:49 +00:00
|
|
|
|
: /* empty */
|
2002-05-17 06:20:27 +00:00
|
|
|
|
{
|
2011-02-03 09:02:49 +00:00
|
|
|
|
symtab_t *tab, *ivars;
|
|
|
|
|
ivars = class_new_ivars ($<class>0);
|
|
|
|
|
for (tab = ivars; tab->parent; tab = tab->parent)
|
|
|
|
|
;
|
2011-02-14 12:25:55 +00:00
|
|
|
|
if (tab == current_symtab)
|
|
|
|
|
internal_error (0, "ivars already linked to parent scope");
|
2011-02-03 09:02:49 +00:00
|
|
|
|
$<symtab>$ = tab;
|
|
|
|
|
tab->parent = current_symtab;
|
|
|
|
|
current_symtab = ivars;
|
|
|
|
|
|
2002-05-17 17:58:57 +00:00
|
|
|
|
current_visibility = vis_protected;
|
2002-05-17 06:20:27 +00:00
|
|
|
|
}
|
|
|
|
|
ivar_decl_list_2
|
2002-05-15 19:10:23 +00:00
|
|
|
|
{
|
2011-02-14 12:45:18 +00:00
|
|
|
|
symtab_t *tab = $<symtab>1;
|
2011-01-17 13:33:33 +00:00
|
|
|
|
$$ = current_symtab;
|
2011-02-14 12:45:18 +00:00
|
|
|
|
current_symtab = tab->parent;
|
|
|
|
|
tab->parent = 0;
|
2011-01-17 13:33:33 +00:00
|
|
|
|
|
2011-02-14 12:45:18 +00:00
|
|
|
|
tab = $$->parent; // preserve the ivars inheritance chain
|
2011-01-17 13:33:33 +00:00
|
|
|
|
build_struct ('s', 0, $$, 0);
|
2011-02-14 12:45:18 +00:00
|
|
|
|
$$->parent = tab;
|
2002-05-15 19:10:23 +00:00
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
ivar_decl_list_2
|
|
|
|
|
: ivar_decl_list_2 visibility_spec ivar_decls
|
2002-05-07 16:55:54 +00:00
|
|
|
|
| ivar_decls
|
|
|
|
|
;
|
|
|
|
|
|
2002-05-10 00:00:23 +00:00
|
|
|
|
visibility_spec
|
|
|
|
|
: PRIVATE { current_visibility = vis_private; }
|
|
|
|
|
| PROTECTED { current_visibility = vis_protected; }
|
|
|
|
|
| PUBLIC { current_visibility = vis_public; }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-10 00:00:23 +00:00
|
|
|
|
ivar_decls
|
2002-05-07 16:55:54 +00:00
|
|
|
|
: /* empty */
|
|
|
|
|
| ivar_decls ivar_decl ';'
|
|
|
|
|
;
|
|
|
|
|
|
2002-05-10 00:00:23 +00:00
|
|
|
|
ivar_decl
|
2011-02-07 11:49:20 +00:00
|
|
|
|
: type ivars
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-10 00:00:23 +00:00
|
|
|
|
ivars
|
2011-02-03 09:04:41 +00:00
|
|
|
|
: struct_decl
|
2011-06-21 10:52:47 +00:00
|
|
|
|
| ivars ',' { $<spec>$ = $<spec>0; } struct_decl { (void) ($<spec>3); }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 21:24:24 +00:00
|
|
|
|
methoddef
|
2011-02-04 12:19:52 +00:00
|
|
|
|
: ci methoddecl optional_state_expr
|
|
|
|
|
{
|
|
|
|
|
method_t *method = $2;
|
|
|
|
|
|
|
|
|
|
method->instance = $1;
|
|
|
|
|
$2 = method = class_find_method (current_class, method);
|
|
|
|
|
$<symbol>$ = method_symbol (current_class, method);
|
|
|
|
|
}
|
2011-03-07 11:51:51 +00:00
|
|
|
|
save_storage
|
2011-02-04 12:19:52 +00:00
|
|
|
|
{
|
|
|
|
|
method_t *method = $2;
|
|
|
|
|
const char *nicename = method_name (method);
|
|
|
|
|
symbol_t *sym = $<symbol>4;
|
2011-02-06 23:32:52 +00:00
|
|
|
|
symtab_t *ivar_scope;
|
|
|
|
|
|
2011-02-04 12:19:52 +00:00
|
|
|
|
$<symtab>$ = current_symtab;
|
2011-02-06 23:32:52 +00:00
|
|
|
|
|
|
|
|
|
ivar_scope = class_ivar_scope (current_class, current_symtab);
|
2011-02-15 03:38:29 +00:00
|
|
|
|
current_func = begin_function (sym, nicename, ivar_scope, 1);
|
2011-02-06 23:32:52 +00:00
|
|
|
|
class_finish_ivar_scope (current_class, ivar_scope,
|
|
|
|
|
current_func->symtab);
|
2011-02-15 13:27:13 +00:00
|
|
|
|
method->func = sym->s.func;
|
2011-02-04 12:19:52 +00:00
|
|
|
|
method->def = sym->s.func->def;
|
|
|
|
|
current_symtab = current_func->symtab;
|
2012-12-02 01:11:30 +00:00
|
|
|
|
current_storage = sc_local;
|
2011-02-04 12:19:52 +00:00
|
|
|
|
}
|
|
|
|
|
compound_statement
|
|
|
|
|
{
|
2011-03-07 11:51:51 +00:00
|
|
|
|
build_code_function ($<symbol>4, $3, $7);
|
|
|
|
|
current_symtab = $<symtab>6;
|
|
|
|
|
current_storage = $5.storage;
|
2011-02-14 14:08:51 +00:00
|
|
|
|
current_func = 0;
|
2011-02-04 12:19:52 +00:00
|
|
|
|
}
|
|
|
|
|
| ci methoddecl '=' '#' const ';'
|
2011-02-04 10:50:24 +00:00
|
|
|
|
{
|
|
|
|
|
symbol_t *sym;
|
|
|
|
|
method_t *method = $2;
|
|
|
|
|
|
|
|
|
|
method->instance = $1;
|
|
|
|
|
method = class_find_method (current_class, method);
|
|
|
|
|
sym = method_symbol (current_class, method);
|
2011-02-15 03:38:29 +00:00
|
|
|
|
build_builtin_function (sym, $5, 1);
|
2012-12-16 03:01:12 +00:00
|
|
|
|
method->func = sym->s.func;
|
2011-02-04 10:50:24 +00:00
|
|
|
|
method->def = sym->s.func->def;
|
|
|
|
|
}
|
2004-02-09 07:35:19 +00:00
|
|
|
|
;
|
2002-05-17 18:35:54 +00:00
|
|
|
|
|
2004-02-09 07:35:19 +00:00
|
|
|
|
ci
|
|
|
|
|
: '+' { $$ = 0; }
|
|
|
|
|
| '-' { $$ = 1; }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 21:24:24 +00:00
|
|
|
|
methodprotolist
|
2002-05-10 00:00:23 +00:00
|
|
|
|
: /* emtpy */ { $$ = 0; }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
| methodprotolist2
|
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 21:24:24 +00:00
|
|
|
|
methodprotolist2
|
2002-11-14 18:17:43 +00:00
|
|
|
|
: { } methodproto
|
2002-05-10 00:00:23 +00:00
|
|
|
|
{
|
|
|
|
|
$$ = new_methodlist ();
|
2002-11-14 18:17:43 +00:00
|
|
|
|
add_method ($$, $2);
|
2002-05-10 00:00:23 +00:00
|
|
|
|
}
|
|
|
|
|
| methodprotolist2 methodproto
|
|
|
|
|
{
|
|
|
|
|
add_method ($1, $2);
|
|
|
|
|
$$ = $1;
|
|
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 21:24:24 +00:00
|
|
|
|
methodproto
|
2002-05-07 16:55:54 +00:00
|
|
|
|
: '+' methoddecl ';'
|
2002-05-08 21:24:24 +00:00
|
|
|
|
{
|
|
|
|
|
$2->instance = 0;
|
|
|
|
|
$$ = $2;
|
|
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
|
| '-' methoddecl ';'
|
2002-05-08 21:24:24 +00:00
|
|
|
|
{
|
|
|
|
|
$2->instance = 1;
|
|
|
|
|
$$ = $2;
|
|
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 21:24:24 +00:00
|
|
|
|
methoddecl
|
2011-02-03 01:53:59 +00:00
|
|
|
|
: '(' abstract_decl ')' unaryselector
|
|
|
|
|
{ $$ = new_method ($2->type, $4, 0); }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
| unaryselector
|
2002-05-08 21:24:24 +00:00
|
|
|
|
{ $$ = new_method (&type_id, $1, 0); }
|
2011-02-03 01:53:59 +00:00
|
|
|
|
| '(' abstract_decl ')' keywordselector optional_param_list
|
|
|
|
|
{ $$ = new_method ($2->type, $4, $5); }
|
2011-02-01 12:23:03 +00:00
|
|
|
|
| keywordselector optional_param_list
|
2002-05-08 21:24:24 +00:00
|
|
|
|
{ $$ = new_method (&type_id, $1, $2); }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2011-02-01 12:23:03 +00:00
|
|
|
|
optional_param_list
|
2002-05-10 00:00:23 +00:00
|
|
|
|
: /* empty */ { $$ = 0; }
|
|
|
|
|
| ',' ELLIPSIS { $$ = new_param (0, 0, 0); }
|
|
|
|
|
| ',' param_list { $$ = $2; }
|
2002-05-08 23:12:49 +00:00
|
|
|
|
| ',' param_list ',' ELLIPSIS
|
|
|
|
|
{
|
|
|
|
|
$$ = new_param (0, 0, 0);
|
|
|
|
|
$$->next = $2;
|
|
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 21:24:24 +00:00
|
|
|
|
unaryselector
|
2011-01-17 13:33:33 +00:00
|
|
|
|
: selector { $$ = new_param ($1->name, 0, 0); }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
keywordselector
|
|
|
|
|
: keyworddecl
|
2002-05-08 05:55:57 +00:00
|
|
|
|
| keywordselector keyworddecl { $2->next = $1; $$ = $2; }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
selector
|
2011-01-17 13:33:33 +00:00
|
|
|
|
: NAME { $$ = $1; }
|
|
|
|
|
| CLASS_NAME { $$ = $1; }
|
2012-12-18 03:49:43 +00:00
|
|
|
|
| OBJECT { $$ = new_symbol (qc_yytext); }
|
2012-10-26 07:01:41 +00:00
|
|
|
|
| TYPE { $$ = new_symbol (qc_yytext); }
|
2011-01-17 13:33:33 +00:00
|
|
|
|
| TYPE_NAME { $$ = $1; }
|
2002-05-08 23:12:49 +00:00
|
|
|
|
| reserved_word
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
reserved_word
|
2012-10-26 07:01:41 +00:00
|
|
|
|
: LOCAL { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| RETURN { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| WHILE { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| DO { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| IF { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| ELSE { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| FOR { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| BREAK { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| CONTINUE { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| SWITCH { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| CASE { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| DEFAULT { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| NIL { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| STRUCT { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| ENUM { $$ = new_symbol (qc_yytext); }
|
|
|
|
|
| TYPEDEF { $$ = new_symbol (qc_yytext); }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
keyworddecl
|
2011-02-03 01:53:59 +00:00
|
|
|
|
: selector ':' '(' abstract_decl ')' identifier
|
|
|
|
|
{ $$ = new_param ($1->name, $4->type, $6->name); }
|
2004-11-02 07:02:00 +00:00
|
|
|
|
| selector ':' identifier
|
2011-01-17 13:33:33 +00:00
|
|
|
|
{ $$ = new_param ($1->name, &type_id, $3->name); }
|
2011-02-03 01:53:59 +00:00
|
|
|
|
| ':' '(' abstract_decl ')' identifier
|
|
|
|
|
{ $$ = new_param ("", $3->type, $5->name); }
|
2004-11-02 07:02:00 +00:00
|
|
|
|
| ':' identifier
|
2011-01-17 13:33:33 +00:00
|
|
|
|
{ $$ = new_param ("", &type_id, $2->name); }
|
2002-05-08 05:55:57 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 23:12:49 +00:00
|
|
|
|
obj_expr
|
|
|
|
|
: obj_messageexpr
|
|
|
|
|
| SELECTOR '(' selectorarg ')' { $$ = selector_expr ($3); }
|
2011-01-17 13:33:33 +00:00
|
|
|
|
| PROTOCOL '(' identifier ')' { $$ = protocol_expr ($3->name); }
|
2011-02-03 01:53:59 +00:00
|
|
|
|
| ENCODE '(' abstract_decl ')' { $$ = encode_expr ($3->type); }
|
2002-05-08 23:12:49 +00:00
|
|
|
|
| obj_string /* FIXME string object? */
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 23:12:49 +00:00
|
|
|
|
obj_messageexpr
|
|
|
|
|
: '[' receiver messageargs ']' { $$ = message_expr ($2, $3); }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 23:12:49 +00:00
|
|
|
|
receiver
|
2004-01-25 21:36:44 +00:00
|
|
|
|
: fexpr
|
2011-02-06 05:33:52 +00:00
|
|
|
|
| CLASS_NAME
|
|
|
|
|
{
|
2011-02-13 07:05:09 +00:00
|
|
|
|
$$ = new_symbol_expr ($1);
|
2011-02-06 05:33:52 +00:00
|
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 23:12:49 +00:00
|
|
|
|
messageargs
|
2011-01-17 13:33:33 +00:00
|
|
|
|
: selector { $$ = new_keywordarg ($1->name, 0); }
|
2002-05-08 23:12:49 +00:00
|
|
|
|
| keywordarglist
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 23:12:49 +00:00
|
|
|
|
keywordarglist
|
|
|
|
|
: keywordarg
|
|
|
|
|
| keywordarglist keywordarg
|
|
|
|
|
{
|
|
|
|
|
$2->next = $1;
|
|
|
|
|
$$ = $2;
|
|
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 23:12:49 +00:00
|
|
|
|
keywordarg
|
2011-01-17 13:33:33 +00:00
|
|
|
|
: selector ':' arg_list { $$ = new_keywordarg ($1->name, $3); }
|
2002-09-11 16:21:26 +00:00
|
|
|
|
| ':' arg_list { $$ = new_keywordarg ("", $2); }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 23:12:49 +00:00
|
|
|
|
selectorarg
|
2011-01-17 13:33:33 +00:00
|
|
|
|
: selector { $$ = new_keywordarg ($1->name, 0); }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
| keywordnamelist
|
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 23:12:49 +00:00
|
|
|
|
keywordnamelist
|
2002-05-07 16:55:54 +00:00
|
|
|
|
: keywordname
|
|
|
|
|
| keywordnamelist keywordname
|
2002-05-08 23:12:49 +00:00
|
|
|
|
{
|
|
|
|
|
$2->next = $1;
|
|
|
|
|
$$ = $2;
|
|
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 23:12:49 +00:00
|
|
|
|
keywordname
|
2011-01-17 13:33:33 +00:00
|
|
|
|
: selector ':' { $$ = new_keywordarg ($1->name, new_nil_expr ()); }
|
|
|
|
|
| ':' { $$ = new_keywordarg ("", new_nil_expr ()); }
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2002-05-08 23:12:49 +00:00
|
|
|
|
obj_string
|
2011-01-17 13:33:33 +00:00
|
|
|
|
: '@' STRING
|
2002-05-08 23:12:49 +00:00
|
|
|
|
{
|
2011-01-17 13:33:33 +00:00
|
|
|
|
//FIXME string object
|
|
|
|
|
$$ = $2;
|
2002-05-08 23:12:49 +00:00
|
|
|
|
}
|
2002-05-07 16:55:54 +00:00
|
|
|
|
;
|
|
|
|
|
|
2001-06-12 19:44:26 +00:00
|
|
|
|
%%
|