mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-25 23:05:13 +02:00
parent
12a13b1c0a
commit
feac018149
27
PowerEditor/Test/FunctionList/lua/unitTest
Normal file
27
PowerEditor/Test/FunctionList/lua/unitTest
Normal file
@ -0,0 +1,27 @@
|
||||
-- Create a file named by_ip/''ip_addess''.cap with all ip traffic of each ip host. (tshark only?)
|
||||
-- Dump files are created for both source and destination hosts
|
||||
function createDir (dirname)
|
||||
-- this will print out an error if the directory already exists, but that's fine
|
||||
os.execute("mkdir " .. dirname)
|
||||
end
|
||||
|
||||
local dir = "by_ip"
|
||||
createDir(dir)
|
||||
|
||||
-- create a table to hold the dumper objects/file handles
|
||||
local dumpers = {}
|
||||
|
||||
local tap = Listener.new("ip")
|
||||
|
||||
-- we will be called once for every IP Header.
|
||||
-- If there's more than one IP header in a given packet we'll dump the packet once per every header
|
||||
function tap.packet(pinfo,tvb,ip)
|
||||
local ip_src, ip_dst = tostring(ip.ip_src), tostring(ip.ip_dst)
|
||||
local src_dmp, dst_dmp
|
||||
end
|
||||
|
||||
function tap.draw()
|
||||
for ip_addr,dumper in pairs(dumpers) do
|
||||
dumper:flush()
|
||||
end
|
||||
end
|
@ -0,0 +1 @@
|
||||
{"leaves":["createDir"],"nodes":[{"leaves":["packet","draw"],"name":"tap"}],"root":"unitTest"}
|
107
PowerEditor/installer/functionList/lua.xml
Normal file
107
PowerEditor/installer/functionList/lua.xml
Normal file
@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!-- Copied from https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4563 -->
|
||||
<NotepadPlus>
|
||||
<functionList>
|
||||
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
| Based on:
|
||||
| http://stackoverflow.com/questions/19246077/how-to-add-lua-functions-to-the-notepad-functionlist-xml
|
||||
|
|
||||
| Note(s):
|
||||
| 1) Multi Line Comment `Level` is supported by Lua 5.1 and above;
|
||||
| 2) Nested table view not supported;
|
||||
\-->
|
||||
<parser
|
||||
displayName="Lua w/ Class"
|
||||
id ="lua_syntax"
|
||||
commentExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
|
||||
(?s: # Multi Line Comment (MLC)
|
||||
(?<!-) # - no preceeding dash, otherwise start of SLC
|
||||
-{2}\x5B(?'MLCLvl'=*)\x5B.*?\x5D\k'MLCLvl'\x5D
|
||||
)
|
||||
| (?m-s:-{2}(?!\x5B=*\x5B).*$) # Single Line Comment (SLC)
|
||||
| (?s:\x22(?:[^\x22\x5C]|\x5C.)*\x22) # String Literal - Double Quoted (SLDQ) / Normal String
|
||||
| (?s: # String Literal - Multi Line (SLML) / Long String
|
||||
(?<!-{2}) # - no preceeding double dash, otherwise start of MLC or SLC
|
||||
\x5B(?'SLMLLvl'=*)\x5B(?:[^\x5C\x5D]|\x5C.)*\x5D\k'SLMLLvl'\x5D
|
||||
)
|
||||
| (?s:\x27(?:[^\x27\x5C]|\x5C.)*\x27) # String Literal - Single Quoted (SLSQ) / Char String
|
||||
"
|
||||
>
|
||||
<classRange
|
||||
mainExpr ="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
|
||||
[.\w]+
|
||||
\s*=
|
||||
\s*\{
|
||||
"
|
||||
openSymbole ="\{"
|
||||
closeSymbole="\}"
|
||||
>
|
||||
<className>
|
||||
<nameExpr expr="[.\w]+" />
|
||||
</className>
|
||||
<function
|
||||
mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
|
||||
[.\w]+
|
||||
\s*=
|
||||
\s*(?'QT'[\x22\x27]?)\w+\k'QT'
|
||||
"
|
||||
>
|
||||
<functionName>
|
||||
<funcNameExpr expr=".*" />
|
||||
</functionName>
|
||||
</function>
|
||||
</classRange>
|
||||
<function
|
||||
mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
|
||||
(?m-i) # ^ and $ match at line-breaks, case-sensitive
|
||||
(?(DEFINE) # definition of sub-routine(s)
|
||||
(?'VALID_ID' # Valid Identifier sub-routine
|
||||
\b(?!(?-i: # - keywords (case-sensitive), not to be used as identifier
|
||||
and
|
||||
| break
|
||||
| do
|
||||
| e(?:lse(?:if)?|nd)
|
||||
| f(?:alse|or|unction)
|
||||
| goto
|
||||
| i[fn]
|
||||
| local
|
||||
| n(?:il|ot)
|
||||
| or
|
||||
| re(?:peat|turn)
|
||||
| t(?:hen|rue)
|
||||
| until
|
||||
| while
|
||||
)\b)
|
||||
[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]* # - valid character combination for identifiers
|
||||
)
|
||||
)
|
||||
(?m) # ^ and $ match at line-breaks
|
||||
(?:
|
||||
^\h* # optional leading white-space at start-of-line
|
||||
(?:local\s+)?
|
||||
function\s+
|
||||
\K # discard text matched so far
|
||||
(?&VALID_ID)
|
||||
(?:\s*\.\s*(?&VALID_ID))*
|
||||
(?:\s*:\s*(?&VALID_ID))?
|
||||
|
|
||||
(?&VALID_ID)
|
||||
(?:\s*\.\s*(?&VALID_ID))*
|
||||
\s*=
|
||||
\s*function
|
||||
)
|
||||
\s*\( # start-of-parameter-list indicator
|
||||
[^)]* # optional parameters
|
||||
\) # end-of-parameter-list indicator
|
||||
"
|
||||
>
|
||||
<functionName>
|
||||
<nameExpr expr="[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*(?=\s*[(=])" />
|
||||
</functionName>
|
||||
<className>
|
||||
<nameExpr expr="[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*(?:\s*\.\s*[A-Za-z_\x7F-\xFF][\w\x7F-\xFF]*)*(?=\s*[.:])" />
|
||||
</className>
|
||||
</function>
|
||||
</parser>
|
||||
</functionList>
|
||||
</NotepadPlus>
|
Loading…
x
Reference in New Issue
Block a user