Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some shit just flatout doesn't work (linestart and filestart)
- Loading branch information
1 parent
2cb2c47
commit af74760
Showing
8 changed files
with
70 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?args str ?> | ||
Hello, <?= str ?>! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
lol | ||
<?args lmao ?> | ||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
-- dry run luapreproc for including files together | ||
local lpp = require("libpreproc") | ||
|
||
local directive_prefix = lpp.pattern("--#", true) | ||
local dblquotes = lpp.block('"', '"') | ||
local include = (lpp.prefix(directive_prefix, lpp.prefix("include ", dblquotes))) | ||
|
||
local parser = lpp.instance() | ||
|
||
parser.env.directives = {} | ||
|
||
local function readfile(file) | ||
local f = assert(io.open(file, "r")) | ||
local dat = f:read("*a") | ||
f:close() | ||
return dat | ||
end | ||
|
||
function parser.env.directives.include(inst, path) | ||
local newinst = inst:clone() | ||
local d = readfile(path) | ||
newinst:compile(d) | ||
local code = newinst:generate() | ||
return code | ||
end | ||
|
||
parser:add_token(include, function(stream, instance, result) | ||
instance:write(string.format("write(directives.include(_INSTANCE, %q))", result.matches[1])) | ||
end) | ||
|
||
local file = arg[1] | ||
|
||
table.remove(arg, 1) | ||
parser:compile(readfile(file)) | ||
print(parser.code) | ||
print(parser:generate(table.unpack(arg))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
print("test lol") | ||
print("test lmao even") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
print("lol lmao") | ||
--#include "tests/luapreproc/test1.lua" | ||
print("shit here") |