Skip to content

Commit

Permalink
Added the concept of preprocessor keywords and @insert.
Browse files Browse the repository at this point in the history
  • Loading branch information
ReFreezed committed Sep 24, 2019
1 parent 89c6f49 commit 239c9da
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 67 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.lua2p linguist-language=Lua
*.luapart linguist-language=Lua
8 changes: 8 additions & 0 deletions misc/quickTest.lua2p
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ print(s:match(ident)) -- "hello5"
print(s:match(num)) -- "2"
print(s:match(funcCall)) -- "hello5( foo )"

-- File inserts.
!(
@insert "misc/quickTest.luapart"
print("Metaprogram - someString: "..someString)
)
local uhh = !(@insert"misc/quickTest.txt")
print("Final program - uhh: "..uhh)

print(!("dataFromCommandLine: "..tostring(dataFromCommandLine)))
print("The end.")

Expand Down
2 changes: 2 additions & 0 deletions misc/quickTest.luapart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Partial file.
local someString = "Icecream"
1 change: 1 addition & 0 deletions misc/quickTest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1+2*3
2 changes: 2 additions & 0 deletions misc/runQuickTest.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ REM lua preprocess-cl.lua --debug --saveinfo=local/info.lua --data="Hello, world

REM lua preprocess-cl.lua --debug --saveinfo=local/info.lua --data="Hello, world!" --outputpaths misc/quickTest.lua2p local/quickTest.output.lua
REM lua preprocess-cl.lua --debug --saveinfo=local/info.lua --data="Hello, world!" --outputpaths misc/quickTest.lua2p local/quickTest.output.lua --linenumbers

lua misc/quickTest.lua
2 changes: 2 additions & 0 deletions misc/runQuickTestUsingHandler.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ IF NOT EXIST local MD local

lua preprocess-cl.lua --debug --saveinfo=local/info.lua --handler=misc/quickTestHandler.lua misc/quickTest.lua2p
REM lua preprocess-cl.lua --debug --saveinfo=local/info.lua --handler=misc/quickTestHandler.lua --outputpaths misc/quickTest.lua2p local/quickTest.output.lua

lua misc/quickTest.lua
2 changes: 2 additions & 0 deletions misc/runTests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ doTest("Output values of different types", function()
assert(not luaOut)
end)

-- @Incomplete: Add tests for @insert.



addLabel("Library API")
Expand Down
Loading

0 comments on commit 239c9da

Please sign in to comment.