aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-01-11 01:09:26 -0800
committerBruce Hill <bitbucket@bruce-hill.com>2018-01-11 01:09:26 -0800
commit6f4b67632a544780438110bb11e5122448e24881 (patch)
tree3549eb211df19ff6870d5cf63ad1c25d1880040b
parentc0333ca31532f14ec8ebd841a5f68b2f35e9cc80 (diff)
Renamed String -> Text
-rw-r--r--lib/operators.nom2
-rw-r--r--lib/utils.nom4
-rw-r--r--lib/utils2.nom4
-rw-r--r--nomsu.lua10
-rwxr-xr-xnomsu.moon10
-rw-r--r--nomsu.peg18
6 files changed, 24 insertions, 24 deletions
diff --git a/lib/operators.nom b/lib/operators.nom
index 7eada51..05656ea 100644
--- a/lib/operators.nom
+++ b/lib/operators.nom
@@ -24,7 +24,7 @@ compile [..]
local condition = nomsu:tree_to_lua(\%condition).expr;
local when_true = nomsu:tree_to_lua(\%when_true_expr).expr;
local when_false = nomsu:tree_to_lua(\%when_false_expr).expr;
- local safe = {String=true, List=true, Dict=true, Number=true};
+ local safe = {Text=true, List=true, Dict=true, Number=true};
if safe[\%when_true_expr.type] then
return "("..condition.." and "..when_true.." or "..when_false..")";
else
diff --git a/lib/utils.nom b/lib/utils.nom
index 6af38c8..dec2375 100644
--- a/lib/utils.nom
+++ b/lib/utils.nom
@@ -12,7 +12,7 @@ compile [assert %condition %msg] to code: ".."
parse [assert %condition] as: assert %condition (nil)
-# String functions
+# Text functions
rule [join %strs with glue %glue] =:
lua do> ".."
local str_bits = {}
@@ -93,7 +93,7 @@ compile [sort %items by %key_expr] to: ".."
return \(%key_expr as lua);
end)
-# String utilities
+# Text utilities
compile [nl, newline, line feed, linefeed, lf] to: "'\\n'"
compile [tab] to: "'\\t'"
compile [bell] to: "'\\a'"
diff --git a/lib/utils2.nom b/lib/utils2.nom
index 8077203..b0b9dd9 100644
--- a/lib/utils2.nom
+++ b/lib/utils2.nom
@@ -6,11 +6,11 @@ require "lib/collections.nom"
compile [say %str] to:
- "nomsu:writeln(\(%str as lua))" if ((%str's "type") == "String")
+ "nomsu:writeln(\(%str as lua))" if ((%str's "type") == "Text")
..else "nomsu:writeln(nomsu:stringify(\(%str as lua)))"
compile [do %action] to code:
- (%action as lua statements) if ((%action's "type") == "Thunk")
+ (%action as lua statements) if ((%action's "type") == "Block")
..else "(\(%action as lua))(nomsu);"
# With statement
diff --git a/nomsu.lua b/nomsu.lua
index fe15ff6..cb8cf03 100644
--- a/nomsu.lua
+++ b/nomsu.lua
@@ -647,7 +647,7 @@ end]]):format(lua_code))
end
end
return buff, inline
- elseif "String" == _exp_0 then
+ elseif "Text" == _exp_0 then
local buff = "\""
local longbuff = "\"..\"\n |"
local inline = true
@@ -873,7 +873,7 @@ end]]):format(lua_code))
return {
expr = self.__class:comma_separated_items("nomsu.defs[" .. tostring(repr(tree.stub)) .. "].fn(", args, ")")
}
- elseif "String" == _exp_0 then
+ elseif "Text" == _exp_0 then
local concat_parts = { }
local string_buffer = ""
local _list_0 = tree.value
@@ -987,7 +987,7 @@ end]]):format(lua_code))
return
end
local _exp_0 = tree.type
- if "List" == _exp_0 or "File" == _exp_0 or "Block" == _exp_0 or "FunctionCall" == _exp_0 or "String" == _exp_0 then
+ if "List" == _exp_0 or "File" == _exp_0 or "Block" == _exp_0 or "FunctionCall" == _exp_0 or "Text" == _exp_0 then
local _list_0 = tree.value
for _index_0 = 1, #_list_0 do
local v = _list_0[_index_0]
@@ -1040,7 +1040,7 @@ end]]):format(lua_code))
if vars[tree.value] ~= nil then
tree = vars[tree.value]
end
- elseif "File" == _exp_0 or "Nomsu" == _exp_0 or "Block" == _exp_0 or "List" == _exp_0 or "FunctionCall" == _exp_0 or "String" == _exp_0 then
+ elseif "File" == _exp_0 or "Nomsu" == _exp_0 or "Block" == _exp_0 or "List" == _exp_0 or "FunctionCall" == _exp_0 or "Text" == _exp_0 then
local new_value = self:replaced_vars(tree.value, vars)
if new_value ~= tree.value then
do
@@ -1118,7 +1118,7 @@ end]]):format(lua_code))
self:error("Invalid type for getting stub: " .. tostring(type(x)) .. " for:\n" .. tostring(repr(x)))
end
local _exp_0 = x.type
- if "String" == _exp_0 then
+ if "Text" == _exp_0 then
return self:get_stub(x.value)
elseif "FunctionCall" == _exp_0 then
return self:get_stub(x.src)
diff --git a/nomsu.moon b/nomsu.moon
index 2c927ca..6da2411 100755
--- a/nomsu.moon
+++ b/nomsu.moon
@@ -427,7 +427,7 @@ end]]\format(lua_code))
buff ..= nomsu
return buff, inline
- when "String"
+ when "Text"
buff = "\""
longbuff = "\"..\"\n |"
inline = true
@@ -583,7 +583,7 @@ end]]\format(lua_code))
remove @compilestack
return expr:@@comma_separated_items("nomsu.defs[#{repr tree.stub}].fn(", args, ")")
- when "String"
+ when "Text"
concat_parts = {}
string_buffer = ""
for bit in *tree.value
@@ -653,7 +653,7 @@ end]]\format(lua_code))
if type(tree) != 'table' or not tree.type
return
switch tree.type
- when "List", "File", "Block", "FunctionCall", "String"
+ when "List", "File", "Block", "FunctionCall", "Text"
for v in *tree.value
@walk_tree(v, depth+1)
when "Dict"
@@ -703,7 +703,7 @@ end]]\format(lua_code))
when "Var"
if vars[tree.value] ~= nil
tree = vars[tree.value]
- when "File", "Nomsu", "Block", "List", "FunctionCall", "String"
+ when "File", "Nomsu", "Block", "List", "FunctionCall", "Text"
new_value = @replaced_vars tree.value, vars
if new_value != tree.value
tree = {k,v for k,v in pairs(tree)}
@@ -747,7 +747,7 @@ end]]\format(lua_code))
if type(x) != 'table'
@error "Invalid type for getting stub: #{type(x)} for:\n#{repr x}"
switch x.type
- when "String" then return @get_stub(x.value)
+ when "Text" then return @get_stub(x.value)
when "FunctionCall" then return @get_stub(x.src)
else @error "Unsupported get stub type: #{x.type} for #{repr x}"
diff --git a/nomsu.peg b/nomsu.peg
index 0bd51df..c7a43c7 100644
--- a/nomsu.peg
+++ b/nomsu.peg
@@ -24,10 +24,10 @@ eol_nomsu (Nomsu): "\" noeol_expression
indented_nomsu (Nomsu): "\" expression
inline_expression:
- number / variable / inline_string / inline_list / inline_dict / inline_nomsu
+ number / variable / inline_text / inline_list / inline_dict / inline_nomsu
/ ("(" %ws* (inline_block / inline_statement) %ws* ")")
noeol_expression:
- indented_string / indented_nomsu / indented_list / indented_dict / indented_block
+ indented_text / indented_nomsu / indented_list / indented_dict / indented_block
/ ("(..)" indent
statement
(dedent / (("" -> "Error while parsing indented expression") => error))
@@ -44,20 +44,20 @@ functioncall (FunctionCall):
word (Word): { %operator / (!number plain_word) }
-inline_string (String):
+inline_text (Text):
'"' {|
({~ (('\"' -> '"') / ('\\' -> '\') / ('\..' -> '..') / %escape_char / [^%nl\"])+ ~}
- / string_interpolation)*
+ / text_interpolation)*
|} '"'
-indented_string (String):
+indented_text (Text):
'".."' %ws* line_comment? %nl %gt_nodented? {|
({~
(("\\" -> "\") / (("\" eol %nl %gt_nodented "..") -> "")
/ (%nl+ {~ %gt_nodented -> "" ~}) / [^%nl\])+
- ~} / string_interpolation)*
- |} ((!.) / (&(%nl+ !%gt_nodented)) / (("" -> "Error while parsing String") => error))
-string_interpolation:
- "\" (variable / inline_list / inline_dict / inline_string / ("(" %ws* (inline_block / inline_statement) %ws* ")"))
+ ~} / text_interpolation)*
+ |} ((!.) / (&(%nl+ !%gt_nodented)) / (("" -> "Error while parsing Text") => error))
+text_interpolation:
+ "\" (variable / inline_list / inline_dict / inline_text / ("(" %ws* (inline_block / inline_statement) %ws* ")"))
number (Number): (("-"? (([0-9]+ "." [0-9]+) / ("." [0-9]+) / ([0-9]+)))-> tonumber)