comparison src/parse.y @ 5279:bd32f770c09a

[project @ 2005-04-12 21:55:31 by jwe]
author jwe
date Tue, 12 Apr 2005 21:55:31 +0000
parents 85b315ad5f7d
children 4e753a157ed2
comparison
equal deleted inserted replaced
5278:fe23ec6763b7 5279:bd32f770c09a
404 %token <tok_val> PLUS_PLUS MINUS_MINUS POW EPOW 404 %token <tok_val> PLUS_PLUS MINUS_MINUS POW EPOW
405 %token <tok_val> NUM IMAG_NUM 405 %token <tok_val> NUM IMAG_NUM
406 %token <tok_val> STRUCT_ELT 406 %token <tok_val> STRUCT_ELT
407 %token <tok_val> NAME 407 %token <tok_val> NAME
408 %token <tok_val> END 408 %token <tok_val> END
409 %token <tok_val> STRING 409 %token <tok_val> DQ_STRING SQ_STRING
410 %token <tok_val> FOR WHILE DO UNTIL 410 %token <tok_val> FOR WHILE DO UNTIL
411 %token <tok_val> IF ELSEIF ELSE 411 %token <tok_val> IF ELSEIF ELSE
412 %token <tok_val> SWITCH CASE OTHERWISE 412 %token <tok_val> SWITCH CASE OTHERWISE
413 %token <tok_val> BREAK CONTINUE FUNC_RET 413 %token <tok_val> BREAK CONTINUE FUNC_RET
414 %token <tok_val> UNWIND CLEANUP 414 %token <tok_val> UNWIND CLEANUP
423 423
424 // Nonterminals we construct. 424 // Nonterminals we construct.
425 %type <comment_type> stash_comment function_beg 425 %type <comment_type> stash_comment function_beg
426 %type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep 426 %type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep
427 %type <tree_type> input 427 %type <tree_type> input
428 %type <tree_constant_type> constant magic_colon anon_fcn_handle 428 %type <tree_constant_type> string constant magic_colon anon_fcn_handle
429 %type <tree_fcn_handle_type> fcn_handle 429 %type <tree_fcn_handle_type> fcn_handle
430 %type <tree_matrix_type> matrix_rows matrix_rows1 430 %type <tree_matrix_type> matrix_rows matrix_rows1
431 %type <tree_cell_type> cell_rows cell_rows1 431 %type <tree_cell_type> cell_rows cell_rows1
432 %type <tree_expression_type> matrix cell 432 %type <tree_expression_type> matrix cell
433 %type <tree_expression_type> primary_expr postfix_expr prefix_expr binary_expr 433 %type <tree_expression_type> primary_expr postfix_expr prefix_expr binary_expr
576 $$ = new tree_identifier 576 $$ = new tree_identifier
577 ($1->sym_rec (), $1->line (), $1->column ()); 577 ($1->sym_rec (), $1->line (), $1->column ());
578 } 578 }
579 ; 579 ;
580 580
581 string : DQ_STRING
582 { $$ = make_constant (DQ_STRING, $1); }
583 | SQ_STRING
584 { $$ = make_constant (SQ_STRING, $1); }
585 ;
586
581 constant : NUM 587 constant : NUM
582 { $$ = make_constant (NUM, $1); } 588 { $$ = make_constant (NUM, $1); }
583 | IMAG_NUM 589 | IMAG_NUM
584 { $$ = make_constant (IMAG_NUM, $1); } 590 { $$ = make_constant (IMAG_NUM, $1); }
585 | STRING 591 | string
586 { $$ = make_constant (STRING, $1); } 592 { $$ = $1; }
587 ; 593 ;
588 594
589 in_matrix_or_assign_lhs 595 in_matrix_or_assign_lhs
590 : // empty 596 : // empty
591 { lexer_flags.looking_at_matrix_or_assign_lhs = true; } 597 { lexer_flags.looking_at_matrix_or_assign_lhs = true; }
892 898
893 word_list_cmd : identifier word_list 899 word_list_cmd : identifier word_list
894 { $$ = make_index_expression ($1, $2, '('); } 900 { $$ = make_index_expression ($1, $2, '('); }
895 ; 901 ;
896 902
897 word_list : STRING 903 word_list : string
898 { 904 { $$ = new tree_argument_list ($1); }
899 tree_constant *tmp = make_constant (STRING, $1); 905 | word_list string
900 $$ = new tree_argument_list (tmp); 906 {
901 } 907 $1->append ($2);
902 | word_list STRING
903 {
904 tree_constant *tmp = make_constant (STRING, $2);
905 $1->append (tmp);
906 $$ = $1; 908 $$ = $1;
907 } 909 }
908 ; 910 ;
909 911
910 expression : simple_expr 912 expression : simple_expr
1762 retval = new tree_constant (tmp, l, c); 1764 retval = new tree_constant (tmp, l, c);
1763 retval->stash_original_text (tok_val->text_rep ()); 1765 retval->stash_original_text (tok_val->text_rep ());
1764 } 1766 }
1765 break; 1767 break;
1766 1768
1767 case STRING: 1769 case DQ_STRING:
1770 case SQ_STRING:
1768 { 1771 {
1769 octave_value tmp (tok_val->text ()); 1772 octave_value tmp (tok_val->text (), op == DQ_STRING ? '"' : '\'');
1770 retval = new tree_constant (tmp, l, c); 1773 retval = new tree_constant (tmp, l, c);
1771 } 1774 }
1772 break; 1775 break;
1773 1776
1774 default: 1777 default: