Tag: lua

Lua Rocks

Inspired by reading [cached]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 is not clever enough to take advantage of
  -- commutativity, i.e …

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