Improve lexer with better string handling and grouping parens/brackets
This allows the lexer to correctly handle strings like:
${'backslash quote right-curly is \\\'}'}
And also allows users to use the bitwise-or operator to mean bitwise or
simply by enclosing the expression inside parens:
${(0x5432 | 0x8000)}
or by using it in the middle of a dictionary literal:
${ {'foo-val': 0x43 | 0x100, 'bar-val': 0x22 | 0x100}[thing+'-val']}
or inside brackets:
${ big_lookup_dict[index_low | (indexhigh << 3)] }
Basically, only "top level" uses of the vertical bar mean pipe.
(Note that currently, any non-top-level use of the vertical bar in
an expression just results in a syntax error in the generated python,
so no working code is affected by this change)
2 files changed