aboutsummaryrefslogtreecommitdiff
path: root/nomnom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-11-08 15:23:22 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-11-08 15:24:15 -0800
commit652c29bdef1f0991cc13bef59d6dc78b657ae9a4 (patch)
tree8e335399e77b1893657b9fa985db0738034daac3 /nomnom
parent1f3660f393c1a17988a15b89f18686b28e51a9e7 (diff)
Major overhaul, splitting nomsu_compiler into nomsu_environment,
nomsu_compiler, and nomsu_decompiler. Also added comprehensions.
Diffstat (limited to 'nomnom')
-rw-r--r--nomnom/ast.nom2
-rw-r--r--nomnom/code_obj.nom2
-rw-r--r--nomnom/compile.nom2
-rw-r--r--nomnom/decompile.nom15
-rw-r--r--nomnom/files.nom2
-rw-r--r--nomnom/source.nom2
6 files changed, 18 insertions, 7 deletions
diff --git a/nomnom/ast.nom b/nomnom/ast.nom
index ef41b26..935b0c5 100644
--- a/nomnom/ast.nom
+++ b/nomnom/ast.nom
@@ -1,6 +1,8 @@
#!/usr/bin/env nomsu -V4.8.10
use "lib/object.nom"
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
# The types are [..]
"Number", "Var", "Block", "EscapedNomsu", "Text", "List", "Dict", "DictEntry",
"IndexChain", "Action", "FileChunks", "Error", "Comment"
diff --git a/nomnom/code_obj.nom b/nomnom/code_obj.nom
index c8d2784..2c78ace 100644
--- a/nomnom/code_obj.nom
+++ b/nomnom/code_obj.nom
@@ -4,6 +4,8 @@
indentation levels.
use "lib/things.nom"
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
a (Code Buffer) is a thing:
that can (set up) by:
assume %its.source
diff --git a/nomnom/compile.nom b/nomnom/compile.nom
index 8241ef2..ad38b69 100644
--- a/nomnom/compile.nom
+++ b/nomnom/compile.nom
@@ -4,6 +4,8 @@ use "nomnom/code_obj.nom"
use "nomnom/parser.nom"
use "nomnom/pretty_errors.nom"
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
externally (report compile error at %tree %err) means:
barf (pretty "Compile Error" error at %tree %err)
diff --git a/nomnom/decompile.nom b/nomnom/decompile.nom
index 11ec233..c958280 100644
--- a/nomnom/decompile.nom
+++ b/nomnom/decompile.nom
@@ -3,6 +3,8 @@
use "nomnom/code_obj.nom"
use "nomnom/parser.nom"
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
# TODO: maybe re-implement the fancy coroutine checker that aborts early if nomsu gets too long
externally (%tree decompiled inline) means:
assume (%tree is a "Syntax Tree")
@@ -175,10 +177,10 @@ externally (%tree decompiled) means:
"FileChunks":
(%1 and %2 should clump) means:
if ((%1.type == "Action") and (%2.type == "Action")):
- if (%1.stub == "use 1"):
- return (%2.stub == "use 1")
- if (%1.stub == "test 1"): return (yes)
- if (%2.stub == "test 1"): return (no)
+ if (%1.stub == "use"):
+ return (%2.stub == "use")
+ if (%1.stub == "test"): return (yes)
+ if (%2.stub == "test"): return (no)
return (not ((recurse on %1)::is multi-line))
@@ -199,14 +201,12 @@ externally (%tree decompiled) means:
return %nomsu
"Action":
- %pos = %tree.source.start
%next_space = ""
if %tree.target:
%target_nomsu = (recurse on %tree.target)
if ((%tree.target.type == "Action") and (%target_nomsu::is one line)):
%target_nomsu::parenthesize
%nomsu::add %target_nomsu
- %pos = %tree.target.source.stop
%next_space = ("\n..::" if (%target_nomsu::is multi-line) else "::")
for %bit in %tree at %i:
@@ -290,8 +290,9 @@ externally (%tree decompiled) means:
"Var":
if ((%tree.(%i+1) is text) and (not (%tree.(%i+1)::matches "^[ \n\t,.:#(){}[%]]"))):
%interp_nomsu::parenthesize
-
"List" "Dict":
+ do nothing
+ else:
%interp_nomsu::parenthesize
%nomsu::add %interp_nomsu
diff --git a/nomnom/files.nom b/nomnom/files.nom
index 352ddfa..61119c0 100644
--- a/nomnom/files.nom
+++ b/nomnom/files.nom
@@ -2,6 +2,8 @@
# Some file utilities for searching for files recursively and using package.nomsupath
use "lib/os.nom"
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
%_SPOOFED_FILES = {}
%_FILE_CACHE = ({} with fallback % -> %_SPOOFED_FILES.%)
%_BROWSE_CACHE = {}
diff --git a/nomnom/source.nom b/nomnom/source.nom
index c36216f..bff8d8d 100644
--- a/nomnom/source.nom
+++ b/nomnom/source.nom
@@ -1,6 +1,8 @@
#!/usr/bin/env nomsu -V4.8.10
use "lib/object.nom"
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
object (Source):
externally (Source from text %text) means:
%match = (%text::matching groups "^@(.-)%[(%d+):(%d+)%]$")