cforth / cnforth

Forth system by C

Home Page:https://github.com/cforth/cnforth/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cnforth -- C语言实现的Forth语言解释器

Author:Chai Fei

简介

cnforth项目是一个用C语言实现的简单的Forth语言解释器,不是一个传统的Forth系统。受到耳朵ear_cforth的启发,以及他的指点。再次感谢耳朵CNFIG社区!!!

特性支持

  1. 核心词;

  2. 定义和使用扩展词;

  3. if else then 控制语句(支持嵌套);

  4. do loop 循环语句(支持嵌套);

  5. 变量和常量(variable constant);

  6. 状态变量state,状态切换词[] ;

  7. 反编译扩展词see ;

  8. 递归定义扩展词(myself);

  9. 从外部读取forth代码(load lib.fs或者命令行./forth lib.fs);

  10. 其他特性参见Wiki

环境

  1. Windows(32位/64位) + Cygwin + gcc 4.9.3

  2. Linux(32位) + gcc 4.9.2

安装

make forth

使用

求8的阶乘,使用递归实现:

./forth lib.fs

>>> : factorial ( Num -- FactorialResult ) dup 1 = if drop 1 else dup 1- myself * then ;
>>> 8 factorial .
40320

About

Forth system by C

https://github.com/cforth/cnforth/wiki


Languages

Language:C 89.0%Language:Forth 10.2%Language:Makefile 0.7%