From 42ec7286b2d36a9ba22925f816a17cb1cc2aa5ce Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 30 Oct 2021 11:32:16 +0800 Subject: + Penlight --- .../Penlight/docs/examples/sipscan.lua.html | 161 +++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 Data/Libraries/Penlight/docs/examples/sipscan.lua.html (limited to 'Data/Libraries/Penlight/docs/examples/sipscan.lua.html') diff --git a/Data/Libraries/Penlight/docs/examples/sipscan.lua.html b/Data/Libraries/Penlight/docs/examples/sipscan.lua.html new file mode 100644 index 0000000..8848423 --- /dev/null +++ b/Data/Libraries/Penlight/docs/examples/sipscan.lua.html @@ -0,0 +1,161 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

sipscan.lua

+
+-- another SIP example, shows how an awkward log file format
+-- can be parsed. It also prints out the actual Lua string
+-- pattern generated:
+-- SYNC%s*%[([+%-%d]%d*)%]%s*([+%-%d]%d*)%s*([+%-%d]%d*)
+
+local sip = require 'pl.sip'
+local stringx = require 'pl.stringx'
+
+local s = [[
+SYNC [1] 0 547 (14679 sec)
+SYNC [2] 0 555 (14679 sec)
+SYNC [3] 0 563 (14679 sec)
+SYNC [4] 0 571 (14679 sec)
+SYNC [5] -1 580 (14679 sec)
+SYNC [6] 0 587 (14679 sec)
+]]
+
+
+local first = true
+local expected
+local res = {}
+local pat = 'SYNC [$i{seq}] $i{diff} $i{val}'
+print(sip.create_pattern(pat))
+local match = sip.compile(pat)
+for line in stringx.lines(s) do
+  if match(line,res) then
+    if first then
+      expected = res.val
+      first = false
+    end
+    print(res.val,expected - res.val)
+    expected = expected + 8
+  end
+end
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + -- cgit v1.1-26-g67d0