Mercurial > octave-nkf
changeset 18419:9154dc252f47
Allow empty classdef or methods/properties/... blocks
* oct-parse.in.yy (rule classdef): Add variant without body.
(rule properties_block, rule methods_block, rule events_block,
rule rnum_block): Add empty variant.
(octave_base_parser::make_classdef): Handle case with NULL body.
(octave_base_parser::make_classdef_properties_block): Handle case with
NULL properties list.
(octave_base_parser::make_classdef_methods_block): Handle case with
NULL methods list.
(octave_base_parser::make_classdef_events_block): Handle case with NULL
events list.
(octave_base_parser::make_classdef_enum_block): Handle case with NULL
enum list.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Fri, 31 Jan 2014 12:02:04 -0500 |
parents | bcd71a2531d3 |
children | c2d1869a95ee |
files | libinterp/parse-tree/oct-parse.in.yy |
diffstat | 1 files changed, 62 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.in.yy Fri Jan 31 11:41:19 2014 -0500 +++ b/libinterp/parse-tree/oct-parse.in.yy Fri Jan 31 12:02:04 2014 -0500 @@ -1508,6 +1508,16 @@ ABORT_PARSE; } } + | classdef_beg stash_comment opt_attr_list identifier opt_superclass_list opt_sep END + { + lexer.parsing_classdef = false; + + if (! ($$ = parser.make_classdef ($1, $3, $4, $5, 0, $7, $2))) + { + // make_classdef deleted $3, $4, and $5. + ABORT_PARSE; + } + } ; opt_attr_list : // empty @@ -1598,6 +1608,15 @@ ABORT_PARSE; } } + | PROPERTIES stash_comment opt_attr_list opt_sep END + { + if (! ($$ = parser.make_classdef_properties_block + ($1, $3, 0, $5, $2))) + { + // make_classdef_properties_block delete $3. + ABORT_PARSE; + } + } ; property_list @@ -1628,6 +1647,16 @@ ABORT_PARSE; } } + | METHODS stash_comment opt_attr_list opt_sep END + { + if (! ($$ = parser.make_classdef_methods_block + ($1, $3, 0, $5, $2))) + { + // make_classdef_methods_block deleted $3. + ABORT_PARSE; + } + } + ; ; method_decl1 : identifier @@ -1692,6 +1721,15 @@ ABORT_PARSE; } } + | EVENTS stash_comment opt_attr_list opt_sep END + { + if (! ($$ = parser.make_classdef_events_block + ($1, $3, 0, $5, $2))) + { + // make_classdef_events_block deleted $3. + ABORT_PARSE; + } + } ; events_list : class_event @@ -1716,6 +1754,15 @@ ABORT_PARSE; } } + | ENUMERATION stash_comment opt_attr_list opt_sep END + { + if (! ($$ = parser.make_classdef_enum_block + ($1, $3, 0, $5, $2))) + { + // make_classdef_enum_block deleted $3. + ABORT_PARSE; + } + } ; enum_list : class_enum @@ -3134,6 +3181,9 @@ int l = tok_val->line (); int c = tok_val->column (); + if (! body) + body = new tree_classdef_body (); + retval = new tree_classdef (a, id, sc, body, lc, tc, curr_package_name, l, c); } @@ -3165,6 +3215,9 @@ int l = tok_val->line (); int c = tok_val->column (); + if (! plist) + plist = new tree_classdef_property_list (); + retval = new tree_classdef_properties_block (a, plist, lc, tc, l, c); } else @@ -3192,6 +3245,9 @@ int l = tok_val->line (); int c = tok_val->column (); + if (! mlist) + mlist = new tree_classdef_methods_list (); + retval = new tree_classdef_methods_block (a, mlist, lc, tc, l, c); } else @@ -3219,6 +3275,9 @@ int l = tok_val->line (); int c = tok_val->column (); + if (! elist) + elist = new tree_classdef_events_list (); + retval = new tree_classdef_events_block (a, elist, lc, tc, l, c); } else @@ -3246,6 +3305,9 @@ int l = tok_val->line (); int c = tok_val->column (); + if (! elist) + elist = new tree_classdef_enum_list (); + retval = new tree_classdef_enum_block (a, elist, lc, tc, l, c); } else