Mercurial > hg > octave-thorsten
changeset 4615:1c0ec4705a5f
[project @ 2003-11-15 01:40:33 by jwe]
author | jwe |
---|---|
date | Sat, 15 Nov 2003 01:40:33 +0000 |
parents | 1e8d49b93fab |
children | 33030b47385a |
files | src/ChangeLog src/parse.y |
diffstat | 2 files changed, 29 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -3,6 +3,11 @@ * version.h (OCTAVE_VERSION): Now 2.1.51. (OCTAVE_API_VERSION): Now api-v2. + * parse.y (cancel_obj_idx): New rule. + (postfix_expr, prefix_expr): Use begin_obj_idx after every + postfix_expr on RHS. Use cancel_obj_idx as soon as possible for + cases where we are not working on an index expression. + * lex.l (maybe_unput_comma, handle_close_bracket): Don't insert comma if we are looking at an object index and the closest nesting level is a brace.
--- a/src/parse.y +++ b/src/parse.y @@ -725,10 +725,21 @@ { lexer_flags.looking_at_indirect_ref = true; } ; +// Two more rules for lexical feedback. To avoid reduce/reduce +// conflicts, We use begin_obj_idx after every postfix_expr on the RHS +// of a rule, then cancel that as soon as possible for cases when we +// are not actually parsing an index expression. Since all of those +// cases are simple tokens that don't involve examining the value of +// lexer_flags.looking_at_object_index, I think we should be OK. + begin_obj_idx : // empty { lexer_flags.looking_at_object_index++; } ; +cancel_obj_idx : // empty + { lexer_flags.looking_at_object_index--; } + ; + postfix_expr : primary_expr { $$ = $1; } | postfix_expr begin_obj_idx '(' ')' @@ -751,21 +762,21 @@ $$ = make_index_expression ($1, $4, '{'); lexer_flags.looking_at_object_index--; } - | postfix_expr PLUS_PLUS - { $$ = make_postfix_op (PLUS_PLUS, $1, $2); } - | postfix_expr MINUS_MINUS - { $$ = make_postfix_op (MINUS_MINUS, $1, $2); } - | postfix_expr QUOTE - { $$ = make_postfix_op (QUOTE, $1, $2); } - | postfix_expr TRANSPOSE - { $$ = make_postfix_op (TRANSPOSE, $1, $2); } - | postfix_expr indirect_ref_op STRUCT_ELT - { $$ = make_indirect_ref ($1, $3->text ()); } - | postfix_expr indirect_ref_op '(' expression ')' - { $$ = make_indirect_ref ($1, $4); } + | postfix_expr begin_obj_idx PLUS_PLUS cancel_obj_idx + { $$ = make_postfix_op (PLUS_PLUS, $1, $3); } + | postfix_expr begin_obj_idx MINUS_MINUS cancel_obj_idx + { $$ = make_postfix_op (MINUS_MINUS, $1, $3); } + | postfix_expr begin_obj_idx QUOTE cancel_obj_idx + { $$ = make_postfix_op (QUOTE, $1, $3); } + | postfix_expr begin_obj_idx TRANSPOSE cancel_obj_idx + { $$ = make_postfix_op (TRANSPOSE, $1, $3); } + | postfix_expr begin_obj_idx indirect_ref_op cancel_obj_idx STRUCT_ELT + { $$ = make_indirect_ref ($1, $5->text ()); } + | postfix_expr begin_obj_idx indirect_ref_op cancel_obj_idx '(' expression ')' + { $$ = make_indirect_ref ($1, $6); } ; -prefix_expr : postfix_expr +prefix_expr : postfix_expr begin_obj_idx cancel_obj_idx { $$ = $1; } | binary_expr { $$ = $1; }