Hello, i'm making a custom language and i want to add mathematical expressions, the problem is that i don't know how to parse them since they are on a string and tonumber doesn't do anything.
The best i can do is
local a = " 1+ 5"
local func,err = loadstring("return "..a)
if func then
print(func())
end
but i don't want to use loadstring, is there any alternative to this?

3 comments
Try storing it into a number value and then access that number value
Just use loadstring mate, it does the parsing for you.
my interpreter has a function to detect types and it would use loadstring all the time, it may cause delay