A C-style language interpreter implemented by the TypeScript types
A C-style language interpreter implemented by the TypeScript types
Hello everyone! I've implemented a toy language called Toc using TypeScript's type system, with the aim of learning TypeScript's type gymnastics and exploring the power of type programming.Toc uses a C-style syntax, close to JavaScript, and supports both dynamic and base types (numbers, booleans, strings, and null). It allows variables, expressions, block statements, if-else conditional statements and for loops, functions as first-class citizens that can be passed in and out, and support for closures. Despite the implementation of the basic functionality, there are some unfortunate aspects, in particular functions do not support recursion (I don't know how to implement it). Also, functions don't support return statements, loops don't support break, etc. (these should be possible, I'm just a bit tired ). Error handling is also sketchy, as there is currently no line number information, making it difficult to locate errors when the program is long. There is also a lack of composite data types (such as objects or arrays). I would like to share this project with you and welcome any suggestions or contributions to improve it, especially to solve the problem of functions not supporting recursion! If you're interested in implementing these features, feel free to visit my GitHub repository at [Toc]( https://github.com/huanguolin/toc ) and submit a PR. I welcome discussion and feedback!
Share cardActual performance
Launch Intel predictions
Analyze your own launch →Correct prediction on native model
Similar products
Nullable Types in TypeScript
Brainfuck interpreter using TypeScript types
TySON – TypeScript as a Configuration Language
Functional data types for TypeScript development
Wordle Implemented in TypeScript Types
Extra Types for TypeScript
Generate TypeScript Types from JSON Samples
AttaLambda: a language where types and data are made of untyped lambdas
TypeScript types that conform to JSON schemas without code generation
Semantic Primitives- TypeScript types that understand natural language