# HG changeset patch # User jwe # Date 770268817 0 # Node ID e27d10f2e5732a5d24007e5cc7d5764f584c8e59 # Parent be9fcedb17156c76689c524f0739a7f521026157 [project @ 1994-05-30 03:33:37 by jwe] diff --git a/src/lex.h b/src/lex.h --- a/src/lex.h +++ b/src/lex.h @@ -96,6 +96,10 @@ // Return transpose or start a string? extern int quote_is_transpose; +// Nonzero means we thing we are looking at the beginning of a +// function definition. +extern int beginning_of_function; + #endif /* diff --git a/src/lex.l b/src/lex.l --- a/src/lex.l +++ b/src/lex.l @@ -20,7 +20,6 @@ */ -%x COMMENT %x NEW_MATRIX %x HELP_FCN %s TEXT_FCN @@ -57,10 +56,6 @@ #include "parse.h" #include "lex.h" -// Nonzero means we thing we are looking at the beginning of a -// function definition. -static int beginning_of_function = 0; - // Nonzero means we think we are looking at a set command. static int doing_set = 0; @@ -73,6 +68,10 @@ // Return transpose or start a string? int quote_is_transpose = 0; +// Nonzero means we thing we are looking at the beginning of a +// function definition. +int beginning_of_function = 0; + // Nonzero means that we should convert spaces to a comma inside a // matrix definition. static int convert_spaces_to_comma = 1; @@ -121,31 +120,6 @@ EXPON ([DdEe][+-]?{D}+) %% -\% | -\# { - if (beginning_of_function) - { - grab_help_text (); - beginning_of_function = 0; - } - - BEGIN COMMENT; - current_input_column += yyleng; - } - -\n { - BEGIN 0; - current_input_column = 1; - quote_is_transpose = 0; - cant_be_identifier = 0; - convert_spaces_to_comma = 1; - return '\n'; - } - -<> { TOK_RETURN (END_OF_INPUT); } - -.*$ { current_input_column += yyleng; } - [^ \t\n] { yyless (0); BEGIN MATRIX; @@ -539,6 +513,26 @@ BIN_OP_RETURN (':', 0); } +\% | +\# { + if (in_brace_or_paren.empty () && beginning_of_function) + { + grab_help_text (); + beginning_of_function = 0; + } + else + { + int c; + while ((c = yyinput ()) != EOF && c != '\n') + ; // Eat comment. + } + + current_input_column = 1; + + if (! braceflag || beginning_of_function) + return '\n'; + } + \" { BEGIN DQSTRING; } ".**" { BIN_OP_RETURN (EPOW, 0); } ".*" { BIN_OP_RETURN (EMUL, 0); } @@ -1144,9 +1138,8 @@ in_comment = 1; case ' ': case '\t': + default: break; - default: - goto done; } } @@ -1154,20 +1147,10 @@ { warning ("grab_help_text: buffer overflow after caching %d chars", max_len); - - goto done; + break; } } - done: - -// Make sure there's an end of line so yylex sees an end to the -// comment immediately. - - yyunput (c, yytext); - if (c != '\n') - yyunput ('\n', yytext); - help_buf[len] = '\0'; } diff --git a/src/parse.y b/src/parse.y --- a/src/parse.y +++ b/src/parse.y @@ -342,7 +342,10 @@ ; list1 : command - { $$ = new tree_command_list ($1); } + { + beginning_of_function = 0; + $$ = new tree_command_list ($1); + } | list1 comma_nl_sep command { $$ = $1->chain ($3); } | list1 semi_sep command