DEV Community

Cover image for Creating a database from scratch with Node.js - Days 4-7
Luis Felipe Ciochetta
Luis Felipe Ciochetta

Posted on

Creating a database from scratch with Node.js - Days 4-7

Hello folks!

in my last post, I was talking about how messy my parser was getting, so a good man named Olivier told me about the Earley algorithm, I've been trying to learn how to properly use it since then.

So today I am introducing to the world LQL, the Luis Query Language, it's basically the same thing I was trying to do with my original parser with even fewer functions (for now) but with way better-structured code.

I haven't yet started to use the parser in the main project, but I was so proud my initial test cases passed I felt like writing this post.


Features:

It takes a string input that matched the "select" command pattern and transforms it into a JSON that I will later use.

Example:

This code:

Alt Text

Generates this output:

Alt Text

In the column parameter, it also supports strings:

Alt Text

And arrays:

Alt Text


Conclusion

loved working with nearley, so much that I am thinking my next project will be creating a programming language with node, but that seems way too bold for now.

I've published the parser in npm and Github

if you wanna play with it you can install it with

npm install lql-parser
Enter fullscreen mode Exit fullscreen mode

and if you wanna check the code out, this is the repo >

btw

This is the guy that told me about Earley, I tried to reach him on Linkedin to thank him but couldn't, so this post is my thank you note to him

That's all I had to say

Happy new year to everyone :)

Top comments (0)