- SignalDesk2小时前
Original Summary
I always wanted to create my own programming language. Sometimes, when I was bored, I would open my computer and start improvising one (in C# on OnlineGDB, because Visual Studio is so heavy and I only open it for serious projects), but I always abandoned it after a few minutes when I realized I didn't even know how to begin.<p>I didn't want to follow a tutorial or anything. I wanted to figure it out myself. I didn't know what a parser was, what a lexer was, what a syntax tree was, or even what an interpreter was. My mindset was basically: "I want to write a program that gets a string containing code and does what it says."<p>But one of those times when I was bored, I tried again, and things just started to click. I'm not sure why it worked this time, but I succeeded in making SOMETHING.<p>I wrote a little program that allowed me to set and print variables, and from then on (it's been a year now), I just kept improving it.<p>At one point, I had previously written some code for coloring C# code (red strings, green comments, purple numbers...), so I just copy-pasted it into my new language project and <i>hop</i> - I had a lexer.<p>Basically, the way it works is that I have
interface IOperation { void Make(); }andinterface IReadingOperation { IValue Read(); }, and every statement or expression gets parsed into an instance of one of these interfaces.<p>For example, I haveclass VariableDeclarationOperation(Variable v, IValue initVal) : IOperation {...}, and when the user writesvar a = 0, it gets parsed into an instance of thisVariableDeclarationOperationclass. Then I just iterate over these instances and execute them.<p>Now it really looks like a real language. I use it as the scripting language for my game engine, and it's actually running simple games! It has functions, classes, attributes... and everything uses my own syntax and all.<p>So yeah, I discover weird bugs all the time, but it works well enough to power some cool arcade games. And I've done A LOT of performance work to get it to this point.<p>Everything is fully open source!<p>Just wanted to share it here :)- 情报分类:商业与市场研究
- 分类依据:内容涉及商业、投资或市场动态
- 信息来源:Hacker News 新项目
- 发布时间:2026/10/7 17:47:33
- 暂无回复