lua-users home
lua-l archive

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


2013/5/14 Mark Gabby <mwgabby@gmail.com>:

> local lpeg = require "lpeg"
>
> local P = lpeg.P
> local R = lpeg.R
> local op_multiply = P "*" + "\195\151" + "\194\183"
> local op_divide = P "/" + "\226\136\149"
> local result = R"09" * ( op_multiply + op_divide ) * R"09"
>
> result:match( "6/2" )

After stripping those annoying `local`s in order to run your code
from the standalone interpreter, it works just fine on Lua 5.2.2
under Ubuntu 12.04. The last expression returns 4, as it should.

You _are_ running latest versions, yes?

BTW you missed "\195\183" as a divide synonym.

> On the other hand, maybe the problem has nothing to do with
> the raw byte encodings.

Probably system-dependent.