Mercurial > hg > octave-lojdl
changeset 16266:36e01847694f classdef
maint: periodic merge of default to classdef
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 11 Mar 2013 14:30:39 -0400 |
parents | 6077d13ddb3b (current diff) 71ee3afedb69 (diff) |
children | dbbef00202ff |
files | libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll libinterp/parse-tree/oct-parse.in.yy |
diffstat | 3 files changed, 32 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.h +++ b/libinterp/parse-tree/lex.h @@ -73,7 +73,8 @@ { BRACKET = 1, BRACE = 2, - PAREN = 3 + PAREN = 3, + ANON_FCN_BODY = 4 }; public: @@ -119,6 +120,13 @@ return ! context.empty () && context.top () == PAREN; } + void anon_fcn_body (void) { context.push (ANON_FCN_BODY); } + + bool is_anon_fcn_body (void) + { + return ! context.empty () && context.top () == ANON_FCN_BODY; + } + bool is_bracket_or_brace (void) { return (! context.empty () @@ -393,8 +401,8 @@ // set of identifiers that might be local variable names. std::set<std::string> pending_local_variables; - // is the closest nesting level a square bracket, squiggly brace or - // a paren? + // is the closest nesting level a square bracket, squiggly brace, + // a paren, or an anonymous function body? bbp_nesting_level nesting_level; // Tokens generated by the lexer.
--- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -821,7 +821,14 @@ "||" { return curr_lexer->handle_op ("||", EXPR_OR_OR); } "<<" { return curr_lexer->handle_incompatible_op ("<<", LSHIFT); } ">>" { return curr_lexer->handle_incompatible_op (">>", RSHIFT); } -";" { return curr_lexer->handle_op (";", ';', true, true); } + +";" { + bool at_beginning_of_statement + = (! (curr_lexer->whitespace_is_significant () + || curr_lexer->looking_at_object_index.front ())); + + return curr_lexer->handle_op (";", ';', true, at_beginning_of_statement); + } "+" { int tok = curr_lexer->handle_unary_op ("+", '+'); @@ -887,8 +894,12 @@ } "," { + bool at_beginning_of_statement + = (! (curr_lexer->whitespace_is_significant () + || curr_lexer->looking_at_object_index.front ())); + return curr_lexer->handle_op - (",", ',', true, ! curr_lexer->looking_at_object_index.front ()); + (",", ',', true, at_beginning_of_statement); } ".'" { @@ -974,7 +985,10 @@ curr_lexer->at_beginning_of_statement = false; if (curr_lexer->looking_at_anon_fcn_args) - curr_lexer->looking_at_anon_fcn_args = false; + { + curr_lexer->looking_at_anon_fcn_args = false; + curr_lexer->nesting_level.anon_fcn_body (); + } return curr_lexer->count_token (')'); }
--- a/libinterp/parse-tree/oct-parse.in.yy +++ b/libinterp/parse-tree/oct-parse.in.yy @@ -542,7 +542,10 @@ ; anon_fcn_handle : '@' param_list statement - { $$ = curr_parser.make_anon_fcn_handle ($2, $3); } + { + $$ = curr_parser.make_anon_fcn_handle ($2, $3); + curr_lexer->nesting_level.remove (); + } ; primary_expr : identifier