comparison src/oct-parse.yy @ 13249:7861a5fd3479

accept enumeration keyword * octave.gperf (octave_kw_id): New keyword ids, enumeration_kw and endenumeration_kw. (octave_kw): Add enumeration and endenumeration to the struct. * lex.ll (is_keyword_token): Handle enumeration and endenumeration. * oct-parse.yy (ENUMERATION): New token. (enum_beg, enum_block, enum_list, class_enum): New non-terminals. (class_body): Accept enum_block. * token.h (token::enumeration_end): New end_tok_type enum value.
author John W. Eaton <jwe@octave.org>
date Thu, 29 Sep 2011 14:11:39 -0400
parents 0c69a564f2be
children f6bbdea030b2
comparison
equal deleted inserted replaced
13247:e36c2f4ea8f5 13249:7861a5fd3479
446 %token <tok_val> BREAK CONTINUE FUNC_RET 446 %token <tok_val> BREAK CONTINUE FUNC_RET
447 %token <tok_val> UNWIND CLEANUP 447 %token <tok_val> UNWIND CLEANUP
448 %token <tok_val> TRY CATCH 448 %token <tok_val> TRY CATCH
449 %token <tok_val> GLOBAL STATIC 449 %token <tok_val> GLOBAL STATIC
450 %token <tok_val> FCN_HANDLE 450 %token <tok_val> FCN_HANDLE
451 %token <tok_val> PROPERTIES 451 %token <tok_val> PROPERTIES METHODS EVENTS ENUMERATION
452 %token <tok_val> METHODS
453 %token <tok_val> EVENTS
454 %token <tok_val> METAQUERY 452 %token <tok_val> METAQUERY
455 %token <tok_val> SUPERCLASSREF 453 %token <tok_val> SUPERCLASSREF
456 %token <tok_val> GET SET 454 %token <tok_val> GET SET
457 455
458 // Other tokens. 456 // Other tokens.
461 // %token VARARGIN VARARGOUT 459 // %token VARARGIN VARARGOUT
462 %token CLOSE_BRACE 460 %token CLOSE_BRACE
463 461
464 // Nonterminals we construct. 462 // Nonterminals we construct.
465 %type <comment_type> stash_comment function_beg classdef_beg 463 %type <comment_type> stash_comment function_beg classdef_beg
466 %type <comment_type> properties_beg methods_beg events_beg 464 %type <comment_type> properties_beg methods_beg events_beg enum_beg
467 %type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep 465 %type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep
468 %type <tree_type> input 466 %type <tree_type> input
469 %type <tree_constant_type> string constant magic_colon 467 %type <tree_constant_type> string constant magic_colon
470 %type <tree_anon_fcn_handle_type> anon_fcn_handle 468 %type <tree_anon_fcn_handle_type> anon_fcn_handle
471 %type <tree_fcn_handle_type> fcn_handle 469 %type <tree_fcn_handle_type> fcn_handle
501 %type <tree_statement_list_type> simple_list simple_list1 list list1 499 %type <tree_statement_list_type> simple_list simple_list1 list list1
502 %type <tree_statement_list_type> opt_list input1 500 %type <tree_statement_list_type> opt_list input1
503 // These types need to be specified. 501 // These types need to be specified.
504 %type <dummy_type> attr 502 %type <dummy_type> attr
505 %type <dummy_type> class_event 503 %type <dummy_type> class_event
504 %type <dummy_type> class_enum
506 %type <dummy_type> class_property 505 %type <dummy_type> class_property
507 %type <dummy_type> properties_list 506 %type <dummy_type> properties_list
508 %type <dummy_type> properties_block 507 %type <dummy_type> properties_block
509 %type <dummy_type> methods_list 508 %type <dummy_type> methods_list
510 %type <dummy_type> methods_block 509 %type <dummy_type> methods_block
511 %type <dummy_type> opt_attr_list 510 %type <dummy_type> opt_attr_list
512 %type <dummy_type> attr_list 511 %type <dummy_type> attr_list
513 %type <dummy_type> events_list 512 %type <dummy_type> events_list
514 %type <dummy_type> events_block 513 %type <dummy_type> events_block
514 %type <dummy_type> enum_list
515 %type <dummy_type> enum_block
515 %type <dummy_type> class_body 516 %type <dummy_type> class_body
516 517
517 // Precedence and associativity. 518 // Precedence and associativity.
518 %right '=' ADD_EQ SUB_EQ MUL_EQ DIV_EQ LEFTDIV_EQ POW_EQ EMUL_EQ EDIV_EQ ELEFTDIV_EQ EPOW_EQ OR_EQ AND_EQ LSHIFT_EQ RSHIFT_EQ 519 %right '=' ADD_EQ SUB_EQ MUL_EQ DIV_EQ LEFTDIV_EQ POW_EQ EMUL_EQ EDIV_EQ ELEFTDIV_EQ EPOW_EQ OR_EQ AND_EQ LSHIFT_EQ RSHIFT_EQ
519 %left EXPR_OR_OR 520 %left EXPR_OR_OR
1535 { $$ = 0; } 1536 { $$ = 0; }
1536 | methods_block 1537 | methods_block
1537 { $$ = 0; } 1538 { $$ = 0; }
1538 | events_block 1539 | events_block
1539 { $$ = 0; } 1540 { $$ = 0; }
1541 | enum_block
1542 { $$ = 0; }
1540 | class_body '\n' properties_block 1543 | class_body '\n' properties_block
1541 { $$ = 0; } 1544 { $$ = 0; }
1542 | class_body '\n' methods_block 1545 | class_body '\n' methods_block
1543 { $$ = 0; } 1546 { $$ = 0; }
1544 | class_body '\n' events_block 1547 | class_body '\n' events_block
1545 { $$ = 0; } 1548 { $$ = 0; }
1549 | class_body '\n' enum_block
1550 { $$ = 0; }
1546 ; 1551 ;
1547 1552
1548 properties_beg : PROPERTIES stash_comment 1553 properties_beg : PROPERTIES stash_comment
1549 { $$ = 0; } 1554 { $$ = 0; }
1550 ; 1555 ;
1594 | events_list '\n' class_event 1599 | events_list '\n' class_event
1595 { $$ = 0; } 1600 { $$ = 0; }
1596 ; 1601 ;
1597 1602
1598 class_event : identifier 1603 class_event : identifier
1604 { $$ = 0; }
1605 ;
1606
1607 enum_beg : ENUMERATION stash_comment
1608 { $$ = 0; }
1609 ;
1610
1611 enum_block : enum_beg opt_attr_list '\n' enum_list '\n' END
1612 { $$ = 0; }
1613 ;
1614
1615 enum_list : class_enum
1616 { $$ = 0; }
1617 | enum_list '\n' class_enum
1618 { $$ = 0; }
1619 ;
1620
1621 class_enum : identifier '(' expression ')'
1599 { $$ = 0; } 1622 { $$ = 0; }
1600 ; 1623 ;
1601 1624
1602 // ============= 1625 // =============
1603 // Miscellaneous 1626 // Miscellaneous
1773 end_error ("classdef", ettype, l, c); 1796 end_error ("classdef", ettype, l, c);
1774 break; 1797 break;
1775 1798
1776 case token::for_end: 1799 case token::for_end:
1777 end_error ("for", ettype, l, c); 1800 end_error ("for", ettype, l, c);
1801 break;
1802
1803 case token::enumeration_end:
1804 end_error ("enumeration", ettype, l, c);
1778 break; 1805 break;
1779 1806
1780 case token::function_end: 1807 case token::function_end:
1781 end_error ("function", ettype, l, c); 1808 end_error ("function", ettype, l, c);
1782 break; 1809 break;