Tag: lua

Lua Rocks

Inspired by reading Lua - an extensible extension language, specifically the section on using fallbacks to implement an expression parser, I wanted to see if I could do so in a safe manner. With safe meaning parsed expressions must not be able to execute arbitrary code.

Half an hour later, I have to say it is surprisingly easy! Less than 50 lines (including comments) is all it takes:

function parse(expression)
  local op, create

  -- Calculate each subexpression at most once, otherwise just return the cached
  -- result. Note that this ...

© Julian Schrittwieser. Built using 開板. Theme by Giulio Fidente on github. .