| 1 |
%{ |
| 2 |
|
| 3 |
/*---------------------------------------------------------------------------- |
| 4 |
ChucK Strongly-timed Audio Programming Language |
| 5 |
Compiler and Virtual Machine |
| 6 |
|
| 7 |
Copyright (c) 2003 Ge Wang and Perry R. Cook. All rights reserved. |
| 8 |
http://chuck.cs.princeton.edu/ |
| 9 |
http://soundlab.cs.princeton.edu/ |
| 10 |
|
| 11 |
This program is free software; you can redistribute it and/or modify |
| 12 |
it under the terms of the GNU General Public License as published by |
| 13 |
the Free Software Foundation; either version 2 of the License, or |
| 14 |
(at your option) any later version. |
| 15 |
|
| 16 |
This program is distributed in the hope that it will be useful, |
| 17 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
GNU General Public License for more details. |
| 20 |
|
| 21 |
You should have received a copy of the GNU General Public License |
| 22 |
along with this program; if not, write to the Free Software |
| 23 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 24 |
U.S.A. |
| 25 |
-----------------------------------------------------------------------------*/ |
| 26 |
|
| 27 |
//----------------------------------------------------------------------------- |
| 28 |
// file: chuck.tab.c |
| 29 |
// desc: chuck parser |
| 30 |
// |
| 31 |
// author: Ge Wang ([email protected]) - generated by yacc |
| 32 |
// Perry R. Cook ([email protected]) |
| 33 |
// |
| 34 |
// initial version created by Ge Wang; |
| 35 |
// based on ansi C grammar by Jeff Lee, maintained by Jutta Degener |
| 36 |
// |
| 37 |
// date: Summer 2002 |
| 38 |
//----------------------------------------------------------------------------- |
| 39 |
#include "chuck_absyn.h" |
| 40 |
#include "chuck_errmsg.h" |
| 41 |
|
| 42 |
#include <stdlib.h> |
| 43 |
#include <stdio.h> |
| 44 |
#include <string.h> |
| 45 |
|
| 46 |
// function |
| 47 |
int yylex( void ); |
| 48 |
|
| 49 |
void yyerror( char * s ) |
| 50 |
{ |
| 51 |
EM_error( EM_tokPos, "%s", s ); |
| 52 |
} |
| 53 |
|
| 54 |
a_Program g_program = NULL; |
| 55 |
|
| 56 |
%} |
| 57 |
|
| 58 |
//----------------------------------------------------------------------------- |
| 59 |
// enable location and the yylloc |
| 60 |
%locations |
| 61 |
|
| 62 |
// better position reporting |
| 63 |
// https://developer.ibm.com/tutorials/l-flexbison/ |
| 64 |
// example code |
| 65 |
// https://github.com/sunxfancy/flex-bison-examples/ |
| 66 |
// advanced uses of bison / make things less singleton-esque |
| 67 |
// https://www.lrde.epita.fr/~tiger/doc/gnuprog2/Advanced-Use-of-Bison.html |
| 68 |
//----------------------------------------------------------------------------- |
| 69 |
// uncomment line below for more informative error messages |
| 70 |
// %error-verbose |
| 71 |
// [test1.ck]:line(5).char(9): syntax error, unexpected ID, expecting COMMA or SEMICOLON |
| 72 |
// it @ is not ! valid => syntax! |
| 73 |
// ^ |
| 74 |
//----------------------------------------------------------------------------- |
| 75 |
|
| 76 |
%union |
| 77 |
{ |
| 78 |
int pos; |
| 79 |
int ival; |
| 80 |
double fval; |
| 81 |
c_str sval; |
| 82 |
|
| 83 |
a_Program program; |
| 84 |
a_Section program_section; |
| 85 |
a_Stmt_List stmt_list; |
| 86 |
a_Class_Def class_def; |
| 87 |
a_Class_Ext class_ext; |
| 88 |
a_Class_Body class_body; |
| 89 |
a_Stmt stmt; |
| 90 |
a_Exp exp; |
| 91 |
a_Func_Def func_def; |
| 92 |
a_Var_Decl_List var_decl_list; |
| 93 |
a_Var_Decl var_decl; |
| 94 |
a_Type_Decl type_decl; |
| 95 |
a_Arg_List arg_list; |
| 96 |
a_Id_List id_list; |
| 97 |
a_Array_Sub array_sub; |
| 98 |
a_Complex complex_exp; |
| 99 |
a_Polar polar_exp; |
| 100 |
a_Vec vec_exp; // ge: added 1.3.5.3 |
| 101 |
a_Import import; // 1.5.4.0 (ge) added |
| 102 |
a_Doc doc; // 1.5.4.4 (ge) added |
| 103 |
a_Example example; // 1.5.5.8 (ge,nick,alex) added |
| 104 |
}; |
| 105 |
|
| 106 |
// expect shift/reduce conflicts |
| 107 |
// 1.3.3.0: changed to 38 for char literal - spencer |
| 108 |
// 1.3.5.3: changed to 39 for vec literal |
| 109 |
// 1.3.6.0: changed to 40 for external keyword |
| 110 |
// 1.4.0.0: changed to 41 for global keyword |
| 111 |
// 1.4.0.1: changed to 79 for left recursion |
| 112 |
// 1.5.1.1: changed to 80 for trailing comma in array literals |
| 113 |
// 1.5.4.0: changed to 84 for @import statements |
| 114 |
// 1.5.4.4: changed to 86 for @doc statements |
| 115 |
// 1.5.5.8: changed to 88 for @example statements |
| 116 |
%expect 88 |
| 117 |
|
| 118 |
%token <sval> ID STRING_LIT CHAR_LIT |
| 119 |
%token <ival> INT_VAL |
| 120 |
%token <fval> FLOAT_VAL |
| 121 |
|
| 122 |
%token |
| 123 |
POUND COMMA COLON SEMICOLON LPAREN RPAREN |
| 124 |
LBRACK RBRACK LBRACE RBRACE DOT |
| 125 |
PLUS MINUS TIMES DIVIDE PERCENT |
| 126 |
EQ NEQ LT LE GT GE AND OR ASSIGN |
| 127 |
IF THEN ELSE WHILE FOR DO LOOP |
| 128 |
BREAK CONTINUE NULL_TOK FUNCTION RETURN |
| 129 |
QUESTION EXCLAMATION S_OR S_AND S_XOR |
| 130 |
PLUSPLUS MINUSMINUS DOLLAR POUNDPAREN PERCENTPAREN ATPAREN |
| 131 |
SIMULT PATTERN CODE TRANSPORT HOST |
| 132 |
TIME WHENEVER NEXT UNTIL EXTERNAL GLOBAL EVERY BEFORE |
| 133 |
AFTER AT AT_SYM ATAT_SYM NEW SIZEOF TYPEOF |
| 134 |
SAME PLUS_CHUCK MINUS_CHUCK TIMES_CHUCK |
| 135 |
DIVIDE_CHUCK S_AND_CHUCK S_OR_CHUCK |
| 136 |
S_XOR_CHUCK SHIFT_RIGHT_CHUCK |
| 137 |
SHIFT_LEFT_CHUCK PERCENT_CHUCK |
| 138 |
SHIFT_RIGHT SHIFT_LEFT TILDA CHUCK |
| 139 |
COLONCOLON S_CHUCK AT_CHUCK LEFT_S_CHUCK |
| 140 |
UNCHUCK UPCHUCK DOWNCHUCK CLASS INTERFACE EXTENDS IMPLEMENTS |
| 141 |
PUBLIC PROTECTED PRIVATE STATIC ABSTRACT CONST |
| 142 |
SPORK ARROW_RIGHT ARROW_LEFT L_HACK R_HACK |
| 143 |
GRUCK_RIGHT GRUCK_LEFT UNGRUCK_RIGHT UNGRUCK_LEFT |
| 144 |
AT_OP AT_CTOR AT_DTOR AT_IMPORT AT_DOC AT_EXAMPLE |
| 145 |
|
| 146 |
|
| 147 |
%type <program> program |
| 148 |
%type <program_section> program_section |
| 149 |
%type <stmt> code_segment |
| 150 |
%type <func_def> function_definition |
| 151 |
%type <class_def> class_definition |
| 152 |
%type <class_body> class_body |
| 153 |
%type <class_body> class_body2 |
| 154 |
%type <class_ext> class_ext |
| 155 |
%type <ival> class_decl |
| 156 |
%type <class_ext> iface_ext |
| 157 |
%type <program_section> class_section |
| 158 |
%type <stmt_list> statement_list |
| 159 |
%type <stmt> statement |
| 160 |
//%type <stmt_label> label_statement |
| 161 |
%type <stmt> loop_statement |
| 162 |
%type <stmt> selection_statement |
| 163 |
%type <stmt> jump_statement |
| 164 |
%type <stmt> expression_statement |
| 165 |
%type <stmt> import_statement |
| 166 |
%type <stmt> doc_statement |
| 167 |
%type <stmt> example_statement |
| 168 |
%type <exp> expression |
| 169 |
%type <exp> chuck_expression |
| 170 |
%type <exp> arrow_expression |
| 171 |
%type <exp> conditional_expression |
| 172 |
%type <exp> logical_or_expression |
| 173 |
%type <exp> logical_and_expression |
| 174 |
%type <exp> inclusive_or_expression |
| 175 |
%type <exp> exclusive_or_expression |
| 176 |
%type <exp> and_expression |
| 177 |
%type <exp> equality_expression |
| 178 |
%type <exp> relational_expression |
| 179 |
%type <exp> shift_expression |
| 180 |
%type <exp> additive_expression |
| 181 |
%type <exp> multiplicative_expression |
| 182 |
%type <exp> tilda_expression |
| 183 |
%type <exp> cast_expression |
| 184 |
%type <exp> unary_expression |
| 185 |
%type <exp> dur_expression |
| 186 |
%type <exp> postfix_expression |
| 187 |
%type <exp> primary_expression |
| 188 |
%type <exp> decl_expression |
| 189 |
%type <ival> overloadable_operator |
| 190 |
%type <ival> unary_operator |
| 191 |
%type <ival> chuck_operator |
| 192 |
%type <ival> arrow_operator |
| 193 |
%type <var_decl_list> var_decl_list |
| 194 |
%type <var_decl> var_decl |
| 195 |
%type <type_decl> type_decl_a |
| 196 |
%type <type_decl> type_decl_b |
| 197 |
%type <type_decl> type_decl |
| 198 |
%type <type_decl> type_decl2 |
| 199 |
%type <ival> function_decl |
| 200 |
%type <ival> static_decl |
| 201 |
%type <arg_list> arg_list |
| 202 |
%type <id_list> id_list |
| 203 |
%type <id_list> id_dot |
| 204 |
%type <array_sub> array_exp |
| 205 |
%type <array_sub> array_empty |
| 206 |
%type <complex_exp> complex_exp |
| 207 |
%type <polar_exp> polar_exp |
| 208 |
%type <vec_exp> vec_exp // ge: added 1.3.5.3 |
| 209 |
%type <import> import_target // 1.5.4.0 (ge) added |
| 210 |
%type <import> import_list // 1.5.4.0 (ge) added |
| 211 |
%type <doc> doc_target // 1.5.4.4 (ge) added |
| 212 |
%type <doc> doc_list // 1.5.4.4 (ge) added |
| 213 |
%type <example> example_target // 1.5.5.8 (ge,nick,alex) added |
| 214 |
%type <example> example_list // 1.5.5.8 (ge,nick,alex) added |
| 215 |
|
| 216 |
%start program |
| 217 |
|
| 218 |
%% |
| 219 |
|
| 220 |
program |
| 221 |
: program_section { $$ = g_program = new_program( $1, @1.first_line, @1.first_column ); } |
| 222 |
| program program_section { $$ = g_program = append_program( $1, $2, @1.first_line, @1.first_column ); } |
| 223 |
; |
| 224 |
|
| 225 |
program_section |
| 226 |
: statement_list { $$ = new_section_stmt( $1, @1.first_line, @1.first_column ); } |
| 227 |
| function_definition { $$ = new_section_func_def( $1, @1.first_line, @1.first_column ); } |
| 228 |
| class_definition { $$ = new_section_class_def( $1, @1.first_line, @1.first_column ); } |
| 229 |
; |
| 230 |
|
| 231 |
class_definition |
| 232 |
: class_decl CLASS id_list LBRACE class_body RBRACE |
| 233 |
{ $$ = new_class_def( $1, $3, NULL, $5, @1.first_line, @1.first_column ); } |
| 234 |
| class_decl CLASS id_list class_ext LBRACE class_body RBRACE |
| 235 |
{ $$ = new_class_def( $1, $3, $4, $6, @1.first_line, @1.first_column ); } |
| 236 |
| class_decl INTERFACE id_list LBRACE class_body RBRACE |
| 237 |
{ $$ = new_iface_def( $1, $3, NULL, $5, @1.first_line, @1.first_column ); } |
| 238 |
| class_decl INTERFACE id_list iface_ext LBRACE class_body RBRACE |
| 239 |
{ $$ = new_iface_def( $1, $3, $4, $6, @1.first_line, @1.first_column ); } |
| 240 |
; |
| 241 |
|
| 242 |
class_ext |
| 243 |
: IMPLEMENTS id_list { $$ = new_class_ext( NULL, $2, @1.first_line, @1.first_column ); } |
| 244 |
| IMPLEMENTS id_list EXTENDS id_dot { $$ = new_class_ext( $4, $2, @1.first_line, @1.first_column ); } |
| 245 |
| EXTENDS id_dot { $$ = new_class_ext( $2, NULL, @1.first_line, @1.first_column ); } |
| 246 |
| EXTENDS id_dot IMPLEMENTS id_list { $$ = new_class_ext( $2, $4, @1.first_line, @1.first_column ); } |
| 247 |
; |
| 248 |
|
| 249 |
class_body |
| 250 |
: class_body2 { $$ = $1; } |
| 251 |
| { $$ = NULL; } |
| 252 |
; |
| 253 |
|
| 254 |
class_body2 |
| 255 |
: class_section { $$ = new_class_body( $1, @1.first_line, @1.first_column ); } |
| 256 |
| class_section class_body2 { $$ = prepend_class_body( $1, $2, @1.first_line, @1.first_column ); } |
| 257 |
; |
| 258 |
|
| 259 |
|
| 260 |
class_section |
| 261 |
: statement_list { $$ = new_section_stmt( $1, @1.first_line, @1.first_column ); } |
| 262 |
| function_definition { $$ = new_section_func_def( $1, @1.first_line, @1.first_column ); } |
| 263 |
| class_definition { $$ = new_section_class_def( $1, @1.first_line, @1.first_column ); } |
| 264 |
; |
| 265 |
|
| 266 |
iface_ext |
| 267 |
: EXTENDS id_list { $$ = new_class_ext( NULL, $2, @1.first_line, @1.first_column ); } |
| 268 |
; |
| 269 |
|
| 270 |
id_list |
| 271 |
: ID { $$ = new_id_list( $1, @1.first_line, @1.first_column /*, &@1 */ ); } |
| 272 |
| ID COMMA id_list { $$ = prepend_id_list( $1, $3, @1.first_line, @1.first_column /*, &@1 */ ); } |
| 273 |
; |
| 274 |
|
| 275 |
id_dot |
| 276 |
: ID { $$ = new_id_list( $1, @1.first_line, @1.first_column /*, &@1*/ ); } |
| 277 |
| ID DOT id_dot { $$ = prepend_id_list( $1, $3, @1.first_line, @1.first_column /*, &@1*/ ); } |
| 278 |
; |
| 279 |
|
| 280 |
function_definition |
| 281 |
: function_decl static_decl type_decl2 ID LPAREN arg_list RPAREN code_segment |
| 282 |
{ $$ = new_func_def( $1, $2, $3, $4, $6, $8, TRUE, @1.first_line, @1.first_column ); } |
| 283 |
| function_decl static_decl type_decl2 ID LPAREN RPAREN code_segment |
| 284 |
{ $$ = new_func_def( $1, $2, $3, $4, NULL, $7, TRUE, @1.first_line, @1.first_column ); } |
| 285 |
| function_decl static_decl ID LPAREN arg_list RPAREN code_segment |
| 286 |
{ $$ = new_func_def( $1, $2, NULL, $3, $5, $7, TRUE, @1.first_line, @1.first_column ); } |
| 287 |
| function_decl static_decl ID LPAREN RPAREN code_segment |
| 288 |
{ $$ = new_func_def( $1, $2, NULL, $3, NULL, $6, TRUE, @1.first_line, @1.first_column ); } |
| 289 |
| function_decl AT_CTOR LPAREN arg_list RPAREN code_segment // 1.5.2.0 (ge) added for constructors |
| 290 |
{ $$ = new_func_def( $1, ae_key_instance, NULL, "@construct", $4, $6, TRUE, @1.first_line, @1.first_column ); } |
| 291 |
| function_decl AT_CTOR LPAREN RPAREN code_segment // 1.5.2.0 (ge) added for constructors |
| 292 |
{ $$ = new_func_def( $1, ae_key_instance, NULL, "@construct", NULL, $5, TRUE, @1.first_line, @1.first_column ); } |
| 293 |
| function_decl AT_DTOR LPAREN RPAREN code_segment // 1.5.2.0 (ge) added for destructor |
| 294 |
{ $$ = new_func_def( $1, ae_key_instance, NULL, "@destruct", NULL, $5, TRUE, @1.first_line, @1.first_column ); } |
| 295 |
| function_decl AT_DTOR LPAREN arg_list RPAREN code_segment // 1.5.2.0 (ge) added for constructors |
| 296 |
{ $$ = new_func_def( $1, ae_key_instance, NULL, "@destruct", $4, $6, TRUE, @1.first_line, @1.first_column ); } |
| 297 |
| function_decl static_decl type_decl2 ID LPAREN arg_list RPAREN SEMICOLON |
| 298 |
{ $$ = new_func_def( $1, $2, $3, $4, $6, NULL, TRUE, @1.first_line, @1.first_column ); } |
| 299 |
| function_decl static_decl type_decl2 ID LPAREN RPAREN SEMICOLON |
| 300 |
{ $$ = new_func_def( $1, $2, $3, $4, NULL, NULL, TRUE, @1.first_line, @1.first_column ); } |
| 301 |
| function_decl static_decl type_decl2 AT_OP overloadable_operator LPAREN arg_list RPAREN code_segment |
| 302 |
{ $$ = new_op_overload( $1, $2, $3, $5, $7, $9, TRUE, FALSE, @1.first_line, @1.first_column, @5.first_column ); } |
| 303 |
| function_decl static_decl type_decl2 AT_OP LPAREN arg_list RPAREN overloadable_operator code_segment |
| 304 |
{ $$ = new_op_overload( $1, $2, $3, $8, $6, $9, TRUE, TRUE, @1.first_line, @1.first_column, @8.first_column ); } |
| 305 |
| function_decl static_decl type_decl2 AT_OP LPAREN overloadable_operator RPAREN LPAREN arg_list RPAREN code_segment |
| 306 |
{ $$ = new_op_overload( $1, $2, $3, $6, $9, $11, TRUE, FALSE, @1.first_line, @1.first_column, @5.first_column ); } |
| 307 |
| function_decl static_decl type_decl2 AT_OP LPAREN arg_list RPAREN LPAREN overloadable_operator RPAREN code_segment |
| 308 |
{ $$ = new_op_overload( $1, $2, $3, $9, $6, $11, TRUE, TRUE, @1.first_line, @1.first_column, @8.first_column ); } |
| 309 |
; |
| 310 |
|
| 311 |
class_decl |
| 312 |
: PUBLIC { $$ = ae_key_public; } |
| 313 |
| PRIVATE { $$ = ae_key_private; } |
| 314 |
| { $$ = ae_key_private; } |
| 315 |
; |
| 316 |
|
| 317 |
function_decl |
| 318 |
: FUNCTION { $$ = ae_key_func; } |
| 319 |
| PUBLIC { $$ = ae_key_public; } |
| 320 |
| PROTECTED { $$ = ae_key_protected; } |
| 321 |
| PRIVATE { $$ = ae_key_private; } |
| 322 |
; |
| 323 |
|
| 324 |
static_decl |
| 325 |
: STATIC { $$ = ae_key_static; } |
| 326 |
| ABSTRACT { $$ = ae_key_abstract; } |
| 327 |
| { $$ = ae_key_instance; } |
| 328 |
; |
| 329 |
|
| 330 |
type_decl_a |
| 331 |
: ID { $$ = new_type_decl( new_id_list( $1, @1.first_line, @1.first_column /*, &@1*/ ), 0, @1.first_line, @1.first_column ); } |
| 332 |
| ID AT_SYM { $$ = new_type_decl( new_id_list( $1, @1.first_line, @1.first_column /*, &@1*/ ), 1, @1.first_line, @1.first_column ); } |
| 333 |
; |
| 334 |
|
| 335 |
type_decl_b |
| 336 |
: LT id_dot GT { $$ = new_type_decl( $2, 0, @1.first_line, @1.first_column ); } |
| 337 |
| LT id_dot GT AT_SYM { $$ = new_type_decl( $2, 1, @1.first_line, @1.first_column ); } |
| 338 |
; |
| 339 |
|
| 340 |
//type_decl_c |
| 341 |
// : LPAREN id_dot RPAREN { $$ = new_type_decl( $3, 0, @1.first_line, @1.first_column ); } |
| 342 |
// // | LPAREN id_dot RPAREN AT_SYM { $$ = new_type_decl( $1, 1, @1.first_line, @1.first_column ); } |
| 343 |
// ; |
| 344 |
|
| 345 |
type_decl |
| 346 |
: type_decl_a { $$ = $1; } |
| 347 |
| type_decl_b { $$ = $1; } |
| 348 |
// | type_decl_c { $$ = $1; } |
| 349 |
; |
| 350 |
|
| 351 |
type_decl2 |
| 352 |
: type_decl { $$ = $1; } |
| 353 |
| type_decl array_empty { $$ = add_type_decl_array( $1, $2, @1.first_line, @1.first_column ); } |
| 354 |
; |
| 355 |
|
| 356 |
arg_list |
| 357 |
: type_decl var_decl { $$ = new_arg_list( $1, $2, @1.first_line, @1.first_column ); } |
| 358 |
| type_decl var_decl COMMA arg_list { $$ = prepend_arg_list( $1, $2, $4, @1.first_line, @1.first_column ); } |
| 359 |
; |
| 360 |
|
| 361 |
statement_list |
| 362 |
: statement { $$ = new_stmt_list( $1, @1.first_line, @1.first_column ); } |
| 363 |
| statement_list statement { $$ = append_stmt_list( $1, $2, @1.first_line, @1.first_column ); } |
| 364 |
; |
| 365 |
|
| 366 |
statement |
| 367 |
: expression_statement { $$ = $1; } |
| 368 |
| loop_statement { $$ = $1; } |
| 369 |
| selection_statement { $$ = $1; } |
| 370 |
| jump_statement { $$ = $1; } |
| 371 |
// | label_statement { } |
| 372 |
| code_segment { $$ = $1; } |
| 373 |
| import_statement { $$ = $1; } |
| 374 |
| doc_statement { $$ = $1; } |
| 375 |
| example_statement { $$ = $1; } |
| 376 |
; |
| 377 |
|
| 378 |
jump_statement |
| 379 |
: RETURN SEMICOLON { $$ = new_stmt_from_return( NULL, @1.first_line, @1.first_column ); } |
| 380 |
| RETURN expression SEMICOLON { $$ = new_stmt_from_return( $2, @1.first_line, @1.first_column ); } |
| 381 |
| BREAK SEMICOLON { $$ = new_stmt_from_break( @1.first_line, @1.first_column ); } |
| 382 |
| CONTINUE SEMICOLON { $$ = new_stmt_from_continue( @1.first_line, @1.first_column ); } |
| 383 |
; |
| 384 |
|
| 385 |
selection_statement |
| 386 |
: IF LPAREN expression RPAREN statement |
| 387 |
{ $$ = new_stmt_from_if( $3, $5, NULL, @1.first_line, @1.first_column ); } |
| 388 |
| IF LPAREN expression RPAREN statement ELSE statement |
| 389 |
{ $$ = new_stmt_from_if( $3, $5, $7, @1.first_line, @1.first_column ); } |
| 390 |
; |
| 391 |
|
| 392 |
loop_statement |
| 393 |
: WHILE LPAREN expression RPAREN statement |
| 394 |
{ $$ = new_stmt_from_while( $3, $5, @1.first_line, @1.first_column ); } |
| 395 |
| DO statement WHILE LPAREN expression RPAREN SEMICOLON |
| 396 |
{ $$ = new_stmt_from_do_while( $5, $2, @1.first_line, @1.first_column ); } |
| 397 |
| FOR LPAREN expression_statement expression_statement RPAREN statement |
| 398 |
{ $$ = new_stmt_from_for( $3, $4, NULL, $6, @1.first_line, @1.first_column ); } |
| 399 |
| FOR LPAREN expression_statement expression_statement expression RPAREN statement |
| 400 |
{ $$ = new_stmt_from_for( $3, $4, $5, $7, @1.first_line, @1.first_column ); } |
| 401 |
| FOR LPAREN expression COLON expression RPAREN statement |
| 402 |
{ $$ = new_stmt_from_foreach( $3, $5, $7, @1.first_line, @1.first_column ); } |
| 403 |
| UNTIL LPAREN expression RPAREN statement |
| 404 |
{ $$ = new_stmt_from_until( $3, $5, @1.first_line, @1.first_column ); } |
| 405 |
| DO statement UNTIL LPAREN expression RPAREN SEMICOLON |
| 406 |
{ $$ = new_stmt_from_do_until( $5, $2, @1.first_line, @1.first_column ); } |
| 407 |
| LOOP LPAREN expression RPAREN statement |
| 408 |
{ $$ = new_stmt_from_loop( $3, $5, @1.first_line, @1.first_column ); } |
| 409 |
; |
| 410 |
|
| 411 |
code_segment |
| 412 |
: LBRACE RBRACE { $$ = new_stmt_from_code( NULL, @1.first_line, @1.first_column ); } |
| 413 |
| LBRACE statement_list RBRACE { $$ = new_stmt_from_code( $2, @1.first_line, @1.first_column ); } |
| 414 |
; |
| 415 |
|
| 416 |
import_statement |
| 417 |
: AT_IMPORT import_target { $$ = new_stmt_from_import( $2, @1.first_line, @1.first_column ); } |
| 418 |
| AT_IMPORT LBRACK RBRACK { $$ = new_stmt_from_import( NULL, @1.first_line, @1.first_column ); } |
| 419 |
| AT_IMPORT LBRACE RBRACE { $$ = new_stmt_from_import( NULL, @1.first_line, @1.first_column ); } |
| 420 |
| AT_IMPORT LBRACK import_list LBRACK { $$ = new_stmt_from_import( $3, @1.first_line, @1.first_column ); } |
| 421 |
| AT_IMPORT LBRACE import_list RBRACE { $$ = new_stmt_from_import( $3, @1.first_line, @1.first_column ); } |
| 422 |
; |
| 423 |
|
| 424 |
import_list |
| 425 |
: import_target { $$ = $1; } |
| 426 |
| import_target COMMA import_list { $$ = prepend_import( $1, $3, @1.first_line, @1.first_column ); } |
| 427 |
; |
| 428 |
|
| 429 |
import_target |
| 430 |
: STRING_LIT { $$ = new_import( $1, NULL, @1.first_line, @1.first_column ); } |
| 431 |
// | id_dot { $$ = new_import( NULL, $1, @1.first_line, @1.first_column ); } |
| 432 |
; |
| 433 |
|
| 434 |
doc_statement |
| 435 |
: AT_DOC doc_target { $$ = new_stmt_from_doc( $2, @1.first_line, @1.first_column ); } |
| 436 |
| AT_DOC LBRACK doc_list RBRACK { $$ = new_stmt_from_doc( $3, @1.first_line, @1.first_column ); } |
| 437 |
| AT_DOC LBRACE doc_list RBRACE { $$ = new_stmt_from_doc( $3, @1.first_line, @1.first_column ); } |
| 438 |
; |
| 439 |
|
| 440 |
doc_list |
| 441 |
: doc_target { $$ = $1; } |
| 442 |
| doc_target COMMA doc_list { $$ = prepend_doc( $1, $3, @1.first_line, @1.first_column ); } |
| 443 |
; |
| 444 |
|
| 445 |
doc_target |
| 446 |
: STRING_LIT { $$ = new_doc( $1, @1.first_line, @1.first_column ); } |
| 447 |
; |
| 448 |
|
| 449 |
example_statement |
| 450 |
: AT_EXAMPLE example_target { $$ = new_stmt_from_example( $2, @1.first_line, @1.first_column ); } |
| 451 |
| AT_EXAMPLE LBRACK example_list RBRACK { $$ = new_stmt_from_example( $3, @1.first_line, @1.first_column ); } |
| 452 |
| AT_EXAMPLE LBRACE example_list RBRACE { $$ = new_stmt_from_example( $3, @1.first_line, @1.first_column ); } |
| 453 |
; |
| 454 |
|
| 455 |
example_list |
| 456 |
: example_target { $$ = $1; } |
| 457 |
| example_target COMMA example_list { $$ = prepend_example( $1, $3, @1.first_line, @1.first_column ); } |
| 458 |
; |
| 459 |
|
| 460 |
example_target |
| 461 |
: STRING_LIT { $$ = new_example( $1, @1.first_line, @1.first_column ); } |
| 462 |
; |
| 463 |
|
| 464 |
expression_statement |
| 465 |
: SEMICOLON { $$ = NULL; } |
| 466 |
| expression SEMICOLON { $$ = new_stmt_from_expression( $1, @1.first_line, @1.first_column ); } |
| 467 |
; |
| 468 |
|
| 469 |
expression |
| 470 |
: chuck_expression { $$ = $1; } |
| 471 |
| expression COMMA chuck_expression { $$ = append_expression( $1, $3, @1.first_line, @1.first_column ); } |
| 472 |
; |
| 473 |
|
| 474 |
chuck_expression |
| 475 |
: arrow_expression { $$ = $1; } |
| 476 |
| chuck_expression chuck_operator arrow_expression |
| 477 |
{ $$ = new_exp_from_binary( $1, $2, $3, @2.first_line, @2.first_column ); } |
| 478 |
; |
| 479 |
|
| 480 |
arrow_expression |
| 481 |
: decl_expression { $$ = $1; } |
| 482 |
| arrow_expression arrow_operator decl_expression |
| 483 |
{ $$ = new_exp_from_binary( $1, $2, $3, @2.first_line, @2.first_column ); } |
| 484 |
; |
| 485 |
|
| 486 |
array_exp |
| 487 |
: LBRACK expression RBRACK { $$ = new_array_sub( $2, @1.first_line, @1.first_column ); } |
| 488 |
| LBRACK expression COMMA RBRACK { $$ = new_array_sub( $2, @1.first_line, @1.first_column ); } |
| 489 |
| LBRACK expression RBRACK array_exp |
| 490 |
{ $$ = prepend_array_sub( $4, $2, @1.first_line, @1.first_column ); } |
| 491 |
| LBRACK expression COMMA RBRACK array_exp |
| 492 |
{ $$ = prepend_array_sub( $5, $2, @1.first_line, @1.first_column ); } |
| 493 |
; |
| 494 |
|
| 495 |
array_empty |
| 496 |
: LBRACK RBRACK { $$ = new_array_sub( NULL, @1.first_line, @1.first_column ); } |
| 497 |
| array_empty LBRACK RBRACK { $$ = prepend_array_sub( $1, NULL, @1.first_line, @1.first_column ); } |
| 498 |
; |
| 499 |
|
| 500 |
decl_expression |
| 501 |
: conditional_expression { $$ = $1; } |
| 502 |
| type_decl var_decl_list { $$ = new_exp_decl( $1, $2, 0, 0, @1.first_line, @1.first_column ); } |
| 503 |
| EXTERNAL type_decl var_decl_list { $$ = new_exp_decl_external( $2, $3, 0, 0, @1.first_line, @1.first_column ); } |
| 504 |
| GLOBAL type_decl var_decl_list { $$ = new_exp_decl_global( $2, $3, 0, 0, @1.first_line, @1.first_column ); } |
| 505 |
| STATIC type_decl var_decl_list { $$ = new_exp_decl( $2, $3, 1, 0, @1.first_line, @1.first_column ); } |
| 506 |
| SAME var_decl_list { $$ = new_exp_decl( NULL, $2, 0, 0, @1.first_line, @1.first_column ); } |
| 507 |
| STATIC SAME var_decl_list { $$ = new_exp_decl( NULL, $3, 1, 0, @1.first_line, @1.first_column ); } |
| 508 |
; |
| 509 |
|
| 510 |
var_decl_list |
| 511 |
: var_decl { $$ = new_var_decl_list( $1, @1.first_line, @1.first_column ); } |
| 512 |
| var_decl COMMA var_decl_list { $$ = prepend_var_decl_list( $1, $3, @1.first_line, @1.first_column ); } |
| 513 |
; |
| 514 |
|
| 515 |
var_decl |
| 516 |
: ID { $$ = new_var_decl( $1, FALSE, NULL, NULL, @1.first_line, @1.first_column ); } |
| 517 |
| ID array_exp { $$ = new_var_decl( $1, FALSE, NULL, $2, @1.first_line, @1.first_column ); } |
| 518 |
| ID array_empty { $$ = new_var_decl( $1, FALSE, NULL, $2, @1.first_line, @1.first_column ); } |
| 519 |
| ID LPAREN RPAREN { $$ = new_var_decl( $1, TRUE, NULL, NULL, @1.first_line, @1.first_column ); } // 1.5.2.0 (ge) added for constructors |
| 520 |
| ID LPAREN expression RPAREN { $$ = new_var_decl( $1, TRUE, $3, NULL, @1.first_line, @1.first_column ); } // 1.5.2.0 (ge) added for constructors |
| 521 |
| ID LPAREN RPAREN array_exp { $$ = new_var_decl( $1, TRUE, NULL, $4, @1.first_line, @1.first_column ); } // 1.5.2.0 (ge) added for constructors |
| 522 |
| ID LPAREN expression RPAREN array_exp { $$ = new_var_decl( $1, TRUE, $3, $5, @1.first_line, @1.first_column ); } // 1.5.2.0 (ge) added for constructors |
| 523 |
; |
| 524 |
|
| 525 |
complex_exp |
| 526 |
: POUNDPAREN expression RPAREN |
| 527 |
{ $$ = new_complex( $2, @1.first_line, @1.first_column ); } |
| 528 |
; |
| 529 |
|
| 530 |
polar_exp |
| 531 |
: PERCENTPAREN expression RPAREN |
| 532 |
{ $$ = new_polar( $2, @1.first_line, @1.first_column ); } |
| 533 |
; |
| 534 |
|
| 535 |
vec_exp // ge: added 1.3.5.3 |
| 536 |
: ATPAREN expression RPAREN |
| 537 |
{ $$ = new_vec( $2, @1.first_line, @1.first_column ); } |
| 538 |
; |
| 539 |
|
| 540 |
chuck_operator |
| 541 |
: CHUCK { $$ = ae_op_chuck; } |
| 542 |
| AT_CHUCK { $$ = ae_op_at_chuck; } |
| 543 |
| PLUS_CHUCK { $$ = ae_op_plus_chuck; } |
| 544 |
| MINUS_CHUCK { $$ = ae_op_minus_chuck; } |
| 545 |
| TIMES_CHUCK { $$ = ae_op_times_chuck; } |
| 546 |
| DIVIDE_CHUCK { $$ = ae_op_divide_chuck; } |
| 547 |
| SHIFT_RIGHT_CHUCK { $$ = ae_op_shift_right_chuck; } |
| 548 |
| SHIFT_LEFT_CHUCK { $$ = ae_op_shift_left_chuck; } |
| 549 |
| PERCENT_CHUCK { $$ = ae_op_percent_chuck; } |
| 550 |
| UNCHUCK { $$ = ae_op_unchuck; } |
| 551 |
| UPCHUCK { $$ = ae_op_upchuck; } |
| 552 |
| DOWNCHUCK { $$ = ae_op_downchuck; } |
| 553 |
| S_AND_CHUCK { $$ = ae_op_s_and_chuck; } |
| 554 |
| S_OR_CHUCK { $$ = ae_op_s_or_chuck; } |
| 555 |
| S_XOR_CHUCK { $$ = ae_op_s_xor_chuck; } |
| 556 |
; |
| 557 |
|
| 558 |
arrow_operator |
| 559 |
: ARROW_LEFT { $$ = ae_op_arrow_left; } |
| 560 |
| ARROW_RIGHT { $$ = ae_op_arrow_right; } |
| 561 |
| GRUCK_LEFT { $$ = ae_op_gruck_left; } |
| 562 |
| GRUCK_RIGHT { $$ = ae_op_gruck_right; } |
| 563 |
| UNGRUCK_LEFT { $$ = ae_op_ungruck_left; } |
| 564 |
| UNGRUCK_RIGHT { $$ = ae_op_ungruck_right; } |
| 565 |
; |
| 566 |
|
| 567 |
conditional_expression |
| 568 |
: logical_or_expression { $$ = $1; } |
| 569 |
| logical_or_expression QUESTION expression COLON conditional_expression |
| 570 |
{ $$ = new_exp_from_if( $1, $3, $5, @1.first_line, @1.first_column ); } |
| 571 |
; |
| 572 |
|
| 573 |
logical_or_expression |
| 574 |
: logical_and_expression { $$ = $1; } |
| 575 |
| logical_or_expression OR logical_and_expression |
| 576 |
{ $$ = new_exp_from_binary( $1, ae_op_or, $3, @2.first_line, @2.first_column ); } |
| 577 |
; |
| 578 |
|
| 579 |
logical_and_expression |
| 580 |
: inclusive_or_expression { $$ = $1; } |
| 581 |
| logical_and_expression AND inclusive_or_expression |
| 582 |
{ $$ = new_exp_from_binary( $1, ae_op_and, $3, @2.first_line, @2.first_column ); } |
| 583 |
; |
| 584 |
|
| 585 |
inclusive_or_expression |
| 586 |
: exclusive_or_expression { $$ = $1; } |
| 587 |
| inclusive_or_expression S_OR exclusive_or_expression |
| 588 |
{ $$ = new_exp_from_binary( $1, ae_op_s_or, $3, @2.first_line, @2.first_column ); } |
| 589 |
; |
| 590 |
|
| 591 |
exclusive_or_expression |
| 592 |
: and_expression { $$ = $1; } |
| 593 |
| exclusive_or_expression S_XOR and_expression |
| 594 |
{ $$ = new_exp_from_binary( $1, ae_op_s_xor, $3, @2.first_line, @2.first_column ); } |
| 595 |
; |
| 596 |
|
| 597 |
and_expression |
| 598 |
: equality_expression { $$ = $1; } |
| 599 |
| and_expression S_AND equality_expression |
| 600 |
{ $$ = new_exp_from_binary( $1, ae_op_s_and, $3, @2.first_line, @2.first_column ); } |
| 601 |
; |
| 602 |
|
| 603 |
equality_expression |
| 604 |
: relational_expression { $$ = $1; } |
| 605 |
| equality_expression EQ relational_expression |
| 606 |
{ $$ = new_exp_from_binary( $1, ae_op_eq, $3, @1.first_line, @1.first_column ); } |
| 607 |
| equality_expression NEQ relational_expression |
| 608 |
{ $$ = new_exp_from_binary( $1, ae_op_neq, $3, @2.first_line, @2.first_column ); } |
| 609 |
; |
| 610 |
|
| 611 |
relational_expression |
| 612 |
: shift_expression { $$ = $1; } |
| 613 |
| relational_expression LT shift_expression |
| 614 |
{ $$ = new_exp_from_binary( $1, ae_op_lt, $3, @2.first_line, @2.first_column ); } |
| 615 |
| relational_expression GT shift_expression |
| 616 |
{ $$ = new_exp_from_binary( $1, ae_op_gt, $3, @2.first_line, @2.first_column ); } |
| 617 |
| relational_expression LE shift_expression |
| 618 |
{ $$ = new_exp_from_binary( $1, ae_op_le, $3, @2.first_line, @2.first_column ); } |
| 619 |
| relational_expression GE shift_expression |
| 620 |
{ $$ = new_exp_from_binary( $1, ae_op_ge, $3, @2.first_line, @2.first_column ); } |
| 621 |
; |
| 622 |
|
| 623 |
shift_expression |
| 624 |
: additive_expression { $$ = $1; } |
| 625 |
| shift_expression SHIFT_LEFT additive_expression |
| 626 |
{ $$ = new_exp_from_binary( $1, ae_op_shift_left, $3, @2.first_line, @2.first_column ); } |
| 627 |
| shift_expression SHIFT_RIGHT additive_expression |
| 628 |
{ $$ = new_exp_from_binary( $1, ae_op_shift_right, $3, @2.first_line, @2.first_column ); } |
| 629 |
; |
| 630 |
|
| 631 |
additive_expression |
| 632 |
: multiplicative_expression { $$ = $1; } |
| 633 |
| additive_expression PLUS multiplicative_expression |
| 634 |
{ $$ = new_exp_from_binary( $1, ae_op_plus, $3, @2.first_line, @2.first_column ); } |
| 635 |
| additive_expression MINUS multiplicative_expression |
| 636 |
{ $$ = new_exp_from_binary( $1, ae_op_minus, $3, @2.first_line, @2.first_column ); } |
| 637 |
; |
| 638 |
|
| 639 |
multiplicative_expression |
| 640 |
: tilda_expression { $$ = $1; } |
| 641 |
| multiplicative_expression TIMES tilda_expression |
| 642 |
{ $$ = new_exp_from_binary( $1, ae_op_times, $3, @2.first_line, @2.first_column ); } |
| 643 |
| multiplicative_expression DIVIDE tilda_expression |
| 644 |
{ $$ = new_exp_from_binary( $1, ae_op_divide, $3, @2.first_line, @2.first_column ); } |
| 645 |
| multiplicative_expression PERCENT tilda_expression |
| 646 |
{ $$ = new_exp_from_binary( $1, ae_op_percent, $3, @2.first_line, @2.first_column ); } |
| 647 |
; |
| 648 |
|
| 649 |
tilda_expression |
| 650 |
: cast_expression { $$ = $1; } |
| 651 |
| tilda_expression TILDA cast_expression |
| 652 |
{ $$ = new_exp_from_binary( $1, ae_op_tilda, $3, @2.first_line, @2.first_column ); } |
| 653 |
; |
| 654 |
|
| 655 |
cast_expression |
| 656 |
: unary_expression { $$ = $1; } |
| 657 |
| cast_expression DOLLAR type_decl |
| 658 |
{ $$ = new_exp_from_cast( $3, $1, @1.first_line, @1.first_column, @2.first_column ); } |
| 659 |
; |
| 660 |
|
| 661 |
unary_expression |
| 662 |
: dur_expression { $$ = $1; } |
| 663 |
| PLUSPLUS unary_expression |
| 664 |
{ $$ = new_exp_from_unary( ae_op_plusplus, $2, @1.first_line, @1.first_column ); } |
| 665 |
| MINUSMINUS unary_expression |
| 666 |
{ $$ = new_exp_from_unary( ae_op_minusminus, $2, @1.first_line, @1.first_column ); } |
| 667 |
| unary_operator unary_expression |
| 668 |
{ $$ = new_exp_from_unary( $1, $2, @1.first_line, @1.first_column ); } |
| 669 |
| TYPEOF unary_expression |
| 670 |
{ $$ = new_exp_from_unary( ae_op_typeof, $2, @1.first_line, @1.first_column ); } |
| 671 |
| SIZEOF unary_expression |
| 672 |
{ $$ = new_exp_from_unary( ae_op_sizeof, $2, @1.first_line, @1.first_column ); } |
| 673 |
| NEW type_decl // e.g., new Foo; |
| 674 |
{ $$ = new_exp_from_unary2( ae_op_new, $2, FALSE, NULL, NULL, @1.first_line, @1.first_column ); } |
| 675 |
| NEW type_decl array_exp // e.g., new Foo[10]; |
| 676 |
{ $$ = new_exp_from_unary2( ae_op_new, $2, FALSE, NULL, $3, @1.first_line, @1.first_column ); } |
| 677 |
| NEW type_decl LPAREN RPAREN // 1.5.2.0 (ge) added for constructors | e.g., new Foo(); |
| 678 |
{ $$ = new_exp_from_unary2( ae_op_new, $2, TRUE, NULL, NULL, @1.first_line, @1.first_column ); } |
| 679 |
| NEW type_decl LPAREN expression RPAREN // 1.5.2.0 (ge) added for constructors | e.g., new Foo(1,2,3); |
| 680 |
{ $$ = new_exp_from_unary2( ae_op_new, $2, TRUE, $4, NULL, @1.first_line, @1.first_column ); } |
| 681 |
| NEW type_decl LPAREN RPAREN array_exp // 1.5.2.0 (ge) added for constructors | e.g., new Foo()[10]; |
| 682 |
{ $$ = new_exp_from_unary2( ae_op_new, $2, TRUE, NULL, $5, @1.first_line, @1.first_column ); } |
| 683 |
| NEW type_decl LPAREN expression RPAREN array_exp // 1.5.2.0 (ge) added for constructors | e.g., new Foo(1,2,3)[10]; |
| 684 |
{ $$ = new_exp_from_unary2( ae_op_new, $2, TRUE, $4, $6, @1.first_line, @1.first_column ); } |
| 685 |
// | SPORK TILDA code_segment |
| 686 |
// { $$ = new_exp_from_unary3( ae_op_spork, $3, @1.first_line, @1.first_column ); } |
| 687 |
; |
| 688 |
|
| 689 |
unary_operator |
| 690 |
: PLUS { $$ = ae_op_plus; } |
| 691 |
| MINUS { $$ = ae_op_minus; } |
| 692 |
| TILDA { $$ = ae_op_tilda; } |
| 693 |
| EXCLAMATION { $$ = ae_op_exclamation; } |
| 694 |
| TIMES { $$ = ae_op_times; } |
| 695 |
| SPORK TILDA { $$ = ae_op_spork; } |
| 696 |
| DOWNCHUCK { $$ = ae_op_downchuck; } |
| 697 |
// | S_AND { $$ = ae_op_s_and; } |
| 698 |
; |
| 699 |
|
| 700 |
// 1.5.1.5 |
| 701 |
overloadable_operator |
| 702 |
: CHUCK { $$ = ae_op_chuck; } |
| 703 |
| PLUS { $$ = ae_op_plus; } |
| 704 |
| MINUS { $$ = ae_op_minus; } |
| 705 |
| TIMES { $$ = ae_op_times; } |
| 706 |
| DIVIDE { $$ = ae_op_divide; } |
| 707 |
| PERCENT { $$ = ae_op_percent; } |
| 708 |
| EQ { $$ = ae_op_eq; } |
| 709 |
| NEQ { $$ = ae_op_neq; } |
| 710 |
| LT { $$ = ae_op_lt; } |
| 711 |
| LE { $$ = ae_op_le; } |
| 712 |
| GT { $$ = ae_op_gt; } |
| 713 |
| GE { $$ = ae_op_ge; } |
| 714 |
| AND { $$ = ae_op_and; } |
| 715 |
| OR { $$ = ae_op_or; } |
| 716 |
| ASSIGN { $$ = ae_op_assign; } |
| 717 |
| EXCLAMATION { $$ = ae_op_exclamation; } |
| 718 |
| S_OR { $$ = ae_op_s_or; } |
| 719 |
| S_AND { $$ = ae_op_s_and; } |
| 720 |
| S_XOR { $$ = ae_op_s_xor; } |
| 721 |
| PLUSPLUS { $$ = ae_op_plusplus; } |
| 722 |
| MINUSMINUS { $$ = ae_op_minusminus; } |
| 723 |
| DOLLAR { $$ = ae_op_dollar; } |
| 724 |
| ATAT_SYM { $$ = ae_op_at_at; } |
| 725 |
| PLUS_CHUCK { $$ = ae_op_plus_chuck; } |
| 726 |
| MINUS_CHUCK { $$ = ae_op_minus_chuck; } |
| 727 |
| TIMES_CHUCK { $$ = ae_op_times_chuck; } |
| 728 |
| DIVIDE_CHUCK { $$ = ae_op_divide_chuck; } |
| 729 |
| S_AND_CHUCK { $$ = ae_op_s_and_chuck; } |
| 730 |
| S_OR_CHUCK { $$ = ae_op_s_or_chuck; } |
| 731 |
| S_XOR_CHUCK { $$ = ae_op_s_xor_chuck; } |
| 732 |
| SHIFT_RIGHT_CHUCK { $$ = ae_op_shift_right_chuck; } |
| 733 |
| SHIFT_LEFT_CHUCK { $$ = ae_op_shift_left_chuck; } |
| 734 |
| PERCENT_CHUCK { $$ = ae_op_percent_chuck; } |
| 735 |
| SHIFT_RIGHT { $$ = ae_op_shift_right; } |
| 736 |
| SHIFT_LEFT { $$ = ae_op_shift_left; } |
| 737 |
| TILDA { $$ = ae_op_tilda; } |
| 738 |
| COLONCOLON { $$ = ae_op_coloncolon; } |
| 739 |
| AT_CHUCK { $$ = ae_op_at_chuck; } |
| 740 |
| UNCHUCK { $$ = ae_op_unchuck; } |
| 741 |
| UPCHUCK { $$ = ae_op_upchuck; } |
| 742 |
| DOWNCHUCK { $$ = ae_op_downchuck; } |
| 743 |
| ARROW_RIGHT { $$ = ae_op_arrow_right; } |
| 744 |
| ARROW_LEFT { $$ = ae_op_arrow_left; } |
| 745 |
| GRUCK_RIGHT { $$ = ae_op_gruck_right; } |
| 746 |
| GRUCK_LEFT { $$ = ae_op_gruck_left; } |
| 747 |
| UNGRUCK_RIGHT { $$ = ae_op_ungruck_right; } |
| 748 |
| UNGRUCK_LEFT { $$ = ae_op_ungruck_left; } |
| 749 |
; |
| 750 |
|
| 751 |
dur_expression |
| 752 |
: postfix_expression |
| 753 |
| dur_expression COLONCOLON postfix_expression |
| 754 |
{ $$ = new_exp_from_dur( $1, $3, @1.first_line, @1.first_column ); } |
| 755 |
; |
| 756 |
|
| 757 |
postfix_expression |
| 758 |
: primary_expression { $$ = $1; } |
| 759 |
| postfix_expression array_exp |
| 760 |
{ $$ = new_exp_from_array( $1, $2, @1.first_line, @1.first_column ); } |
| 761 |
| postfix_expression LPAREN RPAREN |
| 762 |
{ $$ = new_exp_from_func_call( $1, NULL, @1.first_line, @1.first_column ); } |
| 763 |
| postfix_expression LPAREN expression RPAREN |
| 764 |
{ $$ = new_exp_from_func_call( $1, $3, @1.first_line, @1.first_column ); } |
| 765 |
| postfix_expression DOT ID |
| 766 |
{ $$ = new_exp_from_member_dot( $1, $3, @1.first_line, @1.first_column, @3.first_column ); } |
| 767 |
| postfix_expression PLUSPLUS |
| 768 |
{ $$ = new_exp_from_postfix( $1, ae_op_plusplus, @1.first_line, @1.first_column ); } |
| 769 |
| postfix_expression MINUSMINUS |
| 770 |
{ $$ = new_exp_from_postfix( $1, ae_op_minusminus, @1.first_line, @1.first_column ); } |
| 771 |
; |
| 772 |
|
| 773 |
// 1.3.3.0: added CHAR_LIT - spencer |
| 774 |
primary_expression |
| 775 |
: ID { $$ = new_exp_from_id( $1, @1.first_line, @1.first_column ); } |
| 776 |
| INT_VAL { $$ = new_exp_from_int( $1, @1.first_line, @1.first_column ); } |
| 777 |
| FLOAT_VAL { $$ = new_exp_from_float( $1, @1.first_line, @1.first_column ); } |
| 778 |
| STRING_LIT { $$ = new_exp_from_str( $1, @1.first_line, @1.first_column ); } |
| 779 |
| CHAR_LIT { $$ = new_exp_from_char( $1, @1.first_line, @1.first_column ); } |
| 780 |
| array_exp { $$ = new_exp_from_array_lit( $1, @1.first_line, @1.first_column ); } |
| 781 |
| complex_exp { $$ = new_exp_from_complex( $1, @1.first_line, @1.first_column ); } |
| 782 |
| polar_exp { $$ = new_exp_from_polar( $1, @1.first_line, @1.first_column ); } |
| 783 |
| vec_exp { $$ = new_exp_from_vec( $1, @1.first_line, @1.first_column ); } |
| 784 |
| L_HACK expression R_HACK { $$ = new_exp_from_hack( $2, @1.first_line, @1.first_column ); } |
| 785 |
| LPAREN expression RPAREN { $$ = $2; } |
| 786 |
| LPAREN RPAREN { $$ = new_exp_from_nil( @1.first_line, @1.first_column ); } |
| 787 |
; |