lua-users home
lua-l archive

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


On Tue, Jul 5, 2016 at 2:14 PM, Coda Highland <chighland@gmail.com> wrote:
> On Tue, Jul 5, 2016 at 2:11 PM, Soni L. <fakedme@gmail.com> wrote:
>>
>>
>> On 05/07/16 05:18 PM, Sean Conner wrote:
>>>
>>> It was thus said that the Great Soni L. once stated:
>>>>
>>>> As you may or may not know by now, regex can do basic arithmetic, with
>>>> unary integers.[1] Can LPeg do better, say with binary integers, or
>>>> binary floats, or even full-blown decimal?
>>>
>>>    Yup.  You can do the regex approach with a substitution capture
>>> (lpeg.Cs()) or even a full blown calculator (there's an example on the
>>> LPeg
>>> web page).
>>
>> Too bad it's not pure LPeg, instead deferring to a Lua function for it.
>
> Well, considering that regular expressions are capable of doing it,
> and LPeg is capable of implementing regular expressions, by
> isomorphism LPeg is capable of performing arithmetic.
>
> What would be far more interesting is if you could implement an
> expression parser that would actually return the value if you pass in
> the formula as a human-readable string. (I've got some ideas on how
> you could accomplish that...)
>
> /s/ Adam

Aaaaaand my reading comprehension fails because that was acknowledged in the OP.

/s/ Adam