aboutsummaryrefslogtreecommitdiff
path: root/neb.py
diff options
context:
space:
mode:
authormryouse2022-07-11 02:00:24 +0000
committermryouse2022-07-11 02:00:24 +0000
commit6cb8aa19bc47301ae34eecf8c119723c12da34bd (patch)
treebd31d0b6a1a458d04a9488c0f69f8f10472fccb1 /neb.py
parent3b2907af59fb7ed451dc4a73ae645d466f62ba13 (diff)
parent0ed39a708e332399b871a88bf6c7a777630f9247 (diff)
Merge branch 'master' into feature/listtypes
Diffstat (limited to 'neb.py')
-rw-r--r--neb.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/neb.py b/neb.py
index 7e3380f..86c96b1 100644
--- a/neb.py
+++ b/neb.py
@@ -4,6 +4,16 @@ import sys
import readline
+class NebCompleter:
+
+ def __init__(self, syntax):
+ self.syntax = syntax
+
+ def complete(self, text, state):
+ results = [x for x in self.syntax if x.startswith(text)] + [None]
+ return results[state]
+
+
def build_std(repl=False):
GLOBALS = Environment()
global_dict = { **BOOLEAN.environment,
@@ -34,6 +44,11 @@ def debug(prev_lexed, prev_parsed):
def repl():
env = build_std(True)
+
+ readline.parse_and_bind("tab: complete")
+ cmp = NebCompleter(env.environment.keys())
+ readline.set_completer(cmp.complete)
+
print("### neb :)(:")
print("version: < 0")
idx = 1
@@ -65,6 +80,11 @@ def repl():
def run_file(filename):
env = build_std(True)
+
+ readline.parse_and_bind("tab: complete")
+ cmp = NebCompleter(env.environment.keys())
+ readline.set_completer(cmp.complete)
+
with open(filename, "r") as fil:
data = fil.read()