🪲 Highlight pressed keyword when expected key is a number key
Fixes #5757
The highlighting grammar for Level 13 explicitly allowed for Numbers when using the pressed keyword, as part of the EqualityCheck rule. Subsequent grammars (Level 14-18) omitted Numbers since the rule was split out into a dedicated PressedCheck rule. This PR reintroduces Numbers in the pressed grammar rule to fix the highlighting when expecting a number key press.
How to test
Follow these steps to verify this PR works as intended:
- Visit http://localhost:8080/hedy/14#debugging
- Paste in the following code:
if 1 is pressed
print 'one'
else
print 'waiting for second key'
if x is pressed
print 'x'
else
print '?'
- See that
pressedis highlighted orange in bothifconditions - Visit http://localhost:8080/hedy/17#debugging
- Paste in the following code:
stop = False
key = 'x'
while stop == False:
if 1 is pressed:
print 'one'
elif a is pressed:
print 'a'
elif key is pressed:
print 'x'
stop = True
else:
print '?'
- See that
pressedis highlighted orange in all theifandelifconditions
Checklist
- [x] Contains one of the PR categories in the name
- [x] Describes changes in the format above
- [x] Links to an existing issue or discussion
- [x] Has a "How to test" section
Thanks for the fix @brianpeiris!
We are about to make some large changes to the grammar (see https://github.com/hedyorg/hedy/pull/6329) which will then also impact the highlighter, so we need to keep this PR for a little while until @jpelay is ready with the highlighter.
@jpelay Can you take this into account when updating the highlighter?