aboutsummaryrefslogtreecommitdiff
path: root/nomsu.peg
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-05-16 15:44:07 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-05-16 15:45:59 -0700
commitaf9dc0702568dc45b8809523dde760bb99aafbcb (patch)
tree8334bab3a859aaa12ae5cb9f78b92f2eea5477b4 /nomsu.peg
parent3ffeaf1f5dbf3e225dc536066d0fedda3f38ac70 (diff)
Converted DictEntry to be an actual tree, instead of a pseudo-tree, made 'parse % as %'
generate lua code with already-substituted tree literals instead of reparsing and substituting at parse time, and made some general optimizations.
Diffstat (limited to 'nomsu.peg')
-rw-r--r--nomsu.peg11
1 files changed, 6 insertions, 5 deletions
diff --git a/nomsu.peg b/nomsu.peg
index 4ebf6c2..e7c8a7f 100644
--- a/nomsu.peg
+++ b/nomsu.peg
@@ -107,7 +107,7 @@ inline_list_item: inline_block / inline_action / inline_expression
inline_dict (Dict):
!('{..}')
- "{" %ws* ({| (inline_dict_item (comma inline_dict_item)*)? |} -> Tuple) %ws*
+ "{" %ws* ({| (inline_dict_entry (comma inline_dict_entry)*)? |} -> Tuple) %ws*
("}"
/ (({} (%ws* comma? (!. / &%nl)->"Failed to find a closing } on the same line")) => error)
/ (({} ([^%nl]*->"Error while parsing dictionary")) => error))
@@ -117,10 +117,11 @@ indented_dict (Dict):
|} -> Tuple)
(dedent / (({} (non_dedent_error -> "Error while parsing dict")) => error))
dict_line:
- ((dict_key %ws* ":" %ws* (action / expression)) -> DictEntry !comma)
- / (inline_dict_item (comma dict_line?)?)
-inline_dict_item:
- ((dict_key %ws* (":" %ws* (inline_block / inline_action / inline_expression)?)?)-> DictEntry)
+ (dict_entry !comma) / (inline_dict_entry (comma dict_line?)?)
+dict_entry(DictEntry):
+ {| dict_key %ws* ":" %ws* (action / expression) |} -> Tuple
+inline_dict_entry(DictEntry):
+ {| dict_key %ws* (":" %ws* (inline_block / inline_action / inline_expression)?) |} -> Tuple
dict_key:
text_word / inline_expression