Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[parser] Refactor parser to use tokenization. #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

V-FEXrt
Copy link

@V-FEXrt V-FEXrt commented Nov 9, 2021

Summary

Replaces the parser with a token based parser. This allows for easier changes and additions to the language. It allow allows for easy fixes for the "comma in string" bug. This change also fixes small typos found in other parts of the firmware

Features

For the most part this should be a drop in replacement for the previous parser. The only known changes are listed below

  • Commas are now allowed in strings
  • [COMMA] => , substitution has been removed as it is redundant now
  • [RETURN] and [SINGLE QUOTE] have been added as substitutions
    • It is now trivial to add any other substitution in the code
  • A keycode can be directly specifed via hex R0, K0: 0x01+0x02+0xFF
  • A HUGE number of error messages were added (and tested) so when an invalid key map is uploaded it should be easier to figure out what/where when wrong

Testing

This feature was not tested on real hardware (I haven't build the keeb yet :) ) but the code maintains the previous implementations public interface (via parse_layer_definition()) and the language itself is thoroughly tested to ensure correctness

The test can be ran with python3 Firmware/parser_test.py or time python3 Firmware/parser_test.py for timing stats

Refactors parser to process source string as token list.
Fixes a number of small bugs, adds a couple small features, and
adds a bunch of test cases to keep the language running
import time
import supervisor
Copy link
Author

@V-FEXrt V-FEXrt Nov 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it is actually safe to delete these here. I needed to remove them to run the test code on my host machine. Removing them didn't seem to break anything but that might not be the case on the real keyboard and needs to be tested/confirmed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant