Mercurial > hg > octave-lojdl
changeset 428:fa0453b25410
[project @ 1994-05-25 01:06:28 by jwe]
author | jwe |
---|---|
date | Wed, 25 May 1994 01:06:28 +0000 |
parents | a222980dfa55 |
children | f23cd37a0013 |
files | src/lex.l src/parse.y src/pt-base.h src/pt-const.h |
diffstat | 4 files changed, 29 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lex.l +++ b/src/lex.l @@ -29,6 +29,7 @@ %s MATRIX %{ +#define SHORT_CIRCUIT_LOGICALS 1 #ifdef HAVE_CONFIG_H #include "config.h" @@ -543,8 +544,20 @@ "!=" { BIN_OP_RETURN (EXPR_NE, 0); } "<>" { BIN_OP_RETURN (EXPR_NE, 0); } ">=" { BIN_OP_RETURN (EXPR_GE, 0); } -"||" { BIN_OP_RETURN (EXPR_OR, 0); } -"&&" { BIN_OP_RETURN (EXPR_AND, 0); } +"||" { +#ifdef SHORT_CIRCUIT_LOGICALS + BIN_OP_RETURN (EXPR_OR_OR, 0); +#else + BIN_OP_RETURN (EXPR_OR, 0); +#endif + } +"&&" { +#ifdef SHORT_CIRCUIT_LOGICALS + BIN_OP_RETURN (EXPR_AND_AND, 0); +#else + BIN_OP_RETURN (EXPR_AND, 0); +#endif + } "|" { BIN_OP_RETURN (EXPR_OR, 0); } "&" { BIN_OP_RETURN (EXPR_AND, 0); } "!" {
--- a/src/parse.y +++ b/src/parse.y @@ -165,6 +165,7 @@ // Tokens with line and column information. %token <tok_val> '=' ':' '-' '+' '*' '/' +%token <tok_val> EXPR_AND_AND EXPR_OR_OR %token <tok_val> EXPR_AND EXPR_OR EXPR_NOT %token <tok_val> EXPR_LT EXPR_LE EXPR_EQ EXPR_NE EXPR_GE EXPR_GT %token <tok_val> LEFTDIV EMUL EDIV ELEFTDIV QUOTE TRANSPOSE @@ -210,6 +211,7 @@ // Precedence and associativity. %left ';' ',' '\n' %right '=' +%left EXPR_AND_AND EXPR_OR_OR %left EXPR_AND EXPR_OR %left EXPR_LT EXPR_LE EXPR_EQ EXPR_NE EXPR_GE EXPR_GT %left ':' @@ -751,6 +753,12 @@ | simple_expr EXPR_NE simple_expr { $$ = new tree_binary_expression ($1, $3, tree::cmp_ne, $2->line (), $2->column ()); } + | simple_expr EXPR_AND_AND simple_expr + { $$ = new tree_binary_expression + ($1, $3, tree::and_and, $2->line (), $2->column ()); } + | simple_expr EXPR_OR_OR simple_expr + { $$ = new tree_binary_expression + ($1, $3, tree::or_or, $2->line (), $2->column ()); } | simple_expr EXPR_AND simple_expr { $$ = new tree_binary_expression ($1, $3, tree::and, $2->line (), $2->column ()); }
--- a/src/pt-base.h +++ b/src/pt-base.h @@ -77,6 +77,8 @@ cmp_ge, cmp_gt, cmp_ne, + and_and, + or_or, and, or, not,
--- a/src/pt-const.h +++ b/src/pt-const.h @@ -465,6 +465,8 @@ tree_constant convert_to_str (void); + int is_true (void) const; + tree_constant cumprod (void) const; tree_constant cumsum (void) const; tree_constant prod (void) const; @@ -721,6 +723,8 @@ tree_constant convert_to_str (void) { return rep->convert_to_str (); } + int is_true (void) const { return rep->is_true (); } + tree_constant cumprod (void) const { return rep->cumprod (); } tree_constant cumsum (void) const { return rep->cumsum (); } tree_constant prod (void) const { return rep->prod (); }