runner library

Classes

AssignMultiStmt
Like DeclMultiVar, multiple variables can be reassigned at once. Note that it is not a math expr and cannot be used to return assignments as values.
AssignStmt
Variables can be reassigned. This node encodes this operation. Note that it is not a math expr and cannot be used to return assignments as values.
AST
The entry node of any lua program. A program is a collection of stmts.
BinaryExpr
Any binary expression (lhs op rhs) is encoded by this node. op is the operator used on lhs and rhs expressions.
BooleanLiteral
BooleanLiteral.asTrue encodes the literal true. BooleanLiteral.asFalse encodes the literal false.
BreakStmt
Represents the keyword 'break' in lua.
BytesBuilder
Builds a list of bytes, allowing bytes and lists of bytes to be added at the end.
CompressionOptions
Options controlling compression in a WebSocket.
ConnectionTask<S>
A cancelable connection attempt.
ContentType
A MIME/IANA media type used as the value of the HttpHeaders.contentTypeHeader header.
Representation of a cookie. For cookies received by the server as Cookie header values only name and value properties will be set. When building a cookie for the 'set-cookie' header in the server and when receiving cookies in the client as 'set-cookie' headers all fields can be used.
Datagram
A data packet received by a RawDatagramSocket.
DeclArg
This node tells the grammar how to compose a function's argument list.
DeclMultiVar
Lua supports multivariable assignment. Therefore it supports multivariable declarations. The values are determined at runtime and follow the specification here: https://www.lua.org/pil/5.1.html
DeclVar
This represents a variable declaration in lua. The variable name will be id. It may have initialization terms provided by init.
Directory
A reference to a directory (or folder) on the file system.
DoBlockStmt
Lua do-block grammar node.
Evaluator
A very simple LUA evaluator using a basic implementation of the standard runtime StdRuntime. Can be used whereever EvaluatorMixin is expected. If someone wants to get started using this library this is what they want to use.
File
A reference to a file on the file system.
FileLock
Type of lock when requesting a lock on a file.
FileMode
The modes in which a File can be opened.
FileStat
The result of calling the POSIX stat() function on a file system object.
FileSystemCreateEvent
File system event for newly created file system objects.
FileSystemDeleteEvent
File system event for deletion of file system objects.
FileSystemEntity
The common superclass of File, Directory, and Link.
FileSystemEntityType
The type of an entity on the file system, such as a file, directory, or link.
FileSystemEvent
Base event class emitted by FileSystemEntity.watch.
FileSystemModifyEvent
File system event for modifications of file system objects.
FileSystemMoveEvent
File system event for moving of file system objects.
ForIterLoopStmt
The generic variant of lua's for-loop control structure. Unlike the step-wise variant, this evaluates exprs and stores them in vars following the multi-variable assignment rules in this language. That is, if there are too many returned results and not enough vars, then the remaining vars will be nil.
ForLoopStmt
The step-wise variant of lua's for-loop control structure.
FuncExpr
Function declarations can be assigned to variables and are therefore math expressions.
GotoLabelStmt
Represents labels which goto statements use.
GotoStmt
Represents the 'goto' keyword in lua. https://www.lua.org/manual/5.5/manual.html#3.3.4
GroupExpr
Group expressions are expressions wrapped in parents (...).
GZipCodec
The GZipCodec encodes raw bytes to GZip compressed bytes and decodes GZip compressed bytes to raw bytes.
HeaderValue
Representation of a header value in the form:
HttpClient
An HTTP client for communicating with an HTTP server.
HttpClientBasicCredentials
Represents credentials for basic authentication.
HttpClientBearerCredentials
Represents credentials for bearer token authentication.
HttpClientCredentials
Represents credentials for authentication in HttpClient.
HttpClientDigestCredentials
Represents credentials for digest authentication.
HttpClientRequest
HTTP request for a client connection.
HttpClientResponse
HTTP response for a client connection.
HttpConnectionInfo
Information about an HttpRequest, HttpResponse, HttpClientRequest, or HttpClientResponse connection.
HttpConnectionsInfo
Summary statistics about an HttpServers current socket connections.
HttpDate
Utility functions for working with dates with HTTP specific date formats.
HttpHeaders
Headers for HTTP requests and responses.
HttpOverrides
This class facilitates overriding HttpClient with a mock implementation. It should be extended by another class in client code with overrides that construct a mock implementation. The implementation in this base class defaults to the actual HttpClient implementation. For example:
HttpRequest
A server-side object that contains the content of and information about an HTTP request.
HttpResponse
An HTTP response, which returns the headers and data from the server to the client in response to an HTTP request.
HttpServer
A server that delivers content, such as web pages, using the HTTP protocol.
HttpSession
The HttpRequest.session of an HttpRequest.
HttpStatus
HTTP status codes. Exported in dart:io and dart:html.
IfStmt
Represents a linked list of conditional statements. Consider the chain if -> elif -> elif -> else. Therefore else statements are IfStmt without an expr. See IfStmt.terminalElse constructor.
InterfaceAddress
An InternetAddress bound to a NetworkInterface, extended with network configuration details.
InternetAddress
An internet address or a Unix domain address.
InternetAddressType
The type, or address family, of an InternetAddress.
IOOverrides
Facilities for overriding various APIs of dart:io with mock implementations.
IOSink
A combined byte and text output.
KeyValStmt
For convenience, table {key, value} expressions are encoded as this node.
References to filesystem links.
LuaBreakStmtException
A type to represent if the callstack was unwound b/c of the lua break keyword. A break statement can only be inside a loop construct like for, while, and repeat. The parser must report a break statement outside of a loop so the runtime can bubble up out of the construct safely while visiting all loop nodes.
LuaDoc
The configuration class for LuaObject.doc instances. To add documentation use the LuaDoc constructor. Provide a category and the generated docs will group it with those objects sharing the same category. To omit the LuaObject from the generated docs, use LuaDoc.skip.
LuaFuncBuilder
This class provides an API for effortlessly constructing lua function objects.
LuaObject
LuaObjectNoSemantics
Represents a lua object for analyzing irregardless if it is a well-defined variable or value. This permits any visitor to look pass semantic errors and continue marching through the grapheme.
LuaReturnValueException
A type to represent if the callstack was unwound b/c of the lua return keyword. Stores the value of the operation to unpack. See ReturnStmtCallStackUnwind and ReturnStmtDoNotUnwind.
LuaThread
A type that represents a lua thread. It only stores the address addr used by the evaluator. This type is used to distinguish a LuaObject.value from other types.
MathExpr
MemoryAccess
Memory access node encodes which operator op was used, the callee resolved on the left-hand side, the type for convenience, and the input args.
NetworkInterface
A NetworkInterface represents an active network interface on the current system. It contains a list of InterfaceAddresses that are bound to the interface.
NilLiteral
Nil literals are encoded as this node.
NotExpr
In Lua, the not operator is used to negate a boolean value, meaning it converts true to false and false to true.
NumberLiteral
Integers and real literals are encoded as this node.
Pipe
An anonymous pipe that can be used to send data in a single direction i.e. data written to write can be read using read.
Platform
Information about the environment in which the current program is running.
Process
The means to execute a program.
ProcessInfo
Methods for retrieving information about the current process.
ProcessResult
The result of running a non-interactive process started with Process.run or Process.runSync.
ProcessSignal
On Posix systems, ProcessSignal is used to send a specific signal to a child process, see Process.kill.
ProcessStartMode
Modes for running a new process.
RandomAccessFile
Random access to the data in a file.
RawDatagramSocket
An unbuffered interface to a UDP socket.
RawExpr
Represents identifiers in lua. Anything that is not a keyword or an expression is likely an identifier like a variable name or table fields. The spec defines labels as identifiers but those are encoded in this lib by GotoLabelStmt.
RawSecureServerSocket
A server socket providing a stream of low-level RawSecureSockets.
RawSecureSocket
RawSecureSocket provides a secure (SSL or TLS) network connection.
RawServerSocket
A listening socket.
RawSocket
A TCP connection.
RawSocketEvent
Events for the RawDatagramSocket, RawSecureSocket, and RawSocket.
RawSocketOption
The RawSocketOption is used as a parameter to Socket.setRawOption and RawSocket.setRawOption to customize the behaviour of the underlying socket.
RawSynchronousSocket
A low-level class for communicating synchronously over a TCP socket.
RawZLibFilter
The RawZLibFilter class provides a low-level interface to zlib.
ReadPipe
The "read" end of an Pipe created by Pipe.create.
RedirectInfo
Redirect information.
RepeatUntilLoopStmt
Similar to a while-loop but conditional expression untilExpr is the termination condition.
ResourceHandle
A wrapper around OS resource handle so it can be passed via Socket as part of SocketMessage.
ReturnStmt
Represents the keyword 'return' in lua. This keyword can return whole expressions comma separated. See values.
SameSite
Cookie cross-site availability configuration.
SecureServerSocket
A server socket, providing a stream of high-level Sockets.
SecureSocket
A TCP socket using TLS and SSL.
SecurityContext
The object containing the certificates to trust when making a secure client connection, and the certificate chain and private key to serve from a secure server.
SelfExpr
The token for 'self'. While not a keyword in lua, it is encoded as one in this lib for convenience.
ServerSocket
A listening socket.
Socket
A TCP connection between two sockets.
SocketControlMessage
Control message part of the SocketMessage received by a call to RawSocket.readMessage.
SocketDirection
The SocketDirection is used as a parameter to Socket.close and RawSocket.close to close a socket in the specified direction(s).
SocketMessage
A socket message received by a RawDatagramSocket.
SocketOption
An option for a socket which is configured using Socket.setOption.
Stdin
The standard input stream of the process.
StdioType
The type of object a standard IO stream can be attached to.
Stdout
An IOSink connected to either the standard out or error of the process.
StdRuntime
Implement the standard runtime. Initialize the libraries we are interested in using.
StdRuntimeResults
Standard runtime results collects no special information.
Stmt
Base grammar node.
StringLiteral
String literals are encoded as this node.
SystemEncoding
The system encoding is the current code page on Windows and UTF-8 on Linux and Mac.
TableLiteral
Table literal expressions {...} are encoded by this node.
TlsProtocolVersion
A Transport Layer Security (TLS) version.
UnaryExpr
Any tightly bound unary prefix is encoded by this node.
Visitor<T>
This abstraction visits every node class variant. Visitors are the staple of this runtime implementation. They can be used to implement semantic checks as well as implement runtimes. Additionally custom visitors c an walk the AST of a program and generate lua bytecode.
WebSocket
A two-way HTTP communication object for client or server applications.
WebSocketStatus
WebSocket status codes used when closing a WebSocket connection.
WebSocketTransformer
The WebSocketTransformer provides the ability to upgrade a HttpRequest to a WebSocket connection. It supports both upgrading a single HttpRequest and upgrading a stream of HttpRequests.
WhileLoopStmt
Lua while-do loop grammar node.
WritePipe
The "write" end of an Pipe created by Pipe.create.
X509Certificate
X509Certificate represents an SSL certificate, with accessors to get the fields of the certificate.
ZLibCodec
The ZLibCodec encodes raw bytes to ZLib compressed bytes and decodes ZLib compressed bytes to raw bytes.
ZLibDecoder
The ZLibDecoder is used by ZLibCodec and GZipCodec to decompress data.
ZLibEncoder
The ZLibEncoder encoder is used by ZLibCodec and GZipCodec to compress data.
ZLibOption
Exposes ZLib options for input parameters.

Enums

HttpClientResponseCompressionState
Enum that specifies the compression state of the byte stream of an HttpClientResponse.
LuaThreadStatus
Coroutine status values.
LuaType
Strong type enumerations for all possible internal lua primitives. LuaType.unresolved is used for strong type deduction. LuaType.ref is used to help identify control flow. All of the others are the expected user-facing lua types.
MemoryAccessType
Memory access on a variable is in the form of

Mixins

EvaluatorMixin
Enables any class inheritting BaseRuntime to be made available as a public-facing runtime API.

Extensions

LuaArgPackUnpack on LuaArgPack
Native2Lua on Object
A convenience utility on Object to construct LuaObject instances in-place.

Constants

gzip → const GZipCodec
An instance of the default implementation of the GZipCodec.
systemEncoding → const SystemEncoding
The current system encoding.
zlib → const ZLibCodec
An instance of the default implementation of the ZLibCodec.

Properties

exitCode int
Get the global exit code for the Dart VM.
getter/setter pair
pid int
Returns the PID of the current process.
no setter
stderr Stdout
The standard output stream of errors written by this program.
no setter
stdin Stdin
The standard input stream of data read by this program.
no setter
stdout Stdout
The standard output stream of data written by this program.
no setter

Functions

exit(int code) → Never
Exit the Dart VM process immediately with the given exit code.
parse(String content, {RunnerErrorsCallback? onErrors}) AST?
Reads the lua file at path. If there was an error, calls onErrors with those errors and returns null. Otherwise returns the constructed AST.
parseFile(String path, {RunnerErrorsCallback? onErrors}) AST?
Reads a File at path and calls parse. Forwards onErrors to parse.
run(AST ast, {RunnerErrorsCallback? onErrors}) → (bool, LuaObject)
Implementation over runner uses Evaluator machinery for the runtime. Uses print for the default RunnerErrorsCallback value if not provided.
runner(AST ast, {required EvaluatorMixin constructor(), RunnerErrorsCallback? onErrors}) → (bool, LuaObject)
Creates an evaluator satisfying EvaluatorMixin via constructor. Then passes ast into EvaluatorMixin.visitAST to parse and evaluate the scriptlet or program.
sleep(Duration duration) → void
Sleep for the duration specified in duration.
stdioType(dynamic object) StdioType
Whether a stream is attached to a file, pipe, terminal, or something else.

Typedefs

BadCertificateCallback = bool Function(X509Certificate cr, String host, int port)
LuaArgPack = List<LuaObject>
This type is used for multi variable value assignment and for multiple return values.
LuaFieldsMap = Map<Object, LuaObject?>
Shorthand notation for a Map of Object -> LuaObject key-pairs. Note that the LuaObject can be null as lua represents these as LuaType.nil.
RunnerErrorsCallback = void Function(List<String>)

Exceptions / Errors

CertificateException
An exception that happens in the handshake phase of establishing a secure network connection, when looking up or verifying a certificate.
FileSystemException
Exception thrown when a file operation fails.
HandshakeException
An exception that happens in the handshake phase of establishing a secure network connection.
HttpException
IOException
Base class for all IO related exceptions.
OSError
An Exception holding information about an error from the operating system.
PathAccessException
Exception thrown when a file operation fails because the necessary access rights are not available.
PathExistsException
Exception thrown when a file operation fails because the target path already exists.
PathNotFoundException
Exception thrown when a file operation fails because a file or directory does not exist.
ProcessException
RedirectException
SignalException
SocketException
Exception thrown when a socket operation fails.
StdinException
Exception thrown by some operations of Stdin
StdoutException
Exception thrown by some operations of Stdout
TlsException
A secure networking exception caused by a failure in the TLS/SSL protocol.
WebSocketException