aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-05-26 13:09:20 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-05-26 13:09:25 -0700
commit0b4a81191ae61d53832d85614f0bb0f2912d7a39 (patch)
tree62a34b551d915f0f2b34be33cda1b0d44dfe8008
parent64294f5cd6ab67236625cf4d645debafc35d0055 (diff)
Minor tidying.
-rw-r--r--nomsu.lua2
-rwxr-xr-xnomsu.moon2
-rw-r--r--nomsu.peg21
3 files changed, 12 insertions, 13 deletions
diff --git a/nomsu.lua b/nomsu.lua
index d05a5e6..fcc3941 100644
--- a/nomsu.lua
+++ b/nomsu.lua
@@ -193,7 +193,7 @@ do
end)
_with_0.dedent = P(function(self, start)
local nodent = lpeg.userdata.indent_stack[#lpeg.userdata.indent_stack]
- local spaces = self:match("[ ]*", start)
+ local spaces = self:match("^[ ]*", start)
if #spaces <= #nodent - 4 then
remove(lpeg.userdata.indent_stack)
return start
diff --git a/nomsu.moon b/nomsu.moon
index 5890592..8fef96c 100755
--- a/nomsu.moon
+++ b/nomsu.moon
@@ -166,7 +166,7 @@ NOMSU_DEFS = with {}
-- stack minus 4, this pattern matches and pops off the top of the stack exactly once.
.dedent = P (start)=>
nodent = lpeg.userdata.indent_stack[#lpeg.userdata.indent_stack]
- spaces = @match("[ ]*", start)
+ spaces = @match("^[ ]*", start)
if #spaces <= #nodent-4
remove(lpeg.userdata.indent_stack)
return start
diff --git a/nomsu.peg b/nomsu.peg
index b063ea0..459eb32 100644
--- a/nomsu.peg
+++ b/nomsu.peg
@@ -7,20 +7,13 @@ file:
shebang: "#!" [^%nl]* (!. / %nl)
-statement: (action / expression) (eol / (({} ([^%nl]* -> "Error while parsing line")) => error))
-inline_statement: inline_action / inline_expression
-
inline_block (Block):
inline_statement (%ws* ";" %ws* inline_statement)+
block (Block):
statement (nodent (statement / (({} ([^%nl]* -> "Error while parsing block line")) => error)))+
-inline_nomsu (EscapedNomsu): "\" noindex_inline_expression
-indented_nomsu (EscapedNomsu):
- "\" (noindex_inline_expression / (":" %ws* (inline_block / inline_action / inline_expression) eol) / indented_expression)
-
-index_chain (IndexChain):
- noindex_inline_expression ("." (text_word / noindex_inline_expression))+
+statement: (action / expression) (eol / (({} ([^%nl]* -> "Error while parsing line")) => error))
+inline_statement: inline_action / inline_expression
noindex_inline_expression:
number / variable / inline_text / inline_list / inline_dict / inline_nomsu
@@ -31,7 +24,6 @@ noindex_inline_expression:
/ (({} ([^%nl]* -> 'Error while parsing subexpression')) => error)
)
)
-
inline_expression:
index_chain / noindex_inline_expression
indented_expression:
@@ -43,7 +35,14 @@ indented_expression:
expression:
inline_expression / (":" %ws* (inline_block / inline_action / inline_expression) eol) / indented_expression
--- Function calls need at least one word in them
+inline_nomsu (EscapedNomsu): "\" inline_expression
+indented_nomsu (EscapedNomsu):
+ "\" (noindex_inline_expression / (":" %ws* (inline_block / inline_action / inline_expression) eol) / indented_expression)
+
+index_chain (IndexChain):
+ noindex_inline_expression ("." (text_word / noindex_inline_expression))+
+
+-- Actions need at least one word in them
inline_action (Action):
(inline_expression %ws*)* word (%ws* (inline_expression / word))*
(%ws* ":" %ws* (inline_block / inline_action / inline_expression))?