aboutsummaryrefslogtreecommitdiff
path: root/nomsu.7.peg
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-03-09 15:55:22 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-03-09 15:55:22 -0800
commit3d2db69148a73a7b6ff8c0a4b64419bdc5cf6d3f (patch)
tree4e25476ec30be5c0946e5f2ba748b863aecbb272 /nomsu.7.peg
parentc7483d92b79cc07c603b5b412694dbb69b0eaee7 (diff)
Added support for "{:\n...}" style comprehensions
Diffstat (limited to 'nomsu.7.peg')
-rw-r--r--nomsu.7.peg14
1 files changed, 9 insertions, 5 deletions
diff --git a/nomsu.7.peg b/nomsu.7.peg
index 15f7433..650623c 100644
--- a/nomsu.7.peg
+++ b/nomsu.7.peg
@@ -193,6 +193,7 @@ variable (Var) <- "$" ({ident_char+} / "(" ws* (inline_action / variable) ws* ")
inline_list (List) <-
+ !indented_list
"[" ws* !eol
(inline_list_item (ws* ',' ws* inline_list_item)* (ws* ',')?)? ws*
("]" / eof / (","? (missing_bracket_error / unexpected_code)))
@@ -200,8 +201,9 @@ inline_list_item <- inline_action / inline_expression
indented_list (List) <-
({|
- "[" eol nl_indent
- list_line (nl_nodent list_line)*
+ "[" (
+ (ws* indented_block)
+ / (eol nl_indent list_line (nl_nodent list_line)*))
{:curr_indent: %nil :}
|} -> unpack)
(nl_nodent "]" / eof / missing_bracket_error / unexpected_code)
@@ -211,15 +213,17 @@ list_line <-
inline_dict (Dict) <-
+ !indented_dict
"{" ws* !eol
((inline_action / inline_expression) (ws* ',' ws* (inline_action / inline_expression))*)? ws*
("}" / eof / (","? (missing_brace_error / unexpected_code)))
indented_dict (Dict) <-
({|
- "{" eol nl_indent
- dict_line (nl_nodent dict_line)*
- (%nl (ws* %nl)* nodent (comment / eol / unexpected_code))*
+ "{" (
+ (ws* indented_block)
+ / (eol nl_indent dict_line (nl_nodent dict_line)*
+ (%nl (ws* %nl)* nodent (comment / eol / unexpected_code))*))
{:curr_indent: %nil :}
|} -> unpack)
(nl_nodent "}" / eof / missing_brace_error / unexpected_code)