aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-10-30 20:32:14 -0700
committerBruce Hill <bruce@bruce-hill.com>2018-10-30 20:32:49 -0700
commite7e84c9eda38c930f5475301de4a449dcf59e8b6 (patch)
treeb0d3890516170ca5aee0269aace10121b97a7593
parentfdf7a537c8ae13fc7ccb32278e5e364a52005443 (diff)
Fix for compiler not parenthesizing method targets, fix for parser not
recognizing \ line continuation, and improvements to upgrade tool API.
-rw-r--r--nomsu.4.peg6
-rw-r--r--nomsu_compiler.lua6
-rw-r--r--nomsu_compiler.moon5
-rwxr-xr-xtools/upgrade.nom27
4 files changed, 29 insertions, 15 deletions
diff --git a/nomsu.4.peg b/nomsu.4.peg
index 06bfead..a3677c6 100644
--- a/nomsu.4.peg
+++ b/nomsu.4.peg
@@ -121,9 +121,9 @@ inline_action (Action):
inline_arg: inline_expression / inline_block
action (Action):
!section_division
- ({:target: arg :} (eol nl_nodent "..")? ws* "::" (eol nl_nodent "..")? ws*)?
- ( (arg ((eol nl_nodent "..")? ws* (arg / word))+)
- / (word ((eol nl_nodent "..")? ws* (arg / word))*))
+ ({:target: arg :} ((ws* "\")? eol nl_nodent "..")? ws* "::" ((ws* "\")? eol nl_nodent "..")? ws*)?
+ ( (arg (((ws* "\")? eol nl_nodent "..")? ws* (arg / word))+)
+ / (word (((ws* "\")? eol nl_nodent "..")? ws* (arg / word))*))
arg: expression / inline_block / indented_block
word: !number { operator_char+ / ident_char+ }
diff --git a/nomsu_compiler.lua b/nomsu_compiler.lua
index 7aa117c..f9ba314 100644
--- a/nomsu_compiler.lua
+++ b/nomsu_compiler.lua
@@ -1005,7 +1005,11 @@ do
elseif "Action" == _exp_0 then
local nomsu = NomsuCode(tree.source)
if tree.target then
- nomsu:append(self:tree_to_inline_nomsu(tree.target), "::")
+ local inline_target = self:tree_to_inline_nomsu(tree.target)
+ if tree.target.type == "Action" then
+ inline_target:parenthesize()
+ end
+ nomsu:append(inline_target, "::")
end
for i, bit in ipairs(tree) do
if type(bit) == "string" then
diff --git a/nomsu_compiler.moon b/nomsu_compiler.moon
index 387c901..1106382 100644
--- a/nomsu_compiler.moon
+++ b/nomsu_compiler.moon
@@ -631,7 +631,10 @@ with NomsuCompiler
when "Action"
nomsu = NomsuCode(tree.source)
if tree.target
- nomsu\append @tree_to_inline_nomsu(tree.target), "::"
+ inline_target = @tree_to_inline_nomsu(tree.target)
+ if tree.target.type == "Action"
+ inline_target\parenthesize!
+ nomsu\append inline_target, "::"
for i,bit in ipairs tree
if type(bit) == "string"
clump_words = (type(tree[i-1]) == 'string' and is_operator(bit) != is_operator(tree[i-1]))
diff --git a/tools/upgrade.nom b/tools/upgrade.nom
index cd3fbbb..4e03945 100755
--- a/tools/upgrade.nom
+++ b/tools/upgrade.nom
@@ -10,22 +10,29 @@ use "lib/os.nom"
%args = (command line args)
%inplace = (no)
-if (%args.1 is "-i"):
- %inplace = (yes)
- %args::remove index 1
-
-if (%args.1 is "-t"):
- use "lib/consolecolor.nom"
- %test = (yes)
- %args::remove index 1
+%version = (Nomsu version)
+repeat:
+ if %args.1 is:
+ "-i":
+ %inplace = (yes)
+ %args::remove index 1
+ "-t":
+ use "lib/consolecolor.nom"
+ %test = (yes)
+ %args::remove index 1
+ "-V":
+ %version = %args.2
+ %args::remove index 1
+ %args::remove index 1
+ else: stop
for %path in %args:
for file %filename in %path:
unless (%filename::matches "%.nom$"): do next %filename
%tree = (parse (read file %filename) from %filename)
- %uptree = (%tree upgraded)
+ %uptree = (%tree upgraded to %version)
%text = "\
- ..#!/usr/bin/env nomsu -V\(Nomsu version)
+ ..#!/usr/bin/env nomsu -V\%version
\(%uptree as nomsu)"
if: