aboutsummaryrefslogtreecommitdiff
path: root/nomsu.2.peg
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-17 17:25:12 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-17 17:25:28 -0700
commit77a338c1673ae5815ea2124f709cc657da30e8c8 (patch)
tree05465a58eda23f7ca6d914eca817ed18b906f492 /nomsu.2.peg
parent6afa71d67843c2c0624240d90f6ec2a268a5d300 (diff)
Oops, didn't mean to check in smushed_action.
Diffstat (limited to 'nomsu.2.peg')
-rw-r--r--nomsu.2.peg17
1 files changed, 7 insertions, 10 deletions
diff --git a/nomsu.2.peg b/nomsu.2.peg
index 58ae33d..5f9b398 100644
--- a/nomsu.2.peg
+++ b/nomsu.2.peg
@@ -1,7 +1,7 @@
-- Nomsu version 2
file (FileChunks):
{:curr_indent: ' '* :}
- ("#!" (!"nomsu" [^%nl])* "nomsu" %ws+ "-V" %ws* {:version: ([0-9.]+ -> tonumber) :} [^%nl]*)?
+ ("#!" (!"nomsu" [^%nl])* "nomsu" %ws+ "-V" %ws* {:version: [0-9.]+ :} [^%nl]*)?
comment? blank_lines?
(chunk (nl_nodent section_division nl_nodent chunk)*)?
blank_lines?
@@ -16,7 +16,7 @@ nl_nodent: blank_lines nodent
nl_indent: blank_lines {:curr_indent: indent :} (comment nl_nodent)?
comment:
- "#" (({} {~ [^%nl]* ((%nl (!indent %ws* %nl)*) (indent -> '') [^%nl]*)* ~} %userdata) => add_comment)
+ "#" (({} {~ [^%nl]* (%nl+ (indent -> '') [^%nl]*)* ~} %userdata) => add_comment)
eol_comment:
"#" (({} {[^%nl]*} %userdata) => add_comment)
@@ -27,7 +27,7 @@ inline_block (Block):
chunk (Block):
statement (nl_nodent statement)*
indented_block (Block):
- ":" eol nl_indent statement (nl_nodent statement)*
+ ":" eol nl_indent statement (nl_nodent statement)* (%nl (%ws* %nl)* nodent comment)*
statement: (action / expression) (eol / (!! [^%nl]+ -> "Unexpected character while parsing line" !!))
inline_statement: (inline_action / inline_expression)
@@ -62,16 +62,13 @@ index_chain (IndexChain):
-- Actions need either at least 1 word, or at least 2 tokens
inline_action (Action):
!section_division
- ( ((smushed_action / inline_expression) (%ws* (smushed_action / inline_expression / word))+)
- / (word (%ws* (smushed_action / inline_expression / word))*))
+ ( (inline_expression (%ws* (inline_expression / word))+)
+ / (word (%ws* (inline_expression / word))*))
(%ws* inline_block)?
action (Action):
!section_division
- ( ((smushed_action / expression) ((nl_nodent "..")? %ws* (smushed_action / expression / word))+)
- / (word ((nl_nodent "..")? %ws* (smushed_action / expression / word))*))
-smushed_action (Action):
- !section_division
- (index_chain / noindex_inline_expression / word+) (index_chain / noindex_inline_expression / word+ / "(" %ws* ")")+
+ ( (expression ((nl_nodent "..")? %ws* (expression / word))+)
+ / (word ((nl_nodent "..")? %ws* (expression / word))*))
word: !number { %operator_char+ / %ident_char+ }