Skip to main content

CurateClick

tsplay.dev favicon

Toc

Toc 是一个使用 TypeScript 类型系统实现的 C 风格语言解释器,支持动态类型、变量、表达式、控制语句和函数闭包等特性。

Check out Toc on CurateClick

• Copy the embed code to showcase this product on your website

• Share on X to spread the word about this amazing tool

两年前学习 TypeScript 类型体操时,个人的终极体操,并编写了介绍长文给初学者:类型体操之实现一个类C风格语言的解释器下面是实现效果演示的动图:demo实现的语言叫 Toc (点击在线体验). 它是 C 风格语法,接近 js。动态类型,基础类型有数字、布尔、字符串和 null,支持变量,表达式,块语句,if-else 条件语句,for 循环语句,函数。且函数是一等公民,可以传入传出,支持闭包。更详细的语法,可以参见 Toc Grammar Spec。文章比较长,主要介绍了:1. ts 的类型系统是怎样的函数式语言?2. 如何实现 Toc 解释器?文章介绍的很详细,其中为了照顾没有编译器基础的,还写了一个 ts 版本(不使用类型系统,直接使用 ts 语言,额,也可以说用 js 实现的)的做对照。

Latest Weekly Picks

promptbuilder.cc favicon
Weekly Pick

Generate, optimize, test, and manage AI prompts in one place. Turn an idea into a ready-to-use prompt in seconds.

Prompt Builder
freqz.net favicon
Weekly Pick

Your Personal K-Style Vibe Photo Studio

Freqz
webleadr.com favicon
Weekly Pick

Find and contact web design leads and businesses without websites, like local dentists, effortlessly from any location in just a few clicks.

Webleadr

the art of having something to say

pretty-scale.com favicon
Weekly Pick

How Pretty Are You? Let AI Decide.

Pretty Scale
c2story.com favicon
Weekly Pick

Create Illustrated Stories with AI

C2story

Impromptu Speech Topics & Timer

Seedance 2.0: Multimodal AI video creator. Precisely direct characters and cameras to create production-ready, multi-shot cinematic stories in one click.