aboutsummaryrefslogtreecommitdiff
path: root/neb.py
diff options
context:
space:
mode:
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()