*** empty log message ***
[chuck-blob.git] / v2 / chuck.y
blob55e3521bdd577c9f9c737d4b790dd3163fed3a1b
1 %{
3 /*----------------------------------------------------------------------------
4 ChucK Concurrent, On-the-fly Audio Programming Language
5 Compiler and Virtual Machine
7 Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved.
8 http://chuck.cs.princeton.edu/
9 http://soundlab.cs.princeton.edu/
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.
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.
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 -----------------------------------------------------------------------------*/
27 //-----------------------------------------------------------------------------
28 // file: chuck.tab.c
29 // desc: chuck parser
31 // author: Ge Wang (gewang@cs.princeton.edu) - generated by yacc
32 // Perry R. Cook (prc@cs.princeton.edu)
34 // based in part on the ansi C grammar by Jeff Lee, maintained by Jutta Degener
36 // date: Summer 2002
37 //-----------------------------------------------------------------------------
38 #include <stdio.h>
39 #include <string.h>
40 #include <stdlib.h>
41 #include "chuck_utils.h"
42 #include "chuck_errmsg.h"
43 #include "chuck_absyn.h"
45 // function
46 int yylex( void );
48 void yyerror( char *s )
50 EM_error( EM_tokPos, "%s", s );
53 a_Program g_program = NULL;
58 %union
60 int pos;
61 int ival;
62 double fval;
63 c_str sval;
65 a_Program program;
66 a_Section program_section;
67 a_Stmt_List stmt_list;
68 a_Class_Def class_def;
69 a_Class_Ext class_ext;
70 a_Class_Body class_body;
71 a_Stmt stmt;
72 a_Exp exp;
73 a_Func_Def func_def;
74 a_Var_Decl_List var_decl_list;
75 a_Var_Decl var_decl;
76 a_Type_Decl type_decl;
77 a_Arg_List arg_list;
78 a_Id_List id_list;
79 a_Array_Sub array_sub;
80 a_Complex complex_exp;
81 a_Polar polar_exp;
84 // expect 37 shift/reduce conflicts
85 %expect 37
87 %token <sval> ID STRING_LIT
88 %token <ival> NUM
89 %token <fval> FLOAT
91 %token
92 POUND COMMA COLON SEMICOLON LPAREN RPAREN
93 LBRACK RBRACK LBRACE RBRACE DOT
94 PLUS MINUS TIMES DIVIDE PERCENT
95 EQ NEQ LT LE GT GE AND OR ASSIGN
96 IF THEN ELSE WHILE FOR DO LOOP
97 BREAK CONTINUE NULL_TOK FUNCTION RETURN
98 QUESTION EXCLAMATION S_OR S_AND S_XOR
99 PLUSPLUS MINUSMINUS DOLLAR POUNDPAREN PERCENTPAREN
100 SIMULT PATTERN CODE TRANSPORT HOST
101 TIME WHENEVER NEXT UNTIL EVERY BEFORE
102 AFTER AT AT_SYM ATAT_SYM NEW SIZEOF TYPEOF
103 SAME PLUS_CHUCK MINUS_CHUCK TIMES_CHUCK
104 DIVIDE_CHUCK S_AND_CHUCK S_OR_CHUCK
105 S_XOR_CHUCK SHIFT_RIGHT_CHUCK
106 SHIFT_LEFT_CHUCK PERCENT_CHUCK
107 SHIFT_RIGHT SHIFT_LEFT TILDA CHUCK
108 COLONCOLON S_CHUCK AT_CHUCK LEFT_S_CHUCK
109 UNCHUCK UPCHUCK CLASS INTERFACE EXTENDS IMPLEMENTS
110 PUBLIC PROTECTED PRIVATE STATIC ABSTRACT CONST
111 SPORK ARROW_RIGHT ARROW_LEFT L_HACK R_HACK
114 %type <program> program
115 %type <program_section> program_section
116 %type <stmt> code_segment
117 %type <func_def> function_definition
118 %type <class_def> class_definition
119 %type <class_body> class_body
120 %type <class_body> class_body2
121 %type <class_ext> class_ext
122 %type <ival> class_decl
123 %type <class_ext> iface_ext
124 %type <program_section> class_section
125 %type <stmt_list> statement_list
126 %type <stmt> statement
127 //%type <stmt_label> label_statement
128 %type <stmt> loop_statement
129 %type <stmt> selection_statement
130 %type <stmt> jump_statement
131 %type <stmt> expression_statement
132 %type <exp> expression
133 %type <exp> chuck_expression
134 %type <exp> arrow_expression
135 %type <exp> conditional_expression
136 %type <exp> logical_or_expression
137 %type <exp> logical_and_expression
138 %type <exp> inclusive_or_expression
139 %type <exp> exclusive_or_expression
140 %type <exp> and_expression
141 %type <exp> equality_expression
142 %type <exp> relational_expression
143 %type <exp> shift_expression
144 %type <exp> additive_expression
145 %type <exp> multiplicative_expression
146 %type <exp> tilda_expression
147 %type <exp> cast_expression
148 %type <exp> unary_expression
149 %type <exp> dur_expression
150 %type <exp> postfix_expression
151 %type <exp> primary_expression
152 %type <exp> decl_expression
153 %type <ival> unary_operator
154 %type <ival> chuck_operator
155 %type <ival> arrow_operator
156 %type <var_decl_list> var_decl_list
157 %type <var_decl> var_decl
158 %type <type_decl> type_decl_a
159 %type <type_decl> type_decl_b
160 %type <type_decl> type_decl
161 %type <type_decl> type_decl2
162 %type <ival> function_decl
163 %type <ival> static_decl
164 %type <arg_list> arg_list
165 %type <id_list> id_list
166 %type <id_list> id_dot
167 %type <array_sub> array_exp
168 %type <array_sub> array_empty
169 %type <complex_exp> complex_exp
170 %type <polar_exp> polar_exp
172 %start program
176 program
177 : program_section { $$ = g_program = new_program( $1, EM_lineNum ); }
178 | program_section program { $$ = g_program = prepend_program( $1, $2, EM_lineNum ); }
181 program_section
182 : statement_list { $$ = new_section_stmt( $1, EM_lineNum ); }
183 | function_definition { $$ = new_section_func_def( $1, EM_lineNum ); }
184 | class_definition { $$ = new_section_class_def( $1, EM_lineNum ); }
187 class_definition
188 : class_decl CLASS id_list LBRACE class_body RBRACE
189 { $$ = new_class_def( $1, $3, NULL, $5, EM_lineNum ); }
190 | class_decl CLASS id_list class_ext LBRACE class_body RBRACE
191 { $$ = new_class_def( $1, $3, $4, $6, EM_lineNum ); }
192 | class_decl INTERFACE id_list LBRACE class_body RBRACE
193 { $$ = new_iface_def( $1, $3, NULL, $5, EM_lineNum ); }
194 | class_decl INTERFACE id_list iface_ext LBRACE class_body RBRACE
195 { $$ = new_iface_def( $1, $3, $4, $6, EM_lineNum ); }
198 class_ext
199 : IMPLEMENTS id_list { $$ = new_class_ext( NULL, $2, EM_lineNum ); }
200 | IMPLEMENTS id_list EXTENDS id_dot { $$ = new_class_ext( $4, $2, EM_lineNum ); }
201 | EXTENDS id_dot { $$ = new_class_ext( $2, NULL, EM_lineNum ); }
202 | EXTENDS id_dot IMPLEMENTS id_list { $$ = new_class_ext( $2, $4, EM_lineNum ); }
205 class_body
206 : class_body2 { $$ = $1; }
207 | { $$ = NULL; }
210 class_body2
211 : class_section { $$ = new_class_body( $1, EM_lineNum ); }
212 | class_section class_body2 { $$ = prepend_class_body( $1, $2, EM_lineNum ); }
216 class_section
217 : statement_list { $$ = new_section_stmt( $1, EM_lineNum ); }
218 | function_definition { $$ = new_section_func_def( $1, EM_lineNum ); }
219 | class_definition { $$ = new_section_class_def( $1, EM_lineNum ); }
222 iface_ext
223 : EXTENDS id_list { $$ = new_class_ext( NULL, $2, EM_lineNum ); }
226 id_list
227 : ID { $$ = new_id_list( $1, EM_lineNum ); }
228 | ID COMMA id_list { $$ = prepend_id_list( $1, $3, EM_lineNum ); }
231 id_dot
232 : ID { $$ = new_id_list( $1, EM_lineNum ); }
233 | ID DOT id_dot { $$ = prepend_id_list( $1, $3, EM_lineNum ); }
236 function_definition
237 : function_decl static_decl type_decl2 ID LPAREN arg_list RPAREN code_segment
238 { $$ = new_func_def( $1, $2, $3, $4, $6, $8, EM_lineNum ); }
239 | function_decl static_decl type_decl2 ID LPAREN RPAREN code_segment
240 { $$ = new_func_def( $1, $2, $3, $4, NULL, $7, EM_lineNum ); }
241 | function_decl static_decl type_decl2 ID LPAREN arg_list RPAREN SEMICOLON
242 { $$ = new_func_def( $1, $2, $3, $4, $6, NULL, EM_lineNum ); }
243 | function_decl static_decl type_decl2 ID LPAREN RPAREN SEMICOLON
244 { $$ = new_func_def( $1, $2, $3, $4, NULL, NULL, EM_lineNum ); }
247 class_decl
248 : PUBLIC { $$ = ae_key_public; }
249 | PRIVATE { $$ = ae_key_private; }
250 | { $$ = ae_key_private; }
253 function_decl
254 : FUNCTION { $$ = ae_key_func; }
255 | PUBLIC { $$ = ae_key_public; }
256 | PROTECTED { $$ = ae_key_protected; }
257 | PRIVATE { $$ = ae_key_private; }
260 static_decl
261 : STATIC { $$ = ae_key_static; }
262 | ABSTRACT { $$ = ae_key_abstract; }
263 | { $$ = ae_key_instance; }
266 type_decl_a
267 : ID { $$ = new_type_decl( new_id_list( $1, EM_lineNum ), 0, EM_lineNum ); }
268 | ID AT_SYM { $$ = new_type_decl( new_id_list( $1, EM_lineNum ), 1, EM_lineNum ); }
271 type_decl_b
272 : LT id_dot GT { $$ = new_type_decl( $2, 0, EM_lineNum ); }
273 | LT id_dot GT AT_SYM { $$ = new_type_decl( $2, 1, EM_lineNum ); }
276 //type_decl_c
277 // : LPAREN id_dot RPAREN { $$ = new_type_decl( $3, 0, EM_lineNum ); }
278 // // | LPAREN id_dot RPAREN AT_SYM { $$ = new_type_decl( $1, 1, EM_lineNum ); }
279 // ;
281 type_decl
282 : type_decl_a { $$ = $1; }
283 | type_decl_b { $$ = $1; }
284 // | type_decl_c { $$ = $1; }
287 type_decl2
288 : type_decl { $$ = $1; }
289 | type_decl array_empty { $$ = add_type_decl_array( $1, $2, EM_lineNum ); }
292 arg_list
293 : type_decl var_decl { $$ = new_arg_list( $1, $2, EM_lineNum ); }
294 | type_decl var_decl COMMA arg_list { $$ = prepend_arg_list( $1, $2, $4, EM_lineNum ); }
297 statement_list
298 : statement { $$ = new_stmt_list( $1, EM_lineNum ); }
299 | statement statement_list { $$ = prepend_stmt_list( $1, $2, EM_lineNum ); }
302 statement
303 : expression_statement { $$ = $1; }
304 | loop_statement { $$ = $1; }
305 | selection_statement { $$ = $1; }
306 | jump_statement { $$ = $1; }
307 // | label_statement { }
308 | code_segment { $$ = $1; }
311 jump_statement
312 : RETURN SEMICOLON { $$ = new_stmt_from_return( NULL, EM_lineNum ); }
313 | RETURN expression SEMICOLON { $$ = new_stmt_from_return( $2, EM_lineNum ); }
314 | BREAK SEMICOLON { $$ = new_stmt_from_break( EM_lineNum ); }
315 | CONTINUE SEMICOLON { $$ = new_stmt_from_continue( EM_lineNum ); }
318 selection_statement
319 : IF LPAREN expression RPAREN statement
320 { $$ = new_stmt_from_if( $3, $5, NULL, EM_lineNum ); }
321 | IF LPAREN expression RPAREN statement ELSE statement
322 { $$ = new_stmt_from_if( $3, $5, $7, EM_lineNum ); }
325 loop_statement
326 : WHILE LPAREN expression RPAREN statement
327 { $$ = new_stmt_from_while( $3, $5, EM_lineNum ); }
328 | DO statement WHILE LPAREN expression RPAREN SEMICOLON
329 { $$ = new_stmt_from_do_while( $5, $2, EM_lineNum ); }
330 | FOR LPAREN expression_statement expression_statement RPAREN statement
331 { $$ = new_stmt_from_for( $3, $4, NULL, $6, EM_lineNum ); }
332 | FOR LPAREN expression_statement expression_statement expression RPAREN statement
333 { $$ = new_stmt_from_for( $3, $4, $5, $7, EM_lineNum ); }
334 | UNTIL LPAREN expression RPAREN statement
335 { $$ = new_stmt_from_until( $3, $5, EM_lineNum ); }
336 | DO statement UNTIL LPAREN expression RPAREN SEMICOLON
337 { $$ = new_stmt_from_do_until( $5, $2, EM_lineNum ); }
338 | LOOP LPAREN expression RPAREN statement
339 { $$ = new_stmt_from_loop( $3, $5, EM_lineNum ); }
342 code_segment
343 : LBRACE RBRACE { $$ = new_stmt_from_code( NULL, EM_lineNum ); }
344 | LBRACE statement_list RBRACE { $$ = new_stmt_from_code( $2, EM_lineNum ); }
347 expression_statement
348 : SEMICOLON { $$ = NULL; }
349 | expression SEMICOLON { $$ = new_stmt_from_expression( $1, EM_lineNum ); }
352 expression
353 : chuck_expression { $$ = $1; }
354 | chuck_expression COMMA expression { $$ = prepend_expression( $1, $3, EM_lineNum ); }
357 chuck_expression
358 : arrow_expression { $$ = $1; }
359 | chuck_expression chuck_operator arrow_expression
360 { $$ = new_exp_from_binary( $1, $2, $3, EM_lineNum ); }
363 arrow_expression
364 : decl_expression { $$ = $1; }
365 | arrow_expression arrow_operator decl_expression
366 { $$ = new_exp_from_binary( $1, $2, $3, EM_lineNum ); }
369 array_exp
370 : LBRACK expression RBRACK { $$ = new_array_sub( $2, EM_lineNum ); }
371 | LBRACK expression RBRACK array_exp
372 { $$ = prepend_array_sub( $4, $2, EM_lineNum ); }
375 array_empty
376 : LBRACK RBRACK { $$ = new_array_sub( NULL, EM_lineNum ); }
377 | array_empty LBRACK RBRACK { $$ = prepend_array_sub( $1, NULL, EM_lineNum ); }
380 decl_expression
381 : conditional_expression { $$ = $1; }
382 | type_decl var_decl_list { $$ = new_exp_decl( $1, $2, 0, EM_lineNum ); }
383 | STATIC type_decl var_decl_list { $$ = new_exp_decl( $2, $3, 1, EM_lineNum ); }
384 | SAME var_decl_list { $$ = new_exp_decl( NULL, $2, 0, EM_lineNum ); }
385 | STATIC SAME var_decl_list { $$ = new_exp_decl( NULL, $3, 1, EM_lineNum ); }
388 var_decl_list
389 : var_decl { $$ = new_var_decl_list( $1, EM_lineNum ); }
390 | var_decl COMMA var_decl_list { $$ = prepend_var_decl_list( $1, $3, EM_lineNum ); }
393 var_decl
394 : ID { $$ = new_var_decl( $1, NULL, EM_lineNum ); }
395 | ID array_exp { $$ = new_var_decl( $1, $2, EM_lineNum ); }
396 | ID array_empty { $$ = new_var_decl( $1, $2, EM_lineNum ); }
399 complex_exp
400 : POUNDPAREN expression RPAREN
401 { $$ = new_complex( $2, EM_lineNum ); }
404 polar_exp
405 : PERCENTPAREN expression RPAREN
406 { $$ = new_polar( $2, EM_lineNum ); }
409 chuck_operator
410 : CHUCK { $$ = ae_op_chuck; }
411 | AT_CHUCK { $$ = ae_op_at_chuck; }
412 | PLUS_CHUCK { $$ = ae_op_plus_chuck; }
413 | MINUS_CHUCK { $$ = ae_op_minus_chuck; }
414 | TIMES_CHUCK { $$ = ae_op_times_chuck; }
415 | DIVIDE_CHUCK { $$ = ae_op_divide_chuck; }
416 | SHIFT_RIGHT_CHUCK { $$ = ae_op_shift_right_chuck; }
417 | SHIFT_LEFT_CHUCK { $$ = ae_op_shift_left_chuck; }
418 | PERCENT_CHUCK { $$ = ae_op_percent_chuck; }
419 | UNCHUCK { $$ = ae_op_unchuck; }
420 | UPCHUCK { $$ = ae_op_upchuck; }
421 | S_AND_CHUCK { $$ = ae_op_s_and_chuck; }
422 | S_OR_CHUCK { $$ = ae_op_s_or_chuck; }
423 | S_XOR_CHUCK { $$ = ae_op_s_xor_chuck; }
426 arrow_operator
427 : ARROW_LEFT { $$ = ae_op_arrow_left; }
428 | ARROW_RIGHT { $$ = ae_op_arrow_right; }
431 conditional_expression
432 : logical_or_expression { $$ = $1; }
433 | logical_or_expression QUESTION expression COLON conditional_expression
434 { $$ = new_exp_from_if( $1, $3, $5, EM_lineNum ); }
437 logical_or_expression
438 : logical_and_expression { $$ = $1; }
439 | logical_or_expression OR logical_and_expression
440 { $$ = new_exp_from_binary( $1, ae_op_or, $3, EM_lineNum ); }
443 logical_and_expression
444 : inclusive_or_expression { $$ = $1; }
445 | logical_and_expression AND inclusive_or_expression
446 { $$ = new_exp_from_binary( $1, ae_op_and, $3, EM_lineNum ); }
449 inclusive_or_expression
450 : exclusive_or_expression { $$ = $1; }
451 | inclusive_or_expression S_OR exclusive_or_expression
452 { $$ = new_exp_from_binary( $1, ae_op_s_or, $3, EM_lineNum ); }
455 exclusive_or_expression
456 : and_expression { $$ = $1; }
457 | exclusive_or_expression S_XOR and_expression
458 { $$ = new_exp_from_binary( $1, ae_op_s_xor, $3, EM_lineNum ); }
461 and_expression
462 : equality_expression { $$ = $1; }
463 | and_expression S_AND equality_expression
464 { $$ = new_exp_from_binary( $1, ae_op_s_and, $3, EM_lineNum ); }
467 equality_expression
468 : relational_expression { $$ = $1; }
469 | equality_expression EQ relational_expression
470 { $$ = new_exp_from_binary( $1, ae_op_eq, $3, EM_lineNum ); }
471 | equality_expression NEQ relational_expression
472 { $$ = new_exp_from_binary( $1, ae_op_neq, $3, EM_lineNum ); }
475 relational_expression
476 : shift_expression { $$ = $1; }
477 | relational_expression LT shift_expression
478 { $$ = new_exp_from_binary( $1, ae_op_lt, $3, EM_lineNum ); }
479 | relational_expression GT shift_expression
480 { $$ = new_exp_from_binary( $1, ae_op_gt, $3, EM_lineNum ); }
481 | relational_expression LE shift_expression
482 { $$ = new_exp_from_binary( $1, ae_op_le, $3, EM_lineNum ); }
483 | relational_expression GE shift_expression
484 { $$ = new_exp_from_binary( $1, ae_op_ge, $3, EM_lineNum ); }
487 shift_expression
488 : additive_expression { $$ = $1; }
489 | shift_expression SHIFT_LEFT additive_expression
490 { $$ = new_exp_from_binary( $1, ae_op_shift_left, $3, EM_lineNum ); }
491 | shift_expression SHIFT_RIGHT additive_expression
492 { $$ = new_exp_from_binary( $1, ae_op_shift_right, $3, EM_lineNum ); }
495 additive_expression
496 : multiplicative_expression { $$ = $1; }
497 | additive_expression PLUS multiplicative_expression
498 { $$ = new_exp_from_binary( $1, ae_op_plus, $3, EM_lineNum ); }
499 | additive_expression MINUS multiplicative_expression
500 { $$ = new_exp_from_binary( $1, ae_op_minus, $3, EM_lineNum ); }
503 multiplicative_expression
504 : tilda_expression { $$ = $1; }
505 | multiplicative_expression TIMES tilda_expression
506 { $$ = new_exp_from_binary( $1, ae_op_times, $3, EM_lineNum ); }
507 | multiplicative_expression DIVIDE tilda_expression
508 { $$ = new_exp_from_binary( $1, ae_op_divide, $3, EM_lineNum ); }
509 | multiplicative_expression PERCENT tilda_expression
510 { $$ = new_exp_from_binary( $1, ae_op_percent, $3, EM_lineNum ); }
513 tilda_expression
514 : cast_expression { $$ = $1; }
515 | tilda_expression TILDA cast_expression
516 { $$ = new_exp_from_binary( $1, ae_op_tilda, $3, EM_lineNum ); }
519 cast_expression
520 : unary_expression { $$ = $1; }
521 | cast_expression DOLLAR type_decl
522 { $$ = new_exp_from_cast( $3, $1, EM_lineNum ); }
525 unary_expression
526 : dur_expression { $$ = $1; }
527 | PLUSPLUS unary_expression
528 { $$ = new_exp_from_unary( ae_op_plusplus, $2, EM_lineNum ); }
529 | MINUSMINUS unary_expression
530 { $$ = new_exp_from_unary( ae_op_minusminus, $2, EM_lineNum ); }
531 | unary_operator unary_expression
532 { $$ = new_exp_from_unary( $1, $2, EM_lineNum ); }
533 | TYPEOF unary_expression
534 { $$ = new_exp_from_unary( ae_op_typeof, $2, EM_lineNum ); }
535 | SIZEOF unary_expression
536 { $$ = new_exp_from_unary( ae_op_sizeof, $2, EM_lineNum ); }
537 | NEW type_decl
538 { $$ = new_exp_from_unary2( ae_op_new, $2, NULL, EM_lineNum ); }
539 | NEW type_decl array_exp
540 { $$ = new_exp_from_unary2( ae_op_new, $2, $3, EM_lineNum ); }
541 | SPORK TILDA code_segment
542 { $$ = new_exp_from_unary3( ae_op_spork, $3, EM_lineNum ); }
545 unary_operator
546 : PLUS { $$ = ae_op_plus; }
547 | MINUS { $$ = ae_op_minus; }
548 | TILDA { $$ = ae_op_tilda; }
549 | EXCLAMATION { $$ = ae_op_exclamation; }
550 | TIMES { $$ = ae_op_times; }
551 | SPORK TILDA { $$ = ae_op_spork; }
552 // | S_AND { $$ = ae_op_s_and; }
555 dur_expression
556 : postfix_expression
557 | dur_expression COLONCOLON postfix_expression
558 { $$ = new_exp_from_dur( $1, $3, EM_lineNum ); }
561 postfix_expression
562 : primary_expression { $$ = $1; }
563 | postfix_expression array_exp
564 { $$ = new_exp_from_array( $1, $2, EM_lineNum ); }
565 | postfix_expression LPAREN RPAREN
566 { $$ = new_exp_from_func_call( $1, NULL, EM_lineNum ); }
567 | postfix_expression LPAREN expression RPAREN
568 { $$ = new_exp_from_func_call( $1, $3, EM_lineNum ); }
569 | postfix_expression DOT ID
570 { $$ = new_exp_from_member_dot( $1, $3, EM_lineNum ); }
571 | postfix_expression PLUSPLUS
572 { $$ = new_exp_from_postfix( $1, ae_op_plusplus, EM_lineNum ); }
573 | postfix_expression MINUSMINUS
574 { $$ = new_exp_from_postfix( $1, ae_op_minusminus, EM_lineNum ); }
577 primary_expression
578 : ID { $$ = new_exp_from_id( $1, EM_lineNum ); }
579 | NUM { $$ = new_exp_from_int( $1, EM_lineNum ); }
580 | FLOAT { $$ = new_exp_from_float( $1, EM_lineNum ); }
581 | STRING_LIT { $$ = new_exp_from_str( $1, EM_lineNum ); }
582 | array_exp { $$ = new_exp_from_array_lit( $1, EM_lineNum ); }
583 | complex_exp { $$ = new_exp_from_complex( $1, EM_lineNum ); }
584 | polar_exp { $$ = new_exp_from_polar( $1, EM_lineNum ); }
585 | L_HACK expression R_HACK { $$ = new_exp_from_hack( $2, EM_lineNum ); }
586 | LPAREN expression RPAREN { $$ = $2; }
587 | LPAREN RPAREN { $$ = new_exp_from_nil( EM_lineNum ); }