diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2017-11-14 02:51:27 -0500 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2017-11-14 02:51:27 -0500 |
| commit | 6ab0fb837e5b1cc40002037e2ed15505f99cbbe3 (patch) | |
| tree | d7fbc91d82588af74b5f4a931c7ba3344f63ab41 /tests/forms.py | |
| parent | 10dad94b84ae0a41b1ff03d6d705732834958efb (diff) | |
Macro expander.
This includes a fairly complete quasiquote system, and a complete rework of the expander.
Diffstat (limited to 'tests/forms.py')
| -rw-r--r-- | tests/forms.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/forms.py b/tests/forms.py index 1a49636..7ea216f 100644 --- a/tests/forms.py +++ b/tests/forms.py @@ -1,6 +1,7 @@ from hypothesis.strategies import integers, decimals as hypo_decimals, booleans, characters, text, tuples, lists as hypo_lists, just, one_of from hypothesis.strategies import deferred, recursive +from actinide import tokenizer as t from actinide.symbol_table import * from actinide.types import * @@ -37,7 +38,7 @@ def strings(): # Generates any character legal in a symbol, which cannot be part of some other # kind of atom. def symbol_characters(): - return characters(blacklist_characters='01234567890#. \t\n();"') + return characters(blacklist_characters='01234567890#' + t.whitespace + t.parens + t.quotes + t.string_delim + t.comment_delim) # Generates symbols guaranteed not to conflict with other kinds of literal. This # is a subset of the legal symbols. @@ -45,6 +46,15 @@ def symbols(): return text(symbol_characters(), min_size=1)\ .map(lambda item: symbol_table[item]) +def quoted_forms(): + return tuples( + one_of( + symbol_table[q] + for q in ['quote', 'quasiquote', 'unquote', 'unquote-splicing'] + ), + deferred(lambda: forms), + ).map(lambda elems: list(*elems)) + # Generates atoms. def atoms(): return one_of( |
