Lux is an easy to use string parsing tool. You can get it on Roblox Creator Marketplace or test it in Lux Lab. After installation you can require and use it:
local Lux = require(script.Lux)
local parser = Lux.generateParser([[ -- Generate grammar & parser
name = "%u%l+"; -- One uppercase letter and lowercase letters
greetings = "Hello," name; -- "Hello," and name
!text = { greetings }; -- Root rule: any greetings.
]])
local tree = parser:parse("Hello, Bob")
Lux.show(tree)
I’m stuck. I can’t solve recursion problem and I can’t update this module to fix the bugs. Sorry, I don’t know what to do. You shouldn’t use it until I find a solution. If someone know how to improve this module, please DM me.
Hello! I’m so happy! I found the solution and soon wil release Lux update with bug fixes. Also I have to warn that I will not update the Lux for 2 weeks as I’m away from my computer.
This doesn’t work because each rule definition needs to end in a semi-colon (;).
This would work:
local Lux = require(script.Lux)
local parser = Lux.generateParser([[ -- Generate grammar & parser
name = "%u%l+"; -- One uppercase letter and lowercase letters
greetings = "Hello," name; -- "Hello," and name
!text = { greetings }; -- Root rule: any greetings.
]])
local tree = parser:parse("Hello, Bob")
Lux.show(tree)
I think it should also be noted that some string patterns can cause an infinite recursion to occur within the module (I found this out while messing around with it)
I can’t quite reproduce the problem at the moment since I was just writing random string patterns and don’t remember the problematic ones in particular.
However, I did discover another infinite recursion while trying to recreate the string pattern one:
One thing I would ask for is proper error handling, when you’re creating a language it is essential to tell where the error has come from, but the library just says that it expected EOF instead of the actual error.
Hi, I was actually just planning on making something quite similar and am going to make a parser that uses LALR(1). Don’t know how long it will take but i thought it would be a fun side project to experiment with. I’m also going to add a configurable syntax highlighter which allows you to mess with token highlighting using the richtext feature in textlabels.