Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
eight trigrams sixty-four palms
Browse files Browse the repository at this point in the history
  • Loading branch information
rjdbcm committed Oct 26, 2021
1 parent c5debf7 commit 6441b8e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
57 changes: 57 additions & 0 deletions Aspidites/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@
list_count = Forward()
list_append = Forward()
list_remove = Forward()
dict_items = Forward()
dict_keys = Forward()
dict_vals = Forward()
dict_discard = Forward()
dict_update = Forward()
dict_copy = Forward()
dict_remove = Forward()
set_discard = Forward()
set_update = Forward()
set_copy = Forward()
set_remove = Forward()
set_str = Forward()
set_str_evolver = Forward()
dict_str = Forward()
Expand Down Expand Up @@ -95,10 +106,21 @@
list_item = ( # Precedence important!!!
slice_str
| list_index
| dict_items
| dict_keys
| list_count
| dict_vals
| dict_discard
| set_discard
# | list_set
| list_append
| dict_update
| set_update
| dict_copy
| set_copy
| list_remove
| dict_remove
| set_remove
| comp_expr # Expressions
| arith_expr
| identifier
Expand Down Expand Up @@ -142,6 +164,41 @@
replaceWith('.remove')) + list_item).setParseAction(
cvt_list_index)

dict_items <<= ((identifier | list_str | slice_str) + index_items.setParseAction(replaceWith('.items()')))
dict_keys <<= ((identifier | list_str | slice_str) + keys.setParseAction(replaceWith('.keys()')))
dict_vals <<= ((identifier | list_str | slice_str) + count_vals.setParseAction(replaceWith('.values()')))
dict_discard <<= (
(identifier | list_str | slice_str) + discard.setParseAction(
replaceWith('.discard')) + list_item).setParseAction(
cvt_list_index)
dict_update <<= (
(identifier | list_str | slice_str) + append_update.setParseAction(
replaceWith('.append')) + list_item).setParseAction(
cvt_list_index)

dict_copy <<= ((identifier | list_str | slice_str) + copy.setParseAction(replaceWith('.copy()')))

dict_remove <<= (
(identifier | list_str | slice_str) + remove.setParseAction(
replaceWith('.remove')) + list_item).setParseAction(
cvt_list_index)

set_discard <<= (
(identifier | list_str | slice_str) + discard.setParseAction(
replaceWith('.discard')) + list_item).setParseAction(
cvt_list_index)
set_update <<= (
(identifier | list_str | slice_str) + append_update.setParseAction(
replaceWith('.append')) + list_item).setParseAction(
cvt_list_index)

set_copy <<= ((identifier | list_str | slice_str) + copy.setParseAction(replaceWith('.copy()')))

set_remove <<= (
(identifier | list_str | slice_str) + remove.setParseAction(
replaceWith('.remove')) + list_item).setParseAction(
cvt_list_index)

lit_ellipse = Literal("...").setParseAction(replaceWith('...'))
assignable = func_call | list_item | lit_ellipse

Expand Down
2 changes: 2 additions & 0 deletions Aspidites/parser/reserved.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
keys = Literal("[@]")
count_vals = Literal("[#]")
set_add = Literal("[$]")
discard = Literal("[%]")
copy = Literal("[&]")
append_update = Literal("[^]")
remove = Literal("[*]")
match_none = Literal("(!)").setParseAction(replaceWith('__match'))
Expand Down

0 comments on commit 6441b8e

Please sign in to comment.