Mercurial > octave
diff src/lex.l @ 1276:cbdf7db98554
[project @ 1995-04-24 15:31:24 by jwe]
author | jwe |
---|---|
date | Mon, 24 Apr 1995 15:31:24 +0000 |
parents | fd3ed8834b77 |
children | 4acabfbdd381 |
line wrap: on
line diff
--- a/src/lex.l Fri Apr 21 19:59:03 1995 +0000 +++ b/src/lex.l Mon Apr 24 15:31:24 1995 +0000 @@ -142,8 +142,6 @@ NOTEQ ((~=)|(!=)|(<>)) POW ((\*\*)|(\^)) EPOW (\.{POW}) -PLUS ((\+)|(\.\+)) -MINUS ((\-)|(\.\-)) NOT ((\~)|(\!)) IDENT ([_a-zA-Z][_a-zA-Z0-9]*) EXPON ([DdEe][+-]?{D}+) @@ -503,6 +501,8 @@ // Other operators. %} +".+" { BIN_OP_RETURN (EPLUS, 0); } +".-" { BIN_OP_RETURN (EMINUS, 0); } ".*" { BIN_OP_RETURN (EMUL, 0); } "./" { BIN_OP_RETURN (EDIV, 0); } ".\\" { BIN_OP_RETURN (ELEFTDIV, 0); } @@ -548,13 +548,13 @@ BIN_OP_RETURN (EXPR_NOT, 0); } -{PLUS} { +"+" { if (plotting && ! in_plot_range) past_plot_range = 1; BIN_OP_RETURN ('+', 0); } -{MINUS} { +"-" { if (plotting && ! in_plot_range) past_plot_range = 1; BIN_OP_RETURN ('-', 0); @@ -1239,96 +1239,49 @@ // Try to determine if the next token should be treated as a binary // operator. This is even uglier, but it also seems to do the right -// thing. +// thing. Note that it is only necessary to check the spacing for `+' +// and `-', since those are the only tokens that can appear as unary +// ops too. static int next_token_is_bin_op (int spc_prev, char *yytext) { int bin_op = 0; - int spc_next = 0; int c0 = yyinput (); - int c1 = yyinput (); switch (c0) { case '+': case '-': + { + int c1 = yyinput (); + yyunput (c1, yytext); + int spc_next = (c1 == ' ' || c1 == '\t'); + bin_op = looks_like_bin_op (spc_prev, spc_next); + } + break; + case '/': case ':': case '\\': case '^': - spc_next = (c1 == ' ' || c1 == '\t'); - break; - case '&': - if (c1 == '&') - spc_next = next_char_is_space (); - else - spc_next = (c1 == ' ' || c1 == '\t'); - break; - case '*': - if (c1 == '*') - spc_next = next_char_is_space (); - else - spc_next = (c1 == ' ' || c1 == '\t'); - break; - case '|': - if (c1 == '|') - spc_next = next_char_is_space (); - else - spc_next = (c1 == ' ' || c1 == '\t'); - break; - case '<': - if (c1 == '=' || c1 == '>') - spc_next = next_char_is_space (); - else - spc_next = (c1 == ' ' || c1 == '\t'); - break; - case '>': - if (c1 == '=') - spc_next = next_char_is_space (); - else - spc_next = (c1 == ' ' || c1 == '\t'); - break; - case '~': case '!': case '=': - if (c1 == '=') - spc_next = next_char_is_space (); - else - goto done; - break; - case '.': - if (c1 == '*') - { - int c2 = yyinput (); - if (c2 == '*') - spc_next = next_char_is_space (); - else - spc_next = (c2 == ' ' || c2 == '\t'); - yyunput (c2, yytext); - } - else if (c1 == '/' || c1 == '\\' || c1 == '^') - spc_next = next_char_is_space (); - else - goto done; + bin_op = 1; break; default: - goto done; + break; } - bin_op = looks_like_bin_op (spc_prev, spc_next); - - done: - yyunput (c1, yytext); yyunput (c0, yytext); return bin_op;