xls
xls copied to clipboard
dslx_reference improvements
I'm going to record some things I noticed that need improvement:
- [x] In the Precedence table, mis-rendered
||and|- https://github.com/google/xls/pull/1292
- [x] In the Precedence table,
>>>should not be there because it does not exist- https://github.com/google/xls/pull/1292
- [x] concatenate operator is missing from Precedence. I believe it's the same precedence as
+and-(confirmed below)- https://github.com/google/xls/pull/1298
- [ ]
..the range expression is missing from Precedence. I believe it's lower than everything else (lower than boolean or) - [ ]
/and%are in the table but not mentioned in binary expressions. Both operators are worth describing their precise semantics (e.g. is%the remainder or the modulo function?) - [ ]
asis never introduced as a binary expression or operator. It looks like this section is aboutas. But I think the current way things are organized and described could be improved. E.g.,asis clearly a binary expression as it takes two arguments. Why not make it a subsection under Binary Expressions? This suggestion also applies comparison operators and concatenation operator. Anything that's in the precedence table should probably be grouped as a unary or binary expression/operator. - [x]
(...), the grouping expression, is never is never mentioned as an expression, nor is its precedence mentioned (I assume it's the highest precedence?)- https://github.com/google/xls/pull/1298
- [ ]
trueandfalseare never introduced as a bit type - [ ] 'expression statements' are never documented. E.g.
Foo(); - [ ]
letexpressions are not expressions. They are statements. In the past they were expressions but they aren't now. Update the wording and move to the statement section.
Proof that concatenation is the same precedence as + - and also left associative.
assert_eq(u4:0b1 ++ u1:0b1 + u5:0b1, u5:0b100);
assert_eq(u4:0b1 + u4:0b1 ++ u1:0b1, u5:0b101);
assert_eq(u4:0b1 - u4:0b1 ++ u1:0b1, u5:0b1);
assert_eq(u4:0b1 ++ u1:0b1 - u5:0b1, u5:0b10);
Proof that let is not an expression:
0036: assert_eq(let x=u32:6; x, u32:6);
~~~~~~~~~~~~~~~~~~^-^ ParseError: Expected start of an expression; got: keyword:let