changeset 16238:38bd5ae8463b

new opt_semi non-terminal for parser; use opt_comma in cell_or_matrix_row * oct-parse.in.yy (opt_semi): New non-terminal. (cell_or_matrix_row): Use opt_comma. (cell_rows, matrix_rows): Use opt_semi.
author John W. Eaton <jwe@octave.org>
date Sat, 09 Mar 2013 18:04:55 -0500
parents 70f465930546
children 90dfd98a915a 8f4f32a9d991
files libinterp/parse-tree/oct-parse.in.yy
diffstat 1 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.in.yy	Sat Mar 09 18:04:51 2013 -0500
+++ b/libinterp/parse-tree/oct-parse.in.yy	Sat Mar 09 18:04:55 2013 -0500
@@ -235,7 +235,8 @@
 // Nonterminals we construct.
 %type <comment_type> stash_comment function_beg classdef_beg
 %type <comment_type> properties_beg methods_beg events_beg enum_beg
-%type <sep_type> sep_no_nl opt_sep_no_nl nl opt_nl sep opt_sep opt_comma
+%type <sep_type> sep_no_nl opt_sep_no_nl nl opt_nl sep opt_sep
+%type <sep_type> opt_comma opt_semi
 %type <tree_type> input
 %type <tree_constant_type> string constant magic_colon
 %type <tree_anon_fcn_handle_type> anon_fcn_handle
@@ -453,9 +454,7 @@
                   }
                 ;
 
-matrix_rows     : matrix_rows1
-                  { $$ = $1; }
-                | matrix_rows1 ';'      // Ignore trailing semicolon.
+matrix_rows     : matrix_rows1 opt_semi
                   { $$ = $1; }
                 ;
 
@@ -476,9 +475,7 @@
                   { $$ = curr_parser.finish_cell ($2); }
                 ;
 
-cell_rows       : cell_rows1
-                  { $$ = $1; }
-                | cell_rows1 ';'        // Ignore trailing semicolon.
+cell_rows       : cell_rows1 opt_semi
                   { $$ = $1; }
                 ;
 
@@ -492,9 +489,7 @@
                 ;
 
 cell_or_matrix_row
-                : arg_list
-                  { $$ = curr_parser.validate_matrix_row ($1); }
-                | arg_list ','  // Ignore trailing comma.
+                : arg_list opt_comma
                   { $$ = curr_parser.validate_matrix_row ($1); }
                 ;
 
@@ -1458,6 +1453,12 @@
                   { $$ = ','; }
                 ;
 
+opt_semi        : // empty
+                  { $$ = 0; }
+                | ';'
+                  { $$ = ';'; }
+                ;
+
 %%
 
 // Generic error messages.