Skip to content

Commit

Permalink
map nse to lua, sharkdp#2151
Browse files Browse the repository at this point in the history
  • Loading branch information
Cre3per committed Jun 4, 2022
1 parent 16488f3 commit 7558817
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

## Syntaxes

- NSE (Nmap Scripting Engine) is mapped to Lua, see #2151 (@Cre3per)

## Themes

## `bat` as a library
Expand Down
3 changes: 3 additions & 0 deletions src/syntax_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ impl<'a> SyntaxMapping<'a> {
.insert("*.pac", MappingTarget::MapTo("JavaScript (Babel)"))
.unwrap();

// See #2151, https://nmap.org/book/nse-language.html
// mapping.insert("*.nse", MappingTarget::MapTo("Lua")).unwrap();

// See #1008
mapping
.insert("rails", MappingTarget::MapToUnknown)
Expand Down
34 changes: 34 additions & 0 deletions tests/syntax-tests/highlighted/NSE/test.nse
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--- Finds factorial of a number.
-- @param value Number to find factorial.
-- @return Factorial of number.
local function factorial(value)
 if value <= 1 then
 return 1
 else
 return value * factorial(value - 1)
 end
end

--- Joins a table of strings into a new string.
-- @param table Table of strings.
-- @param separator Separator character.
-- @return Joined string.
local function join(table, separator)
 local data = ""
 
 for index, value in ipairs(table) do
 data = data .. value .. separator
 end
 
 data = data:sub(1, data:len() - 1)
 
 return data
end

local a = factorial(5)

print(a)

local b = join({ "l", "u", "a" }, ",")

print(b)
34 changes: 34 additions & 0 deletions tests/syntax-tests/source/NSE/test.nse
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--- Finds factorial of a number.
-- @param value Number to find factorial.
-- @return Factorial of number.
local function factorial(value)
if value <= 1 then
return 1
else
return value * factorial(value - 1)
end
end

--- Joins a table of strings into a new string.
-- @param table Table of strings.
-- @param separator Separator character.
-- @return Joined string.
local function join(table, separator)
local data = ""

for index, value in ipairs(table) do
data = data .. value .. separator
end

data = data:sub(1, data:len() - 1)

return data
end

local a = factorial(5)

print(a)

local b = join({ "l", "u", "a" }, ",")

print(b)

0 comments on commit 7558817

Please sign in to comment.