# HG changeset patch # User John W. Eaton # Date 1386998448 18000 # Sat Dec 14 00:20:48 2013 -0500 # Branch stable # Node ID 8ae17d8176f029e58c875ab9ebd434999f073cce # Parent 25e87795f437a14408824bf9745d5ac5bd2d3224 fix block comments at beginning of file (bug #40894) * lex.ll (^{S}*{CCHAR}\{{S}*{NL}): New pattern. ({ANY_INCLUDING_NL}): Use yyless (0) instead of curr_lexer->xunput. diff --git a/libinterp/parse-tree/lex.ll b/libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -268,7 +268,7 @@ {ANY_INCLUDING_NL} { curr_lexer->lexer_debug ("{ANY_INCLUDING_NL}"); - curr_lexer->xunput (yytext[0]); + yyless (0); // May be reset later if we see "function" or "classdef" appears // as the first token. @@ -280,6 +280,28 @@ } %{ +// Hmm, is there no better way to do this? +%} + +^{S}*{CCHAR}\{{S}*{NL} { + curr_lexer->lexer_debug ("^{S}*{CCHAR}\\{{S}*{NL}"); + + yyless (0); + + // May be reset later if we see "function" or "classdef" appears + // as the first token. + curr_lexer->reading_script_file = true; + + curr_lexer->pop_start_state (); + + curr_lexer->decrement_promptflag (); + + curr_lexer->push_start_state (BLOCK_COMMENT_START); + + return curr_lexer->show_token (INPUT_FILE); + } + +%{ // Help and other command-style functions. %} @@ -491,7 +513,6 @@ curr_lexer->decrement_promptflag (); curr_lexer->push_start_state (BLOCK_COMMENT_START); - } ^{S}*{CCHAR}\{{S}*{NL} {