**diff options**

author | Alexis Lockwood | 2021-07-08 19:55:56 -0600 |
---|---|---|

committer | Alexis Lockwood | 2021-07-08 19:55:56 -0600 |

commit | 50651dae90976f223dfe58dc941c188f684cd40e (patch) | |

tree | dff2ae65a9514fe0158539fb391afeabe4503150 /README.md | |

parent | 6952ba1cc69282636c3b5f372aa62d2fc6375163 (diff) |

Add bitshift operators

Diffstat (limited to 'README.md')

-rw-r--r-- | README.md | 32 |

1 files changed, 31 insertions, 1 deletions

@@ -107,7 +107,6 @@ The following things use pool entries: - All keywords (except block definers like loops) should cleanly stop parsing at the first keyword they don't recognize. This will enable things like IF...THEN...ELSE -- Add leftshift, rightshift operators - It'd be cool if `ls_minify` could access full idents beyond `LS_IDENT_LEN`; the number of possible minified six-letter idents is enormous (about 52 billion if I did the math right) so if you're always going to minify idents @@ -254,6 +253,37 @@ COMn [speed] [parity] [data] FILE device /path/to/file ``` +## Operators + +The following operators are supported, with higher precedence values binding +more tightly: + +| **OPER** | **PREC** | **OPERATION ** | +|:---------:|---------:|----------------| +| `ABS n` | 13 | Absolute value of n | +| `NOT n` | 13 | Bitwise inverse of n | +| `-n` | 13 | Negation of n | +| `x * y` | 12 | Multiplication of x by y | +| `x / y` | 12 | Division of x by y | +| `x % y` | 12 | Remainder of x divided by y | +| `x + y` | 11 | Addition of x and y | +| `x - y` | 11 | Subtraction from x of y | +| `x << y` | 10 | Shift of x left by y bits. If y < 0, shift right. | +| `x >> y` | 10 | Shift of x right by y bits. If y < 0, shift left. | +| `x < y` | 9 | Comparison of x < y | +| `x > y` | 9 | Comparison of x > y | +| `x <= y` | 9 | Comparison of x ≤ y | +| `x >= y` | 9 | Comparison of x ≥ y | +| `x = y` | 8 | Comparison of x = y | +| `x <> y` | 8 | Comparison of x ≠ y | +| `x and y` | 7 | Bitwise AND of x with y | +| `x xor y` | 7 | Bitwise XOR of x with y | +| `x or y` | 7 | Bitwise OR of x with y | +| `x eqv y` | 7 | Bitwise equivalency of x and y (`not (x xor y)`) | +| `x imp y` | 7 | Bitwise implication of x and y (`not (x and not y`) | + +The operator precedence is based on that of C. + ## Statements (More verbose documentation is provided below, when useful) |