gamesys / moonshine

A lightweight Lua VM for the browser
http://moonshinejs.org
MIT License
502 stars 35 forks source link

False positive in rosetta stone pattern matching #18

Open TannerRogalsky opened 10 years ago

TannerRogalsky commented 10 years ago

Hey Paul! I found a small bug in the pattern translation code. I think that the first ROSETTA_STONE entry is matching hyphens when it shouldn't be and turning a pattern like ^(%d+)-(%d+)$ into ^(\d+)*?(\d+)$.

https://github.com/gamesys/moonshine/blob/adff2ed4f2a15bea502633ac29f0c362593bd7c8/vm/src/lib.js#L42

paulcuth commented 10 years ago

Cheers, Tanner. The regex translation is a tricky part of the VM. I'll take a look.

TannerRogalsky commented 10 years ago

Haha, as regexes can sometimes be.