AIFeed

Writing a primitive Forth in JavaScript (2024)

Original text(via Lobsters)

Writing a primitive Forth in JavaScript

Contents

  • Introduction What is Forth ? Motivation Resources Prototype
  • What is Forth ?
  • Proto Forth breakdown Data structures Word search Word call Word parse Interpreter (entry point) Word evaluation (forth core logic)
  • Data structures
  • Interpreter (entry point)
  • Word evaluation (forth core logic)
  • Postfix notation

Introduction

What is Forth ?

Motivation

Resources

  • Forth Tutorial
  • Forth Primitives
  • StackFlow Forth
  • Forth History
  • The Language That Writes Itself
  • XXIIVV page about Forth

Prototype

  • : switch to compile mode
  • ; switch to interpreter mode
  • + add two numbers
  • - subtract two numbers
  • . show stack top content
  • words show defined words

Proto Forth breakdown

Data structures

  • a data stack to pass data between words, my prototype has a single data type : numbers
  • a words dictionary which is where predefined words (also called primitives) go into along with user defined words

Word search

Word call

Word parse

Interpreter (entry point)

Word evaluation (forth core logic)

Postfix notation

Conclusion

Licence Creative Commons
Licence Creative Commons

The text above was extracted automatically from the source page and may miss images, tables or code blocks. The original is authoritative.

Published by Lobsters
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗