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/testglobal.lua.html | 153 +++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 Data/Libraries/Penlight/docs/examples/testglobal.lua.html (limited to 'Data/Libraries/Penlight/docs/examples/testglobal.lua.html') diff --git a/Data/Libraries/Penlight/docs/examples/testglobal.lua.html b/Data/Libraries/Penlight/docs/examples/testglobal.lua.html new file mode 100644 index 0000000..e05a1f8 --- /dev/null +++ b/Data/Libraries/Penlight/docs/examples/testglobal.lua.html @@ -0,0 +1,153 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

testglobal.lua

+
+-- very simple lexer program which looks at all identifiers in a Lua
+-- file and checks whether they're in the global namespace.
+-- At the end, we dump out the result of count_map, which will give us
+-- unique identifiers with their usage count.
+-- (an example of a program which itself needs to be careful about what
+-- goes into the global namespace)
+
+local utils = require 'pl.utils'
+local file = require 'pl.file'
+local lexer = require 'pl.lexer'
+local List = require 'pl.List'
+local pretty = require 'pl.pretty'
+local seq = require 'pl.seq'
+local path = require 'pl.path'
+
+utils.on_error 'quit'
+
+local txt = file.read(arg[1] or path.normpath('examples/testglobal.lua'))
+local globals = List()
+for t,v in lexer.lua(txt) do
+	if t == 'iden' and rawget(_G,v) then
+		globals:append(v)
+	end
+end
+
+pretty.dump(seq.count_map(globals))
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + -- cgit v1.1-26-g67d0