Created
November 5, 2020 12:27
-
-
Save rntz/1d366d1dc62d6c9aa532405e1828ecb1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mod.capture(rule="<user.letter> | <user.number_key> | <user.symbol_key> | ship <user.letter>") | |
def char(m) -> str: | |
"""A single character.""" | |
if m[0] == "ship": return m.letter.upper() | |
return str(m) | |
@mod.capture(rule="<user.char_chunk>+") | |
def chars(m) -> str: | |
"""A sequence of characters, spelled out.""" | |
return "".join(m.char_chunk_list) | |
@mod.capture( | |
rule="<user.letter> | <user.number_key> | <user.symbol_key> | ship <user.letters> [over|sunk]") | |
def char_chunk(m) -> str: | |
"One chunk of a character sequence." | |
try: return m.letters.upper() | |
except AttributeError: return str(m) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ~.37s to compile!: ~1.43s without, ~1.8s with | |
leap: key(ctrl-:) | |
leap anywhere: key(alt-g 0) | |
leap$: key(alt-g 0) | |
leap <user.chars>$: | |
key(ctrl-:) | |
insert(chars) | |
key(enter) | |
leap word <user.word>$: | |
key(ctrl-:) | |
insert(word) | |
key(enter) | |
leap (say|phrase) <user.text>$: | |
key(ctrl-:) | |
insert(text) | |
key(enter) | |
# TODO: handle chained formatters | |
leap <user.format_text>$: | |
key(ctrl-:) | |
insert(format_text) | |
key(enter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment