mirror of
https://github.com/open-simh/simtools.git
synced 2026-01-27 04:31:45 +00:00
Add binary operator '_' for left shift
If the command line option yus to allow the underscore character in symbols is NOT selected, then interpret underscore as a new binary operator meaning to do a left shift of the left side value by the number of bit positions indicated by the right side value. As for the arithmetic operators, both values must be literal (numeric constants or symbols equated to a numeric constant).
This commit is contained in:
committed by
Rhialto The M
parent
e452ac437c
commit
dcdbc02b2e
11
parse.c
11
parse.c
@@ -596,6 +596,7 @@ int parse_float(
|
||||
#define MUL_PREC 1
|
||||
#define AND_PREC 1
|
||||
#define OR_PREC 1
|
||||
#define LSH_PREC 1
|
||||
|
||||
EX_TREE *parse_unary(
|
||||
char *cp); /* Prototype for forward calls */
|
||||
@@ -678,6 +679,16 @@ EX_TREE *parse_binary(
|
||||
leftp = tp;
|
||||
break;
|
||||
|
||||
case '_':
|
||||
if (symbol_allow_underscores || depth >= LSH_PREC)
|
||||
return leftp;
|
||||
|
||||
rightp = parse_binary(cp + 1, term, LSH_PREC);
|
||||
tp = new_ex_bin(EX_LSH, leftp, rightp);
|
||||
tp->cp = rightp->cp;
|
||||
leftp = tp;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Some unknown character. Let caller decide if it's okay. */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user