diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-01-11 14:14:02 +0000 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-01-12 09:40:55 +0000 |
commit | 7c654b719d2c186bd645a560525dd3e9c86d15cd (patch) | |
tree | ca0796d3a81e868c0c293de82474d3ae50af5792 /gdb/f-exp.y | |
parent | e998918e9890d5efc0270ad6f140e098eaf0081f (diff) | |
download | gdb-7c654b719d2c186bd645a560525dd3e9c86d15cd.zip gdb-7c654b719d2c186bd645a560525dd3e9c86d15cd.tar.gz gdb-7c654b719d2c186bd645a560525dd3e9c86d15cd.tar.bz2 |
gdb/fortran: add symbol base comparison operators
Fortran supports symbol based comparison operators as well as the
classic text based comparison operators, so we have:
Text | Symbol
Operator | Operator
---------|---------
.eq. | ==
.ne. | /=
.le. | <=
.ge. | >=
.gt. | >
.lt. | <
This commit adds the symbol based operators as well as some tests.
gdb/ChangeLog:
* f-exp.y (dot_ops): Rename to...
(fortran_operators): ...this. Add a header comment. Add symbol
based operators.
(yylex): Update to use fortran_operators not dot_ops. Remove
special handling for '**', this is now included in
fortran_operators.
gdb/testsuite/ChangeLog:
* gdb.fortran/dot-ops.exp: Add new tests.
Diffstat (limited to 'gdb/f-exp.y')
-rw-r--r-- | gdb/f-exp.y | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/gdb/f-exp.y b/gdb/f-exp.y index e0f1b1f..3b0f23d 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -979,7 +979,9 @@ struct token bool case_sensitive; }; -static const struct token dot_ops[] = +/* List of Fortran operators. */ + +static const struct token fortran_operators[] = { { ".and.", BOOL_AND, BINOP_END, false }, { ".or.", BOOL_OR, BINOP_END, false }, @@ -987,11 +989,18 @@ static const struct token dot_ops[] = { ".eq.", EQUAL, BINOP_END, false }, { ".eqv.", EQUAL, BINOP_END, false }, { ".neqv.", NOTEQUAL, BINOP_END, false }, + { "==", EQUAL, BINOP_END, false }, { ".ne.", NOTEQUAL, BINOP_END, false }, + { "/=", NOTEQUAL, BINOP_END, false }, { ".le.", LEQ, BINOP_END, false }, + { "<=", LEQ, BINOP_END, false }, { ".ge.", GEQ, BINOP_END, false }, + { ">=", GEQ, BINOP_END, false }, { ".gt.", GREATERTHAN, BINOP_END, false }, + { ">", GREATERTHAN, BINOP_END, false }, { ".lt.", LESSTHAN, BINOP_END, false }, + { "<", LESSTHAN, BINOP_END, false }, + { "**", STARSTAR, BINOP_EXP, false }, }; /* Holds the Fortran representation of a boolean, and the integer value we @@ -1163,26 +1172,17 @@ yylex (void) } } - /* See if it is a special .foo. operator. */ - for (int i = 0; i < ARRAY_SIZE (dot_ops); i++) - if (strncasecmp (tokstart, dot_ops[i].oper, - strlen (dot_ops[i].oper)) == 0) + /* See if it is a Fortran operator. */ + for (int i = 0; i < ARRAY_SIZE (fortran_operators); i++) + if (strncasecmp (tokstart, fortran_operators[i].oper, + strlen (fortran_operators[i].oper)) == 0) { - gdb_assert (!dot_ops[i].case_sensitive); - pstate->lexptr += strlen (dot_ops[i].oper); - yylval.opcode = dot_ops[i].opcode; - return dot_ops[i].token; + gdb_assert (!fortran_operators[i].case_sensitive); + pstate->lexptr += strlen (fortran_operators[i].oper); + yylval.opcode = fortran_operators[i].opcode; + return fortran_operators[i].token; } - /* See if it is an exponentiation operator. */ - - if (strncmp (tokstart, "**", 2) == 0) - { - pstate->lexptr += 2; - yylval.opcode = BINOP_EXP; - return STARSTAR; - } - switch (c = *tokstart) { case 0: |