-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathassert.lua
More file actions
29 lines (25 loc) · 823 Bytes
/
assert.lua
File metadata and controls
29 lines (25 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function assert_handler(state, params)
-- we expect a single parameter that is an expression.
if (#params ~= 1 or (params[1].type ~= "STRING" and params[1].type ~= "EXPRESSION")) then
error("error: .ASSERT directive expects single expression parameter.")
end
local expr = nil;
if (params[1].type == "STRING") then
expr = expression_create(params[1].value);
else
expr = params[1].value
end
-- output a symbol for the expression.
state:add_symbol("assertion:" .. expr:representation());
end
function setup()
-- perform setup
add_preprocessor_directive("ASSERT", assert_handler, false, true)
end
MODULE = {
Type = "Preprocessor",
Name = ".ASSERT directive",
Version = "1.0",
SDescription = "The .ASSERT directive",
URL = "http://dcputoolcha.in/docs/modules/list/assert.html"
};