Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View fab13n's full-sized avatar

Fleutot fab13n

  • Freelance & combohr.com
  • Toulouse, France
View GitHub Profile
require 'metalua.walk'
local M = { }
-- support for old-style modules
treequery=M
-- multimap helper mmap: associate a key to a set of values
local function mmap_add (mmap, node, x)
if node==nil then return false end
local set = mmap[node]
@fab13n
fab13n / gist:1264745
Created October 5, 2011 15:34
TreeQuery prototype
local walk = require 'metalua.treequery.walk'
local M = { }
-- support for old-style modules
treequery = M
-- multimap helper mmap: associate a key to a set of values
local function mmap_add (mmap, node, x)
if node==nil then return false end
local set = mmap[node]
@fab13n
fab13n / gist:1264752
Created October 5, 2011 15:35
TreeQuery prototype visitor
-- Low level AST traversal library.
-- This library is a helper for the higher-level treequery library.
-- It walks through every node of an AST, depth-first, and executes
-- some callbacks contained in its cfg config table:
--
-- * cfg.down(...) is called when it walks down a node, and receive as
-- parameters the node just entered, followed by its parent, grand-parent
-- etc. until the root node.
--
-- * cfg.up(...) is called when it walks back up a node, and receive as
@fab13n
fab13n / gist:1301275
Created October 20, 2011 14:26
metalua/treequery.mlua
local walk = require 'metalua.treequery.walk'
local M = { }
-- support for old-style modules
treequery = M
-- -----------------------------------------------------------------------------
-- -----------------------------------------------------------------------------
--
-- multimap helper mmap: associate a key to a set of values
@fab13n
fab13n / gist:1301283
Created October 20, 2011 14:29
metalua/treequery/walk.mlua
-{ extension "match" }
local M = { traverse = { }; tags = { }; debug = false }
--------------------------------------------------------------------------------
-- Standard tags: can be used to guess the type of an AST, or to check
-- that the type of an AST is respected.
--------------------------------------------------------------------------------
M.tags.stat = table.transpose{
require 'sched'
require 'web.server'
require 'web.template'
require 'serial'
telnet = require 'shell.telnet'
uart = serial.open('/dev/ttyAMA0', { baudrate=19200 })
-- Read enough data from the UART to extract two consecutive frames.
function get_raw_data()