lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Pure-Lua String Literal 99a62b4 is a module that can parse Lua string literals in a way compatible with load(). It currently supports the full syntax of Lua 5.2 and Lua 5.3 string literals.

It is available at https://github.com/SoniEx2/Stuff/blob/99a62b41dc126d35daa7a03ebae3b0fd9eefa4c9/lua/String.lua

The error messages between Pure-Lua String Literal 99a62b4 and a specific load()-based construct are quite similar. In fact, except for one particular case, the error messages are exactly the same between Pure-Lua String Literal 99a62b4's parse52 and Lua 5.2.4's own load()! (If you find that they aren't, please let me know, it's probably a bug!)

The module provides the following APIs:

stringliteral.parse52(s) --> Parse a Lua 5.2 string literal contained in s.
stringliteral.parse53(s) --> Parse a Lua 5.3 string literal contained in s.

The given APIs use error(), so you might want to call them using pcall().

PS: I'm not sure if I would call this production-ready, but I *am* using it in production...

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.