DEV Community

C++Love
C++Love

Posted on

4

A basic but real Lua Interpreter in C#

Hello everyone! Below you will find a semi-working parser and interpreter for the lua programming language.
However, it is far from finished and very crude.
Some drawbacks of it include:
Loops aren't implemented yet.
Extremely buggy and prone to infinite loops.
Many aspects of lua aren't implemented.
Strings aren't even unique yet so they are basically treated as identifiers, which means no important keywords such as if, then, function allowed inside strings without decorating them with say, an underscore.

The good parts:
Real tokenizer and parser made from scratch, not just reading a file line by line and using regular expressions or replace!
It can run recursive factorial.

And finally, I shall honor your eyes with the code.
https://repl.it/@CSharpIsGud/LuaInterpreter2

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay