Full Code of akkartik/teliva for AI

main 618b49fbf3db cached
169 files
1.6 MB
511.7k tokens
1467 symbols
1 requests
Download .txt
Showing preview only (1,736K chars total). Download the full file or copy to clipboard to get everything.
Repository: akkartik/teliva
Branch: main
Commit: 618b49fbf3db
Files: 169
Total size: 1.6 MB

Directory structure:
gitextract_eymj815d/

├── .gitattributes
├── .gitignore
├── COPYRIGHT.md
├── Makefile
├── README.md
├── anagrams.tlv
├── break.tlv
├── chesstv.tlv
├── counter.tlv
├── doc/
│   ├── contents.html
│   ├── lua.css
│   ├── manual.css
│   └── manual.html
├── gemini.tlv
├── graphviz.tlv
├── hanoi.tlv
├── life.tlv
├── lisp.lua
├── lisp.tlv
├── manual_tests
├── sandboxing/
│   ├── README.md
│   ├── includes
│   ├── system_includes
│   └── unique_system_includes
├── shell.nix
├── sieve.tlv
├── smol.tlv
├── src/
│   ├── Makefile
│   ├── file.lua
│   ├── json.lua
│   ├── jsonf.lua
│   ├── kilo.c
│   ├── lapi.c
│   ├── lapi.h
│   ├── lauxlib.c
│   ├── lauxlib.h
│   ├── lbaselib.c
│   ├── lcode.c
│   ├── lcode.h
│   ├── lcurses/
│   │   ├── Makefile
│   │   ├── _helpers.c
│   │   ├── chstr.c
│   │   ├── compat-5.2.c
│   │   ├── compat-5.2.h
│   │   ├── curses.c
│   │   ├── curses.lua
│   │   ├── strlcpy.c
│   │   └── window.c
│   ├── ldebug.c
│   ├── ldebug.h
│   ├── ldo.c
│   ├── ldo.h
│   ├── ldump.c
│   ├── lfunc.c
│   ├── lfunc.h
│   ├── lgc.c
│   ├── lgc.h
│   ├── linit.c
│   ├── liolib.c
│   ├── llex.c
│   ├── llex.h
│   ├── llimits.h
│   ├── lmathlib.c
│   ├── lmem.c
│   ├── lmem.h
│   ├── lobject.c
│   ├── lobject.h
│   ├── lopcodes.c
│   ├── lopcodes.h
│   ├── loslib.c
│   ├── lparser.c
│   ├── lparser.h
│   ├── lstate.c
│   ├── lstate.h
│   ├── lstring.c
│   ├── lstring.h
│   ├── lstrlib.c
│   ├── ltable.c
│   ├── ltable.h
│   ├── ltablib.c
│   ├── ltm.c
│   ├── ltm.h
│   ├── lua.c
│   ├── lua.h
│   ├── luaconf.h
│   ├── lualib.h
│   ├── luasec/
│   │   ├── Makefile
│   │   ├── compat.h
│   │   ├── config.c
│   │   ├── context.c
│   │   ├── context.h
│   │   ├── ec.c
│   │   ├── ec.h
│   │   ├── https.lua
│   │   ├── options.c
│   │   ├── options.h
│   │   ├── options.lua
│   │   ├── ssl.c
│   │   ├── ssl.h
│   │   ├── ssl.lua
│   │   ├── x509.c
│   │   └── x509.h
│   ├── luasocket/
│   │   ├── auxiliar.c
│   │   ├── auxiliar.h
│   │   ├── buffer.c
│   │   ├── buffer.h
│   │   ├── compat.c
│   │   ├── compat.h
│   │   ├── except.c
│   │   ├── except.h
│   │   ├── ftp.lua
│   │   ├── headers.lua
│   │   ├── http.lua
│   │   ├── inet.c
│   │   ├── inet.h
│   │   ├── io.c
│   │   ├── io.h
│   │   ├── ltn12.lua
│   │   ├── luasocket.c
│   │   ├── luasocket.h
│   │   ├── makefile
│   │   ├── mbox.lua
│   │   ├── mime.c
│   │   ├── mime.h
│   │   ├── mime.lua
│   │   ├── options.c
│   │   ├── options.h
│   │   ├── pierror.h
│   │   ├── select.c
│   │   ├── select.h
│   │   ├── serial.c
│   │   ├── smtp.lua
│   │   ├── socket.h
│   │   ├── socket.lua
│   │   ├── tcp.c
│   │   ├── tcp.h
│   │   ├── timeout.c
│   │   ├── timeout.h
│   │   ├── tp.lua
│   │   ├── udp.c
│   │   ├── udp.h
│   │   ├── unix.c
│   │   ├── unix.h
│   │   ├── unixdgram.c
│   │   ├── unixdgram.h
│   │   ├── unixstream.c
│   │   ├── unixstream.h
│   │   ├── url.lua
│   │   ├── usocket.c
│   │   ├── usocket.h
│   │   ├── wsocket.c
│   │   └── wsocket.h
│   ├── lundump.c
│   ├── lundump.h
│   ├── lvm.c
│   ├── lvm.h
│   ├── lzio.c
│   ├── lzio.h
│   ├── realpath.c
│   ├── task.lua
│   ├── teliva.c
│   ├── teliva.h
│   ├── tlv.c
│   ├── tlv.h
│   └── vimrc.vim
├── template.tlv
├── toot-toot.tlv
├── tour.md
└── zet.tlv

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitattributes
================================================
*.teliva linguist-language=Lua
*.tlv linguist-language=Lua


================================================
FILE: .gitignore
================================================
*.o
*.a


================================================
FILE: COPYRIGHT.md
================================================
Lua License
-----------

Lua is licensed under the terms of the MIT license reproduced below.
This means that Lua is free software and can be used for both academic
and commercial purposes at absolutely no cost.

For details and rationale, see http://www.lua.org/license.html .

===============================================================================

Copyright (C) 1994-2012 Lua.org, PUC-Rio.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

===============================================================================


================================================
FILE: Makefile
================================================
# makefile for installing Lua
# see INSTALL for installation instructions
# see src/Makefile and src/luaconf.h for further customization

# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT =======================

# Your platform. See PLATS for possible values.
PLAT= none

# Where to install. The installation starts in the src and doc directories,
# so take care if INSTALL_TOP is not an absolute path.
INSTALL_TOP= /usr/local
INSTALL_BIN= $(INSTALL_TOP)/bin
INSTALL_INC= $(INSTALL_TOP)/include
INSTALL_LIB= $(INSTALL_TOP)/lib
INSTALL_MAN= $(INSTALL_TOP)/man/man1
#
# You probably want to make INSTALL_LMOD and INSTALL_CMOD consistent with
# LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h (and also with etc/lua.pc).
INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V

# How to install. If your install program does not support "-p", then you
# may have to run ranlib on the installed liblua.a (do "make ranlib").
INSTALL= install -p
INSTALL_EXEC= $(INSTALL) -m 0755
INSTALL_DATA= $(INSTALL) -m 0644
#
# If you don't have install you can use cp instead.
# INSTALL= cp -p
# INSTALL_EXEC= $(INSTALL)
# INSTALL_DATA= $(INSTALL)

# Utilities.
MKDIR= mkdir -p
RANLIB= ranlib

# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========

# Keep this sync'd with src/Makefile
PLATS= freebsd linux macosx netbsd openbsd

# What to install.
TO_BIN= lua luac
TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
TO_LIB= liblua.a
TO_MAN= lua.1 luac.1

# Lua version and release.
V= 5.1
R= 5.1.5

all:	$(PLAT)

$(PLATS) clean:
	cd src && $(MAKE) $@

install: dummy
	cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
	cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
	cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
	cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
	cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)

ranlib:
	cd src && cd $(INSTALL_LIB) && $(RANLIB) $(TO_LIB)

local:
	$(MAKE) install INSTALL_TOP=..

none:
	@echo "Please do"
	@echo "   make PLATFORM"
	@echo "where PLATFORM is one of these:"
	@echo "   $(PLATS)"
	@echo "See INSTALL for complete instructions."

# make may get confused with test/ and INSTALL in a case-insensitive OS
dummy:

# echo config parameters
echo:
	@echo ""
	@echo "These are the parameters currently set in src/Makefile to build Lua $R:"
	@echo ""
	@cd src && $(MAKE) -s echo
	@echo ""
	@echo "These are the parameters currently set in Makefile to install Lua $R:"
	@echo ""
	@echo "PLAT = $(PLAT)"
	@echo "INSTALL_TOP = $(INSTALL_TOP)"
	@echo "INSTALL_BIN = $(INSTALL_BIN)"
	@echo "INSTALL_INC = $(INSTALL_INC)"
	@echo "INSTALL_LIB = $(INSTALL_LIB)"
	@echo "INSTALL_MAN = $(INSTALL_MAN)"
	@echo "INSTALL_LMOD = $(INSTALL_LMOD)"
	@echo "INSTALL_CMOD = $(INSTALL_CMOD)"
	@echo "INSTALL_EXEC = $(INSTALL_EXEC)"
	@echo "INSTALL_DATA = $(INSTALL_DATA)"
	@echo ""
	@echo "See also src/luaconf.h ."
	@echo ""

# echo private config parameters
pecho:
	@echo "V = $(V)"
	@echo "R = $(R)"
	@echo "TO_BIN = $(TO_BIN)"
	@echo "TO_INC = $(TO_INC)"
	@echo "TO_LIB = $(TO_LIB)"
	@echo "TO_MAN = $(TO_MAN)"

# echo config parameters as Lua code
# uncomment the last sed expression if you want nil instead of empty strings
lecho:
	@echo "-- installation parameters for Lua $R"
	@echo "VERSION = '$V'"
	@echo "RELEASE = '$R'"
	@$(MAKE) echo | grep = | sed -e 's/= /= "/' -e 's/$$/"/' #-e 's/""/nil/'
	@echo "-- EOF"

# list targets that do not create files (but not all makes understand .PHONY)
.PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho

# (end of Makefile)


================================================
FILE: README.md
================================================
# Teliva - an environment for end-user programming

> “Enable all people to modify the software they use in the course of using it.”
> — https://futureofcoding.org/episodes/033.html

> “What if we, and all computer users, could reach in and modify our favorite apps?”
> — https://www.inkandswitch.com/end-user-programming

> “Software must be as easy to change as it is to use.”
> — https://malleable.systems

## What's this, then?

Teliva is the most naive way to make software as easy to change as it is to
use: an interpreted environment for running shareable little text-mode apps.
Its language of choice is Lua, excluding all features that can conceivably
introduce moving parts in running a Lua program.

Here's how you run one of the example apps (the [Tower of Hanoi](https://en.wikipedia.org/wiki/Tower_of_Hanoi)):

```sh
git clone https://github.com/akkartik/teliva
cd teliva
make linux  # replace with 'macosx', etc. depending on your OS
src/teliva hanoi.tlv
```

![screenshot of Teliva running the Towers of Hanoi](doc/hanoi.png)

No matter what app you run, you are always guaranteed access to a single
obvious, consistent way (currently the hotkey `ctrl-u`) to inspect its
sources.

When you look under the hood of an app, the first thing you see is a
_big-picture view_ which shows the app's major data structures and a top-down
view of the app's code.

![screenshot of big-picture view for the Towers of Hanoi](doc/hanoi-big-picture.png)

Select a definition, make a change, hit `ctrl-x`, and the app will run with
your updates. ([video](https://archive.org/details/akkartik-2021-11-14))

You will need some Unix-like platform with a C compiler and the ncurses and
openssl libraries. Some possible commands to install them, depending on your
OS and package manager of choice:

* `guix shell -D lua openssl -- make linux`
* `nix-shell --pure` (from a directory containing shell.nix in this repo)
* `sudo apt install libncursesw6-dev openssl`
* `brew install ncurses openssl`

So far I've tested Teliva on Linux, Mac OS X, OpenBSD, NetBSD and FreeBSD; it
should work on other flavors of BSD, WSL on Windows, etc. with only minor
modifications.

## What else can it do?

Anything! Some more sample apps to try out:

* Conway's Game of Life, as an example of an animated local app.
  ```
  src/teliva life.tlv
  ```

  [video](https://merveilles.town/@akkartik/107277755421024772)

* A viewer for [LiChess TV](https://lichess.org/tv), as an example of
  animation and accessing a remote API over a network.
  ```
  src/teliva chesstv.tlv
  ```

  [video](https://merveilles.town/@akkartik/107319684018301051)

* A browser for the [Gemini protocol](https://gemini.circumlunar.space).
  ```
  src/teliva gemini.tlv
  ```

  [video](https://merveilles.town/@akkartik/107489728557201145)

These are just a start. The sky is the limit.

## So, just a programming language, then?

There's one big difference with other programming languages: Teliva apps are
sandboxed like a browser. Most languages assume the fiction that the person
running a program trusts all the code in the program. This assumption hasn't
been valid since a decade after the Unix big bang, if then. Teliva takes on
the reality that apps can get complex and use code written by strangers. In
response, Teliva tries to always summarize for you what the program you're
running is trying to do, and to ask you before a random app tries to do
something sensitive. Permissions you grant a Teliva app will be _flexible_ and
_easy to understand_. Browsers and mobile apps today tend to make you choose
between those two properties.

The sandboxing experience is still under construction. See [this talk](https://archive.org/details/akkartik-2022-01-16-fosdem)
(15 minutes) for a rundown of current thinking. It isn't yet safe to run
untrusted Teliva apps you download from the internet. (Fortunately you're
unlikely to run into any such apps.)

## Isn't this just an IDE?

There's one big difference: these apps are not intended to be runnable outside
of the Teliva environment. Editing the sources and visualizing permissions
granted will always be core features that are front and center in the UI.

A second, more subtle difference: it's primarily an environment for _running_
apps, and only secondarily for editing them. Starting up the environment puts
you in a running app by default. Creating an app from a clean slate is a
low-priority use case, as is lots of specialized support for developing
complex apps. The sweet spot for Teliva is simple apps that people will want
to edit after using for a while.

## Who are we trusting by trusting you?

Teliva is designed to have a shallow, manageable software supply chain. I
rely on packages distributed by the following reputable brands:

* A well-known Posix OS, either Linux or BSD.
* A standard C library, usually GNU libc.
* The [ncurses](https://tldp.org/HOWTO/NCURSES-Programming-HOWTO) library for
  building text-mode user interfaces. ([Alternative documentation](https://tldp.org/LDP/lpg-0.4.pdf))

Teliva's codebase also includes forks of the following reputable brands:

* [Lua 5.1](https://www.lua.org/manual/5.1)
* The [Kilo](https://github.com/antirez/kilo) text editor, modified to use
  ncurses. (Read more about it in this [fantastic walk-through](https://viewsourcecode.org/snaptoken/kilo).)
* The [lcurses](https://github.com/lcurses/lcurses) binding for ncurses (as
  module `curses`).
* The [luasocket](https://w3.impa.br/~diego/software/luasocket) library of
  networking primitives (modules `socket`, `http`, `url`, `headers`, `mime`,
  `ltn12`).
* The [luasec](https://github.com/brunoos/luasec) library for HTTPS support
  (modules `https` and `ssl`).
* The [json.lua](https://github.com/rxi/json.lua) library for
  serializing/deserializing to JSON (modules `json` and `jsonf`).

I only add to this list with great deliberation. Since it includes indirect
suppliers (suppliers of suppliers), I have an incentive to only include
suppliers who also have shallow supply chains. Minimizing the size of the
supply chain should result in more reliable software that requires less
frequent upgrades.

(Look in [the manual](https://akkartik.github.io/teliva/doc/manual.html) for
more details of what's available.)

## Why Lua?

It's reputedly the fastest interpreted language per line of implementation
code.

## Will it run any Lua program?

Not quite. My priority is providing a good experience for newcomers to
comprehend and modify the programs they use. If it's not clear how to provide
that experience for some kinds of Lua programs, I'd rather disable support for
them in Teliva and let people use regular Lua. Or other platforms!

- This approach doesn't make sense for batch programs, I think. I also don't
  yet have a good story for building server programs in this way.

- I don't know how to obtain a simple, shallow graphics stack, so there's no
  support for graphics at the moment.

- Teliva initializes the ncurses library by default, so apps should assume
  they have access to a (color, UTF-8) text-mode window for printing text to,
  and a keyboard for reading keystrokes from.

- Teliva doesn't use files for source code, so the `require` keyword no longer
  makes sense. You get some libraries preloaded (see below). Beyond those,
  apps should include all Lua code they want to use.

- To create a well-behaved sandbox, Teliva doesn't support adding libraries
  with C bindings beyond the few it starts up with.

- Functions that start with `test_` are special. They're considered automated
  tests and called without arguments every time an app starts up.

- The function `main` is special. It runs every time an app starts up, if all
  its automated tests pass.

- Some functions are disabled because I don't know how to sandbox them
  effectively:
  - `os.execute`, `os.getenv`, `io.popen`
  - `io.lines` (not a security issue; just difficult to distinguish missing
    files from sandboxing issues)

- Some functions are disabled because they don't seem to make sense in an
  ncurses environment. This includes the Lua notions of default files, which
  start out as stdin/stdout.
  - `io.input`, `io.read`
  - `io.output`, `io.write`, `io.flush`
  - `curses.getstr()`, `curses.mvgetstr()` (When using these it's easy for the
    screen to get confusing.)

- Some functions in lcurses have [additional smarts](https://github.com/lcurses/lcurses/blob/master/lib/curses.lua).
  Teliva is [consistent with the underlying ncurses](https://github.com/akkartik/teliva/blob/main/src/lcurses/curses.lua).

Look in [the manual](https://akkartik.github.io/teliva/doc/manual.html) for
more details of what's available.

I may delete more capabilities throughout this stack as I discover features
that don't fit well with the Teliva experience. If you find Teliva of use,
please [introduce yourself](http://akkartik.name/contact) to me so that I am
aware of your use cases. Anybody who is interested can gain a say in its
future direction.

## What's with the name?

Teliva is the Tamil root for ‘clear’. Very much aspirational.

## Known issues

* Colors are currently hardcoded. You get a light background even if your
  terminal started out dark. To tweak colors, look for calls to
  `assume_default_colors()` and `init_pair()`, either in .tlv files for a
  specific app, or in the C sources for the standard code browser/editor.

* Backspace is known to not work in some configurations. As a workaround,
  typing `ctrl-h` tends to work in those situations.

* Keys outside the main keyboard area are mostly not supported. This includes
  the delete key when it's set away from the main keyboard area. (Macs call
  the backspace key “delete”; it should behave like backspace. As
  a consequence the menu sometimes mentions keys that don't work, just to
  encourage people to try options.)

* chesstv.tlv silently fails on OpenBSD and NetBSD for some reason I haven't
  investigated yet. Interestingly, I'm running Teliva with curses on NetBSD
  but ncurses on OpenBSD, so that is probably not an issue.

* life.tlv looks terrible on OpenBSD and NetBSD, with lines wrapping halfway.

## Mirrors and Forks

Updates to Teliva can be downloaded from the following mirrors:
* https://github.com/akkartik/teliva
* https://repo.or.cz/teliva.git
* https://codeberg.org/akkartik/teliva
* https://tildegit.org/akkartik/teliva
* https://git.tilde.institute/akkartik/teliva
* https://git.sr.ht/~akkartik/teliva
* https://pagure.io/teliva

Forks of Teliva are encouraged. If you show me your fork, I'll link to it
here.

## Feedback

[Most appreciated.](http://akkartik.name/contact)


================================================
FILE: anagrams.tlv
================================================
# .tlv file generated by https://github.com/akkartik/teliva
# You may edit it if you are careful; however, you may see cryptic errors if you
# violate Teliva's assumptions.
#
# .tlv files are representations of Teliva programs. Teliva programs consist of
# sequences of definitions. Each definition is a table of key/value pairs. Keys
# and values are both strings.
#
# Lines in .tlv files always follow exactly one of the following forms:
# - comment lines at the top of the file starting with '#' at column 0
# - beginnings of definitions starting with '- ' at column 0, followed by a
#   key/value pair
# - key/value pairs consisting of '  ' at column 0, containing either a
#   spaceless value on the same line, or a multi-line value
# - multiline values indented by more than 2 spaces, starting with a '>'
#
# If these constraints are violated, Teliva may unceremoniously crash. Please
# report bugs at http://akkartik.name/contact
- __teliva_timestamp: original
  str_helpers:
    >-- some string helpers from http://lua-users.org/wiki/StringIndexing
    >
    >-- index characters using []
    >getmetatable('').__index = function(str,i)
    >  if type(i) == 'number' then
    >    return str:sub(i,i)
    >  else
    >    return string[i]
    >  end
    >end
    >
    >-- ranges using (), selected bytes using {}
    >getmetatable('').__call = function(str,i,j)
    >  if type(i)~='table' then
    >    return str:sub(i,j)
    >  else
    >    local t={}
    >    for k,v in ipairs(i) do
    >      t[k]=str:sub(v,v)
    >    end
    >    return table.concat(t)
    >  end
    >end
    >
    >-- iterate over an ordered sequence
    >function q(x)
    >  if type(x) == 'string' then
    >    return x:gmatch('.')
    >  else
    >    return ipairs(x)
    >  end
    >end
    >
    >-- insert within string
    >function string.insert(str1, str2, pos)
    >  return str1:sub(1,pos)..str2..str1:sub(pos+1)
    >end
    >
    >function string.remove(s, pos)
    >  return s:sub(1,pos-1)..s:sub(pos+1)
    >end
    >
    >function string.pos(s, sub)
    >  return string.find(s, sub, 1, true)  -- plain=true to disable regular expressions
    >end
    >
    >-- TODO: backport utf-8 support from Lua 5.3
- __teliva_timestamp: original
  debugy:
    >debugy = 5
- __teliva_timestamp: original
  dbg:
    >-- helper for debug by print; overlay debug information towards the right
    >-- reset debugy every time you refresh screen
    >function dbg(window, s)
    >  local oldy = 0
    >  local oldx = 0
    >  oldy, oldx = window:getyx()
    >  window:mvaddstr(debugy, 60, s)
    >  debugy = debugy+1
    >  window:mvaddstr(oldy, oldx, '')
    >end
- __teliva_timestamp: original
  check:
    >function check(x, msg)
    >  if x then
    >    Window:addch('.')
    >  else
    >    print('F - '..msg)
    >    print('  '..str(x)..' is false/nil')
    >    teliva_num_test_failures = teliva_num_test_failures + 1
    >    -- overlay first test failure on editors
    >    if teliva_first_failure == nil then
    >      teliva_first_failure = msg
    >    end
    >  end
    >end
- __teliva_timestamp: original
  check_eq:
    >function check_eq(x, expected, msg)
    >  if eq(x, expected) then
    >    Window:addch('.')
    >  else
    >    print('F - '..msg)
    >    print('  expected '..str(expected)..' but got '..str(x))
    >    teliva_num_test_failures = teliva_num_test_failures + 1
    >    -- overlay first test failure on editors
    >    if teliva_first_failure == nil then
    >      teliva_first_failure = msg
    >    end
    >  end
    >end
- __teliva_timestamp: original
  eq:
    >function eq(a, b)
    >  if type(a) ~= type(b) then return false end
    >  if type(a) == 'table' then
    >    if #a ~= #b then return false end
    >    for k, v in pairs(a) do
    >      if b[k] ~= v then
    >        return false
    >      end
    >    end
    >    for k, v in pairs(b) do
    >      if a[k] ~= v then
    >        return false
    >      end
    >    end
    >    return true
    >  end
    >  return a == b
    >end
- __teliva_timestamp: original
  str:
    >-- smarter tostring
    >-- slow; used only for debugging
    >function str(x)
    >  if type(x) == 'table' then
    >    local result = ''
    >    result = result..#x..'{'
    >    for k, v in pairs(x) do
    >      result = result..str(k)..'='..str(v)..', '
    >    end
    >    result = result..'}'
    >    return result
    >  elseif type(x) == 'string' then
    >    return '"'..x..'"'
    >  end
    >  return tostring(x)
    >end
- __teliva_timestamp: original
  find_index:
    >function find_index(arr, x)
    >  for n, y in ipairs(arr) do
    >    if x == y then
    >      return n
    >    end
    >  end
    >end
- __teliva_timestamp: original
  trim:
    >function trim(s)
    >  return s:gsub('^%s*', ''):gsub('%s*$', '')
    >end
- __teliva_timestamp: original
  split:
    >function split(s, d)
    >  result = {}
    >  for match in (s..d):gmatch("(.-)"..d) do
    >    table.insert(result, match);
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  map:
    >-- only for arrays
    >function map(l, f)
    >  result = {}
    >  for _, x in ipairs(l) do
    >    table.insert(result, f(x))
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  reduce:
    >-- only for arrays
    >function reduce(l, f, init)
    >  result = init
    >  for _, x in ipairs(l) do
    >    result = f(result, x)
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  filter:
    >function filter(h, f)
    >  result = {}
    >  for k, v in pairs(h) do
    >    if f(k, v) then
    >      result[k] = v
    >    end
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  ifilter:
    >-- only for arrays
    >function ifilter(l, f)
    >  result = {}
    >  for _, x in ipairs(l) do
    >    if f(x) then
    >      table.insert(result, x)
    >    end
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  sort_letters:
    >function sort_letters(s)
    >  tmp = {}
    >  for i=1,#s do
    >    table.insert(tmp, s[i])
    >  end
    >  table.sort(tmp)
    >  local result = ''
    >  for _, c in pairs(tmp) do
    >    result = result..c
    >  end
    >  return result
    >end
    >
    >function test_sort_letters(s)
    >  check_eq(sort_letters(''), '', 'test_sort_letters: empty')
    >  check_eq(sort_letters('ba'), 'ab', 'test_sort_letters: non-empty')
    >  check_eq(sort_letters('abba'), 'aabb', 'test_sort_letters: duplicates')
    >end
- __teliva_timestamp: original
  count_letters:
    >-- TODO: handle unicode
    >function count_letters(s)
    >  local result = {}
    >  for i=1,s:len() do
    >    local c = s[i]
    >    if result[c] == nil then
    >      result[c] = 1
    >    else
    >      result[c] = result[c] + 1
    >    end
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  count:
    >-- turn an array of elements into a map from elements to their frequency
    >-- analogous to count_letters for non-strings
    >function count(a)
    >  local result = {}
    >  for i, v in ipairs(a) do
    >    if result[v] == nil then
    >      result[v] = 1
    >    else
    >      result[v] = result[v] + 1
    >    end
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  union:
    >function union(a, b)
    >  for k, v in pairs(b) do
    >    a[k] = v
    >  end
    >  return a
    >end
- __teliva_timestamp: original
  subtract:
    >-- set subtraction
    >function subtract(a, b)
    >  for k, v in pairs(b) do
    >    a[k] = nil
    >  end
    >  return a
    >end
- __teliva_timestamp: original
  all:
    >-- universal quantifier on sets
    >function all(s, f)
    >  for k, v in pairs(s) do
    >    if not f(k, v) then
    >      return false
    >    end
    >  end
    >  return true
    >end
- __teliva_timestamp: original
  to_array:
    >-- turn a set into an array
    >-- drops values
    >function to_array(h)
    >  local result = {}
    >  for k, _ in pairs(h) do
    >    table.insert(result, k)
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  append:
    >-- concatenate list 'elems' into 'l', modifying 'l' in the process
    >function append(l, elems)
    >  for i=1,#elems do
    >    table.insert(l, elems[i])
    >  end
    >end
- __teliva_timestamp: original
  prepend:
    >-- concatenate list 'elems' into the start of 'l', modifying 'l' in the process
    >function prepend(l, elems)
    >  for i=1,#elems do
    >    table.insert(l, i, elems[i])
    >  end
    >end
- __teliva_timestamp: original
  all_but:
    >function all_but(x, idx)
    >  if type(x) == 'table' then
    >    local result = {}
    >    for i, elem in ipairs(x) do
    >      if i ~= idx then
    >        table.insert(result,elem)
    >      end
    >    end
    >    return result
    >  elseif type(x) == 'string' then
    >    if idx < 1 then return x:sub(1) end
    >    return x:sub(1, idx-1) .. x:sub(idx+1)
    >  else
    >    error('all_but: unsupported type '..type(x))
    >  end
    >end
    >
    >function test_all_but()
    >  check_eq(all_but('', 0), '', 'all_but: empty')
    >  check_eq(all_but('abc', 0), 'abc', 'all_but: invalid low index')
    >  check_eq(all_but('abc', 4), 'abc', 'all_but: invalid high index')
    >  check_eq(all_but('abc', 1), 'bc', 'all_but: first index')
    >  check_eq(all_but('abc', 3), 'ab', 'all_but: final index')
    >  check_eq(all_but('abc', 2), 'ac', 'all_but: middle index')
    >end
- __teliva_timestamp: original
  set:
    >function set(l)
    >  local result = {}
    >  for i, elem in ipairs(l) do
    >    result[elem] = true
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  set_eq:
    >function set_eq(l1, l2)
    >  return eq(set(l1), set(l2))
    >end
    >
    >function test_set_eq()
    >  check(set_eq({1}, {1}), 'set_eq: identical')
    >  check(not set_eq({1, 2}, {1, 3}), 'set_eq: different')
    >  check(set_eq({1, 2}, {2, 1}), 'set_eq: order')
    >  check(set_eq({1, 2, 2}, {2, 1}), 'set_eq: duplicates')
    >end
- __teliva_timestamp: original
  clear:
    >function clear(lines)
    >  while #lines > 0 do
    >    table.remove(lines)
    >  end
    >end
- __teliva_timestamp: original
  zap:
    >function zap(target, src)
    >  clear(target)
    >  append(target, src)
    >end
- __teliva_timestamp: original
  mfactorial:
    >-- memoized version of factorial
    >-- doesn't memoize recursive calls, but may be good enough
    >mfactorial = memo1(factorial)
- __teliva_timestamp: original
  factorial:
    >function factorial(n)
    >  local result = 1
    >  for i=1,n do
    >    result = result*i
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  memo1:
    >-- a higher-order function that takes a function of a single arg
    >-- (that never returns nil)
    >-- and returns a memoized version of it
    >function memo1(f)
    >  local memo = {}
    >  return function(x)
    >    if memo[x] == nil then
    >      memo[x] = f(x)
    >    end
    >    return memo[x]
    >  end
    >end
    >
    >-- mfactorial doesn't seem noticeably faster
    >function test_memo1()
    >  for i=0,30 do
    >    check_eq(mfactorial(i), factorial(i), 'memo1 over factorial: '..str(i))
    >  end
    >end
- __teliva_timestamp: original
  num_permutations:
    >-- number of permutations of n distinct objects, taken r at a time
    >function num_permutations(n, r)
    >  return factorial(n)/factorial(n-r)
    >end
    >
    >-- mfactorial doesn't seem noticeably faster
    >function test_memo1()
    >  for i=0,30 do
    >    for j=0,i do
    >      check_eq(num_permutations(i, j), mfactorial(i)/mfactorial(i-j), 'num_permutations memoizes: '..str(i)..'P'..str(j))
    >    end
    >  end
    >end
- __teliva_timestamp: original
  menu:
    >-- To show app-specific hotkeys in the menu bar, add hotkey/command
    >-- arrays of strings to the menu array.
    >menu = {
    >  {'^h', 'backspace'},
    >}
- __teliva_timestamp: original
  Window:
    >Window = curses.stdscr()
- __teliva_timestamp: original
  doc:blurb:
    >Show all anagrams of a given word
- __teliva_timestamp: original
  word:
    >word = ''
- __teliva_timestamp: original
  cursor:
    >cursor = 1
- __teliva_timestamp: original
  main:
    >function main()
    >  Window:nodelay(true)
    >  while true do
    >    render(Window)
    >    update(Window)
    >  end
    >end
- __teliva_timestamp: original
  update:
    >function update(window)
    >  local key
    >  while true do
    >    key = window:getch()
    >    if key then break end
    >  end
    >  if key == curses.KEY_LEFT then
    >    if cursor > 1 then
    >      cursor = cursor-1
    >    end
    >  elseif key == curses.KEY_RIGHT then
    >    if cursor <= #word then
    >      cursor = cursor+1
    >    end
    >  elseif key == curses.KEY_BACKSPACE or key == 8 or key == 127 then  -- ctrl-h, ctrl-?, delete
    >    if cursor > 1 then
    >      cursor = cursor-1
    >      word = word:remove(cursor)
    >    end
    >  elseif key >= 32 and key < 127 then
    >    word = word:insert(string.char(key), cursor-1)
    >    cursor = cursor+1
    >  end
    >end
- __teliva_timestamp: original
  render:
    >function render(window)
    >  window:clear()
    >
    >  local prompt_str = ' what is your name? '
    >  window:attron(curses.A_REVERSE)
    >  window:mvaddstr(0, 0, prompt_str)
    >  window:attroff(curses.A_REVERSE)
    >  window:addstr(' ')
    >  window:attron(curses.A_BOLD)
    >  window:addstr(word)
    >  window:attroff(curses.A_BOLD)
    >  window:mvaddstr(2, 0, '')
    >  local results = anagrams(word)
    >  if #results > 0 then
    >    window:attron(curses.A_REVERSE)
    >    print(#results..' anagrams')
    >    window:attroff(curses.A_REVERSE)
    >    for i, w in ipairs(results) do
    >      window:addstr(w)
    >      window:addstr(' ')
    >    end
    >  end
    >
    >  window:mvaddstr(0, string.len(prompt_str)+cursor, '')
    >  window:refresh()
    >end
- __teliva_timestamp:
    >Mon Feb 21 17:42:28 2022
  anagrams:
    >function anagrams(word)
    >  return gather(sort_letters(word))
    >end
- __teliva_timestamp:
    >Mon Feb 21 18:18:07 2022
  gather:
    >function gather(s)
    >  if s == '' then return {} end
    >  local result = {}
    >  for i=1, #s do
    >    if i == 1 or s[i] ~= s[i-1] then
    >      append(result, combine(s[i], gather(all_but(s, i))))
    >    end
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  __teliva_note:
    >basic version
  combine:
    >-- return 'l' with each element prefixed with 'prefix'
    >function combine(prefix, l)
    >  if #l == 0 then return {prefix} end
    >  local result = {}
    >  for _, elem in ipairs(l) do
    >    table.insert(result, prefix..elem)
    >  end
    >  return result
    >end
    >
    >function test_combine()
    >  check_eq(combine('abc', {}), {'abc'}, 'test_combine: empty list')
    >end
- __teliva_timestamp:
    >Sat Mar  5 15:24:00 2022
  count_anagrams:
    >function count_anagrams(s)
    >  local result = factorial(s:len())
    >  local letter_counts = count_letters(s)
    >  for l, cnt in pairs(letter_counts) do
    >    result = result / factorial(cnt)
    >  end
    >  return result
    >end
- __teliva_timestamp:
    >Sat Mar  5 15:53:23 2022
  key_pressed:
    >-- only works when nodelay (non-blocking keyboard)
    >function key_pressed(window)
    >  local c = window:getch()
    >  if c == nil then return false end
    >  window:ungetch(c)
    >  return true
    >end
- __teliva_timestamp:
    >Sat Mar  5 15:55:34 2022
  render:
    >function render(window)
    >  window:clear()
    >
    >  local prompt_str = ' what is your name? '
    >  window:attron(curses.A_REVERSE)
    >  window:mvaddstr(0, 0, prompt_str)
    >  window:attroff(curses.A_REVERSE)
    >  window:addstr(' ')
    >  window:attron(curses.A_BOLD)
    >  window:addstr(word)
    >  window:attroff(curses.A_BOLD)
    >  window:mvaddstr(2, 0, '')
    >  if #word > 0 then
    >    local num_anagrams = count_anagrams(word)
    >    window:attron(curses.A_REVERSE)
    >    print(num_anagrams..' anagrams')
    >    window:attroff(curses.A_REVERSE)
    >    local results = anagrams(word)
    >    if results == nil then  -- interrupted
    >      window:addstr('...')
    >    else
    >      assert(#results == num_anagrams, "something's wrong; the count is unexpected")
    >      for i, w in ipairs(results) do
    >        window:addstr(w)
    >        window:addstr(' ')
    >        if key_pressed(window) then
    >          break
    >        end
    >      end
    >    end
    >  end
    >
    >  window:mvaddstr(0, string.len(prompt_str)+cursor, '')
    >  window:refresh()
    >end
- __teliva_timestamp:
    >Sat Mar  5 15:56:35 2022
  __teliva_note:
    >restart computation when a key is pressed
  gather:
    >-- return a list of unique permutations of a sorted string 's'
    >-- the letters in 's' must be in alphabetical order, so that duplicates are adjacent
    >-- this function can take a long time for long strings, so we make it interruptible
    >-- if a key is pressed, it returns nil
    >-- since it's recursive, we also need to handle recursive calls returning nil
    >function gather(s)
    >  if s == '' then return {} end
    >  local result = {}
    >  for i=1, #s do
    >    if i == 1 or s[i] ~= s[i-1] then
    >      local subresult = gather(all_but(s, i))
    >      if subresult == nil then return nil end  -- interrupted
    >      append(result, combine(s[i], subresult))
    >    end
    >    if key_pressed(Window) then return nil end  -- interrupted
    >  end
    >  return result
    >end


================================================
FILE: break.tlv
================================================
# .tlv file generated by https://github.com/akkartik/teliva
# You may edit it if you are careful; however, you may see cryptic errors if you
# violate Teliva's assumptions.
#
# .tlv files are representations of Teliva programs. Teliva programs consist of
# sequences of definitions. Each definition is a table of key/value pairs. Keys
# and values are both strings.
#
# Lines in .tlv files always follow exactly one of the following forms:
# - comment lines at the top of the file starting with '#' at column 0
# - beginnings of definitions starting with '- ' at column 0, followed by a
#   key/value pair
# - key/value pairs consisting of '  ' at column 0, containing either a
#   spaceless value on the same line, or a multi-line value
# - multiline values indented by more than 2 spaces, starting with a '>'
#
# If these constraints are violated, Teliva may unceremoniously crash. Please
# report bugs at http://akkartik.name/contact
- __teliva_timestamp: original
  str_helpers:
    >-- some string helpers from http://lua-users.org/wiki/StringIndexing
    >
    >-- index characters using []
    >getmetatable('').__index = function(str,i)
    >  if type(i) == 'number' then
    >    return str:sub(i,i)
    >  else
    >    return string[i]
    >  end
    >end
    >
    >-- ranges using (), selected bytes using {}
    >getmetatable('').__call = function(str,i,j)
    >  if type(i)~='table' then
    >    return str:sub(i,j)
    >  else
    >    local t={}
    >    for k,v in ipairs(i) do
    >      t[k]=str:sub(v,v)
    >    end
    >    return table.concat(t)
    >  end
    >end
    >
    >-- iterate over an ordered sequence
    >function q(x)
    >  if type(x) == 'string' then
    >    return x:gmatch('.')
    >  else
    >    return ipairs(x)
    >  end
    >end
    >
    >-- insert within string
    >function string.insert(str1, str2, pos)
    >  return str1:sub(1,pos)..str2..str1:sub(pos+1)
    >end
    >
    >function string.remove(s, pos)
    >  return s:sub(1,pos-1)..s:sub(pos+1)
    >end
    >
    >function string.pos(s, sub)
    >  return string.find(s, sub, 1, true)  -- plain=true to disable regular expressions
    >end
    >
    >-- TODO: backport utf-8 support from Lua 5.3
- __teliva_timestamp: original
  debugy:
    >debugy = 5
- __teliva_timestamp: original
  dbg:
    >-- helper for debug by print; overlay debug information towards the right
    >-- reset debugy every time you refresh screen
    >function dbg(window, s)
    >  local oldy = 0
    >  local oldx = 0
    >  oldy, oldx = window:getyx()
    >  window:mvaddstr(debugy, 60, s)
    >  debugy = debugy+1
    >  window:mvaddstr(oldy, oldx, '')
    >end
- __teliva_timestamp: original
  check:
    >function check(x, msg)
    >  if x then
    >    Window:addch('.')
    >  else
    >    print('F - '..msg)
    >    print('  '..str(x)..' is false/nil')
    >    teliva_num_test_failures = teliva_num_test_failures + 1
    >    -- overlay first test failure on editors
    >    if teliva_first_failure == nil then
    >      teliva_first_failure = msg
    >    end
    >  end
    >end
- __teliva_timestamp: original
  check_eq:
    >function check_eq(x, expected, msg)
    >  if eq(x, expected) then
    >    Window:addch('.')
    >  else
    >    print('F - '..msg)
    >    print('  expected '..str(expected)..' but got '..str(x))
    >    teliva_num_test_failures = teliva_num_test_failures + 1
    >    -- overlay first test failure on editors
    >    if teliva_first_failure == nil then
    >      teliva_first_failure = msg
    >    end
    >  end
    >end
- __teliva_timestamp: original
  eq:
    >function eq(a, b)
    >  if type(a) ~= type(b) then return false end
    >  if type(a) == 'table' then
    >    if #a ~= #b then return false end
    >    for k, v in pairs(a) do
    >      if b[k] ~= v then
    >        return false
    >      end
    >    end
    >    for k, v in pairs(b) do
    >      if a[k] ~= v then
    >        return false
    >      end
    >    end
    >    return true
    >  end
    >  return a == b
    >end
- __teliva_timestamp: original
  str:
    >-- smarter tostring
    >-- slow; used only for debugging
    >function str(x)
    >  if type(x) == 'table' then
    >    local result = ''
    >    result = result..#x..'{'
    >    for k, v in pairs(x) do
    >      result = result..str(k)..'='..str(v)..', '
    >    end
    >    result = result..'}'
    >    return result
    >  elseif type(x) == 'string' then
    >    return '"'..x..'"'
    >  end
    >  return tostring(x)
    >end
- __teliva_timestamp: original
  find_index:
    >function find_index(arr, x)
    >  for n, y in ipairs(arr) do
    >    if x == y then
    >      return n
    >    end
    >  end
    >end
- __teliva_timestamp: original
  trim:
    >function trim(s)
    >  return s:gsub('^%s*', ''):gsub('%s*$', '')
    >end
- __teliva_timestamp: original
  split:
    >function split(s, d)
    >  result = {}
    >  for match in (s..d):gmatch("(.-)"..d) do
    >    table.insert(result, match);
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  map:
    >-- only for arrays
    >function map(l, f)
    >  result = {}
    >  for _, x in ipairs(l) do
    >    table.insert(result, f(x))
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  reduce:
    >-- only for arrays
    >function reduce(l, f, init)
    >  result = init
    >  for _, x in ipairs(l) do
    >    result = f(result, x)
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  filter:
    >function filter(h, f)
    >  result = {}
    >  for k, v in pairs(h) do
    >    if f(k, v) then
    >      result[k] = v
    >    end
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  ifilter:
    >-- only for arrays
    >function ifilter(l, f)
    >  result = {}
    >  for _, x in ipairs(l) do
    >    if f(x) then
    >      table.insert(result, x)
    >    end
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  sort_letters:
    >function sort_letters(s)
    >  tmp = {}
    >  for i=1,#s do
    >    table.insert(tmp, s[i])
    >  end
    >  table.sort(tmp)
    >  local result = ''
    >  for _, c in pairs(tmp) do
    >    result = result..c
    >  end
    >  return result
    >end
    >
    >function test_sort_letters(s)
    >  check_eq(sort_letters(''), '', 'test_sort_letters: empty')
    >  check_eq(sort_letters('ba'), 'ab', 'test_sort_letters: non-empty')
    >  check_eq(sort_letters('abba'), 'aabb', 'test_sort_letters: duplicates')
    >end
- __teliva_timestamp: original
  count_letters:
    >-- TODO: handle unicode
    >function count_letters(s)
    >  local result = {}
    >  for i=1,s:len() do
    >    local c = s[i]
    >    if result[c] == nil then
    >      result[c] = 1
    >    else
    >      result[c] = result[c] + 1
    >    end
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  count:
    >-- turn an array of elements into a map from elements to their frequency
    >-- analogous to count_letters for non-strings
    >function count(a)
    >  local result = {}
    >  for i, v in ipairs(a) do
    >    if result[v] == nil then
    >      result[v] = 1
    >    else
    >      result[v] = result[v] + 1
    >    end
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  union:
    >function union(a, b)
    >  for k, v in pairs(b) do
    >    a[k] = v
    >  end
    >  return a
    >end
- __teliva_timestamp: original
  subtract:
    >-- set subtraction
    >function subtract(a, b)
    >  for k, v in pairs(b) do
    >    a[k] = nil
    >  end
    >  return a
    >end
- __teliva_timestamp: original
  all:
    >-- universal quantifier on sets
    >function all(s, f)
    >  for k, v in pairs(s) do
    >    if not f(k, v) then
    >      return false
    >    end
    >  end
    >  return true
    >end
- __teliva_timestamp: original
  to_array:
    >-- turn a set into an array
    >-- drops values
    >function to_array(h)
    >  local result = {}
    >  for k, _ in pairs(h) do
    >    table.insert(result, k)
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  append:
    >-- concatenate list 'elems' into 'l', modifying 'l' in the process
    >function append(l, elems)
    >  for i=1,#elems do
    >    table.insert(l, elems[i])
    >  end
    >end
- __teliva_timestamp: original
  prepend:
    >-- concatenate list 'elems' into the start of 'l', modifying 'l' in the process
    >function prepend(l, elems)
    >  for i=1,#elems do
    >    table.insert(l, i, elems[i])
    >  end
    >end
- __teliva_timestamp: original
  all_but:
    >function all_but(x, idx)
    >  if type(x) == 'table' then
    >    local result = {}
    >    for i, elem in ipairs(x) do
    >      if i ~= idx then
    >        table.insert(result,elem)
    >      end
    >    end
    >    return result
    >  elseif type(x) == 'string' then
    >    if idx < 1 then return x:sub(1) end
    >    return x:sub(1, idx-1) .. x:sub(idx+1)
    >  else
    >    error('all_but: unsupported type '..type(x))
    >  end
    >end
    >
    >function test_all_but()
    >  check_eq(all_but('', 0), '', 'all_but: empty')
    >  check_eq(all_but('abc', 0), 'abc', 'all_but: invalid low index')
    >  check_eq(all_but('abc', 4), 'abc', 'all_but: invalid high index')
    >  check_eq(all_but('abc', 1), 'bc', 'all_but: first index')
    >  check_eq(all_but('abc', 3), 'ab', 'all_but: final index')
    >  check_eq(all_but('abc', 2), 'ac', 'all_but: middle index')
    >end
- __teliva_timestamp: original
  set:
    >function set(l)
    >  local result = {}
    >  for i, elem in ipairs(l) do
    >    result[elem] = true
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  set_eq:
    >function set_eq(l1, l2)
    >  return eq(set(l1), set(l2))
    >end
    >
    >function test_set_eq()
    >  check(set_eq({1}, {1}), 'set_eq: identical')
    >  check(not set_eq({1, 2}, {1, 3}), 'set_eq: different')
    >  check(set_eq({1, 2}, {2, 1}), 'set_eq: order')
    >  check(set_eq({1, 2, 2}, {2, 1}), 'set_eq: duplicates')
    >end
- __teliva_timestamp: original
  clear:
    >function clear(lines)
    >  while #lines > 0 do
    >    table.remove(lines)
    >  end
    >end
- __teliva_timestamp: original
  zap:
    >function zap(target, src)
    >  clear(target)
    >  append(target, src)
    >end
- __teliva_timestamp: original
  mfactorial:
    >-- memoized version of factorial
    >-- doesn't memoize recursive calls, but may be good enough
    >mfactorial = memo1(factorial)
- __teliva_timestamp: original
  factorial:
    >function factorial(n)
    >  local result = 1
    >  for i=1,n do
    >    result = result*i
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  memo1:
    >-- a higher-order function that takes a function of a single arg
    >-- (that never returns nil)
    >-- and returns a memoized version of it
    >function memo1(f)
    >  local memo = {}
    >  return function(x)
    >    if memo[x] == nil then
    >      memo[x] = f(x)
    >    end
    >    return memo[x]
    >  end
    >end
    >
    >-- mfactorial doesn't seem noticeably faster
    >function test_memo1()
    >  for i=0,30 do
    >    check_eq(mfactorial(i), factorial(i), 'memo1 over factorial: '..str(i))
    >  end
    >end
- __teliva_timestamp: original
  num_permutations:
    >-- number of permutations of n distinct objects, taken r at a time
    >function num_permutations(n, r)
    >  return factorial(n)/factorial(n-r)
    >end
    >
    >-- mfactorial doesn't seem noticeably faster
    >function test_memo1()
    >  for i=0,30 do
    >    for j=0,i do
    >      check_eq(num_permutations(i, j), mfactorial(i)/mfactorial(i-j), 'num_permutations memoizes: '..str(i)..'P'..str(j))
    >    end
    >  end
    >end
- __teliva_timestamp: original
  menu:
    >-- To show app-specific hotkeys in the menu bar, add hotkey/command
    >-- arrays of strings to the menu array.
    >menu = {}
- __teliva_timestamp: original
  Window:
    >Window = curses.stdscr()
- __teliva_timestamp: original
  window:
    >-- constructor for fake screen and window
    >-- call it like this:
    >--   local w = window{
    >--     kbd=kbd('abc'),
    >--     scr=scr{h=5, w=4},
    >--   }
    >-- eventually it'll do everything a real ncurses window can
    >function window(h)
    >  h.__index = h
    >  setmetatable(h, h)
    >  h.__index = function(table, key)
    >    return rawget(h, key)
    >  end
    >  h.attrset = function(self, x)
    >    self.scr.attrs = x
    >  end
    >  h.attron = function(self, x)
    >    -- currently same as attrset since Lua 5.1 doesn't have bitwise operators
    >    -- doesn't support multiple attrs at once
    >--    local old = self.scr.attrs
    >--    self.scr.attrs = old|x
    >    self.scr.attrs = x
    >  end
    >  h.attroff = function(self, x)
    >    -- currently borked since Lua 5.1 doesn't have bitwise operators
    >    -- doesn't support multiple attrs at once
    >--    local old = self.scr.attrs
    >--    self.scr.attrs = old & (~x)
    >    self.scr.attrs = curses.A_NORMAL
    >  end
    >  h.getch = function(self)
    >    local c = table.remove(h.kbd, 1)
    >    if c == nil then return c end
    >    return string.byte(c)  -- for verisimilitude with ncurses
    >  end
    >  h.addch = function(self, c)
    >    local scr = self.scr
    >    if c == '\n' then
    >      scr.cursy = scr.cursy+1
    >      scr.cursx = 0
    >      return
    >    end
    >    if scr.cursy <= scr.h then
    >      scr[scr.cursy][scr.cursx] = {data=c, attrs=scr.attrs}
    >      scr.cursx = scr.cursx+1
    >      if scr.cursx > scr.w then
    >        scr.cursy = scr.cursy+1
    >        scr.cursx = 1
    >      end
    >    end
    >  end
    >  h.addstr = function(self, s)
    >    for i=1,s:len() do
    >      self:addch(s[i])
    >    end
    >  end
    >  h.mvaddch = function(self, y, x, c)
    >    self.scr.cursy = y
    >    self.scr.cursx = x
    >    self:addch(c)
    >  end
    >  h.mvaddstr = function(self, y, x, s)
    >    self.scr.cursy = y
    >    self.scr.cursx = x
    >    self:addstr(s)
    >  end
    >  h.clear = function(self)
    >    clear_scr(self.scr)
    >  end
    >  h.refresh = function(self)
    >    -- nothing
    >  end
    >  return h
    >end
- __teliva_timestamp: original
  kbd:
    >function kbd(keys)
    >  local result = {}
    >  for i=1,keys:len() do
    >    table.insert(result, keys[i])
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  scr:
    >function scr(props)
    >  props.cursx = 1
    >  props.cursy = 1
    >  clear_scr(props)
    >  return props
    >end
- __teliva_timestamp: original
  clear_scr:
    >function clear_scr(props)
    >  props.cursy = 1
    >  props.cursx = 1
    >  for y=1,props.h do
    >    props[y] = {}
    >    for x=1,props.w do
    >      props[y][x] = {data=' ', attrs=curses.A_NORMAL}
    >    end
    >  end
    >  return props
    >end
- __teliva_timestamp: original
  check_screen:
    >function check_screen(window, contents, message)
    >  local x, y = 1, 1
    >  for i=1,contents:len() do
    >    check_eq(window.scr[y][x].data, contents[i], message..'/'..y..','..x)
    >    x = x+1
    >    if x > window.scr.w then
    >      y = y+1
    >      x = 1
    >    end
    >  end
    >end
    >
    >-- putting it all together, an example test of both keyboard and screen
    >function test_check_screen()
    >  local lines = {
    >    c='123',
    >    d='234',
    >    a='345',
    >    b='456',
    >  }
    >  local w = window{
    >    kbd=kbd('abc'),
    >    scr=scr{h=3, w=5},
    >  }
    >  local y = 1
    >  while true do
    >    local b = w:getch()
    >    if b == nil then break end
    >    w:mvaddstr(y, 1, lines[string.char(b)])
    >    y = y+1
    >  end
    >  check_screen(w, '345  '..
    >                  '456  '..
    >                  '123  ',
    >              'test_check_screen')
    >end
- __teliva_timestamp: original
  check_reverse:
    >function check_reverse(window, contents, message)
    >  local x, y = 1, 1
    >  for i=1,contents:len() do
    >    if contents[i] ~= ' ' then
    >      -- hacky version while we're without bitwise operators on Lua 5.1
    >--      check(window.scr[y][x].attrs & curses.A_REVERSE, message..'/'..y..','..x)
    >      check_eq(window.scr[y][x].attrs, curses.A_REVERSE, message..'/'..y..','..x)
    >    else
    >      -- hacky version while we're without bitwise operators on Lua 5.1
    >--      check(window.scr[y][x].attrs & (~curses.A_REVERSE), message..'/'..y..','..x)
    >      check(window.scr[y][x].attrs ~= curses.A_REVERSE, message..'/'..y..','..x)
    >    end
    >    x = x+1
    >    if x > window.scr.w then
    >      y = y+1
    >      x = 1
    >    end
    >  end
    >end
- __teliva_timestamp: original
  check_bold:
    >function check_bold(window, contents, message)
    >  local x, y = 1, 1
    >  for i=1,contents:len() do
    >    if contents[i] ~= ' ' then
    >      -- hacky version while we're without bitwise operators on Lua 5.1
    >--      check(window.scr[y][x].attrs & curses.A_BOLD, message..'/'..y..','..x)
    >      check_eq(window.scr[y][x].attrs, curses.A_BOLD, message..'/'..y..','..x)
    >    else
    >      -- hacky version while we're without bitwise operators on Lua 5.1
    >--      check(window.scr[y][x].attrs & (~curses.A_BOLD), message..'/'..y..','..x)
    >      check(window.scr[y][x].attrs ~= curses.A_BOLD, message..'/'..y..','..x)
    >    end
    >    x = x+1
    >    if x > window.scr.w then
    >      y = y+1
    >      x = 1
    >    end
    >  end
    >end
- __teliva_timestamp: original
  check_color:
    >-- check which parts of a screen have the given color_pair
    >function check_color(window, cp, contents, message)
    >  local x, y = 1, 1
    >  for i=1,contents:len() do
    >    if contents[i] ~= ' ' then
    >      -- hacky version while we're without bitwise operators on Lua 5.1
    >--      check(window.scr[y][x].attrs & curses.color_pair(cp), message..'/'..y..','..x)
    >      check_eq(window.scr[y][x].attrs, curses.color_pair(cp), message..'/'..y..','..x)
    >    else
    >      -- hacky version while we're without bitwise operators on Lua 5.1
    >--      check(window.scr[y][x].attrs & (~curses.A_BOLD), message..'/'..y..','..x)
    >      check(window.scr[y][x].attrs ~= curses.color_pair(cp), message..'/'..y..','..x)
    >    end
    >    x = x+1
    >    if x > window.scr.w then
    >      y = y+1
    >      x = 1
    >    end
    >  end
    >end
- __teliva_timestamp: original
  sep:
    >-- horizontal separator
    >function sep(window)
    >  local y, _ = window:getyx()
    >  window:mvaddstr(y+1, 0, '')
    >  local _, cols = window:getmaxyx()
    >  for col=1,cols do
    >    window:addstr('_')
    >  end
    >end
- __teliva_timestamp: original
  render:
    >function render(window)
    >  window:clear()
    >  -- draw stuff to screen here
    >  window:attron(curses.A_BOLD)
    >  window:mvaddstr(1, 5, "example app")
    >  window:attrset(curses.A_NORMAL)
    >  for i=0,15 do
    >    window:attrset(curses.color_pair(i))
    >    window:mvaddstr(3+i, 5, "========================")
    >  end
    >  window:refresh()
    >end
- __teliva_timestamp: original
  update:
    >function update(window)
    >  local key = window:getch()
    >  -- process key here
    >end
- __teliva_timestamp: original
  init_colors:
    >function init_colors()
    >  for i=0,7 do
    >    curses.init_pair(i, i, -1)
    >  end
    >  curses.init_pair(8, 7, 0)
    >  curses.init_pair(9, 7, 1)
    >  curses.init_pair(10, 7, 2)
    >  curses.init_pair(11, 7, 3)
    >  curses.init_pair(12, 7, 4)
    >  curses.init_pair(13, 7, 5)
    >  curses.init_pair(14, 7, 6)
    >  curses.init_pair(15, -1, 15)
    >end
- __teliva_timestamp: original
  main:
    >function main()
    >  init_colors()
    >
    >  while true do
    >    render(Window)
    >    update(Window)
    >  end
    >end
- __teliva_timestamp:
    >Thu Mar 17 21:21:29 2022
  program:
    >program = {lines = nil, cursor = nil}
    >-- lines: [line]
    >-- cursor: int, index into lines
    >-- line: {[word], cursor}
    >-- word: {string, cursor}
- __teliva_timestamp:
    >Thu Mar 17 21:27:38 2022
  render:
    >function render(window)
    >  local key = window:getch()
    >  for row, line in ipair(program.lines) do
    >    for col, word in ipair(line.words) do
    >      window:addstr(word)
    >      window:addstr(' ')
    >    end
    >    window:addstr('\n')
    >  end
    >end
- __teliva_timestamp:
    >Thu Mar 17 21:28:39 2022
  render:
    >function render(window)
    >  local key = window:getch()
    >  for row, line in ipairs(program.lines) do
    >    for col, word in pairs(line.words) do
    >      window:addstr(word)
    >      window:addstr(' ')
    >    end
    >    window:addstr('\n')
    >  end
    >end
- __teliva_timestamp:
    >Thu Mar 17 21:31:33 2022
  Program:
    >Program = {
    >  cursor_y = 1,
    >  lines = {
    >    {
    >      cursor_x = 1,
    >      words = {
    >        {
    >          cursor = 0,
    >          data = '',
    >        },
    >      },
    >    },
    >  },
    >}
    >
    >
    >
    >
    >
- __teliva_timestamp:
    >Thu Mar 17 21:32:05 2022
  render:
    >function render(window)
    >  window:clear()
    >  for row, line in ipairs(program.lines) do
    >    for col, word in pairs(line.words) do
    >      window:addstr(word)
    >      window:addstr(' ')
    >    end
    >    window:addstr('\n')
    >  end
    >  window:refresh()
    >end
- __teliva_timestamp:
    >Thu Mar 17 21:32:22 2022
  render:
    >function render(window)
    >  window:clear()
    >  for row, line in ipairs(program.lines) do
    >    for col, word in pairs(line.words) do
    >      window:addstr(word.data)
    >      window:addstr(' ')
    >    end
    >    window:addstr('\n')
    >  end
    >  window:refresh()
    >end
- __teliva_timestamp:
    >Thu Mar 17 21:33:00 2022
  update:
    >function update(window)
    >  local key = window:getch()
    >  if key == ' ' then
    >    print('space')
    >    window:getch()
    >  end
    >end
- __teliva_timestamp:
    >Thu Mar 17 21:33:17 2022
  update:
    >function update(window)
    >  local key = window:getch()
    >  if key == string.byte(' ') then
    >    print('space')
    >    window:getch()
    >  end
    >end
- __teliva_timestamp:
    >Thu Mar 17 21:33:31 2022
  update:
    >function update(window)
    >  local key = string.char(window:getch())
    >  if key == ' ' then
    >    print('space')
    >    window:getch()
    >  end
    >end
- __teliva_timestamp:
    >Thu Mar 17 21:36:14 2022
  __teliva_note:
    >very initial skeleton
    >- just render, no eval
    >- no stack rendering
    >- no cursor (just appends)
  update:
    >function update(window)
    >  local key = string.char(window:getch())
    >  if key == ' ' then
    >    table.insert(program.lines[1].words, {data='', cursor=0})
    >  else
    >    local words = program.lines[1].words
    >    words[#words].data = words[#words].data .. key
    >  end
    >end
- __teliva_timestamp:
    >Thu Mar 17 21:39:24 2022
  main:
    >function main()
    >  init_colors()
    >
    >  while true do
    >    render(Window)
    >    update(Window)
    >  end
    >end
    >
    >function test_basic_render()
    >  
- __teliva_timestamp:
    >Thu Mar 17 21:43:05 2022
  main:
    >function main()
    >  init_colors()
    >
    >  while true do
    >    render(Window, Program)
    >    update(Window, Program)
    >  end
    >end
- __teliva_timestamp:
    >Thu Mar 17 21:43:11 2022
  render:
    >function render(window, program)
    >  window:clear()
    >  for row, line in ipairs(program.lines) do
    >    for col, word in pairs(line.words) do
    >      window:addstr(word.data)
    >      window:addstr(' ')
    >    end
    >    window:addstr('\n')
    >  end
    >  window:refresh()
    >end
    >
    >function test_render()
    >  local w = window{
    >    kbd=kbd(''),
    >    scr=scr{h=3, w=5},
    >  }
    >end
- __teliva_timestamp:
    >Thu Mar 17 21:43:20 2022
  update:
    >function update(window, program, key)
    >  if key == ' ' then
    >    table.insert(program.lines[1].words, {data='', cursor=0})
    >  else
    >    local words = program.lines[1].words
    >    words[#words].data = words[#words].data .. key
    >  end
    >end
- __teliva_timestamp:
    >Thu Mar 17 21:58:10 2022
  Program:
    >Program = empty_program()
- __teliva_timestamp:
    >Thu Mar 17 21:58:10 2022
  empty_program:
    >function empty_program()
    >  return {
    >    cursor_y = 1,
    >    lines = {
    >      {
    >        cursor_x = 1,
    >        words = {
    >          {
    >            cursor = 0,
    >            data = '',
    >          },
    >        },
    >      },
    >    },
    >  }
    >end
- __teliva_timestamp:
    >Thu Mar 17 22:36:24 2022
  render:
    >function render(window, program)
    >  window:clear()
    >  for row, line in ipairs(program.lines) do
    >    for col, word in pairs(line.words) do
    >      window:addstr(word.data)
    >      window:addstr(' ')
    >    end
    >    window:addstr('\n')
    >  end
    >  window:refresh()
    >end
- __teliva_timestamp:
    >Thu Mar 17 22:41:01 2022
  __teliva_note:
    >a passing test
  main:
    >function main()
    >  init_colors()
    >
    >  while true do
    >    render(Window, Program)
    >    local key = string.char(Window:getch())  -- nodelay can't be set
    >    update(Window, Program, key)
    >  end
    >end
    >
    >function test_incomplete()
    >  local w = window{
    >    kbd=kbd('ab c'),
    >    scr=scr{h=3, w=5},
    >  }
    >  local prog = empty_program()
    >  while true do
    >    render(w, prog)
    >    local key = w:getch()
    >    if key == nil then break end
    >    update(w, prog, string.char(key))
    >  end
    >  check_screen(w, 'ab c '..
    >                  '     '..
    >                  '     ',
    >               'test_main_incomplete')
    >end
- __teliva_timestamp: original
  doc:blurb:
    >A concatenative programming language with a live-updating debug UI.
    >by Kartik Agaram and Sumeet Agarwal
    >
    >Highly incomplete.
    >
    >Previous prototypes:
    >  - https://archive.org/details/akkartik-2min-2020-12-06
    >  - https://merveilles.town/@akkartik/105759816342173743


================================================
FILE: chesstv.tlv
================================================
# .tlv file generated by https://github.com/akkartik/teliva
# You may edit it if you are careful; however, you may see cryptic errors if you
# violate Teliva's assumptions.
#
# .tlv files are representations of Teliva programs. Teliva programs consist of
# sequences of definitions. Each definition is a table of key/value pairs. Keys
# and values are both strings.
#
# Lines in .tlv files always follow exactly one of the following forms:
# - comment lines at the top of the file starting with '#' at column 0
# - beginnings of definitions starting with '- ' at column 0, followed by a
#   key/value pair
# - key/value pairs consisting of '  ' at column 0, containing either a
#   spaceless value on the same line, or a multi-line value
# - multiline values indented by more than 2 spaces, starting with a '>'
#
# If these constraints are violated, Teliva may unceremoniously crash. Please
# report bugs at http://akkartik.name/contact
- __teliva_timestamp: original
  check:
    >function check(x, msg)
    >  if x then
    >    Window:addch('.')
    >  else
    >    print('F - '..msg)
    >    print('  '..str(x)..' is false/nil')
    >    teliva_num_test_failures = teliva_num_test_failures + 1
    >    -- overlay first test failure on editors
    >    if teliva_first_failure == nil then
    >      teliva_first_failure = msg
    >    end
    >  end
    >end
- __teliva_timestamp: original
  check_eq:
    >function check_eq(x, expected, msg)
    >  if eq(x, expected) then
    >    Window:addch('.')
    >  else
    >    print('F - '..msg)
    >    print('  expected '..str(expected)..' but got '..str(x))
    >    teliva_num_test_failures = teliva_num_test_failures + 1
    >    -- overlay first test failure on editors
    >    if teliva_first_failure == nil then
    >      teliva_first_failure = msg
    >    end
    >  end
    >end
- __teliva_timestamp: original
  eq:
    >function eq(a, b)
    >  if type(a) ~= type(b) then return false end
    >  if type(a) == 'table' then
    >    if #a ~= #b then return false end
    >    for k, v in pairs(a) do
    >      if b[k] ~= v then
    >        return false
    >      end
    >    end
    >    for k, v in pairs(b) do
    >      if a[k] ~= v then
    >        return false
    >      end
    >    end
    >    return true
    >  end
    >  return a == b
    >end
- __teliva_timestamp: original
  str:
    >-- smarter tostring
    >-- slow; used only for debugging
    >function str(x)
    >  if type(x) == 'table' then
    >    local result = ''
    >    result = result..#x..'{'
    >    for k, v in pairs(x) do
    >      result = result..str(k)..'='..str(v)..', '
    >    end
    >    result = result..'}'
    >    return result
    >  elseif type(x) == 'string' then
    >    return '"'..x..'"'
    >  end
    >  return tostring(x)
    >end
- __teliva_timestamp: original
  Window:
    >Window = curses.stdscr()
    >-- animation-based app
    >Window:nodelay(true)
    >lines, cols = Window:getmaxyx()
- __teliva_timestamp: original
  current_game:
    >current_game = {}
- __teliva_timestamp: original
  piece_glyph:
    >piece_glyph = {
    >  -- for legibility, white pieces also use unicode glyphs for black pieces
    >  -- we rely on colors to distinguish them
    >  K = 0x265a,
    >  Q = 0x265b,
    >  R = 0x265c,
    >  B = 0x265d,
    >  N = 0x265e,
    >  P = 0x265f,
    >  k = 0x265a,
    >  q = 0x265b,
    >  r = 0x265c,
    >  b = 0x265d,
    >  n = 0x265e,
    >  p = 0x265f,
    >}
- __teliva_timestamp: original
  top_player:
    >function top_player(current_game)
    >  if current_game.players[1].color == "black" then
    >    return current_game.players[1]
    >  end
    >  return current_game.players[2]
    >end
- __teliva_timestamp: original
  bottom_player:
    >function bottom_player(current_game)
    >  if current_game.players[1].color == "white" then
    >    return current_game.players[1]
    >  end
    >  return current_game.players[2]
    >end
- __teliva_timestamp: original
  render_player:
    >function render_player(y, x, player)
    >  Window:mvaddstr(y, x, player.user.name)
    >  Window:addstr(" · ")
    >  Window:addstr(tostring(player.rating))
    >end
- __teliva_timestamp: original
  render_square:
    >function render_square(current_game, rank, file, highlighted_squares)
    >  -- decide whether to highlight
    >  local hl = 0
    >  if (rank == highlighted_squares.from.rank and file == highlighted_squares.from.file)
    >      or (rank == highlighted_squares.to.rank and file == highlighted_squares.to.file) then
    >    hl = 4
    >  end
    >  if (rank+file)%2 == 1 then
    >    -- light square
    >    Window:attrset(curses.color_pair(1+hl))
    >  else
    >    -- dark square
    >    Window:attrset(curses.color_pair(3+hl))
    >  end
    >  Window:mvaddstr((8 - rank + 1)*3,   file*5, "     ")
    >  Window:mvaddstr((8 - rank + 1)*3+1, file*5, "     ")
    >  Window:mvaddstr((8 - rank + 1)*3+2, file*5, "     ")
    >  Window:attrset(curses.A_NORMAL)
    >end
- __teliva_timestamp: original
  render_fen_rank:
    >function render_fen_rank(rank, fen_rank, highlighted_squares)
    >  local file = 1
    >  for x in fen_rank:gmatch(".") do
    >    if x:match("%d") then
    >      file = file + tonumber(x)
    >    else
    >      -- decide whether to highlight
    >      local hl = 0
    >      if (rank == highlighted_squares.from.rank and file == highlighted_squares.from.file)
    >          or (rank == highlighted_squares.to.rank and file == highlighted_squares.to.file) then
    >        hl = 4
    >      end
    >      if (rank+file)%2 == 1 then
    >        if x < 'Z' then
    >          -- white piece on light square
    >          Window:attrset(curses.color_pair(1+hl))
    >        else
    >          -- black piece on light square
    >          Window:attrset(curses.color_pair(2+hl))
    >        end
    >      else
    >        if x < 'Z' then
    >          -- white piece on dark square
    >          Window:attrset(curses.color_pair(3+hl))
    >        else
    >          -- black piece on dark square
    >          Window:attrset(curses.color_pair(4+hl))
    >        end
    >      end
    >      Window:mvaddstr((8 - rank + 1)*3+1, file*5+2, utf8(piece_glyph[x]))
    >      Window:attrset(curses.A_NORMAL)
    >      file = file + 1
    >    end
    >  end
    >end
- __teliva_timestamp: original
  render_time:
    >function render_time(y, x, seconds)
    >  if seconds == nil then return end
    >  Window:mvaddstr(y, x, tostring(math.floor(seconds/60)))
    >  Window:addstr(string.format(":%02d", seconds%60))
    >end
- __teliva_timestamp: original
  render_board:
    >function render_board(current_game)
    >--?   Window:mvaddstr(1, 50, dump(current_game.fen))
    >--?   Window:mvaddstr(6, 50, dump(current_game.previously_moved_squares))
    >  render_player(2, 5, top_player(current_game))
    >  render_time(2, 35, current_game.bc)
    >  for rank=8,1,-1 do
    >    for file=1,8 do
    >      render_square(current_game, rank, file, current_game.previously_moved_squares)
    >    end
    >    render_fen_rank(rank, current_game.fen_rank[8-rank+1], current_game.previously_moved_squares)
    >  end
    >  render_player(27, 5, bottom_player(current_game))
    >  render_time(27, 35, current_game.wc)
    >end
- __teliva_timestamp: original
  parse_lm:
    >function parse_lm(move)
    >--?   Window:mvaddstr(4, 50, move)
    >  local file1 = string.byte(move:sub(1, 1)) - 96  -- 'a'-1
    >  local rank1 = string.byte(move:sub(2, 2)) - 48  -- '0'
    >  local file2 = string.byte(move:sub(3, 3)) - 96  -- 'a'-1
    >  local rank2 = string.byte(move:sub(4, 4)) - 48  -- '0'
    >--?   Window:mvaddstr(5, 50, dump({{rank1, file1}, {rank2, file2}}))
    >  return {from={rank=rank1, file=file1}, to={rank=rank2, file=file2}}
    >end
- __teliva_timestamp: original
  render:
    >function render(chunk)
    >  local o = json.decode(chunk)
    >  if o.t == "featured" then
    >    current_game = o.d
    >--?     current_game.lm = "__"
    >    current_game.previously_moved_squares = {from={rank=0, file=0}, to={rank=0, file=0}}  -- no highlight
    >  else
    >    current_game.fen = o.d.fen
    >    current_game.wc = o.d.wc
    >    current_game.bc = o.d.bc
    >--?     current_game.lm = o.d.lm
    >    current_game.previously_moved_squares = parse_lm(o.d.lm)
    >--?     Window:nodelay(false)
    >--?     Window:mvaddstr(3, 50, "paused")
    >  end
    >  current_game.fen_rank = split(current_game.fen, "%w+")
    >  render_board(current_game)
    >  Window:refresh()
    >end
- __teliva_timestamp: original
  init_colors:
    >function init_colors()
    >  -- colors
    >  local light_piece = 1
    >  local dark_piece = 0
    >  local light_square = 252
    >  local dark_square = 242
    >  local light_last_moved_square = 229
    >  local dark_last_moved_square = 226
    >  -- initialize colors
    >  curses.init_pair(1, light_piece, light_square)
    >  curses.init_pair(2, dark_piece, light_square)
    >  curses.init_pair(3, light_piece, dark_square)
    >  curses.init_pair(4, dark_piece, dark_square)
    >  curses.init_pair(5, light_piece, light_last_moved_square)
    >  curses.init_pair(6, dark_piece, light_last_moved_square)
    >  curses.init_pair(7, light_piece, dark_last_moved_square)
    >  curses.init_pair(8, dark_piece, dark_last_moved_square)
    >end
- __teliva_timestamp: original
  main:
    >function main()
    >  init_colors()
    >  local request = {
    >    url = "https://lichess.org/api/tv/feed",
    >    sink = function(chunk, err)
    >             if chunk then
    >               Window:clear()
    >               render(chunk)
    >               Window:getch()
    >             end
    >             return 1
    >           end,
    >  }
    >  http.request(request)
    >end
- __teliva_timestamp: original
  utf8:
    >-- https://stackoverflow.com/questions/7983574/how-to-write-a-unicode-symbol-in-lua
    >function utf8(decimal)
    >  local bytemarkers = { {0x7FF,192}, {0xFFFF,224}, {0x1FFFFF,240} }
    >  if decimal<128 then return string.char(decimal) end
    >  local charbytes = {}
    >  for bytes,vals in ipairs(bytemarkers) do
    >    if decimal<=vals[1] then
    >      for b=bytes+1,2,-1 do
    >        local mod = decimal%64
    >        decimal = (decimal-mod)/64
    >        charbytes[b] = string.char(128+mod)
    >      end
    >      charbytes[1] = string.char(vals[2]+decimal)
    >      break
    >    end
    >  end
    >  return table.concat(charbytes)
    >end
- __teliva_timestamp: original
  split:
    >function split(s, pat)
    >  result = {}
    >  for x in s:gmatch(pat) do
    >    table.insert(result, x)
    >  end
    >  return result
    >end
- __teliva_timestamp: original
  dump:
    >-- https://stackoverflow.com/questions/9168058/how-to-dump-a-table-to-console
    >function dump(o)
    >  if type(o) == 'table' then
    >    local s = '{ '
    >    for k,v in pairs(o) do
    >      if type(k) ~= 'number' then k = '"'..k..'"' end
    >      s = s .. '['..k..'] = ' .. dump(v) .. ','
    >    end
    >    return s .. '} '
    >  else
    >    return tostring(o)
    >  end
    >end
- __teliva_timestamp:
    >Sat Feb 12 18:57:02 2022
  __teliva_note:
    >better UX when app isn't permitted to access the network
  main:
    >function main()
    >  init_colors()
    >  local request = {
    >    url = "https://lichess.org/api/tv/feed",
    >    sink = function(chunk, err)
    >             if chunk then
    >               Window:clear()
    >               -- main event loop is here
    >               render(chunk)
    >               Window:getch()
    >             end
    >             return 1
    >           end,
    >  }
    >  http.request(request)
    >  -- degenerate event loop just to show errors in sandboxing, etc.
    >  while true do Window:getch(); end
    >end
- __teliva_timestamp:
    >Thu Feb 17 20:00:23 2022
  doc:blurb:
    >A demo of Teliva's support for networking: watch the current live chess game from Lichess TV.
    >
    >Compare with https://lichess.org/tv on a browser.


================================================
FILE: counter.tlv
================================================
# .tlv file generated by https://github.com/akkartik/teliva
# You may edit it if you are careful; however, you may see cryptic errors if you
# violate Teliva's assumptions.
#
# .tlv files are representations of Teliva programs. Teliva programs consist of
# sequences of definitions. Each definition is a table of key/value pairs. Keys
# and values are both strings.
#
# Lines in .tlv files always follow exactly one of the following forms:
# - comment lines at the top of the file starting with '#' at column 0
# - beginnings of definitions starting with '- ' at column 0, followed by a
#   key/value pair
# - key/value pairs consisting of '  ' at column 0, containing either a
#   spaceless value on the same line, or a multi-line value
# - multiline values indented by more than 2 spaces, starting with a '>'
#
# If these constraints are violated, Teliva may unceremoniously crash. Please
# report bugs at http://akkartik.name/contact
- __teliva_timestamp: original
  check:
    >function check(x, msg)
    >  if x then
    >    Window:addch('.')
    >  else
    >    print('F - '..msg)
    >    print('  '..str(x)..' is false/nil')
    >    teliva_num_test_failures = teliva_num_test_failures + 1
    >    -- overlay first test failure on editors
    >    if teliva_first_failure == nil then
    >      teliva_first_failure = msg
    >    end
    >  end
    >end
- __teliva_timestamp: original
  check_eq:
    >function check_eq(x, expected, msg)
    >  if eq(x, expected) then
    >    Window:addch('.')
    >  else
    >    print('F - '..msg)
    >    print('  expected '..str(expected)..' but got '..str(x))
    >    teliva_num_test_failures = teliva_num_test_failures + 1
    >    -- overlay first test failure on editors
    >    if teliva_first_failure == nil then
    >      teliva_first_failure = msg
    >    end
    >  end
    >end
- __teliva_timestamp: original
  eq:
    >function eq(a, b)
    >  if type(a) ~= type(b) then return false end
    >  if type(a) == 'table' then
    >    if #a ~= #b then return false end
    >    for k, v in pairs(a) do
    >      if b[k] ~= v then
    >        return false
    >      end
    >    end
    >    for k, v in pairs(b) do
    >      if a[k] ~= v then
    >        return false
    >      end
    >    end
    >    return true
    >  end
    >  return a == b
    >end
- __teliva_timestamp: original
  str:
    >-- smarter tostring
    >-- slow; used only for debugging
    >function str(x)
    >  if type(x) == 'table' then
    >    local result = ''
    >    result = result..#x..'{'
    >    for k, v in pairs(x) do
    >      result = result..str(k)..'='..str(v)..', '
    >    end
    >    result = result..'}'
    >    return result
    >  elseif type(x) == 'string' then
    >    return '"'..x..'"'
    >  end
    >  return tostring(x)
    >end
- __teliva_timestamp: original
  Window:
    >Window = curses.stdscr()
- __teliva_timestamp: original
  n:
    >n = 0
- __teliva_timestamp: original
  render:
    >function render(window)
    >  window:clear()
    >  window:attron(curses.A_BOLD)
    >  window:attron(curses.color_pair(6))
    >  window:mvaddstr(10, 10, "     ")
    >  window:mvaddstr(10, 11, n)
    >  window:attroff(curses.color_pair(6))
    >  window:attroff(curses.A_BOLD)
    >  window:refresh()
    >end
- __teliva_timestamp: original
  menu:
    >menu = {
    >  {"Enter", "increment"}
    >}
- __teliva_timestamp: original
  update:
    >function update(window)
    >  local key = window:getch()
    >  if key == 10 then
    >    n = n+1
    >  end
    >end
- __teliva_timestamp: original
  main:
    >function main()
    >  for i=1,7 do
    >    curses.init_pair(i, 0, i)
    >  end
    >
    >  while true do
    >    render(Window)
    >    update(Window)
    >  end
    >end
- __teliva_timestamp:
    >Thu Feb 17 20:01:19 2022
  doc:blurb:
    >Example app: counter widget
    >
    >Look at the menu below to see what keyboard shortcuts are available.


================================================
FILE: doc/contents.html
================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Teliva Reference Manual - contents</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
<STYLE TYPE="text/css">
ul {
	list-style-type: none ;
}
</STYLE>
</HEAD>

<BODY>

<HR>
<H1>
Teliva Reference Manual
</H1>

<P>
This reference manual for Teliva is based on the official definition of the
Lua language.

<P>
Please support Lua by <A HREF="http://www.lua.org/donations.html">donating</A> or purchasing:
<BLOCKQUOTE>
<A HREF="http://www.amazon.com/exec/obidos/ASIN/8590379833/lua-indexmanual-20">
<IMG SRC="cover.png" ALT="" TITLE="buy from Amazon" BORDER=1 ALIGN="left" HSPACE=12>
</A>
<B>Lua 5.1 Reference Manual</B>
<BR>by R. Ierusalimschy, L. H. de Figueiredo, W. Celes
<BR>Lua.org, August 2006
<BR>ISBN 85-903798-3-3
<BR CLEAR="all">
</BLOCKQUOTE>

<P>
<A HREF="manual.html">start</A>
&middot;
<A HREF="#contents">contents</A>
&middot;
<A HREF="#index">index</A>
&middot;
<A HREF="http://www.lua.org/manual/">other versions</A>
<HR>
<SMALL>
Copyright &copy; 2006&ndash;2012 Lua.org, PUC-Rio.
Freely available under the terms of the
<A HREF="http://www.lua.org/license.html">Lua license</A>.
</SMALL>

<H2><A NAME="contents">Contents</A></H2>
<UL style="padding: 0">
<LI><A HREF="manual.html">1 &ndash; Introduction</A>
<P>
<LI><A HREF="manual.html#2">2 &ndash; The Language</A>
<UL>
<LI><A HREF="manual.html#2.1">2.1 &ndash; Lexical Conventions</A>
<LI><A HREF="manual.html#2.2">2.2 &ndash; Values and Types</A>
<UL>
<LI><A HREF="manual.html#2.2.1">2.2.1 &ndash; Coercion</A>
</UL>
<LI><A HREF="manual.html#2.3">2.3 &ndash; Variables</A>
<LI><A HREF="manual.html#2.4">2.4 &ndash; Statements</A>
<UL>
<LI><A HREF="manual.html#2.4.1">2.4.1 &ndash; Chunks</A>
<LI><A HREF="manual.html#2.4.2">2.4.2 &ndash; Blocks</A>
<LI><A HREF="manual.html#2.4.3">2.4.3 &ndash; Assignment</A>
<LI><A HREF="manual.html#2.4.4">2.4.4 &ndash; Control Structures</A>
<LI><A HREF="manual.html#2.4.5">2.4.5 &ndash; For Statement</A>
<LI><A HREF="manual.html#2.4.6">2.4.6 &ndash; Function Calls as Statements</A>
<LI><A HREF="manual.html#2.4.7">2.4.7 &ndash; Local Declarations</A>
</UL>
<LI><A HREF="manual.html#2.5">2.5 &ndash; Expressions</A>
<UL>
<LI><A HREF="manual.html#2.5.1">2.5.1 &ndash; Arithmetic Operators</A>
<LI><A HREF="manual.html#2.5.2">2.5.2 &ndash; Relational Operators</A>
<LI><A HREF="manual.html#2.5.3">2.5.3 &ndash; Logical Operators</A>
<LI><A HREF="manual.html#2.5.4">2.5.4 &ndash; Concatenation</A>
<LI><A HREF="manual.html#2.5.5">2.5.5 &ndash; The Length Operator</A>
<LI><A HREF="manual.html#2.5.6">2.5.6 &ndash; Precedence</A>
<LI><A HREF="manual.html#2.5.7">2.5.7 &ndash; Table Constructors</A>
<LI><A HREF="manual.html#2.5.8">2.5.8 &ndash; Function Calls</A>
<LI><A HREF="manual.html#2.5.9">2.5.9 &ndash; Function Definitions</A>
</UL>
<LI><A HREF="manual.html#2.6">2.6 &ndash; Visibility Rules</A>
<LI><A HREF="manual.html#2.7">2.7 &ndash; Error Handling</A>
<LI><A HREF="manual.html#2.8">2.8 &ndash; Metatables</A>
<LI><A HREF="manual.html#2.9">2.9 &ndash; Environments</A>
<LI><A HREF="manual.html#2.10">2.10 &ndash; Garbage Collection</A>
<UL>
<LI><A HREF="manual.html#2.10.1">2.10.1 &ndash; Garbage-Collection Metamethods</A>
<LI><A HREF="manual.html#2.10.2">2.10.2 &ndash; Weak Tables</A>
</UL>
<LI><A HREF="manual.html#2.11">2.11 &ndash; Coroutines</A>
</UL>
<P>
<LI><A HREF="manual.html#5">5 &ndash; Standard Libraries</A>
<UL>
<LI><A HREF="manual.html#5.1">5.1 &ndash; Basic Functions</A>
<LI><A HREF="manual.html#5.2">5.2 &ndash; Coroutine Manipulation</A>
<LI><A HREF="manual.html#5.3">5.3 &ndash; Modules</A>
<LI><A HREF="manual.html#5.4">5.4 &ndash; String Manipulation</A>
<UL>
<LI><A HREF="manual.html#5.4.1">5.4.1 &ndash; Patterns</A>
</UL>
<LI><A HREF="manual.html#5.5">5.5 &ndash; Table Manipulation</A>
<LI><A HREF="manual.html#5.6">5.6 &ndash; Mathematical Functions</A>
<LI><span class='teliva'><A HREF="manual.html#5.7">5.7 &ndash; File Input and Output Facilities</A></span>
<LI><A HREF="manual.html#5.8">5.8 &ndash; Operating System Facilities</A>
<LI><span class='teliva'><A HREF="manual.html#5.10">5.10 &ndash; Curses Window Facilities</A></span>
<LI><span class='teliva'><A HREF="manual.html#5.11">5.11 &ndash; Networking Facilities</A></span>
<LI><span class='teliva'><A HREF="manual.html#5.12">5.12 &ndash; JSON Facilities</A></span>
<LI><span class='teliva'><A HREF="manual.html#5.13">5.13 &ndash; Tasks and Channels</A></span>
</UL>
<P>
<LI><A HREF="manual.html#8">8 &ndash; The Complete Syntax of Lua</A>
</UL>

<H2><A NAME="index">Index</A></H2>
<TABLE WIDTH="100%">
<TR VALIGN="top">
<TD>
<H3><A NAME="functions">Lua functions</A></H3>
<A HREF="manual.html#pdf-_G">_G</A><BR>
<A HREF="manual.html#pdf-_VERSION">_VERSION</A><BR>
<P>

<A HREF="manual.html#pdf-assert">assert</A><BR>
<A HREF="manual.html#pdf-collectgarbage">collectgarbage</A><BR>
<A HREF="manual.html#pdf-error">error</A><BR>
<A HREF="manual.html#pdf-getfenv">getfenv</A><BR>
<A HREF="manual.html#pdf-getmetatable">getmetatable</A><BR>
<A HREF="manual.html#pdf-ipairs">ipairs</A><BR>
<A HREF="manual.html#pdf-next">next</A><BR>
<A HREF="manual.html#pdf-pairs">pairs</A><BR>
<A HREF="manual.html#pdf-print">print</A><BR>
<A HREF="manual.html#pdf-rawequal">rawequal</A><BR>
<A HREF="manual.html#pdf-rawget">rawget</A><BR>
<A HREF="manual.html#pdf-rawset">rawset</A><BR>
<A HREF="manual.html#pdf-select">select</A><BR>
<A HREF="manual.html#pdf-setfenv">setfenv</A><BR>
<A HREF="manual.html#pdf-setmetatable">setmetatable</A><BR>
<A HREF="manual.html#pdf-tonumber">tonumber</A><BR>
<A HREF="manual.html#pdf-tostring">tostring</A><BR>
<A HREF="manual.html#pdf-type">type</A><BR>
<A HREF="manual.html#pdf-unpack">unpack</A><BR>
<P>

<A HREF="manual.html#pdf-coroutine.create">coroutine.create</A><BR>
<A HREF="manual.html#pdf-coroutine.resume">coroutine.resume</A><BR>
<A HREF="manual.html#pdf-coroutine.running">coroutine.running</A><BR>
<A HREF="manual.html#pdf-coroutine.status">coroutine.status</A><BR>
<A HREF="manual.html#pdf-coroutine.wrap">coroutine.wrap</A><BR>
<A HREF="manual.html#pdf-coroutine.yield">coroutine.yield</A><BR>
<P>

<A HREF="manual.html#pdf-debug.debug">debug.debug</A><BR>
<A HREF="manual.html#pdf-debug.getfenv">debug.getfenv</A><BR>
<A HREF="manual.html#pdf-debug.gethook">debug.gethook</A><BR>
<A HREF="manual.html#pdf-debug.getinfo">debug.getinfo</A><BR>
<A HREF="manual.html#pdf-debug.getlocal">debug.getlocal</A><BR>
<A HREF="manual.html#pdf-debug.getmetatable">debug.getmetatable</A><BR>
<A HREF="manual.html#pdf-debug.getregistry">debug.getregistry</A><BR>
<A HREF="manual.html#pdf-debug.getupvalue">debug.getupvalue</A><BR>
<A HREF="manual.html#pdf-debug.setfenv">debug.setfenv</A><BR>
<A HREF="manual.html#pdf-debug.sethook">debug.sethook</A><BR>
<A HREF="manual.html#pdf-debug.setlocal">debug.setlocal</A><BR>
<A HREF="manual.html#pdf-debug.setmetatable">debug.setmetatable</A><BR>
<A HREF="manual.html#pdf-debug.setupvalue">debug.setupvalue</A><BR>
<A HREF="manual.html#pdf-debug.traceback">debug.traceback</A><BR>

</TD>
<TD>
<H3>&nbsp;</H3>
<A HREF="manual.html#pdf-file:close">file:close</A><BR>
<A HREF="manual.html#pdf-file:flush">file:flush</A><BR>
<A HREF="manual.html#pdf-file:lines">file:lines</A><BR>
<A HREF="manual.html#pdf-file:read">file:read</A><BR>
<A HREF="manual.html#pdf-file:seek">file:seek</A><BR>
<A HREF="manual.html#pdf-file:setvbuf">file:setvbuf</A><BR>
<A HREF="manual.html#pdf-file:write">file:write</A><BR>
<P>

<A HREF="manual.html#pdf-io.close">io.close</A><BR>
<A HREF="manual.html#pdf-io.open">io.open</A><BR>
<A HREF="manual.html#pdf-io.tmpfile">io.tmpfile</A><BR>
<A HREF="manual.html#pdf-io.type">io.type</A><BR>
<P>

<A HREF="manual.html#pdf-math.abs">math.abs</A><BR>
<A HREF="manual.html#pdf-math.acos">math.acos</A><BR>
<A HREF="manual.html#pdf-math.asin">math.asin</A><BR>
<A HREF="manual.html#pdf-math.atan">math.atan</A><BR>
<A HREF="manual.html#pdf-math.atan2">math.atan2</A><BR>
<A HREF="manual.html#pdf-math.ceil">math.ceil</A><BR>
<A HREF="manual.html#pdf-math.cos">math.cos</A><BR>
<A HREF="manual.html#pdf-math.cosh">math.cosh</A><BR>
<A HREF="manual.html#pdf-math.deg">math.deg</A><BR>
<A HREF="manual.html#pdf-math.exp">math.exp</A><BR>
<A HREF="manual.html#pdf-math.floor">math.floor</A><BR>
<A HREF="manual.html#pdf-math.fmod">math.fmod</A><BR>
<A HREF="manual.html#pdf-math.frexp">math.frexp</A><BR>
<A HREF="manual.html#pdf-math.huge">math.huge</A><BR>
<A HREF="manual.html#pdf-math.ldexp">math.ldexp</A><BR>
<A HREF="manual.html#pdf-math.log">math.log</A><BR>
<A HREF="manual.html#pdf-math.log10">math.log10</A><BR>
<A HREF="manual.html#pdf-math.max">math.max</A><BR>
<A HREF="manual.html#pdf-math.min">math.min</A><BR>
<A HREF="manual.html#pdf-math.modf">math.modf</A><BR>
<A HREF="manual.html#pdf-math.pi">math.pi</A><BR>
<A HREF="manual.html#pdf-math.pow">math.pow</A><BR>
<A HREF="manual.html#pdf-math.rad">math.rad</A><BR>
<A HREF="manual.html#pdf-math.random">math.random</A><BR>
<A HREF="manual.html#pdf-math.randomseed">math.randomseed</A><BR>
<A HREF="manual.html#pdf-math.sin">math.sin</A><BR>
<A HREF="manual.html#pdf-math.sinh">math.sinh</A><BR>
<A HREF="manual.html#pdf-math.sqrt">math.sqrt</A><BR>
<A HREF="manual.html#pdf-math.tan">math.tan</A><BR>
<A HREF="manual.html#pdf-math.tanh">math.tanh</A><BR>
<P>

<A HREF="manual.html#pdf-os.clock">os.clock</A><BR>
<A HREF="manual.html#pdf-os.date">os.date</A><BR>
<A HREF="manual.html#pdf-os.difftime">os.difftime</A><BR>
<A HREF="manual.html#pdf-os.exit">os.exit</A><BR>
<A HREF="manual.html#pdf-os.remove">os.remove</A><BR>
<A HREF="manual.html#pdf-os.rename">os.rename</A><BR>
<A HREF="manual.html#pdf-os.setlocale">os.setlocale</A><BR>
<A HREF="manual.html#pdf-os.time">os.time</A><BR>
<A HREF="manual.html#pdf-os.tmpname">os.tmpname</A><BR>
<P>

<A HREF="manual.html#pdf-string.byte">string.byte</A><BR>
<A HREF="manual.html#pdf-string.char">string.char</A><BR>
<A HREF="manual.html#pdf-string.dump">string.dump</A><BR>
<A HREF="manual.html#pdf-string.find">string.find</A><BR>
<A HREF="manual.html#pdf-string.format">string.format</A><BR>
<A HREF="manual.html#pdf-string.gmatch">string.gmatch</A><BR>
<A HREF="manual.html#pdf-string.gsub">string.gsub</A><BR>
<A HREF="manual.html#pdf-string.len">string.len</A><BR>
<A HREF="manual.html#pdf-string.lower">string.lower</A><BR>
<A HREF="manual.html#pdf-string.match">string.match</A><BR>
<A HREF="manual.html#pdf-string.rep">string.rep</A><BR>
<A HREF="manual.html#pdf-string.reverse">string.reverse</A><BR>
<A HREF="manual.html#pdf-string.sub">string.sub</A><BR>
<A HREF="manual.html#pdf-string.upper">string.upper</A><BR>
<P>

<A HREF="manual.html#pdf-table.concat">table.concat</A><BR>
<A HREF="manual.html#pdf-table.insert">table.insert</A><BR>
<A HREF="manual.html#pdf-table.maxn">table.maxn</A><BR>
<A HREF="manual.html#pdf-table.remove">table.remove</A><BR>
<A HREF="manual.html#pdf-table.sort">table.sort</A><BR>

</TD>
</TR>
</TABLE>
<P>

</BODY>
</HTML>


================================================
FILE: doc/lua.css
================================================
body {
	color: #000000 ;
	background-color: #FFFFFF ;
	font-family: Helvetica, Arial, sans-serif ;
	text-align: justify ;
	margin: auto ;
	width: 50em ;
}

h1, h2, h3, h4 {
	font-family: Verdana, Geneva, sans-serif ;
	font-weight: normal ;
	font-style: italic ;
}

h2 {
	padding-top: 0.4em ;
	padding-bottom: 0.4em ;
	padding-left: 30px ;
	padding-right: 30px ;
	margin-left: -30px ;
	background-color: #E0E0FF ;
}

h3 {
	padding-left: 0.5em ;
	border-left: solid #E0E0FF 1em ;
}

table h3 {
	padding-left: 0px ;
	border-left: none ;
}

a:link {
	color: #000080 ;
	background-color: inherit ;
	text-decoration: none ;
}

a:visited {
	background-color: inherit ;
	text-decoration: none ;
}

a:link:hover, a:visited:hover {
	color: #000080 ;
	background-color: #E0E0FF ;
}

a:link:active, a:visited:active {
	color: #FF0000 ;
}

hr {
	border: 0 ;
	height: 1px ;
	color: #a0a0a0 ;
	background-color: #a0a0a0 ;
}

:target {
	background-color: #F8F8F8 ;
	padding: 8px ;
	border: solid #a0a0a0 2px ;
}

.footer {
	color: gray ;
	font-size: small ;
}

input[type=text] {
	border: solid #a0a0a0 2px ;
	border-radius: 2em ;
	-moz-border-radius: 2em ;
	background-image: url('images/search.png') ;
	background-repeat: no-repeat;
	background-position: 4px center ;
	padding-left: 20px ;
	height: 2em ;
}

.teliva {
	background-color: #f1a7fe;
	padding-left: 2px;
	padding-right: 2px;
	padding-top: 5px;
	padding-bottom: 2px;
}


================================================
FILE: doc/manual.css
================================================
h3 code {
	font-family: inherit ;
	font-size: inherit ;
}

pre, code {
	font-size: 12pt ;
}

span.apii {
	float: right ;
	font-family: inherit ;
	font-style: normal ;
	font-size: small ;
	color: gray ;
}

p+h1, ul+h1 {
	padding-top: 0.4em ;
	padding-bottom: 0.4em ;
	padding-left: 30px ;
	margin-left: -30px ;
	background-color: #E0E0FF ;
}

.teliva {
	background-color: #f1a7fe;
	padding-left: 2px;
	padding-right: 2px;
	padding-top: 5px;
	padding-bottom: 2px;
}


================================================
FILE: doc/manual.html
================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
<title>Teliva Reference Manual</title>
<link rel="stylesheet" type="text/css" href="lua.css">
<link rel="stylesheet" type="text/css" href="manual.css">
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
</head>

<body>

<hr>
<h1>
Teliva Reference Manual
</h1>

<small>
by Kartik Agaram
</small>

<p>
Based on <a href="http://www.lua.org/">Lua 5.1</a> by Roberto Ierusalimschy,
Luiz Henrique de Figueiredo, Waldemar Celes

<p>
<small>
Copyright &copy; 2006&ndash;2012 Lua.org, PUC-Rio.
Freely available under the terms of the
<a href="http://www.lua.org/license.html">Lua license</a>.
</small>

<hr>
<p>

<a href="contents.html#contents">contents</A>
&middot;
<a href="contents.html#index">index</A>
&middot;
<A HREF="http://www.lua.org/manual/">other versions</A>

<!-- ====================================================================== -->
<p>

<!-- $Id: manual.of,v 1.49.1.2 2012/01/13 20:23:26 roberto Exp $ -->




<h1>1 - <a name="1">Introduction</a></h1>

Teliva is a platform based on Lua for sandboxed software packaged with an
environment for making changes to it. For a more detailed introduction, see
<a href='../README.md'>the Readme</a>.

<p>
Teliva is free software, and is provided as usual with no guarantees, as
stated in its license.

<p>
This manual is based on the Lua manual. Lua features absent in Teliva should
be absent in this manual as well. <span class='teliva'>Features added to
Teliva above and beyond Lua will be described in text like this.</span>

<p>
For a discussion of the decisions behind the design of Lua,
see the technical papers available at Lua's web site.
For a detailed introduction to programming in Lua,
see Roberto's book, <em>Programming in Lua (Second Edition)</em>.



<h1>2 - <a name="2">The Language</a></h1>

<p>
This section describes the lexis, the syntax, and the semantics of Lua.
In other words,
this section describes
which tokens are valid,
how they can be combined,
and what their combinations mean.


<p>
The language constructs will be explained using the usual extended BNF notation,
in which
{<em>a</em>}&nbsp;means&nbsp;0 or more <em>a</em>'s, and
[<em>a</em>]&nbsp;means an optional <em>a</em>.
Non-terminals are shown like non-terminal,
keywords are shown like <b>kword</b>,
and other terminal symbols are shown like `<b>=</b>&acute;.
The complete syntax of Lua can be found in <a href="#8">&sect;8</a>
at the end of this manual.



<h2>2.1 - <a name="2.1">Lexical Conventions</a></h2>

<p>
<em>Names</em>
(also called <em>identifiers</em>)
in Lua can be any string of letters,
digits, and underscores,
not beginning with a digit.
This coincides with the definition of names in most languages.
(The definition of letter depends on the current locale:
any character considered alphabetic by the current locale
can be used in an identifier.)
Identifiers are used to name variables and table fields.


<p>
The following <em>keywords</em> are reserved
and cannot be used as names:


<pre>
     and       break     do        else      elseif
     end       false     for       function  if
     in        local     nil       not       or
     repeat    return    then      true      until     while
</pre>

<p>
Lua is a case-sensitive language:
<code>and</code> is a reserved word, but <code>And</code> and <code>AND</code>
are two different, valid names.
As a convention, names starting with an underscore followed by
uppercase letters (such as <a href="#pdf-_VERSION"><code>_VERSION</code></a>)
are reserved for internal global variables used by Lua.


<p>
The following strings denote other tokens:

<pre>
     +     -     *     /     %     ^     #
     ==    ~=    &lt;=    &gt;=    &lt;     &gt;     =
     (     )     {     }     [     ]
     ;     :     ,     .     ..    ...
</pre>

<p>
<em>Literal strings</em>
can be delimited by matching single or double quotes,
and can contain the following C-like escape sequences:
'<code>\a</code>' (bell),
'<code>\b</code>' (backspace),
'<code>\f</code>' (form feed),
'<code>\n</code>' (newline),
'<code>\r</code>' (carriage return),
'<code>\t</code>' (horizontal tab),
'<code>\v</code>' (vertical tab),
'<code>\\</code>' (backslash),
'<code>\"</code>' (quotation mark [double quote]),
and '<code>\'</code>' (apostrophe [single quote]).
Moreover, a backslash followed by a real newline
results in a newline in the string.
A character in a string can also be specified by its numerical value
using the escape sequence <code>\<em>ddd</em></code>,
where <em>ddd</em> is a sequence of up to three decimal digits.
(Note that if a numerical escape is to be followed by a digit,
it must be expressed using exactly three digits.)
Strings in Lua can contain any 8-bit value, including embedded zeros,
which can be specified as '<code>\0</code>'.


<p>
Literal strings can also be defined using a long format
enclosed by <em>long brackets</em>.
We define an <em>opening long bracket of level <em>n</em></em> as an opening
square bracket followed by <em>n</em> equal signs followed by another
opening square bracket.
So, an opening long bracket of level&nbsp;0 is written as <code>[[</code>,
an opening long bracket of level&nbsp;1 is written as <code>[=[</code>,
and so on.
A <em>closing long bracket</em> is defined similarly;
for instance, a closing long bracket of level&nbsp;4 is written as <code>]====]</code>.
A long string starts with an opening long bracket of any level and
ends at the first closing long bracket of the same level.
Literals in this bracketed form can run for several lines,
do not interpret any escape sequences,
and ignore long brackets of any other level.
They can contain anything except a closing bracket of the proper level.


<p>
For convenience,
when the opening long bracket is immediately followed by a newline,
the newline is not included in the string.
As an example, in a system using ASCII
(in which '<code>a</code>' is coded as&nbsp;97,
newline is coded as&nbsp;10, and '<code>1</code>' is coded as&nbsp;49),
the five literal strings below denote the same string:

<pre>
     a = 'alo\n123"'
     a = "alo\n123\""
     a = '\97lo\10\04923"'
     a = [[alo
     123"]]
     a = [==[
     alo
     123"]==]
</pre>

<p>
A <em>numerical constant</em> can be written with an optional decimal part
and an optional decimal exponent.
Lua also accepts integer hexadecimal constants,
by prefixing them with <code>0x</code>.
Examples of valid numerical constants are

<pre>
     3   3.0   3.1416   314.16e-2   0.31416E1   0xff   0x56
</pre>

<p>
A <em>comment</em> starts with a double hyphen (<code>--</code>)
anywhere outside a string.
If the text immediately after <code>--</code> is not an opening long bracket,
the comment is a <em>short comment</em>,
which runs until the end of the line.
Otherwise, it is a <em>long comment</em>,
which runs until the corresponding closing long bracket.
Long comments are frequently used to disable code temporarily.





<h2>2.2 - <a name="2.2">Values and Types</a></h2>

<p>
Lua is a <em>dynamically typed language</em>.
This means that
variables do not have types; only values do.
There are no type definitions in the language.
All values carry their own type.


<p>
All values in Lua are <em>first-class values</em>.
This means that all values can be stored in variables,
passed as arguments to other functions, and returned as results.


<p>
There are eight basic types in Lua:
<em>nil</em>, <em>boolean</em>, <em>number</em>,
<em>string</em>, <em>function</em>, <em>userdata</em>,
<em>thread</em>, and <em>table</em>.
<em>Nil</em> is the type of the value <b>nil</b>,
whose main property is to be different from any other value;
it usually represents the absence of a useful value.
<em>Boolean</em> is the type of the values <b>false</b> and <b>true</b>.
Both <b>nil</b> and <b>false</b> make a condition false;
any other value makes it true.
<em>Number</em> represents real (double-precision floating-point) numbers.
(It is easy to build Lua interpreters that use other
internal representations for numbers,
such as single-precision float or long integers;
see file <code>luaconf.h</code>.)
<em>String</em> represents arrays of characters.

Lua is 8-bit clean:
strings can contain any 8-bit character,
including embedded zeros ('<code>\0</code>') (see <a href="#2.1">&sect;2.1</a>).


<p>
<div class='teliva'>The type <em>userdata</em> is opaque to Teliva, and
used by low-level code to manage details of C&nbsp;data stored in Lua
variables. Unlike Lua, Teliva doesn't support creating or managing userdata
since it doesn't permit extension by C libraries. This manual doesn't allude
to userdata further.</div>

<p>
The type <em>thread</em> represents independent threads of execution
and it is used to implement coroutines (see <a href="#2.11">&sect;2.11</a>).
Do not confuse Lua threads with operating-system threads.
Lua supports coroutines on all systems,
even those that do not support threads.


<p>
The type <em>table</em> implements associative arrays,
that is, arrays that can be indexed not only with numbers,
but with any value (except <b>nil</b>).
Tables can be <em>heterogeneous</em>;
that is, they can contain values of all types (except <b>nil</b>).
Tables are the sole data structuring mechanism in Lua;
they can be used to represent ordinary arrays,
symbol tables, sets, records, graphs, trees, etc.
To represent records, Lua uses the field name as an index.
The language supports this representation by
providing <code>a.name</code> as syntactic sugar for <code>a["name"]</code>.
There are several convenient ways to create tables in Lua
(see <a href="#2.5.7">&sect;2.5.7</a>).


<p>
Like indices,
the value of a table field can be of any type (except <b>nil</b>).
In particular,
because functions are first-class values,
table fields can contain functions.
Thus tables can also carry <em>methods</em> (see <a href="#2.5.9">&sect;2.5.9</a>).


<p>
Tables, functions and threads are <em>objects</em>:
variables do not actually <em>contain</em> these values,
only <em>references</em> to them.
Assignment, parameter passing, and function returns
always manipulate references to such values;
these operations do not imply any kind of copy.


<p>
The library function <a href="#pdf-type"><code>type</code></a> returns a string describing the type
of a given value.



<h3>2.2.1 - <a name="2.2.1">Coercion</a></h3>

<p>
Lua provides automatic conversion between
string and number values at run time.
Any arithmetic operation applied to a string tries to convert
this string to a number, following the usual conversion rules.
Conversely, whenever a number is used where a string is expected,
the number is converted to a string, in a reasonable format.
For complete control over how numbers are converted to strings,
use the <code>format</code> function from the string library
(see <a href="#pdf-string.format"><code>string.format</code></a>).







<h2>2.3 - <a name="2.3">Variables</a></h2>

<p>
Variables are places that store values.

There are three kinds of variables in Lua:
global variables, local variables, and table fields.


<p>
A single name can denote a global variable or a local variable
(or a function's formal parameter,
which is a particular kind of local variable):

<pre>
	var ::= Name
</pre><p>
Name denotes identifiers, as defined in <a href="#2.1">&sect;2.1</a>.


<p>
Any variable is assumed to be global unless explicitly declared
as a local (see <a href="#2.4.7">&sect;2.4.7</a>).
Local variables are <em>lexically scoped</em>:
local variables can be freely accessed by functions
defined inside their scope (see <a href="#2.6">&sect;2.6</a>).


<p>
Before the first assignment to a variable, its value is <b>nil</b>.


<p>
Square brackets are used to index a table:

<pre>
	var ::= prefixexp `<b>[</b>&acute; exp `<b>]</b>&acute;
</pre><p>
The meaning of accesses to global variables 
and table fields can be changed via metatables.
An access to an indexed variable <code>t[i]</code> is equivalent to
a call <code>gettable_event(t,i)</code>.
(See <a href="#2.8">&sect;2.8</a> for a complete description of the
<code>gettable_event</code> function.
This function is not defined or callable in Lua.
We use it here only for explanatory purposes.)


<p>
The syntax <code>var.Name</code> is just syntactic sugar for
<code>var["Name"]</code>:

<pre>
	var ::= prefixexp `<b>.</b>&acute; Name
</pre>

<p>
All global variables live as fields in ordinary Lua tables,
called <em>environment tables</em> or simply
<em>environments</em> (see <a href="#2.9">&sect;2.9</a>).
Each function has its own reference to an environment,
so that all global variables in this function
will refer to this environment table.
When a function is created,
it inherits the environment from the function that created it.
To get the environment table of a Lua function,
you call <a href="#pdf-getfenv"><code>getfenv</code></a>.
To replace it,
you call <a href="#pdf-setfenv"><code>setfenv</code></a>.


<p>
An access to a global variable <code>x</code>
is equivalent to <code>_env.x</code>,
which in turn is equivalent to

<pre>
     gettable_event(_env, "x")
</pre><p>
where <code>_env</code> is the environment of the running function.
(See <a href="#2.8">&sect;2.8</a> for a complete description of the
<code>gettable_event</code> function.
This function is not defined or callable in Lua.
Similarly, the <code>_env</code> variable is not defined in Lua.
We use them here only for explanatory purposes.)





<h2>2.4 - <a name="2.4">Statements</a></h2>

<p>
Lua supports an almost conventional set of statements,
similar to those in Pascal or C.
This set includes
assignments, control structures, function calls,
and variable declarations.



<h3>2.4.1 - <a name="2.4.1">Chunks</a></h3>

<p>
The unit of execution of Lua is called a <em>chunk</em>.
A chunk is simply a sequence of statements,
which are executed sequentially.
Each statement can be optionally followed by a semicolon:

<pre>
	chunk ::= {stat [`<b>;</b>&acute;]}
</pre><p>
There are no empty statements and thus '<code>;;</code>' is not legal.


<p>
Lua handles a chunk as the body of an anonymous function 
with a variable number of arguments
(see <a href="#2.5.9">&sect;2.5.9</a>).
As such, chunks can define local variables,
receive arguments, and return values.


<p>
A chunk can be stored in a file or in a string inside the host program.
To execute a chunk,
Lua first pre-compiles the chunk into instructions for a virtual machine,
and then it executes the compiled code
with an interpreter for the virtual machine.


<p>
Chunks can also be pre-compiled into binary form;
see program <code>luac</code> for details.
Programs in source and compiled forms are interchangeable;
Lua automatically detects the file type and acts accordingly.






<h3>2.4.2 - <a name="2.4.2">Blocks</a></h3><p>
A block is a list of statements;
syntactically, a block is the same as a chunk:

<pre>
	block ::= chunk
</pre>

<p>
A block can be explicitly delimited to produce a single statement:

<pre>
	stat ::= <b>do</b> block <b>end</b>
</pre><p>
Explicit blocks are useful
to control the scope of variable declarations.
Explicit blocks are also sometimes used to
add a <b>return</b> or <b>break</b> statement in the middle
of another block (see <a href="#2.4.4">&sect;2.4.4</a>).





<h3>2.4.3 - <a name="2.4.3">Assignment</a></h3>

<p>
Lua allows multiple assignments.
Therefore, the syntax for assignment
defines a list of variables on the left side
and a list of expressions on the right side.
The elements in both lists are separated by commas:

<pre>
	stat ::= varlist `<b>=</b>&acute; explist
	varlist ::= var {`<b>,</b>&acute; var}
	explist ::= exp {`<b>,</b>&acute; exp}
</pre><p>
Expressions are discussed in <a href="#2.5">&sect;2.5</a>.


<p>
Before the assignment,
the list of values is <em>adjusted</em> to the length of
the list of variables.
If there are more values than needed,
the excess values are thrown away.
If there are fewer values than needed,
the list is extended with as many  <b>nil</b>'s as needed.
If the list of expressions ends with a function call,
then all values returned by that call enter the list of values,
before the adjustment
(except when the call is enclosed in parentheses; see <a href="#2.5">&sect;2.5</a>).


<p>
The assignment statement first evaluates all its expressions
and only then are the assignments performed.
Thus the code

<pre>
     i = 3
     i, a[i] = i+1, 20
</pre><p>
sets <code>a[3]</code> to 20, without affecting <code>a[4]</code>
because the <code>i</code> in <code>a[i]</code> is evaluated (to 3)
before it is assigned&nbsp;4.
Similarly, the line

<pre>
     x, y = y, x
</pre><p>
exchanges the values of <code>x</code> and <code>y</code>,
and

<pre>
     x, y, z = y, z, x
</pre><p>
cyclically permutes the values of <code>x</code>, <code>y</code>, and <code>z</code>.


<p>
The meaning of assignments to global variables
and table fields can be changed via metatables.
An assignment to an indexed variable <code>t[i] = val</code> is equivalent to
<code>settable_event(t,i,val)</code>.
(See <a href="#2.8">&sect;2.8</a> for a complete description of the
<code>settable_event</code> function.
This function is not defined or callable in Lua.
We use it here only for explanatory purposes.)


<p>
An assignment to a global variable <code>x = val</code>
is equivalent to the assignment
<code>_env.x = val</code>,
which in turn is equivalent to

<pre>
     settable_event(_env, "x", val)
</pre><p>
where <code>_env</code> is the environment of the running function.
(The <code>_env</code> variable is not defined in Lua.
We use it here only for explanatory purposes.)





<h3>2.4.4 - <a name="2.4.4">Control Structures</a></h3><p>
The control structures
<b>if</b>, <b>while</b>, and <b>repeat</b> have the usual meaning and
familiar syntax:




<pre>
	stat ::= <b>while</b> exp <b>do</b> block <b>end</b>
	stat ::= <b>repeat</b> block <b>until</b> exp
	stat ::= <b>if</b> exp <b>then</b> block {<b>elseif</b> exp <b>then</b> block} [<b>else</b> block] <b>end</b>
</pre><p>
Lua also has a <b>for</b> statement, in two flavors (see <a href="#2.4.5">&sect;2.4.5</a>).


<p>
The condition expression of a
control structure can return any value.
Both <b>false</b> and <b>nil</b> are considered false.
All values different from <b>nil</b> and <b>false</b> are considered true
(in particular, the number 0 and the empty string are also true).


<p>
In the <b>repeat</b>&ndash;<b>until</b> loop,
the inner block does not end at the <b>until</b> keyword,
but only after the condition.
So, the condition can refer to local variables
declared inside the loop block.


<p>
The <b>return</b> statement is used to return values
from a function or a chunk (which is just a function).

Functions and chunks can return more than one value,
and so the syntax for the <b>return</b> statement is

<pre>
	stat ::= <b>return</b> [explist]
</pre>

<p>
The <b>break</b> statement is used to terminate the execution of a
<b>while</b>, <b>repeat</b>, or <b>for</b> loop,
skipping to the next statement after the loop:


<pre>
	stat ::= <b>break</b>
</pre><p>
A <b>break</b> ends the innermost enclosing loop.


<p>
The <b>return</b> and <b>break</b>
statements can only be written as the <em>last</em> statement of a block.
If it is really necessary to <b>return</b> or <b>break</b> in the
middle of a block,
then an explicit inner block can be used,
as in the idioms
<code>do return end</code> and <code>do break end</code>,
because now <b>return</b> and <b>break</b> are the last statements in
their (inner) blocks.





<h3>2.4.5 - <a name="2.4.5">For Statement</a></h3>

<p>

The <b>for</b> statement has two forms:
one numeric and one generic.


<p>
The numeric <b>for</b> loop repeats a block of code while a
control variable runs through an arithmetic progression.
It has the following syntax:

<pre>
	stat ::= <b>for</b> Name `<b>=</b>&acute; exp `<b>,</b>&acute; exp [`<b>,</b>&acute; exp] <b>do</b> block <b>end</b>
</pre><p>
The <em>block</em> is repeated for <em>name</em> starting at the value of
the first <em>exp</em>, until it passes the second <em>exp</em> by steps of the
third <em>exp</em>.
More precisely, a <b>for</b> statement like

<pre>
     for v = <em>e1</em>, <em>e2</em>, <em>e3</em> do <em>block</em> end
</pre><p>
is equivalent to the code:

<pre>
     do
       local <em>var</em>, <em>limit</em>, <em>step</em> = tonumber(<em>e1</em>), tonumber(<em>e2</em>), tonumber(<em>e3</em>)
       if not (<em>var</em> and <em>limit</em> and <em>step</em>) then error() end
       while (<em>step</em> &gt; 0 and <em>var</em> &lt;= <em>limit</em>) or (<em>step</em> &lt;= 0 and <em>var</em> &gt;= <em>limit</em>) do
         local v = <em>var</em>
         <em>block</em>
         <em>var</em> = <em>var</em> + <em>step</em>
       end
     end
</pre><p>
Note the following:

<ul>

<li>
All three control expressions are evaluated only once,
before the loop starts.
They must all result in numbers.
</li>

<li>
<code><em>var</em></code>, <code><em>limit</em></code>, and <code><em>step</em></code> are invisible variables.
The names shown here are for explanatory purposes only.
</li>

<li>
If the third expression (the step) is absent,
then a step of&nbsp;1 is used.
</li>

<li>
You can use <b>break</b> to exit a <b>for</b> loop.
</li>

<li>
The loop variable <code>v</code> is local to the loop;
you cannot use its value after the <b>for</b> ends or is broken.
If you need this value,
assign it to another variable before breaking or exiting the loop.
</li>

</ul>

<p>
The generic <b>for</b> statement works over functions,
called <em>iterators</em>.
On each iteration, the iterator function is called to produce a new value,
stopping when this new value is <b>nil</b>.
The generic <b>for</b> loop has the following syntax:

<pre>
	stat ::= <b>for</b> namelist <b>in</b> explist <b>do</b> block <b>end</b>
	namelist ::= Name {`<b>,</b>&acute; Name}
</pre><p>
A <b>for</b> statement like

<pre>
     for <em>var_1</em>, &middot;&middot;&middot;, <em>var_n</em> in <em>explist</em> do <em>block</em> end
</pre><p>
is equivalent to the code:

<pre>
     do
       local <em>f</em>, <em>s</em>, <em>var</em> = <em>explist</em>
       while true do
         local <em>var_1</em>, &middot;&middot;&middot;, <em>var_n</em> = <em>f</em>(<em>s</em>, <em>var</em>)
         <em>var</em> = <em>var_1</em>
         if <em>var</em> == nil then break end
         <em>block</em>
       end
     end
</pre><p>
Note the following:

<ul>

<li>
<code><em>explist</em></code> is evaluated only once.
Its results are an <em>iterator</em> function,
a <em>state</em>,
and an initial value for the first <em>iterator variable</em>.
</li>

<li>
<code><em>f</em></code>, <code><em>s</em></code>, and <code><em>var</em></code> are invisible variables.
The names are here for explanatory purposes only.
</li>

<li>
You can use <b>break</b> to exit a <b>for</b> loop.
</li>

<li>
The loop variables <code><em>var_i</em></code> are local to the loop;
you cannot use their values after the <b>for</b> ends.
If you need these values,
then assign them to other variables before breaking or exiting the loop.
</li>

</ul>




<h3>2.4.6 - <a name="2.4.6">Function Calls as Statements</a></h3><p>
To allow possible side-effects,
function calls can be executed as statements:

<pre>
	stat ::= functioncall
</pre><p>
In this case, all returned values are thrown away.
Function calls are explained in <a href="#2.5.8">&sect;2.5.8</a>.





<h3>2.4.7 - <a name="2.4.7">Local Declarations</a></h3><p>
Local variables can be declared anywhere inside a block.
The declaration can include an initial assignment:

<pre>
	stat ::= <b>local</b> namelist [`<b>=</b>&acute; explist]
</pre><p>
If present, an initial assignment has the same semantics
of a multiple assignment (see <a href="#2.4.3">&sect;2.4.3</a>).
Otherwise, all variables are initialized with <b>nil</b>.


<p>
A chunk is also a block (see <a href="#2.4.1">&sect;2.4.1</a>),
and so local variables can be declared in a chunk outside any explicit block.
The scope of such local variables extends until the end of the chunk.


<p>
The visibility rules for local variables are explained in <a href="#2.6">&sect;2.6</a>.







<h2>2.5 - <a name="2.5">Expressions</a></h2>

<p>
The basic expressions in Lua are the following:

<pre>
	exp ::= prefixexp
	exp ::= <b>nil</b> | <b>false</b> | <b>true</b>
	exp ::= Number
	exp ::= String
	exp ::= function
	exp ::= tableconstructor
	exp ::= `<b>...</b>&acute;
	exp ::= exp binop exp
	exp ::= unop exp
	prefixexp ::= var | functioncall | `<b>(</b>&acute; exp `<b>)</b>&acute;
</pre>

<p>
Numbers and literal strings are explained in <a href="#2.1">&sect;2.1</a>;
variables are explained in <a href="#2.3">&sect;2.3</a>;
function definitions are explained in <a href="#2.5.9">&sect;2.5.9</a>;
function calls are explained in <a href="#2.5.8">&sect;2.5.8</a>;
table constructors are explained in <a href="#2.5.7">&sect;2.5.7</a>.
Vararg expressions,
denoted by three dots ('<code>...</code>'), can only be used when
directly inside a vararg function;
they are explained in <a href="#2.5.9">&sect;2.5.9</a>.


<p>
Binary operators comprise arithmetic operators (see <a href="#2.5.1">&sect;2.5.1</a>),
relational operators (see <a href="#2.5.2">&sect;2.5.2</a>), logical operators (see <a href="#2.5.3">&sect;2.5.3</a>),
and the concatenation operator (see <a href="#2.5.4">&sect;2.5.4</a>).
Unary operators comprise the unary minus (see <a href="#2.5.1">&sect;2.5.1</a>),
the unary <b>not</b> (see <a href="#2.5.3">&sect;2.5.3</a>),
and the unary <em>length operator</em> (see <a href="#2.5.5">&sect;2.5.5</a>).


<p>
Both function calls and vararg expressions can result in multiple values.
If an expression is used as a statement
(only possible for function calls (see <a href="#2.4.6">&sect;2.4.6</a>)),
then its return list is adjusted to zero elements,
thus discarding all returned values.
If an expression is used as the last (or the only) element
of a list of expressions,
then no adjustment is made
(unless the call is enclosed in parentheses).
In all other contexts,
Lua adjusts the result list to one element,
discarding all values except the first one.


<p>
Here are some examples:

<pre>
     f()                -- adjusted to 0 results
     g(f(), x)          -- f() is adjusted to 1 result
     g(x, f())          -- g gets x plus all results from f()
     a,b,c = f(), x     -- f() is adjusted to 1 result (c gets nil)
     a,b = ...          -- a gets the first vararg parameter, b gets
                        -- the second (both a and b can get nil if there
                        -- is no corresponding vararg parameter)
     
     a,b,c = x, f()     -- f() is adjusted to 2 results
     a,b,c = f()        -- f() is adjusted to 3 results
     return f()         -- returns all results from f()
     return ...         -- returns all received vararg parameters
     return x,y,f()     -- returns x, y, and all results from f()
     {f()}              -- creates a list with all results from f()
     {...}              -- creates a list with all vararg parameters
     {f(), nil}         -- f() is adjusted to 1 result
</pre>

<p>
Any expression enclosed in parentheses always results in only one value.
Thus,
<code>(f(x,y,z))</code> is always a single value,
even if <code>f</code> returns several values.
(The value of <code>(f(x,y,z))</code> is the first value returned by <code>f</code>
or <b>nil</b> if <code>f</code> does not return any values.)



<h3>2.5.1 - <a name="2.5.1">Arithmetic Operators</a></h3><p>
Lua supports the usual arithmetic operators:
the binary <code>+</code> (addition),
<code>-</code> (subtraction), <code>*</code> (multiplication),
<code>/</code> (division), <code>%</code> (modulo), and <code>^</code> (exponentiation);
and unary <code>-</code> (negation).
If the operands are numbers, or strings that can be converted to
numbers (see <a href="#2.2.1">&sect;2.2.1</a>),
then all operations have the usual meaning.
Exponentiation works for any exponent.
For instance, <code>x^(-0.5)</code> computes the inverse of the square root of <code>x</code>.
Modulo is defined as

<pre>
     a % b == a - math.floor(a/b)*b
</pre><p>
That is, it is the remainder of a division that rounds
the quotient towards minus infinity.





<h3>2.5.2 - <a name="2.5.2">Relational Operators</a></h3><p>
The relational operators in Lua are

<pre>
     ==    ~=    &lt;     &gt;     &lt;=    &gt;=
</pre><p>
These operators always result in <b>false</b> or <b>true</b>.


<p>
Equality (<code>==</code>) first compares the type of its operands.
If the types are different, then the result is <b>false</b>.
Otherwise, the values of the operands are compared.
Numbers and strings are compared in the usual way.
Objects (tables, threads, and functions)
are compared by <em>reference</em>:
two objects are considered equal only if they are the <em>same</em> object.
Every time you create a new object
(a table, thread, or function),
this new object is different from any previously existing object.


<p>
You can change the way that Lua compares tables by using the "eq" metamethod
(see <a href="#2.8">&sect;2.8</a>).


<p>
The conversion rules of <a href="#2.2.1">&sect;2.2.1</a>
<em>do not</em> apply to equality comparisons.
Thus, <code>"0"==0</code> evaluates to <b>false</b>,
and <code>t[0]</code> and <code>t["0"]</code> denote different
entries in a table.


<p>
The operator <code>~=</code> is exactly the negation of equality (<code>==</code>).


<p>
The order operators work as follows.
If both arguments are numbers, then they are compared as such.
Otherwise, if both arguments are strings,
then their values are compared according to the current locale.
Otherwise, Lua tries to call the "lt" or the "le"
metamethod (see <a href="#2.8">&sect;2.8</a>).
A comparison <code>a &gt; b</code> is translated to <code>b &lt; a</code>
and <code>a &gt;= b</code> is translated to <code>b &lt;= a</code>.





<h3>2.5.3 - <a name="2.5.3">Logical Operators</a></h3><p>
The logical operators in Lua are
<b>and</b>, <b>or</b>, and <b>not</b>.
Like the control structures (see <a href="#2.4.4">&sect;2.4.4</a>),
all logical operators consider both <b>false</b> and <b>nil</b> as false
and anything else as true.


<p>
The negation operator <b>not</b> always returns <b>false</b> or <b>true</b>.
The conjunction operator <b>and</b> returns its first argument
if this value is <b>false</b> or <b>nil</b>;
otherwise, <b>and</b> returns its second argument.
The disjunction operator <b>or</b> returns its first argument
if this value is different from <b>nil</b> and <b>false</b>;
otherwise, <b>or</b> returns its second argument.
Both <b>and</b> and <b>or</b> use short-cut evaluation;
that is,
the second operand is evaluated only if necessary.
Here are some examples:

<pre>
     10 or 20            --&gt; 10
     10 or error()       --&gt; 10
     nil or "a"          --&gt; "a"
     nil and 10          --&gt; nil
     false and error()   --&gt; false
     false and nil       --&gt; false
     false or nil        --&gt; nil
     10 and 20           --&gt; 20
</pre><p>
(In this manual,
<code>--&gt;</code> indicates the result of the preceding expression.)





<h3>2.5.4 - <a name="2.5.4">Concatenation</a></h3><p>
The string concatenation operator in Lua is
denoted by two dots ('<code>..</code>').
If both operands are strings or numbers, then they are converted to
strings according to the rules mentioned in <a href="#2.2.1">&sect;2.2.1</a>.
Otherwise, the "concat" metamethod is called (see <a href="#2.8">&sect;2.8</a>).





<h3>2.5.5 - <a name="2.5.5">The Length Operator</a></h3>

<p>
The length operator is denoted by the unary operator <code>#</code>.
The length of a string is its number of bytes
(that is, the usual meaning of string length when each
character is one byte).


<p>
The length of a table <code>t</code> is defined to be any
integer index <code>n</code>
such that <code>t[n]</code> is not <b>nil</b> and <code>t[n+1]</code> is <b>nil</b>;
moreover, if <code>t[1]</code> is <b>nil</b>, <code>n</code> can be zero.
For a regular array, with non-nil values from 1 to a given <code>n</code>,
its length is exactly that <code>n</code>,
the index of its last value.
If the array has "holes"
(that is, <b>nil</b> values between other non-nil values),
then <code>#t</code> can be any of the indices that
directly precedes a <b>nil</b> value
(that is, it may consider any such <b>nil</b> value as the end of
the array). 





<h3>2.5.6 - <a name="2.5.6">Precedence</a></h3><p>
Operator precedence in Lua follows the table below,
from lower to higher priority:

<pre>
     or
     and
     &lt;     &gt;     &lt;=    &gt;=    ~=    ==
     ..
     +     -
     *     /     %
     not   #     - (unary)
     ^
</pre><p>
As usual,
you can use parentheses to change the precedences of an expression.
The concatenation ('<code>..</code>') and exponentiation ('<code>^</code>')
operators are right associative.
All other binary operators are left associative.





<h3>2.5.7 - <a name="2.5.7">Table Constructors</a></h3><p>
Table constructors are expressions that create tables.
Every time a constructor is evaluated, a new table is created.
A constructor can be used to create an empty table
or to create a table and initialize some of its fields.
The general syntax for constructors is

<pre>
	tableconstructor ::= `<b>{</b>&acute; [fieldlist] `<b>}</b>&acute;
	fieldlist ::= field {fieldsep field} [fieldsep]
	field ::= `<b>[</b>&acute; exp `<b>]</b>&acute; `<b>=</b>&acute; exp | Name `<b>=</b>&acute; exp | exp
	fieldsep ::= `<b>,</b>&acute; | `<b>;</b>&acute;
</pre>

<p>
Each field of the form <code>[exp1] = exp2</code> adds to the new table an entry
with key <code>exp1</code> and value <code>exp2</code>.
A field of the form <code>name = exp</code> is equivalent to
<code>["name"] = exp</code>.
Finally, fields of the form <code>exp</code> are equivalent to
<code>[i] = exp</code>, where <code>i</code> are consecutive numerical integers,
starting with 1.
Fields in the other formats do not affect this counting.
For example,

<pre>
     a = { [f(1)] = g; "x", "y"; x = 1, f(x), [30] = 23; 45 }
</pre><p>
is equivalent to

<pre>
     do
       local t = {}
       t[f(1)] = g
       t[1] = "x"         -- 1st exp
       t[2] = "y"         -- 2nd exp
       t.x = 1            -- t["x"] = 1
       t[3] = f(x)        -- 3rd exp
       t[30] = 23
       t[4] = 45          -- 4th exp
       a = t
     end
</pre>

<p>
If the last field in the list has the form <code>exp</code>
and the expression is a function call or a vararg expression,
then all values returned by this expression enter the list consecutively
(see <a href="#2.5.8">&sect;2.5.8</a>).
To avoid this,
enclose the function call or the vararg expression
in parentheses (see <a href="#2.5">&sect;2.5</a>).


<p>
The field list can have an optional trailing separator,
as a convenience for machine-generated code.





<h3>2.5.8 - <a name="2.5.8">Function Calls</a></h3><p>
A function call in Lua has the following syntax:

<pre>
	functioncall ::= prefixexp args
</pre><p>
In a function call,
first prefixexp and args are evaluated.
If the value of prefixexp has type <em>function</em>,
then this function is called
with the given arguments.
Otherwise, the prefixexp "call" metamethod is called,
having as first parameter the value of prefixexp,
followed by the original call arguments
(see <a href="#2.8">&sect;2.8</a>).


<p>
The form

<pre>
	functioncall ::= prefixexp `<b>:</b>&acute; Name args
</pre><p>
can be used to call "methods".
A call <code>v:name(<em>args</em>)</code>
is syntactic sugar for <code>v.name(v,<em>args</em>)</code>,
except that <code>v</code> is evaluated only once.


<p>
Arguments have the following syntax:

<pre>
	args ::= `<b>(</b>&acute; [explist] `<b>)</b>&acute;
	args ::= tableconstructor
	args ::= String
</pre><p>
All argument expressions are evaluated before the call.
A call of the form <code>f{<em>fields</em>}</code> is
syntactic sugar for <code>f({<em>fields</em>})</code>;
that is, the argument list is a single new table.
A call of the form <code>f'<em>string</em>'</code>
(or <code>f"<em>string</em>"</code> or <code>f[[<em>string</em>]]</code>)
is syntactic sugar for <code>f('<em>string</em>')</code>;
that is, the argument list is a single literal string.


<p>
As an exception to the free-format syntax of Lua,
you cannot put a line break before the '<code>(</code>' in a function call.
This restriction avoids some ambiguities in the language.
If you write

<pre>
     a = f
     (g).x(a)
</pre><p>
Lua would see that as a single statement, <code>a = f(g).x(a)</code>.
So, if you want two statements, you must add a semi-colon between them.
If you actually want to call <code>f</code>,
you must remove the line break before <code>(g)</code>.


<p>
A call of the form <code>return</code> <em>functioncall</em> is called
a <em>tail call</em>.
Lua implements <em>proper tail calls</em>
(or <em>proper tail recursion</em>):
in a tail call,
the called function reuses the stack entry of the calling function.
Therefore, there is no limit on the number of nested tail calls that
a program can execute.
However, a tail call erases any debug information about the
calling function.
Note that a tail call only happens with a particular syntax,
where the <b>return</b> has one single function call as argument;
this syntax makes the calling function return exactly
the returns of the called function.
So, none of the following examples are tail calls:

<pre>
     return (f(x))        -- results adjusted to 1
     return 2 * f(x)
     return x, f(x)       -- additional results
     f(x); return         -- results discarded
     return x or f(x)     -- results adjusted to 1
</pre>




<h3>2.5.9 - <a name="2.5.9">Function Definitions</a></h3>

<p>
The syntax for function definition is

<pre>
	function ::= <b>function</b> funcbody
	funcbody ::= `<b>(</b>&acute; [parlist] `<b>)</b>&acute; block <b>end</b>
</pre>

<p>
The following syntactic sugar simplifies function definitions:

<pre>
	stat ::= <b>function</b> funcname funcbody
	stat ::= <b>local</b> <b>function</b> Name funcbody
	funcname ::= Name {`<b>.</b>&acute; Name} [`<b>:</b>&acute; Name]
</pre><p>
The statement

<pre>
     function f () <em>body</em> end
</pre><p>
translates to

<pre>
     f = function () <em>body</em> end
</pre><p>
The statement

<pre>
     function t.a.b.c.f () <em>body</em> end
</pre><p>
translates to

<pre>
     t.a.b.c.f = function () <em>body</em> end
</pre><p>
The statement

<pre>
     local function f () <em>body</em> end
</pre><p>
translates to

<pre>
     local f; f = function () <em>body</em> end
</pre><p>
<em>not</em> to

<pre>
     local f = function () <em>body</em> end
</pre><p>
(This only makes a difference when the body of the function
contains references to <code>f</code>.)


<p>
A function definition is an executable expression,
whose value has type <em>function</em>.
When Lua pre-compiles a chunk,
all its function bodies are pre-compiled too.
Then, whenever Lua executes the function definition,
the function is <em>instantiated</em> (or <em>closed</em>).
This function instance (or <em>closure</em>)
is the final value of the expression.
Different instances of the same function
can refer to different  external local variables
and can have different environment tables.


<p>
Parameters act as local variables that are
initialized with the argument values:

<pre>
	parlist ::= namelist [`<b>,</b>&acute; `<b>...</b>&acute;] | `<b>...</b>&acute;
</pre><p>
When a function is called,
the list of arguments is adjusted to
the length of the list of parameters,
unless the function is a variadic or <em>vararg function</em>,
which is
indicated by three dots ('<code>...</code>') at the end of its parameter list.
A vararg function does not adjust its argument list;
instead, it collects all extra arguments and supplies them
to the function through a <em>vararg expression</em>,
which is also written as three dots.
The value of this expression is a list of all actual extra arguments,
similar to a function with multiple results.
If a vararg expression is used inside another expression
or in the middle of a list of expressions,
then its return list is adjusted to one element.
If the expression is used as the last element of a list of expressions,
then no adjustment is made
(unless that last expression is enclosed in parentheses).


<p>
As an example, consider the following definitions:

<pre>
     function f(a, b) end
     function g(a, b, ...) end
     function r() return 1,2,3 end
</pre><p>
Then, we have the following mapping from arguments to parameters and
to the vararg expression:

<pre>
     CALL            PARAMETERS
     
     f(3)             a=3, b=nil
     f(3, 4)          a=3, b=4
     f(3, 4, 5)       a=3, b=4
     f(r(), 10)       a=1, b=10
     f(r())           a=1, b=2
     
     g(3)             a=3, b=nil, ... --&gt;  (nothing)
     g(3, 4)          a=3, b=4,   ... --&gt;  (nothing)
     g(3, 4, 5, 8)    a=3, b=4,   ... --&gt;  5  8
     g(5, r())        a=5, b=1,   ... --&gt;  2  3
</pre>

<p>
Results are returned using the <b>return</b> statement (see <a href="#2.4.4">&sect;2.4.4</a>).
If control reaches the end of a function
without encountering a <b>return</b> statement,
then the function returns with no results.


<p>
The <em>colon</em> syntax
is used for defining <em>methods</em>,
that is, functions that have an implicit extra parameter <code>self</code>.
Thus, the statement

<pre>
     function t.a.b.c:f (<em>params</em>) <em>body</em> end
</pre><p>
is syntactic sugar for

<pre>
     t.a.b.c.f = function (self, <em>params</em>) <em>body</em> end
</pre>






<h2>2.6 - <a name="2.6">Visibility Rules</a></h2>

<p>

Lua is a lexically scoped language.
The scope of variables begins at the first statement <em>after</em>
their declaration and lasts until the end of the innermost block that
includes the declaration.
Consider the following example:

<pre>
     x = 10                -- global variable
     do                    -- new block
       local x = x         -- new 'x', with value 10
       print(x)            --&gt; 10
       x = x+1
       do                  -- another block
         local x = x+1     -- another 'x'
         print(x)          --&gt; 12
       end
       print(x)            --&gt; 11
     end
     print(x)              --&gt; 10  (the global one)
</pre>

<p>
Notice that, in a declaration like <code>local x = x</code>,
the new <code>x</code> being declared is not in scope yet,
and so the second <code>x</code> refers to the outside variable.


<p>
Because of the lexical scoping rules,
local variables can be freely accessed by functions
defined inside their scope.
A local variable used by an inner function is called
an <em>upvalue</em>, or <em>external local variable</em>,
inside the inner function.


<p>
Notice that each execution of a <b>local</b> statement
defines new local variables.
Consider the following example:

<pre>
     a = {}
     local x = 20
     for i=1,10 do
       local y = 0
       a[i] = function () y=y+1; return x+y end
     end
</pre><p>
The loop creates ten closures
(that is, ten instances of the anonymous function).
Each of these closures uses a different <code>y</code> variable,
while all of them share the same <code>x</code>.





<h2>2.7 - <a name="2.7">Error Handling</a></h2>

<p>
<div class='teliva'>
Errors returned by Teliva code should display on screen in red. Please report
crashes or other behavior.
</div>


<p>
Lua code can explicitly generate an error by calling the
<a href="#pdf-error"><code>error</code></a> function.
If you need to catch errors in Lua,
you can use the <a href="#pdf-pcall"><code>pcall</code></a> function.





<h2>2.8 - <a name="2.8">Metatables</a></h2>

<p>
Every value in Lua can have a <em>metatable</em>.
This <em>metatable</em> is an ordinary Lua table
that defines the behavior of the original value
under certain special operations.
You can change several aspects of the behavior
of operations over a value by setting specific fields in its metatable.
For instance, when a non-numeric value is the operand of an addition,
Lua checks for a function in the field <code>"__add"</code> in its metatable.
If it finds one,
Lua calls this function to perform the addition.


<p>
We call the keys in a metatable <em>events</em>
and the values <em>metamethods</em>.
In the previous example, the event is <code>"add"</code> 
and the metamethod is the function that performs the addition.


<p>
You can query the metatable of any value
through the <a href="#pdf-getmetatable"><code>getmetatable</code></a> function.


<p>
You can replace the metatable of tables
through the <a href="#pdf-setmetatable"><code>setmetatable</code></a>
function.


<p>
Tables have individual metatables
(although multiple tables can share their metatables).
Values of all other types share one single metatable per type;
that is, there is one single metatable for all numbers,
one for all strings, etc.


<p>
A metatable controls how an object behaves in arithmetic operations,
order comparisons, concatenation, length operation, and indexing.
For each of these operations Lua associates a specific key
called an <em>event</em>.
When Lua performs one of these operations over a value,
it checks whether this value has a metatable with the corresponding event.
If so, the value associated with that key (the metamethod)
controls how Lua will perform the operation.


<p>
Metatables control the operations listed next.
Each operation is identified by its corresponding name.
The key for each operation is a string with its name prefixed by
two underscores, '<code>__</code>';
for instance, the key for operation "add" is the
string <code>"__add"</code>.
The semantics of these operations is better explained by a Lua function
describing how the interpreter executes the operation.


<p>
The code shown here in Lua is only illustrative;
the real behavior is hard coded in the interpreter
and it is much more efficient than this simulation.
All functions used in these descriptions
(<a href="#pdf-rawget"><code>rawget</code></a>, <a href="#pdf-tonumber"><code>tonumber</code></a>, etc.)
are described in <a href="#5.1">&sect;5.1</a>.
In particular, to retrieve the metamethod of a given object,
we use the expression

<pre>
     metatable(obj)[event]
</pre><p>
This should be read as

<pre>
     rawget(getmetatable(obj) or {}, event)
</pre><p>

That is, the access to a metamethod does not invoke other metamethods,
and the access to objects with no metatables does not fail
(it simply results in <b>nil</b>).



<ul>

<li><b>"add":</b>
the <code>+</code> operation.



<p>
The function <code>getbinhandler</code> below defines how Lua chooses a handler
for a binary operation.
First, Lua tries the first operand.
If its type does not define a handler for the operation,
then Lua tries the second operand.

<pre>
     function getbinhandler (op1, op2, event)
       return metatable(op1)[event] or metatable(op2)[event]
     end
</pre><p>
By using this function,
the behavior of the <code>op1 + op2</code> is

<pre>
     function add_event (op1, op2)
       local o1, o2 = tonumber(op1), tonumber(op2)
       if o1 and o2 then  -- both operands are numeric?
         return o1 + o2   -- '+' here is the primitive 'add'
       else  -- at least one of the operands is not numeric
         local h = getbinhandler(op1, op2, "__add")
         if h then
           -- call the handler with both operands
           return (h(op1, op2))
         else  -- no handler available: default behavior
           error(&middot;&middot;&middot;)
         end
       end
     end
</pre><p>
</li>

<li><b>"sub":</b>
the <code>-</code> operation.

Behavior similar to the "add" operation.
</li>

<li><b>"mul":</b>
the <code>*</code> operation.

Behavior similar to the "add" operation.
</li>

<li><b>"div":</b>
the <code>/</code> operation.

Behavior similar to the "add" operation.
</li>

<li><b>"mod":</b>
the <code>%</code> operation.

Behavior similar to the "add" operation,
with the operation
<code>o1 - floor(o1/o2)*o2</code> as the primitive operation.
</li>

<li><b>"pow":</b>
the <code>^</code> (exponentiation) operation.

Behavior similar to the "add" operation,
with the function <code>pow</code> (from the C&nbsp;math library)
as the primitive operation.
</li>

<li><b>"unm":</b>
the unary <code>-</code> operation.


<pre>
     function unm_event (op)
       local o = tonumber(op)
       if o then  -- operand is numeric?
         return -o  -- '-' here is the primitive 'unm'
       else  -- the operand is not numeric.
         -- Try to get a handler from the operand
         local h = metatable(op).__unm
         if h then
           -- call the handler with the operand
           return (h(op))
         else  -- no handler available: default behavior
           error(&middot;&middot;&middot;)
         end
       end
     end
</pre><p>
</li>

<li><b>"concat":</b>
the <code>..</code> (concatenation) operation.


<pre>
     function concat_event (op1, op2)
       if (type(op1) == "string" or type(op1) == "number") and
          (type(op2) == "string" or type(op2) == "number") then
         return op1 .. op2  -- primitive string concatenation
       else
         local h = getbinhandler(op1, op2, "__concat")
         if h then
           return (h(op1, op2))
         else
           error(&middot;&middot;&middot;)
         end
       end
     end
</pre><p>
</li>

<li><b>"len":</b>
the <code>#</code> operation.


<pre>
     function len_event (op)
       if type(op) == "string" then
         return strlen(op)         -- primitive string length
       elseif type(op) == "table" then
         return #op                -- primitive table length
       else
         local h = metatable(op).__len
         if h then
           -- call the handler with the operand
           return (h(op))
         else  -- no handler available: default behavior
           error(&middot;&middot;&middot;)
         end
       end
     end
</pre><p>
See <a href="#2.5.5">&sect;2.5.5</a> for a description of the length of a table.
</li>

<li><b>"eq":</b>
the <code>==</code> operation.

The function <code>getcomphandler</code> defines how Lua chooses a metamethod
for comparison operators.
A metamethod only is selected when both objects
being compared have the same type
and the same metamethod for the selected operation.

<pre>
     function getcomphandler (op1, op2, event)
       if type(op1) ~= type(op2) then return nil end
       local mm1 = metatable(op1)[event]
       local mm2 = metatable(op2)[event]
       if mm1 == mm2 then return mm1 else return nil end
     end
</pre><p>
The "eq" event is defined as follows:

<pre>
     function eq_event (op1, op2)
       if type(op1) ~= type(op2) then  -- different types?
         return false   -- different objects
       end
       if op1 == op2 then   -- primitive equal?
         return true   -- objects are equal
       end
       -- try metamethod
       local h = getcomphandler(op1, op2, "__eq")
       if h then
         return (h(op1, op2))
       else
         return false
       end
     end
</pre><p>
<code>a ~= b</code> is equivalent to <code>not (a == b)</code>.
</li>

<li><b>"lt":</b>
the <code>&lt;</code> operation.


<pre>
     function lt_event (op1, op2)
       if type(op1) == "number" and type(op2) == "number" then
         return op1 &lt; op2   -- numeric comparison
       elseif type(op1) == "string" and type(op2) == "string" then
         return op1 &lt; op2   -- lexicographic comparison
       else
         local h = getcomphandler(op1, op2, "__lt")
         if h then
           return (h(op1, op2))
         else
           error(&middot;&middot;&middot;)
         end
       end
     end
</pre><p>
<code>a &gt; b</code> is equivalent to <code>b &lt; a</code>.
</li>

<li><b>"le":</b>
the <code>&lt;=</code> operation.


<pre>
     function le_event (op1, op2)
       if type(op1) == "number" and type(op2) == "number" then
         return op1 &lt;= op2   -- numeric comparison
       elseif type(op1) == "string" and type(op2) == "string" then
         return op1 &lt;= op2   -- lexicographic comparison
       else
         local h = getcomphandler(op1, op2, "__le")
         if h then
           return (h(op1, op2))
         else
           h = getcomphandler(op1, op2, "__lt")
           if h then
             return not h(op2, op1)
           else
             error(&middot;&middot;&middot;)
           end
         end
       end
     end
</pre><p>
<code>a &gt;= b</code> is equivalent to <code>b &lt;= a</code>.
Note that, in the absence of a "le" metamethod,
Lua tries the "lt", assuming that <code>a &lt;= b</code> is
equivalent to <code>not (b &lt; a)</code>.
</li>

<li><b>"index":</b>
The indexing access <code>table[key]</code>.


<pre>
     function gettable_event (table, key)
       local h
       if type(table) == "table" then
         local v = rawget(table, key)
         if v ~= nil then return v end
         h = metatable(table).__index
         if h == nil then return nil end
       else
         h = metatable(table).__index
         if h == nil then
           error(&middot;&middot;&middot;)
         end
       end
       if type(h) == "function" then
         return (h(table, key))     -- call the handler
       else return h[key]           -- or repeat operation on it
       end
     end
</pre><p>
</li>

<li><b>"newindex":</b>
The indexing assignment <code>table[key] = value</code>.


<pre>
     function settable_event (table, key, value)
       local h
       if type(table) == "table" then
         local v = rawget(table, key)
         if v ~= nil then rawset(table, key, value); return end
         h = metatable(table).__newindex
         if h == nil then rawset(table, key, value); return end
       else
         h = metatable(table).__newindex
         if h == nil then
           error(&middot;&middot;&middot;)
         end
       end
       if type(h) == "function" then
         h(table, key,value)           -- call the handler
       else h[key] = value             -- or repeat operation on it
       end
     end
</pre><p>
</li>

<li><b>"call":</b>
called when Lua calls a value.


<pre>
     function function_event (func, ...)
       if type(func) == "function" then
         return func(...)   -- primitive call
       else
         local h = metatable(func).__call
         if h then
           return h(func, ...)
         else
           error(&middot;&middot;&middot;)
         end
       end
     end
</pre><p>
</li>

</ul>




<h2>2.9 - <a name="2.9">Environments</a></h2>

<p>
Besides metatables, objects of types thread and function
have another table associated with them, called their
<em>environment</em>.
Like metatables, environments are regular tables and
multiple objects can share the same environment.


<p>
Threads are created sharing the environment of the creating thread.
Nested Lua functions are created sharing the environment of
the creating Lua function.


<p>
Environments associated with threads are called
<em>global environments</em>.
They are used as the default environment for threads.


<p>
Environments associated with Lua functions are used to resolve
all accesses to global variables within the function (see <a href="#2.3">&sect;2.3</a>).
They are used as the default environment for nested Lua functions
created by the function.


<p>
You can change the environment of a Lua function or the
running thread by calling <a href="#pdf-setfenv"><code>setfenv</code></a>.
You can get the environment of a Lua function or the running thread
by calling <a href="#pdf-getfenv"><code>getfenv</code></a>.





<h2>2.10 - <a name="2.10">Garbage Collection</a></h2>

<p>
Lua performs automatic memory management.
This means that
you have to worry neither about allocating memory for new objects
nor about freeing it when the objects are no longer needed.
Lua manages memory automatically by running
a <em>garbage collector</em> from time to time
to collect all <em>dead objects</em>
(that is, objects that are no longer accessible from Lua).
All memory used by Lua is subject to automatic management:
tables, functions, threads, strings, etc.


<p>
Lua implements an incremental mark-and-sweep collector.
It uses two numbers to control its garbage-collection cycles:
the <em>garbage-collector pause</em> and
the <em>garbage-collector step multiplier</em>.
Both use percentage points as units
(so that a value of 100 means an internal value of 1).


<p>
The garbage-collector pause
controls how long the collector waits before starting a new cycle.
Larger values make the collector less aggressive.
Values smaller than 100 mean the collector will not wait to
start a new cycle.
A value of 200 means that the collector waits for the total memory in use
to double before starting a new cycle.


<p>
The step multiplier
controls the relative speed of the collector relative to
memory allocation.
Larger values make the collector more aggressive but also increase
the size of each incremental step.
Values smaller than 100 make the collector too slow and
can result in the collector never finishing a cycle.
The default, 200, means that the collector runs at "twice"
the speed of memory allocation.


<p>
<div class='teliva'>Modifying these parameters requires changes to Teliva's C
sources.</div>



<h3>2.10.2 - <a name="2.10.2">Weak Tables</a></h3>

<p>
A <em>weak table</em> is a table whose elements are
<em>weak references</em>.
A weak reference is ignored by the garbage collector.
In other words,
if the only references to an object are weak references,
then the garbage collector will collect this object.


<p>
A weak table can have weak keys, weak values, or both.
A table with weak keys allows the collection of its keys,
but prevents the collection of its values.
A table with both weak keys and weak values allows the collection of
both keys and values.
In any case, if either the key or the value is collected,
the whole pair is removed from the table.
The weakness of a table is controlled by the
<code>__mode</code> field of its metatable.
If the <code>__mode</code> field is a string containing the character&nbsp;'<code>k</code>',
the keys in the table are weak.
If <code>__mode</code> contains '<code>v</code>',
the values in the table are weak.


<p>
After you use a table as a metatable,
you should not change the value of its <code>__mode</code> field.
Otherwise, the weak behavior of the tables controlled by this
metatable is undefined.







<h2>2.11 - <a name="2.11">Coroutines</a></h2>

<p>
Lua supports coroutines,
also called <em>collaborative multithreading</em>.
A coroutine in Lua represents an independent thread of execution.
Unlike threads in multithread systems, however,
a coroutine only suspends its execution by explicitly calling
a yield function.


<p>
You create a coroutine with a call to <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>.
Its sole argument is a function
that is the main function of the coroutine.
The <code>create</code> function only creates a new coroutine and
returns a handle to it (an object of type <em>thread</em>);
it does not start the coroutine execution.


<p>
When you first call <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>,
passing as its first argument
a thread returned by <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,
the coroutine starts its execution,
at the first line of its main function.
Extra arguments passed to <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> are passed on
to the coroutine main function.
After the coroutine starts running,
it runs until it terminates or <em>yields</em>.


<p>
A coroutine can terminate its execution in two ways:
normally, when its main function returns
(explicitly or implicitly, after the last instruction);
and abnormally, if there is an unprotected error.
In the first case, <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> returns <b>true</b>,
plus any values returned by the coroutine main function.
In case of errors, <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> returns <b>false</b>
plus an error message.


<p>
A coroutine yields by calling <a href="#pdf-coroutine.yield"><code>coroutine.yield</code></a>.
When a coroutine yields,
the corresponding <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> returns immediately,
even if the yield happens inside nested function calls
(that is, not in the main function,
but in a function directly or indirectly called by the main function).
In the case of a yield, <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a> also returns <b>true</b>,
plus any values passed to <a href="#pdf-coroutine.yield"><code>coroutine.yield</code></a>.
The next time you resume the same coroutine,
it continues its execution from the point where it yielded,
with the call to <a href="#pdf-coroutine.yield"><code>coroutine.yield</code></a> returning any extra
arguments passed to <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>.


<p>
Like <a href="#pdf-coroutine.create"><code>coroutine.create</code></a>,
the <a href="#pdf-coroutine.wrap"><code>coroutine.wrap</code></a> function also creates a coroutine,
but instead of returning the coroutine itself,
it returns a function that, when called, resumes the coroutine.
Any arguments passed to this function
go as extra arguments to <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>.
<a href="#pdf-coroutine.wrap"><code>coroutine.wrap</code></a> returns all the values returned by <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>,
except the first one (the boolean error code).
Unlike <a href="#pdf-coroutine.resume"><code>coroutine.resume</code></a>,
<a href="#pdf-coroutine.wrap"><code>coroutine.wrap</code></a> does not catch errors;
any error is propagated to the caller.


<p>
As an example,
consider the following code:

<pre>
     function foo (a)
       print("foo", a)
       return coroutine.yield(2*a)
     end
     
     co = coroutine.create(function (a,b)
           print("co-body", a, b)
           local r = foo(a+1)
           print("co-body", r)
           local r, s = coroutine.yield(a+b, a-b)
           print("co-body", r, s)
           return b, "end"
     end)
            
     print("main", coroutine.resume(co, 1, 10))
     print("main", coroutine.resume(co, "r"))
     print("main", coroutine.resume(co, "x", "y"))
     print("main", coroutine.resume(co, "x", "y"))
</pre><p>
When you run it, it produces the following output:

<pre>
     co-body 1       10
     foo     2
     
     main    true    4
     co-body r
     main    true    11      -9
     co-body x       y
     main    true    10      end
     main    false   cannot resume dead coroutine
</pre>

<div class='teliva'>
Coroutines are powerful, but require some experience to use tastefully. Try to
use them judiciously. If you find yourself juggling lots of coroutines and
trying to decide which one to try to resume, you should probably be using
<a href='#5.13'>tasks and channels</a> instead. On the other hand, tasks have
some cognitive overheads. You have to explicitly manage them with
<a href='#pdf-task.scheduler'><code>task.scheduler</code></a>, and errors can
sometimes be hard to track down. For simple generators that emit elements
on demand, a coroutine is likely the best solution.
</div>


<h1>3 - <a name="3">C API</a></h1>

<div class='teliva'>Unlike Lua, Teliva isn't intended to be modified at the C
level. However, forks of Teliva are encouraged.</div>


<h1>5 - <a name="5">Standard Libraries</a></h1>

<p>
The standard Lua libraries provide useful functions
that are implemented directly in C.
Some of these functions provide essential services to the language
(e.g., <a href="#pdf-type"><code>type</code></a> and <a href="#pdf-getmetatable"><code>getmetatable</code></a>);
others provide access to "outside" services (e.g., I/O);
and others could be implemented in Lua itself,
but are quite useful or have critical performance requirements that
deserve an implementation in C (e.g., <a href="#pdf-table.sort"><code>table.sort</code></a>).


<p>
Currently, Lua has the following standard libraries:

<ul>

<li>basic library, which includes the coroutine sub-library;</li>

<li>package library;</li>

<li>string manipulation;</li>

<li>table manipulation;</li>

<li>mathematical functions (sin, log, etc.);</li>

<li>input and output;</li>

<li>operating system facilities;</li>

<li>debug facilities.</li>

</ul><p>
Except for the basic and package libraries,
each library provides all its functions as fields of a global table
or as methods of its objects.


<h2>5.1 - <a name="5.1">Basic Primitives</a></h2>

<p>
The basic library provides some core functions to Lua.
If you do not include this library in your application,
you should check carefully whether you need to provide 
implementations for some of its facilities.


<p>
<hr><h3><a name="pdf-arg"><code>arg</code></a></h3>
A global variable containing any commandline arguments.


<p>
<hr><h3><a name="pdf-assert"><code>assert (v [, message])</code></a></h3>
Issues an  error when
the value of its argument <code>v</code> is false (i.e., <b>nil</b> or <b>false</b>);
otherwise, returns all its arguments.
<code>message</code> is an error message;
when absent, it defaults to "assertion failed!"




<p>
<hr><h3><a name="pdf-collectgarbage"><code>collectgarbage ([opt [, arg]])</code></a></h3>


<p>
This function is a generic interface to the garbage collector.
It performs different functions according to its first argument, <code>opt</code>:

<ul>

<li><b>"collect":</b>
performs a full garbage-collection cycle.
This is the default option.
</li>

<li><b>"stop":</b>
stops the garbage collector.
</li>

<li><b>"restart":</b>
restarts the garbage collector.
</li>

<li><b>"count":</b>
returns the total memory in use by Lua (in Kbytes).
</li>

<li><b>"step":</b>
performs a garbage-collection step.
The step "size" is controlled by <code>arg</code>
(larger values mean more steps) in a non-specified way.
If you want to control the step size
you must experimentally tune the value of <code>arg</code>.
Returns <b>true</b> if the step finished a collection cycle.
</li>

<li><b>"setpause":</b>
sets <code>arg</code> as the new value for the <em>pause</em> of
the collector (see <a href="#2.10">&sect;2.10</a>).
Returns the previous value for <em>pause</em>.
</li>

<li><b>"setstepmul":</b>
sets <code>arg</code> as the new value for the <em>step multiplier</em> of
the collector (see <a href="#2.10">&sect;2.10</a>).
Returns the previous value for <em>step</em>.
</li>

</ul>




<p>
<hr><h3><a name="pdf-error"><code>error (message [, level])</code></a></h3>
Terminates the last protected function called
and returns <code>message</code> as the error message.
Function <code>error</code> never returns.


<p>
Usually, <code>error</code> adds some information about the error position
at the beginning of the message.
The <code>level</code> argument specifies how to get the error position.
With level&nbsp;1 (the default), the error position is where the
<code>error</code> function was called.
Level&nbsp;2 points the error to where the function
that called <code>error</code> was called; and so on.
Passing a level&nbsp;0 avoids the addition of error position information
to the message.




<p>
<hr><h3><a name="pdf-_G"><code>_G</code></a></h3>
A global variable that
holds the global environment (that is, <code>_G._G = _G</code>).
Lua itself does not use this variable;
changing its value does not affect any environment,
nor vice-versa.
(Use <a href="#pdf-setfenv"><code>setfenv</code></a> to change environments.)




<p>
<hr><h3><a name="pdf-getfenv"><code>getfenv ([f])</code></a></h3>
Returns the current environment in use by the function.
<code>f</code> can be a Lua function or a number
that specifies the function at that stack level:
Level&nbsp;1 is the function calling <code>getfenv</code>.
If the given function is not a Lua function,
or if <code>f</code> is 0,
<code>getfenv</code> returns the global environment.
The default for <code>f</code> is 1.




<p>
<hr><h3><a name="pdf-getmetatable"><code>getmetatable (object)</code></a></h3>


<p>
If <code>object</code> does not have a metatable, returns <b>nil</b>.
Otherwise,
if the object's metatable has a <code>"__metatable"</code> field,
returns the associated value.
Otherwise, returns the metatable of the given object.




<p>
<hr><h3><a name="pdf-ipairs"><code>ipairs (t)</code></a></h3>


<p>
Returns three values: an iterator function, the table <code>t</code>, and 0,
so that the construction

<pre>
     for i,v in ipairs(t) do <em>body</em> end
</pre><p>
will iterate over the pairs (<code>1,t[1]</code>), (<code>2,t[2]</code>), &middot;&middot;&middot;,
up to the first integer key absent from the table.


<p>
<hr><h3><a name="pdf-next"><code>next (table [, index])</code></a></h3>


<p>
Allows a program to traverse all fields of a table.
Its first argument is a table and its second argument
is an index in this table.
<code>next</code> returns the next index of the table
and its associated value.
When called with <b>nil</b> as its second argument,
<code>next</code> returns an initial index
and its associated value.
When called with the last index,
or with <b>nil</b> in an empty table,
<code>next</code> returns <b>nil</b>.
If the second argument is absent, then it is interpreted as <b>nil</b>.
In particular,
you can use <code>next(t)</code> to check whether a table is empty.


<p>
The order in which the indices are enumerated is not specified,
<em>even for numeric indices</em>.
(To traverse a table in numeric order,
use a numerical <b>for</b> or the <a href="#pdf-ipairs"><code>ipairs</code></a> function.)


<p>
The behavior of <code>next</code> is <em>undefined</em> if,
during the traversal,
you assign any value to a non-existent field in the table.
You may however modify existing fields.
In particular, you may clear existing fields.




<p>
<hr><h3><a name="pdf-pairs"><code>pairs (t)</code></a></h3>


<p>
Returns three values: the <a href="#pdf-next"><code>next</code></a> function, the table <code>t</code>, and <b>nil</b>,
so that the construction

<pre>
     for k,v in pairs(t) do <em>body</em> end
</pre><p>
will iterate over all key&ndash;value pairs of table <code>t</code>.


<p>
See function <a href="#pdf-next"><code>next</code></a> for the caveats of modifying
the table during its traversal.




<p>
<hr><h3><a name="pdf-print"><code>print (&middot;&middot;&middot;)</code></a></h3>
Receives any number of arguments,
and prints their values to <code>stdout</code>,
using the <a href="#pdf-tostring"><code>tostring</code></a> function to convert them to strings.
<code>print</code> is not intended for formatted output,
but only as a quick way to show a value,
typically for debugging.
For formatted output, use <a href="#pdf-string.format"><code>string.format</code></a>.




<p>
<hr><h3><a name="pdf-rawequal"><code>rawequal (v1, v2)</code></a></h3>
Checks whether <code>v1</code> is equal to <code>v2</code>,
without invoking any metamethod.
Returns a boolean.




<p>
<hr><h3><a name="pdf-rawget"><code>rawget (table, index)</code></a></h3>
Gets the real value of <code>table[index]</code>,
without invoking any metamethod.
<code>table</code> must be a table;
<code>index</code> may be any value.




<p>
<hr><h3><a name="pdf-rawset"><code>rawset (table, index, value)</code></a></h3>
Sets the real value of <code>table[index]</code> to <code>value</code>,
without invoking any metamethod.
<code>table</code> must be a table,
<code>index</code> any value different from <b>nil</b>,
and <code>value</code> any Lua value.


<p>
This function returns <code>table</code>.




<p>
<hr><h3><a name="pdf-select"><code>select (index, &middot;&middot;&middot;)</code></a></h3>


<p>
If <code>index</code> is a number,
returns all arguments after argument number <code>index</code>.
Otherwise, <code>index</code> must be the string <code>"#"</code>,
and <code>select</code> returns the total number of extra arguments it received.




<p>
<hr><h3><a name="pdf-setfenv"><code>setfenv (f, table)</code></a></h3>


<p>
Sets the environment to be used by the given function.
<code>f</code> can be a Lua function or a number
that specifies the function at that stack level:
Level&nbsp;1 is the function calling <code>setfenv</code>.
<code>setfenv</code> returns the given function.


<p>
As a special case, when <code>f</code> is 0 <code>setfenv</code> changes
the environment of the running thread.
In this case, <code>setfenv</code> returns no values.




<p>
<hr><h3><a name="pdf-setmetatable"><code>setmetatable (table, metatable)</code></a></h3>


<p>
Sets the metatable for the given table.
(You cannot change the metatable of other types.)
If <code>metatable</code> is <b>nil</b>,
removes the metatable of the given table.
If the original metatable has a <code>"__metatable"</code> field,
raises an error.


<p>
This function returns <code>table</code>.




<p>
<hr><h3><a name="pdf-tonumber"><code>tonumber (e [, base])</code></a></h3>
Tries to convert its argument to a number.
If the argument is already a number or a string convertible
to a number, then <code>tonumber</code> returns this number;
otherwise, it returns <b>nil</b>.


<p>
An optional argument specifies the base to interpret the numeral.
The base may be any integer between 2 and 36, inclusive.
In bases above&nbsp;10, the letter '<code>A</code>' (in either upper or lower case)
represents&nbsp;10, '<code>B</code>' represents&nbsp;11, and so forth,
with '<code>Z</code>' representing 35.
In base 10 (the default), the number can have a decimal part,
as well as an optional exponent part (see <a href="#2.1">&sect;2.1</a>).
In other bases, only unsigned integers are accepted.




<p>
<hr><h3><a name="pdf-tostring"><code>tostring (e)</code></a></h3>
Receives an argument of any type and
converts it to a string in a reasonable format.
For complete control of how numbers are converted,
use <a href="#pdf-string.format"><code>string.format</code></a>.


<p>
If the metatable of <code>e</code> has a <code>"__tostring"</code> field,
then <code>tostring</code> calls the corresponding value
with <code>e</code> as argument,
and uses the result of the call as its result.




<p>
<hr><h3><a name="pdf-type"><code>type (v)</code></a></h3>
Returns the type of its only argument, coded as a string.
The possible results of this function are
"<code>nil</code>" (a string, not the value <b>nil</b>),
"<code>number</code>",
"<code>string</code>",
"<code>boolean</code>",
"<code>table</code>",
"<code>function</code>",
"<code>thread</code>",
and "<code>userdata</code>".




<p>
<hr><h3><a name="pdf-unpack"><code>unpack (list [, i [, j]])</code></a></h3>
Returns the elements from the given table.
This function is equivalent to

<pre>
     return list[i], list[i+1], &middot;&middot;&middot;, list[j]
</pre><p>
except that the above code can be written only for a fixed number
of elements.
By default, <code>i</code> is&nbsp;1 and <code>j</code> is the length of the list,
as defined by the length operator (see <a href="#2.5.5">&sect;2.5.5</a>).




<p>
<hr><h3><a name="pdf-_VERSION"><code>_VERSION</code></a></h3>
A global variable (not a function) that
holds a string containing the current interpreter version.
The current contents of this variable is "<code>Lua 5.1</code>".




<h2>5.2 - <a name="5.2">Coroutine Manipulation</a></h2>

<p>
The operations related to coroutines comprise a sub-library of
the basic library and come inside the table <a name="pdf-coroutine"><code>coroutine</code></a>.
See <a href="#2.11">&sect;2.11</a> for a general description of coroutines.


<p>
<hr><h3><a name="pdf-coroutine.create"><code>coroutine.create (f)</code></a></h3>


<p>
Creates a new coroutine, with body <code>f</code>.
<code>f</code> must be a Lua function.
Returns this new coroutine,
an object with type <code>"thread"</code>.




<p>
<hr><h3><a name="pdf-coroutine.resume"><code>coroutine.resume (co [, val1, &middot;&middot;&middot;])</code></a></h3>


<p>
Starts or continues the execution of coroutine <code>co</code>.
The first time you resume a coroutine,
it starts running its body.
The values <code>val1</code>, &middot;&middot;&middot; are passed
as the arguments to the body function.
If the coroutine has yielded,
<code>resume</code> restarts it;
the values <code>val1</code>, &middot;&middot;&middot; are passed
as the results from the yield.


<p>
If the coroutine runs without any errors,
<code>resume</code> returns <b>true</b> plus any values passed to <code>yield</code>
(if the coroutine yields) or any values returned by the body function
(if the coroutine terminates).
If there is any error,
<code>resume</code> returns <b>false</b> plus the error message.




<p>
<hr><h3><a name="pdf-coroutine.running"><code>coroutine.running ()</code></a></h3>


<p>
Returns the running coroutine,
or <b>nil</b> when called by the main thread.




<p>
<hr><h3><a name="pdf-coroutine.status"><code>coroutine.status (co)</code></a></h3>


<p>
Returns the status of coroutine <code>co</code>, as a string:
<code>"running"</code>,
if the coroutine is running (that is, it called <code>status</code>);
<code>"suspended"</code>, if the coroutine is suspended in a call to <code>yield</code>,
or if it has not started running yet;
<code>"normal"</code> if the coroutine is active but not running
(that is, it has resumed another coroutine);
and <code>"dead"</code> if the coroutine has finished its body function,
or if it has stopped with an error.




<p>
<hr><h3><a name="pdf-coroutine.wrap"><code>coroutine.wrap (f)</code></a></h3>


<p>
Creates a new coroutine, with body <code>f</code>.
<code>f</code> must be a Lua function.
Returns a function that resumes the coroutine each time it is called.
Any arguments passed to the function behave as the
extra arguments to <code>resume</code>.
Returns the same values returned by <code>resume</code>,
except the first boolean.
In case of error, propagates the error.




<p>
<hr><h3><a name="pdf-coroutine.yield"><code>coroutine.yield (&middot;&middot;&middot;)</code></a></h3>


<p>
Suspends the execution of the calling coroutine.
The coroutine cannot be running a primitive implemented in
C, a metamethod, or an iterator.
Any arguments to <code>yield</code> are passed as extra results to <code>resume</code>.







<h2>5.4 - <a name="5.4">String Manipulation</a></h2>

<p>
This library provides generic functions for string manipulation,
such as finding and extracting substrings, and pattern matching.
When indexing a string in Lua, the first character is at position&nbsp;1
(not at&nbsp;0, as in C).
Indices are allowed to be negative and are interpreted as indexing backwards,
from the end of the string.
Thus, the last character is at position -1, and so on.


<p>
The string library provides all its functions inside the table
<a name="pdf-string"><code>string</code></a>.
It also sets a metatable for strings
where the <code>__index</code> field points to the <code>string</code> table.
Therefore, you can use the string functions in object-oriented style.
For instance, <code>string.byte(s, i)</code>
can be written as <code>s:byte(i)</code>.


<p>
The string library assumes one-byte character encodings.


<p>
<hr><h3><a name="pdf-string.byte"><code>string.byte (s [, i [, j]])</code></a></h3>
Returns the internal numerical codes of the characters <code>s[i]</code>,
<code>s[i+1]</code>, &middot;&middot;&middot;, <code>s[j]</code>.
The default value for <code>i</code> is&nbsp;1;
the default value for <code>j</code> is&nbsp;<code>i</code>.


<p>
Note that numerical codes are not necessarily portable across platforms.




<p>
<hr><h3><a name="pdf-string.char"><code>string.char (&middot;&middot;&middot;)</code></a></h3>
Receives zero or more integers.
Returns a string with length equal to the number of arguments,
in which each character has the internal numerical code equal
to its corresponding argument.


<p>
Note that numerical codes are not necessarily portable across platforms.



<p>
<hr><h3><a name="pdf-string.find"><code>string.find (s, pattern [, init [, plain]])</code></a></h3>
Looks for the first match of
<code>pattern</code> in the string <code>s</code>.
If it finds a match, then <code>find</code> returns the indices of&nbsp;<code>s</code>
where this occurrence starts and ends;
otherwise, it returns <b>nil</b>.
A third, optional numerical argument <code>init</code> specifies
where to start the search;
its default value is&nbsp;1 and can be negative.
A value of <b>true</b> as a fourth, optional argument <code>plain</code>
turns off the pattern matching facilities,
so the function does a plain "find substring" operation,
with no characters in <code>pattern</code> being considered "magic".
Note that if <code>plain</code> is given, then <code>init</code> must be given as well.


<p>
If the pattern has captures,
then in a successful match
the captured values are also returned,
after the two indices.




<p>
<hr><h3><a name="pdf-string.format"><code>string.format (formatstring, &middot;&middot;&middot;)</code></a></h3>
Returns a formatted version of its variable number of arguments
following the description given in its first argument (which must be a string).
The format string follows the same rules as the <code>printf</code> family of
standard C&nbsp;functions.
The only differences are that the options/modifiers
<code>*</code>, <code>l</code>, <code>L</code>, <code>n</code>, <code>p</code>,
and <code>h</code> are not supported
and that there is an extra option, <code>q</code>.
The <code>q</code> option formats a string in a form suitable to be safely read
back by the Lua interpreter:
the string is written between double quotes,
and all double quotes, newlines, embedded zeros,
and backslashes in the string
are correctly escaped when written.
For instance, the call

<pre>
     string.format('%q', 'a string with "quotes" and \n new line')
</pre><p>
will produce the string:

<pre>
     "a string with \"quotes\" and \
      new line"
</pre>

<p>
The options <code>c</code>, <code>d</code>, <code>E</code>, <code>e</code>, <code>f</code>,
<code>g</code>, <code>G</code>, <code>i</code>, <code>o</code>, <code>u</code>, <code>X</code>, and <code>x</code> all
expect a number as argument,
whereas <code>q</code> and <code>s</code> expect a string.


<p>
This function does not accept string values
containing embedded zeros,
except as arguments to the <code>q</code> option.




<p>
<hr><h3><a name="pdf-string.gmatch"><code>string.gmatch (s, pattern)</code></a></h3>
Returns an iterator function that,
each time it is called,
returns the next captures from <code>pattern</code> over string <code>s</code>.
If <code>pattern</code> specifies no captures,
then the whole match is produced in each call.


<p>
As an example, the following loop

<pre>
     s = "hello world from Lua"
     for w in string.gmatch(s, "%a+") do
       print(w)
     end
</pre><p>
will iterate over all the words from string <code>s</code>,
printing one per line.
The next example collects all pairs <code>key=value</code> from the
given string into a table:

<pre>
     t = {}
     s = "from=world, to=Lua"
     for k, v in string.gmatch(s, "(%w+)=(%w+)") do
       t[k] = v
     end
</pre>

<p>
For this function, a '<code>^</code>' at the start of a pattern does not
work as an anchor, as this would prevent the iteration.




<p>
<hr><h3><a name="pdf-string.gsub"><code>string.gsub (s, pattern, repl [, n])</code></a></h3>
Returns a copy of <code>s</code>
in which all (or the first <code>n</code>, if given)
occurrences of the <code>pattern</code> have been
replaced by a replacement string specified by <code>repl</code>,
which can be a string, a table, or a function.
<code>gsub</code> also returns, as its second value,
the total number of matches that occurred.


<p>
If <code>repl</code> is a string, then its value is used for replacement.
The character&nbsp;<code>%</code> works as an escape character:
any sequence in <code>repl</code> of the form <code>%<em>n</em></code>,
with <em>n</em> between 1 and 9,
stands for the value of the <em>n</em>-th captured substring (see below).
The sequence <code>%0</code> stands for the whole match.
The sequence <code>%%</code> stands for a single&nbsp;<code>%</code>.


<p>
If <code>repl</code> is a table, then the table is queried for every match,
using the first capture as the key;
if the pattern specifies no captures,
then the whole match is used as the key.


<p>
If <code>repl</code> is a function, then this function is called every time a
match occurs, with all captured substrings passed as arguments,
in order;
if the pattern specifies no captures,
then the whole match is passed as a sole argument.


<p>
If the value returned by the table query or by the function call
is a string or a number,
then it is used as the replacement string;
otherwise, if it is <b>false</b> or <b>nil</b>,
then there is no replacement
(that is, the original match is kept in the string).


<p>
Here are some examples:

<pre>
     x = string.gsub("hello world", "(%w+)", "%1 %1")
     --&gt; x="hello hello world world"
     
     x = string.gsub("hello world", "%w+", "%0 %0", 1)
     --&gt; x="hello hello world"
     
     x = string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1")
     --&gt; x="world hello Lua from"
     
     x = string.gsub("home = $HOME, user = $USER", "%$(%w+)", os.getenv)
     --&gt; x="home = /home/roberto, user = roberto"
     
     local t = {name="lua", version="5.1"}
     x = string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
     --&gt; x="lua-5.1.tar.gz"
</pre>



<p>
<hr><h3><a name="pdf-string.len"><code>string.len (s)</code></a></h3>
Receives a string and returns its length.
The empty string <code>""</code> has length 0.
Embedded zeros are counted,
so <code>"a\000bc\000"</code> has length 5.




<p>
<hr><h3><a name="pdf-string.lower"><code>string.lower (s)</code></a></h3>
Receives a string and returns a copy of this string with all
uppercase letters changed to lowercase.
All other characters are left unchanged.
The definition of what an uppercase letter is depends on the current locale.




<p>
<hr><h3><a name="pdf-string.match"><code>string.match (s, pattern [, init])</code></a></h3>
Looks for the first <em>match</em> of
<code>pattern</code> in the string <code>s</code>.
If it finds one, then <code>match</code> returns
the captures from the pattern;
otherwise it returns <b>nil</b>.
If <code>pattern</code> specifies no captures,
then the whole match is returned.
A third, optional numerical argument <code>init</code> specifies
where to start the search;
its default value is&nbsp;1 and can be negative.




<p>
<hr><h3><a name="pdf-string.rep"><code>string.rep (s, n)</code></a></h3>
Returns a string that is the concatenation of <code>n</code> copies of
the string <code>s</code>.




<p>
<hr><h3><a name="pdf-string.reverse"><code>string.reverse (s)</code></a></h3>
Returns a string that is the string <code>s</code> reversed.




<p>
<hr><h3><a name="pdf-string.sub"><code>string.sub (s, i [, j])</code></a></h3>
Returns the substring of <code>s</code> that
starts at <code>i</code>  and continues until <code>j</code>;
<code>i</code> and <code>j</code> can be negative.
If <code>j</code> is absent, then it is assumed to be equal to -1
(which is the same as the string length).
In particular,
the call <code>string.sub(s,1,j)</code> returns a prefix of <code>s</code>
with length <code>j</code>,
and <code>string.sub(s, -i)</code> returns a suffix of <code>s</code>
with length <code>i</code>.




<p>
<hr><h3><a name="pdf-string.upper"><code>string.upper (s)</code></a></h3>
Receives a string and returns a copy of this string with all
lowercase letters changed to uppercase.
All other characters are left unchanged.
The definition of what a lowercase letter is depends on the current locale.



<h3>5.4.1 - <a name="5.4.1">Patterns</a></h3>


<h4>Character Class:</h4><p>
A <em>character class</em> is used to represent a set of characters.
The following combinations are allowed in describing a character class:

<ul>

<li><b><em>x</em>:</b>
(where <em>x</em> is not one of the <em>magic characters</em>
<code>^$()%.[]*+-?</code>)
represents the character <em>x</em> itself.
</li>

<li><b><code>.</code>:</b> (a dot) represents all characters.</li>

<li><b><code>%a</code>:</b> represents all letters.</li>

<li><b><code>%c</code>:</b> represents all control characters.</li>

<li><b><code>%d</code>:</b> represents all digits.</li>

<li><b><code>%l</code>:</b> represents all lowercase letters.</li>

<li><b><code>%p</code>:</b> represents all punctuation characters.</li>

<li><b><code>%s</code>:</b> represents all space characters.</li>

<li><b><code>%u</code>:</b> represents all uppercase letters.</li>

<li><b><code>%w</code>:</b> represents all alphanumeric characters.</li>

<li><b><code>%x</code>:</b> represents all hexadecimal digits.</li>

<li><b><code>%z</code>:</b> represents the character with representation 0.</li>

<li><b><code>%<em>x</em></code>:</b> (where <em>x</em> is any non-alphanumeric character)
represents the character <em>x</em>.
This is the standard way to escape the magic characters.
Any punctuation character (even the non magic)
can be preceded by a '<code>%</code>'
when used to represent itself in a pattern.
</li>

<li><b><code>[<em>set</em>]</code>:</b>
represents the class which is the union of all
characters in <em>set</em>.
A range of characters can be specified by
separating the end characters of the range with a '<code>-</code>'.
All classes <code>%</code><em>x</em> described above can also be used as
components in <em>set</em>.
All other characters in <em>set</em> represent themselves.
For example, <code>[%w_]</code> (or <code>[_%w]</code>)
represents all alphanumeric characters plus the underscore,
<code>[0-7]</code> represents the octal digits,
and <code>[0-7%l%-]</code> represents the octal digits plus
the lowercase letters plus the '<code>-</code>' character.


<p>
The interaction between ranges and classes is not defined.
Therefore, patterns like <code>[%a-z]</code> or <code>[a-%%]</code>
have no meaning.
</li>

<li><b><code>[^<em>set</em>]</code>:</b>
represents the complement of <em>set</em>,
where <em>set</em> is interpreted as above.
</li>

</ul><p>
For all classes represented by single letters (<code>%a</code>, <code>%c</code>, etc.),
the corresponding uppercase letter represents the complement of the class.
For instance, <code>%S</code> represents all non-space characters.


<p>
The definitions of letter, space, and other character groups
depend on the current locale.
In particular, the class <code>[a-z]</code> may not be equivalent to <code>%l</code>.





<h4>Pattern Item:</h4><p>
A <em>pattern item</em> can be

<ul>

<li>
a single character class,
which matches any single character in the class;
</li>

<li>
a single character class followed by '<code>*</code>',
which matches 0 or more repetitions of characters in the class.
These repetition items will always match the longest possible sequence;
</li>

<li>
a single character class followed by '<code>+</code>',
which matches 1 or more repetitions of characters in the class.
These repetition items will always match the longest possible sequence;
</li>

<li>
a single character class followed by '<code>-</code>',
which also matches 0 or more repetitions of characters in the class.
Unlike '<code>*</code>',
these repetition items will always match the <em>shortest</em> possible sequence;
</li>

<li>
a single character class followed by '<code>?</code>',
which matches 0 or 1 occurrence of a character in the class;
</li>

<li>
<code>%<em>n</em></code>, for <em>n</em> between 1 and 9;
such item matches a substring equal to the <em>n</em>-th captured string
(see below);
</li>

<li>
<code>%b<em>xy</em></code>, where <em>x</em> and <em>y</em> are two distinct characters;
such item matches strings that start with&nbsp;<em>x</em>, end with&nbsp;<em>y</em>,
and where the <em>x</em> and <em>y</em> are <em>balanced</em>.
This means that, if one reads the string from left to right,
counting <em>+1</em> for an <em>x</em> and <em>-1</em> for a <em>y</em>,
the ending <em>y</em> is the first <em>y</em> where the count reaches 0.
For instance, the item <code>%b()</code> matches expressions with
balanced parentheses.
</li>

</ul>




<h4>Pattern:</h4><p>
A <em>pattern</em> is a sequence of pattern items.
A '<code>^</code>' at the beginning of a pattern anchors the match at the
beginning of the subject string.
A '<code>$</code>' at the end of a pattern anchors the match at the
end of the subject string.
At other positions,
'<code>^</code>' and '<code>$</code>' have no special meaning and represent themselves.





<h4>Captures:</h4><p>
A pattern can contain sub-patterns enclosed in parentheses;
they describe <em>captures</em>.
When a match succeeds, the substrings of the subject string
that match captures are stored (<em>captured</em>) for future use.
Captures are numbered according to their left parentheses.
For instance, in the pattern <code>"(a*(.)%w(%s*))"</code>,
the part of the string matching <code>"a*(.)%w(%s*)"</code> is
stored as the first capture (and therefore has number&nbsp;1);
the character matching "<code>.</code>" is captured with number&nbsp;2,
and the part matching "<code>%s*</code>" has number&nbsp;3.


<p>
As a special case, the empty capture <code>()</code> captures
the current string position (a number).
For instance, if we apply the pattern <code>"()aa()"</code> on the
string <code>"flaaap"</code>, there will be two captures: 3&nbsp;and&nbsp;5.


<p>
A pattern cannot contain embedded zeros.  Use <code>%z</code> instead.











<h2>5.5 - <a name="5.5">Table Manipulation</a></h2><p>
This library provides generic functions for table manipulation.
It provides all its functions inside the table <a name="pdf-table"><code>table</code></a>.


<p>
Most functions in the table library assume that the table
represents an array or a list.
For these functions, when we talk about the "length" of a table
we mean the result of the length operator.


<p>
<hr><h3><a name="pdf-table.concat"><code>table.concat (table [, sep [, i [, j]]])</code></a></h3>
Given an array where all elements are strings or numbers,
returns <code>table[i]..sep..table[i+1] &middot;&middot;&middot; sep..table[j]</code>.
The default value for <code>sep</code> is the empty string,
the default for <code>i</code> is 1,
and the default for <code>j</code> is the length of the table.
If <code>i</code> is greater than <code>j</code>, returns the empty string.




<p>
<hr><h3><a name="pdf-table.insert"><code>table.insert (table, [pos,] value)</code></a></h3>


<p>
Inserts element <code>value</code> at position <code>pos</code> in <code>table</code>,
shifting up other elements to open space, if necessary.
The default value for <code>pos</code> is <code>n+1</code>,
where <code>n</code> is the length of the table (see <a href="#2.5.5">&sect;2.5.5</a>),
so that a call <code>table.insert(t,x)</code> inserts <code>x</code> at the end
of table <code>t</code>.




<p>
<hr><h3><a name="pdf-table.maxn"><code>table.maxn (table)</code></a></h3>


<p>
Returns the largest positive numerical index of the given table,
or zero if the table has no positive numerical indices.
(To do its job this function does a linear traversal of
the whole table.) 




<p>
<hr><h3><a name="pdf-table.remove"><code>table.remove (table [, pos])</code></a></h3>


<p>
Removes from <code>table</code> the element at position <code>pos</code>,
shifting down other elements to close the space, if necessary.
Returns the value of the removed element.
The default value for <code>pos</code> is <code>n</code>,
where <code>n</code> is the length of the table,
so that a call <code>table.remove(t)</code> removes the last element
of table <code>t</code>.




<p>
<hr><h3><a name="pdf-table.sort"><code>table.sort (table [, comp])</code></a></h3>
Sorts table elements in a given order, <em>in-place</em>,
from <code>table[1]</code> to <code>table[n]</code>,
where <code>n</code> is the length of the table.
If <code>comp</code> is given,
then it must be a function that receives two table elements,
and returns true
when the first is less than the second
(so that <code>not comp(a[i+1],a[i])</code> will be true after the sort).
If <code>comp</code> is not given,
then the standard Lua operator <code>&lt;</code> is used instead.


<p>
The sort algorithm is not stable;
that is, elements considered equal by the given order
may have their relative positions changed by the sort.







<h2>5.6 - <a name="5.6">Mathematical Functions</a></h2>

<p>
This library is an interface to the standard C&nbsp;math library.
It provides all its functions inside the table <a name="pdf-math"><code>math</code></a>.


<p>
<hr><h3><a name="pdf-math.abs"><code>math.abs (x)</code></a></h3>


<p>
Returns the absolute value of <code>x</code>.




<p>
<hr><h3><a name="pdf-math.acos"><code>math.acos (x)</code></a></h3>


<p>
Returns the arc cosine of <code>x</code> (in radians).




<p>
<hr><h3><a name="pdf-math.asin"><code>math.asin (x)</code></a></h3>


<p>
Returns the arc sine of <code>x</code> (in radians).




<p>
<hr><h3><a name="pdf-math.atan"><code>math.atan (x)</code></a></h3>


<p>
Returns the arc tangent of <code>x</code> (in radians).




<p>
<hr><h3><a name="pdf-math.atan2"><code>math.atan2 (y, x)</code></a></h3>


<p>
Returns the arc tangent of <code>y/x</code> (in radians),
but uses the signs of both parameters to find the
quadrant of the result.
(It also handles correctly the case of <code>x</code> being zero.)




<p>
<hr><h3><a name="pdf-math.ceil"><code>math.ceil (x)</code></a></h3>


<p>
Returns the smallest integer larger than or equal to <code>x</code>.




<p>
<hr><h3><a name="pdf-math.cos"><code>math.cos (x)</code></a></h3>


<p>
Returns the cosine of <code>x</code> (assumed to be in radians).




<p>
<hr><h3><a name="pdf-math.cosh"><code>math.cosh (x)</code></a></h3>


<p>
Returns the hyperbolic cosine of <code>x</code>.




<p>
<hr><h3><a name="pdf-math.deg"><code>math.deg (x)</code></a></h3>


<p>
Returns the angle <code>x</code> (given in radians) in degrees.




<p>
<hr><h3><a name="pdf-math.exp"><code>math.exp (x)</code></a></h3>


<p>
Returns the value <em>e<sup>x</sup></em>.




<p>
<hr><h3><a name="pdf-math.floor"><code>math.floor (x)</code></a></h3>


<p>
Returns the largest integer smaller than or equal to <code>x</code>.




<p>
<hr><h3><a name="pdf-math.fmod"><code>math.fmod (x, y)</code></a></h3>


<p>
Returns the remainder of the division of <code>x</code> by <code>y</code>
that rounds the quotient towards zero.




<p>
<hr><h3><a name="pdf-math.frexp"><code>math.frexp (x)</code></a></h3>


<p>
Returns <code>m</code> and <code>e</code> such that <em>x = m2<sup>e</sup></em>,
<code>e</code> is an integer and the absolute value of <code>m</code> is
in the range <em>[0.5, 1)</em>
(or zero when <code>x</code> is zero).




<p>
<hr><h3><a name="pdf-math.huge"><code>math.huge</code></a></h3>


<p>
The value <code>HUGE_VAL</code>,
a value larger than or equal to any other numerical value.




<p>
<hr><h3><a name="pdf-math.ldexp"><code>math.ldexp (m, e)</code></a></h3>


<p>
Returns <em>m2<sup>e</sup></em> (<code>e</code> should be an integer).




<p>
<hr><h3><a name="pdf-math.log"><code>math.log (x)</code></a></h3>


<p>
Returns the natural logarithm of <code>x</code>.




<p>
<hr><h3><a name="pdf-math.log10"><code>math.log10 (x)</code></a></h3>


<p>
Returns the base-10 logarithm of <code>x</code>.




<p>
<hr><h3><a name="pdf-math.max"><code>math.max (x, &middot;&middot;&middot;)</code></a></h3>


<p>
Returns the maximum value among its arguments.




<p>
<hr><h3><a name="pdf-math.min"><code>math.min (x, &middot;&middot;&middot;)</code></a></h3>


<p>
Returns the minimum value among its arguments.




<p>
<hr><h3><a name="pdf-math.modf"><code>math.modf (x)</code></a></h3>


<p>
Returns two numbers,
the integral part of <code>x</code> and the fractional part of <code>x</code>.




<p>
<hr><h3><a name="pdf-math.pi"><code>math.pi</code></a></h3>


<p>
The value of <em>pi</em>.




<p>
<hr><h3><a name="pdf-math.pow"><code>math.pow (x, y)</code></a></h3>


<p>
Returns <em>x<sup>y</sup></em>.
(You can also use the expression <code>x^y</code> to compute this value.)




<p>
<hr><h3><a name="pdf-math.rad"><code>math.rad (x)</code></a></h3>


<p>
Returns the angle <code>x</code> (given in degrees) in radians.




<p>
<hr><h3><a name="pdf-math.random"><code>math.random ([m [, n]])</code></a></h3>


<p>
This function is an interface to the simple
pseudo-random generator function <code>rand</code> provided by ANSI&nbsp;C.
(No guarantees can be given for its statistical properties.)


<p>
When called without arguments,
returns a uniform pseudo-random real number
in the range <em>[0,1)</em>.  
When called with an integer number <code>m</code>,
<code>math.random</code> returns
a uniform pseudo-random integer in the range <em>[1, m]</em>.
When called with two integer numbers <code>m</code> and <code>n</code>,
<code>math.random</code> returns a uniform pseudo-random
integer in the range <em>[m, n]</em>.




<p>
<hr><h3><a name="pdf-math.randomseed"><code>math.randomseed (x)</code></a></h3>


<p>
Sets <code>x</code> as the "seed"
for the pseudo-random generator:
equal seeds produce equal sequences of numbers.




<p>
<hr><h3><a name="pdf-math.sin"><code>math.sin (x)</code></a></h3>


<p>
Returns the sine of <code>x</code> (assumed to be in radians).




<p>
<hr><h3><a name="pdf-math.sinh"><code>math.sinh (x)</code></a></h3>


<p>
Returns the hyperbolic sine of <code>x</code>.




<p>
<hr><h3><a name="pdf-math.sqrt"><code>math.sqrt (x)</code></a></h3>


<p>
Returns the square root of <code>x</code>.
(You can also use the expression <code>x^0.5</code> to compute this value.)




<p>
<hr><h3><a name="pdf-math.tan"><code>math.tan (x)</code></a></h3>


<p>
Returns the tangent of <code>x</code> (assumed to be in radians).




<p>
<hr><h3><a name="pdf-math.tanh"><code>math.tanh (x)</code></a></h3>


<p>
Returns the hyperbolic tangent of <code>x</code>.







<h2>5.7 - <a name="5.7">File Input and Output Facilities</a></h2>

<div class='teliva'>
While Teliva supports the standard Lua primitives for managing files via
handles, idiomatic Teliva uses some slightly different primitives that use a
subtly different file object (name tbd).

<p>
<hr><h3><a name="pdf-start_reading"><code>start_reading (fs, filename)</code></a></h3>

<p>
This function opens a file exclusively for reading, and returns an object (NOT
a file handle as in Lua) or <b>nil</b> on error. If the returned object is
stored in variable <code>f</code>, <code>f.read(format)</code> will read from
the file. Legal values for <code>format</code> are identical to
<a href='#pdf-file:read'><code>file:read(format)</code></a>.

<p>
(The <code>fs</code> parameter is currently unused. It will be used to pass in
fake file systems for tests.)


<p>
<hr><h3><a name="pdf-start_writing"><code>start_writing(fs, filename)</code></a></h3>

<p>
This function opens a file exclusively for writing, and returns an object (NOT
a file handle as in Lua) or <b>nil</b> on error. If the result is stored in
variable <code>f</code>, <code>f.write(x)</code> will write <code>x</code> to
the file. <code>f.close()</code> will persist the changes and make them
externally visible. All changes will be hidden until <code>f.close()</code>.

<p>
(The <code>fs</code> parameter is currently unused. It will be used to pass in
fake file systems for tests.)


<hr>
The rest of this section describes Lua's standard primitives for File I/O.
</div>


<p>
Unless otherwise stated,
all File I/O functions return <b>nil</b> on failure
(plus an error message as a second result and
a system-dependent error code as a third result)
and some value different from <b>nil</b> on success.


<p>
<hr><h3><a name="pdf-io.close"><code>io.close (file)</code></a></h3>


<p>
Equivalent to <code>file:close()</code>.



<p>
<hr><h3><a name="pdf-io.open"><code>io.open (filename [, mode])</code></a></h3>


<p>
This function opens a file,
in the mode specified in the string <code>mode</code>.
It returns a new file handle,
or, in case of errors, <b>nil</b> plus an error message.


<p>
The <code>mode</code> string can be any of the following:

<ul>
<li><b>"r":</b> read mode (the default);</li>
<li><b>"w":</b> write mode;</li>
<li><b>"a":</b> append mode;</li>
<li><b>"r+":</b> update mode, all previous data is preserved;</li>
<li><b>"w+":</b> update mode, all previous data is erased;</li>
<li><b>"a+":</b> append update mode, previous data is preserved,
  writing is only allowed at the end of file.</li>
</ul><p>
The <code>mode</code> string can also have a '<code>b</code>' at the end,
which is needed in some systems to open the file in binary mode.
This string is exactly what is used in the
standard&nbsp;C function <code>fopen</code>.

<div class='teliva'>
<em>This function is sandboxed. It may fail if the computer owner's
permissions disallow it.</em>
</div>



<p>
<hr><h3><a name="pdf-io.tmpfile"><code>io.tmpfile ()</code></a></h3>


<p>
Returns a handle for a temporary file.
This file is opened in update mode
and it is automatically removed when the program ends.




<p>
<hr><h3><a name="pdf-io.type"><code>io.type (obj)</code></a></h3>


<p>
Checks whether <code>obj</code> is a valid file handle.
Returns the string <code>"file"</code> if <code>obj</code> is an open file handle,
<code>"closed file"</code> if <code>obj</code> is a closed file handle,
or <b>nil</b> if <code>obj</code> is not a file handle.




<p>
<hr><h3><a name="pdf-file:close"><code>file:close ()</code></a></h3>


<p>
Closes <code>file</code>.
Note that files are automatically closed when
their handles are garbage collected,
but that takes an unpredictable amount of time to happen.




<p>
<hr><h3><a name="pdf-file:flush"><code>file:flush ()</code></a></h3>


<p>
Saves any written data to <code>file</code>.




<p>
<hr><h3><a name="pdf-file:lines"><code>file:lines ()</code></a></h3>


<p>
Returns an iterator function that,
each time it is called,
returns a new line from the file.
Therefore, the construction

<pre>
     for line in file:lines() do <em>body</em> end
</pre><p>
will iterate over all lines of the file.
(Unlike <a href="#pdf-io.lines"><code>io.lines</code></a>, this function does not close the file
when the loop ends.)




<p>
<hr><h3><a name="pdf-file:read"><code>file:read (&middot;&middot;&middot;)</code></a></h3>


<p>
Reads the file <code>file</code>,
according to the given formats, which specify what to read.
For each format,
the function returns a string (or a number) with the characters read,
or <b>nil</b> if it cannot read data with the specified format.
When called without formats,
it uses a default format that reads the entire next line
(see below).


<p>
The available formats are

<ul>

<li><b>"*n":</b>
reads a number;
this is the only format that returns a number instead of a string.
</li>

<li><b>"*a":</b>
reads the whole file, starting at the current position.
On end of file, it returns the empty string.
</li>

<li><b>"*l":</b>
reads the next line (skipping the end of line),
returning <b>nil</b> on end of file.
This is the default format.
</li>

<li><b><em>number</em>:</b>
reads a string with up to this number of characters,
returning <b>nil</b> on end of file.
If number is zero,
it reads nothing and returns an empty string,
or <b>nil</b> on end of file.
</li>

</ul>



<p>
<hr><h3><a name="pdf-file:seek"><code>file:seek ([whence] [, offset])</code></a></h3>


<p>
Sets and gets the file position,
measured from the beginning of the file,
to the position given by <code>offset</code> plus a base
specified by the string <code>whence</code>, as follows:

<ul>
<li><b>"set":</b> base is position 0 (beginning of the file);</li>
<li><b>"cur":</b> base is current position;</li>
<li><b>"end":</b> base is end of file;</li>
</ul><p>
In case of success, function <code>seek</code> returns the final file position,
measured in bytes from the beginning of the file.
If this function fails, it returns <b>nil</b>,
plus a string describing the error.


<p>
The default value for <code>whence</code> is <code>"cur"</code>,
and for <code>offset</code> is 0.
Therefore, the call <code>file:seek()</code> returns the current
file position, without changing it;
the call <code>file:seek("set")</code> sets the position to the
beginning of the file (and returns 0);
and the call <code>file:seek("end")</code> sets the position to the
end of the file, and returns its size.




<p>
<hr><h3><a name="pdf-file:setvbuf"><code>file:setvbuf (mode [, size])</code></a></h3>


<p>
Sets the buffering mode for an output file.
There are three available modes:

<ul>

<li><b>"no":</b>
no buffering; the result of any output operation appears immediately.
</li>

<li><b>"full":</b>
full buffering; output operation is performed only
when the buffer is full (or when you explicitly <code>flush</code> the file
(see <a href="#pdf-io.flush"><code>io.flush</code></a>)).
</li>

<li><
Download .txt
gitextract_eymj815d/

├── .gitattributes
├── .gitignore
├── COPYRIGHT.md
├── Makefile
├── README.md
├── anagrams.tlv
├── break.tlv
├── chesstv.tlv
├── counter.tlv
├── doc/
│   ├── contents.html
│   ├── lua.css
│   ├── manual.css
│   └── manual.html
├── gemini.tlv
├── graphviz.tlv
├── hanoi.tlv
├── life.tlv
├── lisp.lua
├── lisp.tlv
├── manual_tests
├── sandboxing/
│   ├── README.md
│   ├── includes
│   ├── system_includes
│   └── unique_system_includes
├── shell.nix
├── sieve.tlv
├── smol.tlv
├── src/
│   ├── Makefile
│   ├── file.lua
│   ├── json.lua
│   ├── jsonf.lua
│   ├── kilo.c
│   ├── lapi.c
│   ├── lapi.h
│   ├── lauxlib.c
│   ├── lauxlib.h
│   ├── lbaselib.c
│   ├── lcode.c
│   ├── lcode.h
│   ├── lcurses/
│   │   ├── Makefile
│   │   ├── _helpers.c
│   │   ├── chstr.c
│   │   ├── compat-5.2.c
│   │   ├── compat-5.2.h
│   │   ├── curses.c
│   │   ├── curses.lua
│   │   ├── strlcpy.c
│   │   └── window.c
│   ├── ldebug.c
│   ├── ldebug.h
│   ├── ldo.c
│   ├── ldo.h
│   ├── ldump.c
│   ├── lfunc.c
│   ├── lfunc.h
│   ├── lgc.c
│   ├── lgc.h
│   ├── linit.c
│   ├── liolib.c
│   ├── llex.c
│   ├── llex.h
│   ├── llimits.h
│   ├── lmathlib.c
│   ├── lmem.c
│   ├── lmem.h
│   ├── lobject.c
│   ├── lobject.h
│   ├── lopcodes.c
│   ├── lopcodes.h
│   ├── loslib.c
│   ├── lparser.c
│   ├── lparser.h
│   ├── lstate.c
│   ├── lstate.h
│   ├── lstring.c
│   ├── lstring.h
│   ├── lstrlib.c
│   ├── ltable.c
│   ├── ltable.h
│   ├── ltablib.c
│   ├── ltm.c
│   ├── ltm.h
│   ├── lua.c
│   ├── lua.h
│   ├── luaconf.h
│   ├── lualib.h
│   ├── luasec/
│   │   ├── Makefile
│   │   ├── compat.h
│   │   ├── config.c
│   │   ├── context.c
│   │   ├── context.h
│   │   ├── ec.c
│   │   ├── ec.h
│   │   ├── https.lua
│   │   ├── options.c
│   │   ├── options.h
│   │   ├── options.lua
│   │   ├── ssl.c
│   │   ├── ssl.h
│   │   ├── ssl.lua
│   │   ├── x509.c
│   │   └── x509.h
│   ├── luasocket/
│   │   ├── auxiliar.c
│   │   ├── auxiliar.h
│   │   ├── buffer.c
│   │   ├── buffer.h
│   │   ├── compat.c
│   │   ├── compat.h
│   │   ├── except.c
│   │   ├── except.h
│   │   ├── ftp.lua
│   │   ├── headers.lua
│   │   ├── http.lua
│   │   ├── inet.c
│   │   ├── inet.h
│   │   ├── io.c
│   │   ├── io.h
│   │   ├── ltn12.lua
│   │   ├── luasocket.c
│   │   ├── luasocket.h
│   │   ├── makefile
│   │   ├── mbox.lua
│   │   ├── mime.c
│   │   ├── mime.h
│   │   ├── mime.lua
│   │   ├── options.c
│   │   ├── options.h
│   │   ├── pierror.h
│   │   ├── select.c
│   │   ├── select.h
│   │   ├── serial.c
│   │   ├── smtp.lua
│   │   ├── socket.h
│   │   ├── socket.lua
│   │   ├── tcp.c
│   │   ├── tcp.h
│   │   ├── timeout.c
│   │   ├── timeout.h
│   │   ├── tp.lua
│   │   ├── udp.c
│   │   ├── udp.h
│   │   ├── unix.c
│   │   ├── unix.h
│   │   ├── unixdgram.c
│   │   ├── unixdgram.h
│   │   ├── unixstream.c
│   │   ├── unixstream.h
│   │   ├── url.lua
│   │   ├── usocket.c
│   │   ├── usocket.h
│   │   ├── wsocket.c
│   │   └── wsocket.h
│   ├── lundump.c
│   ├── lundump.h
│   ├── lvm.c
│   ├── lvm.h
│   ├── lzio.c
│   ├── lzio.h
│   ├── realpath.c
│   ├── task.lua
│   ├── teliva.c
│   ├── teliva.h
│   ├── tlv.c
│   ├── tlv.h
│   └── vimrc.vim
├── template.tlv
├── toot-toot.tlv
├── tour.md
└── zet.tlv
Download .txt
SYMBOL INDEX (1467 symbols across 89 files)

FILE: src/kilo.c
  type editorSyntax (line 69) | struct editorSyntax {
  type erow (line 79) | typedef struct erow {
  type hlcolor (line 90) | typedef struct hlcolor {
  type editorConfig (line 98) | struct editorConfig {
  type editorConfig (line 111) | struct editorConfig
  type editorSyntax (line 147) | struct editorSyntax
  type editorSyntax (line 155) | struct editorSyntax
  function is_separator (line 166) | static int is_separator(int c) {
  function editorRowHasOpenComment (line 173) | static int editorRowHasOpenComment(erow *row, char *mce) {
  function editorUpdateSyntax (line 181) | static void editorUpdateSyntax(erow *row) {
  function editorSyntaxToColorPair (line 350) | static int editorSyntaxToColorPair(int hl) {
  function editorUpdateRow (line 368) | static void editorUpdateRow(erow *row) {
  function editorInsertRow (line 404) | static void editorInsertRow(int at, char *s, size_t len) {
  function editorFreeRow (line 425) | static void editorFreeRow(erow *row) {
  function editorDelRow (line 432) | static void editorDelRow(int at) {
  function clearEditor (line 444) | void clearEditor(void) {
  function editorRowInsertChar (line 479) | static void editorRowInsertChar(erow *row, int at, int c) {
  function editorRowAppendString (line 502) | static void editorRowAppendString(erow *row, char *s, size_t len) {
  function editorRowDelChar (line 512) | static void editorRowDelChar(erow *row, int at) {
  function editorInsertChar (line 521) | static void editorInsertChar(int c) {
  function editorInsertNewline (line 543) | static void editorInsertNewline(void) {
  function editorDelChar (line 579) | static void editorDelChar() {
  function editorUncommentCursorRow (line 613) | static void editorUncommentCursorRow() {
  function editorCommentCursorRow (line 624) | static void editorCommentCursorRow() {
  function editorOpen (line 636) | int editorOpen(char *filename) {
  function editorSaveToDisk (line 669) | static int editorSaveToDisk(void) {
  function editorMenu (line 698) | static void editorMenu(void) {
  function editorFindMenu (line 733) | static void editorFindMenu(void) {
  function editorGoMenu (line 758) | static void editorGoMenu(void) {
  function editorRefreshScreen (line 771) | static void editorRefreshScreen(void (*menu_func)(void)) {
  function editorFind (line 861) | static void editorFind() {
  function editorAtStartOfLine (line 959) | static int editorAtStartOfLine() {
  function editorMoveCursor (line 964) | static void editorMoveCursor(int key) {
  function identifier_char (line 1037) | static int identifier_char(char c) {
  function word_at_cursor (line 1042) | static void word_at_cursor(char* out, int capacity) {
  function editorGo (line 1068) | static void editorGo(lua_State* L) {
  function editorProcessKeypress2 (line 1120) | static void editorProcessKeypress2(int c) {
  function editorProcessKeypress (line 1212) | static void editorProcessKeypress(lua_State* L) {
  function initEditor (line 1232) | static void initEditor(void) {
  function edit (line 1244) | int edit(lua_State* L, char* filename, char* definition_name) {
  function editProse (line 1269) | int editProse(lua_State* L, char* filename) {
  function editorNonCodeMenu (line 1289) | static void editorNonCodeMenu(void) {
  function editNonCode (line 1322) | void editNonCode(char* filename) {
  function editFilePermissions (line 1342) | void editFilePermissions(char* filename) {
  function editFrom (line 1370) | int editFrom(lua_State* L, char* filename, char* definition_name, int ro...
  function editProseFrom (line 1399) | int editProseFrom(lua_State* L, char* filename, int rowoff, int coloff, ...
  function resumeEdit (line 1423) | int resumeEdit(lua_State* L) {
  function resumeNonCodeEdit (line 1441) | void resumeNonCodeEdit() {
  function resumeFilePermissionsEdit (line 1456) | void resumeFilePermissionsEdit() {

FILE: src/lapi.c
  function TValue (line 49) | static TValue *index2adr (lua_State *L, int idx) {
  function Table (line 79) | static Table *getcurrenv (lua_State *L) {
  function luaA_pushobject (line 89) | void luaA_pushobject (lua_State *L, const TValue *o) {
  function LUA_API (line 95) | LUA_API int lua_checkstack (lua_State *L, int size) {
  function LUA_API (line 110) | LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
  function LUA_API (line 125) | LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
  function LUA_API (line 130) | LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
  function LUA_API (line 140) | LUA_API lua_State *lua_newthread (lua_State *L) {
  function LUA_API (line 158) | LUA_API int lua_gettop (lua_State *L) {
  function LUA_API (line 163) | LUA_API void lua_settop (lua_State *L, int idx) {
  function LUA_API (line 179) | LUA_API void lua_remove (lua_State *L, int idx) {
  function LUA_API (line 190) | LUA_API void lua_insert (lua_State *L, int idx) {
  function LUA_API (line 202) | LUA_API void lua_replace (lua_State *L, int idx) {
  function LUA_API (line 227) | LUA_API void lua_pushvalue (lua_State *L, int idx) {
  function LUA_API (line 241) | LUA_API int lua_type (lua_State *L, int idx) {
  function LUA_API (line 247) | LUA_API const char *lua_typename (lua_State *L, int t) {
  function LUA_API (line 253) | LUA_API int lua_iscfunction (lua_State *L, int idx) {
  function LUA_API (line 259) | LUA_API int lua_isnumber (lua_State *L, int idx) {
  function LUA_API (line 266) | LUA_API int lua_isstring (lua_State *L, int idx) {
  function LUA_API (line 272) | LUA_API int lua_isuserdata (lua_State *L, int idx) {
  function LUA_API (line 278) | LUA_API int lua_rawequal (lua_State *L, int index1, int index2) {
  function LUA_API (line 286) | LUA_API int lua_equal (lua_State *L, int index1, int index2) {
  function LUA_API (line 298) | LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
  function LUA_API (line 312) | LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
  function LUA_API (line 322) | LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
  function LUA_API (line 336) | LUA_API int lua_toboolean (lua_State *L, int idx) {
  function LUA_API (line 342) | LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
  function LUA_API (line 360) | LUA_API size_t lua_objlen (lua_State *L, int idx) {
  function LUA_API (line 378) | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
  function LUA_API (line 384) | LUA_API void *lua_touserdata (lua_State *L, int idx) {
  function LUA_API (line 394) | LUA_API lua_State *lua_tothread (lua_State *L, int idx) {
  function LUA_API (line 400) | LUA_API const void *lua_topointer (lua_State *L, int idx) {
  function LUA_API (line 420) | LUA_API void lua_pushnil (lua_State *L) {
  function LUA_API (line 428) | LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
  function LUA_API (line 436) | LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
  function LUA_API (line 444) | LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
  function LUA_API (line 453) | LUA_API void lua_pushstring (lua_State *L, const char *s) {
  function LUA_API (line 461) | LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
  function LUA_API (line 472) | LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
  function LUA_API (line 485) | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
  function LUA_API (line 502) | LUA_API void lua_pushboolean (lua_State *L, int b) {
  function LUA_API (line 510) | LUA_API void lua_pushlightuserdata (lua_State *L, void *p) {
  function LUA_API (line 518) | LUA_API int lua_pushthread (lua_State *L) {
  function LUA_API (line 533) | LUA_API void lua_gettable (lua_State *L, int idx) {
  function LUA_API (line 543) | LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
  function LUA_API (line 556) | LUA_API void lua_rawget (lua_State *L, int idx) {
  function LUA_API (line 566) | LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
  function LUA_API (line 577) | LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
  function LUA_API (line 586) | LUA_API int lua_getmetatable (lua_State *L, int objindex) {
  function LUA_API (line 615) | LUA_API void lua_getfenv (lua_State *L, int idx) {
  function LUA_API (line 644) | LUA_API void lua_settable (lua_State *L, int idx) {
  function LUA_API (line 656) | LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
  function LUA_API (line 670) | LUA_API void lua_rawset (lua_State *L, int idx) {
  function LUA_API (line 683) | LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
  function LUA_API (line 696) | LUA_API int lua_setmetatable (lua_State *L, int objindex) {
  function LUA_API (line 733) | LUA_API int lua_setfenv (lua_State *L, int idx) {
  function LUA_API (line 775) | LUA_API void lua_call (lua_State *L, int nargs, int nresults) {
  type CallS (line 791) | struct CallS {  /* data to `f_call' */
  function f_call (line 797) | static void f_call (lua_State *L, void *ud) {
  function LUA_API (line 804) | LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfun...
  type CCallS (line 830) | struct CCallS {  /* data to `f_Ccall' */
  function f_Ccall (line 836) | static void f_Ccall (lua_State *L, void *ud) {
  function LUA_API (line 849) | LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) {
  function LUA_API (line 861) | LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
  function LUA_API (line 874) | LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
  function LUA_API (line 889) | LUA_API int  lua_status (lua_State *L) {
  function LUA_API (line 898) | LUA_API int lua_gc (lua_State *L, int what, int data) {
  function LUA_API (line 963) | LUA_API int lua_error (lua_State *L) {
  function LUA_API (line 972) | LUA_API int lua_next (lua_State *L, int idx) {
  function LUA_API (line 989) | LUA_API void lua_concat (lua_State *L, int n) {
  function LUA_API (line 1006) | LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) {
  function LUA_API (line 1016) | LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
  function LUA_API (line 1024) | LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
  function LUA_API (line 1056) | LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
  function LUA_API (line 1070) | LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {

FILE: src/lauxlib.c
  function LUALIB_API (line 43) | LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extram...
  function LUALIB_API (line 61) | LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
  function tag_error (line 68) | static void tag_error (lua_State *L, int narg, int tag) {
  function LUALIB_API (line 73) | LUALIB_API void luaL_where (lua_State *L, int level) {
  function LUALIB_API (line 86) | LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
  function LUALIB_API (line 99) | LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
  function LUALIB_API (line 112) | LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
  function LUALIB_API (line 124) | LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tnam...
  function LUALIB_API (line 140) | LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *me...
  function LUALIB_API (line 146) | LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) {
  function LUALIB_API (line 152) | LUALIB_API void luaL_checkany (lua_State *L, int narg) {
  function LUALIB_API (line 158) | LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t...
  function LUALIB_API (line 165) | LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
  function LUALIB_API (line 176) | LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
  function LUALIB_API (line 184) | LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number...
  function LUALIB_API (line 189) | LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
  function LUALIB_API (line 197) | LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg,
  function LUALIB_API (line 203) | LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *eve...
  function LUALIB_API (line 219) | LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) {
  function LUALIB_API (line 229) | LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
  function libsize (line 235) | static int libsize (const luaL_Reg *l) {
  function LUALIB_API (line 242) | LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
  function checkint (line 280) | static int checkint (lua_State *L, int topop) {
  function getsizes (line 287) | static void getsizes (lua_State *L) {
  function LUALIB_API (line 302) | LUALIB_API void luaL_setn (lua_State *L, int t, int n) {
  function LUALIB_API (line 321) | LUALIB_API int luaL_getn (lua_State *L, int t) {
  function LUALIB_API (line 340) | LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const cha...
  function LUALIB_API (line 357) | LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
  function emptybuffer (line 398) | static int emptybuffer (luaL_Buffer *B) {
  function adjuststack (line 410) | static void adjuststack (luaL_Buffer *B) {
  function LUALIB_API (line 429) | LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
  function LUALIB_API (line 436) | LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
  function LUALIB_API (line 442) | LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
  function LUALIB_API (line 447) | LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
  function LUALIB_API (line 454) | LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
  function LUALIB_API (line 472) | LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
  function LUALIB_API (line 481) | LUALIB_API int luaL_ref (lua_State *L, int t) {
  function LUALIB_API (line 504) | LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {
  type LoadF (line 522) | typedef struct LoadF {
  function errfile (line 543) | static int errfile (lua_State *L, const char *what, int fnameindex) {
  function LUALIB_API (line 552) | LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
  type LoadS (line 593) | typedef struct LoadS {
  function LUALIB_API (line 609) | LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t s...
  function LUALIB_API (line 618) | LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) {
  function panic (line 639) | static int panic (lua_State *L) {
  function LUALIB_API (line 647) | LUALIB_API lua_State *luaL_newstate (void) {

FILE: src/lauxlib.h
  type luaL_Reg (line 35) | typedef struct luaL_Reg {
  type luaL_Buffer (line 129) | typedef struct luaL_Buffer {

FILE: src/lbaselib.c
  function luaB_print (line 30) | static int luaB_print (lua_State *L) {
  function luaB_tonumber (line 54) | static int luaB_tonumber (lua_State *L) {
  function luaB_error (line 82) | static int luaB_error (lua_State *L) {
  function luaB_getmetatable (line 94) | static int luaB_getmetatable (lua_State *L) {
  function luaB_setmetatable (line 105) | static int luaB_setmetatable (lua_State *L) {
  function getfunc (line 118) | static void getfunc (lua_State *L, int opt) {
  function luaB_getfenv (line 134) | static int luaB_getfenv (lua_State *L) {
  function luaB_setfenv (line 144) | static int luaB_setfenv (lua_State *L) {
  function luaB_rawequal (line 162) | static int luaB_rawequal (lua_State *L) {
  function luaB_rawget (line 170) | static int luaB_rawget (lua_State *L) {
  function luaB_rawset (line 178) | static int luaB_rawset (lua_State *L) {
  function luaB_gcinfo (line 188) | static int luaB_gcinfo (lua_State *L) {
  function luaB_collectgarbage (line 194) | static int luaB_collectgarbage (lua_State *L) {
  function luaB_type (line 220) | static int luaB_type (lua_State *L) {
  function luaB_next (line 227) | static int luaB_next (lua_State *L) {
  function luaB_pairs (line 239) | static int luaB_pairs (lua_State *L) {
  function ipairsaux (line 248) | static int ipairsaux (lua_State *L) {
  function luaB_ipairs (line 258) | static int luaB_ipairs (lua_State *L) {
  function luaB_assert (line 267) | static int luaB_assert (lua_State *L) {
  function luaB_unpack (line 275) | static int luaB_unpack (lua_State *L) {
  function luaB_select (line 291) | static int luaB_select (lua_State *L) {
  function luaB_pcall (line 307) | static int luaB_pcall (lua_State *L) {
  function luaB_xpcall (line 317) | static int luaB_xpcall (lua_State *L) {
  function luaB_tostring (line 329) | static int luaB_tostring (lua_State *L) {
  function luaB_newproxy (line 354) | static int luaB_newproxy (lua_State *L) {
  function costatus (line 423) | static int costatus (lua_State *L, lua_State *co) {
  function luaB_costatus (line 443) | static int luaB_costatus (lua_State *L) {
  function auxresume (line 451) | static int auxresume (lua_State *L, lua_State *co, int narg) {
  function luaB_coresume (line 476) | static int luaB_coresume (lua_State *L) {
  function luaB_auxwrap (line 494) | static int luaB_auxwrap (lua_State *L) {
  function luaB_cocreate (line 509) | static int luaB_cocreate (lua_State *L) {
  function luaB_cowrap (line 519) | static int luaB_cowrap (lua_State *L) {
  function luaB_yield (line 526) | static int luaB_yield (lua_State *L) {
  function luaB_corunning (line 531) | static int luaB_corunning (lua_State *L) {
  function auxopen (line 551) | static void auxopen (lua_State *L, const char *name,
  function base_open (line 559) | static void base_open (lua_State *L) {
  function LUALIB_API (line 581) | LUALIB_API int luaopen_base (lua_State *L) {

FILE: src/lcode.c
  function isnumeral (line 30) | static int isnumeral(expdesc *e) {
  function luaK_nil (line 35) | void luaK_nil (FuncState *fs, int from, int n) {
  function luaK_jump (line 59) | int luaK_jump (FuncState *fs) {
  function luaK_ret (line 69) | void luaK_ret (FuncState *fs, int first, int nret) {
  function condjump (line 74) | static int condjump (FuncState *fs, OpCode op, int A, int B, int C) {
  function fixjump (line 80) | static void fixjump (FuncState *fs, int pc, int dest) {
  function luaK_getlabel (line 94) | int luaK_getlabel (FuncState *fs) {
  function getjump (line 100) | static int getjump (FuncState *fs, int pc) {
  function Instruction (line 109) | static Instruction *getjumpcontrol (FuncState *fs, int pc) {
  function need_value (line 122) | static int need_value (FuncState *fs, int list) {
  function patchtestreg (line 131) | static int patchtestreg (FuncState *fs, int node, int reg) {
  function removevalues (line 144) | static void removevalues (FuncState *fs, int list) {
  function patchlistaux (line 150) | static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
  function dischargejpc (line 163) | static void dischargejpc (FuncState *fs) {
  function luaK_patchlist (line 169) | void luaK_patchlist (FuncState *fs, int list, int target) {
  function luaK_patchtohere (line 179) | void luaK_patchtohere (FuncState *fs, int list) {
  function luaK_concat (line 185) | void luaK_concat (FuncState *fs, int *l1, int l2) {
  function luaK_checkstack (line 199) | void luaK_checkstack (FuncState *fs, int n) {
  function luaK_reserveregs (line 209) | void luaK_reserveregs (FuncState *fs, int n) {
  function freereg (line 215) | static void freereg (FuncState *fs, int reg) {
  function freeexp (line 223) | static void freeexp (FuncState *fs, expdesc *e) {
  function addk (line 229) | static int addk (FuncState *fs, TValue *k, TValue *v) {
  function luaK_stringK (line 250) | int luaK_stringK (FuncState *fs, TString *s) {
  function luaK_numberK (line 257) | int luaK_numberK (FuncState *fs, lua_Number r) {
  function boolK (line 264) | static int boolK (FuncState *fs, int b) {
  function nilK (line 271) | static int nilK (FuncState *fs) {
  function luaK_setreturns (line 280) | void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
  function luaK_setoneret (line 292) | void luaK_setoneret (FuncState *fs, expdesc *e) {
  function luaK_dischargevars (line 304) | void luaK_dischargevars (FuncState *fs, expdesc *e) {
  function code_label (line 337) | static int code_label (FuncState *fs, int A, int b, int jump) {
  function discharge2reg (line 343) | static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
  function discharge2anyreg (line 382) | static void discharge2anyreg (FuncState *fs, expdesc *e) {
  function exp2reg (line 390) | static void exp2reg (FuncState *fs, expdesc *e, int reg) {
  function luaK_exp2nextreg (line 414) | void luaK_exp2nextreg (FuncState *fs, expdesc *e) {
  function luaK_exp2anyreg (line 422) | int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
  function luaK_exp2val (line 436) | void luaK_exp2val (FuncState *fs, expdesc *e) {
  function luaK_exp2RK (line 444) | int luaK_exp2RK (FuncState *fs, expdesc *e) {
  function luaK_storevar (line 472) | void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
  function luaK_self (line 503) | void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
  function invertjump (line 516) | static void invertjump (FuncState *fs, expdesc *e) {
  function jumponcond (line 524) | static int jumponcond (FuncState *fs, expdesc *e, int cond) {
  function luaK_goiftrue (line 539) | void luaK_goiftrue (FuncState *fs, expdesc *e) {
  function luaK_goiffalse (line 563) | static void luaK_goiffalse (FuncState *fs, expdesc *e) {
  function codenot (line 586) | static void codenot (FuncState *fs, expdesc *e) {
  function luaK_indexed (line 621) | void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
  function constfolding (line 627) | static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
  function codearith (line 653) | static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e...
  function codecomp (line 673) | static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
  function luaK_prefix (line 689) | void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
  function luaK_infix (line 710) | void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
  function luaK_posfix (line 737) | void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
  function luaK_fixline (line 784) | void luaK_fixline (FuncState *fs, int line) {
  function luaK_code (line 789) | static int luaK_code (FuncState *fs, Instruction i, int line) {
  function luaK_codeABC (line 804) | int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
  function luaK_codeABx (line 812) | int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
  function luaK_setlist (line 819) | void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {

FILE: src/lcode.h
  type BinOpr (line 26) | typedef enum BinOpr {
  type UnOpr (line 36) | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;

FILE: src/lcurses/_helpers.c
  function argtypeerror (line 109) | static int
  function lua_Integer (line 117) | static lua_Integer
  function checkint (line 126) | static int
  function chtype (line 133) | static chtype
  function chtype (line 145) | static chtype
  function optint (line 156) | static int

FILE: src/lcurses/chstr.c
  type chstr (line 49) | typedef struct
  function chstr (line 58) | static chstr *
  function chstr (line 75) | static chstr *
  function Cset_str (line 100) | static int
  function Cset_ch (line 143) | static int
  function Cget (line 178) | static int
  function Clen (line 207) | static int
  function Cdup (line 222) | static int
  function C__call (line 241) | static int
  function LUALIB_API (line 263) | LUALIB_API int

FILE: src/lcurses/compat-5.2.c
  function lua_absindex (line 10) | int lua_absindex (lua_State *L, int i) {
  function lua_copy (line 17) | void lua_copy (lua_State *L, int from, int to) {
  function lua_rawgetp (line 25) | void lua_rawgetp (lua_State *L, int i, const void *p) {
  function lua_rawsetp (line 31) | void lua_rawsetp (lua_State *L, int i, const void *p) {
  function lua_Number (line 57) | lua_Number lua_tonumberx (lua_State *L, int i, int *isnum) {
  function push_package_table (line 68) | static void push_package_table (lua_State *L) {
  function lua_getuservalue (line 84) | void lua_getuservalue (lua_State *L, int i) {
  function lua_setuservalue (line 105) | void lua_setuservalue (lua_State *L, int i) {
  function luaL_setfuncs (line 119) | void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
  function luaL_setmetatable (line 133) | void luaL_setmetatable (lua_State *L, const char *tname) {
  function luaL_getsubtable (line 140) | int luaL_getsubtable (lua_State *L, int i, const char *name) {
  function countlevels (line 157) | static int countlevels (lua_State *L) {
  function findfield (line 171) | static int findfield (lua_State *L, int objidx, int level) {
  function pushglobalfuncname (line 194) | static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
  function pushfuncname (line 209) | static void pushfuncname (lua_State *L, lua_Debug *ar) {
  function luaL_traceback (line 229) | void luaL_traceback (lua_State *L, lua_State *L1,
  function luaL_checkversion (line 257) | void luaL_checkversion (lua_State *L) {
  function luaL_fileresult (line 263) | int luaL_fileresult (lua_State *L, int stat, const char *fname) {
  type LUAI_INT32 (line 288) | typedef LUAI_INT32 LUA_INT32;
  function compat52_call_lua (line 402) | static void compat52_call_lua (lua_State *L, char const code[], size_t len,
  function lua_arith (line 443) | void lua_arith (lua_State *L, int op) {
  function lua_compare (line 461) | int lua_compare (lua_State *L, int idx1, int idx2, int op) {
  function lua_pushunsigned (line 486) | void lua_pushunsigned (lua_State *L, lua_Unsigned n) {
  function lua_Unsigned (line 491) | lua_Unsigned luaL_checkunsigned (lua_State *L, int i) {
  function lua_Unsigned (line 501) | lua_Unsigned lua_tounsignedx (lua_State *L, int i, int *isnum) {
  function lua_Unsigned (line 509) | lua_Unsigned luaL_optunsigned (lua_State *L, int i, lua_Unsigned def) {
  function lua_Integer (line 514) | lua_Integer lua_tointegerx (lua_State *L, int i, int *isnum) {
  function lua_len (line 523) | void lua_len (lua_State *L, int i) {
  function luaL_len (line 541) | int luaL_len (lua_State *L, int i) {
  function luaL_requiref (line 580) | void luaL_requiref (lua_State *L, char const* modname,
  function luaL_buffinit (line 599) | void luaL_buffinit (lua_State *L, luaL_Buffer_52 *B) {
  function luaL_addlstring (line 631) | void luaL_addlstring (luaL_Buffer_52 *B, const char *s, size_t l) {
  function luaL_addvalue (line 637) | void luaL_addvalue (luaL_Buffer_52 *B) {
  function luaL_pushresult (line 649) | void luaL_pushresult (luaL_Buffer_52 *B) {

FILE: src/lcurses/compat-5.2.h
  type LUAI_UINT32 (line 62) | typedef LUAI_UINT32 lua_Unsigned;
  type luaL_Buffer_52 (line 64) | typedef struct luaL_Buffer_52 {
  type luaL_Stream (line 73) | typedef struct luaL_Stream {

FILE: src/lcurses/curses.c
  function Pnew_chstr (line 83) | static int
  function register_curses_constants (line 107) | static void
  function cleanup_curses (line 196) | void
  function init_stdscr (line 209) | static int
  function Pendwin (line 237) | static int
  function Pisendwin (line 250) | static int
  function Pstdscr (line 264) | static int
  function Pcols (line 281) | static int
  function Plines (line 296) | static int
  function Pstart_color (line 310) | static int
  function Phas_colors (line 328) | static int
  function Puse_default_colors (line 342) | static int
  function Passume_default_colors (line 356) | static int
  function Pinit_pair (line 375) | static int
  function Ppair_content (line 394) | static int
  function Pcolors (line 418) | static int
  function Pcolor_pairs (line 432) | static int
  function Pcolor_pair (line 446) | static int
  function Pbaudrate (line 460) | static int
  function Perasechar (line 473) | static int
  function Phas_ic (line 487) | static int
  function Phas_il (line 500) | static int
  function Pkillchar (line 513) | static int
  function Ptermattrs (line 528) | static int
  function Ptermname (line 546) | static int
  function Plongname (line 559) | static int
  function ripoffline_cb (line 570) | static int
  function Pripoffline (line 609) | static int
  function Pcurs_set (line 655) | static int
  function Pnapms (line 675) | static int
  function Presizeterm (line 692) | static int
  function Pbeep (line 708) | static int
  function Pflash (line 722) | static int
  function Pnewwin (line 740) | static int
  function Pdoupdate (line 760) | static int
  function Pslk_init (line 775) | static int
  function Pslk_set (line 792) | static int
  function Pslk_refresh (line 809) | static int
  function Pslk_noutrefresh (line 823) | static int
  function Pslk_label (line 837) | static int
  function Pslk_clear (line 852) | static int
  function Pslk_restore (line 866) | static int
  function Pslk_touch (line 879) | static int
  function Pslk_attron (line 893) | static int
  function Pslk_attroff (line 908) | static int
  function Pslk_attrset (line 923) | static int
  function Pcbreak (line 939) | static int
  function Pecho (line 956) | static int
  function Praw (line 973) | static int
  function Phalfdelay (line 989) | static int
  function Pnl (line 1005) | static int
  function Punctrl (line 1022) | static int
  function Pkeyname (line 1038) | static int
  function Pdelay_output (line 1054) | static int
  function Pflushinp (line 1069) | static int
  function Pungetch (line 1084) | static int
  function Pnewpad (line 1100) | static int
  function Ptigetflag (line 1120) | static int
  function Ptigetnum (line 1141) | static int
  function Ptigetstr (line 1166) | static int
  function LUALIB_API (line 1468) | LUALIB_API int

FILE: src/lcurses/strlcpy.c
  function strlcpy (line 49) | static size_t strlcpy(char *dst, const char *src, size_t siz)

FILE: src/lcurses/window.c
  function lc_newwin (line 48) | static void
  function WINDOW (line 66) | static WINDOW **
  function WINDOW (line 76) | static WINDOW *
  function W__tostring (line 91) | static int
  function Wclose (line 110) | static int
  function Wmove_window (line 131) | static int
  function Wsub (line 152) | static int
  function Wderive (line 177) | static int
  function Wmove_derived (line 199) | static int
  function Wresize (line 217) | static int
  function Wclone (line 237) | static int
  function Wsyncup (line 251) | static int
  function Wsyncok (line 266) | static int
  function Wcursyncup (line 280) | static int
  function Wsyncdown (line 294) | static int
  function Wrefresh (line 310) | static int
  function Wnoutrefresh (line 327) | static int
  function Wredrawwin (line 341) | static int
  function Wredrawln (line 356) | static int
  function Wmove (line 374) | static int
  function Wscrl (line 391) | static int
  function Wtouch (line 407) | static int
  function Wtouchline (line 432) | static int
  function Wis_linetouched (line 454) | static int
  function Wis_wintouched (line 469) | static int
  function Wgetyx (line 484) | static int
  function Wgetparyx (line 503) | static int
  function Wgetbegyx (line 522) | static int
  function Wgetmaxyx (line 541) | static int
  function Wborder (line 573) | static int
  function Wbox (line 601) | static int
  function Whline (line 625) | static int
  function Wvline (line 646) | static int
  function Wmvhline (line 667) | static int
  function Wmvvline (line 690) | static int
  function Werase (line 709) | static int
  function Wclear (line 722) | static int
  function Wclrtobot (line 735) | static int
  function Wclrtoeol (line 748) | static int
  function Waddch (line 762) | static int
  function Wmvaddch (line 780) | static int
  function Wechoch (line 798) | static int
  function Waddchstr (line 815) | static int
  function Wmvaddchstr (line 838) | static int
  function Waddstr (line 862) | static int
  function Wmvaddstr (line 882) | static int
  function Wwbkgdset (line 900) | static int
  function Wwbkgd (line 917) | static int
  function Wgetbkgd (line 933) | static int
  function Wintrflush (line 947) | static int
  function Wkeypad (line 963) | static int
  function Wmeta (line 979) | static int
  function Wnodelay (line 995) | static int
  function Wtimeout (line 1010) | static int
  function Wnotimeout (line 1027) | static int
  function Wclearok (line 1043) | static int
  function Widcok (line 1059) | static int
  function Widlok (line 1076) | static int
  function Wleaveok (line 1092) | static int
  function Wscrollok (line 1108) | static int
  function Wimmedok (line 1124) | static int
  function Wwsetscrreg (line 1142) | static int
  function Woverlay (line 1160) | static int
  function Woverwrite (line 1176) | static int
  function Wcopywin (line 1199) | static int
  function Wdelch (line 1222) | static int
  function Wmvdelch (line 1237) | static int
  function Wdeleteln (line 1253) | static int
  function Winsertln (line 1266) | static int
  function Wwinsdelln (line 1280) | static int
  function Wgetch (line 1297) | static int
  function Wungetch (line 1375) | static int
  function Wmvgetch (line 1395) | static int
  function Wwinch (line 1421) | static int
  function Wmvwinch (line 1437) | static int
  function Wwinchnstr (line 1455) | static int
  function Wmvwinchnstr (line 1478) | static int
  function Wwinnstr (line 1502) | static int
  function Wmvwinnstr (line 1531) | static int
  function Wwinsch (line 1560) | static int
  function Wmvwinsch (line 1578) | static int
  function Wwinsstr (line 1596) | static int
  function Wmvwinsstr (line 1614) | static int
  function Wwinsnstr (line 1633) | static int
  function Wmvwinsnstr (line 1653) | static int
  function Wsubpad (line 1675) | static int
  function Wprefresh (line 1701) | static int
  function Wpnoutrefresh (line 1729) | static int
  function Wpechochar (line 1752) | static int
  function Wattroff (line 1769) | static int
  function Wattron (line 1785) | static int
  function Wattrset (line 1801) | static int
  function Wstandend (line 1816) | static int
  function Wstandout (line 1829) | static int
  function LUALIB_API (line 1936) | LUALIB_API int

FILE: src/ldebug.c
  function currentpc (line 36) | static int currentpc (lua_State *L, CallInfo *ci) {
  function currentline (line 44) | static int currentline (lua_State *L, CallInfo *ci) {
  function LUA_API (line 56) | LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int coun...
  function LUA_API (line 69) | LUA_API lua_Hook lua_gethook (lua_State *L) {
  function LUA_API (line 74) | LUA_API int lua_gethookmask (lua_State *L) {
  function LUA_API (line 79) | LUA_API int lua_gethookcount (lua_State *L) {
  function LUA_API (line 84) | LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
  function Proto (line 107) | static Proto *getluaproto (CallInfo *ci) {
  function LUA_API (line 127) | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int...
  function LUA_API (line 138) | LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int...
  function funcinfo (line 150) | static void funcinfo (lua_Debug *ar, Closure *cl) {
  function info_tailcall (line 167) | static void info_tailcall (lua_Debug *ar) {
  function collectvalidlines (line 177) | static void collectvalidlines (lua_State *L, Closure *f) {
  function auxgetinfo (line 193) | static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
  function LUA_API (line 232) | LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
  function precheck (line 276) | static int precheck (const Proto *pt) {
  function luaG_checkopenop (line 290) | int luaG_checkopenop (Instruction i) {
  function checkArgMode (line 304) | static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) {
  function Instruction (line 317) | Instruction symbexec (const Proto *pt, int lastpc, int reg) {
  function luaG_checkcode (line 484) | int luaG_checkcode (const Proto *pt) {
  function isinstack (line 559) | static int isinstack (CallInfo *ci, const TValue *o) {
  function luaG_typeerror (line 567) | void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
  function luaG_concaterror (line 581) | void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
  function luaG_aritherror (line 588) | void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
  function luaG_ordererror (line 596) | int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
  function addinfo (line 607) | static void addinfo (lua_State *L, const char *msg) {
  function luaG_errormsg (line 618) | void luaG_errormsg (lua_State *L) {
  function luaG_runerror (line 631) | void luaG_runerror (lua_State *L, const char *fmt, ...) {

FILE: src/ldo.c
  type lua_longjmp (line 43) | struct lua_longjmp {
  function luaD_seterrorobj (line 50) | void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
  function restore_stack_limit (line 70) | static void restore_stack_limit (lua_State *L) {
  function resetstack (line 80) | static void resetstack (lua_State *L, int status) {
  function luaD_throw (line 93) | void luaD_throw (lua_State *L, int errcode) {
  function luaD_rawrunprotected (line 110) | int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
  function correctstack (line 125) | static void correctstack (lua_State *L, TValue *oldstack) {
  function luaD_reallocstack (line 140) | void luaD_reallocstack (lua_State *L, int newsize) {
  function luaD_reallocCI (line 151) | void luaD_reallocCI (lua_State *L, int newsize) {
  function luaD_growstack (line 160) | void luaD_growstack (lua_State *L, int n) {
  function CallInfo (line 168) | static CallInfo *growCI (lua_State *L) {
  function luaD_callhook (line 180) | void luaD_callhook (lua_State *L, int event, int line) {
  function StkId (line 207) | static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
  function StkId (line 243) | static StkId tryfuncTM (lua_State *L, StkId func) {
  function luaD_precall (line 265) | int luaD_precall (lua_State *L, StkId func, int nresults) {
  function StkId (line 333) | static StkId callrethooks (lua_State *L, StkId firstResult) {
  function luaD_poscall (line 344) | int luaD_poscall (lua_State *L, StkId firstResult) {
  function luaD_call (line 371) | void luaD_call (lua_State *L, StkId func, int nResults) {
  function resume (line 385) | static void resume (lua_State *L, void *ud) {
  function resume_error (line 410) | static int resume_error (lua_State *L, const char *msg) {
  function LUA_API (line 419) | LUA_API int lua_resume (lua_State *L, int nargs) {
  function LUA_API (line 444) | LUA_API int lua_yield (lua_State *L, int nresults) {
  function luaD_pcall (line 455) | int luaD_pcall (lua_State *L, Pfunc func, void *u,
  type SParser (line 484) | struct SParser {  /* data to `f_parser' */
  function f_parser (line 490) | static void f_parser (lua_State *L, void *ud) {
  function luaD_protectedparser (line 508) | int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) {

FILE: src/ldump.c
  type DumpState (line 18) | typedef struct {
  function DumpBlock (line 29) | static void DumpBlock(const void* b, size_t size, DumpState* D)
  function DumpChar (line 39) | static void DumpChar(int y, DumpState* D)
  function DumpInt (line 45) | static void DumpInt(int x, DumpState* D)
  function DumpNumber (line 50) | static void DumpNumber(lua_Number x, DumpState* D)
  function DumpVector (line 55) | static void DumpVector(const void* b, int n, size_t size, DumpState* D)
  function DumpString (line 61) | static void DumpString(const TString* s, DumpState* D)
  function DumpConstants (line 80) | static void DumpConstants(const Proto* f, DumpState* D)
  function DumpDebug (line 111) | static void DumpDebug(const Proto* f, DumpState* D)
  function DumpFunction (line 129) | static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
  function DumpHeader (line 143) | static void DumpHeader(DumpState* D)
  function luaU_dump (line 153) | int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, i...

FILE: src/lfunc.c
  function Closure (line 23) | Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) {
  function Closure (line 33) | Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) {
  function UpVal (line 44) | UpVal *luaF_newupval (lua_State *L) {
  function UpVal (line 53) | UpVal *luaF_findupval (lua_State *L, StkId level) {
  function unlinkupval (line 82) | static void unlinkupval (UpVal *uv) {
  function luaF_freeupval (line 89) | void luaF_freeupval (lua_State *L, UpVal *uv) {
  function luaF_close (line 96) | void luaF_close (lua_State *L, StkId level) {
  function Proto (line 115) | Proto *luaF_newproto (lua_State *L) {
  function luaF_freeproto (line 141) | void luaF_freeproto (lua_State *L, Proto *f) {
  function luaF_freeclosure (line 152) | void luaF_freeclosure (lua_State *L, Closure *c) {

FILE: src/lgc.c
  function removeentry (line 62) | static void removeentry (Node *n) {
  function reallymarkobject (line 69) | static void reallymarkobject (global_State *g, GCObject *o) {
  function marktmu (line 115) | static void marktmu (global_State *g) {
  function luaC_separateudata (line 128) | size_t luaC_separateudata (lua_State *L, int all) {
  function traversetable (line 158) | static int traversetable (global_State *g, Table *h) {
  function traverseproto (line 203) | static void traverseproto (global_State *g, Proto *f) {
  function traverseclosure (line 224) | static void traverseclosure (global_State *g, Closure *cl) {
  function checkstacksizes (line 241) | static void checkstacksizes (lua_State *L, StkId max) {
  function traversestack (line 256) | static void traversestack (global_State *g, lua_State *l) {
  function l_mem (line 277) | static l_mem propagatemark (global_State *g) {
  function propagateall (line 323) | static size_t propagateall (global_State *g) {
  function iscleared (line 337) | static int iscleared (const TValue *o, int iskey) {
  function cleartable (line 351) | static void cleartable (GCObject *l) {
  function freeobj (line 378) | static void freeobj (lua_State *L, GCObject *o) {
  function GCObject (line 407) | static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
  function checkSizes (line 431) | static void checkSizes (lua_State *L) {
  function GCTM (line 445) | static void GCTM (lua_State *L) {
  function luaC_callGCTM (line 477) | void luaC_callGCTM (lua_State *L) {
  function luaC_freeall (line 483) | void luaC_freeall (lua_State *L) {
  function markmt (line 493) | static void markmt (global_State *g) {
  function markroot (line 501) | static void markroot (lua_State *L) {
  function remarkupvals (line 515) | static void remarkupvals (global_State *g) {
  function atomic (line 525) | static void atomic (lua_State *L) {
  function l_mem (line 556) | static l_mem singlestep (lua_State *L) {
  function luaC_step (line 610) | void luaC_step (lua_State *L) {
  function luaC_fullgc (line 635) | void luaC_fullgc (lua_State *L) {
  function luaC_barrierf (line 661) | void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
  function luaC_barrierback (line 674) | void luaC_barrierback (lua_State *L, Table *t) {
  function luaC_link (line 685) | void luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
  function luaC_linkupval (line 694) | void luaC_linkupval (lua_State *L, UpVal *uv) {

FILE: src/linit.c
  function LUALIB_API (line 35) | LUALIB_API void luaL_openlibs (lua_State *L) {

FILE: src/liolib.c
  function pushresult (line 24) | static int pushresult (lua_State *L, int i, const char *filename) {
  function io_type (line 45) | static int io_type (lua_State *L) {
  function FILE (line 60) | static FILE *tofile (lua_State *L) {
  function FILE (line 74) | static FILE **newfile (lua_State *L) {
  function io_fclose (line 86) | static int io_fclose (lua_State *L) {
  function aux_close (line 94) | static int aux_close (lua_State *L) {
  function io_close (line 101) | static int io_close (lua_State *L) {
  function io_gc (line 107) | static int io_gc (lua_State *L) {
  function io_tostring (line 116) | static int io_tostring (lua_State *L) {
  function io_open (line 127) | static int io_open (lua_State *L) {
  function io_tmpfile (line 160) | static int io_tmpfile (lua_State *L) {
  function aux_lines (line 170) | static void aux_lines (lua_State *L, int idx, int toclose) {
  function f_lines (line 177) | static int f_lines (lua_State *L) {
  function read_number (line 191) | static int read_number (lua_State *L, FILE *f) {
  function test_eof (line 204) | static int test_eof (lua_State *L, FILE *f) {
  function read_line (line 212) | static int read_line (lua_State *L, FILE *f) {
  function read_chars (line 234) | static int read_chars (lua_State *L, FILE *f, size_t n) {
  function g_read (line 252) | static int g_read (lua_State *L, FILE *f, int first) {
  function f_read (line 299) | static int f_read (lua_State *L) {
  function io_readline (line 304) | static int io_readline (lua_State *L) {
  function g_write (line 326) | static int g_write (lua_State *L, FILE *f, int arg) {
  function f_write (line 345) | static int f_write (lua_State *L) {
  function f_seek (line 350) | static int f_seek (lua_State *L) {
  function f_setvbuf (line 366) | static int f_setvbuf (lua_State *L) {
  function f_flush (line 377) | static int f_flush (lua_State *L) {
  function createmeta (line 412) | static void createmeta (lua_State *L) {
  function newfenv (line 420) | static void newfenv (lua_State *L, lua_CFunction cls) {
  function LUALIB_API (line 427) | LUALIB_API int luaopen_io (lua_State *L) {

FILE: src/llex.c
  function save (line 51) | static void save (LexState *ls, int c) {
  function luaX_init (line 64) | void luaX_init (lua_State *L) {
  function luaX_lexerror (line 102) | void luaX_lexerror (LexState *ls, const char *msg, int token) {
  function luaX_syntaxerror (line 112) | void luaX_syntaxerror (LexState *ls, const char *msg) {
  function TString (line 117) | TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
  function inclinenumber (line 129) | static void inclinenumber (LexState *ls) {
  function luaX_setinput (line 140) | void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) {
  function check_next (line 163) | static int check_next (LexState *ls, const char *set) {
  function buffreplace (line 171) | static void buffreplace (LexState *ls, char from, char to) {
  function trydecpoint (line 179) | static void trydecpoint (LexState *ls, SemInfo *seminfo) {
  function read_numeral (line 194) | static void read_numeral (LexState *ls, SemInfo *seminfo) {
  function skip_sep (line 210) | static int skip_sep (LexState *ls) {
  function read_long_string (line 223) | static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
  function read_string (line 278) | static void read_string (LexState *ls, int del, SemInfo *seminfo) {
  function llex (line 334) | static int llex (LexState *ls, SemInfo *seminfo) {
  function luaX_next (line 448) | void luaX_next (LexState *ls) {
  function luaX_lookahead (line 459) | void luaX_lookahead (LexState *ls) {

FILE: src/llex.h
  type RESERVED (line 24) | enum RESERVED {
  type SemInfo (line 43) | typedef union {
  type Token (line 49) | typedef struct Token {
  type LexState (line 55) | typedef struct LexState {

FILE: src/llimits.h
  type LUAI_UINT32 (line 18) | typedef LUAI_UINT32 lu_int32;
  type LUAI_UMEM (line 20) | typedef LUAI_UMEM lu_mem;
  type LUAI_MEM (line 22) | typedef LUAI_MEM l_mem;
  type lu_byte (line 27) | typedef unsigned char lu_byte;
  type LUAI_USER_ALIGNMENT_T (line 47) | typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
  type LUAI_UACNUMBER (line 51) | typedef LUAI_UACNUMBER l_uacNumber;
  type lu_int32 (line 88) | typedef lu_int32 Instruction;

FILE: src/lmathlib.c
  function math_abs (line 26) | static int math_abs (lua_State *L) {
  function math_sin (line 31) | static int math_sin (lua_State *L) {
  function math_sinh (line 36) | static int math_sinh (lua_State *L) {
  function math_cos (line 41) | static int math_cos (lua_State *L) {
  function math_cosh (line 46) | static int math_cosh (lua_State *L) {
  function math_tan (line 51) | static int math_tan (lua_State *L) {
  function math_tanh (line 56) | static int math_tanh (lua_State *L) {
  function math_asin (line 61) | static int math_asin (lua_State *L) {
  function math_acos (line 66) | static int math_acos (lua_State *L) {
  function math_atan (line 71) | static int math_atan (lua_State *L) {
  function math_atan2 (line 76) | static int math_atan2 (lua_State *L) {
  function math_ceil (line 81) | static int math_ceil (lua_State *L) {
  function math_floor (line 86) | static int math_floor (lua_State *L) {
  function math_fmod (line 91) | static int math_fmod (lua_State *L) {
  function math_modf (line 96) | static int math_modf (lua_State *L) {
  function math_sqrt (line 104) | static int math_sqrt (lua_State *L) {
  function math_pow (line 109) | static int math_pow (lua_State *L) {
  function math_log (line 114) | static int math_log (lua_State *L) {
  function math_log10 (line 119) | static int math_log10 (lua_State *L) {
  function math_exp (line 124) | static int math_exp (lua_State *L) {
  function math_deg (line 129) | static int math_deg (lua_State *L) {
  function math_rad (line 134) | static int math_rad (lua_State *L) {
  function math_frexp (line 139) | static int math_frexp (lua_State *L) {
  function math_ldexp (line 146) | static int math_ldexp (lua_State *L) {
  function math_min (line 153) | static int math_min (lua_State *L) {
  function math_max (line 167) | static int math_max (lua_State *L) {
  function math_random (line 181) | static int math_random (lua_State *L) {
  function math_randomseed (line 209) | static int math_randomseed (lua_State *L) {
  function LUALIB_API (line 251) | LUALIB_API int luaopen_math (lua_State *L) {

FILE: src/lobject.c
  function luaO_int2fb (line 35) | int luaO_int2fb (unsigned int x) {
  function luaO_fb2int (line 47) | int luaO_fb2int (int x) {
  function luaO_log2 (line 54) | int luaO_log2 (unsigned int x) {
  function luaO_rawequalObj (line 72) | int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
  function luaO_str2d (line 90) | int luaO_str2d (const char *s, lua_Number *result) {
  function pushstr (line 104) | static void pushstr (lua_State *L, const char *str) {
  function luaO_chunkid (line 182) | void luaO_chunkid (char *out, const char *source, size_t bufflen) {

FILE: src/lobject.h
  type GCObject (line 36) | typedef union GCObject GCObject;
  type GCheader (line 49) | typedef struct GCheader {
  type Value (line 59) | typedef union {
  type TValue (line 73) | typedef struct lua_TValue {
  type TValue (line 193) | typedef TValue *StkId;
  type TString (line 199) | typedef union TString {
  type Udata (line 215) | typedef union Udata {
  type Proto (line 231) | typedef struct Proto {
  type LocVar (line 262) | typedef struct LocVar {
  type UpVal (line 274) | typedef struct UpVal {
  type CClosure (line 295) | typedef struct CClosure {
  type LClosure (line 302) | typedef struct LClosure {
  type Closure (line 309) | typedef union Closure {
  type TKey (line 323) | typedef union TKey {
  type Node (line 332) | typedef struct Node {
  type Table (line 338) | typedef struct Table {

FILE: src/lopcodes.h
  type OpMode (line 31) | enum OpMode {iABC, iABx, iAsBx}
  type OpCode (line 150) | typedef enum {
  type OpArgMask (line 245) | enum OpArgMask {

FILE: src/loslib.c
  function os_pushresult (line 24) | static int os_pushresult (lua_State *L, int i, const char *filename) {
  function os_remove (line 40) | static int os_remove (lua_State *L) {
  function os_rename (line 64) | static int os_rename (lua_State *L) {
  function os_tmpname (line 110) | static int os_tmpname (lua_State *L) {
  function os_clock (line 121) | static int os_clock (lua_State *L) {
  function setfield (line 135) | static void setfield (lua_State *L, const char *key, int value) {
  function setboolfield (line 140) | static void setboolfield (lua_State *L, const char *key, int value) {
  function getboolfield (line 147) | static int getboolfield (lua_State *L, const char *key) {
  function getfield (line 156) | static int getfield (lua_State *L, const char *key, int d) {
  function os_date (line 171) | static int os_date (lua_State *L) {
  function os_time (line 217) | static int os_time (lua_State *L) {
  function os_difftime (line 242) | static int os_difftime (lua_State *L) {
  function os_setlocale (line 251) | static int os_setlocale (lua_State *L) {
  function os_exit (line 263) | static int os_exit (lua_State *L) {
  function LUALIB_API (line 286) | LUALIB_API int luaopen_os (lua_State *L) {

FILE: src/lparser.c
  type BlockCnt (line 40) | typedef struct BlockCnt {
  function anchor_token (line 57) | static void anchor_token (LexState *ls) {
  function error_expected (line 65) | static void error_expected (LexState *ls, int token) {
  function errorlimit (line 71) | static void errorlimit (FuncState *fs, int limit, const char *what) {
  function testnext (line 80) | static int testnext (LexState *ls, int c) {
  function check (line 89) | static void check (LexState *ls, int c) {
  function checknext (line 94) | static void checknext (LexState *ls, int c) {
  function check_match (line 104) | static void check_match (LexState *ls, int what, int who, int where) {
  function TString (line 117) | static TString *str_checkname (LexState *ls) {
  function init_exp (line 126) | static void init_exp (expdesc *e, expkind k, int i) {
  function codestring (line 133) | static void codestring (LexState *ls, expdesc *e, TString *s) {
  function checkname (line 138) | static void checkname(LexState *ls, expdesc *e) {
  function registerlocalvar (line 143) | static int registerlocalvar (LexState *ls, TString *varname) {
  function new_localvar (line 160) | static void new_localvar (LexState *ls, TString *name, int n) {
  function adjustlocalvars (line 167) | static void adjustlocalvars (LexState *ls, int nvars) {
  function removevars (line 176) | static void removevars (LexState *ls, int tolevel) {
  function indexupvalue (line 183) | static int indexupvalue (FuncState *fs, TString *name, expdesc *v) {
  function searchvar (line 207) | static int searchvar (FuncState *fs, TString *n) {
  function markupval (line 217) | static void markupval (FuncState *fs, int level) {
  function singlevaraux (line 224) | static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int ba...
  function singlevar (line 248) | static void singlevar (LexState *ls, expdesc *var) {
  function adjust_assign (line 256) | static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *...
  function enterlevel (line 276) | static void enterlevel (LexState *ls) {
  function enterblock (line 285) | static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) {
  function leaveblock (line 296) | static void leaveblock (FuncState *fs) {
  function pushclosure (line 310) | static void pushclosure (LexState *ls, FuncState *func, expdesc *v) {
  function open_func (line 328) | static void open_func (LexState *ls, FuncState *fs) {
  function close_func (line 356) | static void close_func (LexState *ls) {
  function Proto (line 383) | Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *nam...
  function field (line 407) | static void field (LexState *ls, expdesc *v) {
  function yindex (line 418) | static void yindex (LexState *ls, expdesc *v) {
  type ConsControl (line 434) | struct ConsControl {
  function recfield (line 443) | static void recfield (LexState *ls, struct ConsControl *cc) {
  function closelistfield (line 464) | static void closelistfield (FuncState *fs, struct ConsControl *cc) {
  function lastlistfield (line 475) | static void lastlistfield (FuncState *fs, struct ConsControl *cc) {
  function listfield (line 490) | static void listfield (LexState *ls, struct ConsControl *cc) {
  function constructor (line 498) | static void constructor (LexState *ls, expdesc *t) {
  function parlist (line 543) | static void parlist (LexState *ls) {
  function body (line 576) | static void body (LexState *ls, expdesc *e, int needself, int line) {
  function explist1 (line 596) | static int explist1 (LexState *ls, expdesc *v) {
  function funcargs (line 609) | static void funcargs (LexState *ls, expdesc *f) {
  function prefixexp (line 667) | static void prefixexp (LexState *ls, expdesc *v) {
  function primaryexp (line 690) | static void primaryexp (LexState *ls, expdesc *v) {
  function simpleexp (line 727) | static void simpleexp (LexState *ls, expdesc *v) {
  function UnOpr (line 778) | static UnOpr getunopr (int op) {
  function BinOpr (line 788) | static BinOpr getbinopr (int op) {
  function BinOpr (line 828) | static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) {
  function expr (line 856) | static void expr (LexState *ls, expdesc *v) {
  function block_follow (line 871) | static int block_follow (int token) {
  function block (line 881) | static void block (LexState *ls) {
  type LHS_assign (line 896) | struct LHS_assign {
  function check_conflict (line 908) | static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc...
  function assignment (line 931) | static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
  function cond (line 965) | static int cond (LexState *ls) {
  function breakstat (line 975) | static void breakstat (LexState *ls) {
  function whilestat (line 991) | static void whilestat (LexState *ls, int line) {
  function repeatstat (line 1010) | static void repeatstat (LexState *ls, int line) {
  function exp1 (line 1036) | static int exp1 (LexState *ls) {
  function forbody (line 1046) | static void forbody (LexState *ls, int base, int line, int nvars, int is...
  function fornum (line 1067) | static void fornum (LexState *ls, TString *varname, int line) {
  function forlist (line 1089) | static void forlist (LexState *ls, TString *indexname) {
  function forstat (line 1112) | static void forstat (LexState *ls, int line) {

FILE: src/lparser.h
  type expkind (line 19) | typedef enum {
  type expdesc (line 37) | typedef struct expdesc {
  type upvaldesc (line 48) | typedef struct upvaldesc {
  type BlockCnt (line 54) | struct BlockCnt
  type FuncState (line 58) | typedef struct FuncState {

FILE: src/lstate.c
  type LG (line 30) | typedef struct LG {
  function stack_init (line 37) | static void stack_init (lua_State *L1, lua_State *L) {
  function freestack (line 56) | static void freestack (lua_State *L, lua_State *L1) {
  function f_luaopen (line 65) | static void f_luaopen (lua_State *L, void *ud) {
  function preinit_state (line 79) | static void preinit_state (lua_State *L, global_State *g) {
  function close_state (line 100) | static void close_state (lua_State *L) {
  function lua_State (line 114) | lua_State *luaE_newthread (lua_State *L) {
  function luaE_freethread (line 129) | void luaE_freethread (lua_State *L, lua_State *L1) {
  function LUA_API (line 137) | LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
  function callallgcTM (line 185) | static void callallgcTM (lua_State *L, void *ud) {
  function LUA_API (line 191) | LUA_API void lua_close (lua_State *L) {

FILE: src/lstate.h
  type lua_longjmp (line 18) | struct lua_longjmp
  type stringtable (line 38) | typedef struct stringtable {
  type CallInfo (line 48) | typedef struct CallInfo {
  type global_State (line 68) | typedef struct global_State {
  type lua_State (line 100) | struct lua_State {
  type Table (line 141) | struct Table
  type Proto (line 142) | struct Proto
  type UpVal (line 143) | struct UpVal
  type lua_State (line 144) | struct lua_State

FILE: src/lstring.c
  function luaS_resize (line 22) | void luaS_resize (lua_State *L, int newsize) {
  function TString (line 50) | static TString *newlstr (lua_State *L, const char *str, size_t l,
  function TString (line 75) | TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
  function Udata (line 96) | Udata *luaS_newudata (lua_State *L, size_t s, Table *e) {

FILE: src/lstrlib.c
  function str_len (line 28) | static int str_len (lua_State *L) {
  function posrelat (line 36) | static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) {
  function str_sub (line 43) | static int str_sub (lua_State *L) {
  function str_reverse (line 57) | static int str_reverse (lua_State *L) {
  function str_lower (line 68) | static int str_lower (lua_State *L) {
  function str_upper (line 81) | static int str_upper (lua_State *L) {
  function str_rep (line 93) | static int str_rep (lua_State *L) {
  function str_byte (line 106) | static int str_byte (lua_State *L) {
  function str_char (line 125) | static int str_char (lua_State *L) {
  type MatchState (line 151) | typedef struct MatchState {
  function check_capture (line 167) | static int check_capture (MatchState *ms, int l) {
  function capture_to_close (line 175) | static int capture_to_close (MatchState *ms) {
  function match_class (line 207) | static int match_class (int c, int cl) {
  function matchbracketclass (line 226) | static int matchbracketclass (int c, const char *p, const char *ec) {
  function singlematch (line 249) | static int singlematch (int c, const char *p, const char *ep) {
  function push_onecapture (line 447) | static void push_onecapture (MatchState *ms, int i, const char *s,
  function push_captures (line 466) | static int push_captures (MatchState *ms, const char *s, const char *e) {
  function str_find_aux (line 476) | static int str_find_aux (lua_State *L, int find) {
  function str_find (line 519) | static int str_find (lua_State *L) {
  function str_match (line 524) | static int str_match (lua_State *L) {
  function gmatch_aux (line 529) | static int gmatch_aux (lua_State *L) {
  function gmatch (line 555) | static int gmatch (lua_State *L) {
  function gfind_nodef (line 565) | static int gfind_nodef (lua_State *L) {
  function add_s (line 571) | static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
  function add_value (line 593) | static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
  function str_gsub (line 625) | static int str_gsub (lua_State *L) {
  function addquoted (line 677) | static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
  function addintlen (line 728) | static void addintlen (char *form) {
  function str_format (line 737) | static int str_format (lua_State *L) {
  function createmetatable (line 828) | static void createmetatable (lua_State *L) {
  function LUALIB_API (line 843) | LUALIB_API int luaopen_string (lua_State *L) {

FILE: src/ltable.c
  function Node (line 84) | static Node *hashnum (const Table *t, lua_Number n) {
  function Node (line 100) | static Node *mainposition (const Table *t, const TValue *key) {
  function arrayindex (line 120) | static int arrayindex (const TValue *key) {
  function findindex (line 137) | static int findindex (lua_State *L, Table *t, StkId key) {
  function luaH_next (line 162) | int luaH_next (lua_State *L, Table *t, StkId key) {
  function computesizes (line 189) | static int computesizes (int nums[], int *narray) {
  function countint (line 211) | static int countint (const TValue *key, int *nums) {
  function numusearray (line 222) | static int numusearray (const Table *t, int *nums) {
  function numusehash (line 247) | static int numusehash (const Table *t, int *nums, int *pnasize) {
  function setarrayvector (line 263) | static void setarrayvector (lua_State *L, Table *t, int size) {
  function setnodevector (line 272) | static void setnodevector (lua_State *L, Table *t, int size) {
  function resize (line 297) | static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
  function luaH_resizearray (line 327) | void luaH_resizearray (lua_State *L, Table *t, int nasize) {
  function rehash (line 333) | static void rehash (lua_State *L, Table *t, const TValue *ek) {
  function Table (line 358) | Table *luaH_new (lua_State *L, int narray, int nhash) {
  function luaH_free (line 374) | void luaH_free (lua_State *L, Table *t) {
  function Node (line 382) | static Node *getfreepos (Table *t) {
  function TValue (line 399) | static TValue *newkey (lua_State *L, Table *t, const TValue *key) {
  function TValue (line 435) | const TValue *luaH_getnum (Table *t, int key) {
  function TValue (line 455) | const TValue *luaH_getstr (Table *t, TString *key) {
  function TValue (line 469) | const TValue *luaH_get (Table *t, const TValue *key) {
  function TValue (line 494) | TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
  function TValue (line 508) | TValue *luaH_setnum (lua_State *L, Table *t, int key) {
  function TValue (line 520) | TValue *luaH_setstr (lua_State *L, Table *t, TString *key) {
  function unbound_search (line 532) | static int unbound_search (Table *t, unsigned int j) {
  function luaH_getn (line 560) | int luaH_getn (Table *t) {
  function Node (line 582) | Node *luaH_mainposition (const Table *t, const TValue *key) {
  function luaH_isdummy (line 586) | int luaH_isdummy (Node *n) { return n == dummynode; }

FILE: src/ltablib.c
  function foreachi (line 22) | static int foreachi (lua_State *L) {
  function foreach (line 39) | static int foreach (lua_State *L) {
  function maxn (line 56) | static int maxn (lua_State *L) {
  function getn (line 72) | static int getn (lua_State *L) {
  function setn (line 78) | static int setn (lua_State *L) {
  function tinsert (line 90) | static int tinsert (lua_State *L) {
  function tremove (line 118) | static int tremove (lua_State *L) {
  function addfield (line 135) | static void addfield (lua_State *L, luaL_Buffer *b, int i) {
  function tconcat (line 144) | static int tconcat (lua_State *L) {
  function set2 (line 173) | static void set2 (lua_State *L, int i, int j) {
  function sort_comp (line 178) | static int sort_comp (lua_State *L, int a, int b) {
  function auxsort (line 193) | static void auxsort (lua_State *L, int l, int u) {
  function sort (line 256) | static int sort (lua_State *L) {
  function LUALIB_API (line 283) | LUALIB_API int luaopen_table (lua_State *L) {

FILE: src/ltm.c
  function luaT_init (line 30) | void luaT_init (lua_State *L) {
  function TValue (line 50) | const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
  function TValue (line 61) | const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {

FILE: src/ltm.h
  type TMS (line 18) | typedef enum {

FILE: src/lua.c
  function lstop (line 34) | static void lstop (lua_State *L, lua_Debug *ar) {
  function laction (line 41) | static void laction (int i) {
  function print_usage (line 48) | static void print_usage (void) {
  function l_message (line 53) | static void l_message (const char *pname, const char *msg) {
  function report (line 67) | static int report (lua_State *L, int status) {
  function traceback (line 78) | static int traceback (lua_State *L) {
  function docall (line 98) | int docall (lua_State *L, int narg, int clear) {
  function set_args (line 114) | void set_args (lua_State *L, char **argv, int n) {
  function dofile (line 130) | static int dofile (lua_State *L, const char *name) {
  function dostring (line 136) | int dostring (lua_State *L, const char *s, const char *name) {
  function stack_dump (line 142) | void stack_dump (lua_State *L) {
  function handle_luainit (line 176) | static int handle_luainit (lua_State *L) {
  function dorequire (line 188) | static int dorequire (lua_State *L, const char *filename, const char *gl...
  type Smain (line 201) | struct Smain {
  function pmain (line 209) | static int pmain (lua_State *L) {
  function main (line 262) | int main (int argc, char **argv) {

FILE: src/lua.h
  type lua_State (line 53) | typedef struct lua_State lua_State;
  type LUA_NUMBER (line 102) | typedef LUA_NUMBER lua_Number;
  type LUA_INTEGER (line 106) | typedef LUA_INTEGER lua_Integer;
  type lua_Debug (line 327) | typedef struct lua_Debug lua_Debug;
  type lua_Debug (line 347) | struct lua_Debug {

FILE: src/luasec/config.c
  function LSEC_API (line 15) | LSEC_API int luaopen_ssl_config(lua_State *L)

FILE: src/luasec/context.c
  function p_context (line 39) | static p_context checkctx(lua_State *L, int idx)
  function p_context (line 44) | static p_context testctx(lua_State *L, int idx)
  function set_option_flag (line 52) | static int set_option_flag(const char *opt, unsigned long *flag)
  function SSL_METHOD (line 68) | static const SSL_METHOD* str2method(const char *method, int *vmin, int *...
  function SSL_METHOD (line 85) | static const SSL_METHOD* str2method(const char *method, int *vmin, int *...
  function set_verify_flag (line 121) | static int set_verify_flag(const char *str, int *flag)
  function passwd_cb (line 145) | static int passwd_cb(char *buf, int size, int flag, void *udata)
  function add_cert_error (line 169) | static void add_cert_error(lua_State *L, SSL *ssl, int err, int depth)
  function DH (line 199) | static DH *dhparam_cb(SSL *ssl, int is_export, int keylength)
  function cert_verify_cb (line 237) | static int cert_verify_cb(X509_STORE_CTX *x509_ctx, void *ptr)
  function verify_cb (line 269) | static int verify_cb(int preverify_ok, X509_STORE_CTX *x509_ctx)
  function create (line 308) | static int create(lua_State *L)
  function load_locations (line 356) | static int load_locations(lua_State *L)
  function load_cert (line 374) | static int load_cert(lua_State *L)
  function load_key (line 391) | static int load_key(lua_State *L)
  function check_key (line 425) | static int check_key(lua_State *L)
  function set_cipher (line 435) | static int set_cipher(lua_State *L)
  function set_ciphersuites (line 451) | static int set_ciphersuites(lua_State *L)
  function set_depth (line 469) | static int set_depth(lua_State *L)
  function set_verify (line 480) | static int set_verify(lua_State *L)
  function set_options (line 503) | static int set_options(lua_State *L)
  function set_mode (line 529) | static int set_mode(lua_State *L)
  function set_dhparam (line 551) | static int set_dhparam(lua_State *L)
  function set_curve (line 569) | static int set_curve(lua_State *L)
  function set_curves_list (line 604) | static int set_curves_list(lua_State *L)
  function set_alpn (line 629) | static int set_alpn(lua_State *L)
  function alpn_cb (line 651) | static int alpn_cb(SSL *s, const unsigned char **out, unsigned char *out...
  function set_alpn_cb (line 695) | static int set_alpn_cb(lua_State *L)
  function set_dane (line 714) | static int set_dane(lua_State *L)
  function meth_destroy (line 757) | static int meth_destroy(lua_State *L)
  function meth_tostring (line 784) | static int meth_tostring(lua_State *L)
  function meth_set_verify_ext (line 794) | static int meth_set_verify_ext(lua_State *L)
  function SSL_CTX (line 869) | SSL_CTX* lsec_checkcontext(lua_State *L, int idx)
  function SSL_CTX (line 875) | SSL_CTX* lsec_testcontext(lua_State *L, int idx)
  function lsec_getmode (line 884) | int lsec_getmode(lua_State *L, int idx)
  function LSEC_API (line 895) | LSEC_API int luaopen_ssl_context(lua_State *L)

FILE: src/luasec/context.h
  type t_context (line 23) | typedef struct t_context_ {
  type t_context (line 30) | typedef t_context* p_context;

FILE: src/luasec/ec.c
  function EC_KEY (line 7) | EC_KEY *lsec_find_ec_key(lua_State *L, const char *str)
  function lsec_load_curves (line 22) | void lsec_load_curves(lua_State *L)
  function lsec_get_curves (line 80) | void lsec_get_curves(lua_State *L)
  function lsec_load_curves (line 99) | void lsec_load_curves(lua_State *L)
  function lsec_get_curves (line 104) | void lsec_get_curves(lua_State *L)

FILE: src/luasec/options.c
  function LSEC_API (line 182) | LSEC_API lsec_ssl_option_t* lsec_get_ssl_options() {

FILE: src/luasec/options.h
  type lsec_ssl_option_s (line 13) | struct lsec_ssl_option_s {
  type lsec_ssl_option_t (line 18) | typedef struct lsec_ssl_option_s lsec_ssl_option_t;

FILE: src/luasec/ssl.c
  function lsec_socket_error (line 46) | static int lsec_socket_error()
  function meth_destroy (line 86) | static int meth_destroy(lua_State *L)
  function handshake (line 117) | static int handshake(p_ssl ssl)
  function ssl_send (line 159) | static int ssl_send(void *ctx, const char *data, size_t count, size_t *s...
  function ssl_recv (line 203) | static int ssl_recv(void *ctx, char *data, size_t count, size_t *got,
  function SSL_CTX (line 246) | static SSL_CTX* luaossl_testcontext(lua_State *L, int arg) {
  function SSL (line 253) | static SSL* luaossl_testssl(lua_State *L, int arg) {
  function meth_create (line 263) | static int meth_create(lua_State *L)
  function meth_send (line 330) | static int meth_send(lua_State *L) {
  function meth_receive (line 338) | static int meth_receive(lua_State *L) {
  function meth_getstats (line 346) | static int meth_getstats(lua_State *L) {
  function meth_setstats (line 354) | static int meth_setstats(lua_State *L) {
  function meth_getfd (line 362) | static int meth_getfd(lua_State *L)
  function meth_setfd (line 373) | static int meth_setfd(lua_State *L)
  function meth_handshake (line 387) | static int meth_handshake(lua_State *L)
  function meth_close (line 414) | static int meth_close(lua_State *L)
  function meth_settimeout (line 423) | static int meth_settimeout(lua_State *L)
  function meth_dirty (line 432) | static int meth_dirty(lua_State *L)
  function meth_want (line 445) | static int meth_want(lua_State *L)
  function meth_compression (line 463) | static int meth_compression(lua_State *L)
  function meth_getpeercertificate (line 487) | static int meth_getpeercertificate(lua_State *L)
  function meth_getpeerchain (line 536) | static int meth_getpeerchain(lua_State *L)
  function copy_error_table (line 570) | static void copy_error_table(lua_State *L, int src, int dst)
  function meth_getpeerverification (line 591) | static int meth_getpeerverification(lua_State *L)
  function meth_getfinished (line 623) | static int meth_getfinished(lua_State *L)
  function meth_getpeerfinished (line 650) | static int meth_getpeerfinished(lua_State *L)
  function meth_tostring (line 677) | static int meth_tostring(lua_State *L)
  function meth_setmethod (line 688) | static int meth_setmethod(lua_State *L)
  function meth_info (line 702) | static int meth_info(lua_State *L)
  function sni_cb (line 721) | static int sni_cb(SSL *ssl, int *ad, void *arg)
  function meth_sni (line 761) | static int meth_sni(lua_State *L)
  function meth_getsniname (line 803) | static int meth_getsniname(lua_State *L)
  function meth_getalpn (line 814) | static int meth_getalpn(lua_State *L)
  function meth_copyright (line 827) | static int meth_copyright(lua_State *L)
  function meth_dane (line 838) | static int meth_dane(lua_State *L)
  function meth_tlsa (line 847) | static int meth_tlsa(lua_State *L)
  function LSEC_API (line 922) | LSEC_API int luaopen_ssl_core(lua_State *L)
  function LSEC_API (line 964) | LSEC_API int luaopen_ssl(lua_State *L) {

FILE: src/luasec/ssl.h
  type t_ssl (line 28) | typedef struct t_ssl_ {
  type t_ssl (line 37) | typedef t_ssl* p_ssl;

FILE: src/luasec/x509.c
  function lsec_pushx509 (line 47) | void lsec_pushx509(lua_State* L, X509 *cert)
  function X509 (line 59) | X509* lsec_checkx509(lua_State* L, int idx)
  function p_x509 (line 67) | p_x509 lsec_checkp_x509(lua_State* L, int idx)
  type sockaddr (line 88) | struct sockaddr
  type sockaddr_in (line 89) | struct sockaddr_in
  type sockaddr_in6 (line 90) | struct sockaddr_in6
  type in_addr (line 96) | struct in_addr
  type sockaddr (line 97) | struct sockaddr
  type sockaddr_in (line 98) | struct sockaddr_in
  type in6_addr (line 103) | struct in6_addr
  type sockaddr (line 104) | struct sockaddr
  type sockaddr_in6 (line 105) | struct sockaddr_in6
  function to_hex (line 122) | static void to_hex(const char* in, int length, char* out)
  function push_asn1_objname (line 135) | static void push_asn1_objname(lua_State* L, ASN1_OBJECT *object, int no_...
  function push_asn1_string (line 146) | static void push_asn1_string(lua_State* L, ASN1_STRING *string, int encode)
  function push_asn1_time (line 172) | static int push_asn1_time(lua_State *L, const ASN1_UTCTIME *tm)
  function push_asn1_ip (line 187) | static void push_asn1_ip(lua_State *L, ASN1_STRING *string)
  function push_subtable (line 212) | static int push_subtable(lua_State* L, int idx)
  function push_x509_name (line 232) | static int push_x509_name(lua_State* L, X509_NAME *name, int encode)
  function meth_subject (line 260) | static int meth_subject(lua_State* L)
  function meth_issuer (line 269) | static int meth_issuer(lua_State* L)
  function meth_extensions (line 278) | int meth_extensions(lua_State* L)
  function meth_pem (line 381) | static int meth_pem(lua_State* L)
  function meth_pubkey (line 403) | static int meth_pubkey(lua_State* L)
  function meth_digest (line 449) | static int meth_digest(lua_State* L)
  function meth_valid_at (line 486) | static int meth_valid_at(lua_State* L)
  function meth_serial (line 501) | static int meth_serial(lua_State *L)
  function meth_notbefore (line 519) | static int meth_notbefore(lua_State *L)
  function meth_notafter (line 528) | static int meth_notafter(lua_State *L)
  function meth_issued (line 537) | static int meth_issued(lua_State* L)
  function meth_destroy (line 622) | static int meth_destroy(lua_State* L)
  function meth_tostring (line 632) | static int meth_tostring(lua_State *L)
  function meth_set_encode (line 642) | static int meth_set_encode(lua_State* L)
  function meth_get_signature_name (line 661) | static int meth_get_signature_name(lua_State* L)
  function load_cert (line 675) | static int load_cert(lua_State* L)
  function LSEC_API (line 734) | LSEC_API int luaopen_ssl_x509(lua_State *L)

FILE: src/luasec/x509.h
  type t_x509 (line 20) | typedef struct t_x509_ {
  type t_x509 (line 24) | typedef t_x509* p_x509;

FILE: src/luasocket/auxiliar.c
  function auxiliar_open (line 13) | int auxiliar_open(lua_State *L) {
  function auxiliar_newclass (line 22) | void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *fu...
  function auxiliar_tostring (line 45) | int auxiliar_tostring(lua_State *L) {
  function auxiliar_add2group (line 66) | void auxiliar_add2group(lua_State *L, const char *classname, const char ...
  function auxiliar_checkboolean (line 77) | int auxiliar_checkboolean(lua_State *L, int objidx) {
  function auxiliar_setclass (line 114) | void auxiliar_setclass(lua_State *L, const char *classname, int objidx) {
  function auxiliar_typeerror (line 150) | int auxiliar_typeerror (lua_State *L, int narg, const char *tname) {

FILE: src/luasocket/buffer.c
  function buffer_open (line 32) | int buffer_open(lua_State *L) {
  function buffer_init (line 40) | void buffer_init(p_buffer buf, p_io io, p_timeout tm) {
  function buffer_meth_getstats (line 51) | int buffer_meth_getstats(lua_State *L, p_buffer buf) {
  function buffer_meth_setstats (line 61) | int buffer_meth_setstats(lua_State *L, p_buffer buf) {
  function buffer_meth_send (line 72) | int buffer_meth_send(lua_State *L, p_buffer buf) {
  function buffer_meth_receive (line 105) | int buffer_meth_receive(lua_State *L, p_buffer buf) {
  function buffer_isempty (line 154) | int buffer_isempty(p_buffer buf) {
  function sendraw (line 165) | static int sendraw(p_buffer buf, const char *data, size_t count, size_t ...
  function recvraw (line 184) | static int recvraw(p_buffer buf, size_t wanted, luaL_Buffer *b) {
  function recvall (line 202) | static int recvall(p_buffer buf, luaL_Buffer *b) {
  function recvline (line 222) | static int recvline(p_buffer buf, luaL_Buffer *b) {
  function buffer_skip (line 246) | static void buffer_skip(p_buffer buf, size_t count) {
  function buffer_get (line 257) | static int buffer_get(p_buffer buf, const char **data, size_t *count) {

FILE: src/luasocket/buffer.h
  type t_buffer (line 26) | typedef struct t_buffer_ {
  type t_buffer (line 34) | typedef t_buffer *p_buffer;

FILE: src/luasocket/compat.c
  function luasocket_setfuncs (line 9) | void luasocket_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {

FILE: src/luasocket/except.c
  type lua_KContext (line 15) | typedef int lua_KContext;
  function wrap (line 37) | static void wrap(lua_State *L) {
  function finalize (line 45) | static int finalize(lua_State *L) {
  function do_nothing (line 56) | static int do_nothing(lua_State *L) {
  function global_newtry (line 61) | static int global_newtry(lua_State *L) {
  function unwrap (line 73) | static int unwrap(lua_State *L) {
  function protected_finish (line 86) | static int protected_finish(lua_State *L, int status, lua_KContext ctx) {
  function protected_cont (line 95) | static int protected_cont(lua_State *L) {
  function protected_ (line 104) | static int protected_(lua_State *L) {
  function global_protect (line 112) | static int global_protect(lua_State *L) {
  function except_open (line 123) | int except_open(lua_State *L) {

FILE: src/luasocket/inet.c
  type hostent (line 20) | struct hostent
  function inet_open (line 36) | int inet_open(lua_State *L)
  function inet_gethost (line 52) | static int inet_gethost(const char *address, struct hostent **hp) {
  function inet_global_tohostname (line 64) | static int inet_global_tohostname(lua_State *L) {
  function inet_global_getnameinfo (line 82) | static int inet_global_getnameinfo(lua_State *L) {
  function inet_global_toip (line 134) | static int inet_global_toip(lua_State *L)
  function inet_optfamily (line 153) | int inet_optfamily(lua_State* L, int narg, const char* def)
  function inet_optsocktype (line 161) | int inet_optsocktype(lua_State* L, int narg, const char* def)
  function inet_global_getaddrinfo (line 169) | static int inet_global_getaddrinfo(lua_State *L)
  function inet_global_gethostname (line 232) | static int inet_global_gethostname(lua_State *L)
  function inet_meth_getpeername (line 252) | int inet_meth_getpeername(lua_State *L, p_socket ps, int family)
  function inet_meth_getsockname (line 286) | int inet_meth_getsockname(lua_State *L, p_socket ps, int family)
  function inet_pushresolved (line 322) | static void inet_pushresolved(lua_State *L, struct hostent *hp)
  type sockaddr_in (line 378) | struct sockaddr_in
  type sockaddr_in6 (line 386) | struct sockaddr_in6
  type in6_addr (line 387) | struct in6_addr
  type addrinfo (line 402) | struct addrinfo
  type addrinfo (line 404) | struct addrinfo
  type sockaddr_in6 (line 452) | struct sockaddr_in6
  type sockaddr_in (line 453) | struct sockaddr_in
  type addrinfo (line 464) | struct addrinfo
  type addrinfo (line 465) | struct addrinfo
  function inet_aton (line 507) | int inet_aton(const char *cp, struct in_addr *inp)
  function inet_pton (line 529) | int inet_pton(int af, const char *src, void *dst)

FILE: src/luasocket/inet.h
  type addrinfo (line 39) | struct addrinfo
  type addrinfo (line 41) | struct addrinfo
  type in_addr (line 44) | struct in_addr

FILE: src/luasocket/io.c
  function io_init (line 11) | void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx) {

FILE: src/luasocket/io.h
  type t_io (line 51) | typedef struct t_io_ {
  type t_io (line 57) | typedef t_io *p_io;

FILE: src/luasocket/luasocket.c
  function global_skip (line 56) | static int global_skip(lua_State *L) {
  function global_unload (line 65) | static int global_unload(lua_State *L) {
  function base_open (line 74) | static int base_open(lua_State *L) {
  function LUASOCKET_API (line 99) | LUASOCKET_API int luaopen_socket_core(lua_State *L) {

FILE: src/luasocket/mime.c
  type UC (line 13) | typedef unsigned char UC;
  function LUASOCKET_API (line 170) | LUASOCKET_API int luaopen_mime_core(lua_State *L)
  function mime_global_wrp (line 196) | static int mime_global_wrp(lua_State *L)
  function b64setup (line 242) | static void b64setup(UC *unbase)
  function b64encode (line 262) | static size_t b64encode(UC c, UC *input, size_t size,
  function b64pad (line 287) | static size_t b64pad(const UC *input, size_t size,
  function b64decode (line 318) | static size_t b64decode(UC c, UC *input, size_t size,
  function mime_global_b64 (line 352) | static int mime_global_b64(lua_State *L)
  function mime_global_unb64 (line 398) | static int mime_global_unb64(lua_State *L)
  function qpsetup (line 454) | static void qpsetup(UC *cl, UC *unbase)
  function qpquote (line 508) | static void qpquote(UC c, luaL_Buffer *buffer)
  function qpencode (line 519) | static size_t qpencode(UC c, UC *input, size_t size,
  function qppad (line 562) | static size_t qppad(UC *input, size_t size, luaL_Buffer *buffer)
  function mime_global_qp (line 581) | static int mime_global_qp(lua_State *L)
  function qpdecode (line 623) | static size_t qpdecode(UC c, UC *input, size_t size, luaL_Buffer *buffer) {
  function mime_global_unqp (line 657) | static int mime_global_unqp(lua_State *L)
  function mime_global_qpwrp (line 702) | static int mime_global_qpwrp(lua_State *L)
  function eolprocess (line 763) | static int eolprocess(int c, int last, const char *marker,
  function mime_global_eol (line 787) | static int mime_global_eol(lua_State *L)
  function dot (line 813) | static size_t dot(int c, size_t state, luaL_Buffer *buffer)
  function mime_global_dot (line 834) | static int mime_global_dot(lua_State *L)

FILE: src/luasocket/options.c
  function opt_meth_setoption (line 31) | int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps)
  function opt_meth_getoption (line 44) | int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps)
  function opt_set_reuseaddr (line 59) | int opt_set_reuseaddr(lua_State *L, p_socket ps)
  function opt_get_reuseaddr (line 64) | int opt_get_reuseaddr(lua_State *L, p_socket ps)
  function opt_set_reuseport (line 71) | int opt_set_reuseport(lua_State *L, p_socket ps)
  function opt_get_reuseport (line 76) | int opt_get_reuseport(lua_State *L, p_socket ps)
  function opt_set_tcp_nodelay (line 83) | int opt_set_tcp_nodelay(lua_State *L, p_socket ps)
  function opt_get_tcp_nodelay (line 88) | int opt_get_tcp_nodelay(lua_State *L, p_socket ps)
  function opt_get_tcp_keepidle (line 96) | int opt_get_tcp_keepidle(lua_State *L, p_socket ps)
  function opt_set_tcp_keepidle (line 101) | int opt_set_tcp_keepidle(lua_State *L, p_socket ps)
  function opt_get_tcp_keepcnt (line 111) | int opt_get_tcp_keepcnt(lua_State *L, p_socket ps)
  function opt_set_tcp_keepcnt (line 116) | int opt_set_tcp_keepcnt(lua_State *L, p_socket ps)
  function opt_get_tcp_keepintvl (line 126) | int opt_get_tcp_keepintvl(lua_State *L, p_socket ps)
  function opt_set_tcp_keepintvl (line 131) | int opt_set_tcp_keepintvl(lua_State *L, p_socket ps)
  function opt_set_keepalive (line 139) | int opt_set_keepalive(lua_State *L, p_socket ps)
  function opt_get_keepalive (line 144) | int opt_get_keepalive(lua_State *L, p_socket ps)
  function opt_set_dontroute (line 150) | int opt_set_dontroute(lua_State *L, p_socket ps)
  function opt_get_dontroute (line 155) | int opt_get_dontroute(lua_State *L, p_socket ps)
  function opt_set_broadcast (line 161) | int opt_set_broadcast(lua_State *L, p_socket ps)
  function opt_get_broadcast (line 166) | int opt_get_broadcast(lua_State *L, p_socket ps)
  function opt_set_recv_buf_size (line 172) | int opt_set_recv_buf_size(lua_State *L, p_socket ps)
  function opt_get_recv_buf_size (line 177) | int opt_get_recv_buf_size(lua_State *L, p_socket ps)
  function opt_get_send_buf_size (line 183) | int opt_get_send_buf_size(lua_State *L, p_socket ps)
  function opt_set_send_buf_size (line 188) | int opt_set_send_buf_size(lua_State *L, p_socket ps)
  function opt_set_ip6_unicast_hops (line 194) | int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps)
  function opt_get_ip6_unicast_hops (line 199) | int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps)
  function opt_set_ip6_multicast_hops (line 205) | int opt_set_ip6_multicast_hops(lua_State *L, p_socket ps)
  function opt_get_ip6_multicast_hops (line 210) | int opt_get_ip6_multicast_hops(lua_State *L, p_socket ps)
  function opt_set_ip_multicast_loop (line 216) | int opt_set_ip_multicast_loop(lua_State *L, p_socket ps)
  function opt_get_ip_multicast_loop (line 221) | int opt_get_ip_multicast_loop(lua_State *L, p_socket ps)
  function opt_set_ip6_multicast_loop (line 227) | int opt_set_ip6_multicast_loop(lua_State *L, p_socket ps)
  function opt_get_ip6_multicast_loop (line 232) | int opt_get_ip6_multicast_loop(lua_State *L, p_socket ps)
  function opt_set_linger (line 238) | int opt_set_linger(lua_State *L, p_socket ps)
  function opt_get_linger (line 255) | int opt_get_linger(lua_State *L, p_socket ps)
  function opt_set_ip_multicast_ttl (line 271) | int opt_set_ip_multicast_ttl(lua_State *L, p_socket ps)
  function opt_set_ip_multicast_if (line 277) | int opt_set_ip_multicast_if(lua_State *L, p_socket ps)
  function opt_get_ip_multicast_if (line 288) | int opt_get_ip_multicast_if(lua_State *L, p_socket ps)
  function opt_set_ip_add_membership (line 302) | int opt_set_ip_add_membership(lua_State *L, p_socket ps)
  function opt_set_ip_drop_membersip (line 307) | int opt_set_ip_drop_membersip(lua_State *L, p_socket ps)
  function opt_set_ip6_add_membership (line 313) | int opt_set_ip6_add_membership(lua_State *L, p_socket ps)
  function opt_set_ip6_drop_membersip (line 318) | int opt_set_ip6_drop_membersip(lua_State *L, p_socket ps)
  function opt_get_ip6_v6only (line 323) | int opt_get_ip6_v6only(lua_State *L, p_socket ps)
  function opt_set_ip6_v6only (line 328) | int opt_set_ip6_v6only(lua_State *L, p_socket ps)
  function opt_get_error (line 334) | int opt_get_error(lua_State *L, p_socket ps)
  function opt_setmembership (line 350) | static int opt_setmembership(lua_State *L, p_socket ps, int level, int n...
  function opt_ip6_setmembership (line 371) | static int opt_ip6_setmembership(lua_State *L, p_socket ps, int level, i...
  function opt_get (line 397) | static
  function opt_set (line 410) | static
  function opt_getboolean (line 422) | static int opt_getboolean(lua_State *L, p_socket ps, int level, int name)
  function opt_setboolean (line 433) | static int opt_setboolean(lua_State *L, p_socket ps, int level, int name)
  function opt_getint (line 439) | static int opt_getint(lua_State *L, p_socket ps, int level, int name)
  function opt_setint (line 450) | static int opt_setint(lua_State *L, p_socket ps, int level, int name)

FILE: src/luasocket/options.h
  type t_opt (line 15) | typedef struct t_opt {
  type t_opt (line 19) | typedef t_opt *p_opt;

FILE: src/luasocket/select.c
  function select_open (line 35) | int select_open(lua_State *L) {
  function global_select (line 52) | static int global_select(lua_State *L) {
  function t_socket (line 88) | static t_socket getfd(lua_State *L) {
  function dirty (line 104) | static int dirty(lua_State *L) {
  function collect_fd (line 117) | static void collect_fd(lua_State *L, int tab, int itab,
  function check_dirty (line 158) | static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set) {
  function return_fd (line 183) | static void return_fd(lua_State *L, fd_set *set, t_socket max_fd,
  function make_assoc (line 196) | static void make_assoc(lua_State *L, int tab) {

FILE: src/luasocket/serial.c
  function LUASOCKET_API (line 59) | LUASOCKET_API int luaopen_socket_serial(lua_State *L) {
  function meth_send (line 74) | static int meth_send(lua_State *L) {
  function meth_receive (line 79) | static int meth_receive(lua_State *L) {
  function meth_getstats (line 84) | static int meth_getstats(lua_State *L) {
  function meth_setstats (line 89) | static int meth_setstats(lua_State *L) {
  function meth_getfd (line 97) | static int meth_getfd(lua_State *L) {
  function meth_setfd (line 104) | static int meth_setfd(lua_State *L) {
  function meth_dirty (line 110) | static int meth_dirty(lua_State *L) {
  function meth_close (line 119) | static int meth_close(lua_State *L)
  function meth_settimeout (line 131) | static int meth_settimeout(lua_State *L) {
  function global_create (line 144) | static int global_create(lua_State *L) {

FILE: src/luasocket/socket.h
  type SA (line 32) | typedef struct sockaddr SA;
  type hostent (line 62) | struct hostent
  type hostent (line 63) | struct hostent

FILE: src/luasocket/tcp.c
  function tcp_open (line 128) | int tcp_open(lua_State *L)
  function meth_send (line 149) | static int meth_send(lua_State *L) {
  function meth_receive (line 154) | static int meth_receive(lua_State *L) {
  function meth_getstats (line 159) | static int meth_getstats(lua_State *L) {
  function meth_setstats (line 164) | static int meth_setstats(lua_State *L) {
  function meth_getoption (line 172) | static int meth_getoption(lua_State *L)
  function meth_setoption (line 178) | static int meth_setoption(lua_State *L)
  function meth_getfd (line 187) | static int meth_getfd(lua_State *L)
  function meth_setfd (line 195) | static int meth_setfd(lua_State *L)
  function meth_dirty (line 202) | static int meth_dirty(lua_State *L)
  function meth_accept (line 213) | static int meth_accept(lua_State *L)
  function meth_bind (line 244) | static int meth_bind(lua_State *L) {
  function meth_connect (line 271) | static int meth_connect(lua_State *L) {
  function meth_close (line 302) | static int meth_close(lua_State *L)
  function meth_getfamily (line 313) | static int meth_getfamily(lua_State *L)
  function meth_listen (line 331) | static int meth_listen(lua_State *L)
  function meth_shutdown (line 351) | static int meth_shutdown(lua_State *L)
  function meth_getpeername (line 365) | static int meth_getpeername(lua_State *L)
  function meth_getsockname (line 372) | static int meth_getsockname(lua_State *L)
  function meth_settimeout (line 382) | static int meth_settimeout(lua_State *L)
  function meth_gettimeout (line 388) | static int meth_gettimeout(lua_State *L)
  function tcp_create (line 400) | static int tcp_create(lua_State *L, int family) {
  function global_create (line 426) | static int global_create(lua_State *L) {
  function global_create4 (line 430) | static int global_create4(lua_State *L) {
  function global_create6 (line 434) | static int global_create6(lua_State *L) {
  function global_connect (line 438) | static int global_connect(lua_State *L) {

FILE: src/luasocket/tcp.h
  type t_tcp (line 23) | typedef struct t_tcp_ {
  type t_tcp (line 31) | typedef t_tcp *p_tcp;

FILE: src/luasocket/timeout.c
  function timeout_init (line 47) | void timeout_init(p_timeout tm, double block, double total) {
  function timeout_get (line 60) | double timeout_get(p_timeout tm) {
  function timeout_getstart (line 81) | double timeout_getstart(p_timeout tm) {
  function timeout_getretry (line 93) | double timeout_getretry(p_timeout tm) {
  function p_timeout (line 113) | p_timeout timeout_markstart(p_timeout tm) {
  function timeout_gettime (line 124) | double timeout_gettime(void) {
  function timeout_gettime (line 134) | double timeout_gettime(void) {
  function timeout_open (line 145) | int timeout_open(lua_State *L) {
  function timeout_meth_settimeout (line 156) | int timeout_meth_settimeout(lua_State *L, p_timeout tm) {
  function timeout_meth_gettimeout (line 178) | int timeout_meth_gettimeout(lua_State *L, p_timeout tm) {
  function timeout_lua_gettime (line 190) | static int timeout_lua_gettime(lua_State *L)
  function timeout_lua_sleep (line 200) | int timeout_lua_sleep(lua_State *L)
  function timeout_lua_sleep (line 210) | int timeout_lua_sleep(lua_State *L)

FILE: src/luasocket/timeout.h
  type t_timeout (line 10) | typedef struct t_timeout_ {
  type t_timeout (line 15) | typedef t_timeout *p_timeout;

FILE: src/luasocket/udp.c
  function udp_open (line 123) | int udp_open(lua_State *L) {
  function meth_send (line 154) | static int meth_send(lua_State *L) {
  function meth_sendto (line 174) | static int meth_sendto(lua_State *L) {
  function meth_receive (line 234) | static int meth_receive(lua_State *L) {
  function meth_receivefrom (line 263) | static int meth_receivefrom(lua_State *L) {
  function meth_getfamily (line 307) | static int meth_getfamily(lua_State *L) {
  function meth_getfd (line 321) | static int meth_getfd(lua_State *L) {
  function meth_setfd (line 328) | static int meth_setfd(lua_State *L) {
  function meth_dirty (line 334) | static int meth_dirty(lua_State *L) {
  function meth_getpeername (line 344) | static int meth_getpeername(lua_State *L) {
  function meth_getsockname (line 349) | static int meth_getsockname(lua_State *L) {
  function meth_setoption (line 357) | static int meth_setoption(lua_State *L) {
  function meth_getoption (line 365) | static int meth_getoption(lua_State *L) {
  function meth_settimeout (line 373) | static int meth_settimeout(lua_State *L) {
  function meth_gettimeout (line 378) | static int meth_gettimeout(lua_State *L) {
  function meth_setpeername (line 386) | static int meth_setpeername(lua_State *L) {
  function meth_close (line 420) | static int meth_close(lua_State *L) {
  function meth_setsockname (line 430) | static int meth_setsockname(lua_State *L) {
  function udp_create (line 456) | static int udp_create(lua_State *L, int family) {
  function global_create (line 478) | static int global_create(lua_State *L) {
  function global_create4 (line 482) | static int global_create4(lua_State *L) {
  function global_create6 (line 486) | static int global_create6(lua_State *L) {

FILE: src/luasocket/udp.h
  type t_udp (line 22) | typedef struct t_udp_ {
  type t_udp (line 27) | typedef t_udp *p_udp;

FILE: src/luasocket/unix.c
  function add_alias (line 19) | static void add_alias(lua_State *L, int index, const char *name, const c...
  function compat_socket_unix_call (line 25) | static int compat_socket_unix_call(lua_State *L)
  function LUASOCKET_API (line 47) | LUASOCKET_API int luaopen_socket_unix(lua_State *L)

FILE: src/luasocket/unix.h
  type t_unix (line 16) | typedef struct t_unix_ {
  type t_unix (line 22) | typedef t_unix *p_unix;

FILE: src/luasocket/unixdgram.c
  function unixdgram_open (line 86) | int unixdgram_open(lua_State *L)
  function meth_send (line 112) | static int meth_send(lua_State *L)
  function meth_sendto (line 133) | static int meth_sendto(lua_State *L)
  function meth_receive (line 171) | static int meth_receive(lua_State *L) {
  function meth_receivefrom (line 200) | static int meth_receivefrom(lua_State *L) {
  function meth_setoption (line 236) | static int meth_setoption(lua_State *L) {
  function meth_getfd (line 244) | static int meth_getfd(lua_State *L) {
  function meth_setfd (line 251) | static int meth_setfd(lua_State *L) {
  function meth_dirty (line 257) | static int meth_dirty(lua_State *L) {
  type sockaddr_un (line 268) | struct sockaddr_un
  function meth_bind (line 283) | static int meth_bind(lua_State *L)
  function meth_getsockname (line 297) | static int meth_getsockname(lua_State *L)
  type sockaddr_un (line 318) | struct sockaddr_un
  function meth_connect (line 334) | static int meth_connect(lua_State *L)
  function meth_close (line 353) | static int meth_close(lua_State *L)
  function meth_settimeout (line 364) | static int meth_settimeout(lua_State *L)
  function meth_gettimeout (line 370) | static int meth_gettimeout(lua_State *L)
  function global_create (line 382) | static int global_create(lua_State *L)

FILE: src/luasocket/unixstream.c
  function unixstream_open (line 81) | int unixstream_open(lua_State *L)
  function meth_send (line 103) | static int meth_send(lua_State *L) {
  function meth_receive (line 108) | static int meth_receive(lua_State *L) {
  function meth_getstats (line 113) | static int meth_getstats(lua_State *L) {
  function meth_setstats (line 118) | static int meth_setstats(lua_State *L) {
  function meth_setoption (line 126) | static int meth_setoption(lua_State *L) {
  function meth_getfd (line 134) | static int meth_getfd(lua_State *L) {
  function meth_setfd (line 141) | static int meth_setfd(lua_State *L) {
  function meth_dirty (line 147) | static int meth_dirty(lua_State *L) {
  function meth_accept (line 157) | static int meth_accept(lua_State *L) {
  type sockaddr_un (line 185) | struct sockaddr_un
  function meth_bind (line 205) | static int meth_bind(lua_State *L) {
  function meth_getsockname (line 218) | static int meth_getsockname(lua_State *L)
  type sockaddr_un (line 239) | struct sockaddr_un
  function meth_connect (line 259) | static int meth_connect(lua_State *L)
  function meth_close (line 278) | static int meth_close(lua_State *L)
  function meth_listen (line 289) | static int meth_listen(lua_State *L)
  function meth_shutdown (line 308) | static int meth_shutdown(lua_State *L)
  function meth_settimeout (line 322) | static int meth_settimeout(lua_State *L) {
  function global_create (line 333) | static int global_create(lua_State *L) {

FILE: src/luasocket/usocket.c
  function socket_waitfd (line 27) | int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
  function socket_waitfd (line 49) | int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
  function socket_open (line 81) | int socket_open(void) {
  function socket_close (line 90) | int socket_close(void) {
  function socket_destroy (line 97) | void socket_destroy(p_socket ps) {
  function socket_select (line 107) | int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds,
  function socket_create (line 124) | int socket_create(p_socket ps, int domain, int type, int protocol) {
  function socket_bind (line 133) | int socket_bind(p_socket ps, SA *addr, socklen_t len) {
  function socket_listen (line 148) | int socket_listen(p_socket ps, int backlog) {
  function socket_shutdown (line 157) | void socket_shutdown(p_socket ps, int how) {
  function socket_connect (line 164) | int socket_connect(p_socket ps, SA *addr, socklen_t len, p_timeout tm) {
  function socket_accept (line 190) | int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *len, p_...
  function socket_send (line 207) | int socket_send(p_socket ps, const char *data, size_t count,
  function socket_sendto (line 241) | int socket_sendto(p_socket ps, const char *data, size_t count, size_t *s...
  function socket_recv (line 266) | int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_ti...
  function socket_recvfrom (line 288) | int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got,
  function socket_write (line 316) | int socket_write(p_socket ps, const char *data, size_t count,
  function socket_read (line 351) | int socket_read(p_socket ps, char *data, size_t count, size_t *got, p_ti...
  function socket_setblocking (line 373) | void socket_setblocking(p_socket ps) {
  function socket_setnonblocking (line 382) | void socket_setnonblocking(p_socket ps) {
  function socket_gethostbyaddr (line 391) | int socket_gethostbyaddr(const char *addr, socklen_t len, struct hostent...
  function socket_gethostbyname (line 399) | int socket_gethostbyname(const char *addr, struct hostent **hp) {

FILE: src/luasocket/usocket.h
  type t_socket (line 58) | typedef int t_socket;
  type t_socket (line 59) | typedef t_socket *p_socket;
  type t_sockaddr_storage (line 60) | typedef struct sockaddr_storage t_sockaddr_storage;

FILE: src/luasocket/wsocket.c
  function socket_open (line 21) | int socket_open(void) {
  function socket_close (line 37) | int socket_close(void) {
  function socket_waitfd (line 50) | int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
  function socket_select (line 78) | int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds,
  function socket_destroy (line 93) | void socket_destroy(p_socket ps) {
  function socket_shutdown (line 104) | void socket_shutdown(p_socket ps, int how) {
  function socket_create (line 113) | int socket_create(p_socket ps, int domain, int type, int protocol) {
  function socket_connect (line 122) | int socket_connect(p_socket ps, SA *addr, socklen_t len, p_timeout tm) {
  function socket_bind (line 151) | int socket_bind(p_socket ps, SA *addr, socklen_t len) {
  function socket_listen (line 162) | int socket_listen(p_socket ps, int backlog) {
  function socket_accept (line 173) | int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *len,
  function socket_send (line 195) | int socket_send(p_socket ps, const char *data, size_t count,
  function socket_sendto (line 223) | int socket_sendto(p_socket ps, const char *data, size_t count, size_t *s...
  function socket_recv (line 244) | int socket_recv(p_socket ps, char *data, size_t count, size_t *got,
  function socket_recvfrom (line 273) | int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got,
  function socket_setblocking (line 302) | void socket_setblocking(p_socket ps) {
  function socket_setnonblocking (line 310) | void socket_setnonblocking(p_socket ps) {
  function socket_gethostbyaddr (line 318) | int socket_gethostbyaddr(const char *addr, socklen_t len, struct hostent...
  function socket_gethostbyname (line 324) | int socket_gethostbyname(const char *addr, struct hostent **hp) {

FILE: src/luasocket/wsocket.h
  type socklen_t (line 14) | typedef int socklen_t;
  type SOCKADDR_STORAGE (line 15) | typedef SOCKADDR_STORAGE t_sockaddr_storage;
  type SOCKET (line 16) | typedef SOCKET t_socket;
  type t_socket (line 17) | typedef t_socket *p_socket;

FILE: src/lundump.c
  type LoadState (line 23) | typedef struct {
  function error (line 36) | static void error(LoadState* S, const char* why)
  function LoadBlock (line 48) | static void LoadBlock(LoadState* S, void* b, size_t size)
  function LoadChar (line 54) | static int LoadChar(LoadState* S)
  function LoadInt (line 61) | static int LoadInt(LoadState* S)
  function lua_Number (line 69) | static lua_Number LoadNumber(LoadState* S)
  function TString (line 76) | static TString* LoadString(LoadState* S)
  function LoadCode (line 90) | static void LoadCode(LoadState* S, Proto* f)
  function LoadConstants (line 100) | static void LoadConstants(LoadState* S, Proto* f)
  function LoadDebug (line 137) | static void LoadDebug(LoadState* S, Proto* f)
  function Proto (line 161) | static Proto* LoadFunction(LoadState* S, TString* p)
  function LoadHeader (line 183) | static void LoadHeader(LoadState* S)
  function Proto (line 195) | Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
  function luaU_header (line 214) | void luaU_header (char* h)

FILE: src/lvm.c
  function TValue (line 35) | const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
  function luaV_tostring (line 47) | int luaV_tostring (lua_State *L, StkId obj) {
  function traceexec (line 60) | static void traceexec (lua_State *L, const Instruction *pc) {
  function callTMres (line 80) | static void callTMres (lua_State *L, StkId res, const TValue *f,
  function callTM (line 96) | static void callTM (lua_State *L, const TValue *f, const TValue *p1,
  function luaV_gettable (line 108) | void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId va...
  function luaV_settable (line 134) | void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId va...
  function call_binTM (line 165) | static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,
  function TValue (line 176) | static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2,
  function call_orderTM (line 190) | static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,
  function l_strcmp (line 203) | static int l_strcmp (const TString *ls, const TString *rs) {
  function luaV_lessthan (line 225) | int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
  function lessequal (line 239) | static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
  function luaV_equalval (line 255) | int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
  function luaV_concat (line 282) | void luaV_concat (lua_State *L, int total, int last) {
  function Arith (line 317) | static void Arith (lua_State *L, StkId ra, const TValue *rb,
  function luaV_execute (line 377) | void luaV_execute (lua_State *L, int nexeccalls) {

FILE: src/lzio.c
  function luaZ_fill (line 21) | int luaZ_fill (ZIO *z) {
  function luaZ_lookahead (line 35) | int luaZ_lookahead (ZIO *z) {
  function luaZ_init (line 48) | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
  function luaZ_read (line 58) | size_t luaZ_read (ZIO *z, void *b, size_t n) {

FILE: src/lzio.h
  type ZIO (line 18) | typedef struct Zio ZIO;
  type Mbuffer (line 24) | typedef struct Mbuffer {
  type Zio (line 56) | struct Zio {

FILE: src/realpath.c
  type stat (line 52) | struct stat

FILE: src/teliva.c
  function starts_with (line 22) | int starts_with(const char* s, const char* prefix) {
  function contains (line 26) | int contains(const char* s, const char* sub) {
  function any_equal (line 30) | int any_equal(char* const* arr, const char* s) {
  function any_starts_with (line 37) | int any_starts_with(char* const* arr, const char* s) {
  function draw_string_on_menu (line 48) | void draw_string_on_menu(const char* s) {
  function draw_menu_item (line 57) | void draw_menu_item(const char* key, const char* name) {
  function draw_menu (line 90) | static void draw_menu(lua_State* L) {
  function render_permissions (line 142) | static void render_permissions(lua_State* L) {
  function render_trusted_teliva_data (line 166) | void render_trusted_teliva_data(lua_State* L) {
  function render_wrapped_text (line 183) | static int render_wrapped_text(int y, int xmin, int xmax, const char* te...
  function render_previous_error (line 207) | void render_previous_error(void) {
  function report_in_developer_mode (line 215) | int report_in_developer_mode(lua_State* L, int status) {
  function big_picture_menu (line 236) | static void big_picture_menu(void) {
  function is_current_definition (line 252) | static int is_current_definition(lua_State* L, const char* definition_na...
  function draw_definition_name (line 282) | void draw_definition_name(const char* definition_name) {
  function draw_highlighted_definition_name (line 291) | void draw_highlighted_definition_name(const char* definition_name) {
  function save_call_graph_depth (line 300) | void save_call_graph_depth(lua_State* L, int depth, const char* name) {
  function precompute_names_of_globals (line 341) | static void precompute_names_of_globals(lua_State* L) {
  function save_caller (line 359) | static void save_caller(lua_State* L, const char* name, const char* call...
  function record_metadata_about_function_call (line 382) | void record_metadata_about_function_call (lua_State *L, CallInfo *ci) {
  function clear_caller (line 397) | static void clear_caller(lua_State* L) {
  function default_big_picture_view (line 418) | void default_big_picture_view(lua_State* L) {
  function big_picture_view (line 688) | void big_picture_view(lua_State* L) {
  function editor_view_in_progress (line 706) | int editor_view_in_progress(lua_State* L) {
  function draw_current_definition_name_and_callers (line 723) | void draw_current_definition_name_and_callers(lua_State* L) {
  function restore_editor_view (line 749) | int restore_editor_view(lua_State* L) {
  function developer_mode (line 791) | void developer_mode(lua_State* L) {
  function save_editor_state (line 815) | void save_editor_state(int rowoff, int coloff, int cy, int cx) {
  function look_up_definition (line 839) | static int look_up_definition (lua_State* L, const char* name) {
  function save_to_current_definition_and_editor_buffer (line 868) | void save_to_current_definition_and_editor_buffer(lua_State* L, const ch...
  function read_editor_buffer (line 891) | static void read_editor_buffer(char* out, int capacity) {
  function update_definition (line 897) | static void update_definition(lua_State* L, const char* name, char* new_...
  function load_editor_buffer_to_current_definition_in_image (line 927) | void load_editor_buffer_to_current_definition_in_image(lua_State* L) {
  function load_editor_buffer_to_current_definition_in_image_and_reload (line 935) | int load_editor_buffer_to_current_definition_in_image_and_reload(lua_Sta...
  function edit_current_definition (line 947) | static int edit_current_definition(lua_State* L) {
  function recent_changes_menu (line 973) | static void recent_changes_menu(int cursor, int history_array_size) {
  function render_wrapped_lua_text (line 1015) | static int render_wrapped_lua_text(int y, int xmin, int xmax, const char...
  function render_recent_changes (line 1042) | static void render_recent_changes(lua_State* L, int start_index) {
  function add_undo_event (line 1111) | static void add_undo_event(lua_State* L, int cursor) {
  function save_note_to_editor_buffer (line 1132) | static void save_note_to_editor_buffer(lua_State* L, int cursor) {
  function load_note_from_editor_buffer (line 1153) | static void load_note_from_editor_buffer(lua_State* L, int cursor) {
  function recent_changes_view (line 1164) | static void recent_changes_view(lua_State* L) {
  function binding_exists (line 1207) | static int binding_exists (lua_State *L, const char *name) {
  function load_definitions (line 1216) | static int load_definitions(lua_State* L) {
  function run_tests (line 1250) | static int run_tests(lua_State* L) {
  function clear_call_graph_depth (line 1306) | static void clear_call_graph_depth(lua_State* L) {
  function isarg (line 1327) | static int isarg(lua_State* trustedL) {
  function inarg (line 1333) | static int inarg(lua_State* trustedL) {
  function initialize_trustedL (line 1344) | void initialize_trustedL() {
  function file_operation_permitted_manually (line 1370) | static int file_operation_permitted_manually(const char* filename, const...
  function file_operation_permitted_automatically (line 1391) | static int file_operation_permitted_automatically(const char* filename, ...
  function file_operation_permitted (line 1410) | int file_operation_permitted(const char* filename, const char* mode) {
  function permissions_menu (line 1417) | static void permissions_menu() {
  function characterize_file_operations_predicate (line 1435) | void characterize_file_operations_predicate() {
  function render_permissions_screen (line 1489) | static void render_permissions_screen() {
  function validate_file_operations_predicate (line 1592) | int validate_file_operations_predicate() {
  function load_file_operations_predicate (line 1607) | static int load_file_operations_predicate(const char* body) {
  function edit_file_operations_predicate_body (line 1621) | static void edit_file_operations_predicate_body() {
  function print_file_permission_suggestions (line 1663) | void print_file_permission_suggestions(int row) {
  function permissions_view (line 1676) | static void permissions_view() {
  function save_permissions_to_user_configuration (line 1697) | static void save_permissions_to_user_configuration(lua_State* L) {
  function load_permissions_from_user_configuration (line 1745) | static void load_permissions_from_user_configuration(lua_State* L) {
  function permissions_mode (line 1798) | void permissions_mode(lua_State* L) {
  type AuditEvent (line 1824) | typedef struct {
  function append_to_audit_log (line 1834) | void append_to_audit_log(lua_State* L, const char* buffer) {
  function events_menu (line 1851) | static void events_menu() {
  function render_event (line 1862) | static void render_event(int i, int y, int cursor) {
  function render_events (line 1871) | static void render_events(int cursor) {
  function load_image (line 1921) | int load_image(lua_State* L, char** argv, int n) {

FILE: src/teliva.h
  type KEY_ACTION (line 9) | enum KEY_ACTION {
  type color (line 60) | enum color {
  type color (line 83) | enum color {
  type color (line 106) | enum color {
  type color_pair (line 129) | enum color_pair {

FILE: src/tlv.c
  function teliva_load_multiline_string (line 25) | static void teliva_load_multiline_string(lua_State* L, FILE* in, char* l...
  function teliva_load_definition (line 58) | void teliva_load_definition(lua_State* L, FILE* in) {
  function load_tlv (line 104) | void load_tlv(lua_State* L, char* filename) {
  function emit_multiline_string (line 122) | void emit_multiline_string(FILE* out, const char* value) {
  function save_tlv_key (line 141) | static void save_tlv_key(lua_State* L, const char* key, FILE* out) {
  function save_tlv (line 156) | void save_tlv(lua_State* L, char* filename) {
  function is_special_history_key (line 216) | int is_special_history_key(const char* key) {
Condensed preview — 169 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,792K chars).
[
  {
    "path": ".gitattributes",
    "chars": 59,
    "preview": "*.teliva linguist-language=Lua\n*.tlv linguist-language=Lua\n"
  },
  {
    "path": ".gitignore",
    "chars": 8,
    "preview": "*.o\n*.a\n"
  },
  {
    "path": "COPYRIGHT.md",
    "chars": 1508,
    "preview": "Lua License\n-----------\n\nLua is licensed under the terms of the MIT license reproduced below.\nThis means that Lua is fre"
  },
  {
    "path": "Makefile",
    "chars": 3636,
    "preview": "# makefile for installing Lua\n# see INSTALL for installation instructions\n# see src/Makefile and src/luaconf.h for furth"
  },
  {
    "path": "README.md",
    "chars": 10709,
    "preview": "# Teliva - an environment for end-user programming\n\n> &ldquo;Enable all people to modify the software they use in the co"
  },
  {
    "path": "anagrams.tlv",
    "chars": 17747,
    "preview": "# .tlv file generated by https://github.com/akkartik/teliva\n# You may edit it if you are careful; however, you may see c"
  },
  {
    "path": "break.tlv",
    "chars": 26462,
    "preview": "# .tlv file generated by https://github.com/akkartik/teliva\n# You may edit it if you are careful; however, you may see c"
  },
  {
    "path": "chesstv.tlv",
    "chars": 12106,
    "preview": "# .tlv file generated by https://github.com/akkartik/teliva\n# You may edit it if you are careful; however, you may see c"
  },
  {
    "path": "counter.tlv",
    "chars": 3942,
    "preview": "# .tlv file generated by https://github.com/akkartik/teliva\n# You may edit it if you are careful; however, you may see c"
  },
  {
    "path": "doc/contents.html",
    "chars": 11038,
    "preview": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n<HTML>\n<HEAD>\n<TITLE>Teliva Reference Manual - contents<"
  },
  {
    "path": "doc/lua.css",
    "chars": 1416,
    "preview": "body {\n\tcolor: #000000 ;\n\tbackground-color: #FFFFFF ;\n\tfont-family: Helvetica, Arial, sans-serif ;\n\ttext-align: justify "
  },
  {
    "path": "doc/manual.css",
    "chars": 464,
    "preview": "h3 code {\n\tfont-family: inherit ;\n\tfont-size: inherit ;\n}\n\npre, code {\n\tfont-size: 12pt ;\n}\n\nspan.apii {\n\tfloat: right ;"
  },
  {
    "path": "doc/manual.html",
    "chars": 129729,
    "preview": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n<html>\n\n<head>\n<title>Teliva Reference Manual</title>\n<l"
  },
  {
    "path": "gemini.tlv",
    "chars": 16433,
    "preview": "# .tlv file generated by https://github.com/akkartik/teliva\n# You may edit it if you are careful; however, you may see c"
  },
  {
    "path": "graphviz.tlv",
    "chars": 42725,
    "preview": "# .tlv file generated by https://github.com/akkartik/teliva\n# You may edit it if you are careful; however, you may see c"
  },
  {
    "path": "hanoi.tlv",
    "chars": 6025,
    "preview": "# .tlv file generated by https://github.com/akkartik/teliva\n# You may edit it if you are careful; however, you may see c"
  },
  {
    "path": "life.tlv",
    "chars": 19507,
    "preview": "# .tlv file generated by https://github.com/akkartik/teliva\n# You may edit it if you are careful; however, you may see c"
  },
  {
    "path": "lisp.lua",
    "chars": 5089,
    "preview": "-- atom types:\n--   nil\n--   true\n--   {num=3.4}\n--   {char='a'}\n--   {str='bc'}\n--   {sym='foo'}\n-- non-atom type:\n--  "
  },
  {
    "path": "lisp.tlv",
    "chars": 13171,
    "preview": "# .tlv file generated by https://github.com/akkartik/teliva\n# You may edit it if you are careful; however, you may see c"
  },
  {
    "path": "manual_tests",
    "chars": 1942,
    "preview": "run a program\nrun a program, edit\nrun a program, edit, make an edit, run | edit takes effect\nrun a program with error | "
  },
  {
    "path": "sandboxing/README.md",
    "chars": 3765,
    "preview": "This directory includes some working notes to audit the entire Teliva codebase\nfor side-effects that should be gated/san"
  },
  {
    "path": "sandboxing/includes",
    "chars": 20340,
    "preview": "kilo.c:#include <assert.h>\nkilo.c:#include <ncurses.h>\nkilo.c:#include <stdlib.h>\nkilo.c:#include <stdio.h>\nkilo.c:#incl"
  },
  {
    "path": "sandboxing/system_includes",
    "chars": 7350,
    "preview": "kilo.c:#include <assert.h>\nkilo.c:#include <ncurses.h>\nkilo.c:#include <stdlib.h>\nkilo.c:#include <stdio.h>\nkilo.c:#incl"
  },
  {
    "path": "sandboxing/unique_system_includes",
    "chars": 548,
    "preview": "arpa/inet.h\nassert.h\nctype.h\ndlfcn.h\nerrno.h\nfcntl.h\nfloat.h\ngrp.h\nlimits.h\nlocale.h\nmach-o/dyld.h\nmath.h\nncurses.h\nnet/"
  },
  {
    "path": "shell.nix",
    "chars": 509,
    "preview": "{ pkgs ? import (fetchTarball \"https://github.com/NixOS/nixpkgs/archive/nixos-21.11.tar.gz\") {} }:\n\npkgs.mkShell {\n\tLOCA"
  },
  {
    "path": "sieve.tlv",
    "chars": 7007,
    "preview": "# .tlv file generated by https://github.com/akkartik/teliva\n# You may edit it if you are careful; however, you may see c"
  },
  {
    "path": "smol.tlv",
    "chars": 50258,
    "preview": "# .tlv file generated by https://github.com/akkartik/teliva\n# You may edit it if you are careful; however, you may see c"
  },
  {
    "path": "src/Makefile",
    "chars": 5955,
    "preview": "# makefile for building Lua\n# see ../INSTALL for installation instructions\n# see ../Makefile and luaconf.h for further c"
  },
  {
    "path": "src/file.lua",
    "chars": 3322,
    "preview": "-- primitive for reading files from a file system (or, later, network)\n-- returns an object or nil on error\n-- read line"
  },
  {
    "path": "src/json.lua",
    "chars": 9661,
    "preview": "--\n-- https://github.com/rxi/json.lua\n--\n-- Copyright (c) 2020 rxi\n--\n-- Permission is hereby granted, free of charge, t"
  },
  {
    "path": "src/jsonf.lua",
    "chars": 8092,
    "preview": "--\n-- variant of https://github.com/rxi/json.lua decoding from channels of\n-- characters rather than strings\n--\n-- Copyr"
  },
  {
    "path": "src/kilo.c",
    "chars": 45085,
    "preview": "/* Based on https://github.com/antirez/kilo\n *\n * ----------------------------------------------------------------------"
  },
  {
    "path": "src/lapi.c",
    "chars": 22677,
    "preview": "/*\n** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $\n** Lua API\n** See Copyright Notice in lua.h\n*/\n\n\n#include"
  },
  {
    "path": "src/lapi.h",
    "chars": 262,
    "preview": "/*\n** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $\n** Auxiliary functions from Lua API\n** See Copyright Notic"
  },
  {
    "path": "src/lauxlib.c",
    "chars": 17418,
    "preview": "/*\n** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $\n** Auxiliary functions for building Lua libraries\n** "
  },
  {
    "path": "src/lauxlib.h",
    "chars": 5777,
    "preview": "/*\n** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $\n** Auxiliary functions for building Lua libraries\n** S"
  },
  {
    "path": "src/lbaselib.c",
    "chars": 15020,
    "preview": "/*\n** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $\n** Basic library\n** See Copyright Notice in lua.h\n*/"
  },
  {
    "path": "src/lcode.c",
    "chars": 21170,
    "preview": "/*\n** $Id: lcode.c,v 2.25.1.5 2011/01/31 14:53:16 roberto Exp $\n** Code generator for Lua\n** See Copyright Notice in lua"
  },
  {
    "path": "src/lcode.h",
    "chars": 2750,
    "preview": "/*\n** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $\n** Code generator for Lua\n** See Copyright Notice in lua"
  },
  {
    "path": "src/lcurses/Makefile",
    "chars": 83,
    "preview": "curses.o: curses.c window.c chstr.c _helpers.c compat-5.2.c compat-5.2.h strlcpy.c\n"
  },
  {
    "path": "src/lcurses/_helpers.c",
    "chars": 5364,
    "preview": "/*\n * POSIX library for Lua 5.1, 5.2 & 5.3.\n * (c) Gary V. Vaughan <gary@vaughan.pe>, 2013-2017\n * (c) Reuben Thomas <rr"
  },
  {
    "path": "src/lcurses/chstr.c",
    "chars": 6518,
    "preview": "/*\n * Curses binding for Lua 5.1, 5.2 & 5.3.\n *\n * (c) Gary V. Vaughan <gary@vaughan.pe> 2013-2017\n * (c) Reuben Thomas "
  },
  {
    "path": "src/lcurses/compat-5.2.c",
    "chars": 19698,
    "preview": "#include <errno.h>\n#include <string.h>\n\n#include \"../lua.h\"\n#include \"../lauxlib.h\"\n#include \"compat-5.2.h\"\n\n#if !define"
  },
  {
    "path": "src/lcurses/compat-5.2.h",
    "chars": 4749,
    "preview": "#include <stddef.h>\n#include <string.h>\n#include <stdio.h>\n#include \"../lua.h\"\n#include \"../lauxlib.h\"\n#include \"../lual"
  },
  {
    "path": "src/lcurses/curses.c",
    "chars": 33322,
    "preview": "/*\n * Curses binding for Lua 5.1, 5.2 & 5.3.\n *\n * (c) Gary V. Vaughan <gary@vaughan.pe> 2013-2017\n * (c) Reuben Thomas "
  },
  {
    "path": "src/lcurses/curses.lua",
    "chars": 1299,
    "preview": "--- Lua bindings for curses\nlocal M = curses\n\nfunction M.addch (c) return curses.stdscr():addch(c) end\nfunction M.mvaddc"
  },
  {
    "path": "src/lcurses/strlcpy.c",
    "chars": 2871,
    "preview": "/*\t$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $\t*/\n\n/*\n * Copyright (c) 1998 Todd C. Miller <Todd.Miller@"
  },
  {
    "path": "src/lcurses/window.c",
    "chars": 38300,
    "preview": "/*\n * Curses binding for Lua 5.1, 5.2 & 5.3.\n *\n * (c) Gary V. Vaughan <gary@vaughan.pe> 2013-2017\n * (c) Reuben Thomas "
  },
  {
    "path": "src/ldebug.c",
    "chars": 16835,
    "preview": "/*\n** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $\n** Debug Interface\n** See Copyright Notice in lua.h\n*/\n"
  },
  {
    "path": "src/ldebug.h",
    "chars": 1061,
    "preview": "/*\n** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $\n** Auxiliary functions from Debug Interface module\n** Se"
  },
  {
    "path": "src/ldo.c",
    "chars": 14947,
    "preview": "/*\n** $Id: ldo.c,v 2.38.1.4 2012/01/18 02:27:10 roberto Exp $\n** Stack and Call structure of Lua\n** See Copyright Notice"
  },
  {
    "path": "src/ldo.h",
    "chars": 1897,
    "preview": "/*\n** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $\n** Stack and Call structure of Lua\n** See Copyright Notice "
  },
  {
    "path": "src/ldump.c",
    "chars": 3114,
    "preview": "/*\n** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $\n** save precompiled Lua chunks\n** See Copyright Notice in"
  },
  {
    "path": "src/lfunc.c",
    "chars": 4618,
    "preview": "/*\n** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $\n** Auxiliary functions to manipulate prototypes and clos"
  },
  {
    "path": "src/lfunc.h",
    "chars": 1125,
    "preview": "/*\n** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $\n** Auxiliary functions to manipulate prototypes and closu"
  },
  {
    "path": "src/lgc.c",
    "chars": 20053,
    "preview": "/*\n** $Id: lgc.c,v 2.38.1.2 2011/03/18 18:05:38 roberto Exp $\n** Garbage Collector\n** See Copyright Notice in lua.h\n*/\n\n"
  },
  {
    "path": "src/lgc.h",
    "chars": 3159,
    "preview": "/*\n** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $\n** Garbage Collector\n** See Copyright Notice in lua.h\n*/\n\n"
  },
  {
    "path": "src/linit.c",
    "chars": 998,
    "preview": "/*\n** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $\n** Initialization of libraries for lua.c\n** See Copyrigh"
  },
  {
    "path": "src/liolib.c",
    "chars": 11195,
    "preview": "/*\n** $Id: liolib.c,v 2.73.1.4 2010/05/14 15:33:51 roberto Exp $\n** Standard I/O (and system) library\n** See Copyright N"
  },
  {
    "path": "src/llex.c",
    "chars": 12501,
    "preview": "/*\n** $Id: llex.c,v 2.20.1.2 2009/11/23 14:58:22 roberto Exp $\n** Lexical Analyzer\n** See Copyright Notice in lua.h\n*/\n\n"
  },
  {
    "path": "src/llex.h",
    "chars": 2177,
    "preview": "/*\n** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $\n** Lexical Analyzer\n** See Copyright Notice in lua.h\n*/\n\n"
  },
  {
    "path": "src/llimits.h",
    "chars": 2349,
    "preview": "/*\n** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $\n** Limits, basic types, and some other `installation-d"
  },
  {
    "path": "src/lmathlib.c",
    "chars": 5831,
    "preview": "/*\n** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $\n** Standard mathematical library\n** See Copyright Not"
  },
  {
    "path": "src/lmem.c",
    "chars": 2172,
    "preview": "/*\n** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $\n** Interface to Memory Manager\n** See Copyright Notice in"
  },
  {
    "path": "src/lmem.h",
    "chars": 1494,
    "preview": "/*\n** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $\n** Interface to Memory Manager\n** See Copyright Notice in"
  },
  {
    "path": "src/lobject.c",
    "chars": 5498,
    "preview": "/*\n** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $\n** Some generic functions over Lua objects\n** See Copy"
  },
  {
    "path": "src/lobject.h",
    "chars": 8502,
    "preview": "/*\n** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $\n** Type definitions for Lua objects\n** See Copyright N"
  },
  {
    "path": "src/lopcodes.c",
    "chars": 2884,
    "preview": "/*\n** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $\n** See Copyright Notice in lua.h\n*/\n\n\n#define lopcode"
  },
  {
    "path": "src/lopcodes.h",
    "chars": 8086,
    "preview": "/*\n** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $\n** Opcodes for Lua virtual machine\n** See Copyright "
  },
  {
    "path": "src/loslib.c",
    "chars": 8444,
    "preview": "/*\n** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $\n** Standard Operating System library\n** See Copyright N"
  },
  {
    "path": "src/lparser.c",
    "chars": 36696,
    "preview": "/*\n** $Id: lparser.c,v 2.42.1.4 2011/10/21 19:31:42 roberto Exp $\n** Lua Parser\n** See Copyright Notice in lua.h\n*/\n\n\n#i"
  },
  {
    "path": "src/lparser.h",
    "chars": 2261,
    "preview": "/*\n** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $\n** Lua Parser\n** See Copyright Notice in lua.h\n*/\n\n#if"
  },
  {
    "path": "src/lstate.c",
    "chars": 5409,
    "preview": "/*\n** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $\n** Global State\n** See Copyright Notice in lua.h\n*/\n\n\n#"
  },
  {
    "path": "src/lstate.h",
    "chars": 5011,
    "preview": "/*\n** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $\n** Global State\n** See Copyright Notice in lua.h\n*/\n\n#i"
  },
  {
    "path": "src/lstring.c",
    "chars": 3110,
    "preview": "/*\n** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $\n** String table (keeps all strings handled by Lua)\n** S"
  },
  {
    "path": "src/lstring.h",
    "chars": 814,
    "preview": "/*\n** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $\n** String table (keep all strings handled by Lua)\n** S"
  },
  {
    "path": "src/lstrlib.c",
    "chars": 23173,
    "preview": "/*\n** $Id: lstrlib.c,v 1.132.1.5 2010/05/14 15:34:19 roberto Exp $\n** Standard library for string operations and pattern"
  },
  {
    "path": "src/ltable.c",
    "chars": 16263,
    "preview": "/*\n** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $\n** Lua tables (hash)\n** See Copyright Notice in lua.h\n*"
  },
  {
    "path": "src/ltable.h",
    "chars": 1184,
    "preview": "/*\n** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $\n** Lua tables (hash)\n** See Copyright Notice in lua.h\n*"
  },
  {
    "path": "src/ltablib.c",
    "chars": 7341,
    "preview": "/*\n** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $\n** Library for Table Manipulation\n** See Copyright Not"
  },
  {
    "path": "src/ltm.c",
    "chars": 1650,
    "preview": "/*\n** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $\n** Tag methods\n** See Copyright Notice in lua.h\n*/\n\n\n#inclu"
  },
  {
    "path": "src/ltm.h",
    "chars": 1018,
    "preview": "/*\n** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $\n** Tag methods\n** See Copyright Notice in lua.h\n*/\n\n#ifndef"
  },
  {
    "path": "src/lua.c",
    "chars": 7629,
    "preview": "/*\n** $Id: lua.c,v 1.160.1.2 2007/12/28 15:32:23 roberto Exp $\n** Lua stand-alone interpreter\n** See Copyright Notice in"
  },
  {
    "path": "src/lua.h",
    "chars": 11679,
    "preview": "/*\n** $Id: lua.h,v 1.218.1.7 2012/01/13 20:36:20 roberto Exp $\n** Lua - An Extensible Extension Language\n** Lua.org, PUC"
  },
  {
    "path": "src/luaconf.h",
    "chars": 17997,
    "preview": "/*\n** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $\n** Configuration file for Lua\n** See Copyright Notice "
  },
  {
    "path": "src/lualib.h",
    "chars": 1556,
    "preview": "/*\n** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $\n** Lua standard libraries\n** See Copyright Notice in lu"
  },
  {
    "path": "src/luasec/Makefile",
    "chars": 1525,
    "preview": "CMOD=ssl.a\nLMOD=ssl.lua\n\nOBJS= \\\n options.o \\\n x509.o    \\\n context.o \\\n ssl.o     \\\n config.o  \\\n ec.o\n\nWARN=-Wall\n\nBSD"
  },
  {
    "path": "src/luasec/compat.h",
    "chars": 1514,
    "preview": "/*--------------------------------------------------------------------------\n * LuaSec 1.0.2\n *\n * Copyright (C) 2006-20"
  },
  {
    "path": "src/luasec/config.c",
    "chars": 1912,
    "preview": "/*--------------------------------------------------------------------------\n * LuaSec 1.0.2\n *\n * Copyright (C) 2006-20"
  },
  {
    "path": "src/luasec/context.c",
    "chars": 22211,
    "preview": "/*--------------------------------------------------------------------------\n * LuaSec 1.0.2\n *\n * Copyright (C) 2014-20"
  },
  {
    "path": "src/luasec/context.h",
    "chars": 1055,
    "preview": "#ifndef LSEC_CONTEXT_H\n#define LSEC_CONTEXT_H\n\n/*-----------------------------------------------------------------------"
  },
  {
    "path": "src/luasec/ec.c",
    "chars": 2199,
    "preview": "#include <openssl/objects.h>\n\n#include \"ec.h\"\n\n#ifndef OPENSSL_NO_EC\n\nEC_KEY *lsec_find_ec_key(lua_State *L, const char "
  },
  {
    "path": "src/luasec/ec.h",
    "chars": 473,
    "preview": "/*--------------------------------------------------------------------------\n * LuaSec 1.0.2\n *\n * Copyright (C) 2006-20"
  },
  {
    "path": "src/luasec/https.lua",
    "chars": 3960,
    "preview": "----------------------------------------------------------------------------\n-- LuaSec 1.0.2\n-- Copyright (C) 2009-2021 "
  },
  {
    "path": "src/luasec/options.c",
    "chars": 5699,
    "preview": "/*--------------------------------------------------------------------------\n * LuaSec 1.0.2\n *\n * Copyright (C) 2006-20"
  },
  {
    "path": "src/luasec/options.h",
    "chars": 476,
    "preview": "#ifndef LSEC_OPTIONS_H\n#define LSEC_OPTIONS_H\n\n/*-----------------------------------------------------------------------"
  },
  {
    "path": "src/luasec/options.lua",
    "chars": 2113,
    "preview": "local function usage()\n  print(\"Usage:\")\n  print(\"* Generate options of your system:\")\n  print(\"  lua options.lua -g /pa"
  },
  {
    "path": "src/luasec/ssl.c",
    "chars": 24394,
    "preview": "/*--------------------------------------------------------------------------\n * LuaSec 1.0.2\n *\n * Copyright (C) 2014-20"
  },
  {
    "path": "src/luasec/ssl.h",
    "chars": 815,
    "preview": "#ifndef LSEC_SSL_H\n#define LSEC_SSL_H\n\n/*--------------------------------------------------------------------------\n * L"
  },
  {
    "path": "src/luasec/ssl.lua",
    "chars": 7961,
    "preview": "------------------------------------------------------------------------------\n-- LuaSec 1.0.2\n--\n-- Copyright (C) 2006-"
  },
  {
    "path": "src/luasec/x509.c",
    "chars": 17326,
    "preview": "/*--------------------------------------------------------------------------\n * LuaSec 1.0.2\n *\n * Copyright (C) 2014-20"
  },
  {
    "path": "src/luasec/x509.h",
    "chars": 773,
    "preview": "/*--------------------------------------------------------------------------\n * LuaSec 1.0.2\n *\n * Copyright (C) 2014-20"
  },
  {
    "path": "src/luasocket/auxiliar.c",
    "chars": 6166,
    "preview": "/*=========================================================================*\\\n* Auxiliar routines for class hierarchy ma"
  },
  {
    "path": "src/luasocket/auxiliar.h",
    "chars": 2304,
    "preview": "#ifndef AUXILIAR_H\n#define AUXILIAR_H\n/*=========================================================================*\\\n* Au"
  },
  {
    "path": "src/luasocket/buffer.c",
    "chars": 10344,
    "preview": "/*=========================================================================*\\\n* Input/Output interface for Lua programs\n"
  },
  {
    "path": "src/luasocket/buffer.h",
    "chars": 1847,
    "preview": "#ifndef BUF_H\n#define BUF_H \n/*=========================================================================*\\\n* Input/Outpu"
  },
  {
    "path": "src/luasocket/compat.c",
    "chars": 1180,
    "preview": "#include \"luasocket.h\"\n#include \"compat.h\"\n\n#if LUA_VERSION_NUM==501\n\n/*\n** Adapted from Lua 5.2\n*/\nvoid luasocket_setfu"
  },
  {
    "path": "src/luasocket/compat.h",
    "chars": 376,
    "preview": "#ifndef COMPAT_H\n#define COMPAT_H\n\n#ifndef _WIN32\n#pragma GCC visibility push(hidden)\n#endif\n\nvoid luasocket_setfuncs (l"
  },
  {
    "path": "src/luasocket/except.c",
    "chars": 3678,
    "preview": "/*=========================================================================*\\\n* Simple exception support\n* LuaSocket too"
  },
  {
    "path": "src/luasocket/except.h",
    "chars": 1819,
    "preview": "#ifndef EXCEPT_H\n#define EXCEPT_H\n/*=========================================================================*\\\n* Except"
  },
  {
    "path": "src/luasocket/ftp.lua",
    "chars": 10413,
    "preview": "-----------------------------------------------------------------------------\n-- FTP support for the Lua language\n-- Lua"
  },
  {
    "path": "src/luasocket/headers.lua",
    "chars": 3666,
    "preview": "-----------------------------------------------------------------------------\n-- Canonic header field capitalization\n-- "
  },
  {
    "path": "src/luasocket/http.lua",
    "chars": 14082,
    "preview": "-----------------------------------------------------------------------------\n-- HTTP/1.1 client support for the Lua lan"
  },
  {
    "path": "src/luasocket/inet.c",
    "chars": 19177,
    "preview": "/*=========================================================================*\\\n* Internet domain functions\n* LuaSocket to"
  },
  {
    "path": "src/luasocket/inet.h",
    "chars": 1946,
    "preview": "#ifndef INET_H\n#define INET_H\n/*=========================================================================*\\\n* Internet d"
  },
  {
    "path": "src/luasocket/io.c",
    "chars": 986,
    "preview": "/*=========================================================================*\\\n* Input/Output abstraction\n* LuaSocket too"
  },
  {
    "path": "src/luasocket/io.h",
    "chars": 2255,
    "preview": "#ifndef IO_H\n#define IO_H\n/*=========================================================================*\\\n* Input/Output a"
  },
  {
    "path": "src/luasocket/ltn12.lua",
    "chars": 8534,
    "preview": "-----------------------------------------------------------------------------\n-- LTN12 - Filters, sources, sinks and pum"
  },
  {
    "path": "src/luasocket/luasocket.c",
    "chars": 3509,
    "preview": "/*=========================================================================*\\\n* LuaSocket toolkit\n* Networking support f"
  },
  {
    "path": "src/luasocket/luasocket.h",
    "chars": 1288,
    "preview": "#ifndef LUASOCKET_H\n#define LUASOCKET_H\n/*=========================================================================*\\\n* "
  },
  {
    "path": "src/luasocket/makefile",
    "chars": 6871,
    "preview": "# luasocket src/makefile\n#\n# Definitions in this section can be overriden on the command line or in the\n# environment.\n#"
  },
  {
    "path": "src/luasocket/mbox.lua",
    "chars": 2654,
    "preview": "local _M = {}\n\nif module then\n    mbox = _M\nend \n\nfunction _M.split_message(message_s)\n    local message = {}\n    messag"
  },
  {
    "path": "src/luasocket/mime.c",
    "chars": 32767,
    "preview": "/*=========================================================================*\\\n* MIME support functions\n* LuaSocket toolk"
  },
  {
    "path": "src/luasocket/mime.h",
    "chars": 854,
    "preview": "#ifndef MIME_H \n#define MIME_H \n/*=========================================================================*\\\n* Core MIM"
  },
  {
    "path": "src/luasocket/mime.lua",
    "chars": 2332,
    "preview": "-----------------------------------------------------------------------------\n-- MIME support for the Lua language.\n-- A"
  },
  {
    "path": "src/luasocket/options.c",
    "chars": 14131,
    "preview": "/*=========================================================================*\\\n* Common option interface\n* LuaSocket tool"
  },
  {
    "path": "src/luasocket/options.h",
    "chars": 3118,
    "preview": "#ifndef OPTIONS_H\n#define OPTIONS_H\n/*=========================================================================*\\\n* Comm"
  },
  {
    "path": "src/luasocket/pierror.h",
    "chars": 1272,
    "preview": "#ifndef PIERROR_H\n#define PIERROR_H\n/*=========================================================================*\\\n* Erro"
  },
  {
    "path": "src/luasocket/select.c",
    "chars": 6611,
    "preview": "/*=========================================================================*\\\n* Select implementation\n* LuaSocket toolki"
  },
  {
    "path": "src/luasocket/select.h",
    "chars": 680,
    "preview": "#ifndef SELECT_H\n#define SELECT_H\n/*=========================================================================*\\\n* Select"
  },
  {
    "path": "src/luasocket/serial.c",
    "chars": 5854,
    "preview": "/*=========================================================================*\\\n* Serial stream\n* LuaSocket toolkit\n\\*===="
  },
  {
    "path": "src/luasocket/smtp.lua",
    "chars": 7758,
    "preview": "-----------------------------------------------------------------------------\n-- SMTP client support for the Lua languag"
  },
  {
    "path": "src/luasocket/socket.h",
    "chars": 3236,
    "preview": "#ifndef SOCKET_H\n#define SOCKET_H\n/*=========================================================================*\\\n* Socket"
  },
  {
    "path": "src/luasocket/socket.lua",
    "chars": 4093,
    "preview": "-----------------------------------------------------------------------------\n-- LuaSocket helper module\n-- Author: Dieg"
  },
  {
    "path": "src/luasocket/tcp.c",
    "chars": 16986,
    "preview": "/*=========================================================================*\\\n* TCP object\n* LuaSocket toolkit\n\\*======="
  },
  {
    "path": "src/luasocket/tcp.h",
    "chars": 1101,
    "preview": "#ifndef TCP_H\n#define TCP_H\n/*=========================================================================*\\\n* TCP object\n*"
  },
  {
    "path": "src/luasocket/timeout.c",
    "chars": 7303,
    "preview": "/*=========================================================================*\\\n* Timeout management functions\n* LuaSocket"
  },
  {
    "path": "src/luasocket/timeout.h",
    "chars": 1150,
    "preview": "#ifndef TIMEOUT_H\n#define TIMEOUT_H\n/*=========================================================================*\\\n* Time"
  },
  {
    "path": "src/luasocket/tp.lua",
    "chars": 3617,
    "preview": "-----------------------------------------------------------------------------\n-- Unified SMTP/FTP subsystem\n-- LuaSocket"
  },
  {
    "path": "src/luasocket/udp.c",
    "chars": 17673,
    "preview": "/*=========================================================================*\\\n* UDP object\n* LuaSocket toolkit\n\\*======="
  },
  {
    "path": "src/luasocket/udp.h",
    "chars": 916,
    "preview": "#ifndef UDP_H\n#define UDP_H\n/*=========================================================================*\\\n* UDP object\n*"
  },
  {
    "path": "src/luasocket/unix.c",
    "chars": 2184,
    "preview": "/*=========================================================================*\\\n* Unix domain socket\n* LuaSocket toolkit\n\\"
  },
  {
    "path": "src/luasocket/unix.h",
    "chars": 599,
    "preview": "#ifndef UNIX_H\n#define UNIX_H\n/*=========================================================================*\\\n* Unix domai"
  },
  {
    "path": "src/luasocket/unixdgram.c",
    "chars": 13713,
    "preview": "/*=========================================================================*\\\n* Unix domain socket dgram submodule\n* Lua"
  },
  {
    "path": "src/luasocket/unixdgram.h",
    "chars": 762,
    "preview": "#ifndef UNIXDGRAM_H\n#define UNIXDGRAM_H\n/*=========================================================================*\\\n* "
  },
  {
    "path": "src/luasocket/unixstream.c",
    "chars": 12751,
    "preview": "/*=========================================================================*\\\n* Unix domain socket stream sub module\n* L"
  },
  {
    "path": "src/luasocket/unixstream.h",
    "chars": 965,
    "preview": "#ifndef UNIXSTREAM_H\n#define UNIXSTREAM_H\n/*=========================================================================*\\\n"
  },
  {
    "path": "src/luasocket/url.lua",
    "chars": 11536,
    "preview": "-----------------------------------------------------------------------------\n-- URI parsing, composition and relative U"
  },
  {
    "path": "src/luasocket/usocket.c",
    "chars": 16374,
    "preview": "/*=========================================================================*\\\n* Socket compatibilization module for Unix"
  },
  {
    "path": "src/luasocket/usocket.h",
    "chars": 1805,
    "preview": "#ifndef USOCKET_H\n#define USOCKET_H\n/*=========================================================================*\\\n* Sock"
  },
  {
    "path": "src/luasocket/wsocket.c",
    "chars": 16948,
    "preview": "/*=========================================================================*\\\n* Socket compatibilization module for Win3"
  },
  {
    "path": "src/luasocket/wsocket.h",
    "chars": 840,
    "preview": "#ifndef WSOCKET_H\n#define WSOCKET_H\n/*=========================================================================*\\\n* Sock"
  },
  {
    "path": "src/lundump.c",
    "chars": 4629,
    "preview": "/*\n** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $\n** load precompiled Lua chunks\n** See Copyright Notice "
  },
  {
    "path": "src/lundump.h",
    "chars": 890,
    "preview": "/*\n** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $\n** load precompiled Lua chunks\n** See Copyright Notice"
  },
  {
    "path": "src/lvm.c",
    "chars": 23242,
    "preview": "/*\n** $Id: lvm.c,v 2.63.1.5 2011/08/17 20:43:11 roberto Exp $\n** Lua virtual machine\n** See Copyright Notice in lua.h\n*/"
  },
  {
    "path": "src/lvm.h",
    "chars": 1159,
    "preview": "/*\n** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $\n** Lua virtual machine\n** See Copyright Notice in lua.h\n*/\n"
  },
  {
    "path": "src/lzio.c",
    "chars": 1628,
    "preview": "/*\n** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $\n** a generic input stream interface\n** See Copyright Noti"
  },
  {
    "path": "src/lzio.h",
    "chars": 1556,
    "preview": "/*\n** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $\n** Buffered streams\n** See Copyright Notice in lua.h\n*/\n\n"
  },
  {
    "path": "src/realpath.c",
    "chars": 6477,
    "preview": "/*\n * Copyright (c) 2003 Constantin S. Svintsoff <kostik@iclub.nsu.ru>\n *\n * Redistribution and use in source and binary"
  },
  {
    "path": "src/task.lua",
    "chars": 16195,
    "preview": "----------------------------------------------------------------------------\n-- Go style Channels for Lua\n-- https://git"
  },
  {
    "path": "src/teliva.c",
    "chars": 65872,
    "preview": "#include <assert.h>\n#include <ctype.h>\n#ifdef __NetBSD__\n#include <curses.h>\n#else\n#include <ncurses.h>\n#endif\n#include "
  },
  {
    "path": "src/teliva.h",
    "chars": 7459,
    "preview": "#ifndef __TELIVA_H__\n#define __TELIVA_H__\n\n/*** Some details for Teliva apps to be aware of. */\n\n/* Some names for hotke"
  },
  {
    "path": "src/tlv.c",
    "chars": 7175,
    "preview": "#include <assert.h>\n#ifdef __NetBSD__\n#include <curses.h>\n#else\n#include <ncurses.h>\n#endif\n#include <stdio.h>\n#include "
  },
  {
    "path": "src/tlv.h",
    "chars": 270,
    "preview": "#ifndef __TLV_H__\n#define __TLV_H__\n\n/* Helpers for working with the .tlv file format */\n\nextern void teliva_load_defini"
  },
  {
    "path": "src/vimrc.vim",
    "chars": 49,
    "preview": "set tabstop=8\nset softtabstop=2\nset shiftwidth=2\n"
  },
  {
    "path": "template.tlv",
    "chars": 20321,
    "preview": "# .tlv file generated by https://github.com/akkartik/teliva\n# You may edit it if you are careful; however, you may see c"
  },
  {
    "path": "toot-toot.tlv",
    "chars": 32827,
    "preview": "# .tlv file generated by https://github.com/akkartik/teliva\n# You may edit it if you are careful; however, you may see c"
  },
  {
    "path": "tour.md",
    "chars": 5325,
    "preview": "# A guided tour of Teliva\n\nTeliva is an environment for running shareable little text-mode Lua apps that\nare easy to mod"
  },
  {
    "path": "zet.tlv",
    "chars": 143396,
    "preview": "# .tlv file generated by https://github.com/akkartik/teliva\n# You may edit it if you are careful; however, you may see c"
  }
]

About this extraction

This page contains the full source code of the akkartik/teliva GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 169 files (1.6 MB), approximately 511.7k tokens, and a symbol index with 1467 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!