AIFeed

用 JavaScript 编写一个原始 Forth(2024)

Translation(model translation, not the source's own text)

用 JavaScript 写一个原始 Forth(2024)

目录

  • 引言 什么是 Forth?动机 资源 原型
  • 什么是 Forth?
  • 原型 Forth 拆解 数据结构 单词查找 单词调用 单词解析 解释器(入口点)单词求值(forth 核心逻辑)
  • 数据结构
  • 解释器(入口点)
  • 单词求值(forth 核心逻辑)
  • 后缀表示法

引言

什么是 Forth?

动机

资源

  • Forth 教程
  • Forth 原语
  • StackFlow Forth
  • Forth 历史
  • 自我书写的语言
  • XXIIVV 上关于 Forth 的页面

原型

  • : 切换到编译模式
  • ; 切换到解释模式
  • + 两数相加
  • - 两数相减
  • . 显示栈顶内容
  • words 显示已定义的单词

原型 Forth 拆解

数据结构

  • 一个数据栈,用于在单词之间传递数据,我的原型只有一种数据类型:数字
  • 一个单词字典,预定义单词(也称为原语)与用户定义的单词都存放在这里

单词查找

单词调用

单词解析

解释器(入口点)

单词求值(forth 核心逻辑)

后缀表示法

结论

Licence Creative Commons
Licence Creative Commons

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; 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 ↗