summaryrefslogtreecommitdiffstats
path: root/src/forth
diff options
context:
space:
mode:
authorBrian Cully <bjc@spork.org>2025-08-23 10:22:11 -0400
committerBrian Cully <bjc@spork.org>2025-08-23 11:36:31 -0400
commit5b8962e35836cf7ccbfdbca312f6b0eb9269e2a6 (patch)
treee537f04279c4b1ef27f7040c25beff2551c8bf84 /src/forth
parent12c06171b3f94696e852c3910c116f56cbfc5b64 (diff)
downloadautomathon-5b8962e35836cf7ccbfdbca312f6b0eb9269e2a6.tar.gz
automathon-5b8962e35836cf7ccbfdbca312f6b0eb9269e2a6.zip
show wordlist in html on compile
Diffstat (limited to 'src/forth')
-rw-r--r--src/forth/interp.rs17
-rw-r--r--src/forth/parser.rs3
2 files changed, 14 insertions, 6 deletions
diff --git a/src/forth/interp.rs b/src/forth/interp.rs
index cacc5e3..e41f0d9 100644
--- a/src/forth/interp.rs
+++ b/src/forth/interp.rs
@@ -29,6 +29,12 @@ pub enum OpCode {
#[derive(Clone, Debug)]
pub struct ByteCode(pub Vec<OpCode>);
+impl std::ops::Deref for ByteCode {
+ type Target = Vec<OpCode>;
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
impl ByteCode {
pub fn len(&self) -> usize {
@@ -67,15 +73,20 @@ pub struct CallStack(pub Vec<InstructionPointer>);
#[derive(Clone, Debug)]
pub struct WordList(pub Vec<ByteCode>);
+impl std::ops::Deref for WordList {
+ type Target = Vec<ByteCode>;
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
#[derive(Debug)]
pub struct Interp {
// todo: don't be pub, probably
pub stack: DataStack,
- callstack: CallStack,
- // todo: don't be pub
+ pub callstack: CallStack,
pub wordlist: WordList,
- ip: InstructionPointer,
+ pub ip: InstructionPointer,
}
#[derive(Debug)]
diff --git a/src/forth/parser.rs b/src/forth/parser.rs
index ac6715d..1eb93df 100644
--- a/src/forth/parser.rs
+++ b/src/forth/parser.rs
@@ -1,7 +1,5 @@
use super::interp::{ByteCode, OpCode, WordList};
-use log::debug;
-
use std::collections::HashMap;
use std::iter::{Enumerate, Iterator};
use std::str::Chars;
@@ -81,7 +79,6 @@ impl<'a> Parser<'a> {
self.enumerator.by_ref()
.find(|(_i, c)| c.is_whitespace())?;
let word = &self.text[start..end];
- debug!("Parser::next_word → ‘{}’ ({} → {})", word, start, end);
Some((word, start, end))
}