From da0a365bcf2e801ba24864dc9fcbf48e6d11db76 Mon Sep 17 00:00:00 2001 From: zeroflag Date: Sun, 27 Jun 2021 16:22:26 +0200 Subject: [PATCH] words --- src/main/java/com/vectron/fcl/Fcl.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/vectron/fcl/Fcl.java b/src/main/java/com/vectron/fcl/Fcl.java index ef91f1e..b9723a2 100644 --- a/src/main/java/com/vectron/fcl/Fcl.java +++ b/src/main/java/com/vectron/fcl/Fcl.java @@ -16,6 +16,9 @@ import com.vectron.fcl.types.Word; import java.io.IOException; import java.io.Reader; import java.io.StringReader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.Set; public class Fcl { @@ -364,6 +367,13 @@ public class Fcl { addPrimitive("var:", () -> { String name = word(); dict.add(new Var(dp, name)); dp++; }); addPrimitive("val:", () -> { String name = word(); dict.add(new Val(name, stack.pop())); }); addPrimitive("abort", () -> { throw new Aborted(stack.pop().asStr().value()); }); + addPrimitive("words", () -> { + List words = new ArrayList(wordList()); + Collections.sort(words); + for (String each : words) { + transcript.show(each); + transcript.cr(); + }}); addPrimitive("exec", () -> { rstack.push(new Num(ip)); innerLoop(pop().intValue());