-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmacro.lua
More file actions
46 lines (39 loc) · 1.1 KB
/
macro.lua
File metadata and controls
46 lines (39 loc) · 1.1 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
-------------------------------------------------------------
-- Macro processor
-- Copyright (c) 2023 Benjamin Porter
--
-- API declarations for macro processing functions
--------------------------------------------------------------
macro = {}
--- Evaluates the lua expression
---
--- Example:
--- `macro.expr(2*5)` is replaced with `10`
---@param expr any
---@return any
function macro.expr(expr) end
--- Evaluates the string
---
--- Example:
--- `macro.eval[[2*5]]` is replaced with `10`
---@param str string
---@return any
function macro.eval(str) end
--- Starts a macro block
---
--- Example:
--- `macro.do_() print("x = 3") macro.end_()` is replaced with `x = 3`
function macro.do_() end
--- Conditionally starts a macro block
---
--- Example:
--- `macro.if_(FEATURE) print("-- FEATURE ENABLED") macro.end_()`
function macro.if_(expr) end
--- Ends a macro block
---
--- Example:
--- `macro.do_() print("x = 3") macro.end_()` is replaced with `x = 3`
function macro.end_() end
--- A function that will be called after macro processing is complete
---@type fun(file_contents:string):string
macro.post_process = nil