From af9dc0702568dc45b8809523dde760bb99aafbcb Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 16 May 2018 15:44:07 -0700 Subject: 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. --- nomsu.peg | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'nomsu.peg') 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 -- cgit v1.2.3