diff 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
line wrap: on
line diff
--- a/src/oct-parse.yy	Thu Sep 29 12:31:39 2011 +0200
+++ b/src/oct-parse.yy	Thu Sep 29 14:11:39 2011 -0400
@@ -448,9 +448,7 @@
 %token <tok_val> TRY CATCH
 %token <tok_val> GLOBAL STATIC
 %token <tok_val> FCN_HANDLE
-%token <tok_val> PROPERTIES
-%token <tok_val> METHODS
-%token <tok_val> EVENTS
+%token <tok_val> PROPERTIES METHODS EVENTS ENUMERATION
 %token <tok_val> METAQUERY
 %token <tok_val> SUPERCLASSREF
 %token <tok_val> GET SET
@@ -463,7 +461,7 @@
 
 // Nonterminals we construct.
 %type <comment_type> stash_comment function_beg classdef_beg
-%type <comment_type> properties_beg methods_beg events_beg
+%type <comment_type> properties_beg methods_beg events_beg enum_beg
 %type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep
 %type <tree_type> input
 %type <tree_constant_type> string constant magic_colon
@@ -503,6 +501,7 @@
 // These types need to be specified.
 %type <dummy_type> attr
 %type <dummy_type> class_event
+%type <dummy_type> class_enum
 %type <dummy_type> class_property
 %type <dummy_type> properties_list
 %type <dummy_type> properties_block
@@ -512,6 +511,8 @@
 %type <dummy_type> attr_list
 %type <dummy_type> events_list
 %type <dummy_type> events_block
+%type <dummy_type> enum_list
+%type <dummy_type> enum_block
 %type <dummy_type> class_body
 
 // Precedence and associativity.
@@ -1537,12 +1538,16 @@
                   { $$ = 0; }
                 | events_block
                   { $$ = 0; }
+                | enum_block
+                  { $$ = 0; }
                 | class_body '\n' properties_block
                   { $$ = 0; }
                 | class_body '\n' methods_block
                   { $$ = 0; }
                 | class_body '\n' events_block
                   { $$ = 0; }
+                | class_body '\n' enum_block
+                  { $$ = 0; }
                 ;
 
 properties_beg  : PROPERTIES stash_comment
@@ -1599,6 +1604,24 @@
                   { $$ = 0; }
                 ;
 
+enum_beg        : ENUMERATION stash_comment
+                  { $$ = 0; }
+                ;
+
+enum_block      : enum_beg opt_attr_list '\n' enum_list '\n' END
+                  { $$ = 0; }
+                ;
+
+enum_list       : class_enum
+                  { $$ = 0; }
+                | enum_list '\n' class_enum
+                  { $$ = 0; }
+                ;
+
+class_enum      : identifier '(' expression ')'
+                  { $$ = 0; }
+                ;
+
 // =============
 // Miscellaneous
 // =============
@@ -1777,6 +1800,10 @@
           end_error ("for", ettype, l, c);
           break;
 
+        case token::enumeration_end:
+          end_error ("enumeration", ettype, l, c);
+          break;
+
         case token::function_end:
           end_error ("function", ettype, l, c);
           break;