If you need to create your own language in a Python project, do not look any further — Sly is there for the rescue! The web is full with Lexer/Parse

Create your own scripting language in Python with Sly

submited by
Style Pass
2023-01-25 21:30:08

If you need to create your own language in a Python project, do not look any further — Sly is there for the rescue! The web is full with Lexer/Parser generators- ANTLR4, Bison, GOLD, Yacc, Flex- the list just goes on and on. There is only one problem — seems like non of them were really designed for Python.

Some time ago, I was assigned the task of designing an inside platform language for my company’s product. The language had to support backward compatibility with a legacy version, run inside a Python code base, deliver extreme performance for user facing processes and allow great maintainability by all engineers in my team. I searched the web and read much about all the different options to meet these requirements, but most did not seem fit to run with Python. Luckily I found Sly.

In this short tutorial I will try to cover the basic terms for creating a scripting language, and give a short example of using Sly to quickly create your own Lexer and Parser.

Leave a Comment