+buffers.visualizers.lam.keywords = {
+ ['case'] = {},
+ ['of'] = {},
+ ['let'] = {},
+ ['in'] = {},
+}
+
+
+function buffers.visualizers.lam.take_symbol(str)
+ -- See if str starts with a symbol, and return the remaining
+ -- string and that symbol. If no symbol from the table is matched,
+ -- just returns the first character.
+ -- We can do a lookup directly, since symbols can be different in
+ -- length, so we just loop over all symbols, trying them in turn.
+ for symbol,props in pairs(buffers.visualizers.lam.symbols) do
+ -- Try to remove symbol from the start of str
+ symbol, newstr = utf.match(str, "^(" .. symbol .. ")(.*)")
+ if symbol then
+ -- Return this tokens repr, or just the token if it has no
+ -- repr.
+ res = props.repr or symbol
+ -- Enclose the token in {\style .. }
+ if props.style then
+ res = "{\\" .. props.style .. " " .. res .. "}"
+ end
+ return res, newstr
+ end
+ end
+ -- No symbol found, just return the first character
+ return utf.match(str, "^(.)(.*)")
+end
+
+-- Take a single word from str, if posible. Returns the rest of the string and
+-- the word taken.
+function buffers.visualizers.lam.take_word(str)
+ res, newstr = utf.match(str, "^(%a+)(.*)")
+ return res, newstr or str
+end
+