Unnamed: 0
int64 0
0
| repo_id
stringlengths 5
186
| file_path
stringlengths 15
223
| content
stringlengths 1
32.8M
⌀ |
---|---|---|---|
0 | repos/Ziguana-Game-System/old-version/prototypes/wavesynth | repos/Ziguana-Game-System/old-version/prototypes/wavesynth/src/pa-simple.zig | // hand-converted PulseAudio Simple API
/// An audio stream
pub const Stream = struct {
handle: *pa_simple,
/// Create a new "sample upload" connection to the server.
pub fn openUpload() !Stream {
return open(server, name, .upload, dev, stream_name, ss, map, attr);
}
/// Create a new record connection to the server.
pub fn openRecord() !Stream {
return open(server, name, .record, dev, stream_name, ss, map, attr);
}
/// Create a new playback connection to the server.
pub fn openPlayback(server: ?[*]const u8, name: [*]const u8, dev: ?[*]const u8, stream_name: [*]const u8, ss: *const SampleSpecification, map: ?*const ChannelMap, attr: ?*const BufferAttributes) !Stream {
return open(server, name, .playback, dev, stream_name, ss, map, attr);
}
/// Create a new connection to the server.
fn open(server: ?[*]const u8, name: [*]const u8, dir: StreamDirection, dev: ?[*]const u8, stream_name: [*]const u8, ss: *const SampleSpecification, map: ?*const ChannelMap, attr: ?*const BufferAttributes) !Stream {
var err: c_int = undefined;
var stream = pa_simple_new(server, name, dir, dev, stream_name, ss, map, attr, &err) orelse return pulseErrorToZigError(err);
return Stream{
.handle = stream,
};
}
/// Close and free the connection to the server.
pub fn close(stream: Stream) void {
pa_simple_free(stream.handle);
}
/// Write some data to the server.
pub fn write(stream: Stream, data: []const u8) !void {
var err: c_int = undefined;
if (pa_simple_write(stream.handle, data.ptr, data.len, &err) != 0)
return pulseErrorToZigError(err);
}
/// Read some data from the server.
/// This function blocks until bytes amount of data has been received from the server, or until an error occurs.
pub fn read(stream: Stream, data: []u8) !void {
var err: c_int = undefined;
if (pa_simple_read(stream.handle, data.ptr, data.len, &err) != 0)
return pulseErrorToZigError(err);
}
/// Wait until all data already written is played by the daemon.
pub fn drain(stream: Stream) !void {
var err: c_int = undefined;
if (pa_simple_drain(stream.handle, &err) != 0)
return pulseErrorToZigError(err);
}
/// Flush the playback or record buffer. This discards any audio in the buffer.
pub fn flush(stream: Stream) !void {
var err: c_int = undefined;
if (pa_simple_flush(stream.handle, &err) != 0)
return pulseErrorToZigError(err);
}
/// Return the playback or record latency.
pub fn getLatencyInMicroSeconds(stream: Stream) !u64 {
var err: c_int = 0;
const result = pa_simple_get_latency(stream.handle, &err);
if (err != 0)
return pulseErrorToZigError(err);
return result;
}
};
const PulseError = error{UnknownError};
fn pulseErrorToZigError(errc: c_int) PulseError {
return error.UnknownError;
}
const pa_simple = @OpaqueType();
extern fn pa_simple_new(server: ?[*]const u8, name: [*]const u8, dir: StreamDirection, dev: [*c]const u8, stream_name: [*c]const u8, ss: [*c]const SampleSpecification, map: [*c]const ChannelMap, attr: [*c]const BufferAttributes, @"error": ?*c_int) ?*pa_simple;
extern fn pa_simple_free(s: *pa_simple) void;
extern fn pa_simple_write(s: *pa_simple, data: ?*const c_void, bytes: usize, @"error": ?*c_int) c_int;
extern fn pa_simple_drain(s: *pa_simple, @"error": [*]c_int) c_int;
extern fn pa_simple_read(s: *pa_simple, data: ?*c_void, bytes: usize, @"error": ?*c_int) c_int;
extern fn pa_simple_get_latency(s: *pa_simple, @"error": ?*c_int) u64;
extern fn pa_simple_flush(s: *pa_simple, @"error": ?*c_int) c_int;
pub const StreamDirection = extern enum {
noDirection,
playback,
record,
upload,
};
pub const SampleSpecification = extern struct {
format: SampleFormat,
rate: u32,
channels: u8,
};
pub const SampleFormat = extern enum {
u8 = 0,
alaw = 1,
ulaw = 2,
s16le = 3,
s16be = 4,
float32le = 5,
float32be = 6,
s32le = 7,
s32be = 8,
s24le = 9,
s24be = 10,
s24_32le = 11,
s24_32be = 12,
invalid = -1,
};
pub const ChannelMap = extern struct {
channels: u8,
map: [32]ChannelPosition,
};
pub const ChannelPosition = extern enum {
invalid = -1,
mono = 0,
frontLeft = 1,
frontRight = 2,
frontCenter = 3,
// left = 1,
// right = 2,
// center = 3,
rearCenter = 4,
rearLeft = 5,
rearRight = 6,
// lfe = 7,
subwoofer = 7,
frontLeftOfCenter = 8,
frontRightOfCenter = 9,
sideLeft = 10,
sideRight = 11,
aux0 = 12,
aux1 = 13,
aux2 = 14,
aux3 = 15,
aux4 = 16,
aux5 = 17,
aux6 = 18,
aux7 = 19,
aux8 = 20,
aux9 = 21,
aux10 = 22,
aux11 = 23,
aux12 = 24,
aux13 = 25,
aux14 = 26,
aux15 = 27,
aux16 = 28,
aux17 = 29,
aux18 = 30,
aux19 = 31,
aux20 = 32,
aux21 = 33,
aux22 = 34,
aux23 = 35,
aux24 = 36,
aux25 = 37,
aux26 = 38,
aux27 = 39,
aux28 = 40,
aux29 = 41,
aux30 = 42,
aux31 = 43,
topCenter = 44,
topFrontLeft = 45,
topFrontRight = 46,
topFrontCenter = 47,
topRearLeft = 48,
topRearRight = 49,
topRearCenter = 50,
};
pub const BufferAttributes = extern struct {
maxlength: u32,
tlength: u32,
prebuf: u32,
minreq: u32,
fragsize: u32,
};
|
0 | repos/Ziguana-Game-System/old-version/libs | repos/Ziguana-Game-System/old-version/libs/lola/README.md | # LoLa Programming Language

LoLa is a small programming language meant to be embedded into games to be programmed by the players. The compiler and runtime are implemented in Zig and C++.
## Short Example
```js
var list = [ "Hello", "World" ];
for(text in list) {
Print(text);
}
```
You can find more examples in the [examples](examples/lola) folder.
## Why LoLa when there is *X*?
LoLa isn't meant to be your next best day-to-day scripting language. Its design is focused on embedding the language in environments where the users want/need/should write some small scripts like games or scriptable applications. In most script languages, you as a script host don't have control over the execution time of the scripts you're executing. LoLa protects you against programming errors like endless loops and such:
### Controlled Execution Environment
Every script invocation gets a limit of instructions it might execute. When either this limit is reached or the script yields for other reasons (asynchronous functions), the execution is returned to the host.
This means, you can execute the following script "in parallel" to your application main loop without blocking your application *and* without requiring complex multithreading setups:
```js
var timer = 0;
while(true) {
Print("Script running for ", timer, " seconds.");
timer += 1;
Sleep(1.0);
}
```
### Native Asynchronous Design
LoLa features both synchronous and asynchronous host functions. Synchronous host function calls are short-lived and will be executed in-place. Asynchronous functions, in contrast, will be executed multiple times until they yield a value. When they don't yield a value, control will be returned to the script host.
This script will not exhaust the instruction limit, but will only increment the counter, then return control back to the host:
```js
var counter = 0;
while(true) {
counter += 1;
Yield();
}
```
This behaviour can be utilized to wait for certain events in the host environment, for example to react to key presses, a script could look like this:
```js
while(true) {
var input = WaitForKey();
if(input == " ") {
Print("Space was pressed!");
}
}
```
*Note that the current implementation is not thread-safe, but requires to use the limited execution for running scripts in parallel.*
### Native "RPC" Design
LoLa also allows executing multiple scripts on the same *environment*, meaning that you can easily create cross-script communications:
```js
// script a:
var buffer;
function Set(val) { buffer = val; }
function Get() { return val; }
// script b:
// GetBuffer() returns a object referencing a environment for "script a"
var buffer = GetBuffer();
buffer.Set("Hello, World!");
// script c:
// GetBuffer() returns a object referencing a environment for "script a"
var buffer = GetBuffer();
Print("Buffer contains: ", buffer.Get());
```
With a fitting network stack and library, this can even be utilized cross-computer.
This example implements a small chat client and server that could work with LoLa RPC capabilities:
```js
// Chat client implementation:
var server = Connect("lola-rpc://random-projects.net/chat");
if(server == void) {
Print("Could not connect to chat server!");
Exit(1);
}
while(true) {
var list = server.GetMessages(GetUser());
for(msg in list) {
Print("< ", msg);
}
Print("> ");
var msg = ReadLine();
if(msg == void)
break;
if(msg == "")
continue;
server.Send(GetUser(), msg);
}
```
```js
// Chat server implementation
var messages = CreateDictionary();
function Send(user, msg)
{
for(other in messages.GetKeys())
{
if(other != user) {
var log = messages.Get(other);
if(log != void) {
log = log ++ [ user + ": " + msg ];
} else {
log = [];
}
messages.Set(other, log);
}
}
}
function GetMessages(user)
{
var log = messages.Get(user);
if(log != void) {
messages.Set(user, []);
return log;
} else {
return [];
}
}
```
### Serializable State
As LoLa has no reference semantics except for objects, it is easy to understand and learn. It is also simple in its implementation and does not require a complex garbage collector or advanced programming knowledge. Each LoLa value can be serialized/deserialized into a sequence of bytes (only exception are object handles, those require some special attention), so saving the current state of a environment/vm to disk and loading it at a later point is a first-class supported use case.
This is especially useful for games where it is favourable to save your script state into a save game as well without having any drawbacks.
### Simple Error Handling
LoLa provides little to no in-language error handling, as it's not designed to be robust against user programming errors. Each error is passed to the host as a panic, so it can show the user that there was an error (like `OutOfMemory` or `TypeMismatch`).
In-language error handling is based on the dynamic typing: Functions that allow in-language error handling just return `void` instead of a actual return value or `true`/`false` for *success* or *failure*.
This allows simple error checking like this:
```js
var string = ReadFile("demo.data");
if(string != void) {
Print("File contained ", string);
}
```
This design decision was made with the idea in mind that most LoLa programmers won't write the next best security critical software, but just do a quick hack in game to reach their next item unlock.
### Smart compiler
As LoLa isn't the most complex language, the compiler can support the programmer. Even though the language has fully dynamic typing, the compiler can do some type checking at compile time already:
```js
// warning: Possible type mismatch detected: Expected number|string|array, found boolean
if(a < true) { }
```
Right now, this is only used for validating expressions, but it is planned to extend this behaviour to annotate variables as well, so even more type errors can be found during compile time.
Note that this is a fairly new feature, it does not catch all your type mismatches, but can prevent the obvious ones.
## Starting Points
To get familiar with LoLa, you can check out these starting points:
- [Documentation](Documentation/README.md)
- [LoLa Examples](examples/lola/README.md)
- [Script Host Examples](examples/host)
When you want to contribute to the compiler, check out the following documents:
- [Source Code](src/)
- [Bison Grammar](src/library/compiler/grammar.yy)
- [Flex Tokenizer](src/library/compiler/yy.l)
- [Issue List](https://github.com/MasterQ32/LoLa/issues)
## Visual Studio Code Extension
If you want syntax highlighting in VSCode, you can install the [`lola-vscode`](https://github.com/MasterQ32/lola-vscode) extension.
Right now, it's not published in the gallery, so to install the extension, you have to sideload it. [See the VSCode documentation for this](https://vscode-docs.readthedocs.io/en/stable/extensions/install-extension/).
## Building
### Continous Integration



### Requirements
- The [Zig Compiler](https://ziglang.org/) (Version 0.6.0+12ce6eb8f or newer)
### Building
```sh
zig build
./zig-cache/bin/lola
```
### Examples
To compile the host examples, you can use `zig build examples` to build all provided examples. These will be available in `./zig-cache/bin` then.
### Running the test suite
When you change things in the compiler or VM implementation, run the test suite:
```sh
zig build test
```
This will execute all zig tests, and also runs a set of predefined tests within the [`src/test/`](src/test/) folder. These tests will verify that the compiler and language runtime behave correctly.
### Building the website
The website generator is gated behind `-Denable-website` which removes a lot of dependencies for people not wanting to render a new version of the website.
If you still want to update/change the website or documentation, use the following command:
```sh
zig build -Denable-website "-Dversion=$(git describe --tags || git rev-parse --short HEAD)" website
```
It will depend on [koino](https://github.com/kivikakk/koino), which is included as a git submodule. Adding new pages to the documentation is done by modifying the `menu_items` array in `src/tools/render-md-page.zig`. |
0 | repos/Ziguana-Game-System/old-version/libs | repos/Ziguana-Game-System/old-version/libs/lola/build.zig | const std = @import("std");
const Builder = std.build.Builder;
pub fn createPackage(comptime root: []const u8) std.build.Pkg {
return std.build.Pkg{
.name = "lola",
.path = root ++ "/src/library/main.zig",
.dependencies = &[_]std.build.Pkg{
std.build.Pkg{
.name = "interface",
.path = root ++ "/libs/interface.zig/interface.zig",
.dependencies = &[_]std.build.Pkg{},
},
},
};
}
const linkPcre = @import("libs/koino/vendor/libpcre.zig/build.zig").linkPcre;
const pkgs = struct {
const args = std.build.Pkg{
.name = "args",
.path = "libs/args/args.zig",
.dependencies = &[_]std.build.Pkg{},
};
const interface = std.build.Pkg{
.name = "interface",
.path = "libs/interface.zig/interface.zig",
.dependencies = &[_]std.build.Pkg{},
};
const lola = std.build.Pkg{
.name = "lola",
.path = "src/library/main.zig",
.dependencies = &[_]std.build.Pkg{
interface,
},
};
const koino = std.build.Pkg{
.name = "koino",
.path = "libs/koino/src/koino.zig",
.dependencies = &[_]std.build.Pkg{
std.build.Pkg{ .name = "libpcre", .path = "libs/koino/vendor/libpcre.zig/src/main.zig" },
std.build.Pkg{ .name = "htmlentities", .path = "libs/koino/vendor/htmlentities.zig/src/main.zig" },
std.build.Pkg{ .name = "clap", .path = "libs/koino/vendor/zig-clap/clap.zig" },
std.build.Pkg{ .name = "zunicode", .path = "libs/koino/vendor/zunicode/src/zunicode.zig" },
},
};
const zee_alloc = std.build.Pkg{
.name = "zee_alloc",
.path = "libs/zee_alloc/src/main.zig",
};
};
const Example = struct {
name: []const u8,
path: []const u8,
};
const examples = [_]Example{
Example{
.name = "minimal-host",
.path = "examples/host/minimal-host/main.zig",
},
Example{
.name = "multi-environment",
.path = "examples/host/multi-environment/main.zig",
},
Example{
.name = "serialization",
.path = "examples/host/serialization/main.zig",
},
};
pub fn build(b: *Builder) !void {
const version_tag = b.option([]const u8, "version", "Sets the version displayed in the docs and for `lola version`");
const mode = b.standardReleaseOptions();
const target = b.standardTargetOptions(.{
.default_target = if (std.builtin.os.tag == .windows)
std.zig.CrossTarget.parse(.{ .arch_os_abi = "native-native-gnu" }) catch unreachable
else if (std.builtin.os.tag == .linux)
std.zig.CrossTarget.fromTarget(.{
.cpu = std.builtin.cpu,
.os = std.builtin.os,
.abi = .musl,
})
else
std.zig.CrossTarget{},
});
const exe = b.addExecutable("lola", "src/frontend/main.zig");
exe.setBuildMode(mode);
exe.setTarget(target);
exe.addPackage(pkgs.lola);
exe.addPackage(pkgs.args);
exe.addBuildOption([]const u8, "version", version_tag orelse "development");
exe.install();
const wasm_runtime = b.addStaticLibrary("lola", "src/wasm-compiler/main.zig");
wasm_runtime.addPackage(pkgs.lola);
wasm_runtime.addPackage(pkgs.zee_alloc);
wasm_runtime.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding });
wasm_runtime.setBuildMode(.ReleaseSafe);
wasm_runtime.install();
const examples_step = b.step("examples", "Compiles all examples");
inline for (examples) |example| {
const example_exe = b.addExecutable("example-" ++ example.name, example.path);
example_exe.setBuildMode(mode);
example_exe.setTarget(target);
example_exe.addPackage(pkgs.lola);
examples_step.dependOn(&b.addInstallArtifact(example_exe).step);
}
var main_tests = b.addTest("src/library/test.zig");
if (pkgs.lola.dependencies) |deps| {
for (deps) |pkg| {
main_tests.addPackage(pkg);
}
}
main_tests.setBuildMode(mode);
const test_step = b.step("test", "Run test suite");
test_step.dependOn(&main_tests.step);
// Run compiler test suites
{
const prefix = "src/test/";
const behaviour_tests = exe.run();
behaviour_tests.addArg("run");
behaviour_tests.addArg("--no-stdlib"); // we don't want the behaviour tests to be run with any stdlib functions
behaviour_tests.addArg(prefix ++ "behaviour.lola");
behaviour_tests.expectStdOutEqual("Behaviour test suite passed.\n");
test_step.dependOn(&behaviour_tests.step);
const stdib_test = exe.run();
stdib_test.addArg("run");
stdib_test.addArg(prefix ++ "stdlib.lola");
stdib_test.expectStdOutEqual("Standard library test suite passed.\n");
test_step.dependOn(&stdib_test.step);
// when the host is windows, this won't work :(
if (std.builtin.os.tag != .windows) {
std.fs.cwd().makeDir("zig-cache/tmp") catch |err| switch (err) {
error.PathAlreadyExists => {}, // nice
else => |e| return e,
};
const runlib_test = exe.run();
// execute in the zig-cache directory so we have a "safe" playfield
// for file I/O
runlib_test.cwd = "zig-cache/tmp";
// `Exit(123)` is the last call in the runtime suite
runlib_test.expected_exit_code = 123;
runlib_test.expectStdOutEqual(
\\
\\1
\\1.2
\\[ ]
\\[ 1, 2 ]
\\truefalse
\\hello
\\Runtime library test suite passed.
\\
);
runlib_test.addArg("run");
runlib_test.addArg("../../" ++ prefix ++ "runtime.lola");
test_step.dependOn(&runlib_test.step);
}
const emptyfile_test = exe.run();
emptyfile_test.addArg("run");
emptyfile_test.addArg(prefix ++ "empty.lola");
emptyfile_test.expectStdOutEqual("");
test_step.dependOn(&emptyfile_test.step);
const globreturn_test = exe.run();
globreturn_test.addArg("run");
globreturn_test.addArg(prefix ++ "global-return.lola");
globreturn_test.expectStdOutEqual("");
test_step.dependOn(&globreturn_test.step);
const extended_behaviour_test = exe.run();
extended_behaviour_test.addArg("run");
extended_behaviour_test.addArg(prefix ++ "behaviour-with-stdlib.lola");
extended_behaviour_test.expectStdOutEqual("Extended behaviour test suite passed.\n");
test_step.dependOn(&extended_behaviour_test.step);
const compiler_test = exe.run();
compiler_test.addArg("compile");
compiler_test.addArg("--verify"); // verify should not emit a compiled module
compiler_test.addArg(prefix ++ "compiler.lola");
compiler_test.expectStdOutEqual("");
test_step.dependOn(&compiler_test.step);
}
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
/////////////////////////////////////////////////////////////////////////
// Documentation and Website generation:
// this is disabed by-default so we don't depend on any vcpkgs
if (b.option(bool, "enable-website", "Enables website generation.") orelse false) {
// Generates documentation and future files.
const gen_website_step = b.step("website", "Generates the website and all required resources.");
// TODO: Figure out how to emit docs into the right directory
// var gen_docs_runner = b.addTest("src/library/main.zig");
// gen_docs_runner.emit_bin = false;
// gen_docs_runner.emit_docs = true;
// gen_docs_runner.setOutputDir("./website");
// gen_docs_runner.setBuildMode(mode);
const gen_docs_runner = b.addSystemCommand(&[_][]const u8{
"zig",
"test",
pkgs.lola.path,
"-femit-docs",
"-fno-emit-bin",
"--output-dir",
"website/",
"--pkg-begin",
"interface",
pkgs.interface.path,
"--pkg-end",
});
// Only generates documentation
const gen_docs_step = b.step("docs", "Generate the code documentation");
gen_docs_step.dependOn(&gen_docs_runner.step);
gen_website_step.dependOn(&gen_docs_runner.step);
const md_renderer = b.addExecutable("markdown-md-page", "src/tools/render-md-page.zig");
md_renderer.addPackage(pkgs.koino);
try linkPcre(md_renderer);
const render = md_renderer.run();
render.addArg(version_tag orelse "development");
gen_website_step.dependOn(&render.step);
const copy_wasm_runtime = b.addSystemCommand(&[_][]const u8{
"cp",
});
copy_wasm_runtime.addArtifactArg(wasm_runtime);
copy_wasm_runtime.addArg("website/lola.wasm");
gen_website_step.dependOn(©_wasm_runtime.step);
}
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola | repos/Ziguana-Game-System/old-version/libs/lola/src/README.md | # Source Structure
The project is structured into two major parts:
- [`frontend`](frontend/) is the compiler frontend which implements the command line executable
- [`library`](library/) is the implementation of both the runtime as well as the compiler. It is structured into several modules:
- [`library/compiler`](library/compiler/) is the compiler which translates LoLa source code into LoLa byte code
- [`library/runtime`](library/runtime) is the virtual machine implementation that allows running LoLa byte code
- [`library/stdlib`](library/stdlib) is the implementation of the LoLa standard library and builds on the runtime
- [`tools`](tools/) contains small tools that are used in this repo, but have no relevance to LoLa itself. One example is the markdown renderer for the website.
- [`test`](test/) contains source files that are used to test the compiler and runtime implementation. See `build.zig` and the source files in `library` for the use of those. Each file in this folder has a header that explains its usage. |
0 | repos/Ziguana-Game-System/old-version/libs/lola/src | repos/Ziguana-Game-System/old-version/libs/lola/src/wasm-compiler/main.zig | const std = @import("std");
const lola = @import("lola");
const zee_alloc = @import("zee_alloc");
// This is our global object pool that is back-referenced
// by the runtime library.
pub const ObjectPool = lola.runtime.ObjectPool([_]type{
lola.libs.runtime.LoLaList,
lola.libs.runtime.LoLaDictionary,
});
var allocator: *std.mem.Allocator = zee_alloc.ZeeAllocDefaults.wasm_allocator;
var compile_unit: lola.CompileUnit = undefined;
var pool: ObjectPool = undefined;
var environment: lola.runtime.Environment = undefined;
var vm: lola.runtime.VM = undefined;
var is_done: bool = true;
pub fn milliTimestamp() usize {
return JS.millis();
}
const JS = struct {
extern fn writeString(data: [*]const u8, len: u32) void;
extern fn readString(data: [*]u8, len: usize) usize;
extern fn millis() usize;
};
const API = struct {
fn writeLog(_: void, str: []const u8) !usize {
JS.writeString(str.ptr, @intCast(u32, str.len));
return str.len;
}
var debug_writer = std.io.Writer(void, error{}, writeLog){ .context = {} };
fn writeLogNL(_: void, str: []const u8) !usize {
var rest = str;
while (std.mem.indexOf(u8, rest, "\n")) |off| {
var mid = rest[0..off];
JS.writeString(mid.ptr, @intCast(u32, mid.len));
JS.writeString("\r\n", 2);
rest = rest[off + 1 ..];
}
JS.writeString(rest.ptr, @intCast(u32, rest.len));
return str.len;
}
/// debug writer that patches LF into CRLF
var debug_writer_lf = std.io.Writer(void, error{}, writeLogNL){ .context = {} };
fn validate(source: []const u8) !void {
var diagnostics = lola.compiler.Diagnostics.init(allocator);
defer diagnostics.deinit();
// This compiles a piece of source code into a compile unit.
// A compile unit is a piece of LoLa IR code with metadata for
// all existing functions, debug symbols and so on. It can be loaded into
// a environment and be executed.
var temp_compile_unit = try lola.compiler.compile(allocator, &diagnostics, "code", source);
for (diagnostics.messages.items) |msg| {
std.fmt.format(debug_writer_lf, "{}\n", .{msg}) catch unreachable;
}
if (temp_compile_unit) |*unit|
unit.deinit();
}
fn initInterpreter(source: []const u8) !void {
var diagnostics = lola.compiler.Diagnostics.init(allocator);
diagnostics.deinit();
const compile_unit_or_none = try lola.compiler.compile(allocator, &diagnostics, "code", source);
for (diagnostics.messages.items) |msg| {
std.fmt.format(debug_writer_lf, "{}\n", .{msg}) catch unreachable;
}
compile_unit = compile_unit_or_none orelse return error.FailedToCompile;
errdefer compile_unit.deinit();
pool = ObjectPool.init(allocator);
errdefer pool.deinit();
environment = try lola.runtime.Environment.init(allocator, &compile_unit, pool.interface());
errdefer environment.deinit();
try lola.libs.std.install(&environment, allocator);
// try lola.libs.runtime.install(&environment, allocator);
try environment.installFunction("Print", lola.runtime.Function.initSimpleUser(struct {
fn Print(_environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
// const allocator = context.get(std.mem.Allocator);
for (args) |value, i| {
switch (value) {
.string => |str| try debug_writer.writeAll(str.contents),
else => try debug_writer.print("{}", .{value}),
}
}
try debug_writer.writeAll("\r\n");
return .void;
}
}.Print));
try environment.installFunction("Write", lola.runtime.Function.initSimpleUser(struct {
fn Write(_environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
// const allocator = context.get(std.mem.Allocator);
for (args) |value, i| {
switch (value) {
.string => |str| try debug_writer.writeAll(str.contents),
else => try debug_writer.print("{}", .{value}),
}
}
return .void;
}
}.Write));
try environment.installFunction("Read", lola.runtime.Function.initSimpleUser(struct {
fn Read(_environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
if (args.len != 0)
return error.InvalidArgs;
var buffer = std.ArrayList(u8).init(allocator);
defer buffer.deinit();
while (true) {
var temp: [256]u8 = undefined;
const len = JS.readString(&temp, temp.len);
if (len == 0)
break;
try buffer.appendSlice(temp[0..len]);
}
return lola.runtime.Value.fromString(lola.runtime.String.initFromOwned(
allocator,
buffer.toOwnedSlice(),
));
}
}.Read));
vm = try lola.runtime.VM.init(allocator, &environment);
errdefer vm.deinit();
is_done = false;
}
fn deinitInterpreter() void {
if (!is_done) {
vm.deinit();
environment.deinit();
pool.deinit();
compile_unit.deinit();
}
is_done = true;
}
fn stepInterpreter(steps: u32) !void {
if (is_done)
return error.InvalidInterpreterState;
// Run the virtual machine for up to 150 instructions
var result = vm.execute(150) catch |err| {
// When the virtua machine panics, we receive a Zig error
try std.fmt.format(debug_writer_lf, "\x1B[91mLoLa Panic: {}\x1B[m\n", .{@errorName(err)});
try vm.printStackTrace(debug_writer_lf);
return error.LoLaPanic;
};
// Prepare a garbage collection cycle:
pool.clearUsageCounters();
// Mark all objects currently referenced in the environment
try pool.walkEnvironment(environment);
// Mark all objects currently referenced in the virtual machine
try pool.walkVM(vm);
// Delete all objects that are not referenced by our system anymore
pool.collectGarbage();
switch (result) {
// This means that our script execution has ended and
// the top-level code has come to an end
.completed => {
// deinitialize everything, stop execution
deinitInterpreter();
return;
},
// This means the VM has exhausted its provided instruction quota
// and returned control to the host.
.exhausted => {},
// This means the virtual machine was suspended via a async function call.
.paused => {},
}
}
};
export fn initialize() void {
// nothing to init atm
}
export fn malloc(len: usize) [*]u8 {
var slice = allocator.alloc(u8, len) catch unreachable;
return slice.ptr;
}
export fn free(mem: [*]u8, len: usize) void {
allocator.free(mem[0..len]);
}
const LoLaError = error{
OutOfMemory,
FailedToCompile,
SyntaxError,
InvalidCode,
AlreadyDeclared,
TooManyVariables,
TooManyLabels,
LabelAlreadyDefined,
Overflow,
NotInLoop,
VariableNotFound,
InvalidStoreTarget,
LoLaPanic,
AlreadyExists,
InvalidObject,
InvalidInterpreterState,
};
fn mapError(err: LoLaError) u8 {
return switch (err) {
error.OutOfMemory => 1,
error.FailedToCompile => 2,
error.SyntaxError => 3,
error.InvalidCode => 3,
error.AlreadyDeclared => 3,
error.TooManyVariables => 3,
error.TooManyLabels => 3,
error.LabelAlreadyDefined => 3,
error.Overflow => 3,
error.NotInLoop => 3,
error.VariableNotFound => 3,
error.InvalidStoreTarget => 3,
error.AlreadyExists => 3,
error.LoLaPanic => 4,
error.InvalidObject => 5,
error.InvalidInterpreterState => 6,
};
}
export fn validate(source: [*]const u8, source_len: usize) u8 {
API.validate(source[0..source_len]) catch |err| return mapError(err);
return 0;
}
export fn initInterpreter(source: [*]const u8, source_len: usize) u8 {
API.initInterpreter(source[0..source_len]) catch |err| return mapError(err);
return 0;
}
export fn deinitInterpreter() void {
API.deinitInterpreter();
}
export fn stepInterpreter(steps: u32) u8 {
API.stepInterpreter(steps) catch |err| return mapError(err);
return 0;
}
export fn isInterpreterDone() bool {
return is_done;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src | repos/Ziguana-Game-System/old-version/libs/lola/src/library/main.zig | const zig_std = @import("std");
// Import all runtime namespaces
pub usingnamespace @import("common/ir.zig");
pub usingnamespace @import("common/compile-unit.zig");
pub usingnamespace @import("common/disassembler.zig");
pub usingnamespace @import("common/decoder.zig");
/// Contains functions and structures for executing LoLa code.
pub const runtime = struct {
usingnamespace @import("runtime/value.zig");
usingnamespace @import("runtime/environment.zig");
usingnamespace @import("runtime/vm.zig");
usingnamespace @import("runtime/context.zig");
usingnamespace @import("runtime/objects.zig");
pub const EnvironmentMap = @import("runtime/environmentmap.zig").EnvironmentMap;
};
/// LoLa libraries that provide pre-defined functions and variables.
pub const libs = @import("libraries/libs.zig");
/// Contains functions and structures to compile LoLa code.
pub const compiler = struct {
pub const Diagnostics = @import("compiler/diagnostics.zig").Diagnostics;
pub const Location = @import("compiler/location.zig").Location;
pub const tokenizer = @import("compiler/tokenizer.zig");
pub const parser = @import("compiler/parser.zig");
pub const ast = @import("compiler/ast.zig");
pub const validate = @import("compiler/analysis.zig").validate;
pub const generateIR = @import("compiler/codegen.zig").generateIR;
/// Compiles a LoLa source code into a CompileUnit.
/// - `allocator` is used to perform all allocations in the compilation process.
/// - `diagnostics` will contain all diagnostic messages after compilation.
/// - `chunk_name` is the name of the source code piece. This is the name that will be used to refer to chunk in error messages, it is usually the file name.
/// - `source_code` is the LoLa source code that should be compiled.
/// The function returns either a compile unit when `source_code` is a valid program, otherwise it will return `null`.
pub fn compile(
allocator: *zig_std.mem.Allocator,
diagnostics: *Diagnostics,
chunk_name: []const u8,
source_code: []const u8,
) !?CompileUnit {
const seq = try tokenizer.tokenize(allocator, diagnostics, chunk_name, source_code);
defer allocator.free(seq);
var pgm = try parser.parse(allocator, diagnostics, seq);
defer pgm.deinit();
const valid_program = try validate(allocator, diagnostics, pgm);
if (!valid_program)
return null;
return try generateIR(allocator, pgm, chunk_name);
}
};
comptime {
if (zig_std.builtin.is_test) {
// include tests
_ = @import("libraries/stdlib.zig");
_ = @import("libraries/runtime.zig");
_ = @import("compiler/diagnostics.zig");
_ = @import("compiler/string-escaping.zig");
_ = @import("compiler/codegen.zig");
_ = @import("compiler/code-writer.zig");
_ = @import("compiler/typeset.zig");
_ = @import("compiler/analysis.zig");
_ = @import("compiler/tokenizer.zig");
_ = @import("compiler/parser.zig");
_ = @import("compiler/location.zig");
_ = @import("compiler/ast.zig");
_ = @import("compiler/scope.zig");
_ = @import("runtime/vm.zig");
_ = @import("runtime/objects.zig");
_ = @import("runtime/environment.zig");
_ = @import("runtime/environmentmap.zig");
_ = @import("runtime/value.zig");
_ = @import("runtime/context.zig");
_ = @import("common/decoder.zig");
_ = @import("common/disassembler.zig");
_ = @import("common/utility.zig");
_ = @import("common/ir.zig");
_ = @import("common/compile-unit.zig");
_ = compiler.compile;
_ = libs.runtime;
_ = libs.std;
}
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src | repos/Ziguana-Game-System/old-version/libs/lola/src/library/test.zig | // this path is mainly to provide a neat test environment
const lola = @import("main.zig");
comptime {
_ = lola;
}
pub const ObjectPool = lola.runtime.ObjectPool(.{});
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/runtime/context.zig | const std = @import("std");
/// A wrapper for a nullable pointer type that can be passed to LoLa functions.
pub const Context = union(enum) {
const Self = @This();
const Opaque = @Type(.Opaque);
empty: void,
content: *Opaque,
pub fn initVoid() Self {
return Self{
.empty = {},
};
}
pub fn init(comptime T: type, ptr: *T) Self {
return Self{
.content = @ptrCast(*Opaque, ptr),
};
}
pub fn get(self: Self, comptime T: type) *T {
return @ptrCast(*T, @alignCast(@alignOf(T), self.content));
}
};
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/runtime/vm.zig | const std = @import("std");
const lola = @import("../main.zig");
usingnamespace @import("value.zig");
usingnamespace @import("../common/ir.zig");
usingnamespace @import("../common/compile-unit.zig");
usingnamespace @import("../common/decoder.zig");
usingnamespace @import("environment.zig");
usingnamespace @import("objects.zig");
pub const ExecutionResult = enum {
/// The vm instruction quota was exhausted and the execution was terminated.
exhausted,
/// The vm has encountered an asynchronous function call and waits for the completion.
paused,
/// The vm has completed execution of the program and has no more instructions to
/// process.
completed,
};
/// Executor of a compile unit. This virtual machine will
/// execute LoLa instructions.
pub const VM = struct {
const Self = @This();
const Context = struct {
/// Stores the local variables for this call.
locals: []Value,
/// Provides instruction fetches for the right compile unit
decoder: Decoder,
/// Stores the stack balance at start of the function call.
/// This is used to reset the stack to the right balance at the
/// end of a function call. It is also used to check for stack underflows.
stackBalance: usize,
/// The script function which this context is currently executing
environment: *Environment,
};
/// Describes a set of statistics for the virtual machine. Can be useful for benchmarking.
pub const Statistics = struct {
/// Number of instructions executed in total.
instructions: usize = 0,
/// Number of executions which were stalled by a asynchronous function
stalls: usize = 0,
};
allocator: *std.mem.Allocator,
stack: std.ArrayList(Value),
calls: std.ArrayList(Context),
currentAsynCall: ?AsyncFunctionCall,
objectPool: ObjectPoolInterface,
stats: Statistics = Statistics{},
/// Initialize a new virtual machine that will run the given environment.
pub fn init(allocator: *std.mem.Allocator, environment: *Environment) !Self {
var vm = Self{
.allocator = allocator,
.stack = std.ArrayList(Value).init(allocator),
.calls = std.ArrayList(Context).init(allocator),
.currentAsynCall = null,
.objectPool = environment.objectPool,
};
errdefer vm.stack.deinit();
errdefer vm.calls.deinit();
try vm.stack.ensureCapacity(128);
try vm.calls.ensureCapacity(32);
// Initialize with special "init context" that runs the script itself
// and hosts the global variables.
var initFun = try vm.createContext(ScriptFunction{
.environment = environment,
.entryPoint = 0, // start at the very first byte
.localCount = environment.compileUnit.temporaryCount,
});
errdefer vm.deinitContext(&initFun);
try vm.calls.append(initFun);
return vm;
}
pub fn deinit(self: *Self) void {
if (self.currentAsynCall) |*asyncCall| {
asyncCall.deinit();
}
for (self.stack.items) |*v| {
v.deinit();
}
for (self.calls.items) |*c| {
self.deinitContext(c);
}
self.stack.deinit();
self.calls.deinit();
self.* = undefined;
}
pub fn deinitContext(self: Self, ctx: *Context) void {
for (ctx.locals) |*v| {
v.deinit();
}
self.allocator.free(ctx.locals);
ctx.* = undefined;
}
/// Creates a new execution context.
/// The script function must have a resolved environment which
/// uses the same object pool as the main environment.
/// It is not possible to mix several object pools.
fn createContext(self: *Self, fun: ScriptFunction) !Context {
std.debug.assert(fun.environment != null);
std.debug.assert(fun.environment.?.objectPool.self == self.objectPool.self);
var ctx = Context{
.decoder = Decoder.init(fun.environment.?.compileUnit.code),
.stackBalance = self.stack.items.len,
.locals = undefined,
.environment = fun.environment.?,
};
ctx.decoder.offset = fun.entryPoint;
ctx.locals = try self.allocator.alloc(Value, fun.localCount);
for (ctx.locals) |*local| {
local.* = .void;
}
return ctx;
}
/// Pushes the value. Will take ownership of the pushed value.
fn push(self: *Self, value: Value) !void {
try self.stack.append(value);
}
/// Peeks at the top of the stack. The returned value is still owned
/// by the stack.
fn peek(self: Self) !*Value {
const slice = self.stack.items;
if (slice.len == 0)
return error.StackImbalance;
return &slice[slice.len - 1];
}
/// Pops a value from the stack. The ownership will be transferred to the caller.
fn pop(self: *Self) !Value {
if (self.calls.items.len > 0) {
const ctx = &self.calls.items[self.calls.items.len - 1];
// Assert we did not accidently have a stack underflow
std.debug.assert(self.stack.items.len >= ctx.stackBalance);
// this pop would produce a stack underrun for the current function call.
if (self.stack.items.len == ctx.stackBalance)
return error.StackImbalance;
}
return if (self.stack.popOrNull()) |v| v else return error.StackImbalance;
}
/// Runs the virtual machine for `quota` instructions.
pub fn execute(self: *Self, _quota: ?u32) !ExecutionResult {
std.debug.assert(self.calls.items.len > 0);
var quota = _quota;
while (true) {
if (quota) |*q| { // if we have a quota, reduce it til zero.
if (q.* == 0)
return ExecutionResult.exhausted;
q.* -= 1;
}
if (try self.executeSingle()) |result| {
switch (result) {
.completed => {
// A execution may only be completed if no calls
// are active anymore.
std.debug.assert(self.calls.items.len == 0);
std.debug.assert(self.stack.items.len == 0);
return ExecutionResult.completed;
},
.yield => return ExecutionResult.paused,
}
}
}
}
/// Executes a single instruction and returns the state of the machine.
fn executeSingle(self: *Self) !?SingleResult {
if (self.currentAsynCall) |*asyncCall| {
if (asyncCall.object) |obj| {
if (!self.objectPool.isObjectValid(obj))
return error.AsyncCallWithInvalidObject;
}
var res = try asyncCall.execute(asyncCall.context);
if (res) |*result| {
asyncCall.deinit();
self.currentAsynCall = null;
errdefer result.deinit();
try self.push(result.*);
} else {
// We are not finished, continue later...
self.stats.stalls += 1;
return .yield;
}
}
const ctx = &self.calls.items[self.calls.items.len - 1];
const environment = ctx.environment;
// std.debug.warn("execute 0x{X}…\n", .{ctx.decoder.offset});
const instruction = ctx.decoder.read(Instruction) catch |err| return switch (err) {
error.EndOfStream => error.InvalidJump,
else => error.InvalidBytecode,
};
self.stats.instructions += 1;
switch (instruction) {
// Auxiliary Section:
.nop => {},
.pop => {
var value = try self.pop();
value.deinit();
},
// Immediate Section:
.push_num => |i| try self.push(Value.initNumber(i.value)),
.push_str => |i| {
var val = try Value.initString(self.allocator, i.value);
errdefer val.deinit();
try self.push(val);
},
.push_true => try self.push(Value.initBoolean(true)),
.push_false => try self.push(Value.initBoolean(false)),
.push_void => try self.push(.void),
// Memory Access Section:
.store_global_idx => |i| {
if (i.value >= environment.scriptGlobals.len)
return error.InvalidGlobalVariable;
const value = try self.pop();
environment.scriptGlobals[i.value].replaceWith(value);
},
.load_global_idx => |i| {
if (i.value >= environment.scriptGlobals.len)
return error.InvalidGlobalVariable;
var value = try environment.scriptGlobals[i.value].clone();
errdefer value.deinit();
try self.push(value);
},
.store_local => |i| {
if (i.value >= ctx.locals.len)
return error.InvalidLocalVariable;
const value = try self.pop();
ctx.locals[i.value].replaceWith(value);
},
.load_local => |i| {
if (i.value >= ctx.locals.len)
return error.InvalidLocalVariable;
var value = try ctx.locals[i.value].clone();
errdefer value.deinit();
try self.push(value);
},
// Array Operations:
.array_pack => |i| {
var array = try Array.init(self.allocator, i.value);
errdefer array.deinit();
for (array.contents) |*item| {
var value = try self.pop();
errdefer value.deinit();
item.replaceWith(value);
}
try self.push(Value.fromArray(array));
},
.array_load => {
var indexed_val = try self.pop();
defer indexed_val.deinit();
var index_val = try self.pop();
defer index_val.deinit();
const index = try index_val.toInteger(usize);
var dupe: Value = switch (indexed_val) {
.array => |arr| blk: {
if (index >= arr.contents.len)
return error.IndexOutOfRange;
break :blk try arr.contents[index].clone();
},
.string => |str| blk: {
if (index >= str.contents.len)
return error.IndexOutOfRange;
break :blk Value.initInteger(u8, str.contents[index]);
},
else => return error.TypeMismatch,
};
errdefer dupe.deinit();
try self.push(dupe);
},
.array_store => {
var indexed_val = try self.pop();
errdefer indexed_val.deinit();
var index_val = try self.pop();
defer index_val.deinit();
if (indexed_val == .array) {
var value = try self.pop();
// only destroy value when we fail to get the array item,
// otherwise the value is stored in the array and must not
// be deinitialized after that
errdefer value.deinit();
const index = try index_val.toInteger(usize);
if (index >= indexed_val.array.contents.len)
return error.IndexOutOfRange;
indexed_val.array.contents[index].replaceWith(value);
} else if (indexed_val == .string) {
var value = try self.pop();
defer value.deinit();
const string = &indexed_val.string;
const byte = try value.toInteger(u8);
const index = try index_val.toInteger(usize);
if (index >= string.contents.len)
return error.IndexOutOfRange;
if (string.refcount != null and string.refcount.?.* > 1) {
var new_string = try String.init(self.allocator, string.contents);
string.deinit();
string.* = new_string;
}
std.debug.assert(string.refcount == null or string.refcount.?.* == 1);
const contents = try string.obtainMutableStorage();
contents[index] = byte;
} else {
return error.TypeMismatch;
}
try self.push(indexed_val);
},
// Iterator Section:
.iter_make => {
var array_val = try self.pop();
errdefer array_val.deinit();
// is still owned by array_val and will be destroyed in case of array.
var array = try array_val.toArray();
try self.push(Value.fromEnumerator(Enumerator.initFromOwned(array)));
},
.iter_next => {
const enumerator_val = try self.peek();
const enumerator = try enumerator_val.getEnumerator();
if (enumerator.next()) |value| {
self.push(value) catch |err| {
var clone = value;
clone.deinit();
return err;
};
try self.push(Value.initBoolean(true));
} else {
try self.push(Value.initBoolean(false));
}
},
// Control Flow Section:
.ret => {
var call = self.calls.pop();
defer self.deinitContext(&call);
// Restore stack balance
while (self.stack.items.len > call.stackBalance) {
var item = self.stack.pop();
item.deinit();
}
// No more context to execute: we have completed execution
if (self.calls.items.len == 0)
return .completed;
try self.push(.void);
},
.retval => {
var value = try self.pop();
errdefer value.deinit();
var call = self.calls.pop();
defer self.deinitContext(&call);
// Restore stack balance
while (self.stack.items.len > call.stackBalance) {
var item = self.stack.pop();
item.deinit();
}
// No more context to execute: we have completed execution
if (self.calls.items.len == 0) {
// TODO: How to handle returns from the main scrip?
value.deinit();
return .completed;
} else {
try self.push(value);
}
},
.jmp => |target| {
ctx.decoder.offset = target.value;
},
.jif, .jnf => |target| {
var value = try self.pop();
defer value.deinit();
const boolean = try value.toBoolean();
if (boolean == (instruction == .jnf)) {
ctx.decoder.offset = target.value;
}
},
.call_fn => |call| {
const method = environment.getMethod(call.function);
if (method == null)
return error.FunctionNotFound;
if (try self.executeFunctionCall(environment, call, method.?, null))
return .yield;
},
.call_obj => |call| {
var obj_val = try self.pop();
errdefer obj_val.deinit();
if (obj_val != .object)
return error.TypeMismatch;
const obj = obj_val.object;
if (!self.objectPool.isObjectValid(obj))
return error.InvalidObject;
const function_or_null = try self.objectPool.getMethod(obj, call.function);
if (function_or_null) |function| {
if (try self.executeFunctionCall(environment, call, function, obj))
return .yield;
} else {
return error.FunctionNotFound;
}
},
// Logic Section:
.bool_and => {
var lhs = try self.pop();
defer lhs.deinit();
var rhs = try self.pop();
defer rhs.deinit();
const a = try lhs.toBoolean();
const b = try rhs.toBoolean();
try self.push(Value.initBoolean(a and b));
},
.bool_or => {
var lhs = try self.pop();
defer lhs.deinit();
var rhs = try self.pop();
defer rhs.deinit();
const a = try lhs.toBoolean();
const b = try rhs.toBoolean();
try self.push(Value.initBoolean(a or b));
},
.bool_not => {
var val = try self.pop();
defer val.deinit();
const a = try val.toBoolean();
try self.push(Value.initBoolean(!a));
},
// Arithmetic Section:
.negate => {
var value = try self.pop();
defer value.deinit();
const num = try value.toNumber();
try self.push(Value.initNumber(-num));
},
.add => {
var rhs = try self.pop();
defer rhs.deinit();
var lhs = try self.pop();
defer lhs.deinit();
if (@as(TypeId, lhs) != @as(TypeId, rhs))
return error.TypeMismatch;
switch (lhs) {
.number => {
try self.push(Value.initNumber(lhs.number + rhs.number));
},
.string => {
const lstr = lhs.string.contents;
const rstr = rhs.string.contents;
var string = try String.initUninitialized(self.allocator, lstr.len + rstr.len);
errdefer string.deinit();
const buffer = try string.obtainMutableStorage();
std.mem.copy(u8, buffer[0..lstr.len], lstr);
std.mem.copy(u8, buffer[lstr.len..buffer.len], rstr);
try self.push(Value.fromString(string));
},
.array => {
const larr = lhs.array.contents;
const rarr = rhs.array.contents;
var result = try Array.init(self.allocator, larr.len + rarr.len);
errdefer result.deinit();
for (larr) |*item, i| {
result.contents[i].exchangeWith(item);
}
for (rarr) |*item, i| {
result.contents[larr.len + i].exchangeWith(item);
}
try self.push(Value.fromArray(result));
},
else => return error.TypeMismatch,
}
},
.sub => {
try self.executeNumberArithmetic(struct {
fn operator(lhs: f64, rhs: f64) error{DivideByZero}!f64 {
return lhs - rhs;
}
}.operator);
},
.mul => {
try self.executeNumberArithmetic(struct {
fn operator(lhs: f64, rhs: f64) error{DivideByZero}!f64 {
return lhs * rhs;
}
}.operator);
},
.div => {
try self.executeNumberArithmetic(struct {
fn operator(lhs: f64, rhs: f64) error{DivideByZero}!f64 {
if (rhs == 0)
return error.DivideByZero;
return lhs / rhs;
}
}.operator);
},
.mod => {
try self.executeNumberArithmetic(struct {
fn operator(lhs: f64, rhs: f64) error{DivideByZero}!f64 {
if (rhs == 0)
return error.DivideByZero;
return @mod(lhs, rhs);
}
}.operator);
},
// Comparisons:
.eq => {
var lhs = try self.pop();
defer lhs.deinit();
var rhs = try self.pop();
defer rhs.deinit();
try self.push(Value.initBoolean(lhs.eql(rhs)));
},
.neq => {
var lhs = try self.pop();
defer lhs.deinit();
var rhs = try self.pop();
defer rhs.deinit();
try self.push(Value.initBoolean(!lhs.eql(rhs)));
},
.less => try self.executeCompareValues(.lt, false),
.less_eq => try self.executeCompareValues(.lt, true),
.greater => try self.executeCompareValues(.gt, false),
.greater_eq => try self.executeCompareValues(.gt, true),
// Deperecated Section:
.scope_push,
.scope_pop,
.declare,
.store_global_name,
.load_global_name,
=> return error.DeprectedInstruction,
}
return null;
}
/// Initiates or executes a function call.
/// Returns `true` when the VM execution should suspend after the call, else `false`.
fn executeFunctionCall(self: *Self, environment: *Environment, call: anytype, function: Function, object: ?ObjectHandle) !bool {
return switch (function) {
.script => |fun| blk: {
var context = try self.createContext(fun);
errdefer self.deinitContext(&context);
try self.readLocals(call, context.locals);
// Fixup stack balance after popping all locals
context.stackBalance = self.stack.items.len;
try self.calls.append(context);
break :blk false;
},
.syncUser => |fun| blk: {
var locals = try self.allocator.alloc(Value, call.argc);
for (locals) |*l| {
l.* = .void;
}
defer {
for (locals) |*l| {
l.deinit();
}
self.allocator.free(locals);
}
try self.readLocals(call, locals);
var result = try fun.call(environment, fun.context, locals);
errdefer result.deinit();
try self.push(result);
break :blk false;
},
.asyncUser => |fun| blk: {
var locals = try self.allocator.alloc(Value, call.argc);
for (locals) |*l| {
l.* = .void;
}
defer {
for (locals) |*l| {
l.deinit();
}
self.allocator.free(locals);
}
try self.readLocals(call, locals);
self.currentAsynCall = try fun.call(fun.context, locals);
self.currentAsynCall.?.object = object;
break :blk true;
},
};
}
/// Reads a number of call arguments into a slice.
/// If an error happens, all items in `locals` are valid and must be deinitialized.
fn readLocals(self: *Self, call: Instruction.CallArg, locals: []Value) !void {
var i: usize = 0;
while (i < call.argc) : (i += 1) {
var value = try self.pop();
if (i < locals.len) {
locals[i].replaceWith(value);
} else {
value.deinit(); // Discard the value
}
}
}
fn executeCompareValues(self: *Self, wantedOrder: std.math.Order, allowEql: bool) !void {
var rhs = try self.pop();
defer rhs.deinit();
var lhs = try self.pop();
defer lhs.deinit();
if (@as(TypeId, lhs) != @as(TypeId, rhs))
return error.TypeMismatch;
const order = switch (lhs) {
.number => |num| std.math.order(num, rhs.number),
.string => |str| std.mem.order(u8, str.contents, rhs.string.contents),
else => return error.InvalidOperator,
};
try self.push(Value.initBoolean(
if (order == .eq and allowEql) true else order == wantedOrder,
));
}
const SingleResult = enum {
/// The program has encountered an asynchronous function
completed,
/// execution and waits for completion.
yield,
};
fn executeNumberArithmetic(self: *Self, operator: fn (f64, f64) error{DivideByZero}!f64) !void {
var rhs = try self.pop();
defer rhs.deinit();
var lhs = try self.pop();
defer lhs.deinit();
const n_lhs = try lhs.toNumber();
const n_rhs = try rhs.toNumber();
const result = try operator(n_lhs, n_rhs);
try self.push(Value.initNumber(result));
}
/// Prints a stack trace for the current code position into `stream`.
pub fn printStackTrace(self: Self, stream: anytype) !void {
var i: usize = self.calls.items.len;
while (i > 0) {
i -= 1;
const call = self.calls.items[i];
const stack_compile_unit = call.environment.compileUnit;
const location = stack_compile_unit.lookUp(call.decoder.offset);
var current_fun: []const u8 = "<main>";
for (stack_compile_unit.functions) |fun| {
if (call.decoder.offset < fun.entryPoint)
break;
current_fun = fun.name;
}
try stream.print("[{}] at offset {} ({}:{}:{}) in function {}\n", .{
i,
call.decoder.offset,
stack_compile_unit.comment,
if (location) |l| l.sourceLine else 0,
if (location) |l| l.sourceColumn else 0,
current_fun,
});
}
}
pub fn serialize(self: Self, envmap: *lola.runtime.EnvironmentMap, stream: anytype) !void {
if (self.currentAsynCall != null)
return error.NotSupportedYet; // we cannot serialize async function that are in-flight atm
try stream.writeIntLittle(u64, self.stack.items.len);
try stream.writeIntLittle(u64, self.calls.items.len);
for (self.stack.items) |item| {
try item.serialize(stream);
}
for (self.calls.items) |item| {
try stream.writeIntLittle(u16, @intCast(u16, item.locals.len));
try stream.writeIntLittle(u32, item.decoder.offset); // we don't need to store the CompileUnit of the decoder, as it is implicitly referenced by the environment
try stream.writeIntLittle(u32, @intCast(u32, item.stackBalance));
if (envmap.queryByPtr(item.environment)) |env_id| {
try stream.writeIntLittle(u32, env_id);
} else {
return error.UnregisteredEnvironmentPointer;
}
for (item.locals) |loc| {
try loc.serialize(stream);
}
}
}
pub fn deserialize(allocator: *std.mem.Allocator, envmap: *lola.runtime.EnvironmentMap, stream: anytype) !Self {
const stack_size = try stream.readIntLittle(u64);
const call_size = try stream.readIntLittle(u64);
var vm = Self{
.allocator = allocator,
.stack = std.ArrayList(Value).init(allocator),
.calls = std.ArrayList(Context).init(allocator),
.currentAsynCall = null,
.objectPool = undefined,
};
errdefer vm.stack.deinit();
errdefer vm.calls.deinit();
try vm.stack.ensureCapacity(std.math.min(stack_size, 128));
try vm.calls.ensureCapacity(std.math.min(call_size, 32));
try vm.stack.resize(stack_size);
for (vm.stack.items) |*item| {
item.* = .void;
}
errdefer for (vm.stack.items) |*item| {
item.deinit();
};
for (vm.stack.items) |*item| {
item.* = try Value.deserialize(stream, allocator);
}
{
var i: usize = 0;
while (i < call_size) : (i += 1) {
const local_count = try stream.readIntLittle(u16);
const offset = try stream.readIntLittle(u32);
const stack_balance = try stream.readIntLittle(u32);
const env_id = try stream.readIntLittle(u32);
const env = envmap.queryById(env_id) orelse return error.UnregisteredEnvironmentPointer;
if (i == 0) {
// first call defines which environment we use for our
// object pool reference:
vm.objectPool = env.objectPool;
}
var ctx = try vm.createContext(ScriptFunction{
.environment = env,
.entryPoint = offset,
.localCount = local_count,
});
ctx.stackBalance = stack_balance;
errdefer vm.deinitContext(&ctx);
for (ctx.locals) |*local| {
local.* = try Value.deserialize(stream, allocator);
}
try vm.calls.append(ctx);
}
}
return vm;
}
};
const TestPool = ObjectPool(.{});
fn runTest(comptime TestRunner: type) !void {
var code = TestRunner.code;
const cu = CompileUnit{
.arena = undefined,
.comment = "",
.globalCount = 0,
.temporaryCount = 0,
.functions = &[_]CompileUnit.Function{},
.debugSymbols = &[0]CompileUnit.DebugSymbol{},
.code = &code,
};
var pool = TestPool.init(std.testing.allocator);
defer pool.deinit();
var env = try Environment.init(std.testing.allocator, &cu, pool.interface());
defer env.deinit();
var vm = try VM.init(std.testing.allocator, &env);
defer vm.deinit();
try TestRunner.verify(&vm);
}
test "VM basic execution" {
try runTest(struct {
var code = [_]u8{
@enumToInt(InstructionName.ret),
};
fn verify(vm: *VM) !void {
const result = try vm.execute(1);
std.testing.expectEqual(ExecutionResult.completed, result);
}
});
}
test "VM endless loop exhaustion" {
try runTest(struct {
var code = [_]u8{
@enumToInt(InstructionName.jmp),
0x00,
0x00,
0x00,
0x00,
};
fn verify(vm: *VM) !void {
const result = try vm.execute(1000);
std.testing.expectEqual(ExecutionResult.exhausted, result);
}
});
}
test "VM invalid code panic" {
try runTest(struct {
var code = [_]u8{
@enumToInt(InstructionName.jmp),
0x00,
0x00,
0x00,
};
fn verify(vm: *VM) !void {
std.testing.expectError(error.InvalidBytecode, vm.execute(1000));
}
});
}
test "VM invalid jump panic" {
try runTest(struct {
var code = [_]u8{
@enumToInt(InstructionName.jmp),
0x00,
0x00,
0x00,
0xFF,
};
fn verify(vm: *VM) !void {
std.testing.expectError(error.InvalidJump, vm.execute(1000));
}
});
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/runtime/objects.zig | const std = @import("std");
const interfaces = @import("interface");
usingnamespace @import("environment.zig");
usingnamespace @import("vm.zig");
usingnamespace @import("value.zig");
/// Non-owning interface to a abstract LoLa object.
/// It is associated with a object handle in the `ObjectPool` and provides
/// a way to get methods as well as destroy the object when it's garbage collected.
pub const Object = struct {
const Interface = interfaces.Interface(struct {
getMethod: fn (self: *interfaces.SelfType, name: []const u8) ?Function,
destroyObject: fn (self: *interfaces.SelfType) void,
}, interfaces.Storage.NonOwning);
const Class = interfaces.Interface(struct {
serializeObject: ?fn (self: *interfaces.SelfType, stream: OutputStream) anyerror!void,
deserializeObject: ?fn (stream: InputStream) anyerror!*interfaces.SelfType,
}, interfaces.Storage.NonOwning);
const Self = @This();
impl: Interface,
pub fn init(ptr: anytype) Self {
return Self{
.impl = Interface.init(ptr) catch unreachable,
};
}
fn getMethod(self: *const Self, name: []const u8) ?Function {
return self.impl.call("getMethod", .{name});
}
fn destroyObject(self: *Self) void {
self.impl.call("destroyObject", .{});
self.* = undefined;
}
};
/// A opaque handle to objects. These are used inside the virtual machine and environment and
/// will be passed around. They do not hold any memory references and require an object pool to
/// resolve to actual objects.
pub const ObjectHandle = enum(u64) {
const Self = @This();
_, // Just an non-exhaustive handle, no named members
};
pub const InputStream = struct {
const Self = @This();
pub const ErasedSelf = @Type(.Opaque);
self: *const ErasedSelf,
read: fn (self: *const ErasedSelf, buf: []u8) anyerror!usize,
fn from(reader_ptr: anytype) Self {
const T = std.meta.Child(@TypeOf(reader_ptr));
return Self{
.self = @ptrCast(*const ErasedSelf, reader_ptr),
.read = struct {
fn read(self: *const ErasedSelf, buf: []u8) anyerror!usize {
return @ptrCast(*const T, @alignCast(@alignOf(T), self)).read(buf);
}
}.read,
};
}
fn readSome(self: Self, buffer: []u8) anyerror!usize {
return self.read(self.self, buffer);
}
fn reader(self: @This()) Reader {
return Reader{
.context = self,
};
}
pub const Reader = std.io.Reader(Self, anyerror, readSome);
};
pub const OutputStream = struct {
const Self = @This();
pub const ErasedSelf = @Type(.Opaque);
self: *const ErasedSelf,
write: fn (self: *const ErasedSelf, buf: []const u8) anyerror!usize,
fn from(writer_ptr: anytype) Self {
const T = std.meta.Child(@TypeOf(writer_ptr));
return Self{
.self = @ptrCast(*const ErasedSelf, writer_ptr),
.write = struct {
fn write(self: *const ErasedSelf, buf: []const u8) anyerror!usize {
return @ptrCast(*const T, @alignCast(@alignOf(T), self)).write(buf);
}
}.write,
};
}
fn writeSome(self: Self, buffer: []const u8) anyerror!usize {
return self.write(self.self, buffer);
}
fn writer(self: @This()) Writer {
return Writer{
.context = self,
};
}
pub const Writer = std.io.Writer(Self, anyerror, writeSome);
};
const ObjectGetError = error{InvalidObject};
pub const ObjectPoolInterface = struct {
const ErasedSelf = @Type(.Opaque);
self: *ErasedSelf,
getMethodFn: fn (self: *ErasedSelf, handle: ObjectHandle, name: []const u8) ObjectGetError!?Function,
destroyObjectFn: fn (self: *ErasedSelf, handle: ObjectHandle) void,
isObjectValidFn: fn (self: *ErasedSelf, handle: ObjectHandle) bool,
pub fn getMethod(self: @This(), handle: ObjectHandle, name: []const u8) ObjectGetError!?Function {
return self.getMethodFn(self.self, handle, name);
}
pub fn destroyObject(self: @This(), handle: ObjectHandle) void {
return self.destroyObjectFn(self.self, handle);
}
pub fn isObjectValid(self: @This(), handle: ObjectHandle) bool {
return self.isObjectValidFn(self.self, handle);
}
pub fn castTo(self: *@This(), comptime PoolType: type) *PoolType {
return @ptrCast(*PoolType, @alignCast(@alignOf(PoolType), self.self));
}
};
/// An object pool is a structure that is used for garbage collecting objects.
/// Each object gets a unique number assigned when being put into the pool
/// via `createObject`. This handle can then be passed into a VM, used opaquely.
/// The VM can also request methods from objects via `getMethod` call.
/// To collect garbage, the following procedure should be done:
/// 1. Call `clearUsageCounters` to initiate garbage collection
/// 2. Call `walkEnvironment`, `walkVM` or `walkValue` to collect all live objects in different elements
/// 3. Call `collectGarbage` to delete all objects that have no reference counters set.
/// For each object to be deleted, `destroyObject` is invoked and the object is removed from the pool.
/// To retain objects by hand in areas not reachable by any of the `walk*` functions, it's possible to
/// call `retainObject` to increment the reference counter by 1 and `releaseObject` to reduce it by one.
/// Objects marked with this reference counter will not be deleted even when the object is not encountered
/// betewen `clearUsageCounters` and `collectGarbage`.
pub fn ObjectPool(comptime classes_list: anytype) type {
// enforce type safety here
comptime var classes: [classes_list.len]type = undefined;
for (classes_list) |item, i| {
classes[i] = item;
}
comptime var hasher = std.hash.SipHash64(2, 4).init("ObjectPool Serialization Version 1");
comptime var all_classes_can_serialize = (classes.len > 0);
inline for (classes) |class| {
const can_serialize = @hasDecl(class, "serializeObject");
if (can_serialize != @hasDecl(class, "deserializeObject")) {
@compileError("Each class requires either both serializeObject and deserializeObject to be present or none.");
}
all_classes_can_serialize = all_classes_can_serialize and can_serialize;
// this requires to use a typeHash structure instead of the type name
hasher.update(@typeName(class));
}
const TypeIndex = std.meta.Int(
false,
// We need 1 extra value, so 0xFFFF… is never a valid type index
// this marks the end of objects in the stream
std.mem.alignForward(std.math.log2_int_ceil(usize, classes.len + 1), 8),
);
const ClassInfo = struct {
name: []const u8,
serialize: fn (stream: OutputStream, obj: Object) anyerror!void,
deserialize: fn (allocator: *std.mem.Allocator, stream: InputStream) anyerror!Object,
};
// Provide a huge-enough branch quota
@setEvalBranchQuota(1000 * (classes.len + 1));
const class_lut = comptime if (all_classes_can_serialize) blk: {
var lut: [classes.len]ClassInfo = undefined;
for (lut) |*info, i| {
const Class = classes[i];
const Interface = struct {
fn serialize(stream: OutputStream, obj: Object) anyerror!void {
try Class.serializeObject(stream.writer(), @ptrCast(*Class, @alignCast(@alignOf(Class), obj.impl.storage.erased_ptr)));
}
fn deserialize(allocator: *std.mem.Allocator, stream: InputStream) anyerror!Object {
var ptr = try Class.deserializeObject(allocator, stream.reader());
return Object.init(ptr);
}
};
info.* = ClassInfo{
.name = @typeName(Class),
.serialize = Interface.serialize,
.deserialize = Interface.deserialize,
};
}
break :blk lut;
} else {};
const pool_signature = hasher.finalInt();
return struct {
const Self = @This();
const ManagedObject = struct {
refcount: usize,
manualRefcount: usize,
object: Object,
class_id: TypeIndex,
};
/// Is `true` when all classes in the ObjectPool allow seriaization
pub const serializable: bool = all_classes_can_serialize;
/// ever-increasing number which is used to allocate new object handles.
objectCounter: u64,
/// stores all alive objects. Removing elements from this
/// requires to call `.object.destroyObject()`!
objects: std.AutoHashMap(ObjectHandle, ManagedObject),
/// Creates a new object pool, using `allocator` to handle hashmap allocations.
pub fn init(allocator: *std.mem.Allocator) Self {
return Self{
.objectCounter = 0,
.objects = std.AutoHashMap(ObjectHandle, ManagedObject).init(allocator),
};
}
/// Destroys all objects in the pool, then releases all associated memory.
/// Do not use the ObjectPool afterwards!
pub fn deinit(self: *Self) void {
var iter = self.objects.iterator();
while (iter.next()) |obj| {
obj.value.object.destroyObject();
}
self.objects.deinit();
self.* = undefined;
}
// Serialization API
/// Serializes the whole object pool into the `stream`.
pub fn serialize(self: Self, stream: anytype) !void {
if (all_classes_can_serialize) {
try stream.writeIntLittle(u64, pool_signature);
var iter = self.objects.iterator();
while (iter.next()) |entry| {
const obj = &entry.value;
var class = class_lut[obj.class_id];
try stream.writeIntLittle(TypeIndex, obj.class_id);
try stream.writeIntLittle(u64, @enumToInt(entry.key));
try class.serialize(OutputStream.from(&stream), obj.object);
}
try stream.writeIntLittle(TypeIndex, std.math.maxInt(TypeIndex));
} else {
@compileError("This ObjectPool is not serializable!");
}
}
/// Deserializes a object pool from `steam` and returns it.
pub fn deserialize(allocator: *std.mem.Allocator, stream: anytype) !Self {
if (all_classes_can_serialize) {
var pool = init(allocator);
errdefer pool.deinit();
var signature = try stream.readIntLittle(u64);
if (signature != pool_signature)
return error.InvalidStream;
while (true) {
const type_index = try stream.readIntLittle(TypeIndex);
if (type_index == std.math.maxInt(TypeIndex))
break; // end of objects
if (type_index >= class_lut.len)
return error.InvalidStream;
const object_id = try stream.readIntLittle(u64);
pool.objectCounter = std.math.max(object_id + 1, pool.objectCounter);
const gop = try pool.objects.getOrPut(@intToEnum(ObjectHandle, object_id));
if (gop.found_existing)
return error.InvalidStream;
const object = try class_lut[type_index].deserialize(allocator, InputStream.from(&stream));
gop.entry.value = ManagedObject{
.object = object,
.refcount = 0,
.manualRefcount = 0,
.class_id = type_index,
};
}
return pool;
} else {
@compileError("This ObjectPool is not serializable!");
}
}
// Public API
/// Inserts a new object into the pool and returns a handle to it.
/// `object_ptr` must be a mutable pointer to the object itself.
pub fn createObject(self: *Self, object_ptr: anytype) !ObjectHandle {
const ObjectTypeInfo = @typeInfo(@TypeOf(object_ptr)).Pointer;
if (ObjectTypeInfo.is_const)
@compileError("Passing a const pointer to ObjectPool.createObject is not allowed!");
// Calculate the index of the type:
const type_index = inline for (classes) |class, index| {
if (class == ObjectTypeInfo.child)
break index;
} else @compileError("The type " ++ @typeName(ObjectTypeInfo.child) ++ " is not valid for this object pool. Add it to the class list in the type definition to allow creation.");
var object = Object.init(object_ptr);
self.objectCounter += 1;
errdefer self.objectCounter -= 1;
const handle = @intToEnum(ObjectHandle, self.objectCounter);
try self.objects.putNoClobber(handle, ManagedObject{
.object = object,
.refcount = 0,
.manualRefcount = 0,
.class_id = type_index,
});
return handle;
}
/// Keeps the object from beeing garbage collected.
/// To allow recollection, call `releaseObject`.
pub fn retainObject(self: *Self, object: ObjectHandle) ObjectGetError!void {
if (self.objects.getEntry(object)) |obj| {
obj.value.manualRefcount += 1;
} else {
return error.InvalidObject;
}
}
/// Removes a restrain from `retainObject` to re-allow garbage collection.
pub fn releaseObject(self: *Self, object: ObjectHandle) ObjectGetError!void {
if (self.objects.getEntry(object)) |obj| {
obj.value.manualRefcount -= 1;
} else {
return error.InvalidObject;
}
}
/// Destroys an object by external means. This will also invoke the object destructor.
pub fn destroyObject(self: *Self, object: ObjectHandle) void {
if (self.objects.remove(object)) |obj| {
var copy = obj.value.object;
copy.destroyObject();
}
}
/// Returns if an object handle is still valid.
pub fn isObjectValid(self: Self, object: ObjectHandle) bool {
return if (self.objects.get(object)) |obj| true else false;
}
/// Gets the method of an object or `null` if the method does not exist.
/// The returned `Function` is non-owned.
pub fn getMethod(self: Self, object: ObjectHandle, name: []const u8) ObjectGetError!?Function {
if (self.objects.get(object)) |obj| {
return obj.object.getMethod(name);
} else {
return error.InvalidObject;
}
}
// Garbage Collector API
/// Sets all usage counters to zero.
pub fn clearUsageCounters(self: *Self) void {
var iter = self.objects.iterator();
while (iter.next()) |obj| {
obj.value.refcount = 0;
}
}
/// Marks an object handle as used
pub fn markUsed(self: *Self, object: ObjectHandle) ObjectGetError!void {
if (self.objects.getEntry(object)) |obj| {
obj.value.refcount += 1;
} else {
return error.InvalidObject;
}
}
/// Walks through the value marks all referenced objects as used.
pub fn walkValue(self: *Self, value: Value) ObjectGetError!void {
switch (value) {
.object => |oid| try self.markUsed(oid),
.array => |arr| for (arr.contents) |val| {
try self.walkValue(val);
},
else => {},
}
}
/// Walks through all values stored in an environment and marks all referenced objects as used.
pub fn walkEnvironment(self: *Self, env: Environment) ObjectGetError!void {
for (env.scriptGlobals) |glob| {
try self.walkValue(glob);
}
}
/// Walks through all values stored in a virtual machine and marks all referenced objects as used.
pub fn walkVM(self: *Self, vm: VM) ObjectGetError!void {
for (vm.stack.items) |val| {
try self.walkValue(val);
}
for (vm.calls.items) |call| {
for (call.locals) |local| {
try self.walkValue(local);
}
}
}
/// Removes and destroys all objects that are not marked as used.
pub fn collectGarbage(self: *Self) void {
// Now this?!
var iter = self.objects.iterator();
while (iter.next()) |obj| {
if (obj.value.refcount == 0 and obj.value.manualRefcount == 0) {
if (self.objects.remove(obj.key)) |kv| {
var temp_obj = kv.value.object;
temp_obj.destroyObject();
} else {
unreachable;
}
// Hack: Remove modification safety check,
// we want to mutate the HashMap!
// iter.initial_modification_count = iter.hm.modification_count;
}
}
}
// Interface API:
/// Returns the non-generic interface for this object pool.
/// Pass this to `Environment` or other LoLa components.
pub fn interface(self: *Self) ObjectPoolInterface {
const Impl = struct {
const ErasedSelf = ObjectPoolInterface.ErasedSelf;
fn cast(erased_self: *ErasedSelf) *Self {
return @ptrCast(*Self, @alignCast(@alignOf(Self), erased_self));
}
fn getMethod(erased_self: *ErasedSelf, handle: ObjectHandle, name: []const u8) ObjectGetError!?Function {
return cast(erased_self).getMethod(handle, name);
}
fn destroyObject(erased_self: *ErasedSelf, handle: ObjectHandle) void {
return cast(erased_self).destroyObject(handle);
}
fn isObjectValid(erased_self: *ErasedSelf, handle: ObjectHandle) bool {
return cast(erased_self).isObjectValid(handle);
}
};
return ObjectPoolInterface{
.self = @ptrCast(*ObjectPoolInterface.ErasedSelf, self),
.destroyObjectFn = Impl.destroyObject,
.getMethodFn = Impl.getMethod,
.isObjectValidFn = Impl.isObjectValid,
};
}
};
}
const TestObject = struct {
const Self = @This();
got_method_query: bool = false,
got_destroy_call: bool = false,
was_serialized: bool = false,
was_deserialized: bool = false,
pub fn getMethod(self: *Self, name: []const u8) ?Function {
self.got_method_query = true;
return null;
}
pub fn destroyObject(self: *Self) void {
self.got_destroy_call = true;
}
pub fn serializeObject(writer: OutputStream.Writer, object: *Self) !void {
try writer.writeAll("test object");
object.was_serialized = true;
}
var deserialize_instance = Self{};
pub fn deserializeObject(allocator: *std.mem.Allocator, reader: InputStream.Reader) !*Self {
var buf: [11]u8 = undefined;
try reader.readNoEof(&buf);
std.testing.expectEqualStrings("test object", &buf);
deserialize_instance.was_deserialized = true;
return &deserialize_instance;
}
};
const TestPool = ObjectPool([_]type{TestObject});
comptime {
if (std.builtin.is_test) {
{
if (ObjectPool([_]type{}).serializable != false)
@compileError("Empty ObjectPool is required to be unserializable!");
}
{
if (TestPool.serializable != true)
@compileError("TestPool is required to be serializable!");
}
{
const Unserializable = struct {
const Self = @This();
pub fn getMethod(self: *Self, name: []const u8) ?Function {
unreachable;
}
pub fn destroyObject(self: *Self) void {
unreachable;
}
};
if (ObjectPool([_]type{ TestObject, Unserializable }).serializable != false)
@compileError("Unserializable detection doesn't work!");
}
}
}
test "Object" {
var test_obj = TestObject{};
var object = Object.init(&test_obj);
std.testing.expectEqual(false, test_obj.got_destroy_call);
std.testing.expectEqual(false, test_obj.got_method_query);
_ = object.getMethod("irrelevant");
std.testing.expectEqual(false, test_obj.got_destroy_call);
std.testing.expectEqual(true, test_obj.got_method_query);
object.destroyObject();
std.testing.expectEqual(true, test_obj.got_destroy_call);
std.testing.expectEqual(true, test_obj.got_method_query);
}
test "ObjectPool basic object create/destroy cycle" {
var pool = TestPool.init(std.testing.allocator);
defer pool.deinit();
var test_obj = TestObject{};
const handle = try pool.createObject(&test_obj);
std.testing.expectEqual(false, test_obj.got_destroy_call);
std.testing.expectEqual(false, test_obj.got_method_query);
std.testing.expectEqual(true, pool.isObjectValid(handle));
_ = try pool.getMethod(handle, "irrelevant");
std.testing.expectEqual(false, test_obj.got_destroy_call);
std.testing.expectEqual(true, test_obj.got_method_query);
pool.destroyObject(handle);
std.testing.expectEqual(true, test_obj.got_destroy_call);
std.testing.expectEqual(true, test_obj.got_method_query);
std.testing.expectEqual(false, pool.isObjectValid(handle));
}
test "ObjectPool automatic cleanup" {
var pool = TestPool.init(std.testing.allocator);
errdefer pool.deinit();
var test_obj = TestObject{};
const handle = try pool.createObject(&test_obj);
std.testing.expectEqual(false, test_obj.got_destroy_call);
std.testing.expectEqual(false, test_obj.got_method_query);
std.testing.expectEqual(true, pool.isObjectValid(handle));
pool.deinit();
std.testing.expectEqual(true, test_obj.got_destroy_call);
std.testing.expectEqual(false, test_obj.got_method_query);
}
test "ObjectPool garbage collection" {
var pool = TestPool.init(std.testing.allocator);
defer pool.deinit();
var test_obj = TestObject{};
const handle = try pool.createObject(&test_obj);
std.testing.expectEqual(false, test_obj.got_destroy_call);
std.testing.expectEqual(true, pool.isObjectValid(handle));
// Prevent the object from being collected because it is marked as used
pool.clearUsageCounters();
try pool.markUsed(handle);
pool.collectGarbage();
std.testing.expectEqual(false, test_obj.got_destroy_call);
std.testing.expectEqual(true, pool.isObjectValid(handle));
// Prevent the object from being collected because it is marked as referenced
try pool.retainObject(handle);
pool.clearUsageCounters();
pool.collectGarbage();
try pool.releaseObject(handle);
std.testing.expectEqual(false, test_obj.got_destroy_call);
std.testing.expectEqual(true, pool.isObjectValid(handle));
// Destroy the object by not marking it referenced at last
pool.clearUsageCounters();
pool.collectGarbage();
std.testing.expectEqual(true, test_obj.got_destroy_call);
std.testing.expectEqual(false, pool.isObjectValid(handle));
}
// TODO: Write tests for walkEnvironment and walkVM
test "ObjectPool serialization" {
var backing_buffer: [1024]u8 = undefined;
const serialized_id = blk: {
var pool = TestPool.init(std.testing.allocator);
defer pool.deinit();
var test_obj = TestObject{};
const id = try pool.createObject(&test_obj);
std.testing.expectEqual(false, test_obj.was_serialized);
var fbs = std.io.fixedBufferStream(&backing_buffer);
try pool.serialize(fbs.writer());
std.testing.expectEqual(true, test_obj.was_serialized);
break :blk id;
};
{
var fbs = std.io.fixedBufferStream(&backing_buffer);
std.testing.expectEqual(false, TestObject.deserialize_instance.was_deserialized);
var pool = try TestPool.deserialize(std.testing.allocator, fbs.reader());
defer pool.deinit();
std.testing.expectEqual(true, TestObject.deserialize_instance.was_deserialized);
std.testing.expect(pool.isObjectValid(serialized_id));
}
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/runtime/value.zig | const std = @import("std");
const envsrc = @import("environment.zig");
pub const TypeId = enum(u8) {
void = 0,
number = 1,
object = 2,
boolean = 3,
string = 4,
array = 5,
enumerator = 6,
};
/// A struct that represents any possible LoLa value.
pub const Value = union(TypeId) {
const Self = @This();
// non-allocating
void: void,
number: f64,
object: envsrc.ObjectHandle,
boolean: bool,
// allocating
string: String,
array: Array,
enumerator: Enumerator,
pub fn initNumber(val: f64) Self {
return Self{ .number = val };
}
pub fn initInteger(comptime T: type, val: T) Self {
comptime std.debug.assert(@typeInfo(T) == .Int);
return Self{ .number = @intToFloat(f64, val) };
}
pub fn initObject(id: envsrc.ObjectHandle) Self {
return Self{ .object = id };
}
pub fn initBoolean(val: bool) Self {
return Self{ .boolean = val };
}
/// Initializes a new value with string contents.
pub fn initString(allocator: *std.mem.Allocator, text: []const u8) !Self {
return Self{ .string = try String.init(allocator, text) };
}
/// Creates a new value that takes ownership of the passed string.
/// This string must not be deinited.
pub fn fromString(str: String) Self {
return Self{ .string = str };
}
/// Creates a new value that takes ownership of the passed array.
/// This array must not be deinited.
pub fn fromArray(array: Array) Self {
return Self{ .array = array };
}
/// Creates a new value with an enumerator. The array will be cloned
/// into the enumerator and will not be owned.
pub fn initEnumerator(array: Array) !Self {
return Self{ .enumerator = try Enumerator.init(array) };
}
/// Creates a new value that takes ownership of the passed enumerator.
/// This enumerator must not be deinited.
pub fn fromEnumerator(enumerator: Enumerator) Self {
return Self{ .enumerator = enumerator };
}
/// Duplicate this value.
pub fn clone(self: Self) !Self {
return switch (self) {
.string => |s| Self{ .string = try s.clone() },
.array => |a| Self{ .array = try a.clone() },
.enumerator => |e| Self{ .enumerator = try e.clone() },
.void, .number, .object, .boolean => self,
};
}
/// Exchanges two values
pub fn exchangeWith(self: *Self, other: *Self) void {
const temp = self.*;
self.* = other.*;
other.* = temp;
}
/// Replaces the current instance with another instance.
/// This will move the memory from the other instance into the
/// current one. Calling deinit() on `other` after this function
/// is an error.
pub fn replaceWith(self: *Self, other: Self) void {
self.deinit();
self.* = other;
}
/// Checks if two values are equal.
pub fn eql(lhs: Self, rhs: Self) bool {
const Tag = @TagType(Self);
if (@as(Tag, lhs) != @as(Tag, rhs))
return false;
return switch (lhs) {
.void => true,
.number => |n| n == rhs.number,
.object => |o| o == rhs.object,
.boolean => |b| b == rhs.boolean,
.string => |s| String.eql(s, rhs.string),
.array => |a| Array.eql(a, rhs.array),
.enumerator => |e| Enumerator.eql(e, rhs.enumerator),
};
}
pub fn deinit(self: *Self) void {
switch (self.*) {
.array => |*a| a.deinit(),
.string => |*s| s.deinit(),
.enumerator => |*e| e.deinit(),
else => {},
}
self.* = undefined;
}
const ConversionError = error{ TypeMismatch, OutOfRange };
pub fn toNumber(self: Self) ConversionError!f64 {
if (self != .number)
return error.TypeMismatch;
return self.number;
}
pub fn toInteger(self: Self, comptime T: type) ConversionError!T {
const num = std.math.floor(try self.toNumber());
if (num < std.math.minInt(T))
return error.OutOfRange;
if (num > std.math.maxInt(T))
return error.OutOfRange;
return @floatToInt(T, num);
}
pub fn toBoolean(self: Self) ConversionError!bool {
if (self != .boolean)
return error.TypeMismatch;
return self.boolean;
}
pub fn toVoid(self: Self) ConversionError!void {
if (self != .void)
return error.TypeMismatch;
}
pub fn toObject(self: Self) ConversionError!envsrc.ObjectHandle {
if (self != .object)
return error.TypeMismatch;
return self.object;
}
pub fn toArray(self: Self) ConversionError!Array {
if (self != .array)
return error.TypeMismatch;
return self.array;
}
/// Returns either the string contents or errors with TypeMismatch
pub fn toString(self: Self) ConversionError![]const u8 {
if (self != .string)
return error.TypeMismatch;
return self.string.contents;
}
/// Gets the contained array or fails.
pub fn getArray(self: *Self) ConversionError!*Array {
if (self.* != .array)
return error.TypeMismatch;
return &self.array;
}
/// Gets the contained enumerator or fails.
pub fn getEnumerator(self: *Self) ConversionError!*Enumerator {
if (self.* != .enumerator)
return error.TypeMismatch;
return &self.enumerator;
}
fn formatArray(a: Array, stream: anytype) !void {
try stream.writeAll("[");
for (a.contents) |item, i| {
if (i > 0)
try stream.writeAll(",");
// Workaround until #???? is fixed:
// Print only the type name of the array item.
// const itemType = @as(TypeId, item);
// try std.fmt.format(context, Errors, output, " {}", .{@tagName(itemType)});
try stream.print(" {}", .{item});
}
try stream.writeAll(" ]");
}
/// Checks if two values are equal.
pub fn format(value: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, stream: anytype) !void {
return switch (value) {
.void => stream.writeAll("void"),
.number => |n| stream.print("{d}", .{n}),
.object => |o| stream.print("${d}", .{o}),
.boolean => |b| if (b) stream.writeAll("true") else stream.writeAll("false"),
.string => |s| stream.print("\"{}\"", .{s.contents}),
.array => |a| formatArray(a, stream),
.enumerator => |e| {
try stream.print("enumerator({}/{})", .{ e.index, e.array.contents.len });
},
};
}
/// Serializes the value into the given `writer`.
/// Note that this does not serialize object values but only references. It is required to serialize the corresponding
/// object pool as well to gain restorability of objects.
pub fn serialize(self: Self, writer: anytype) (@TypeOf(writer).Error || error{ NotSupported, ObjectTooLarge })!void {
try writer.writeByte(@enumToInt(@as(TypeId, self)));
switch (self) {
.void => return, // void values are empty \o/
.number => |val| try writer.writeAll(std.mem.asBytes(&val)),
.object => |val| try writer.writeIntLittle(u64, @enumToInt(val)),
.boolean => |val| try writer.writeByte(if (val) @as(u8, 1) else 0),
.string => |val| {
try writer.writeIntLittle(u32, std.math.cast(u32, val.contents.len) catch return error.ObjectTooLarge);
try writer.writeAll(val.contents);
},
.array => |arr| {
try writer.writeIntLittle(u32, std.math.cast(u32, arr.contents.len) catch return error.ObjectTooLarge);
for (arr.contents) |item| {
try item.serialize(writer);
}
},
.enumerator => |e| {
try writer.writeIntLittle(u32, std.math.cast(u32, e.array.contents.len) catch return error.ObjectTooLarge);
try writer.writeIntLittle(u32, std.math.cast(u32, e.index) catch return error.ObjectTooLarge);
for (e.array.contents) |item| {
try item.serialize(writer);
}
},
}
}
/// Deserializes a value from the `reader`, using `allocator` to allocate memory.
/// Note that if objects are deserialized you need to also deserialize the corresponding object pool
pub fn deserialize(reader: anytype, allocator: *std.mem.Allocator) (@TypeOf(reader).Error || error{ OutOfMemory, InvalidEnumTag, EndOfStream, NotSupported })!Self {
const type_id_src = try reader.readByte();
const type_id = try std.meta.intToEnum(TypeId, type_id_src);
return switch (type_id) {
.void => .void,
.number => blk: {
var buffer: [@sizeOf(f64)]u8 align(@alignOf(f64)) = undefined;
try reader.readNoEof(&buffer);
break :blk initNumber(@bitCast(f64, buffer));
},
.object => initObject(@intToEnum(envsrc.ObjectHandle, try reader.readIntLittle(@TagType(envsrc.ObjectHandle)))),
.boolean => initBoolean((try reader.readByte()) != 0),
.string => blk: {
const size = try reader.readIntLittle(u32);
const buffer = try allocator.alloc(u8, size);
errdefer allocator.free(buffer);
try reader.readNoEof(buffer);
break :blk fromString(String.initFromOwned(allocator, buffer));
},
.array => blk: {
const size = try reader.readIntLittle(u32);
var array = try Array.init(allocator, size);
errdefer array.deinit();
for (array.contents) |*item| {
item.* = try deserialize(reader, allocator);
}
break :blk fromArray(array);
},
.enumerator => blk: {
const size = try reader.readIntLittle(u32);
const index = try reader.readIntLittle(u32);
var array = try Array.init(allocator, size);
errdefer array.deinit();
for (array.contents) |*item| {
item.* = try deserialize(reader, allocator);
}
break :blk fromEnumerator(Enumerator{
.array = array,
.index = index,
});
},
};
}
};
test "Value.void" {
var voidVal = Value{ .void = {} };
defer voidVal.deinit();
std.debug.assert(voidVal == .void);
}
test "Value.number" {
var value = Value{ .number = 3.14 };
defer value.deinit();
std.debug.assert(value == .number);
std.debug.assert(value.number == 3.14);
}
test "Value.boolean" {
var value = Value{ .boolean = true };
defer value.deinit();
std.debug.assert(value == .boolean);
std.debug.assert(value.boolean == true);
}
test "Value.object" {
var value = Value{ .object = @intToEnum(envsrc.ObjectHandle, 2394) };
defer value.deinit();
std.debug.assert(value == .object);
std.debug.assert(value.object == @intToEnum(envsrc.ObjectHandle, 2394));
}
test "Value.string (move)" {
var value = Value.fromString(try String.init(std.testing.allocator, "Hello"));
defer value.deinit();
std.debug.assert(value == .string);
std.debug.assert(std.mem.eql(u8, value.string.contents, "Hello"));
}
test "Value.string (init)" {
var value = try Value.initString(std.testing.allocator, "Malloc'd");
defer value.deinit();
std.debug.assert(value == .string);
std.debug.assert(std.mem.eql(u8, value.string.contents, "Malloc'd"));
}
test "Value.eql (void)" {
var v1: Value = .void;
var v2: Value = .void;
std.debug.assert(v1.eql(v2));
}
test "Value.eql (boolean)" {
var v1 = Value.initBoolean(true);
var v2 = Value.initBoolean(true);
var v3 = Value.initBoolean(false);
std.debug.assert(v1.eql(v2));
std.debug.assert(v2.eql(v1));
std.debug.assert(v1.eql(v3) == false);
std.debug.assert(v2.eql(v3) == false);
}
test "Value.eql (number)" {
var v1 = Value.initNumber(1.3);
var v2 = Value.initNumber(1.3);
var v3 = Value.initNumber(2.3);
std.debug.assert(v1.eql(v2));
std.debug.assert(v2.eql(v1));
std.debug.assert(v1.eql(v3) == false);
std.debug.assert(v2.eql(v3) == false);
}
test "Value.eql (object)" {
var v1 = Value.initObject(@intToEnum(envsrc.ObjectHandle, 1));
var v2 = Value.initObject(@intToEnum(envsrc.ObjectHandle, 1));
var v3 = Value.initObject(@intToEnum(envsrc.ObjectHandle, 2));
std.debug.assert(v1.eql(v2));
std.debug.assert(v2.eql(v1));
std.debug.assert(v1.eql(v3) == false);
std.debug.assert(v2.eql(v3) == false);
}
test "Value.eql (string)" {
var v1 = try Value.initString(std.testing.allocator, "a");
defer v1.deinit();
var v2 = try Value.initString(std.testing.allocator, "a");
defer v2.deinit();
var v3 = try Value.initString(std.testing.allocator, "b");
defer v3.deinit();
std.debug.assert(v1.eql(v2));
std.debug.assert(v2.eql(v1));
std.debug.assert(v1.eql(v3) == false);
std.debug.assert(v2.eql(v3) == false);
}
/// Immutable string type.
/// Both
pub const String = struct {
const Self = @This();
allocator: *std.mem.Allocator,
contents: []const u8,
refcount: ?*usize,
/// Creates a new, uninitialized string
pub fn initUninitialized(allocator: *std.mem.Allocator, length: usize) !Self {
const alignment = @alignOf(usize);
const ptr_offset = std.mem.alignForward(length, alignment);
const buffer = try allocator.allocAdvanced(
u8,
alignment,
ptr_offset + @sizeOf(usize),
.exact,
);
std.mem.writeIntNative(usize, buffer[ptr_offset..][0..@sizeOf(usize)], 1);
return Self{
.allocator = allocator,
.contents = buffer[0..length],
.refcount = @ptrCast(*usize, @alignCast(alignment, buffer.ptr + ptr_offset)),
};
}
/// Clones `text` with the given parameter and stores the
/// duplicated value.
pub fn init(allocator: *std.mem.Allocator, text: []const u8) !Self {
var string = try initUninitialized(allocator, text.len);
std.mem.copy(
u8,
string.obtainMutableStorage() catch unreachable,
text,
);
return string;
}
/// Returns a string that will take ownership of the passed `text` and
/// will free that with `allocator`.
pub fn initFromOwned(allocator: *std.mem.Allocator, text: []const u8) Self {
return Self{
.allocator = allocator,
.contents = text,
.refcount = null,
};
}
/// Returns a muable slice of the string elements.
/// This may fail with `error.Forbidden` when the string is referenced more than once.
pub fn obtainMutableStorage(self: *Self) error{Forbidden}![]u8 {
if (self.refcount) |rc| {
std.debug.assert(rc.* > 0);
if (rc.* > 1)
return error.Forbidden;
}
// this is safe as we allocated the memory, so it is actually mutable
return @intToPtr([*]u8, @ptrToInt(self.contents.ptr))[0..self.contents.len];
}
pub fn clone(self: Self) error{OutOfMemory}!Self {
if (self.refcount) |rc| {
// we can just increase reference count here
rc.* += 1;
return self;
} else {
// otherwise, return a new copy which is now reference-counted
// -> performance opt-in
return try init(self.allocator, self.contents);
}
}
pub fn eql(lhs: Self, rhs: Self) bool {
return std.mem.eql(u8, lhs.contents, rhs.contents);
}
pub fn deinit(self: *Self) void {
if (self.refcount) |rc| {
std.debug.assert(rc.* > 0);
rc.* -= 1;
if (rc.* > 0)
return;
// patch-up the old length so the allocator will know what happened
self.contents.len = std.mem.alignForward(self.contents.len, @alignOf(usize)) + @sizeOf(usize);
}
self.allocator.free(self.contents);
self.* = undefined;
}
};
test "String" {
var text = try String.init(std.testing.allocator, "Hello, World!");
std.debug.assert(std.mem.eql(u8, text.contents, "Hello, World!"));
var text2 = try text.clone();
text.deinit();
std.debug.assert(std.mem.eql(u8, text2.contents, "Hello, World!"));
text2.deinit();
}
test "String.eql" {
var str1 = try String.init(std.testing.allocator, "Hello, World!");
defer str1.deinit();
var str2 = try String.init(std.testing.allocator, "Hello, World!");
defer str2.deinit();
var str3 = try String.init(std.testing.allocator, "World, Hello!");
defer str3.deinit();
std.debug.assert(str1.eql(str2));
std.debug.assert(str2.eql(str1));
std.debug.assert(str1.eql(str3) == false);
std.debug.assert(str2.eql(str3) == false);
}
pub const Array = struct {
const Self = @This();
allocator: *std.mem.Allocator,
contents: []Value,
pub fn init(allocator: *std.mem.Allocator, size: usize) !Self {
var arr = Self{
.allocator = allocator,
.contents = try allocator.alloc(Value, size),
};
for (arr.contents) |*item| {
item.* = Value{ .void = {} };
}
return arr;
}
pub fn clone(self: Self) error{OutOfMemory}!Self {
var arr = Self{
.allocator = self.allocator,
.contents = try self.allocator.alloc(Value, self.contents.len),
};
errdefer arr.allocator.free(arr.contents);
var index: usize = 0;
// Cleanup all successfully cloned items
errdefer {
var i: usize = 0;
while (i < index) : (i += 1) {
arr.contents[i].deinit();
}
}
while (index < arr.contents.len) : (index += 1) {
arr.contents[index] = try self.contents[index].clone();
}
return arr;
}
pub fn eql(lhs: Self, rhs: Self) bool {
if (lhs.contents.len != rhs.contents.len)
return false;
for (lhs.contents) |v, i| {
if (!Value.eql(v, rhs.contents[i]))
return false;
}
return true;
}
pub fn deinit(self: *Self) void {
for (self.contents) |*item| {
item.deinit();
}
self.allocator.free(self.contents);
self.* = undefined;
}
};
test "Array" {
var array = try Array.init(std.testing.allocator, 3);
defer array.deinit();
std.debug.assert(array.contents.len == 3);
std.debug.assert(array.contents[0] == .void);
std.debug.assert(array.contents[1] == .void);
std.debug.assert(array.contents[2] == .void);
array.contents[0].replaceWith(Value.initBoolean(true));
array.contents[1].replaceWith(try Value.initString(std.testing.allocator, "Hello"));
array.contents[2].replaceWith(Value.initNumber(45.0));
std.debug.assert(array.contents[0] == .boolean);
std.debug.assert(array.contents[1] == .string);
std.debug.assert(array.contents[2] == .number);
}
test "Array.eql" {
var array1 = try Array.init(std.testing.allocator, 2);
defer array1.deinit();
array1.contents[0] = Value.initBoolean(true);
array1.contents[1] = Value.initNumber(42);
var array2 = try Array.init(std.testing.allocator, 2);
defer array2.deinit();
array2.contents[0] = Value.initBoolean(true);
array2.contents[1] = Value.initNumber(42);
var array3 = try Array.init(std.testing.allocator, 2);
defer array3.deinit();
array3.contents[0] = Value.initBoolean(true);
array3.contents[1] = Value.initNumber(43);
var array4 = try Array.init(std.testing.allocator, 3);
defer array4.deinit();
std.debug.assert(array1.eql(array2));
std.debug.assert(array2.eql(array1));
std.debug.assert(array1.eql(array3) == false);
std.debug.assert(array2.eql(array3) == false);
std.debug.assert(array1.eql(array4) == false);
std.debug.assert(array2.eql(array4) == false);
std.debug.assert(array3.eql(array4) == false);
}
pub const Enumerator = struct {
const Self = @This();
array: Array,
index: usize,
/// Creates a new enumerator that will clone the contained value.
pub fn init(array: Array) !Self {
return Self{
.array = try array.clone(),
.index = 0,
};
}
/// Creates a new enumerator that will own the passed value.
pub fn initFromOwned(array: Array) Self {
return Self{
.array = array,
.index = 0,
};
}
/// Checks if the enumerator has a next item.
pub fn hasNext(self: Self) bool {
return self.index < self.array.contents.len;
}
/// Returns either a owned value or nothing.
/// Will replace the returned value in the enumerator array with `void`.
/// As the enumerator can only yield values from the array and does not "store"
/// them for later use, this prevents unnecessary clones.
pub fn next(self: *Self) ?Value {
if (self.index >= self.array.contents.len)
return null;
var result: Value = .void;
self.array.contents[self.index].exchangeWith(&result);
self.index += 1;
return result;
}
pub fn clone(self: Self) !Self {
return Self{
.array = try self.array.clone(),
.index = self.index,
};
}
// Enumerators are never equal to each other.
pub fn eql(lhs: Self, rhs: Self) bool {
return false;
}
pub fn deinit(self: *Self) void {
self.array.deinit();
self.* = undefined;
}
};
test "Enumerator" {
var array = try Array.init(std.testing.allocator, 3);
array.contents[0] = try Value.initString(std.testing.allocator, "a");
array.contents[1] = try Value.initString(std.testing.allocator, "b");
array.contents[2] = try Value.initString(std.testing.allocator, "c");
var enumerator = Enumerator.initFromOwned(array);
defer enumerator.deinit();
std.debug.assert(enumerator.hasNext());
var a = enumerator.next() orelse return error.NotEnoughItems;
defer a.deinit();
var b = enumerator.next() orelse return error.NotEnoughItems;
defer b.deinit();
var c = enumerator.next() orelse return error.NotEnoughItems;
defer c.deinit();
std.debug.assert(enumerator.next() == null);
std.debug.assert(a == .string);
std.debug.assert(b == .string);
std.debug.assert(c == .string);
std.debug.assert(std.mem.eql(u8, a.string.contents, "a"));
std.debug.assert(std.mem.eql(u8, b.string.contents, "b"));
std.debug.assert(std.mem.eql(u8, c.string.contents, "c"));
}
test "Enumerator.eql" {
var array = try Array.init(std.testing.allocator, 0);
defer array.deinit();
var enumerator1 = try Enumerator.init(array);
defer enumerator1.deinit();
var enumerator2 = try Enumerator.init(array);
defer enumerator2.deinit();
std.debug.assert(enumerator1.eql(enumerator2) == false);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/runtime/environment.zig | const std = @import("std");
const iface = @import("interface");
const utility = @import("utility.zig");
// Import modules to reduce file size
usingnamespace @import("value.zig");
usingnamespace @import("../common/compile-unit.zig");
usingnamespace @import("context.zig");
usingnamespace @import("vm.zig");
usingnamespace @import("objects.zig");
/// A script function contained in either this or a foreign
/// environment. For foreign environments.
pub const ScriptFunction = struct {
/// This is a reference to the environment for that function.
/// If the environment is `null`, the environment is context-sensitive
/// and will always be the environment that provided that function.
/// This is a "workaround" for not storing a pointer-to-self in Environment for
/// embedded script functions.
environment: ?*Environment,
entryPoint: u32,
localCount: u16,
};
const UserFunctionCall = fn (
environment: *Environment,
context: Context,
args: []const Value,
) anyerror!Value;
/// A synchronous function that may be called from the script environment
pub const UserFunction = struct {
const Self = @This();
/// Context, will be passed to `call`.
context: Context,
/// Executes the function, returns a value synchronously.
call: UserFunctionCall,
/// Optional destructor that may free the memory stored in `context`.
/// Is called when the function call is deinitialized.
destructor: ?fn (context: Context) void,
pub fn deinit(self: *Self) void {
if (self.destructor) |dtor| {
dtor(self.context);
}
self.* = undefined;
}
};
test "UserFunction (destructor)" {
var uf1: UserFunction = .{
.context = Context.initVoid(),
.call = undefined,
.destructor = null,
};
defer uf1.deinit();
var uf2: UserFunction = .{
.context = Context.init(u32, try std.testing.allocator.create(u32)),
.call = undefined,
.destructor = struct {
fn destructor(ctx: Context) void {
std.testing.allocator.destroy(ctx.get(u32));
}
}.destructor,
};
defer uf2.deinit();
}
/// An asynchronous function that yields execution of the VM
/// and can be resumed later.
pub const AsyncUserFunction = struct {
const Self = @This();
/// Context, will be passed to `call`.
context: Context,
/// Begins execution of this function.
/// After the initialization, the return value will be invoked once
/// to check if the function can finish synchronously.
call: fn (context: Context, args: []const Value) anyerror!AsyncFunctionCall,
/// Optional destructor that may free the memory stored in `context`.
/// Is called when the function call is deinitialized.
destructor: ?fn (context: Context) void,
pub fn deinit(self: *Self) void {
if (self.destructor) |dtor| {
dtor(self.context);
}
self.* = undefined;
}
};
test "AsyncUserFunction (destructor)" {
var uf1: AsyncUserFunction = .{
.context = undefined,
.call = undefined,
.destructor = null,
};
defer uf1.deinit();
var uf2: AsyncUserFunction = .{
.context = Context.init(u32, try std.testing.allocator.create(u32)),
.call = undefined,
.destructor = struct {
fn destructor(ctx: Context) void {
std.testing.allocator.destroy(ctx.get(u32));
}
}.destructor,
};
defer uf2.deinit();
}
/// An asynchronous execution state.
pub const AsyncFunctionCall = struct {
const Self = @This();
/// The object this call state is associated with. This is required to
/// prevent calling functions that operate on dead objects.
/// This field is set by the VM and should not be initialized by the creator
/// of the call.
object: ?ObjectHandle = null,
/// The context may be used to to store the state of this function call.
/// This may be created with `@sliceToBytes`.
context: Context,
/// Executor that will run this function call.
/// May return a value (function call completed) or `null` (function call still in progress).
execute: fn (context: Context) anyerror!?Value,
/// Optional destructor that may free the memory stored in `context`.
/// Is called when the function call is deinitialized.
destructor: ?fn (context: Context) void,
pub fn deinit(self: *Self) void {
if (self.destructor) |dtor| {
dtor(self.context);
}
self.* = undefined;
}
};
test "AsyncFunctionCall.deinit" {
const Helper = struct {
fn destroy(context: Context) void {
std.testing.allocator.destroy(context.get(u32));
}
fn exec(context: Context) anyerror!?Value {
return error.NotSupported;
}
};
var callWithDtor = AsyncFunctionCall{
.object = null,
.context = Context.init(u32, try std.testing.allocator.create(u32)),
.execute = Helper.exec,
.destructor = Helper.destroy,
};
defer callWithDtor.deinit();
var callNoDtor = AsyncFunctionCall{
.object = null,
.context = undefined,
.execute = Helper.exec,
.destructor = null,
};
defer callNoDtor.deinit();
}
/// A function that can be called by a script.
pub const Function = union(enum) {
const Self = @This();
/// This is another function of a script. It may be a foreign
/// or local script to the environment.
script: ScriptFunction,
/// A synchronous function like `Sin` that executes in very short time.
syncUser: UserFunction,
/// An asynchronous function that will yield the VM execution.
asyncUser: AsyncUserFunction,
pub fn initSimpleUser(fun: fn (env: *Environment, context: Context, args: []const Value) anyerror!Value) Function {
return Self{
.syncUser = UserFunction{
.context = Context.initVoid(),
.destructor = null,
.call = fun,
},
};
}
fn zigTypeToLoLa(comptime T: type) TypeId {
const info = @typeInfo(T);
if (info == .Int)
return TypeId.number;
if (info == .Float)
return TypeId.number;
return switch (T) {
bool => TypeId.boolean,
ObjectHandle => TypeId.object,
void => TypeId.void,
[]const u8 => TypeId.string,
else => @compileError(@typeName(T) ++ " is not a wrappable type!"),
};
}
fn convertToZigValue(comptime Target: type, value: Value) !Target {
const info = @typeInfo(Target);
if (info == .Int)
return try value.toInteger(Target);
if (info == .Float)
return @floatCast(Target, try value.toNumber());
return switch (Target) {
// Native types
void => try value.toVoid(),
bool => try value.toBoolean(),
[]const u8 => value.toString(),
// LoLa types
ObjectHandle => try value.toObject(),
String => if (value == .string)
value.string
else
return error.TypeMismatch,
Array => value.toArray(),
Value => value,
else => @compileError(@typeName(T) ++ " is not a wrappable type!"),
};
}
fn convertToLoLaValue(allocator: *std.mem.Allocator, value: anytype) !Value {
const T = @TypeOf(value);
const info = @typeInfo(T);
if (info == .Int)
return Value.initInteger(T, value);
if (info == .Float)
return Value.initNumber(value);
return switch (T) {
// Native types
void => .void,
bool => Value.initBoolean(value),
[]const u8 => try Value.initString(allocator, value),
// LoLa types
ObjectHandle => Value.initObject(value),
String => Value.fromString(value),
Array => Value.fromArray(value),
Value => value,
else => @compileError(@typeName(T) ++ " is not a wrappable type!"),
};
}
/// Wraps a native zig function into a LoLa function.
/// The function may take any number of arguments of supported types and return one of those as well.
/// Supported types are:
/// - `lola.runtime.Value`
/// - `lola.runtime.String`
/// - `lola.runtime.Array`
/// - `lola.runtime.ObjectHandle`
/// - any integer type
/// - any floating point type
/// - `bool`
/// - `void`
/// - `[]const u8`
/// Note that when you receive arguments, you don't own them. Do not free or store String or Array values.
/// When you return a String or Array, you hand over ownership of that value to the LoLa vm.
pub fn wrap(comptime function: anytype) Function {
const F = @TypeOf(function);
const info = @typeInfo(F);
if (info != .Fn)
@compileError("Function.wrap expects a function!");
const function_info = info.Fn;
if (function_info.is_generic)
@compileError("Cannot wrap generic functions!");
if (function_info.is_var_args)
@compileError("Cannot wrap functions with variadic arguments!");
const ArgsTuple = std.meta.ArgsTuple(F);
const Impl = struct {
fn invoke(env: *Environment, context: Context, args: []const Value) anyerror!Value {
if (args.len != function_info.args.len)
return error.InvalidArgs;
var zig_args: ArgsTuple = undefined;
comptime var index = 0;
while (index < function_info.args.len) : (index += 1) {
const T = function_info.args[index].arg_type.?;
zig_args[index] = try convertToZigValue(T, args[index]);
}
const ReturnType = function_info.return_type.?;
const ActualReturnType = switch (@typeInfo(ReturnType)) {
.ErrorUnion => |eu| eu.payload,
else => ReturnType,
};
var result: ActualReturnType = if (ReturnType != ActualReturnType)
try @call(.{}, function, zig_args)
else
@call(.{}, function, zig_args);
return try convertToLoLaValue(env.allocator, result);
}
};
return initSimpleUser(Impl.invoke);
}
pub fn deinit(self: *@This()) void {
switch (self.*) {
.script => {},
.syncUser => |*f| f.deinit(),
.asyncUser => |*f| f.deinit(),
}
}
};
/// An execution environment provides all needed
/// data to execute a compiled piece of code.
/// It stores its global variables, available functions
/// and available features.
pub const Environment = struct {
const Self = @This();
allocator: *std.mem.Allocator,
/// The compile unit that provides the executed script.
compileUnit: *const CompileUnit,
/// Global variables required by the script.
scriptGlobals: []Value,
/// Object interface to
objectPool: ObjectPoolInterface,
/// Stores all available global functions.
/// Functions will be contained in this unit and will be deinitialized,
/// the name must be kept alive until end of the environment.
functions: std.StringHashMap(Function),
/// This is called when the destroyObject is called.
destructor: ?fn (self: *Environment) void,
pub fn init(allocator: *std.mem.Allocator, compileUnit: *const CompileUnit, object_pool: ObjectPoolInterface) !Self {
var self = Self{
.allocator = allocator,
.compileUnit = compileUnit,
.objectPool = object_pool,
.scriptGlobals = undefined,
.functions = undefined,
.destructor = null,
};
self.scriptGlobals = try allocator.alloc(Value, compileUnit.globalCount);
errdefer allocator.free(self.scriptGlobals);
for (self.scriptGlobals) |*glob| {
glob.* = .void;
}
self.functions = std.StringHashMap(Function).init(allocator);
errdefer self.functions.deinit();
for (compileUnit.functions) |srcfun| {
var fun = Function{
.script = ScriptFunction{
.environment = null, // this is a "self-contained" script function
.entryPoint = srcfun.entryPoint,
.localCount = srcfun.localCount,
},
};
_ = try self.functions.put(srcfun.name, fun);
}
return self;
}
pub fn deinit(self: *Self) void {
var iter = self.functions.iterator();
while (iter.next()) |fun| {
fun.value.deinit();
}
for (self.scriptGlobals) |*glob| {
glob.deinit();
}
self.functions.deinit();
self.allocator.free(self.scriptGlobals);
self.* = undefined;
}
/// Adds a function to the environment and makes it available for the script.
pub fn installFunction(self: *Self, name: []const u8, function: Function) !void {
var result = try self.functions.getOrPut(name);
if (result.found_existing)
return error.AlreadyExists;
result.entry.value = function;
}
// Implementation to make a Environment a valid LoLa object:
pub fn getMethod(self: *Self, name: []const u8) ?Function {
if (self.functions.get(name)) |fun| {
var mut_fun = fun;
if (mut_fun == .script and mut_fun.script.environment == null)
mut_fun.script.environment = self;
return mut_fun;
} else {
return null;
}
}
/// This is called when the object is removed from the associated object pool.
pub fn destroyObject(self: *Self) void {
if (self.destructor) |dtor| {
dtor(self);
}
}
/// Computes a unique signature for this environment based on
/// the size and functions stored in the environment. This is used
/// for serialization to ensure that Environments are restored into same
/// state is it was serialized from previously.
fn computeSignature(self: Self) u64 {
var hasher = std.hash.SipHash64(2, 4).init("Environment Serialization Version 1");
// Hash all function names to create reproducability
{
var iter = self.functions.iterator();
while (iter.next()) |item| {
hasher.update(item.key);
}
}
// safe the length of the script globals as a bad signature for
// the comileUnit
{
var buf: [8]u8 = undefined;
std.mem.writeIntLittle(u64, &buf, self.scriptGlobals.len);
hasher.update(&buf);
}
return hasher.finalInt();
}
/// Serializes the environment globals in a way that these
/// are restorable later.
pub fn serialize(self: Self, stream: anytype) !void {
const sig = self.computeSignature();
try stream.writeIntLittle(u64, sig);
for (self.scriptGlobals) |glob| {
try glob.serialize(stream);
}
}
/// Deserializes the environment globals. This might fail with
/// `error.SignatureMismatch` when a environment with a different signature
/// is restored.
pub fn deserialize(self: *Self, stream: anytype) !void {
const sig_env = self.computeSignature();
const sig_ser = try stream.readIntLittle(u64);
if (sig_env != sig_ser)
return error.SignatureMismatch;
for (self.scriptGlobals) |*glob| {
const val = try Value.deserialize(stream, self.allocator);
glob.replaceWith(val);
}
}
};
test "Environment" {
const cu = CompileUnit{
.arena = undefined,
.comment = "",
.globalCount = 4,
.temporaryCount = 0,
.code = "",
.functions = &[_]CompileUnit.Function{
CompileUnit.Function{
.name = "fun1",
.entryPoint = 10,
.localCount = 5,
},
CompileUnit.Function{
.name = "fun_2",
.entryPoint = 21,
.localCount = 1,
},
CompileUnit.Function{
.name = "fun 3",
.entryPoint = 32,
.localCount = 3,
},
},
.debugSymbols = &[0]CompileUnit.DebugSymbol{},
};
var pool = ObjectPool(.{}).init(std.testing.allocator);
defer pool.deinit();
var env = try Environment.init(std.testing.allocator, &cu, pool.interface());
defer env.deinit();
std.debug.assert(env.scriptGlobals.len == 4);
std.debug.assert(env.functions.count() == 3);
const f1 = env.getMethod("fun1") orelse unreachable;
const f2 = env.getMethod("fun_2") orelse unreachable;
const f3 = env.getMethod("fun 3") orelse unreachable;
std.testing.expectEqual(@as(usize, 10), f1.script.entryPoint);
std.testing.expectEqual(@as(usize, 5), f1.script.localCount);
std.testing.expectEqual(&env, f1.script.environment.?);
std.testing.expectEqual(@as(usize, 21), f2.script.entryPoint);
std.testing.expectEqual(@as(usize, 1), f2.script.localCount);
std.testing.expectEqual(&env, f2.script.environment.?);
std.testing.expectEqual(@as(usize, 32), f3.script.entryPoint);
std.testing.expectEqual(@as(usize, 3), f3.script.localCount);
std.testing.expectEqual(&env, f3.script.environment.?);
}
test "Function.wrap" {
const Funcs = struct {
fn returnVoid() void {
unreachable;
}
fn returnValue() Value {
unreachable;
}
fn returnString() String {
unreachable;
}
fn returnArray() Array {
unreachable;
}
fn returnObjectHandle() ObjectHandle {
unreachable;
}
fn returnInt8() u8 {
unreachable;
}
fn returnInt63() i63 {
unreachable;
}
fn returnF64() f64 {
unreachable;
}
fn returnF16() f16 {
unreachable;
}
fn returnBool() bool {
unreachable;
}
fn returnStringLit() []const u8 {
unreachable;
}
fn takeVoid(value: void) void {
unreachable;
}
fn takeValue(value: Value) void {
unreachable;
}
fn takeString(value: String) void {
unreachable;
}
fn takeArray(value: Array) void {
unreachable;
}
fn takeObjectHandle(value: ObjectHandle) void {
unreachable;
}
fn takeInt8(value: u8) void {
unreachable;
}
fn takeInt63(value: i63) void {
unreachable;
}
fn takeF64(value: f64) void {
unreachable;
}
fn takeF16(value: f16) void {
unreachable;
}
fn takeBool(value: bool) void {
unreachable;
}
fn takeStringLit(value: []const u8) void {
unreachable;
}
fn takeAll(
a0: Value,
a1: String,
a2: Array,
a3: ObjectHandle,
a4_1: u7,
a4_2: i33,
a5_1: f32,
a5_2: f16,
a6: bool,
a7: void,
a8: []const u8,
) void {
unreachable;
}
};
inline for (std.meta.declarations(Funcs)) |fun| {
_ = Function.wrap(@field(Funcs, fun.name));
}
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/runtime/environmentmap.zig | const std = @import("std");
const lola = @import("../main.zig");
/// This map is required by the VM serialization to identify environment pointers
/// and allow serialization/deserialization of the correct references.
pub const EnvironmentMap = struct {
const Self = @This();
const Entry = struct {
env: *lola.runtime.Environment,
id: u32,
};
items: std.ArrayList(Entry),
pub fn init(allocator: *std.mem.Allocator) Self {
return Self{
.items = std.ArrayList(Entry).init(allocator),
};
}
pub fn deinit(self: *Self) void {
self.items.deinit();
self.* = undefined;
}
/// Adds a new environment-id-pair to the map.
/// Will return `error.IdAlreadyMapped` if a environment with this ID already exists,
/// will return `error.EnvironmentAlreadyMapped` if the given environment is already in the map.
/// Will return `error.OutOfMemory` when the internal storage cannot be resized.
pub fn add(self: *Self, id: u32, env: *lola.runtime.Environment) !void {
for (self.items.items) |item| {
if (item.id == id)
return error.IdAlreadyMapped;
if (item.env == env)
return error.EnvironmentAlreadyMapped;
}
try self.items.append(Entry{
.id = id,
.env = env,
});
}
/// Returns the ID for the given environment or `null` if the environment was not registered.
pub fn queryByPtr(self: Self, env: *lola.runtime.Environment) ?u32 {
return for (self.items.items) |item| {
if (item.env == env)
break item.id;
} else null;
}
/// Returns the Environment for the given id or `null` if the environment was not registered.
pub fn queryById(self: Self, id: u32) ?*lola.runtime.Environment {
return for (self.items.items) |item| {
if (item.id == id)
break item.env;
} else null;
}
};
test "EnvironmentMap" {
// three storage locations
var env_1: lola.runtime.Environment = undefined;
var env_2: lola.runtime.Environment = undefined;
var env_3: lola.runtime.Environment = undefined;
var map = EnvironmentMap.init(std.testing.allocator);
defer map.deinit();
try map.add(1, &env_1);
try map.add(2, &env_2);
std.testing.expectEqual(@as(?*lola.runtime.Environment, &env_1), map.queryById(1));
std.testing.expectEqual(@as(?*lola.runtime.Environment, &env_2), map.queryById(2));
std.testing.expectEqual(@as(?*lola.runtime.Environment, null), map.queryById(3));
std.testing.expectEqual(@as(?u32, 1), map.queryByPtr(&env_1));
std.testing.expectEqual(@as(?u32, 2), map.queryByPtr(&env_2));
std.testing.expectEqual(@as(?u32, null), map.queryByPtr(&env_3));
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/common/disassembler.zig | const std = @import("std");
usingnamespace @import("compile-unit.zig");
usingnamespace @import("decoder.zig");
usingnamespace @import("ir.zig");
pub const DisassemblerOptions = struct {
/// Prefix each line of the disassembly with the hexadecimal address.
addressPrefix: bool = false,
/// If set, a hexdump with both hex- and ascii display will be emitted.
/// Each line of text will contain `hexwidth` number of bytes.
hexwidth: ?usize = null,
/// If set to `true`, the output will contain a line with the
/// name of function that starts at this offset. This option
/// is set by default.
labelOutput: bool = true,
/// If set to `true`, the disassembled instruction will be emitted.
/// This is set by default.
instructionOutput: bool = true,
};
/// Disassembles a given compile unit into a text stream.
/// The output of the disassembler is adjustable to different formats.
/// If all output is disabled in the config, this function can also be used
/// to verify that a compile unit can be parsed completly without any problems.
pub fn disassemble(stream: anytype, cu: CompileUnit, options: DisassemblerOptions) !void {
var decoder = Decoder.init(cu.code);
const anyOutput = options.addressPrefix or options.labelOutput or options.instructionOutput or (options.hexwidth != null);
if (options.addressPrefix)
try stream.print("{X:0>6}\t", .{decoder.offset});
if (options.labelOutput)
try stream.writeAll("<main>:\n");
while (!decoder.isEof()) {
if (options.labelOutput) {
for (cu.functions) |fun| {
if (fun.entryPoint == decoder.offset) {
if (options.addressPrefix)
try stream.print("{X:0>6}\t", .{decoder.offset});
try stream.print("{}:\n", .{fun.name});
}
}
}
if (options.addressPrefix)
try stream.print("{X:0>6}\t", .{decoder.offset});
const start = decoder.offset;
const instr = try decoder.read(Instruction);
const end = decoder.offset;
if (options.hexwidth) |hw| {
try writeHexDump(stream, decoder.data, start, end, hw);
}
if (options.instructionOutput) {
try stream.writeAll("\t");
try stream.writeAll(@tagName(@as(InstructionName, instr)));
inline for (std.meta.fields(Instruction)) |fld| {
if (instr == @field(InstructionName, fld.name)) {
if (fld.field_type == Instruction.Deprecated) {
// no-op
} else if (fld.field_type == Instruction.NoArg) {
// no-op
} else if (fld.field_type == Instruction.CallArg) {
const args = @field(instr, fld.name);
try stream.print(" {} {}", .{ args.function, args.argc });
} else {
if (@TypeOf(@field(instr, fld.name).value) == f64) {
try stream.print(" {d}", .{@field(instr, fld.name).value});
} else if (instr == .jif or instr == .jmp or instr == .jnf) {
try stream.print(" 0x{X}", .{@field(instr, fld.name).value});
} else {
try stream.print(" {}", .{@field(instr, fld.name).value});
}
}
}
}
}
if (anyOutput)
try stream.writeAll("\n");
if (options.hexwidth) |hw| {
var cursor = start + hw;
var paddedEnd = start + 2 * hw;
while (paddedEnd < end + hw) : (paddedEnd += hw) {
if (options.addressPrefix)
try stream.print("{X:0>6}\t", .{cursor});
try writeHexDump(stream, decoder.data, cursor, end, hw);
cursor += hw;
try stream.writeAll("\n");
}
}
}
}
fn writeHexDump(stream: anytype, data: []const u8, begin: usize, end: usize, width: usize) !void {
var offset_hex = begin;
while (offset_hex < begin + width) : (offset_hex += 1) {
if (offset_hex < end) {
try stream.print("{X:0>2} ", .{data[offset_hex]});
} else {
try stream.writeAll(" ");
}
}
try stream.writeAll("|");
var offset_bin = begin;
while (offset_bin < begin + width) : (offset_bin += 1) {
if (offset_bin < end) {
if (std.ascii.isPrint(data[offset_bin])) {
try stream.print("{c}", .{data[offset_bin]});
} else {
try stream.writeAll(".");
}
} else {
try stream.writeAll(" ");
}
}
try stream.writeAll("|");
}
test "disassemble" {
// dummy test
_ = disassemble;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/common/compile-unit.zig | const std = @import("std");
const utility = @import("utility.zig");
// Import modules to reduce file size
// usingnamespace @import("value.zig");
/// A compiled piece of code, provides the building blocks for
/// an environment. Note that a compile unit must be instantiated
/// into an environment to be executed.
pub const CompileUnit = struct {
const Self = @This();
/// Description of a script function.
pub const Function = struct {
name: []const u8,
entryPoint: u32,
localCount: u16,
};
/// A mapping of which code portion belongs to which
/// line in the source code.
/// Lines are valid from offset until the next available symbol.
pub const DebugSymbol = struct {
/// Offset of the symbol from the start of the compiled code.
offset: u32,
/// The line number, starting at 1.
sourceLine: u32,
/// The offset into the line, starting at 1.
sourceColumn: u16,
};
arena: std.heap.ArenaAllocator,
/// Freeform file structure comment. This usually contains the file name of the compile file.
comment: []const u8,
/// Number of global (persistent) variables stored in the environment
globalCount: u16,
/// Number of temporary (local) variables in the global scope.
temporaryCount: u16,
/// The compiled binary code.
code: []u8,
/// Array of function definitions
functions: []const Function,
/// Sorted array of debug symbols
debugSymbols: []const DebugSymbol,
/// Loads a compile unit from a data stream.
pub fn loadFromStream(allocator: *std.mem.Allocator, stream: anytype) !Self {
// var inStream = file.getInStream();
// var stream = &inStream.stream;
var header: [8]u8 = undefined;
stream.readNoEof(&header) catch |err| switch (err) {
error.EndOfStream => return error.InvalidFormat, // file is too short!
else => return err,
};
if (!std.mem.eql(u8, &header, "LoLa\xB9\x40\x80\x5A"))
return error.InvalidFormat;
const version = try stream.readIntLittle(u32);
if (version != 1)
return error.UnsupportedVersion;
var comment: [256]u8 = undefined;
try stream.readNoEof(&comment);
var unit = Self{
.arena = std.heap.ArenaAllocator.init(allocator),
.globalCount = undefined,
.temporaryCount = undefined,
.code = undefined,
.functions = undefined,
.debugSymbols = undefined,
.comment = undefined,
};
errdefer unit.arena.deinit();
unit.comment = try std.mem.dupe(&unit.arena.allocator, u8, utility.clampFixedString(&comment));
unit.globalCount = try stream.readIntLittle(u16);
unit.temporaryCount = try stream.readIntLittle(u16);
const functionCount = try stream.readIntLittle(u16);
const codeSize = try stream.readIntLittle(u32);
const numSymbols = try stream.readIntLittle(u32);
if (functionCount > codeSize or numSymbols > codeSize) {
// It is not reasonable to have multiple functions per
// byte of code.
// The same is valid for debug symbols.
return error.CorruptedData;
}
const functions = try unit.arena.allocator.alloc(Function, functionCount);
const code = try unit.arena.allocator.alloc(u8, codeSize);
const debugSymbols = try unit.arena.allocator.alloc(DebugSymbol, numSymbols);
for (functions) |*fun| {
var name: [128]u8 = undefined;
try stream.readNoEof(&name);
const entryPoint = try stream.readIntLittle(u32);
const localCount = try stream.readIntLittle(u16);
fun.* = Function{
.name = try std.mem.dupe(&unit.arena.allocator, u8, utility.clampFixedString(&name)),
.entryPoint = entryPoint,
.localCount = localCount,
};
}
unit.functions = functions;
try stream.readNoEof(code);
unit.code = code;
for (debugSymbols) |*sym| {
const offset = try stream.readIntLittle(u32);
const sourceLine = try stream.readIntLittle(u32);
const sourceColumn = try stream.readIntLittle(u16);
sym.* = DebugSymbol{
.offset = offset,
.sourceLine = sourceLine,
.sourceColumn = sourceColumn,
};
}
std.sort.sort(DebugSymbol, debugSymbols, {}, struct {
fn lessThan(context: void, lhs: DebugSymbol, rhs: DebugSymbol) bool {
return lhs.offset < rhs.offset;
}
}.lessThan);
unit.debugSymbols = debugSymbols;
return unit;
}
/// Saves a compile unit to a data stream.
pub fn saveToStream(self: Self, stream: anytype) !void {
try stream.writeAll("LoLa\xB9\x40\x80\x5A");
try stream.writeIntLittle(u32, 1);
try stream.writeAll(self.comment);
try stream.writeByteNTimes(0, 256 - self.comment.len);
try stream.writeIntLittle(u16, self.globalCount);
try stream.writeIntLittle(u16, self.temporaryCount);
try stream.writeIntLittle(u16, @intCast(u16, self.functions.len));
try stream.writeIntLittle(u32, @intCast(u32, self.code.len));
try stream.writeIntLittle(u32, @intCast(u32, self.debugSymbols.len));
for (self.functions) |fun| {
try stream.writeAll(fun.name);
try stream.writeByteNTimes(0, 128 - fun.name.len);
try stream.writeIntNative(u32, fun.entryPoint);
try stream.writeIntNative(u16, fun.localCount);
}
try stream.writeAll(self.code);
for (self.debugSymbols) |sym| {
try stream.writeIntNative(u32, sym.offset);
try stream.writeIntNative(u32, sym.sourceLine);
try stream.writeIntNative(u16, sym.sourceColumn);
}
}
/// Searches for a debug symbol that preceeds the given address.
/// Function assumes that CompileUnit.debugSymbols is sorted
/// front-to-back by offset.
pub fn lookUp(self: Self, offset: u32) ?DebugSymbol {
if (offset >= self.code.len)
return null;
var result: ?DebugSymbol = null;
for (self.debugSymbols) |sym| {
if (sym.offset > offset)
break;
result = sym;
}
return result;
}
pub fn deinit(self: Self) void {
self.arena.deinit();
}
};
const serializedCompileUnit = "" // SoT
++ "LoLa\xB9\x40\x80\x5A" // Header
++ "\x01\x00\x00\x00" // Version
++ "Made with NativeLola.zig!" ++ ("\x00" ** (256 - 25)) // Comment
++ "\x03\x00" // globalCount
++ "\x55\x11" // temporaryCount
++ "\x02\x00" // functionCount
++ "\x05\x00\x00\x00" // codeSize
++ "\x03\x00\x00\x00" // numSymbols
++ "Function1" ++ ("\x00" ** (128 - 9)) // Name
++ "\x00\x00\x00\x00" // entryPoint
++ "\x01\x00" // localCount
++ "Function2" ++ ("\x00" ** (128 - 9)) // Name
++ "\x10\x10\x00\x00" // entryPoint
++ "\x02\x00" // localCount
++ "Hello" // code
++ "\x01\x00\x00\x00" ++ "\x01\x00\x00\x00" ++ "\x01\x00" // dbgSym1
++ "\x02\x00\x00\x00" ++ "\x02\x00\x00\x00" ++ "\x04\x00" // dbgSym2
++ "\x04\x00\x00\x00" ++ "\x03\x00\x00\x00" ++ "\x08\x00" // dbgSym3
;
test "CompileUnit I/O" {
var sliceInStream = std.io.fixedBufferStream(serializedCompileUnit);
const cu = try CompileUnit.loadFromStream(std.testing.allocator, sliceInStream.reader());
defer cu.deinit();
std.debug.assert(std.mem.eql(u8, cu.comment, "Made with NativeLola.zig!"));
std.debug.assert(cu.globalCount == 3);
std.debug.assert(cu.temporaryCount == 0x1155);
std.debug.assert(std.mem.eql(u8, cu.code, "Hello"));
std.debug.assert(cu.functions.len == 2);
std.debug.assert(cu.debugSymbols.len == 3);
std.debug.assert(std.mem.eql(u8, cu.functions[0].name, "Function1"));
std.debug.assert(cu.functions[0].entryPoint == 0x00000000);
std.debug.assert(cu.functions[0].localCount == 1);
std.debug.assert(std.mem.eql(u8, cu.functions[1].name, "Function2"));
std.debug.assert(cu.functions[1].entryPoint == 0x00001010);
std.debug.assert(cu.functions[1].localCount == 2);
std.debug.assert(cu.debugSymbols[0].offset == 1);
std.debug.assert(cu.debugSymbols[0].sourceLine == 1);
std.debug.assert(cu.debugSymbols[0].sourceColumn == 1);
std.debug.assert(cu.debugSymbols[1].offset == 2);
std.debug.assert(cu.debugSymbols[1].sourceLine == 2);
std.debug.assert(cu.debugSymbols[1].sourceColumn == 4);
std.debug.assert(cu.debugSymbols[2].offset == 4);
std.debug.assert(cu.debugSymbols[2].sourceLine == 3);
std.debug.assert(cu.debugSymbols[2].sourceColumn == 8);
var storage: [serializedCompileUnit.len]u8 = undefined;
var sliceOutStream = std.io.fixedBufferStream(&storage);
try cu.saveToStream(sliceOutStream.writer());
std.debug.assert(sliceOutStream.getWritten().len == serializedCompileUnit.len);
std.debug.assert(std.mem.eql(u8, sliceOutStream.getWritten(), serializedCompileUnit));
}
test "CompileUnit.lookUp" {
var sliceInStream = std.io.fixedBufferStream(serializedCompileUnit);
const cu = try CompileUnit.loadFromStream(std.testing.allocator, sliceInStream.reader());
defer cu.deinit();
std.debug.assert(cu.lookUp(0) == null); // no debug symbol before 1
std.debug.assert(cu.lookUp(1).?.sourceLine == 1);
std.debug.assert(cu.lookUp(2).?.sourceLine == 2);
std.debug.assert(cu.lookUp(3).?.sourceLine == 2);
std.debug.assert(cu.lookUp(4).?.sourceLine == 3);
std.debug.assert(cu.lookUp(5) == null); // no debug symbol after end-of-code
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/common/utility.zig | const std = @import("std");
pub fn clampFixedString(str: []const u8) []const u8 {
if (std.mem.indexOfScalar(u8, str, 0)) |off| {
return str[0..off];
} else {
return str;
}
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/common/ir.zig | /// This enumeration contains all possible instructions and assigns each a value.
pub const InstructionName = enum(u8) {
nop = 0,
scope_push = 1, // deprecated
scope_pop = 2, // deprecated
declare = 3, // deprecated
store_global_name = 4, // deprecated
load_global_name = 5, // deprecated
push_str = 6,
push_num = 7,
array_pack = 8,
call_fn = 9,
call_obj = 10,
pop = 11,
add = 12,
sub = 13,
mul = 14,
div = 15,
mod = 16,
bool_and = 17,
bool_or = 18,
bool_not = 19,
negate = 20,
eq = 21,
neq = 22,
less_eq = 23,
greater_eq = 24,
less = 25,
greater = 26,
jmp = 27,
jnf = 28,
iter_make = 29,
iter_next = 30,
array_store = 31,
array_load = 32,
ret = 33,
store_local = 34,
load_local = 35,
// HERE BE HOLE
retval = 37,
jif = 38,
store_global_idx = 39,
load_global_idx = 40,
push_true = 41,
push_false = 42,
push_void = 43,
};
/// This union contains each possible instruction with its (optional) arguments already encoded.
/// Each instruction type is either `NoArg`, `SingleArg`, `CallArg` or `Deprecated`, defining how
/// each instruction is encoded.
/// This information can be used to encode/decode the instructions based on their meta-information.
pub const Instruction = union(InstructionName) {
pub const Deprecated = struct {};
pub const NoArg = struct {};
fn SingleArg(comptime T: type) type {
return struct { value: T };
}
pub const CallArg = struct {
function: []const u8,
argc: u8,
};
nop: NoArg,
scope_push: Deprecated,
scope_pop: Deprecated,
declare: Deprecated,
store_global_name: Deprecated,
load_global_name: Deprecated,
push_str: SingleArg([]const u8),
push_num: SingleArg(f64),
array_pack: SingleArg(u16),
call_fn: CallArg,
call_obj: CallArg,
pop: NoArg,
add: NoArg,
sub: NoArg,
mul: NoArg,
div: NoArg,
mod: NoArg,
bool_and: NoArg,
bool_or: NoArg,
bool_not: NoArg,
negate: NoArg,
eq: NoArg,
neq: NoArg,
less_eq: NoArg,
greater_eq: NoArg,
less: NoArg,
greater: NoArg,
jmp: SingleArg(u32),
jnf: SingleArg(u32),
iter_make: NoArg,
iter_next: NoArg,
array_store: NoArg,
array_load: NoArg,
ret: NoArg,
store_local: SingleArg(u16),
load_local: SingleArg(u16),
retval: NoArg,
jif: SingleArg(u32),
store_global_idx: SingleArg(u16),
load_global_idx: SingleArg(u16),
push_true: NoArg,
push_false: NoArg,
push_void: NoArg,
};
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/common/decoder.zig | const std = @import("std");
const utility = @import("utility.zig");
// Import modules to reduce file size
usingnamespace @import("ir.zig");
usingnamespace @import("compile-unit.zig");
/// A struct that allows decoding data from LoLa IR code.
pub const Decoder = struct {
const Self = @This();
data: []const u8,
// we are restricted to 4GB code size in the binary format, the decoder itself can use the same restriction
offset: u32,
pub fn init(source: []const u8) Self {
return Self{
.data = source,
.offset = 0,
};
}
pub fn isEof(self: Self) bool {
return self.offset >= self.data.len;
}
pub fn readRaw(self: *Self, dest: []u8) !void {
if (self.offset == self.data.len)
return error.EndOfStream;
if (self.offset + dest.len > self.data.len)
return error.NotEnoughData;
std.mem.copy(u8, dest, self.data[self.offset .. self.offset + dest.len]);
self.offset += @intCast(u32, dest.len);
}
pub fn readBytes(self: *Self, comptime count: comptime_int) ![count]u8 {
var data: [count]u8 = undefined;
try self.readRaw(&data);
return data;
}
/// Reads a value of the given type from the data stream.
/// Allowed types are `u8`, `u16`, `u32`, `f64`, `Instruction`.
pub fn read(self: *Self, comptime T: type) !T {
if (T == Instruction) {
return readInstruction(self);
}
const data = try self.readBytes(@sizeOf(T));
switch (T) {
u8, u16, u32 => return std.mem.readIntLittle(T, &data),
f64 => return @bitCast(f64, data),
InstructionName => return try std.meta.intToEnum(InstructionName, data[0]),
else => @compileError("Unsupported type " ++ @typeName(T) ++ " for Decoder.read!"),
}
}
/// Reads a variable-length string from the data stream.
/// Note that the returned handle is only valid as long as Decoder.data is valid.
pub fn readVarString(self: *Self) ![]const u8 {
const len = try self.read(u16);
if (self.offset + len > self.data.len)
return error.NotEnoughData; // this is when a string tells you it's longer than the actual data storage.
const string = self.data[self.offset .. self.offset + len];
self.offset += len;
return string;
}
/// Reads a fixed-length string from the data. The string may either be 0-terminated
/// or use the available length completly.
/// Note that the returned handle is only valid as long as Decoder.data is valid.
pub fn readFixedString(self: *Self, comptime len: comptime_int) ![]const u8 {
if (self.offset == self.data.len)
return error.EndOfStream;
if (self.offset + len > self.data.len)
return error.NotEnoughData;
const fullMem = self.data[self.offset .. self.offset + len];
self.offset += len;
return utility.clampFixedString(fullMem);
}
/// Reads a a full instruction from the source.
/// This will provide full decoding and error checking.
fn readInstruction(self: *Self) !Instruction {
if (self.isEof())
return error.EndOfStream;
const instr = try self.read(InstructionName);
inline for (std.meta.fields(Instruction)) |fld| {
if (instr == @field(InstructionName, fld.name)) {
if (fld.field_type == Instruction.Deprecated) {
return error.DeprecatedInstruction;
} else if (fld.field_type == Instruction.NoArg) {
return @unionInit(Instruction, fld.name, .{});
} else if (fld.field_type == Instruction.CallArg) {
const fun = self.readVarString() catch |err| return mapEndOfStreamToNotEnoughData(err);
const argc = self.read(u8) catch |err| return mapEndOfStreamToNotEnoughData(err);
return @unionInit(Instruction, fld.name, Instruction.CallArg{
.function = fun,
.argc = argc,
});
} else {
const ValType = std.meta.fieldInfo(fld.field_type, "value").field_type;
if (ValType == []const u8) {
return @unionInit(Instruction, fld.name, fld.field_type{
.value = self.readVarString() catch |err| return mapEndOfStreamToNotEnoughData(err),
});
} else {
return @unionInit(Instruction, fld.name, fld.field_type{
.value = self.read(ValType) catch |err| return mapEndOfStreamToNotEnoughData(err),
});
}
}
}
}
return error.InvalidInstruction;
}
fn mapEndOfStreamToNotEnoughData(err: anytype) @TypeOf(err) {
return switch (err) {
error.EndOfStream => error.NotEnoughData,
else => err,
};
}
};
// zig fmt: off
const decoderTestBlob = [_]u8{
1,2,3, // "[3]u8"
8, // u8,
16, 0, // u16
32, 0, 0, 0, // u32
12, // Instruction "add"
5, 00, 'H', 'e', 'l', 'l', 'o', // String(*) "Hello"
0x1F, 0x85, 0xEB, 0x51, 0xB8, 0x1E, 0x09, 0x40, // f64 = 3.14000000000000012434 == 0x40091EB851EB851F
'B', 'y', 'e', 0, 0, 0, 0, 0, // String(8) "Bye"
};
// zig fmt: on
test "Decoder" {
var decoder = Decoder.init(&decoderTestBlob);
std.debug.assert(std.mem.eql(u8, &(try decoder.readBytes(3)), &[3]u8{ 1, 2, 3 }));
std.debug.assert((try decoder.read(u8)) == 8);
std.debug.assert((try decoder.read(u16)) == 16);
std.debug.assert((try decoder.read(u32)) == 32);
std.debug.assert((try decoder.read(InstructionName)) == .add);
std.debug.assert(std.mem.eql(u8, try decoder.readVarString(), "Hello"));
std.debug.assert((try decoder.read(f64)) == 3.14000000000000012434);
std.debug.assert(std.mem.eql(u8, try decoder.readFixedString(8), "Bye"));
if (decoder.readBytes(1)) |_| {
std.debug.assert(false);
} else |err| {
std.debug.assert(err == error.EndOfStream);
}
}
test "Decoder.NotEnoughData" {
const blob = [_]u8{1};
var decoder = Decoder.init(&blob);
if (decoder.read(u16)) |_| {
std.debug.assert(false);
} else |err| {
std.debug.assert(err == error.NotEnoughData);
}
}
test "Decoder.NotEnoughData (string)" {
const blob = [_]u8{ 1, 0 };
var decoder = Decoder.init(&blob);
if (decoder.readVarString()) |_| {
std.debug.assert(false);
} else |err| {
std.debug.assert(err == error.NotEnoughData);
}
}
test "Decoder.read(Instruction)" {
const Pattern = struct {
const ResultType = std.meta.declarationInfo(Decoder, "readInstruction").data.Fn.return_type;
text: []const u8,
instr: ResultType,
fn isMatch(self: @This(), testee: ResultType) bool {
if (self.instr) |a_p| {
if (testee) |b_p| return eql(a_p, b_p) else |_| return false;
} else |a_e| {
if (testee) |_| return false else |b_e| return a_e == b_e;
}
}
fn eql(a: Instruction, b: Instruction) bool {
@setEvalBranchQuota(5000);
const activeField = @as(InstructionName, a);
if (activeField != @as(InstructionName, b))
return false;
inline for (std.meta.fields(InstructionName)) |fld| {
if (activeField == @field(InstructionName, fld.name)) {
const FieldType = std.meta.fieldInfo(Instruction, fld.name).field_type;
const lhs = @field(a, fld.name);
const rhs = @field(b, fld.name);
if ((FieldType == Instruction.Deprecated) or (FieldType == Instruction.NoArg)) {
return true;
} else if (FieldType == Instruction.CallArg) {
return lhs.argc == rhs.argc and std.mem.eql(u8, lhs.function, rhs.function);
} else {
const ValType = std.meta.fieldInfo(FieldType, "value").field_type;
if (ValType == []const u8) {
return std.mem.eql(u8, lhs.value, rhs.value);
} else {
return lhs.value == rhs.value;
}
}
}
}
unreachable;
}
};
const patterns = [_]Pattern{
.{ .text = "\x00", .instr = Instruction{ .nop = .{} } },
.{ .text = "\x01", .instr = error.DeprecatedInstruction },
.{ .text = "\x02", .instr = error.DeprecatedInstruction },
.{ .text = "\x03", .instr = error.DeprecatedInstruction },
.{ .text = "\x06\x03\x00ABC", .instr = Instruction{ .push_str = .{ .value = "ABC" } } },
.{ .text = "\x07\x00\x00\x00\x00\x00\x00\x00\x00", .instr = Instruction{ .push_num = .{ .value = 0 } } },
.{ .text = "\x08\x00\x10", .instr = Instruction{ .array_pack = .{ .value = 0x1000 } } },
.{ .text = "\x09\x01\x00x\x01", .instr = Instruction{ .call_fn = .{ .function = "x", .argc = 1 } } },
.{ .text = "\x0A\x02\x00yz\x03", .instr = Instruction{ .call_obj = .{ .function = "yz", .argc = 3 } } },
.{ .text = "\x0B", .instr = Instruction{ .pop = .{} } },
.{ .text = "\x0C", .instr = Instruction{ .add = .{} } },
.{ .text = "\x0D", .instr = Instruction{ .sub = .{} } },
.{ .text = "\x0E", .instr = Instruction{ .mul = .{} } },
.{ .text = "\x0F", .instr = Instruction{ .div = .{} } },
.{ .text = "\x10", .instr = Instruction{ .mod = .{} } },
.{ .text = "\x11", .instr = Instruction{ .bool_and = .{} } },
.{ .text = "\x12", .instr = Instruction{ .bool_or = .{} } },
.{ .text = "\x13", .instr = Instruction{ .bool_not = .{} } },
.{ .text = "\x14", .instr = Instruction{ .negate = .{} } },
.{ .text = "\x15", .instr = Instruction{ .eq = .{} } },
.{ .text = "\x16", .instr = Instruction{ .neq = .{} } },
.{ .text = "\x17", .instr = Instruction{ .less_eq = .{} } },
.{ .text = "\x18", .instr = Instruction{ .greater_eq = .{} } },
.{ .text = "\x19", .instr = Instruction{ .less = .{} } },
.{ .text = "\x1A", .instr = Instruction{ .greater = .{} } },
.{ .text = "\x1B\x00\x11\x22\x33", .instr = Instruction{ .jmp = .{ .value = 0x33221100 } } },
.{ .text = "\x1C\x44\x33\x22\x11", .instr = Instruction{ .jnf = .{ .value = 0x11223344 } } },
.{ .text = "\x1D", .instr = Instruction{ .iter_make = .{} } },
.{ .text = "\x1E", .instr = Instruction{ .iter_next = .{} } },
.{ .text = "\x1F", .instr = Instruction{ .array_store = .{} } },
.{ .text = "\x20", .instr = Instruction{ .array_load = .{} } },
.{ .text = "\x21", .instr = Instruction{ .ret = .{} } },
.{ .text = "\x22\xDE\xBA", .instr = Instruction{ .store_local = .{ .value = 0xBADE } } },
.{ .text = "\x23\xFE\xAF", .instr = Instruction{ .load_local = .{ .value = 0xAFFE } } },
.{ .text = "\x25", .instr = Instruction{ .retval = .{} } },
.{ .text = "\x26\x00\x12\x34\x56", .instr = Instruction{ .jif = .{ .value = 0x56341200 } } },
.{ .text = "\x27\x34\x12", .instr = Instruction{ .store_global_idx = .{ .value = 0x1234 } } },
.{ .text = "\x28\x21\x43", .instr = Instruction{ .load_global_idx = .{ .value = 0x4321 } } },
.{ .text = "\x29", .instr = Instruction{ .push_true = .{} } },
.{ .text = "\x2A", .instr = Instruction{ .push_false = .{} } },
.{ .text = "\x2B", .instr = Instruction{ .push_void = .{} } },
.{ .text = "", .instr = error.EndOfStream },
.{ .text = "\x26", .instr = error.NotEnoughData },
.{ .text = "\x09\xFF", .instr = error.NotEnoughData },
.{ .text = "\x26\x00\x00", .instr = error.NotEnoughData },
.{ .text = "\x09\xFF\xFF", .instr = error.NotEnoughData },
};
for (patterns) |pattern| {
var decoder = Decoder.init(pattern.text);
const instruction = decoder.read(Instruction);
if (!pattern.isMatch(instruction)) {
std.debug.warn("expected {}, got {}\n", .{ pattern.instr, instruction });
std.debug.assert(false);
}
}
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/compiler/location.zig | const std = @import("std");
/// A location in a chunk of text. Can be used to locate tokens and AST structures.
pub const Location = struct {
/// the name of the file/chunk this location is relative to
chunk: []const u8,
/// source line, starting at 1
line: u32,
/// source column, starting at 1
column: u32,
/// Offset to the start of the location
offset_start: usize,
/// Offset to the end of the location
offset_end: usize,
pub fn getLength(self: @This()) usize {
return self.offset_end - self.offset_start;
}
pub fn format(self: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
try writer.print("{}:{}:{}", .{ self.chunk, self.line, self.column });
}
pub fn merge(a: Location, b: Location) Location {
// Should emitted from the same chunk
std.debug.assert(a.chunk.ptr == b.chunk.ptr);
const min = if (a.offset_start < b.offset_start)
a
else
b;
return Location{
.chunk = a.chunk,
.line = min.line,
.column = min.column,
.offset_start = std.math.min(a.offset_start, b.offset_start),
.offset_end = std.math.max(a.offset_end, b.offset_end),
};
}
};
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/compiler/string-escaping.zig | const std = @import("std");
pub const EscapedStringIterator = struct {
slice: []const u8,
position: u8,
pub fn init(slice: []const u8) @This() {
return @This(){
.slice = slice,
.position = 0,
};
}
pub fn next(self: *@This()) error{IncompleteEscapeSequence}!?u8 {
if (self.position >= self.slice.len)
return null;
switch (self.slice[self.position]) {
'\\' => {
self.position += 1;
if (self.position == self.slice.len)
return error.IncompleteEscapeSequence;
const c = self.slice[self.position];
self.position += 1;
return switch (c) {
'a' => 7,
'b' => 8,
't' => 9,
'n' => 10,
'r' => 13,
'e' => 27,
'\"' => 34,
'\'' => 39,
'x' => blk: {
if (self.position + 2 > self.slice.len)
return error.IncompleteEscapeSequence;
const str = self.slice[self.position..][0..2];
self.position += 2;
break :blk std.fmt.parseInt(u8, str, 16) catch return error.IncompleteEscapeSequence;
},
else => c,
};
},
else => {
self.position += 1;
return self.slice[self.position - 1];
},
}
}
};
/// Applies all known string escape codes to the given input string,
/// returning a freshly allocated string.
pub fn escapeString(allocator: *std.mem.Allocator, input: []const u8) ![]u8 {
var iterator = EscapedStringIterator{
.slice = input,
.position = 0,
};
var len: usize = 0;
while (try iterator.next()) |_| {
len += 1;
}
iterator.position = 0;
const result = try allocator.alloc(u8, len);
var i: usize = 0;
while (iterator.next() catch unreachable) |c| {
result[i] = c;
i += 1;
}
std.debug.assert(i == len);
return result;
}
test "escape empty string" {
const str = try escapeString(std.testing.allocator, "");
defer std.testing.allocator.free(str);
std.testing.expectEqualStrings("", str);
}
test "escape string without escape codes" {
const str = try escapeString(std.testing.allocator, "ixtAOy9UbcIsIijUi42mtzOSwTiNolZAajBeS9W2PCgkyt7fDbuSQcjqKVRoBhalPBwThIkcVRa6W6tK2go1m7V2WoIrQNxuPzpf");
defer std.testing.allocator.free(str);
std.testing.expectEqualStrings("ixtAOy9UbcIsIijUi42mtzOSwTiNolZAajBeS9W2PCgkyt7fDbuSQcjqKVRoBhalPBwThIkcVRa6W6tK2go1m7V2WoIrQNxuPzpf", str);
}
// \a 7 Alert / Bell
// \b 8 Backspace
// \t 9 Horizontal Tab
// \n 10 Line Feed
// \r 13 Carriage Return
// \e 27 Escape
// \" 34 Double Quotes
// \' 39 Single Quote
test "escape string with predefined escape sequences" {
const str = try escapeString(std.testing.allocator, " \\a \\b \\t \\n \\r \\e \\\" \\' ");
defer std.testing.allocator.free(str);
std.testing.expectEqualStrings(" \x07 \x08 \x09 \x0A \x0D \x1B \" \' ", str);
}
test "escape string with hexadecimal escape sequences" {
const str = try escapeString(std.testing.allocator, " \\xcA \\x84 \\x2d \\x75 \\xb7 \\xF1 \\xf3 \\x9e ");
defer std.testing.allocator.free(str);
std.testing.expectEqualStrings(" \xca \x84 \x2d \x75 \xb7 \xf1 \xf3 \x9e ", str);
}
test "incomplete normal escape sequence" {
std.testing.expectError(error.IncompleteEscapeSequence, escapeString(std.testing.allocator, "\\"));
}
test "incomplete normal hex sequence" {
std.testing.expectError(error.IncompleteEscapeSequence, escapeString(std.testing.allocator, "\\x"));
std.testing.expectError(error.IncompleteEscapeSequence, escapeString(std.testing.allocator, "\\xA"));
}
test "invalid hex sequence" {
std.testing.expectError(error.IncompleteEscapeSequence, escapeString(std.testing.allocator, "\\xXX"));
}
test "escape string with tight predefined escape sequence" {
const str = try escapeString(std.testing.allocator, "\\a");
defer std.testing.allocator.free(str);
std.testing.expectEqualStrings("\x07", str);
}
test "escape string with tight hexadecimal escape sequence" {
const str = try escapeString(std.testing.allocator, "\\xca");
defer std.testing.allocator.free(str);
std.testing.expectEqualStrings("\xca", str);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/compiler/typeset.zig | const std = @import("std");
pub const Type = enum {
@"void",
number,
string,
boolean,
array,
object,
pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
try writer.writerAll(@tagName(value));
}
};
pub const TypeSet = struct {
const Self = @This();
pub const empty = Self{
.@"void" = false,
.number = false,
.string = false,
.boolean = false,
.array = false,
.object = false,
};
pub const any = Self{
.@"void" = true,
.number = true,
.string = true,
.boolean = true,
.array = true,
.object = true,
};
@"void": bool,
number: bool,
string: bool,
boolean: bool,
array: bool,
object: bool,
pub fn from(value_type: Type) Self {
return Self{
.@"void" = (value_type == .@"void"),
.number = (value_type == .number),
.string = (value_type == .string),
.boolean = (value_type == .boolean),
.array = (value_type == .array),
.object = (value_type == .object),
};
}
pub fn init(list: anytype) Self {
var set = TypeSet.empty;
inline for (list) |item| {
set = set.@"union"(from(item));
}
return set;
}
pub fn contains(self: Self, item: Type) bool {
return switch (item) {
.@"void" => self.@"void",
.number => self.number,
.string => self.string,
.boolean => self.boolean,
.array => self.array,
.object => self.object,
};
}
/// Returns a type set that only contains all types that are contained in both parameters.
pub fn intersection(a: Self, b: Self) Self {
var result: Self = undefined;
inline for (std.meta.fields(Self)) |fld| {
@field(result, fld.name) = @field(a, fld.name) and @field(b, fld.name);
}
return result;
}
/// Returns a type set that contains all types that are contained in any of the parameters.
pub fn @"union"(a: Self, b: Self) Self {
var result: Self = undefined;
inline for (std.meta.fields(Self)) |fld| {
@field(result, fld.name) = @field(a, fld.name) or @field(b, fld.name);
}
return result;
}
pub fn isEmpty(self: Self) bool {
inline for (std.meta.fields(Self)) |fld| {
if (@field(self, fld.name))
return false;
}
return true;
}
pub fn isAny(self: Self) bool {
inline for (std.meta.fields(Self)) |fld| {
if (!@field(self, fld.name))
return false;
}
return true;
}
/// Tests if the type set contains at least one common type.
pub fn areCompatible(a: Self, b: Self) bool {
return !intersection(a, b).isEmpty();
}
pub fn format(value: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
if (value.isEmpty()) {
try writer.writeAll("none");
} else if (value.isAny()) {
try writer.writeAll("any");
} else {
var separate = false;
inline for (std.meta.fields(Self)) |fld| {
if (@field(value, fld.name)) {
if (separate) {
try writer.writeAll("|");
}
separate = true;
try writer.writeAll(fld.name);
}
}
}
}
};
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/compiler/parser.zig | const std = @import("std");
const lexer = @import("tokenizer.zig");
const ast = @import("ast.zig");
const diag = @import("diagnostics.zig");
const Location = @import("location.zig").Location;
const EscapedStringIterator = @import("string-escaping.zig").EscapedStringIterator;
/// Parses a sequence of tokens into an abstract syntax tree.
/// Returns either a successfully parsed tree or puts all found
/// syntax errors into `diagnostics`.
pub fn parse(
allocator: *std.mem.Allocator,
diagnostics: *diag.Diagnostics,
sequence: []const lexer.Token,
) !ast.Program {
var arena = std.heap.ArenaAllocator.init(allocator);
errdefer arena.deinit();
var root_script = std.ArrayList(ast.Statement).init(&arena.allocator);
defer root_script.deinit();
var functions = std.ArrayList(ast.Function).init(&arena.allocator);
defer functions.deinit();
const Parser = struct {
const Self = @This();
const Predicate = fn (lexer.Token) bool;
const AcceptError = error{SyntaxError};
const ParseError = std.mem.Allocator.Error || AcceptError;
const SavedState = struct {
index: usize,
};
allocator: *std.mem.Allocator,
sequence: []const lexer.Token,
index: usize = 0,
diagnostics: *diag.Diagnostics,
fn emitDiagnostics(self: *Self, comptime fmt: []const u8, args: anytype) !error{SyntaxError} {
try self.diagnostics.emit(.@"error", self.getCurrentLocation(), fmt, args);
return error.SyntaxError;
}
fn getCurrentLocation(self: Self) Location {
return self.sequence[self.index].location;
}
/// Applies all known string escape codes
fn escapeString(self: Self, input: []const u8) ![]u8 {
var iterator = EscapedStringIterator.init(input);
var len: usize = 0;
while (try iterator.next()) |_| {
len += 1;
}
iterator = EscapedStringIterator.init(input);
const result = try self.allocator.alloc(u8, len);
var i: usize = 0;
while (iterator.next() catch unreachable) |c| {
result[i] = c;
i += 1;
}
std.debug.assert(i == len);
return result;
}
/// Create a save state that allows rewinding the parser process.
/// This should be used when a parsing function calls accept mulitple
/// times and may emit a syntax error.
/// The state should be restored in a errdefer.
fn saveState(self: Self) SavedState {
return SavedState{
.index = self.index,
};
}
/// Restores a previously created save state.
fn restoreState(self: *Self, state: SavedState) void {
self.index = state.index;
}
fn moveToHeap(self: *Self, value: anytype) !*@TypeOf(value) {
const T = @TypeOf(value);
std.debug.assert(@typeInfo(T) != .Pointer);
const ptr = try self.allocator.create(T);
ptr.* = value;
std.debug.assert(std.meta.eql(ptr.*, value));
return ptr;
}
fn any(token: lexer.Token) bool {
return true;
}
fn is(comptime kind: lexer.TokenType) Predicate {
return struct {
fn pred(token: lexer.Token) bool {
return token.type == kind;
}
}.pred;
}
fn oneOf(comptime kinds: anytype) Predicate {
return struct {
fn pred(token: lexer.Token) bool {
return inline for (kinds) |k| {
if (token.type == k)
break true;
} else false;
}
}.pred;
}
fn peek(self: Self) AcceptError!lexer.Token {
if (self.index >= self.sequence.len)
return error.SyntaxError;
return self.sequence[self.index];
}
fn accept(self: *Self, predicate: Predicate) AcceptError!lexer.Token {
if (self.index >= self.sequence.len)
return error.SyntaxError;
const tok = self.sequence[self.index];
if (predicate(tok)) {
self.index += 1;
return tok;
} else {
// std.debug.print("cannot accept {} here!\n", .{tok});
return error.SyntaxError;
}
}
fn acceptFunction(self: *Self) ParseError!ast.Function {
const state = self.saveState();
errdefer self.restoreState(state);
const initial_pos = try self.accept(is(.function));
const name = try self.accept(is(.identifier));
_ = try self.accept(is(.@"("));
var args = std.ArrayList([]const u8).init(self.allocator);
defer args.deinit();
while (true) {
const arg_or_end = try self.accept(oneOf(.{ .identifier, .@")" }));
switch (arg_or_end.type) {
.@")" => break,
.identifier => {
try args.append(arg_or_end.text);
const delimit = try self.accept(oneOf(.{ .@",", .@")" }));
if (delimit.type == .@")")
break;
},
else => unreachable,
}
}
const block = try self.acceptBlock();
return ast.Function{
.location = initial_pos.location,
.name = name.text,
.parameters = args.toOwnedSlice(),
.body = block,
};
}
fn acceptBlock(self: *Self) ParseError!ast.Statement {
const state = self.saveState();
errdefer self.restoreState(state);
const begin = try self.accept(is(.@"{"));
var body = std.ArrayList(ast.Statement).init(self.allocator);
defer body.deinit();
while (true) {
const stmt = self.acceptStatement() catch break;
try body.append(stmt);
}
const end = try self.accept(is(.@"}"));
return ast.Statement{
.location = begin.location,
.type = .{
.block = body.toOwnedSlice(),
},
};
}
fn acceptStatement(self: *Self) ParseError!ast.Statement {
const state = self.saveState();
errdefer self.restoreState(state);
const start = try self.peek();
switch (start.type) {
.@";" => {
_ = try self.accept(is(.@";"));
return ast.Statement{
.location = start.location,
.type = .empty,
};
},
.@"break" => {
_ = try self.accept(is(.@"break"));
_ = try self.accept(is(.@";"));
return ast.Statement{
.location = start.location,
.type = .@"break",
};
},
.@"continue" => {
_ = try self.accept(is(.@"continue"));
_ = try self.accept(is(.@";"));
return ast.Statement{
.location = start.location,
.type = .@"continue",
};
},
.@"{" => {
return try self.acceptBlock();
},
.@"while" => {
_ = try self.accept(is(.@"while"));
_ = try self.accept(is(.@"("));
const condition = try self.acceptExpression();
_ = try self.accept(is(.@")"));
const body = try self.acceptBlock();
return ast.Statement{
.location = start.location,
.type = .{
.while_loop = .{
.condition = condition,
.body = try self.moveToHeap(body),
},
},
};
},
.@"if" => {
_ = try self.accept(is(.@"if"));
_ = try self.accept(is(.@"("));
const condition = try self.acceptExpression();
_ = try self.accept(is(.@")"));
const true_body = try self.acceptStatement();
if (self.accept(is(.@"else"))) |_| {
const false_body = try self.acceptStatement();
return ast.Statement{
.location = start.location,
.type = .{
.if_statement = .{
.condition = condition,
.true_body = try self.moveToHeap(true_body),
.false_body = try self.moveToHeap(false_body),
},
},
};
} else |_| {
return ast.Statement{
.location = start.location,
.type = .{
.if_statement = .{
.condition = condition,
.true_body = try self.moveToHeap(true_body),
.false_body = null,
},
},
};
}
},
.@"for" => {
_ = try self.accept(is(.@"for"));
_ = try self.accept(is(.@"("));
const name = try self.accept(is(.identifier));
_ = try self.accept(is(.in));
const source = try self.acceptExpression();
_ = try self.accept(is(.@")"));
const body = try self.acceptBlock();
return ast.Statement{
.location = start.location,
.type = .{
.for_loop = .{
.variable = name.text,
.source = source,
.body = try self.moveToHeap(body),
},
},
};
},
.@"return" => {
_ = try self.accept(is(.@"return"));
if (self.accept(is(.@";"))) |_| {
return ast.Statement{
.location = start.location,
.type = .return_void,
};
} else |_| {
const value = try self.acceptExpression();
_ = try self.accept(is(.@";"));
return ast.Statement{
.location = start.location,
.type = .{
.return_expr = value,
},
};
}
},
.@"var", .@"const" => {
const decl_type = try self.accept(oneOf(.{ .@"var", .@"const" }));
const name = try self.accept(is(.identifier));
const decider = try self.accept(oneOf(.{ .@";", .@"=" }));
var stmt = ast.Statement{
.location = start.location.merge(name.location),
.type = .{
.declaration = .{
.variable = name.text,
.initial_value = null,
.is_const = (decl_type.type == .@"const"),
},
},
};
if (decider.type == .@"=") {
const value = try self.acceptExpression();
_ = try self.accept(is(.@";"));
stmt.type.declaration.initial_value = value;
}
return stmt;
},
else => {
const expr = try self.acceptExpression();
if ((expr.type == .function_call) or (expr.type == .method_call)) {
_ = try self.accept(is(.@";"));
return ast.Statement{
.location = expr.location,
.type = .{
.discard_value = expr,
},
};
} else {
const mode = try self.accept(oneOf(.{
.@"=",
.@"+=",
.@"-=",
.@"*=",
.@"/=",
.@"%=",
}));
const value = try self.acceptExpression();
_ = try self.accept(is(.@";"));
return switch (mode.type) {
.@"+=", .@"-=", .@"*=", .@"/=", .@"%=" => ast.Statement{
.location = expr.location,
.type = .{
.assignment = .{
.target = expr,
.value = ast.Expression{
.location = expr.location,
.type = .{
.binary_operator = .{
.operator = switch (mode.type) {
.@"+=" => .add,
.@"-=" => .subtract,
.@"*=" => .multiply,
.@"/=" => .divide,
.@"%=" => .modulus,
else => unreachable,
},
.lhs = try self.moveToHeap(expr),
.rhs = try self.moveToHeap(value),
},
},
},
},
},
},
.@"=" => ast.Statement{
.location = expr.location,
.type = .{
.assignment = .{
.target = expr,
.value = value,
},
},
},
else => unreachable,
};
}
},
}
}
fn acceptExpression(self: *Self) ParseError!ast.Expression {
const state = self.saveState();
errdefer self.restoreState(state);
return try self.acceptLogicCombinatorExpression();
}
fn acceptLogicCombinatorExpression(self: *Self) ParseError!ast.Expression {
const state = self.saveState();
errdefer self.restoreState(state);
var expr = try self.acceptComparisonExpression();
while (true) {
var and_or = self.accept(oneOf(.{ .@"and", .@"or" })) catch break;
var rhs = try self.acceptComparisonExpression();
var new_expr = ast.Expression{
.location = expr.location.merge(and_or.location).merge(rhs.location),
.type = .{
.binary_operator = .{
.operator = switch (and_or.type) {
.@"and" => .boolean_and,
.@"or" => .boolean_or,
else => unreachable,
},
.lhs = try self.moveToHeap(expr),
.rhs = try self.moveToHeap(rhs),
},
},
};
expr = new_expr;
}
return expr;
}
fn acceptComparisonExpression(self: *Self) ParseError!ast.Expression {
const state = self.saveState();
errdefer self.restoreState(state);
var expr = try self.acceptSumExpression();
while (true) {
var and_or = self.accept(oneOf(.{
.@"<=",
.@">=",
.@">",
.@"<",
.@"==",
.@"!=",
})) catch break;
var rhs = try self.acceptSumExpression();
var new_expr = ast.Expression{
.location = expr.location.merge(and_or.location).merge(rhs.location),
.type = .{
.binary_operator = .{
.operator = switch (and_or.type) {
.@"<=" => .less_or_equal_than,
.@">=" => .greater_or_equal_than,
.@">" => .greater_than,
.@"<" => .less_than,
.@"==" => .equal,
.@"!=" => .different,
else => unreachable,
},
.lhs = try self.moveToHeap(expr),
.rhs = try self.moveToHeap(rhs),
},
},
};
expr = new_expr;
}
return expr;
}
fn acceptSumExpression(self: *Self) ParseError!ast.Expression {
const state = self.saveState();
errdefer self.restoreState(state);
var expr = try self.acceptMulExpression();
while (true) {
var and_or = self.accept(oneOf(.{
.@"+",
.@"-",
})) catch break;
var rhs = try self.acceptMulExpression();
var new_expr = ast.Expression{
.location = expr.location.merge(and_or.location).merge(rhs.location),
.type = .{
.binary_operator = .{
.operator = switch (and_or.type) {
.@"+" => .add,
.@"-" => .subtract,
else => unreachable,
},
.lhs = try self.moveToHeap(expr),
.rhs = try self.moveToHeap(rhs),
},
},
};
expr = new_expr;
}
return expr;
}
fn acceptMulExpression(self: *Self) ParseError!ast.Expression {
const state = self.saveState();
errdefer self.restoreState(state);
var expr = try self.acceptUnaryPrefixOperatorExpression();
while (true) {
var and_or = self.accept(oneOf(.{
.@"*",
.@"/",
.@"%",
})) catch break;
var rhs = try self.acceptUnaryPrefixOperatorExpression();
var new_expr = ast.Expression{
.location = expr.location.merge(and_or.location).merge(rhs.location),
.type = .{
.binary_operator = .{
.operator = switch (and_or.type) {
.@"*" => .multiply,
.@"/" => .divide,
.@"%" => .modulus,
else => unreachable,
},
.lhs = try self.moveToHeap(expr),
.rhs = try self.moveToHeap(rhs),
},
},
};
expr = new_expr;
}
return expr;
}
fn acceptUnaryPrefixOperatorExpression(self: *Self) ParseError!ast.Expression {
const state = self.saveState();
errdefer self.restoreState(state);
if (self.accept(oneOf(.{ .@"not", .@"-" }))) |prefix| {
// this must directly recurse as we can write `not not x`
const value = try self.acceptUnaryPrefixOperatorExpression();
return ast.Expression{
.location = prefix.location.merge(value.location),
.type = .{
.unary_operator = .{
.operator = switch (prefix.type) {
.@"not" => .boolean_not,
.@"-" => .negate,
else => unreachable,
},
.value = try self.moveToHeap(value),
},
},
};
} else |_| {
return try self.acceptIndexingExpression();
}
}
fn acceptIndexingExpression(self: *Self) ParseError!ast.Expression {
const state = self.saveState();
errdefer self.restoreState(state);
var value = try self.acceptCallExpression();
while (self.accept(is(.@"["))) |_| {
const index = try self.acceptExpression();
_ = try self.accept(is(.@"]"));
var new_value = ast.Expression{
.location = value.location.merge(index.location),
.type = .{
.array_indexer = .{
.value = try self.moveToHeap(value),
.index = try self.moveToHeap(index),
},
},
};
value = new_value;
} else |_| {}
return value;
}
fn acceptCallExpression(self: *Self) ParseError!ast.Expression {
const state = self.saveState();
errdefer self.restoreState(state);
var value = try self.acceptValueExpression();
while (self.accept(oneOf(.{ .@"(", .@"." }))) |sym| {
var new_value = switch (sym.type) {
// call
.@"(" => blk: {
var args = std.ArrayList(ast.Expression).init(self.allocator);
defer args.deinit();
var loc = value.location;
if (self.accept(is(.@")"))) |_| {
// this is the end of the argument list
} else |_| {
while (true) {
const arg = try self.acceptExpression();
try args.append(arg);
const terminator = try self.accept(oneOf(.{ .@")", .@"," }));
loc = terminator.location.merge(loc);
if (terminator.type == .@")")
break;
}
}
break :blk ast.Expression{
.location = loc,
.type = .{
.function_call = .{
.function = try self.moveToHeap(value),
.arguments = args.toOwnedSlice(),
},
},
};
},
// method call
.@"." => blk: {
const method_name = try self.accept(is(.identifier));
_ = try self.accept(is(.@"("));
var args = std.ArrayList(ast.Expression).init(self.allocator);
defer args.deinit();
var loc = value.location;
if (self.accept(is(.@")"))) |_| {
// this is the end of the argument list
} else |_| {
while (true) {
const arg = try self.acceptExpression();
try args.append(arg);
const terminator = try self.accept(oneOf(.{ .@")", .@"," }));
loc = terminator.location.merge(loc);
if (terminator.type == .@")")
break;
}
}
break :blk ast.Expression{
.location = loc,
.type = .{
.method_call = .{
.object = try self.moveToHeap(value),
.name = method_name.text,
.arguments = args.toOwnedSlice(),
},
},
};
},
else => unreachable,
};
value = new_value;
} else |_| {}
return value;
}
fn acceptValueExpression(self: *Self) ParseError!ast.Expression {
const state = self.saveState();
errdefer self.restoreState(state);
const token = try self.accept(oneOf(.{
.@"(",
.@"[",
.number_literal,
.string_literal,
.character_literal,
.identifier,
}));
switch (token.type) {
.@"(" => {
const value = try self.acceptExpression();
_ = try self.accept(is(.@")"));
return value;
},
.@"[" => {
var array = std.ArrayList(ast.Expression).init(self.allocator);
defer array.deinit();
while (true) {
if (self.accept(is(.@"]"))) |_| {
break;
} else |_| {
const item = try self.acceptExpression();
try array.append(item);
const delimit = try self.accept(oneOf(.{ .@",", .@"]" }));
if (delimit.type == .@"]")
break;
}
}
return ast.Expression{
.location = token.location,
.type = .{
.array_literal = array.toOwnedSlice(),
},
};
},
.number_literal => {
const val = if (std.mem.startsWith(u8, token.text, "0x"))
@intToFloat(f64, std.fmt.parseInt(i54, token.text[2..], 16) catch return try self.emitDiagnostics("`{}` is not a valid hexadecimal number!", .{token.text}))
else
std.fmt.parseFloat(f64, token.text) catch return try self.emitDiagnostics("`{}` is not a valid number!", .{token.text});
return ast.Expression{
.location = token.location,
.type = .{
.number_literal = val,
},
};
},
.string_literal => {
std.debug.assert(token.text.len >= 2);
return ast.Expression{
.location = token.location,
.type = .{
.string_literal = self.escapeString(token.text[1 .. token.text.len - 1]) catch return try self.emitDiagnostics("Invalid escape sequence in {}!", .{token.text}),
},
};
},
.character_literal => {
std.debug.assert(token.text.len >= 2);
const escaped_text = self.escapeString(token.text[1 .. token.text.len - 1]) catch return try self.emitDiagnostics("Invalid escape sequence in {}!", .{token.text});
var value: u21 = undefined;
if (escaped_text.len == 0) {
return error.SyntaxError;
} else if (escaped_text.len == 1) {
// this is a shortcut for non-utf8 encoded files.
// it's not a perfect heuristic, but it's okay.
value = escaped_text[0];
} else {
const utf8_len = std.unicode.utf8ByteSequenceLength(escaped_text[0]) catch return try self.emitDiagnostics("Invalid utf8 sequence: `{}`!", .{escaped_text});
if (escaped_text.len != utf8_len)
return error.SyntaxError;
value = std.unicode.utf8Decode(escaped_text[0..utf8_len]) catch return try self.emitDiagnostics("Invalid utf8 sequence: `{}`!", .{escaped_text});
}
return ast.Expression{
.location = token.location,
.type = .{
.number_literal = @intToFloat(f64, value),
},
};
},
.identifier => return ast.Expression{
.location = token.location,
.type = .{
.variable_expr = token.text,
},
},
else => unreachable,
}
}
};
var parser = Parser{
.allocator = &arena.allocator,
.sequence = sequence,
.diagnostics = diagnostics,
};
while (parser.index < parser.sequence.len) {
const state = parser.saveState();
// look-ahead one token and try accepting a "function" keyword,
// use that to select between parsing a function or a statement.
if (parser.accept(Parser.is(.function))) |_| {
// we need to unaccept the function token
parser.restoreState(state);
const fun = try parser.acceptFunction();
try functions.append(fun);
} else |_| {
// no need to unaccept here as we didn't accept in the first place
const stmt = parser.acceptStatement() catch |err| switch (err) {
error.SyntaxError => {
// Do some recovery here:
try diagnostics.emit(.@"error", parser.getCurrentLocation(), "syntax error!", .{});
while (parser.index < parser.sequence.len) {
const recovery_state = parser.saveState();
const tok = try parser.accept(Parser.any);
if (tok.type == .@";")
break;
// We want to be able to parse the next function properly
// even if we have syntax errors.
if (tok.type == .function) {
parser.restoreState(recovery_state);
break;
}
}
continue;
},
else => |e| return e,
};
try root_script.append(stmt);
}
}
return ast.Program{
.arena = arena,
.root_script = root_script.toOwnedSlice(),
.functions = functions.toOwnedSlice(),
};
}
fn testTokenize(str: []const u8) ![]lexer.Token {
var result = std.ArrayList(lexer.Token).init(std.testing.allocator);
var tokenizer = lexer.Tokenizer.init("testsrc", str);
while (true) {
switch (tokenizer.next()) {
.end_of_file => return result.toOwnedSlice(),
.invalid_sequence => unreachable, // we don't do that here
.token => |token| try result.append(token),
}
}
}
test "empty file parsing" {
var diagnostics = diag.Diagnostics.init(std.testing.allocator);
defer diagnostics.deinit();
var pgm = try parse(std.testing.allocator, &diagnostics, &[_]lexer.Token{});
defer pgm.deinit();
// assert that an empty file results in a empty AST
std.testing.expectEqual(@as(usize, 0), pgm.root_script.len);
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
// assert that we didn't encounter syntax errors
std.testing.expectEqual(@as(usize, 0), diagnostics.messages.items.len);
}
fn parseTest(string: []const u8) !ast.Program {
const seq = try testTokenize(string);
defer std.testing.allocator.free(seq);
var diagnostics = diag.Diagnostics.init(std.testing.allocator);
defer diagnostics.deinit();
return try parse(std.testing.allocator, &diagnostics, seq);
}
test "parse single top level statement" {
// test with the simplest of all statements:
// the empty one
var pgm = try parseTest(";");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.empty, pgm.root_script[0].type);
}
test "parse single empty function" {
// 0 params
{
var pgm = try parseTest("function empty(){}");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 1), pgm.functions.len);
std.testing.expectEqual(@as(usize, 0), pgm.root_script.len);
const fun = pgm.functions[0];
std.testing.expectEqualStrings("empty", fun.name);
std.testing.expectEqual(ast.Statement.Type.block, fun.body.type);
std.testing.expectEqual(@as(usize, 0), fun.body.type.block.len);
std.testing.expectEqual(@as(usize, 0), fun.parameters.len);
}
// 1 param
{
var pgm = try parseTest("function empty(p0){}");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 1), pgm.functions.len);
std.testing.expectEqual(@as(usize, 0), pgm.root_script.len);
const fun = pgm.functions[0];
std.testing.expectEqualStrings("empty", fun.name);
std.testing.expectEqual(ast.Statement.Type.block, fun.body.type);
std.testing.expectEqual(@as(usize, 0), fun.body.type.block.len);
std.testing.expectEqual(@as(usize, 1), fun.parameters.len);
std.testing.expectEqualStrings("p0", fun.parameters[0]);
}
// 3 param
{
var pgm = try parseTest("function empty(p0,p1,p2){}");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 1), pgm.functions.len);
std.testing.expectEqual(@as(usize, 0), pgm.root_script.len);
const fun = pgm.functions[0];
std.testing.expectEqualStrings("empty", fun.name);
std.testing.expectEqual(ast.Statement.Type.block, fun.body.type);
std.testing.expectEqual(@as(usize, 0), fun.body.type.block.len);
std.testing.expectEqual(@as(usize, 3), fun.parameters.len);
std.testing.expectEqualStrings("p0", fun.parameters[0]);
std.testing.expectEqualStrings("p1", fun.parameters[1]);
std.testing.expectEqualStrings("p2", fun.parameters[2]);
}
}
test "parse multiple top level statements" {
// test with the simplest of all statements:
// the empty one
var pgm = try parseTest(";;;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 3), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.empty, pgm.root_script[0].type);
std.testing.expectEqual(ast.Statement.Type.empty, pgm.root_script[1].type);
std.testing.expectEqual(ast.Statement.Type.empty, pgm.root_script[2].type);
}
test "parse mixed function and top level statement" {
var pgm = try parseTest(";function n(){};");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 1), pgm.functions.len);
std.testing.expectEqual(@as(usize, 2), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.empty, pgm.root_script[0].type);
std.testing.expectEqual(ast.Statement.Type.empty, pgm.root_script[1].type);
const fun = pgm.functions[0];
std.testing.expectEqualStrings("n", fun.name);
std.testing.expectEqual(ast.Statement.Type.block, fun.body.type);
std.testing.expectEqual(@as(usize, 0), fun.body.type.block.len);
std.testing.expectEqual(@as(usize, 0), fun.parameters.len);
}
test "nested blocks" {
var pgm = try parseTest(
\\{ }
\\{
\\ { ; }
\\ { ; ; }
\\ ;
\\}
\\{ }
);
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 3), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.block, pgm.root_script[0].type);
std.testing.expectEqual(ast.Statement.Type.block, pgm.root_script[1].type);
std.testing.expectEqual(ast.Statement.Type.block, pgm.root_script[2].type);
std.testing.expectEqual(@as(usize, 0), pgm.root_script[0].type.block.len);
std.testing.expectEqual(@as(usize, 3), pgm.root_script[1].type.block.len);
std.testing.expectEqual(@as(usize, 0), pgm.root_script[2].type.block.len);
std.testing.expectEqual(ast.Statement.Type.block, pgm.root_script[1].type.block[0].type);
std.testing.expectEqual(ast.Statement.Type.block, pgm.root_script[1].type.block[1].type);
std.testing.expectEqual(ast.Statement.Type.empty, pgm.root_script[1].type.block[2].type);
std.testing.expectEqual(@as(usize, 1), pgm.root_script[1].type.block[0].type.block.len);
std.testing.expectEqual(@as(usize, 2), pgm.root_script[1].type.block[1].type.block.len);
std.testing.expectEqual(ast.Statement.Type.empty, pgm.root_script[1].type.block[1].type.block[0].type);
std.testing.expectEqual(ast.Statement.Type.empty, pgm.root_script[1].type.block[1].type.block[0].type);
}
test "nested blocks in functions" {
var pgm = try parseTest(
\\function foo() {
\\ { }
\\ {
\\ { ; }
\\ { ; ; }
\\ ;
\\ }
\\ { }
\\}
);
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 1), pgm.functions.len);
std.testing.expectEqual(@as(usize, 0), pgm.root_script.len);
const fun = pgm.functions[0];
std.testing.expectEqual(ast.Statement.Type.block, fun.body.type);
const items = fun.body.type.block;
std.testing.expectEqual(ast.Statement.Type.block, items[0].type);
std.testing.expectEqual(ast.Statement.Type.block, items[1].type);
std.testing.expectEqual(ast.Statement.Type.block, items[2].type);
std.testing.expectEqual(@as(usize, 0), items[0].type.block.len);
std.testing.expectEqual(@as(usize, 3), items[1].type.block.len);
std.testing.expectEqual(@as(usize, 0), items[2].type.block.len);
std.testing.expectEqual(ast.Statement.Type.block, items[1].type.block[0].type);
std.testing.expectEqual(ast.Statement.Type.block, items[1].type.block[1].type);
std.testing.expectEqual(ast.Statement.Type.empty, items[1].type.block[2].type);
std.testing.expectEqual(@as(usize, 1), items[1].type.block[0].type.block.len);
std.testing.expectEqual(@as(usize, 2), items[1].type.block[1].type.block.len);
std.testing.expectEqual(ast.Statement.Type.empty, items[1].type.block[1].type.block[0].type);
std.testing.expectEqual(ast.Statement.Type.empty, items[1].type.block[1].type.block[0].type);
}
test "parsing break" {
var pgm = try parseTest("break;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.@"break", pgm.root_script[0].type);
}
test "parsing continue" {
var pgm = try parseTest("continue;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.@"continue", pgm.root_script[0].type);
}
test "parsing while" {
var pgm = try parseTest("while(1) { }");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.while_loop, pgm.root_script[0].type);
std.testing.expectEqual(ast.Statement.Type.block, pgm.root_script[0].type.while_loop.body.type);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.while_loop.condition.type);
}
test "parsing for" {
var pgm = try parseTest("for(name in 1) { }");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.for_loop, pgm.root_script[0].type);
std.testing.expectEqualStrings("name", pgm.root_script[0].type.for_loop.variable);
std.testing.expectEqual(ast.Statement.Type.block, pgm.root_script[0].type.for_loop.body.type);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.for_loop.source.type);
}
test "parsing single if" {
var pgm = try parseTest("if(1) { }");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.if_statement, pgm.root_script[0].type);
std.testing.expectEqual(ast.Statement.Type.block, pgm.root_script[0].type.if_statement.true_body.type);
std.testing.expectEqual(@as(?*ast.Statement, null), pgm.root_script[0].type.if_statement.false_body);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.if_statement.condition.type);
}
test "parsing if-else" {
var pgm = try parseTest("if(1) { } else ;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.if_statement, pgm.root_script[0].type);
std.testing.expectEqual(ast.Statement.Type.block, pgm.root_script[0].type.if_statement.true_body.type);
std.testing.expectEqual(ast.Statement.Type.empty, pgm.root_script[0].type.if_statement.false_body.?.type);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.if_statement.condition.type);
}
test "parsing return (void)" {
var pgm = try parseTest("return;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.return_void, pgm.root_script[0].type);
}
test "parsing return (value)" {
var pgm = try parseTest("return 1;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.return_expr, pgm.root_script[0].type);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.return_expr.type);
}
test "parsing var declaration (no value)" {
var pgm = try parseTest("var name;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.declaration, pgm.root_script[0].type);
std.testing.expectEqualStrings("name", pgm.root_script[0].type.declaration.variable);
std.testing.expectEqual(false, pgm.root_script[0].type.declaration.is_const);
std.testing.expectEqual(@as(?ast.Expression, null), pgm.root_script[0].type.declaration.initial_value);
}
test "parsing var declaration (initial value)" {
var pgm = try parseTest("var name = 1;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.declaration, pgm.root_script[0].type);
std.testing.expectEqualStrings("name", pgm.root_script[0].type.declaration.variable);
std.testing.expectEqual(false, pgm.root_script[0].type.declaration.is_const);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.declaration.initial_value.?.type);
}
test "parsing const declaration (no value)" {
var pgm = try parseTest("const name;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.declaration, pgm.root_script[0].type);
std.testing.expectEqualStrings("name", pgm.root_script[0].type.declaration.variable);
std.testing.expectEqual(true, pgm.root_script[0].type.declaration.is_const);
std.testing.expectEqual(@as(?ast.Expression, null), pgm.root_script[0].type.declaration.initial_value);
}
test "parsing const declaration (initial value)" {
var pgm = try parseTest("const name = 1;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.declaration, pgm.root_script[0].type);
std.testing.expectEqualStrings("name", pgm.root_script[0].type.declaration.variable);
std.testing.expectEqual(true, pgm.root_script[0].type.declaration.is_const);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.declaration.initial_value.?.type);
}
test "parsing assignment" {
var pgm = try parseTest("1 = 1;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.assignment, pgm.root_script[0].type);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.target.type);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.value.type);
}
test "parsing operator-assignment addition" {
var pgm = try parseTest("1 += 1;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.assignment, pgm.root_script[0].type);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.target.type);
std.testing.expectEqual(ast.Expression.Type.binary_operator, pgm.root_script[0].type.assignment.value.type);
std.testing.expectEqual(ast.BinaryOperator.add, pgm.root_script[0].type.assignment.value.type.binary_operator.operator);
}
test "parsing operator-assignment subtraction" {
var pgm = try parseTest("1 -= 1;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.assignment, pgm.root_script[0].type);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.target.type);
std.testing.expectEqual(ast.Expression.Type.binary_operator, pgm.root_script[0].type.assignment.value.type);
std.testing.expectEqual(ast.BinaryOperator.subtract, pgm.root_script[0].type.assignment.value.type.binary_operator.operator);
}
test "parsing operator-assignment multiplication" {
var pgm = try parseTest("1 *= 1;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.assignment, pgm.root_script[0].type);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.target.type);
std.testing.expectEqual(ast.Expression.Type.binary_operator, pgm.root_script[0].type.assignment.value.type);
std.testing.expectEqual(ast.BinaryOperator.multiply, pgm.root_script[0].type.assignment.value.type.binary_operator.operator);
}
test "parsing operator-assignment division" {
var pgm = try parseTest("1 /= 1;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.assignment, pgm.root_script[0].type);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.target.type);
std.testing.expectEqual(ast.Expression.Type.binary_operator, pgm.root_script[0].type.assignment.value.type);
std.testing.expectEqual(ast.BinaryOperator.divide, pgm.root_script[0].type.assignment.value.type.binary_operator.operator);
}
test "parsing operator-assignment modulus" {
var pgm = try parseTest("1 %= 1;");
defer pgm.deinit();
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Statement.Type.assignment, pgm.root_script[0].type);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.target.type);
std.testing.expectEqual(ast.Expression.Type.binary_operator, pgm.root_script[0].type.assignment.value.type);
std.testing.expectEqual(ast.BinaryOperator.modulus, pgm.root_script[0].type.assignment.value.type.binary_operator.operator);
}
/// Parse a program with `1 = $(EXPR)`, will return `$(EXPR)`
fn getTestExpr(pgm: ast.Program) ast.Expression {
std.testing.expectEqual(@as(usize, 0), pgm.functions.len);
std.testing.expectEqual(@as(usize, 1), pgm.root_script.len);
std.testing.expectEqual(ast.Expression.Type.number_literal, pgm.root_script[0].type.assignment.target.type);
var expr = pgm.root_script[0].type.assignment.value;
return expr;
}
test "integer literal" {
var pgm = try parseTest("1 = 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.number_literal, expr.type);
std.testing.expectWithinEpsilon(@as(f64, 1), expr.type.number_literal, 0.000001);
}
test "decimal literal" {
var pgm = try parseTest("1 = 1.0;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.number_literal, expr.type);
std.testing.expectWithinEpsilon(@as(f64, 1), expr.type.number_literal, 0.000001);
}
test "hexadecimal literal" {
var pgm = try parseTest("1 = 0x1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.number_literal, expr.type);
std.testing.expectWithinEpsilon(@as(f64, 1), expr.type.number_literal, 0.000001);
}
test "string literal" {
var pgm = try parseTest("1 = \"string content\";");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.string_literal, expr.type);
std.testing.expectEqualStrings("string content", expr.type.string_literal);
}
test "escaped string literal" {
var pgm = try parseTest("1 = \"\\\"content\\\"\";");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.string_literal, expr.type);
std.testing.expectEqualStrings("\"content\"", expr.type.string_literal);
}
test "character literal" {
var pgm = try parseTest("1 = ' ';");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.number_literal, expr.type);
std.testing.expectEqual(@as(f64, ' '), expr.type.number_literal);
}
test "variable reference" {
var pgm = try parseTest("1 = variable_name;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.variable_expr, expr.type);
std.testing.expectEqualStrings("variable_name", expr.type.variable_expr);
}
test "addition expression" {
var pgm = try parseTest("1 = 1 + 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.add, expr.type.binary_operator.operator);
}
test "subtraction expression" {
var pgm = try parseTest("1 = 1 - 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.subtract, expr.type.binary_operator.operator);
}
test "multiplication expression" {
var pgm = try parseTest("1 = 1 * 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.multiply, expr.type.binary_operator.operator);
}
test "division expression" {
var pgm = try parseTest("1 = 1 / 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.divide, expr.type.binary_operator.operator);
}
test "modulus expression" {
var pgm = try parseTest("1 = 1 % 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.modulus, expr.type.binary_operator.operator);
}
test "boolean or expression" {
var pgm = try parseTest("1 = 1 or 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.boolean_or, expr.type.binary_operator.operator);
}
test "boolean and expression" {
var pgm = try parseTest("1 = 1 and 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.boolean_and, expr.type.binary_operator.operator);
}
test "greater than expression" {
var pgm = try parseTest("1 = 1 > 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.greater_than, expr.type.binary_operator.operator);
}
test "less than expression" {
var pgm = try parseTest("1 = 1 < 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.less_than, expr.type.binary_operator.operator);
}
test "greater or equal than expression" {
var pgm = try parseTest("1 = 1 >= 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.greater_or_equal_than, expr.type.binary_operator.operator);
}
test "less or equal than expression" {
var pgm = try parseTest("1 = 1 <= 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.less_or_equal_than, expr.type.binary_operator.operator);
}
test "equal expression" {
var pgm = try parseTest("1 = 1 == 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.equal, expr.type.binary_operator.operator);
}
test "different expression" {
var pgm = try parseTest("1 = 1 != 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.different, expr.type.binary_operator.operator);
}
test "operator precedence (binaries)" {
var pgm = try parseTest("1 = 1 + 1 * 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.add, expr.type.binary_operator.operator);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type.binary_operator.rhs.type);
std.testing.expectEqual(ast.BinaryOperator.multiply, expr.type.binary_operator.rhs.type.binary_operator.operator);
}
test "operator precedence (unary and binary mixed)" {
var pgm = try parseTest("1 = -1 * 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.multiply, expr.type.binary_operator.operator);
std.testing.expectEqual(ast.Expression.Type.unary_operator, expr.type.binary_operator.lhs.type);
std.testing.expectEqual(ast.UnaryOperator.negate, expr.type.binary_operator.lhs.type.unary_operator.operator);
}
test "invers operator precedence with parens" {
var pgm = try parseTest("1 = 1 * (1 + 1);");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type);
std.testing.expectEqual(ast.BinaryOperator.multiply, expr.type.binary_operator.operator);
std.testing.expectEqual(ast.Expression.Type.binary_operator, expr.type.binary_operator.rhs.type);
std.testing.expectEqual(ast.BinaryOperator.add, expr.type.binary_operator.rhs.type.binary_operator.operator);
}
test "unary minus expression" {
var pgm = try parseTest("1 = -1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.unary_operator, expr.type);
std.testing.expectEqual(ast.UnaryOperator.negate, expr.type.unary_operator.operator);
}
test "unary not expression" {
var pgm = try parseTest("1 = not 1;");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.unary_operator, expr.type);
std.testing.expectEqual(ast.UnaryOperator.boolean_not, expr.type.unary_operator.operator);
}
test "single array indexing expression" {
var pgm = try parseTest("1 = 1[\"\"];");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.array_indexer, expr.type);
std.testing.expectEqual(ast.Expression.Type.number_literal, expr.type.array_indexer.value.type);
std.testing.expectEqual(ast.Expression.Type.string_literal, expr.type.array_indexer.index.type);
}
test "multiple array indexing expressions" {
var pgm = try parseTest("1 = a[b][c];");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.array_indexer, expr.type);
std.testing.expectEqual(ast.Expression.Type.array_indexer, expr.type.array_indexer.value.type);
std.testing.expectEqual(ast.Expression.Type.variable_expr, expr.type.array_indexer.index.type);
std.testing.expectEqualStrings("c", expr.type.array_indexer.index.type.variable_expr);
std.testing.expectEqual(ast.Expression.Type.variable_expr, expr.type.array_indexer.value.type.array_indexer.value.type);
std.testing.expectEqual(ast.Expression.Type.variable_expr, expr.type.array_indexer.value.type.array_indexer.index.type);
std.testing.expectEqualStrings("a", expr.type.array_indexer.value.type.array_indexer.value.type.variable_expr);
std.testing.expectEqualStrings("b", expr.type.array_indexer.value.type.array_indexer.index.type.variable_expr);
}
test "zero parameter function call expression" {
var pgm = try parseTest("1 = foo();");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.function_call, expr.type);
std.testing.expectEqual(ast.Expression.Type.variable_expr, expr.type.function_call.function.type);
std.testing.expectEqual(@as(usize, 0), expr.type.function_call.arguments.len);
}
test "one parameter function call expression" {
var pgm = try parseTest("1 = foo(a);");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.function_call, expr.type);
std.testing.expectEqual(ast.Expression.Type.variable_expr, expr.type.function_call.function.type);
std.testing.expectEqual(@as(usize, 1), expr.type.function_call.arguments.len);
std.testing.expectEqualStrings("a", expr.type.function_call.arguments[0].type.variable_expr);
}
test "4 parameter function call expression" {
var pgm = try parseTest("1 = foo(a,b,c,d);");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.function_call, expr.type);
std.testing.expectEqual(ast.Expression.Type.variable_expr, expr.type.function_call.function.type);
std.testing.expectEqual(@as(usize, 4), expr.type.function_call.arguments.len);
std.testing.expectEqualStrings("a", expr.type.function_call.arguments[0].type.variable_expr);
std.testing.expectEqualStrings("b", expr.type.function_call.arguments[1].type.variable_expr);
std.testing.expectEqualStrings("c", expr.type.function_call.arguments[2].type.variable_expr);
std.testing.expectEqualStrings("d", expr.type.function_call.arguments[3].type.variable_expr);
}
test "zero parameter method call expression" {
var pgm = try parseTest("1 = a.foo();");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.method_call, expr.type);
std.testing.expectEqualStrings("foo", expr.type.method_call.name);
std.testing.expectEqual(ast.Expression.Type.variable_expr, expr.type.method_call.object.type);
std.testing.expectEqual(@as(usize, 0), expr.type.method_call.arguments.len);
}
test "one parameter method call expression" {
var pgm = try parseTest("1 = a.foo(a);");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.method_call, expr.type);
std.testing.expectEqualStrings("foo", expr.type.method_call.name);
std.testing.expectEqual(ast.Expression.Type.variable_expr, expr.type.method_call.object.type);
std.testing.expectEqual(@as(usize, 1), expr.type.method_call.arguments.len);
std.testing.expectEqualStrings("a", expr.type.method_call.arguments[0].type.variable_expr);
}
test "4 parameter method call expression" {
var pgm = try parseTest("1 = a.foo(a,b,c,d);");
defer pgm.deinit();
const expr = getTestExpr(pgm);
std.testing.expectEqual(ast.Expression.Type.method_call, expr.type);
std.testing.expectEqualStrings("foo", expr.type.method_call.name);
std.testing.expectEqual(ast.Expression.Type.variable_expr, expr.type.method_call.object.type);
std.testing.expectEqual(@as(usize, 4), expr.type.method_call.arguments.len);
std.testing.expectEqualStrings("a", expr.type.method_call.arguments[0].type.variable_expr);
std.testing.expectEqualStrings("b", expr.type.method_call.arguments[1].type.variable_expr);
std.testing.expectEqualStrings("c", expr.type.method_call.arguments[2].type.variable_expr);
std.testing.expectEqualStrings("d", expr.type.method_call.arguments[3].type.variable_expr);
}
test "full suite parsing" {
const seq = try testTokenize(@embedFile("../../test/compiler.lola"));
defer std.testing.allocator.free(seq);
var diagnostics = diag.Diagnostics.init(std.testing.allocator);
defer diagnostics.deinit();
var pgm = try parse(std.testing.allocator, &diagnostics, seq);
defer pgm.deinit();
for (diagnostics.messages.items) |msg| {
std.debug.warn("{}\n", .{msg});
}
// assert that we don't have an empty AST
std.testing.expect(pgm.root_script.len > 0);
std.testing.expect(pgm.functions.len > 0);
// assert that we didn't encounter syntax errors
std.testing.expectEqual(@as(usize, 0), diagnostics.messages.items.len);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/compiler/code-writer.zig | const std = @import("std");
const Instruction = @import("../common/ir.zig").Instruction;
const InstructionName = @import("../common/ir.zig").InstructionName;
/// A handle to a location in source code.
/// This handle is created by a `CodeWriter` and only that code writer
/// knows where this label is located in memory (or if it is yet to be defined).
pub const Label = enum(u32) { _ };
/// A append-only data structure that allows emission of data and instructions to create
/// LoLa byte code.
pub const CodeWriter = struct {
const Self = @This();
const Loop = struct { breakLabel: Label, continueLabel: Label };
const Patch = struct { label: Label, offset: u32 };
/// The bytecode that was already emitted.
code: std.ArrayList(u8),
/// Used as a stack of loops. Each loop has a break position and a continue position,
/// which can be emitted by calling emitBreak or emitContinue. This allows nesting loops
/// and emitting the right loop targets without passing the context around in code generation.
loops: std.ArrayList(Loop),
/// Stores a list of forward references for labels. This is required
/// when a call to `emitLabel` happens before `defineLabel` is called.
/// This list is empty when all emitted label references are well-defined.
patches: std.ArrayList(Patch),
/// Stores the offset for every defined label.
labels: std.AutoHashMap(Label, u32),
next_label: u32 = 0,
pub fn init(allocator: *std.mem.Allocator) Self {
return Self{
.code = std.ArrayList(u8).init(allocator),
.loops = std.ArrayList(Loop).init(allocator),
.patches = std.ArrayList(Patch).init(allocator),
.labels = std.AutoHashMap(Label, u32).init(allocator),
};
}
pub fn deinit(self: *Self) void {
self.code.deinit();
self.loops.deinit();
self.patches.deinit();
self.labels.deinit();
self.* = undefined;
}
/// Finalizes the code generation process and returns the generated code.
/// The returned memory is owned by the caller and was allocated with the allocator passed into `init`.
pub fn finalize(self: *Self) ![]u8 {
if (self.loops.items.len != 0)
return error.InvalidCode;
if (self.patches.items.len != 0)
return error.InvalidCode;
self.loops.shrink(0);
self.patches.shrink(0);
self.labels.clearAndFree();
return self.code.toOwnedSlice();
}
/// Creates a new label identifier. This only returns a new handle, it does
/// not emit any code or modify data structures.
pub fn createLabel(self: *Self) !Label {
if (self.next_label == std.math.maxInt(u32))
return error.TooManyLabels;
const id = @intToEnum(Label, self.next_label);
self.next_label += 1;
return id;
}
/// Defines the location a label references. This must be called exactly once for a label.
/// Calling it more than once is a error, the same as calling it never.
/// Defining a label will patch all forward references in the `code`, removing the need to
/// store patches for later.
pub fn defineLabel(self: *Self, lbl: Label) !void {
const item = try self.labels.getOrPut(lbl);
if (item.found_existing)
return error.LabelAlreadyDefined;
item.entry.value = @intCast(u32, self.code.items.len);
// resolve all forward references to this label, so we
// have a empty patch list when every referenced label was also defined.
var i: usize = 0;
while (i < self.patches.items.len) {
const patch = self.patches.items[i];
if (patch.label == lbl) {
std.mem.writeIntLittle(u32, self.code.items[patch.offset..][0..4], item.entry.value);
_ = self.patches.swapRemove(i);
} else {
i += 1;
}
}
}
/// Combination of createLabel and defineLabel, is provided as a convenience function.
pub fn createAndDefineLabel(self: *Self) !Label {
const lbl = try self.createLabel();
try self.defineLabel(lbl);
return lbl;
}
/// Pushes a new loop construct.
/// `breakLabel` is a label that is jumped to when a `break` instruction is emitted. This is usually the end of the loop.
/// `continueLabel` is a label that is jumped to when a `continue` instruction is emitted. This is usually the start of the loop.
pub fn pushLoop(self: *Self, breakLabel: Label, continueLabel: Label) !void {
try self.loops.append(Loop{
.breakLabel = breakLabel,
.continueLabel = continueLabel,
});
}
/// Pops a loop from the stack.
pub fn popLoop(self: *Self) void {
std.debug.assert(self.loops.items.len > 0);
_ = self.loops.pop();
}
/// emits raw data
pub fn emitRaw(self: *Self, data: []const u8) !void {
if (self.code.items.len + data.len > std.math.maxInt(u32))
return error.OutOfMemory;
try self.code.writer().writeAll(data);
}
/// Emits a label and marks a patch position if necessary
pub fn emitLabel(self: *Self, label: Label) !void {
if (self.labels.get(label)) |offset| {
try self.emitU32(offset);
} else {
try self.patches.append(Patch{
.label = label,
.offset = @intCast(u32, self.code.items.len),
});
try self.emitU32(0xFFFFFFFF);
}
}
/// Emits a raw instruction name without the corresponding instruction arguments.
pub fn emitInstructionName(self: *Self, name: InstructionName) !void {
try self.emitU8(@enumToInt(name));
}
pub fn emitInstruction(self: *Self, instr: Instruction) !void {
try self.emitInstructionName(instr);
inline for (std.meta.fields(Instruction)) |fld| {
if (instr == @field(InstructionName, fld.name)) {
const value = @field(instr, fld.name);
if (fld.field_type == Instruction.Deprecated) {
@panic("called emitInstruction with a deprecated instruction!"); // this is a API violation
} else if (fld.field_type == Instruction.NoArg) {
// It's enough to emit the instruction name
return;
} else if (fld.field_type == Instruction.CallArg) {
try self.emitString(value.function);
try self.emitU8(value.argc);
return;
} else {
const ValType = std.meta.fieldInfo(fld.field_type, "value").field_type;
switch (ValType) {
[]const u8 => try self.emitString(value.value),
u8 => try self.emitU8(value.value),
u16 => try self.emitU16(value.value),
u32 => try self.emitU32(value.value),
f64 => try self.emitNumber(value.value),
else => @compileError("Unsupported encoding: " ++ @typeName(ValType)),
}
return;
}
}
}
unreachable;
}
fn emitNumber(self: *Self, val: f64) !void {
try self.emitRaw(std.mem.asBytes(&val));
}
/// Encodes a variable-length string with a max. length of 0 … 65535 characters.
pub fn emitString(self: *Self, val: []const u8) !void {
try self.emitU16(try std.math.cast(u16, val.len));
try self.emitRaw(val);
}
fn emitInteger(self: *Self, comptime T: type, val: T) !void {
var buf: [@sizeOf(T)]u8 = undefined;
std.mem.writeIntLittle(T, &buf, val);
try self.emitRaw(&buf);
}
/// Emits a unsigned 32 bit integer, encoded little endian.
pub fn emitU8(self: *Self, val: u8) !void {
try self.emitInteger(u8, val);
}
/// Emits a unsigned 32 bit integer, encoded little endian.
pub fn emitU16(self: *Self, val: u16) !void {
try self.emitInteger(u16, val);
}
/// Emits a unsigned 32 bit integer, encoded little endian.
pub fn emitU32(self: *Self, val: u32) !void {
try self.emitInteger(u32, val);
}
pub fn emitBreak(self: *Self) !void {
if (self.loops.items.len > 0) {
const loop = self.loops.items[self.loops.items.len - 1];
try self.emitInstructionName(.jmp);
try self.emitLabel(loop.breakLabel);
} else {
return error.NotInLoop;
}
}
pub fn emitContinue(self: *Self) !void {
if (self.loops.items.len > 0) {
const loop = self.loops.items[self.loops.items.len - 1];
try self.emitInstructionName(.jmp);
try self.emitLabel(loop.continueLabel);
} else {
return error.NotInLoop;
}
}
};
test "empty code generation" {
var writer = CodeWriter.init(std.testing.allocator);
defer writer.deinit();
const mem = try writer.finalize();
defer std.testing.allocator.free(mem);
std.testing.expectEqualSlices(u8, "", mem);
}
test "emitting primitive values" {
var writer = CodeWriter.init(std.testing.allocator);
defer writer.deinit();
try writer.emitU32(0x44332211);
try writer.emitU16(0x6655);
try writer.emitU8(0x77);
try writer.emitInstructionName(.jmp);
const mem = try writer.finalize();
defer std.testing.allocator.free(mem);
std.testing.expectEqualSlices(u8, "\x11\x22\x33\x44\x55\x66\x77\x1B", mem);
}
test "emitting variable-width strings" {
var writer = CodeWriter.init(std.testing.allocator);
defer writer.deinit();
try writer.emitString("Hello");
const mem = try writer.finalize();
defer std.testing.allocator.free(mem);
std.testing.expectEqualSlices(u8, "\x05\x00Hello", mem);
}
test "label handling" {
var writer = CodeWriter.init(std.testing.allocator);
defer writer.deinit();
const label = try writer.createLabel();
try writer.emitLabel(label); // tests the patch path
try writer.defineLabel(label); // tests label insertion
try writer.emitLabel(label); // tests the fast-forward path
const mem = try writer.finalize();
defer std.testing.allocator.free(mem);
std.testing.expectEqualSlices(u8, "\x04\x00\x00\x00\x04\x00\x00\x00", mem);
}
test "label creation" {
var writer = CodeWriter.init(std.testing.allocator);
defer writer.deinit();
const label1 = try writer.createLabel();
const label2 = try writer.createLabel();
const label3 = try writer.createLabel();
std.testing.expect(label1 != label2);
std.testing.expect(label1 != label3);
std.testing.expect(label2 != label3);
}
test "loop creation, break and continue emission" {
var writer = CodeWriter.init(std.testing.allocator);
defer writer.deinit();
const label_start = try writer.createLabel();
const label_end = try writer.createLabel();
std.testing.expectError(error.NotInLoop, writer.emitBreak());
std.testing.expectError(error.NotInLoop, writer.emitContinue());
try writer.emitRaw("A");
try writer.pushLoop(label_end, label_start);
try writer.emitRaw("B");
try writer.defineLabel(label_start);
try writer.emitRaw("C");
try writer.emitBreak();
try writer.emitRaw("D");
try writer.emitContinue();
try writer.emitRaw("E");
try writer.defineLabel(label_end);
try writer.emitRaw("F");
writer.popLoop();
std.testing.expectError(error.NotInLoop, writer.emitBreak());
std.testing.expectError(error.NotInLoop, writer.emitContinue());
const mem = try writer.finalize();
defer std.testing.allocator.free(mem);
std.testing.expectEqualSlices(u8, "ABC\x1B\x0F\x00\x00\x00D\x1B\x02\x00\x00\x00EF", mem);
}
test "emitting numeric value" {
var writer = CodeWriter.init(std.testing.allocator);
defer writer.deinit();
try writer.emitNumber(0.0);
const mem = try writer.finalize();
defer std.testing.allocator.free(mem);
std.testing.expectEqualSlices(u8, "\x00\x00\x00\x00\x00\x00\x00\x00", mem);
}
test "instruction emission" {
var writer = CodeWriter.init(std.testing.allocator);
defer writer.deinit();
// tests a NoArg instruction
try writer.emitInstruction(Instruction{
.push_void = .{},
});
// tests a SingleArg([]const u8) instruction
try writer.emitInstruction(Instruction{
.push_str = .{ .value = "abc" },
});
// tests a SingleArg(f64) instruction
try writer.emitInstruction(Instruction{
.push_num = .{ .value = 0.0000 },
});
// tests a SingleArg(u32) instruction
try writer.emitInstruction(Instruction{
.jmp = .{ .value = 0x44332211 },
});
// tests a SingleArg(u16) instruction
try writer.emitInstruction(Instruction{
.store_local = .{ .value = 0xBEEF },
});
const mem = try writer.finalize();
defer std.testing.allocator.free(mem);
std.testing.expectEqualSlices(
u8,
"\x2B" ++ "\x06\x03\x00abc" ++ "\x07\x00\x00\x00\x00\x00\x00\x00\x00" ++ "\x1B\x11\x22\x33\x44" ++ "\x22\xEF\xBE",
mem,
);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/compiler/codegen.zig | const std = @import("std");
const ast = @import("ast.zig");
const Location = @import("location.zig").Location;
const Scope = @import("scope.zig").Scope;
const Diagnostics = @import("diagnostics.zig").Diagnostics;
const CompileUnit = @import("../common/compile-unit.zig").CompileUnit;
const CodeWriter = @import("code-writer.zig").CodeWriter;
const Instruction = @import("../common/ir.zig").Instruction;
const CodeGenError = error{
OutOfMemory,
AlreadyDeclared,
TooManyVariables,
TooManyLabels,
LabelAlreadyDefined,
Overflow,
NotInLoop,
VariableNotFound,
InvalidStoreTarget,
};
/// Helper structure to emit debug symbols
const DebugSyms = struct {
const Self = @This();
writer: *CodeWriter,
symbols: std.ArrayList(CompileUnit.DebugSymbol),
fn push(self: *Self, location: Location) !void {
try self.symbols.append(CompileUnit.DebugSymbol{
.offset = @intCast(u32, self.writer.code.items.len),
.sourceLine = location.line,
.sourceColumn = @intCast(u16, location.column),
});
}
};
fn emitStore(debug_symbols: *DebugSyms, scope: *Scope, writer: *CodeWriter, expression: ast.Expression) CodeGenError!void {
try debug_symbols.push(expression.location);
std.debug.assert(expression.isAssignable());
switch (expression.type) {
.array_indexer => |indexer| {
try emitExpression(debug_symbols, scope, writer, indexer.index.*); // load the index on the stack
try emitExpression(debug_symbols, scope, writer, indexer.value.*); // load the array on the stack
try writer.emitInstructionName(.array_store);
try emitStore(debug_symbols, scope, writer, indexer.value.*); // now store back the value on the stack
},
.variable_expr => |variable_name| {
if (std.mem.eql(u8, variable_name, "true")) {
return error.InvalidStoreTarget;
} else if (std.mem.eql(u8, variable_name, "false")) {
return error.InvalidStoreTarget;
} else if (std.mem.eql(u8, variable_name, "void")) {
return error.InvalidStoreTarget;
} else {
const v = scope.get(variable_name) orelse return error.VariableNotFound;
switch (v.type) {
.global => try writer.emitInstruction(Instruction{
.store_global_idx = .{ .value = v.storage_slot },
}),
.local => try writer.emitInstruction(Instruction{
.store_local = .{ .value = v.storage_slot },
}),
}
}
},
else => unreachable,
}
}
fn emitExpression(debug_symbols: *DebugSyms, scope: *Scope, writer: *CodeWriter, expression: ast.Expression) CodeGenError!void {
try debug_symbols.push(expression.location);
switch (expression.type) {
.array_indexer => |indexer| {
try emitExpression(debug_symbols, scope, writer, indexer.index.*);
try emitExpression(debug_symbols, scope, writer, indexer.value.*);
try writer.emitInstructionName(.array_load);
},
.variable_expr => |variable_name| {
if (std.mem.eql(u8, variable_name, "true")) {
try writer.emitInstruction(Instruction{
.push_true = .{},
});
} else if (std.mem.eql(u8, variable_name, "false")) {
try writer.emitInstruction(Instruction{
.push_false = .{},
});
} else if (std.mem.eql(u8, variable_name, "void")) {
try writer.emitInstruction(Instruction{
.push_void = .{},
});
} else {
const v = scope.get(variable_name) orelse return error.VariableNotFound;
switch (v.type) {
.global => try writer.emitInstruction(Instruction{
.load_global_idx = .{ .value = v.storage_slot },
}),
.local => try writer.emitInstruction(Instruction{
.load_local = .{ .value = v.storage_slot },
}),
}
}
},
.array_literal => |array| {
var i: usize = array.len;
while (i > 0) {
i -= 1;
try emitExpression(debug_symbols, scope, writer, array[i]);
}
try writer.emitInstruction(Instruction{
.array_pack = .{ .value = @intCast(u16, array.len) },
});
},
.function_call => |call| {
var i: usize = call.arguments.len;
while (i > 0) {
i -= 1;
try emitExpression(debug_symbols, scope, writer, call.arguments[i]);
}
try writer.emitInstruction(Instruction{
.call_fn = .{
.function = call.function.type.variable_expr,
.argc = @intCast(u8, call.arguments.len),
},
});
},
.method_call => |call| {
// TODO: Write code in compiler.lola that covers this path.
var i: usize = call.arguments.len;
while (i > 0) {
i -= 1;
try emitExpression(debug_symbols, scope, writer, call.arguments[i]);
}
try emitExpression(debug_symbols, scope, writer, call.object.*);
try writer.emitInstruction(Instruction{
.call_obj = .{
.function = call.name,
.argc = @intCast(u8, call.arguments.len),
},
});
},
.number_literal => |literal| {
try writer.emitInstruction(Instruction{
.push_num = .{ .value = literal },
});
},
.string_literal => |literal| {
try writer.emitInstruction(Instruction{
.push_str = .{ .value = literal },
});
},
.unary_operator => |expr| {
try emitExpression(debug_symbols, scope, writer, expr.value.*);
try writer.emitInstructionName(switch (expr.operator) {
.negate => .negate,
.boolean_not => .bool_not,
});
},
.binary_operator => |expr| {
try emitExpression(debug_symbols, scope, writer, expr.lhs.*);
try emitExpression(debug_symbols, scope, writer, expr.rhs.*);
try writer.emitInstructionName(switch (expr.operator) {
.add => .add,
.subtract => .sub,
.multiply => .mul,
.divide => .div,
.modulus => .mod,
.boolean_or => .bool_or,
.boolean_and => .bool_and,
.less_than => .less,
.greater_than => .greater,
.greater_or_equal_than => .greater_eq,
.less_or_equal_than => .less_eq,
.equal => .eq,
.different => .neq,
});
},
}
}
fn emitStatement(debug_symbols: *DebugSyms, scope: *Scope, writer: *CodeWriter, stmt: ast.Statement) CodeGenError!void {
try debug_symbols.push(stmt.location);
switch (stmt.type) {
.empty => {
// trivial: do nothing!
},
.assignment => |ass| {
try emitExpression(debug_symbols, scope, writer, ass.value);
try emitStore(debug_symbols, scope, writer, ass.target);
},
.discard_value => |expr| {
try emitExpression(debug_symbols, scope, writer, expr);
try writer.emitInstruction(Instruction{
.pop = .{},
});
},
.return_void => {
try writer.emitInstruction(Instruction{
.ret = .{},
});
},
.return_expr => |expr| {
try emitExpression(debug_symbols, scope, writer, expr);
try writer.emitInstruction(Instruction{
.retval = .{},
});
},
.while_loop => |loop| {
const cont_lbl = try writer.createAndDefineLabel();
const break_lbl = try writer.createLabel();
try writer.pushLoop(break_lbl, cont_lbl);
try emitExpression(debug_symbols, scope, writer, loop.condition);
try writer.emitInstructionName(.jif);
try writer.emitLabel(break_lbl);
try emitStatement(debug_symbols, scope, writer, loop.body.*);
try writer.emitInstructionName(.jmp);
try writer.emitLabel(cont_lbl);
try writer.defineLabel(break_lbl);
writer.popLoop();
},
.for_loop => |loop| {
try scope.enter();
try emitExpression(debug_symbols, scope, writer, loop.source);
try writer.emitInstructionName(.iter_make);
// Loop variable is a constant!
try scope.declare(loop.variable, true);
const loopvar = scope.get(loop.variable) orelse unreachable;
std.debug.assert(loopvar.type == .local);
const loop_start = try writer.createAndDefineLabel();
const loop_end = try writer.createLabel();
try writer.pushLoop(loop_end, loop_start);
try writer.emitInstructionName(.iter_next);
try writer.emitInstructionName(.jif);
try writer.emitLabel(loop_end);
try writer.emitInstruction(Instruction{
.store_local = .{
.value = loopvar.storage_slot,
},
});
try emitStatement(debug_symbols, scope, writer, loop.body.*);
try writer.emitInstructionName(.jmp);
try writer.emitLabel(loop_start);
try writer.defineLabel(loop_end);
writer.popLoop();
// // erase the iterator from the stack
try writer.emitInstructionName(.pop);
try scope.leave();
},
.if_statement => |conditional| {
const end_if = try writer.createLabel();
try emitExpression(debug_symbols, scope, writer, conditional.condition);
if (conditional.false_body) |false_body| {
const false_lbl = try writer.createLabel();
try writer.emitInstructionName(.jif);
try writer.emitLabel(false_lbl);
try emitStatement(debug_symbols, scope, writer, conditional.true_body.*);
try writer.emitInstructionName(.jmp);
try writer.emitLabel(end_if);
try writer.defineLabel(false_lbl);
try emitStatement(debug_symbols, scope, writer, false_body.*);
} else {
try writer.emitInstructionName(.jif);
try writer.emitLabel(end_if);
try emitStatement(debug_symbols, scope, writer, conditional.true_body.*);
}
try writer.defineLabel(end_if);
},
.declaration => |decl| {
try scope.declare(decl.variable, decl.is_const);
if (decl.initial_value) |value| {
try emitExpression(debug_symbols, scope, writer, value);
const v = scope.get(decl.variable) orelse unreachable;
switch (v.type) {
.local => try writer.emitInstruction(Instruction{
.store_local = .{
.value = v.storage_slot,
},
}),
.global => try writer.emitInstruction(Instruction{
.store_global_idx = .{
.value = v.storage_slot,
},
}),
}
}
},
.block => |blk| {
try scope.enter();
for (blk) |s| {
try emitStatement(debug_symbols, scope, writer, s);
}
try scope.leave();
},
.@"break" => {
try writer.emitBreak();
},
.@"continue" => {
try writer.emitContinue();
},
}
}
/// Generates code for a given program. The program is assumed to be sane and checked with
/// code analysis already.
pub fn generateIR(
allocator: *std.mem.Allocator,
program: ast.Program,
comment: []const u8,
) !CompileUnit {
var arena = std.heap.ArenaAllocator.init(allocator);
errdefer arena.deinit();
var writer = CodeWriter.init(allocator);
defer writer.deinit();
var functions = std.ArrayList(CompileUnit.Function).init(allocator);
defer functions.deinit();
var debug_symbols = DebugSyms{
.writer = &writer,
.symbols = std.ArrayList(CompileUnit.DebugSymbol).init(allocator),
};
defer debug_symbols.symbols.deinit();
var global_scope = Scope.init(allocator, null, true);
defer global_scope.deinit();
for (program.root_script) |stmt| {
try emitStatement(&debug_symbols, &global_scope, &writer, stmt);
}
// each script ends with a return
try writer.emitInstruction(Instruction{
.ret = .{},
});
std.debug.assert(global_scope.return_point.items.len == 0);
for (program.functions) |function, i| {
const entry_point = @intCast(u32, writer.code.items.len);
var local_scope = Scope.init(allocator, &global_scope, false);
defer local_scope.deinit();
for (function.parameters) |param| {
try local_scope.declare(param, true);
}
try emitStatement(&debug_symbols, &local_scope, &writer, function.body);
// when no explicit return is given, we implicitly return void
try writer.emitInstruction(Instruction{
.ret = .{},
});
try functions.append(CompileUnit.Function{
.name = try arena.allocator.dupe(u8, function.name),
.entryPoint = entry_point,
.localCount = @intCast(u16, local_scope.max_locals),
});
}
const code = try writer.finalize();
defer allocator.free(code);
std.sort.sort(CompileUnit.DebugSymbol, debug_symbols.symbols.items, {}, struct {
fn lessThan(v: void, lhs: CompileUnit.DebugSymbol, rhs: CompileUnit.DebugSymbol) bool {
return lhs.offset < rhs.offset;
}
}.lessThan);
var cu = CompileUnit{
.comment = try arena.allocator.dupe(u8, comment),
.globalCount = @intCast(u16, global_scope.global_variables.items.len),
.temporaryCount = @intCast(u16, global_scope.max_locals),
.code = try arena.allocator.dupe(u8, code),
.functions = try arena.allocator.dupe(CompileUnit.Function, functions.items),
.debugSymbols = try arena.allocator.dupe(CompileUnit.DebugSymbol, debug_symbols.symbols.items),
.arena = undefined,
};
// this prevents miscompilation of undefined evaluation order in init statement.
// we need to use the arena for allocation above, so we change it.
cu.arena = arena;
return cu;
}
test "code generation" {
// For lack of a better idea:
// Just run the analysis against the compiler test suite
var diagnostics = Diagnostics.init(std.testing.allocator);
defer diagnostics.deinit();
const seq = try @import("tokenizer.zig").tokenize(std.testing.allocator, &diagnostics, "src/test/compiler.lola", @embedFile("../../test/compiler.lola"));
defer std.testing.allocator.free(seq);
var pgm = try @import("parser.zig").parse(std.testing.allocator, &diagnostics, seq);
defer pgm.deinit();
var compile_unit = try generateIR(std.testing.allocator, pgm, "test unit");
defer compile_unit.deinit();
std.testing.expectEqual(@as(usize, 0), diagnostics.messages.items.len);
std.testing.expectEqualStrings("test unit", compile_unit.comment);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/compiler/analysis.zig | const std = @import("std");
const ast = @import("ast.zig");
const Location = @import("location.zig").Location;
const Scope = @import("scope.zig").Scope;
const Diagnostics = @import("diagnostics.zig").Diagnostics;
const Type = @import("typeset.zig").Type;
const TypeSet = @import("typeset.zig").TypeSet;
const AnalysisState = struct {
/// Depth of nested loops (while, for)
loop_nesting: usize,
/// Depth of nested conditionally executed scopes (if, while, for)
conditional_scope_depth: usize,
/// Only `true` when not analyzing a function
is_root_script: bool,
};
const ValidationError = error{OutOfMemory};
const array_or_string = TypeSet.init(.{ .array, .string });
fn expressionTypeToString(src: ast.Expression.Type) []const u8 {
return switch (src) {
.array_indexer => "array indexer",
.variable_expr => "variable",
.array_literal => "array literal",
.function_call => "function call",
.method_call => "method call",
.number_literal => "number literal",
.string_literal => "string literal",
.unary_operator => "unary operator application",
.binary_operator => "binary operator application",
};
}
fn emitTooManyVariables(diagnostics: *Diagnostics, location: Location) !void {
try diagnostics.emit(.@"error", location, "Too many variables declared! The maximum allowed number of variables is 35535.", .{});
}
fn performTypeCheck(diagnostics: *Diagnostics, location: Location, expected: TypeSet, actual: TypeSet) !void {
if (expected.intersection(actual).isEmpty()) {
try diagnostics.emit(.warning, location, "Possible type mismatch detected: Expected {}, found {}", .{
expected,
actual,
});
}
}
/// Validates a expression and returns a set of possible result types.
fn validateExpression(state: *AnalysisState, diagnostics: *Diagnostics, scope: *Scope, expression: ast.Expression) ValidationError!TypeSet {
// we're happy for now with expressions...
switch (expression.type) {
.array_indexer => |indexer| {
const array_type = try validateExpression(state, diagnostics, scope, indexer.value.*);
const index_type = try validateExpression(state, diagnostics, scope, indexer.index.*);
try performTypeCheck(diagnostics, indexer.value.location, array_or_string, array_type);
try performTypeCheck(diagnostics, indexer.index.location, TypeSet.from(.number), index_type);
if (array_type.contains(.array)) {
// when we're possibly indexing an array,
// we return a value of type `any`
return TypeSet.any;
} else if (array_type.contains(.string)) {
// when we are not an array, but a string,
// we can only return a number.
return TypeSet.from(.number);
} else {
return TypeSet.empty;
}
},
.variable_expr => |variable_name| {
// Check reserved names
if (std.mem.eql(u8, variable_name, "true")) {
return TypeSet.from(.boolean);
} else if (std.mem.eql(u8, variable_name, "false")) {
return TypeSet.from(.boolean);
} else if (std.mem.eql(u8, variable_name, "void")) {
return TypeSet.from(.void);
}
const variable = scope.get(variable_name) orelse {
try diagnostics.emit(.@"error", expression.location, "Use of undeclared variable {}", .{
variable_name,
});
return TypeSet.any;
};
return variable.possible_types;
},
.array_literal => |array| {
for (array) |item| {
_ = try validateExpression(state, diagnostics, scope, item);
}
return TypeSet.from(.array);
},
.function_call => |call| {
if (call.function.type != .variable_expr) {
try diagnostics.emit(.@"error", expression.location, "Function name expected", .{});
}
if (call.arguments.len >= 256) {
try diagnostics.emit(.@"error", expression.location, "Function argument list exceeds 255 arguments!", .{});
}
for (call.arguments) |item| {
_ = try validateExpression(state, diagnostics, scope, item);
}
return TypeSet.any;
},
.method_call => |call| {
_ = try validateExpression(state, diagnostics, scope, call.object.*);
for (call.arguments) |item| {
_ = try validateExpression(state, diagnostics, scope, item);
}
return TypeSet.any;
},
.number_literal => |expr| {
// these are always ok
return TypeSet.from(.number);
},
.string_literal => |literal| {
return TypeSet.from(.string);
},
.unary_operator => |expr| {
const result = try validateExpression(state, diagnostics, scope, expr.value.*);
const expected = switch (expr.operator) {
.negate => Type.number,
.boolean_not => Type.boolean,
};
try performTypeCheck(diagnostics, expression.location, TypeSet.from(expected), result);
return result;
},
.binary_operator => |expr| {
const lhs = try validateExpression(state, diagnostics, scope, expr.lhs.*);
const rhs = try validateExpression(state, diagnostics, scope, expr.rhs.*);
const accepted_set = switch (expr.operator) {
.add => TypeSet.init(.{ .string, .number, .array }),
.subtract, .multiply, .divide, .modulus => TypeSet.from(.number),
.boolean_or, .boolean_and => TypeSet.from(.boolean),
.equal, .different => TypeSet.any,
.less_than, .greater_than, .greater_or_equal_than, .less_or_equal_than => TypeSet.init(.{ .string, .number, .array }),
};
try performTypeCheck(diagnostics, expr.lhs.location, accepted_set, lhs);
try performTypeCheck(diagnostics, expr.rhs.location, accepted_set, rhs);
if (!TypeSet.areCompatible(lhs, rhs)) {
try diagnostics.emit(.warning, expression.location, "Possible type mismatch detected. {} and {} are not compatible.\n", .{
lhs,
rhs,
});
return TypeSet.empty;
}
return switch (expr.operator) {
.add => TypeSet.intersection(lhs, rhs),
.subtract, .multiply, .divide, .modulus => TypeSet.from(.number),
.boolean_or, .boolean_and => TypeSet.from(.boolean),
.less_than, .greater_than, .greater_or_equal_than, .less_or_equal_than, .equal, .different => TypeSet.from(.boolean),
};
},
}
return .void;
}
fn validateStore(state: *AnalysisState, diagnostics: *Diagnostics, scope: *Scope, expression: ast.Expression, type_hint: TypeSet) ValidationError!void {
if (!expression.isAssignable()) {
try diagnostics.emit(.@"error", expression.location, "Expected array indexer or a variable, got {}", .{
expressionTypeToString(expression.type),
});
return;
}
switch (expression.type) {
.array_indexer => |indexer| {
const array_val = try validateExpression(state, diagnostics, scope, indexer.value.*);
const index_val = try validateExpression(state, diagnostics, scope, indexer.index.*);
try performTypeCheck(diagnostics, indexer.value.location, array_or_string, array_val);
try performTypeCheck(diagnostics, indexer.index.location, TypeSet.from(.number), index_val);
if (array_val.contains(.string) and !array_val.contains(.array)) {
// when we are sure we write into a string, but definitly not an array
// check if we're writing a number.
try performTypeCheck(diagnostics, expression.location, TypeSet.from(.number), type_hint);
}
// now propagate the store validation back to the lvalue.
// Note that we can assume that the lvalue _is_ a array, as it would be a type mismatch otherwise.
try validateStore(state, diagnostics, scope, indexer.value.*, array_or_string.intersection(array_val));
},
.variable_expr => |variable_name| {
if (std.mem.eql(u8, variable_name, "true") or std.mem.eql(u8, variable_name, "false") or std.mem.eql(u8, variable_name, "void")) {
try diagnostics.emit(.@"error", expression.location, "Expected array indexer or a variable, got {}", .{
variable_name,
});
} else if (scope.get(variable_name)) |variable| {
if (variable.is_const) {
try diagnostics.emit(.@"error", expression.location, "Assignment to constant {} not allowed.", .{
variable_name,
});
}
const previous = variable.possible_types;
if (state.conditional_scope_depth > 0) {
variable.possible_types = variable.possible_types.@"union"(type_hint);
} else {
variable.possible_types = type_hint;
}
// std.debug.warn("mutate {} from {} into {} applying {}\n", .{
// variable_name,
// previous,
// variable.possible_types,
// type_hint,
// });
}
},
else => unreachable,
}
}
fn validateStatement(state: *AnalysisState, diagnostics: *Diagnostics, scope: *Scope, stmt: ast.Statement) ValidationError!void {
switch (stmt.type) {
.empty => {
// trivial: do nothing!
},
.assignment => |ass| {
const value_type = try validateExpression(state, diagnostics, scope, ass.value);
if (ass.target.isAssignable()) {
try validateStore(state, diagnostics, scope, ass.target, value_type);
} else {
try diagnostics.emit(.@"error", ass.target.location, "Expected either a array indexer or a variable, got {}", .{
@tagName(@as(ast.Expression.Type, ass.target.type)),
});
}
},
.discard_value => |expr| {
_ = try validateExpression(state, diagnostics, scope, expr);
},
.return_void => {
// this is always ok
},
.return_expr => |expr| {
// this is ok when the expr is ok
_ = try validateExpression(state, diagnostics, scope, expr);
// and when we are not on the root script.
if (state.is_root_script) {
try diagnostics.emit(.@"error", stmt.location, "Returning a value from global scope is not allowed.", .{});
}
},
.while_loop => |loop| {
state.loop_nesting += 1;
defer state.loop_nesting -= 1;
state.conditional_scope_depth += 1;
defer state.conditional_scope_depth -= 1;
const condition_type = try validateExpression(state, diagnostics, scope, loop.condition);
try validateStatement(state, diagnostics, scope, loop.body.*);
try performTypeCheck(diagnostics, stmt.location, TypeSet.from(.boolean), condition_type);
},
.for_loop => |loop| {
state.loop_nesting += 1;
defer state.loop_nesting -= 1;
state.conditional_scope_depth += 1;
defer state.conditional_scope_depth -= 1;
try scope.enter();
scope.declare(loop.variable, true) catch |err| switch (err) {
error.AlreadyDeclared => unreachable, // not possible for locals
error.TooManyVariables => try emitTooManyVariables(diagnostics, stmt.location),
else => |e| return e,
};
const array_type = try validateExpression(state, diagnostics, scope, loop.source);
try validateStatement(state, diagnostics, scope, loop.body.*);
try performTypeCheck(diagnostics, stmt.location, TypeSet.from(.array), array_type);
try scope.leave();
},
.if_statement => |conditional| {
state.conditional_scope_depth += 1;
defer state.conditional_scope_depth -= 1;
const conditional_type = try validateExpression(state, diagnostics, scope, conditional.condition);
try validateStatement(state, diagnostics, scope, conditional.true_body.*);
if (conditional.false_body) |body| {
try validateStatement(state, diagnostics, scope, body.*);
}
try performTypeCheck(diagnostics, stmt.location, TypeSet.from(.boolean), conditional_type);
},
.declaration => |decl| {
// evaluate expression before so we can safely reference up-variables:
// var a = a * 2;
const initial_value = if (decl.initial_value) |init_val|
try validateExpression(state, diagnostics, scope, init_val)
else
null;
scope.declare(decl.variable, decl.is_const) catch |err| switch (err) {
error.AlreadyDeclared => try diagnostics.emit(.@"error", stmt.location, "Global variable {} is already declared!", .{decl.variable}),
error.TooManyVariables => try emitTooManyVariables(diagnostics, stmt.location),
else => |e| return e,
};
if (initial_value) |init_val|
scope.get(decl.variable).?.possible_types = init_val;
if (decl.is_const and decl.initial_value == null) {
try diagnostics.emit(.@"error", stmt.location, "Constant {} must be initialized!", .{
decl.variable,
});
}
},
.block => |blk| {
try scope.enter();
for (blk) |sub_stmt| {
try validateStatement(state, diagnostics, scope, sub_stmt);
}
try scope.leave();
},
.@"break" => {
if (state.loop_nesting == 0) {
try diagnostics.emit(.@"error", stmt.location, "break outside of loop!", .{});
}
},
.@"continue" => {
if (state.loop_nesting == 0) {
try diagnostics.emit(.@"error", stmt.location, "continue outside of loop!", .{});
}
},
}
}
fn getErrorCount(diagnostics: *const Diagnostics) usize {
var res: usize = 0;
for (diagnostics.messages.items) |msg| {
if (msg.kind == .@"error")
res += 1;
}
return res;
}
/// Validates the `program` against programming mistakes and filles `diagnostics` with the findings.
/// Note that the function will always succeed when no `OutOfMemory` happens. To see if the program
/// is semantically sound, check `diagnostics` for error messages.
pub fn validate(allocator: *std.mem.Allocator, diagnostics: *Diagnostics, program: ast.Program) ValidationError!bool {
var global_scope = Scope.init(allocator, null, true);
defer global_scope.deinit();
const initial_errc = getErrorCount(diagnostics);
for (program.root_script) |stmt| {
var state = AnalysisState{
.loop_nesting = 0,
.is_root_script = true,
.conditional_scope_depth = 0,
};
try validateStatement(&state, diagnostics, &global_scope, stmt);
}
std.debug.assert(global_scope.return_point.items.len == 0);
for (program.functions) |function, i| {
for (program.functions[0..i]) |other_fn| {
if (std.mem.eql(u8, function.name, other_fn.name)) {
try diagnostics.emit(.@"error", function.location, "A function with the name {} was already declared!", .{function.name});
break;
}
}
var local_scope = Scope.init(allocator, &global_scope, false);
defer local_scope.deinit();
for (function.parameters) |param| {
local_scope.declare(param, true) catch |err| switch (err) {
error.AlreadyDeclared => try diagnostics.emit(.@"error", function.location, "A parameter {} is already declared!", .{param}),
error.TooManyVariables => try emitTooManyVariables(diagnostics, function.location),
else => |e| return e,
};
}
var state = AnalysisState{
.loop_nesting = 0,
.is_root_script = false,
.conditional_scope_depth = 0,
};
try validateStatement(&state, diagnostics, &local_scope, function.body);
}
return (getErrorCount(diagnostics) == initial_errc);
}
test "validate correct program" {
// For lack of a better idea:
// Just run the analysis against the compiler test suite
var diagnostics = Diagnostics.init(std.testing.allocator);
defer diagnostics.deinit();
const seq = try @import("tokenizer.zig").tokenize(std.testing.allocator, &diagnostics, "src/test/compiler.lola", @embedFile("../../test/compiler.lola"));
defer std.testing.allocator.free(seq);
var pgm = try @import("parser.zig").parse(std.testing.allocator, &diagnostics, seq);
defer pgm.deinit();
std.testing.expectEqual(true, try validate(std.testing.allocator, &diagnostics, pgm));
for (diagnostics.messages.items) |msg| {
std.debug.warn("{}\n", .{msg});
}
std.testing.expectEqual(@as(usize, 0), diagnostics.messages.items.len);
}
fn expectAnalysisErrors(source: []const u8, expected_messages: []const []const u8) !void {
// For lack of a better idea:
// Just run the analysis against the compiler test suite
var diagnostics = Diagnostics.init(std.testing.allocator);
defer diagnostics.deinit();
const seq = try @import("tokenizer.zig").tokenize(std.testing.allocator, &diagnostics, "", source);
defer std.testing.allocator.free(seq);
var pgm = try @import("parser.zig").parse(std.testing.allocator, &diagnostics, seq);
defer pgm.deinit();
std.testing.expectEqual(false, try validate(std.testing.allocator, &diagnostics, pgm));
std.testing.expectEqual(expected_messages.len, diagnostics.messages.items.len);
for (expected_messages) |expected, i| {
std.testing.expectEqualStrings(expected, diagnostics.messages.items[i].message);
}
}
test "detect return from root script" {
try expectAnalysisErrors("return 10;", &[_][]const u8{
"Returning a value from global scope is not allowed.",
});
}
test "detect const without init" {
try expectAnalysisErrors("const a;", &[_][]const u8{
"Constant a must be initialized!",
});
}
test "detect assignment to const" {
try expectAnalysisErrors("const a = 5; a = 10;", &[_][]const u8{
"Assignment to constant a not allowed.",
});
}
test "detect doubly-declared global variables" {
try expectAnalysisErrors("var a; var a;", &[_][]const u8{
"Global variable a is already declared!",
});
}
test "detect assignment to const parameter" {
try expectAnalysisErrors("function f(x) { x = void; }", &[_][]const u8{
"Assignment to constant x not allowed.",
});
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/compiler/tokenizer.zig | const std = @import("std");
const Diagnostics = @import("diagnostics.zig").Diagnostics;
pub const TokenType = enum {
const Self = @This();
number_literal,
string_literal,
character_literal,
identifier,
comment,
whitespace,
@"{",
@"}",
@"(",
@")",
@"]",
@"[",
@"var",
@"const",
@"for",
@"while",
@"if",
@"else",
@"function",
@"in",
@"break",
@"continue",
@"return",
@"and",
@"or",
@"not",
@"+=",
@"-=",
@"*=",
@"/=",
@"%=",
@"<=",
@">=",
@"<",
@">",
@"!=",
@"==",
@"=",
@".",
@",",
@";",
@"+",
@"-",
@"*",
@"/",
@"%",
/// Returns `true` when the token type is emitted from the tokenizer,
/// otherwise `false`.
pub fn isEmitted(self: Self) bool {
return switch (self) {
.comment, .whitespace => false,
else => true,
};
}
};
const keywords = [_][]const u8{
"var",
"for",
"while",
"if",
"else",
"function",
"in",
"break",
"continue",
"return",
"and",
"or",
"not",
"const",
};
pub const Location = @import("location.zig").Location;
/// A single, recognized piece of text in the source file.
pub const Token = struct {
/// the text that was recognized
text: []const u8,
/// the position in the source file
location: Location,
/// the type (and parsed value) of the token
type: TokenType,
};
pub const Tokenizer = struct {
const Self = @This();
/// Result from a tokenization process
const Result = union(enum) {
token: Token,
end_of_file: void,
invalid_sequence: []const u8,
};
source: []const u8,
offset: usize,
current_location: Location,
pub fn init(chunk_name: []const u8, source: []const u8) Self {
return Self{
.source = source,
.offset = 0,
.current_location = Location{
.line = 1,
.column = 1,
.chunk = chunk_name,
.offset_start = undefined,
.offset_end = undefined,
},
};
}
pub fn next(self: *Self) Result {
while (true) {
const start = self.offset;
if (start >= self.source.len)
return .end_of_file;
if (nextInternal(self)) |token_type| {
const end = self.offset;
std.debug.assert(end > start); // tokens may never be empty!
var token = Token{
.type = token_type,
.location = self.current_location,
.text = self.source[start..end],
};
// std.debug.print("token: `{}`\n", .{token.text});
if (token.type == .identifier) {
inline for (keywords) |kwd| {
if (std.mem.eql(u8, token.text, kwd)) {
token.type = @field(TokenType, kwd);
break;
}
}
}
token.location.offset_start = start;
token.location.offset_end = end;
for (token.text) |c| {
if (c == '\n') {
self.current_location.line += 1;
self.current_location.column = 1;
} else {
self.current_location.column += 1;
}
}
if (token.type.isEmitted())
return Result{ .token = token };
} else {
while (self.accept(invalid_char_class)) {}
const end = self.offset;
self.current_location.offset_start = start;
self.current_location.offset_end = end;
return Result{ .invalid_sequence = self.source[start..end] };
}
}
}
const Predicate = fn (u8) bool;
fn accept(self: *Self, predicate: fn (u8) bool) bool {
if (self.offset >= self.source.len)
return false;
const c = self.source[self.offset];
const accepted = predicate(c);
// std.debug.print("{c} → {}\n", .{
// c, accepted,
// });
if (accepted) {
self.offset += 1;
return true;
} else {
return false;
}
}
fn any(c: u8) bool {
return true;
}
fn anyOf(comptime chars: []const u8) Predicate {
return struct {
fn pred(c: u8) bool {
return inline for (chars) |o| {
if (c == o)
break true;
} else false;
}
}.pred;
}
fn noneOf(comptime chars: []const u8) Predicate {
return struct {
fn pred(c: u8) bool {
return inline for (chars) |o| {
if (c == o)
break false;
} else true;
}
}.pred;
}
const invalid_char_class = noneOf(" \r\n\tABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789+-*/%={}()[]<>\"\'.,;!");
const whitespace_class = anyOf(" \r\n\t");
const comment_class = noneOf("\n");
const identifier_class = anyOf("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789");
const digit_class = anyOf("0123456789");
const hexdigit_class = anyOf("0123456789abcdefABCDEF");
const string_char_class = noneOf("\"\\");
const character_char_class = noneOf("\'\\");
fn nextInternal(self: *Self) ?TokenType {
std.debug.assert(self.offset < self.source.len);
// copy for shorter code
const source = self.source;
if (self.accept(whitespace_class)) {
while (self.accept(whitespace_class)) {}
return .whitespace;
}
const current_char = source[self.offset];
self.offset += 1;
switch (current_char) {
'=' => return if (self.accept(anyOf("=")))
.@"=="
else
.@"=",
'!' => return if (self.accept(anyOf("=")))
.@"!="
else
null,
'.' => return .@".",
',' => return .@",",
';' => return .@";",
'{' => return .@"{",
'}' => return .@"}",
'(' => return .@"(",
')' => return .@")",
']' => return .@"]",
'[' => return .@"[",
'+' => return if (self.accept(anyOf("=")))
.@"+="
else
.@"+",
'-' => return if (self.accept(anyOf("=")))
.@"-="
else
.@"-",
'*' => return if (self.accept(anyOf("=")))
.@"*="
else
.@"*",
'/' => {
if (self.accept(anyOf("/"))) {
while (self.accept(comment_class)) {}
return .comment;
} else if (self.accept(anyOf("="))) {
return .@"/=";
} else {
return .@"/";
}
},
'%' => return if (self.accept(anyOf("=")))
.@"%="
else
.@"%",
'<' => return if (self.accept(anyOf("=")))
.@"<="
else
.@"<",
'>' => return if (self.accept(anyOf("=")))
.@">="
else
.@">",
// parse numbers
'0'...'9' => {
while (self.accept(digit_class)) {}
if (self.accept(anyOf("xX"))) {
while (self.accept(hexdigit_class)) {}
return .number_literal;
} else if (self.accept(anyOf("."))) {
while (self.accept(digit_class)) {}
return .number_literal;
}
return .number_literal;
},
// parse identifiers
'a'...'z', 'A'...'Z', '_' => {
while (self.accept(identifier_class)) {}
return .identifier;
},
// parse strings
'"' => {
while (true) {
while (self.accept(string_char_class)) {}
if (self.accept(anyOf("\""))) {
return .string_literal;
} else if (self.accept(anyOf("\\"))) {
if (self.accept(anyOf("x"))) { // hex literal
if (!self.accept(hexdigit_class))
return null;
if (!self.accept(hexdigit_class))
return null;
} else {
if (!self.accept(any))
return null;
}
} else {
return null;
}
}
},
// parse character literals
'\'' => {
while (true) {
while (self.accept(character_char_class)) {}
if (self.accept(anyOf("\'"))) {
return .character_literal;
} else if (self.accept(anyOf("\\"))) {
if (self.accept(anyOf("x"))) { // hex literal
if (!self.accept(hexdigit_class))
return null;
if (!self.accept(hexdigit_class))
return null;
} else {
if (!self.accept(any))
return null;
}
} else {
return null;
}
}
},
else => return null,
}
}
};
pub fn tokenize(allocator: *std.mem.Allocator, diagnostics: *Diagnostics, chunk_name: []const u8, source: []const u8) ![]Token {
var result = std.ArrayList(Token).init(allocator);
var tokenizer = Tokenizer.init(chunk_name, source);
while (true) {
switch (tokenizer.next()) {
.end_of_file => return result.toOwnedSlice(),
.invalid_sequence => |seq| {
try diagnostics.emit(.@"error", tokenizer.current_location, "invalid byte sequence: {X}", .{
seq,
});
},
.token => |token| try result.append(token),
}
}
}
test "Tokenizer empty string" {
var tokenizer = Tokenizer.init("??", "");
std.testing.expectEqual(@TagType(Tokenizer.Result).end_of_file, tokenizer.next());
}
test "Tokenizer invalid bytes" {
var tokenizer = Tokenizer.init("??", "\\``?`a##§");
{
const item = tokenizer.next();
std.testing.expectEqual(@TagType(Tokenizer.Result).invalid_sequence, item);
std.testing.expectEqualStrings("\\``?`", item.invalid_sequence);
}
{
const item = tokenizer.next();
std.testing.expectEqual(@TagType(Tokenizer.Result).token, item);
std.testing.expectEqualStrings("a", item.token.text);
}
{
const item = tokenizer.next();
std.testing.expectEqual(@TagType(Tokenizer.Result).invalid_sequence, item);
std.testing.expectEqualStrings("##§", item.invalid_sequence);
}
}
test "Tokenizer (tokenize compiler test suite)" {
var tokenizer = Tokenizer.init("src/test/compiler.lola", @embedFile("../../test/compiler.lola"));
while (true) {
switch (tokenizer.next()) {
.token => {
// Use this for manual validation:
// std.debug.print("token: {}\n", .{tok});
},
.end_of_file => break,
.invalid_sequence => |seq| {
std.debug.print("failed to parse test file at `{}`!\n", .{
seq,
});
// this test should never reach this state, as the test file
// is validated by hand
unreachable;
},
}
}
}
test "tokenize" {
// TODO: Implement meaningful test
_ = tokenize;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/compiler/diagnostics.zig | const std = @import("std");
const Location = @import("location.zig").Location;
pub const Diagnostics = struct {
const Self = @This();
pub const MessageKind = enum {
@"error", warning, notice
};
pub const Message = struct {
kind: MessageKind,
location: Location,
message: []const u8,
pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
try writer.print("{}: {}: {}", .{
value.location,
@tagName(value.kind),
value.message,
});
}
};
arena: std.heap.ArenaAllocator,
messages: std.ArrayList(Message),
pub fn init(allocator: *std.mem.Allocator) Self {
return Self{
.arena = std.heap.ArenaAllocator.init(allocator),
.messages = std.ArrayList(Message).init(allocator),
};
}
pub fn deinit(self: *Self) void {
self.messages.deinit();
self.arena.deinit();
}
/// Emits a new diagnostic message and appends that to the current output.
pub fn emit(self: *Self, kind: MessageKind, location: Location, comptime fmt: []const u8, args: anytype) !void {
const msg_string = try std.fmt.allocPrint(&self.arena.allocator, fmt, args);
errdefer self.arena.allocator.free(msg_string);
try self.messages.append(Message{
.kind = kind,
.location = location,
.message = msg_string,
});
}
/// returns true when the collection has any critical messages.
pub fn hasErrors(self: Self) bool {
return for (self.messages.items) |msg| {
if (msg.kind == .@"error")
break true;
} else false;
}
};
test "diagnostic list" {
const loc = Location{
.chunk = "demo",
.line = 1,
.column = 2,
.offset_end = undefined,
.offset_start = undefined,
};
var diagnostics = Diagnostics.init(std.testing.allocator);
defer diagnostics.deinit();
std.testing.expectEqual(false, diagnostics.hasErrors());
std.testing.expectEqual(@as(usize, 0), diagnostics.messages.items.len);
try diagnostics.emit(.warning, loc, "{}", .{"this is a warning!"});
std.testing.expectEqual(false, diagnostics.hasErrors());
std.testing.expectEqual(@as(usize, 1), diagnostics.messages.items.len);
try diagnostics.emit(.notice, loc, "{}", .{"this is a notice!"});
std.testing.expectEqual(false, diagnostics.hasErrors());
std.testing.expectEqual(@as(usize, 2), diagnostics.messages.items.len);
try diagnostics.emit(.@"error", loc, "{}", .{"this is a error!"});
std.testing.expectEqual(true, diagnostics.hasErrors());
std.testing.expectEqual(@as(usize, 3), diagnostics.messages.items.len);
std.testing.expectEqualStrings("this is a warning!", diagnostics.messages.items[0].message);
std.testing.expectEqualStrings("this is a notice!", diagnostics.messages.items[1].message);
std.testing.expectEqualStrings("this is a error!", diagnostics.messages.items[2].message);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/compiler/scope.zig | const std = @import("std");
const Type = @import("typeset.zig").Type;
const TypeSet = @import("typeset.zig").TypeSet;
/// A scope structure that can be used to manage variable
/// allocation with different scopes (global, local).
pub const Scope = struct {
const Self = @This();
const Variable = struct {
/// This is the offset of the variables
name: []const u8,
storage_slot: u16,
type: enum { local, global },
possible_types: TypeSet = TypeSet.any,
is_const: bool,
};
arena: std.heap.ArenaAllocator,
local_variables: std.ArrayList(Variable),
global_variables: std.ArrayList(Variable),
return_point: std.ArrayList(usize),
/// When this is true, the scope will declare
/// top-level variables as `global`, otherwise as `local`.
is_global: bool,
/// When this is non-null, the scope will use this as a fallback
/// in `get` and will pass the query to this value.
/// Note: It is not allowed that `global_scope` will return a `local` variable then!
global_scope: ?*Self,
/// The highest number of local variables that were declared at a point in this scope.
max_locals: usize = 0,
/// Creates a new scope.
/// `global_scope` is a reference towards a scope that will provide references to a encasing scope.
/// This scope must only provide `global` variables.
pub fn init(allocator: *std.mem.Allocator, global_scope: ?*Self, is_global: bool) Self {
return Self{
.arena = std.heap.ArenaAllocator.init(allocator),
.local_variables = std.ArrayList(Variable).init(allocator),
.global_variables = std.ArrayList(Variable).init(allocator),
.return_point = std.ArrayList(usize).init(allocator),
.is_global = is_global,
.global_scope = global_scope,
};
}
pub fn deinit(self: *Self) void {
self.local_variables.deinit();
self.global_variables.deinit();
self.return_point.deinit();
self.arena.deinit();
self.* = undefined;
}
/// Enters a sub-scope. This is usually called at the start of a block.
/// Sub-scopes are a set of variables that are only valid in a smaller
/// portion of the code.
/// This will push a return point to which later must be returned by
/// calling `leave`.
pub fn enter(self: *Self) !void {
try self.return_point.append(self.local_variables.items.len);
}
/// Leaves a sub-scope. This is usually called at the end of a block.
pub fn leave(self: *Self) !void {
self.local_variables.shrink(self.return_point.pop());
}
/// Declares are new variable.
pub fn declare(self: *Self, name: []const u8, is_const: bool) !void {
if (self.is_global and (self.return_point.items.len == 0)) {
// a variable is only global when the scope is a global scope and
// we don't have any sub-scopes open (which would create temporary variables)
for (self.global_variables.items) |variable| {
if (std.mem.eql(u8, variable.name, name)) {
// Global variables are not allowed to
return error.AlreadyDeclared;
}
}
if (self.global_variables.items.len == std.math.maxInt(u16))
return error.TooManyVariables;
try self.global_variables.append(Variable{
.storage_slot = @intCast(u16, self.global_variables.items.len),
.name = try self.arena.allocator.dupe(u8, name),
.type = .global,
.is_const = is_const,
});
} else {
if (self.local_variables.items.len == std.math.maxInt(u16))
return error.TooManyVariables;
try self.local_variables.append(Variable{
.storage_slot = @intCast(u16, self.local_variables.items.len),
.name = try self.arena.allocator.dupe(u8, name),
.type = .local,
.is_const = is_const,
});
self.max_locals = std.math.max(self.max_locals, self.local_variables.items.len);
}
}
/// Tries to return a variable named `name`. This will first search in the
/// local variables, then in the global ones.
/// Will return `null` when a variable is not found.
pub fn get(self: Self, name: []const u8) ?*Variable {
var i: usize = undefined;
// First, search all local variables back-to-front:
// This allows trivial shadowing as variables will be searched
// in reverse declaration order.
i = self.local_variables.items.len;
while (i > 0) {
i -= 1;
const variable = &self.local_variables.items[i];
if (std.mem.eql(u8, variable.name, name))
return variable;
}
if (self.is_global) {
// The same goes for global variables
i = self.global_variables.items.len;
while (i > 0) {
i -= 1;
const variable = &self.global_variables.items[i];
if (std.mem.eql(u8, variable.name, name))
return variable;
}
}
if (self.global_scope) |globals| {
const global = globals.get(name);
// The global scope is not allowed to supply local variables to us. If this happens,
// a programming error was done.
std.debug.assert(global == null or global.?.type != .local);
return global;
}
return null;
}
};
test "scope init/deinit" {
var scope = Scope.init(std.testing.allocator, null, false);
defer scope.deinit();
}
test "scope declare/get" {
var scope = Scope.init(std.testing.allocator, null, true);
defer scope.deinit();
try scope.declare("foo", true);
std.testing.expectError(error.AlreadyDeclared, scope.declare("foo", true));
try scope.enter();
try scope.declare("bar", true);
std.testing.expect(scope.get("foo").?.type == .global);
std.testing.expect(scope.get("bar").?.type == .local);
std.testing.expect(scope.get("bam") == null);
try scope.leave();
std.testing.expect(scope.get("foo").?.type == .global);
std.testing.expect(scope.get("bar") == null);
std.testing.expect(scope.get("bam") == null);
}
test "variable allocation" {
var scope = Scope.init(std.testing.allocator, null, true);
defer scope.deinit();
try scope.declare("foo", true);
try scope.declare("bar", true);
try scope.declare("bam", true);
std.testing.expect(scope.get("foo").?.storage_slot == 0);
std.testing.expect(scope.get("bar").?.storage_slot == 1);
std.testing.expect(scope.get("bam").?.storage_slot == 2);
try scope.enter();
try scope.declare("foo", true);
try scope.enter();
try scope.declare("bar", true);
try scope.declare("bam", true);
std.testing.expect(scope.get("foo").?.storage_slot == 0);
std.testing.expect(scope.get("bar").?.storage_slot == 1);
std.testing.expect(scope.get("bam").?.storage_slot == 2);
std.testing.expect(scope.get("foo").?.type == .local);
std.testing.expect(scope.get("bar").?.type == .local);
std.testing.expect(scope.get("bam").?.type == .local);
try scope.leave();
std.testing.expect(scope.get("foo").?.type == .local);
std.testing.expect(scope.get("bar").?.type == .global);
std.testing.expect(scope.get("bam").?.type == .global);
try scope.leave();
std.testing.expect(scope.get("foo").?.type == .global);
std.testing.expect(scope.get("bar").?.type == .global);
std.testing.expect(scope.get("bam").?.type == .global);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/compiler/ast.zig | const std = @import("std");
const Location = @import("location.zig").Location;
pub const UnaryOperator = enum {
negate,
boolean_not,
};
pub const BinaryOperator = enum {
add,
subtract,
multiply,
divide,
modulus,
boolean_or,
boolean_and,
less_than,
greater_than,
greater_or_equal_than,
less_or_equal_than,
equal,
different,
};
pub const Expression = struct {
const Self = @This();
pub const Type = @TagType(ExprValue);
/// Starting location of the statement
location: Location,
/// kind of the expression as well as associated child nodes.
/// child expressions memory is stored in the `Program` structure.
type: ExprValue,
/// Returns true when the expression allows an assignment similar to
/// Cs `lvalue`.
pub fn isAssignable(self: Self) bool {
return switch (self.type) {
.array_indexer, .variable_expr => true,
else => false,
};
}
const ExprValue = union(enum) {
array_indexer: struct {
value: *Expression,
index: *Expression,
},
variable_expr: []const u8,
array_literal: []Expression,
function_call: struct {
// this must be a expression of type `variable_expr`
function: *Expression,
arguments: []Expression,
},
method_call: struct {
object: *Expression,
name: []const u8,
arguments: []Expression,
},
number_literal: f64,
string_literal: []const u8,
unary_operator: struct {
operator: UnaryOperator,
value: *Expression,
},
binary_operator: struct {
operator: BinaryOperator,
lhs: *Expression,
rhs: *Expression,
},
};
};
pub const Statement = struct {
const Self = @This();
pub const Type = @TagType(StmtValue);
/// Starting location of the statement
location: Location,
/// kind of the statement as well as associated child nodes.
/// child statements and expressions memory is stored in the
/// `Program` structure.
type: StmtValue,
const StmtValue = union(enum) {
empty: void, // Just a single, flat ';'
/// Top level assignment as in `lvalue = value`.
assignment: struct {
target: Expression,
value: Expression,
},
/// Top-level function call like `Foo()`
discard_value: Expression,
return_void: void,
return_expr: Expression,
while_loop: struct {
condition: Expression,
body: *Statement,
},
for_loop: struct {
variable: []const u8,
source: Expression,
body: *Statement,
},
if_statement: struct {
condition: Expression,
true_body: *Statement,
false_body: ?*Statement,
},
declaration: struct {
variable: []const u8,
initial_value: ?Expression,
is_const: bool,
},
block: []Statement,
@"break": void,
@"continue": void,
};
};
pub const Function = struct {
/// Starting location of the function
location: Location,
name: []const u8,
parameters: [][]const u8,
body: Statement,
};
/// Root node of the abstract syntax tree,
/// contains a whole LoLa file.
pub const Program = struct {
const Self = @This();
/// Arena storing all associated memory with the AST.
/// Each node, string or array is stored here.
arena: std.heap.ArenaAllocator,
/// The sequence of statements that are not contained in functions.
root_script: []Statement,
/// All declared functions in the script.
functions: []Function,
/// Releases all resources associated with this syntax tree.
pub fn deinit(self: *Self) void {
self.arena.deinit();
self.* = undefined;
}
};
pub fn dumpExpression(writer: anytype, expr: Expression) @TypeOf(writer).Error!void {
switch (expr.type) {
.array_indexer => |val| {
try dumpExpression(writer, val.value.*);
try writer.writeAll("[");
try dumpExpression(writer, val.index.*);
try writer.writeAll("]");
},
.variable_expr => |val| try writer.writeAll(val),
.array_literal => |val| {
try writer.writeAll("[ ");
for (val) |item, index| {
if (index > 0) {
try writer.writeAll(", ");
}
try dumpExpression(writer, item);
}
try writer.writeAll("]");
},
.function_call => |val| unreachable,
.method_call => |val| unreachable,
.number_literal => |val| try writer.print("{d}", .{val}),
.string_literal => |val| try writer.print("\"{}\"", .{val}),
.unary_operator => |val| {
try writer.writeAll(switch (val.operator) {
.negate => "-",
.boolean_not => "not",
});
try dumpExpression(writer, val.value.*);
},
.binary_operator => |val| {
try writer.writeAll("(");
try dumpExpression(writer, val.lhs.*);
try writer.writeAll(" ");
try writer.writeAll(switch (val.operator) {
.add => "+",
.subtract => "-",
.multiply => "*",
.divide => "/",
.modulus => "%",
.boolean_or => "or",
.boolean_and => "and",
.less_than => "<",
.greater_than => ">",
.greater_or_equal_than => ">=",
.less_or_equal_than => "<=",
.equal => "==",
.different => "!=",
});
try writer.writeAll(" ");
try dumpExpression(writer, val.rhs.*);
try writer.writeAll(")");
},
}
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/libraries/libs.zig | /// Provides the LoLa standard library.
pub const std = @import("stdlib.zig");
/// Provides the LoLa runtime library.
pub const runtime = @import("runtime.zig");
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/libraries/stdlib.zig | // This file implements the LoLa standard library
const std = @import("std");
const lola = @import("../main.zig");
const whitespace = [_]u8{
0x09, // horizontal tab
0x0A, // line feed
0x0B, // vertical tab
0x0C, // form feed
0x0D, // carriage return
0x20, // space
};
const root = @import("root");
const milliTimestamp = if (std.builtin.os.tag == .freestanding)
if (@hasDecl(root, "milliTimestamp"))
root.milliTimestamp
else
@compileError("Please provide milliTimestamp in the root file for freestanding targets!")
else
std.time.milliTimestamp;
/// Installs the LoLa standard library into the given environment,
/// providing it with a basic set of functions.
/// `allocator` will be used to perform new allocations for the environment.
pub fn install(environment: *lola.runtime.Environment, allocator: *std.mem.Allocator) !void {
// Install all functions from the namespace "functions":
inline for (std.meta.declarations(sync_functions)) |decl| {
try environment.installFunction(decl.name, lola.runtime.Function{
.syncUser = lola.runtime.UserFunction{
.context = lola.runtime.Context.init(std.mem.Allocator, allocator),
.destructor = null,
.call = @field(sync_functions, decl.name),
},
});
}
inline for (std.meta.declarations(async_functions)) |decl| {
try environment.installFunction(decl.name, lola.runtime.Function{
.asyncUser = lola.runtime.AsyncUserFunction{
.context = lola.runtime.Context.init(std.mem.Allocator, allocator),
.destructor = null,
.call = @field(async_functions, decl.name),
},
});
}
}
/// empty compile unit for testing purposes
const empty_compile_unit = lola.CompileUnit{
.arena = std.heap.ArenaAllocator.init(std.testing.failing_allocator),
.comment = "empty compile unit",
.globalCount = 0,
.temporaryCount = 0,
.code = "",
.functions = &[0]lola.CompileUnit.Function{},
.debugSymbols = &[0]lola.CompileUnit.DebugSymbol{},
};
test "stdlib.install" {
var pool = lola.runtime.ObjectPool([_]type{}).init(std.testing.allocator);
defer pool.deinit();
var env = try lola.runtime.Environment.init(std.testing.allocator, &empty_compile_unit, pool.interface());
defer env.deinit();
// TODO: Reinsert this
try install(&env, std.testing.allocator);
}
const async_functions = struct {
fn Sleep(call_context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.AsyncFunctionCall {
const allocator = call_context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
const seconds = try args[0].toNumber();
const Context = struct {
allocator: *std.mem.Allocator,
end_time: f64,
};
const ptr = try allocator.create(Context);
ptr.* = Context{
.allocator = allocator,
.end_time = @intToFloat(f64, milliTimestamp()) + 1000.0 * seconds,
};
return lola.runtime.AsyncFunctionCall{
.context = lola.runtime.Context.init(Context, ptr),
.destructor = struct {
fn dtor(exec_context: lola.runtime.Context) void {
const ctx = exec_context.get(Context);
ctx.allocator.destroy(ctx);
}
}.dtor,
.execute = struct {
fn execute(exec_context: lola.runtime.Context) anyerror!?lola.runtime.Value {
const ctx = exec_context.get(Context);
if (ctx.end_time < @intToFloat(f64, milliTimestamp())) {
return .void;
} else {
return null;
}
}
}.execute,
};
}
fn Yield(call_context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.AsyncFunctionCall {
const allocator = call_context.get(std.mem.Allocator);
if (args.len != 0)
return error.InvalidArgs;
const Context = struct {
allocator: *std.mem.Allocator,
end: bool,
};
const ptr = try allocator.create(Context);
ptr.* = Context{
.allocator = allocator,
.end = false,
};
return lola.runtime.AsyncFunctionCall{
.context = lola.runtime.Context.init(Context, ptr),
.destructor = struct {
fn dtor(exec_context: lola.runtime.Context) void {
const ctx = exec_context.get(Context);
ctx.allocator.destroy(ctx);
}
}.dtor,
.execute = struct {
fn execute(exec_context: lola.runtime.Context) anyerror!?lola.runtime.Value {
const ctx = exec_context.get(Context);
if (ctx.end) {
return .void;
} else {
ctx.end = true;
return null;
}
}
}.execute,
};
}
};
const sync_functions = struct {
fn Length(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
return switch (args[0]) {
.string => |str| lola.runtime.Value.initNumber(@intToFloat(f64, str.contents.len)),
.array => |arr| lola.runtime.Value.initNumber(@intToFloat(f64, arr.contents.len)),
else => error.TypeMismatch,
};
}
fn SubString(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len < 2 or args.len > 3)
return error.InvalidArgs;
if (args[0] != .string)
return error.TypeMismatch;
if (args[1] != .number)
return error.TypeMismatch;
if (args.len == 3 and args[2] != .number)
return error.TypeMismatch;
const str = args[0].string;
const start = try args[1].toInteger(usize);
if (start >= str.contents.len)
return lola.runtime.Value.initString(allocator, "");
const sliced = if (args.len == 3)
str.contents[start..][0..std.math.min(str.contents.len - start, try args[2].toInteger(usize))]
else
str.contents[start..];
return try lola.runtime.Value.initString(allocator, sliced);
}
fn Trim(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
if (args[0] != .string)
return error.TypeMismatch;
const str = args[0].string;
return try lola.runtime.Value.initString(
allocator,
std.mem.trim(u8, str.contents, &whitespace),
);
}
fn TrimLeft(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
if (args[0] != .string)
return error.TypeMismatch;
const str = args[0].string;
return try lola.runtime.Value.initString(
allocator,
std.mem.trimLeft(u8, str.contents, &whitespace),
);
}
fn TrimRight(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
if (args[0] != .string)
return error.TypeMismatch;
const str = args[0].string;
return try lola.runtime.Value.initString(
allocator,
std.mem.trimRight(u8, str.contents, &whitespace),
);
}
fn IndexOf(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 2)
return error.InvalidArgs;
if (args[0] == .string) {
if (args[1] != .string)
return error.TypeMismatch;
const haystack = args[0].string.contents;
const needle = args[1].string.contents;
return if (std.mem.indexOf(u8, haystack, needle)) |index|
lola.runtime.Value.initNumber(@intToFloat(f64, index))
else
.void;
} else if (args[0] == .array) {
const haystack = args[0].array.contents;
for (haystack) |val, i| {
if (val.eql(args[1]))
return lola.runtime.Value.initNumber(@intToFloat(f64, i));
}
return .void;
} else {
return error.TypeMismatch;
}
}
fn LastIndexOf(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 2)
return error.InvalidArgs;
if (args[0] == .string) {
if (args[1] != .string)
return error.TypeMismatch;
const haystack = args[0].string.contents;
const needle = args[1].string.contents;
return if (std.mem.lastIndexOf(u8, haystack, needle)) |index|
lola.runtime.Value.initNumber(@intToFloat(f64, index))
else
.void;
} else if (args[0] == .array) {
const haystack = args[0].array.contents;
var i: usize = haystack.len;
while (i > 0) {
i -= 1;
if (haystack[i].eql(args[1]))
return lola.runtime.Value.initNumber(@intToFloat(f64, i));
}
return .void;
} else {
return error.TypeMismatch;
}
}
fn Byte(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
if (args[0] != .string)
return error.TypeMismatch;
const value = args[0].string.contents;
if (value.len > 0)
return lola.runtime.Value.initNumber(@intToFloat(f64, value[0]))
else
return .void;
}
fn Chr(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
const val = try args[0].toInteger(u8);
return try lola.runtime.Value.initString(
allocator,
&[_]u8{val},
);
}
fn NumToString(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len < 1 or args.len > 2)
return error.InvalidArgs;
var buffer: [256]u8 = undefined;
const slice = if (args.len == 2) blk: {
const base = try args[1].toInteger(u8);
const val = try args[0].toInteger(isize);
const len = std.fmt.formatIntBuf(&buffer, val, base, true, std.fmt.FormatOptions{});
break :blk buffer[0..len];
} else blk: {
var stream = std.io.fixedBufferStream(&buffer);
const val = try args[0].toNumber();
try std.fmt.formatFloatDecimal(val, .{}, stream.writer());
break :blk stream.getWritten();
};
return try lola.runtime.Value.initString(allocator, slice);
}
fn StringToNum(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len < 1 or args.len > 2)
return error.InvalidArgs;
const str = try args[0].toString();
if (args.len == 2) {
const base = try args[1].toInteger(u8);
const text = if (base == 16) blk: {
var tmp = str;
if (std.mem.startsWith(u8, tmp, "0x"))
tmp = tmp[2..];
if (std.mem.endsWith(u8, tmp, "h"))
tmp = tmp[0 .. tmp.len - 1];
break :blk tmp;
} else str;
const val = try std.fmt.parseInt(isize, text, base); // return .void;
return lola.runtime.Value.initNumber(@intToFloat(f64, val));
} else {
const val = std.fmt.parseFloat(f64, str) catch return .void;
return lola.runtime.Value.initNumber(val);
}
}
fn Split(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len < 2 or args.len > 3)
return error.InvalidArgs;
const input = try args[0].toString();
const separator = try args[1].toString();
const removeEmpty = if (args.len == 3) try args[2].toBoolean() else false;
var items = std.ArrayList(lola.runtime.Value).init(allocator);
defer {
for (items.items) |*i| {
i.deinit();
}
items.deinit();
}
var iter = std.mem.split(input, separator);
while (iter.next()) |slice| {
if (!removeEmpty or slice.len > 0) {
var val = try lola.runtime.Value.initString(allocator, slice);
errdefer val.deinit();
try items.append(val);
}
}
return lola.runtime.Value.fromArray(lola.runtime.Array{
.allocator = allocator,
.contents = items.toOwnedSlice(),
});
}
fn Join(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len < 1 or args.len > 2)
return error.InvalidArgs;
const array = try args[0].toArray();
const separator = if (args.len == 2) try args[1].toString() else "";
for (array.contents) |item| {
if (item != .string)
return error.TypeMismatch;
}
var result = std.ArrayList(u8).init(allocator);
defer result.deinit();
for (array.contents) |item, i| {
if (i > 0) {
try result.appendSlice(separator);
}
try result.appendSlice(try item.toString());
}
return lola.runtime.Value.fromString(lola.runtime.String.initFromOwned(
allocator,
result.toOwnedSlice(),
));
}
fn Range(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len < 1 or args.len > 2)
return error.InvalidArgs;
if (args.len == 2) {
const start = try args[0].toInteger(usize);
const length = try args[1].toInteger(usize);
var arr = try lola.runtime.Array.init(allocator, length);
for (arr.contents) |*item, i| {
item.* = lola.runtime.Value.initNumber(@intToFloat(f64, start + i));
}
return lola.runtime.Value.fromArray(arr);
} else {
const length = try args[0].toInteger(usize);
var arr = try lola.runtime.Array.init(allocator, length);
for (arr.contents) |*item, i| {
item.* = lola.runtime.Value.initNumber(@intToFloat(f64, i));
}
return lola.runtime.Value.fromArray(arr);
}
}
fn Slice(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 3)
return error.InvalidArgs;
const array = try args[0].toArray();
const start = try args[1].toInteger(usize);
const length = try args[2].toInteger(usize);
// Out of bounds
if (start >= array.contents.len)
return lola.runtime.Value.fromArray(try lola.runtime.Array.init(allocator, 0));
const actual_length = std.math.min(length, array.contents.len - start);
var arr = try lola.runtime.Array.init(allocator, actual_length);
errdefer arr.deinit();
for (arr.contents) |*item, i| {
item.* = try array.contents[start + i].clone();
}
return lola.runtime.Value.fromArray(arr);
}
fn DeltaEqual(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 3)
return error.InvalidArgs;
const a = try args[0].toNumber();
const b = try args[1].toNumber();
const delta = try args[2].toNumber();
return lola.runtime.Value.initBoolean(std.math.fabs(a - b) < delta);
}
fn Sin(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
return lola.runtime.Value.initNumber(std.math.sin(try args[0].toNumber()));
}
fn Cos(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
return lola.runtime.Value.initNumber(std.math.cos(try args[0].toNumber()));
}
fn Tan(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
return lola.runtime.Value.initNumber(std.math.tan(try args[0].toNumber()));
}
fn Atan(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len == 1) {
return lola.runtime.Value.initNumber(
std.math.atan(try args[0].toNumber()),
);
} else if (args.len == 2) {
return lola.runtime.Value.initNumber(std.math.atan2(
f64,
try args[0].toNumber(),
try args[1].toNumber(),
));
} else {
return error.InvalidArgs;
}
}
fn Sqrt(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
return lola.runtime.Value.initNumber(std.math.sqrt(try args[0].toNumber()));
}
fn Pow(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 2)
return error.InvalidArgs;
return lola.runtime.Value.initNumber(std.math.pow(
f64,
try args[0].toNumber(),
try args[1].toNumber(),
));
}
fn Log(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len == 1) {
return lola.runtime.Value.initNumber(
std.math.log10(try args[0].toNumber()),
);
} else if (args.len == 2) {
return lola.runtime.Value.initNumber(std.math.log(
f64,
try args[1].toNumber(),
try args[0].toNumber(),
));
} else {
return error.InvalidArgs;
}
}
fn Exp(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
return lola.runtime.Value.initNumber(std.math.exp(try args[0].toNumber()));
}
fn Timestamp(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 0)
return error.InvalidArgs;
return lola.runtime.Value.initNumber(@intToFloat(f64, milliTimestamp()) / 1000.0);
}
fn TypeOf(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
return lola.runtime.Value.initString(allocator, switch (args[0]) {
.void => "void",
.boolean => "boolean",
.string => "string",
.number => "number",
.object => "object",
.array => "array",
.enumerator => "enumerator",
});
}
fn ToString(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
var str = try std.fmt.allocPrint(allocator, "{}", .{args[0]});
return lola.runtime.Value.fromString(lola.runtime.String.initFromOwned(allocator, str));
}
fn HasFunction(env: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
switch (args.len) {
1 => {
var name = try args[0].toString();
return lola.runtime.Value.initBoolean(env.functions.get(name) != null);
},
2 => {
var obj = try args[0].toObject();
var name = try args[1].toString();
const maybe_method = try env.objectPool.getMethod(obj, name);
return lola.runtime.Value.initBoolean(maybe_method != null);
},
else => return error.InvalidArgs,
}
}
fn Serialize(env: *lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
const value = args[0];
var string_buffer = std.ArrayList(u8).init(allocator);
defer string_buffer.deinit();
try value.serialize(string_buffer.writer());
return lola.runtime.Value.fromString(lola.runtime.String.initFromOwned(allocator, string_buffer.toOwnedSlice()));
}
fn Deserialize(env: *lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) !lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
const serialized_string = try args[0].toString();
var stream = std.io.fixedBufferStream(serialized_string);
return try lola.runtime.Value.deserialize(stream.reader(), allocator);
}
};
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src/library | repos/Ziguana-Game-System/old-version/libs/lola/src/library/libraries/runtime.zig | // This file implements the LoLa Runtime Library.
const std = @import("std");
const lola = @import("../main.zig");
const root = @import("root");
const GlobalObjectPool = if (std.builtin.is_test)
// we need to do a workaround here for testing purposes
lola.runtime.ObjectPool([_]type{
LoLaList,
LoLaDictionary,
})
else if (@hasDecl(root, "ObjectPool"))
root.ObjectPool
else
@compileError("Please define and use a global ObjectPool type to use the runtime classes.");
comptime {
if (std.builtin.is_test) {
const T = lola.runtime.ObjectPool([_]type{
LoLaList,
LoLaDictionary,
});
if (!T.serializable)
@compileError("Both LoLaList and LoLaDictionary must be serializable!");
}
}
/// Installs the LoLa standard library into the given environment,
/// providing it with a basic set of functions.
/// `allocator` will be used to perform new allocations for the environment.
pub fn install(environment: *lola.runtime.Environment, allocator: *std.mem.Allocator) !void {
// Install all functions from the namespace "functions":
inline for (std.meta.declarations(sync_functions)) |decl| {
try environment.installFunction(decl.name, lola.runtime.Function{
.syncUser = lola.runtime.UserFunction{
.context = lola.runtime.Context.init(std.mem.Allocator, allocator),
.destructor = null,
.call = @field(sync_functions, decl.name),
},
});
}
inline for (std.meta.declarations(async_functions)) |decl| {
try environment.installFunction(decl.name, lola.runtime.Function{
.asyncUser = lola.runtime.AsyncUserFunction{
.context = lola.runtime.Context.init(std.mem.Allocator, allocator),
.destructor = null,
.call = @field(async_functions, decl.name),
},
});
}
}
/// empty compile unit for testing purposes
const empty_compile_unit = lola.CompileUnit{
.arena = std.heap.ArenaAllocator.init(std.testing.failing_allocator),
.comment = "empty compile unit",
.globalCount = 0,
.temporaryCount = 0,
.code = "",
.functions = &[0]lola.CompileUnit.Function{},
.debugSymbols = &[0]lola.CompileUnit.DebugSymbol{},
};
test "runtime.install" {
var pool = GlobalObjectPool.init(std.testing.allocator);
defer pool.deinit();
var env = try lola.runtime.Environment.init(std.testing.allocator, &empty_compile_unit, pool.interface());
defer env.deinit();
try install(&env, std.testing.allocator);
}
const async_functions = struct {
// fn Sleep(call_context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.AsyncFunctionCall {
// const allocator = call_context.get(std.mem.Allocator);
// if (args.len != 1)
// return error.InvalidArgs;
// const seconds = try args[0].toNumber();
// const Context = struct {
// allocator: *std.mem.Allocator,
// end_time: f64,
// };
// const ptr = try allocator.create(Context);
// ptr.* = Context{
// .allocator = allocator,
// .end_time = @intToFloat(f64, std.time.milliTimestamp()) + 1000.0 * seconds,
// };
// return lola.runtime.AsyncFunctionCall{
// .context = lola.runtime.Context.init(Context, ptr),
// .destructor = struct {
// fn dtor(exec_context: lola.runtime.Context) void {
// const ctx = exec_context.get(Context);
// ctx.allocator.destroy(ctx);
// }
// }.dtor,
// .execute = struct {
// fn execute(exec_context: lola.runtime.Context) anyerror!?lola.runtime.Value {
// const ctx = exec_context.get(Context);
// if (ctx.end_time < @intToFloat(f64, std.time.milliTimestamp())) {
// return .void;
// } else {
// return null;
// }
// }
// }.execute,
// };
// }
};
const sync_functions = struct {
fn Print(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
var stdout = std.io.getStdOut().writer();
for (args) |value, i| {
switch (value) {
.string => |str| try stdout.writeAll(str.contents),
else => try stdout.print("{}", .{value}),
}
}
try stdout.writeAll("\n");
return .void;
}
fn Exit(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
if (args.len != 1)
return error.InvalidArgs;
const status = try args[0].toInteger(u8);
std.process.exit(status);
}
fn ReadFile(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
const path = try args[0].toString();
var file = std.fs.cwd().openFile(path, .{ .read = true, .write = false }) catch return .void;
defer file.close();
// 2 GB
var contents = try file.readToEndAlloc(allocator, 2 << 30);
return lola.runtime.Value.fromString(lola.runtime.String.initFromOwned(allocator, contents));
}
fn FileExists(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 1)
return error.InvalidArgs;
const path = try args[0].toString();
var file = std.fs.cwd().openFile(path, .{ .read = true, .write = false }) catch return lola.runtime.Value.initBoolean(false);
file.close();
return lola.runtime.Value.initBoolean(true);
}
fn WriteFile(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 2)
return error.InvalidArgs;
const path = try args[0].toString();
const value = try args[1].toString();
var file = try std.fs.cwd().createFile(path, .{});
defer file.close();
try file.writeAll(value);
return .void;
}
fn CreateList(environment: *lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len > 1)
return error.InvalidArgs;
if (args.len > 0) _ = try args[0].toArray();
const list = try allocator.create(LoLaList);
errdefer allocator.destroy(list);
list.* = LoLaList{
.allocator = allocator,
.data = std.ArrayList(lola.runtime.Value).init(allocator),
};
if (args.len > 0) {
const array = args[0].toArray() catch unreachable;
errdefer list.data.deinit();
try list.data.resize(array.contents.len);
for (list.data.items) |*item| {
item.* = .void;
}
errdefer for (list.data.items) |*item| {
item.deinit();
};
for (list.data.items) |*item, index| {
item.* = try array.contents[index].clone();
}
}
return lola.runtime.Value.initObject(
try environment.objectPool.castTo(GlobalObjectPool).createObject(list),
);
}
fn CreateDictionary(environment: *lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const allocator = context.get(std.mem.Allocator);
if (args.len != 0)
return error.InvalidArgs;
const list = try allocator.create(LoLaDictionary);
errdefer allocator.destroy(list);
list.* = LoLaDictionary{
.allocator = allocator,
.data = std.ArrayList(LoLaDictionary.KV).init(allocator),
};
return lola.runtime.Value.initObject(
try environment.objectPool.castTo(GlobalObjectPool).createObject(list),
);
}
};
pub const LoLaList = struct {
const Self = @This();
allocator: *std.mem.Allocator,
data: std.ArrayList(lola.runtime.Value),
pub fn getMethod(self: *Self, name: []const u8) ?lola.runtime.Function {
inline for (std.meta.declarations(funcs)) |decl| {
if (std.mem.eql(u8, name, decl.name)) {
return lola.runtime.Function{
.syncUser = .{
.context = lola.runtime.Context.init(Self, self),
.call = @field(funcs, decl.name),
.destructor = null,
},
};
}
}
return null;
}
pub fn destroyObject(self: *Self) void {
for (self.data.items) |*item| {
item.deinit();
}
self.data.deinit();
self.allocator.destroy(self);
}
pub fn serializeObject(writer: lola.runtime.OutputStream.Writer, object: *Self) !void {
try writer.writeIntLittle(u32, @intCast(u32, object.data.items.len));
for (object.data.items) |item| {
try item.serialize(writer);
}
}
pub fn deserializeObject(allocator: *std.mem.Allocator, reader: lola.runtime.InputStream.Reader) !*Self {
const item_count = try reader.readIntLittle(u32);
var list = try allocator.create(Self);
list.* = Self{
.allocator = allocator,
.data = std.ArrayList(lola.runtime.Value).init(allocator),
};
errdefer list.destroyObject(); // this will also free memory!
try list.data.resize(item_count);
// sane init to make destroyObject not explode
// (deinit a void value is a no-op)
for (list.data.items) |*item| {
item.* = .void;
}
for (list.data.items) |*item| {
item.* = try lola.runtime.Value.deserialize(reader, allocator);
}
return list;
}
const funcs = struct {
fn Add(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const list = context.get(Self);
if (args.len != 1)
return error.InvalidArgs;
var cloned = try args[0].clone();
errdefer cloned.deinit();
try list.data.append(cloned);
return .void;
}
fn Remove(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const list = context.get(Self);
if (args.len != 1)
return error.InvalidArgs;
const value = args[0];
var src_index: usize = 0;
var dst_index: usize = 0;
while (src_index < list.data.items.len) : (src_index += 1) {
const eql = list.data.items[src_index].eql(value);
if (eql) {
// When the element is equal, we destroy and remove it.
// std.debug.print("deinit {} ({})\n", .{
// src_index,
// list.data.items[src_index],
// });
list.data.items[src_index].deinit();
} else {
// Otherwise, we move the object to the front of the list skipping
// the already removed elements.
// std.debug.print("move {} ({}) → {} ({})\n", .{
// src_index,
// list.data.items[src_index],
// dst_index,
// list.data.items[dst_index],
// });
if (src_index > dst_index) {
list.data.items[dst_index] = list.data.items[src_index];
}
dst_index += 1;
}
}
// note:
// we don't need to deinit() excess values here as we moved them
// above, so they are "twice" in the list.
list.data.shrink(dst_index);
return .void;
}
fn RemoveAt(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const list = context.get(Self);
if (args.len != 1)
return error.InvalidArgs;
const index = try args[0].toInteger(usize);
if (index < list.data.items.len) {
list.data.items[index].deinit();
std.mem.copy(
lola.runtime.Value,
list.data.items[index..],
list.data.items[index + 1 ..],
);
list.data.shrink(list.data.items.len - 1);
}
return .void;
}
fn GetCount(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const list = context.get(Self);
if (args.len != 0)
return error.InvalidArgs;
return lola.runtime.Value.initInteger(usize, list.data.items.len);
}
fn GetItem(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const list = context.get(Self);
if (args.len != 1)
return error.InvalidArgs;
const index = try args[0].toInteger(usize);
if (index >= list.data.items.len)
return error.OutOfRange;
return try list.data.items[index].clone();
}
fn SetItem(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const list = context.get(Self);
if (args.len != 2)
return error.InvalidArgs;
const index = try args[0].toInteger(usize);
if (index >= list.data.items.len)
return error.OutOfRange;
var cloned = try args[1].clone();
list.data.items[index].replaceWith(cloned);
return .void;
}
fn ToArray(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const list = context.get(Self);
if (args.len != 0)
return error.InvalidArgs;
var array = try lola.runtime.Array.init(list.allocator, list.data.items.len);
errdefer array.deinit();
for (array.contents) |*item, index| {
item.* = try list.data.items[index].clone();
}
return lola.runtime.Value.fromArray(array);
}
fn IndexOf(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const list = context.get(Self);
if (args.len != 1)
return error.InvalidArgs;
for (list.data.items) |item, index| {
if (item.eql(args[0]))
return lola.runtime.Value.initInteger(usize, index);
}
return .void;
}
fn Resize(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const list = context.get(Self);
if (args.len != 1)
return error.InvalidArgs;
const new_size = try args[0].toInteger(usize);
const old_size = list.data.items.len;
if (old_size > new_size) {
for (list.data.items[new_size..]) |*item| {
item.deinit();
}
list.data.shrink(new_size);
} else if (new_size > old_size) {
try list.data.resize(new_size);
for (list.data.items[old_size..]) |*item| {
item.* = .void;
}
}
return .void;
}
fn Clear(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const list = context.get(Self);
if (args.len != 0)
return error.InvalidArgs;
for (list.data.items) |*item| {
item.deinit();
}
list.data.shrink(0);
return .void;
}
};
};
pub const LoLaDictionary = struct {
const Self = @This();
const KV = struct {
key: lola.runtime.Value,
value: lola.runtime.Value,
fn deinit(self: *KV) void {
self.key.deinit();
self.value.deinit();
self.* = undefined;
}
};
allocator: *std.mem.Allocator,
data: std.ArrayList(KV),
pub fn getMethod(self: *Self, name: []const u8) ?lola.runtime.Function {
inline for (std.meta.declarations(funcs)) |decl| {
if (std.mem.eql(u8, name, decl.name)) {
return lola.runtime.Function{
.syncUser = .{
.context = lola.runtime.Context.init(Self, self),
.call = @field(funcs, decl.name),
.destructor = null,
},
};
}
}
return null;
}
pub fn destroyObject(self: *Self) void {
for (self.data.items) |*item| {
item.deinit();
}
self.data.deinit();
self.allocator.destroy(self);
}
pub fn serializeObject(writer: lola.runtime.OutputStream.Writer, object: *Self) !void {
try writer.writeIntLittle(u32, @intCast(u32, object.data.items.len));
for (object.data.items) |item| {
try item.key.serialize(writer);
try item.value.serialize(writer);
}
}
pub fn deserializeObject(allocator: *std.mem.Allocator, reader: lola.runtime.InputStream.Reader) !*Self {
const item_count = try reader.readIntLittle(u32);
var list = try allocator.create(Self);
list.* = Self{
.allocator = allocator,
.data = std.ArrayList(KV).init(allocator),
};
errdefer list.destroyObject(); // this will also free memory!
try list.data.resize(item_count);
// sane init to make destroyObject not explode
// (deinit a void value is a no-op)
for (list.data.items) |*item| {
item.* = KV{
.key = .void,
.value = .void,
};
}
for (list.data.items) |*item| {
item.key = try lola.runtime.Value.deserialize(reader, allocator);
item.value = try lola.runtime.Value.deserialize(reader, allocator);
}
return list;
}
const funcs = struct {
fn Set(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const dict = context.get(Self);
if (args.len != 2)
return error.InvalidArgs;
if (args[1] == .void) {
// short-circuit a argument `void` to a call to `Remove(key)`
var result = try Remove(environment, context, args[0..1]);
result.deinit();
return .void;
}
var value = try args[1].clone();
errdefer value.deinit();
for (dict.data.items) |*item| {
if (item.key.eql(args[0])) {
item.value.replaceWith(value);
return .void;
}
}
var key = try args[0].clone();
errdefer key.deinit();
try dict.data.append(KV{
.key = key,
.value = value,
});
return .void;
}
fn Get(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const dict = context.get(Self);
if (args.len != 1)
return error.InvalidArgs;
for (dict.data.items) |item| {
if (item.key.eql(args[0])) {
return try item.value.clone();
}
}
return .void;
}
fn Contains(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const dict = context.get(Self);
if (args.len != 1)
return error.InvalidArgs;
for (dict.data.items) |item| {
if (item.key.eql(args[0])) {
return lola.runtime.Value.initBoolean(true);
}
}
return lola.runtime.Value.initBoolean(false);
}
fn Remove(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const dict = context.get(Self);
if (args.len != 1)
return error.InvalidArgs;
for (dict.data.items) |*item, index| {
if (item.key.eql(args[0])) {
// use a fast swap-remove here
item.deinit();
const last_index = dict.data.items.len - 1;
dict.data.items[index] = dict.data.items[last_index];
dict.data.shrink(last_index);
return lola.runtime.Value.initBoolean(true);
}
}
return lola.runtime.Value.initBoolean(false);
}
fn Clear(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const dict = context.get(Self);
if (args.len != 0)
return error.InvalidArgs;
for (dict.data.items) |*item, index| {
item.deinit();
}
dict.data.shrink(0);
return .void;
}
fn GetCount(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const dict = context.get(Self);
if (args.len != 0)
return error.InvalidArgs;
return lola.runtime.Value.initInteger(usize, dict.data.items.len);
}
fn GetKeys(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const dict = context.get(Self);
if (args.len != 0)
return error.InvalidArgs;
var arr = try lola.runtime.Array.init(dict.allocator, dict.data.items.len);
errdefer arr.deinit();
for (dict.data.items) |item, index| {
arr.contents[index].replaceWith(try item.key.clone());
}
return lola.runtime.Value.fromArray(arr);
}
fn GetValues(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
const dict = context.get(Self);
if (args.len != 0)
return error.InvalidArgs;
var arr = try lola.runtime.Array.init(dict.allocator, dict.data.items.len);
errdefer arr.deinit();
for (dict.data.items) |item, index| {
arr.contents[index].replaceWith(try item.value.clone());
}
return lola.runtime.Value.fromArray(arr);
}
};
};
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src | repos/Ziguana-Game-System/old-version/libs/lola/src/tools/render-md-page.zig | const std = @import("std");
const assert = std.debug.assert;
const koino = @import("koino");
const MenuItem = struct {
input_file_name: []const u8,
output_file_name: []const u8,
header: []const u8,
};
const menu_items = [_]MenuItem{
MenuItem{
.input_file_name = "documentation/README.md",
.output_file_name = "website/docs/language.htm",
.header = "Language Reference",
},
MenuItem{
.input_file_name = "documentation/standard-library.md",
.output_file_name = "website/docs/standard-library.htm",
.header = "Standard Library",
},
MenuItem{
.input_file_name = "documentation/runtime-library.md",
.output_file_name = "website/docs/runtime-library.htm",
.header = "Runtime Library",
},
MenuItem{
.input_file_name = "documentation/ir.md",
.output_file_name = "website/docs/intermediate-language.htm",
.header = "IR",
},
MenuItem{
.input_file_name = "documentation/modules.md",
.output_file_name = "website/docs/module-binary.htm",
.header = "Module Format",
},
};
pub fn main() !u8 {
@setEvalBranchQuota(1500);
var stderr = std.io.getStdErr().writer();
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
var args = std.process.args();
const exe_name = try (args.next(&gpa.allocator) orelse return 1);
gpa.allocator.free(exe_name);
const version_name = if (args.next(&gpa.allocator)) |v|
try v
else
null;
defer if (version_name) |name| {
gpa.allocator.free(name);
};
for (menu_items) |current_file, current_index| {
const options = koino.Options{
.extensions = .{
.table = true,
.autolink = true,
.strikethrough = true,
},
};
var infile = try std.fs.cwd().openFile(current_file.input_file_name, .{});
defer infile.close();
var markdown = try infile.reader().readAllAlloc(&gpa.allocator, 1024 * 1024 * 1024);
defer gpa.allocator.free(markdown);
var output = try markdownToHtml(&gpa.allocator, options, markdown);
defer gpa.allocator.free(output);
var outfile = try std.fs.cwd().createFile(current_file.output_file_name, .{});
defer outfile.close();
try outfile.writeAll(
\\<!DOCTYPE html>
\\<html lang="en">
\\
\\<head>
\\ <meta charset="utf-8">
\\ <meta name="viewport" content="width=device-width, initial-scale=1">
\\ <title>LoLa Documentation</title>
\\ <link rel="icon"
\\ href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAgklEQVR4AWMYWuD7EllJIM4G4g4g5oIJ/odhOJ8wToOxSTXgNxDHoeiBMfA4+wGShjyYOCkG/IGqWQziEzYAoUAeiF9D5U+DxEg14DRU7jWIT5IBIOdCxf+A+CQZAAoopEB7QJwBCBwHiip8UYmRdrAlDpIMgApwQZNnNii5Dq0MBgCxxycBnwEd+wAAAABJRU5ErkJggg==">
\\ <link rel="stylesheet" href="../documentation.css" />
\\</head>
\\
\\<body class="canvas">
\\ <div class="flex-main">
\\ <div class="flex-filler"></div>
\\ <div class="flex-left sidebar">
\\ <nav>
\\ <div class="logo">
\\ <img src="../img/logo.png" />
\\ </div>
\\ <div id="sectPkgs" class="">
\\ <h2><span>Documents</span></h2>
\\ <ul id="listPkgs" class="packages">
);
for (menu_items) |menu, i| {
var is_current = (current_index == i);
var current_class = if (is_current)
@as([]const u8, "class=\"active\"")
else
"";
try outfile.writer().print(
\\<li><a href="{}" {}>{}</a></li>
\\
, .{
std.fs.path.basename(menu.output_file_name),
current_class,
menu.header,
});
}
var version_name_str = @as(?[]const u8, version_name) orelse @as([]const u8, "development");
try outfile.writer().print(
\\ </ul>
\\ </div>
\\ <div id="sectInfo" class="">
\\ <h2><span>LoLa Version</span></h2>
\\ <p class="str" id="tdZigVer">{}</p>
\\ </div>
\\ </nav>
\\ </div>
\\ <div class="flex-right">
\\ <div class="wrap">
\\ <section class="docs">
, .{
version_name_str,
});
try outfile.writer().writeAll(output);
try outfile.writeAll(
\\ </section>
\\ </div>
\\ <div class="flex-filler"></div>
\\ </div>
\\ </div>
\\</body>
\\
\\</html>
\\
);
}
return 0;
}
fn markdownToHtmlInternal(resultAllocator: *std.mem.Allocator, internalAllocator: *std.mem.Allocator, options: koino.Options, markdown: []const u8) ![]u8 {
var p = try koino.parser.Parser.init(internalAllocator, options);
try p.feed(markdown);
var doc = try p.finish();
p.deinit();
defer doc.deinit();
return try koino.html.print(resultAllocator, p.options, doc);
}
pub fn markdownToHtml(allocator: *std.mem.Allocator, options: koino.Options, markdown: []const u8) ![]u8 {
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();
return markdownToHtmlInternal(allocator, &arena.allocator, options, markdown);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/src | repos/Ziguana-Game-System/old-version/libs/lola/src/frontend/main.zig | const std = @import("std");
const lola = @import("lola");
const argsParser = @import("args");
const build_options = @import("build_options");
var gpa_state = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_state.allocator;
// This is our global object pool that is back-referenced
// by the runtime library.
pub const ObjectPool = lola.runtime.ObjectPool([_]type{
lola.libs.runtime.LoLaList,
lola.libs.runtime.LoLaDictionary,
});
pub fn main() !u8 {
defer _ = gpa_state.deinit();
var args = std.process.args();
var argsAllocator = gpa;
const exeName = try (args.next(argsAllocator) orelse {
try std.io.getStdErr().writer().writeAll("Failed to get executable name from the argument list!\n");
return 1;
});
defer argsAllocator.free(exeName);
const module = try (args.next(argsAllocator) orelse {
try print_usage();
return 1;
});
defer argsAllocator.free(module);
if (std.mem.eql(u8, module, "compile")) {
const options = try argsParser.parse(CompileCLI, &args, argsAllocator);
defer options.deinit();
return try compile(options.options, options.positionals);
} else if (std.mem.eql(u8, module, "dump")) {
const options = try argsParser.parse(DisassemblerCLI, &args, argsAllocator);
defer options.deinit();
return try disassemble(options.options, options.positionals);
} else if (std.mem.eql(u8, module, "run")) {
const options = try argsParser.parse(RunCLI, &args, argsAllocator);
defer options.deinit();
return try run(options.options, options.positionals);
} else if (std.mem.eql(u8, module, "help")) {
try print_usage();
return 0;
} else if (std.mem.eql(u8, module, "version")) {
try std.io.getStdOut().writeAll(build_options.version ++ "\n");
return 0;
} else {
try std.io.getStdErr().writer().print(
"Unrecognized command: {}\nSee `lola help` for detailed usage information.\n",
.{
module,
},
);
return 1;
}
return 0;
}
pub fn print_usage() !void {
const usage_msg =
\\Usage: lola [command] [options]
\\
\\Commands:
\\ compile [source] Compiles the given source file into a module.
\\ dump [module] Disassembles the given module.
\\ run [file] Runs the given file. Both modules and source files are allowed.
\\ version Prints version number and exits.
\\
\\General Options:
\\ -o [output file] Defines the output file for the action.
\\
\\Compile Options:
\\ --verify, -v Does not emit the output file, but only runs in-memory checks.
\\ This can be used to do syntax checks of the code.
\\
\\Disassemble Options:
\\ --with-offset, -O Adds offsets to the disassembly.
\\ --with-hexdump, -b Adds the hex dump in the disassembly.
\\ --metadata Dumps information about the module itself.
\\
\\Run Options:
\\ --limit [n] Limits execution to [n] instructions, then halts.
\\ --mode [autodetect|source|module] Determines if run should interpret the file as a source file,
\\ a precompiled module or if it should autodetect the file type.
\\ --no-stdlib Removes the standard library from the environment.
\\ --no-runtime Removes the system runtime from the environment.
\\ --benchmark Runs the script 100 times, measuring the duration of each run and
\\ will print a benchmark result in the end.
\\
;
// \\ -S Intermixes the disassembly with the original source code if possible.
try std.io.getStdErr().writer().writeAll(usage_msg);
}
const DisassemblerCLI = struct {
@"output": ?[]const u8 = null,
@"metadata": bool = false,
@"with-offset": bool = false,
@"with-hexdump": bool = false,
// @"intermix-source": bool = false,
pub const shorthands = .{
// .S = "intermix-source",
.b = "with-hexdump",
.O = "with-offset",
.o = "output",
.m = "metadata",
};
};
fn disassemble(options: DisassemblerCLI, files: []const []const u8) !u8 {
var stream = std.io.getStdOut().writer();
if (files.len == 0) {
try print_usage();
return 1;
}
var logfile: ?std.fs.File = null;
defer if (logfile) |f|
f.close();
if (options.output) |outfile| {
logfile = try std.fs.cwd().createFile(outfile, .{
.read = false,
.truncate = true,
.exclusive = false,
});
stream = logfile.?.writer();
}
for (files) |arg| {
if (files.len != 1) {
try stream.print("Disassembly for {}:\n", .{arg});
}
var arena = std.heap.ArenaAllocator.init(gpa);
defer arena.deinit();
const allocator = &arena.allocator;
var cu = blk: {
var file = try std.fs.cwd().openFile(arg, .{ .read = true, .write = false });
defer file.close();
break :blk try lola.CompileUnit.loadFromStream(allocator, file.reader());
};
defer cu.deinit();
if (options.metadata) {
try stream.writeAll("metadata:\n");
try stream.print("\tcomment: {}\n", .{cu.comment});
try stream.print("\tcode size: {} bytes\n", .{cu.code.len});
try stream.print("\tnum globals: {}\n", .{cu.globalCount});
try stream.print("\tnum temporaries: {}\n", .{cu.temporaryCount});
try stream.print("\tnum functions: {}\n", .{cu.functions.len});
for (cu.functions) |fun| {
try stream.print("\t\tep={X:0>4} lc={: >3} {}\n", .{
fun.entryPoint,
fun.localCount,
fun.name,
});
}
try stream.print("\tnum debug syms: {}\n", .{cu.debugSymbols.len});
try stream.writeAll("disassembly:\n");
}
try lola.disassemble(stream, cu, lola.DisassemblerOptions{
.addressPrefix = options.@"with-offset",
.hexwidth = if (options.@"with-hexdump") 8 else null,
.labelOutput = true,
.instructionOutput = true,
});
}
return 0;
}
const CompileCLI = struct {
@"output": ?[]const u8 = null,
verify: bool = false,
pub const shorthands = .{
.o = "output",
.v = "verify",
};
};
const ModuleBuffer = extern struct {
data: [*]u8,
length: usize,
};
fn compile(options: CompileCLI, files: []const []const u8) !u8 {
if (files.len != 1) {
try print_usage();
return 1;
}
const allocator = gpa;
const inname = files[0];
const outname = if (options.output) |name|
name
else blk: {
var name = try allocator.alloc(u8, inname.len + 3);
std.mem.copy(u8, name[0..inname.len], inname);
std.mem.copy(u8, name[inname.len..], ".lm");
break :blk name;
};
defer if (options.output == null)
allocator.free(outname);
const cu = compileFileToUnit(allocator, inname) catch |err| switch (err) {
error.CompileError => return 1,
else => |e| return e,
};
defer cu.deinit();
if (!options.verify) {
var file = try std.fs.cwd().createFile(outname, .{ .truncate = true, .read = false, .exclusive = false });
defer file.close();
try cu.saveToStream(file.writer());
}
return 0;
}
const RunCLI = struct {
limit: ?u32 = null,
mode: enum { autodetect, source, module } = .autodetect,
@"no-stdlib": bool = false,
@"no-runtime": bool = false,
benchmark: bool = false,
};
fn autoLoadModule(allocator: *std.mem.Allocator, options: RunCLI, file: []const u8) !lola.CompileUnit {
return switch (options.mode) {
.autodetect => loadModuleFromFile(allocator, file) catch |err| if (err == error.InvalidFormat)
try compileFileToUnit(allocator, file)
else
return err,
.module => try loadModuleFromFile(allocator, file),
.source => try compileFileToUnit(allocator, file),
};
}
fn run(options: RunCLI, files: []const []const u8) !u8 {
if (files.len != 1) {
try print_usage();
return 1;
}
const allocator = gpa;
var cu = autoLoadModule(allocator, options, files[0]) catch |err| {
const stderr = std.io.getStdErr().writer();
if (err == error.FileNotFound) {
try stderr.print("Could not find '{}'. Are you sure you passed the right file?\n", .{files[0]});
return 1;
}
try stderr.writeAll(switch (options.mode) {
.autodetect => "Failed to run file: File seems not to be a compiled module or source file!\n",
.module => "Failed to run file: File seems not to be a compiled module.\n",
.source => return 1, // We already have the diagnostic output of the compiler anyways
});
if (err != error.InvalidFormat and err != error.CompileError) {
try stderr.print("The following error happened: {}\n", .{
@errorName(err),
});
}
return 1;
};
defer cu.deinit();
var pool = ObjectPool.init(allocator);
defer pool.deinit();
var env = try lola.runtime.Environment.init(allocator, &cu, pool.interface());
defer env.deinit();
if (!options.@"no-stdlib") {
try lola.libs.std.install(&env, allocator);
}
if (!options.@"no-runtime") {
try lola.libs.runtime.install(&env, allocator);
// Move these two to a test runner
try env.installFunction("Expect", lola.runtime.Function.initSimpleUser(struct {
fn call(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
if (args.len != 1)
return error.InvalidArgs;
const assertion = try args[0].toBoolean();
if (!assertion)
return error.AssertionFailed;
return .void;
}
}.call));
try env.installFunction("ExpectEqual", lola.runtime.Function.initSimpleUser(struct {
fn call(environment: *const lola.runtime.Environment, context: lola.runtime.Context, args: []const lola.runtime.Value) anyerror!lola.runtime.Value {
if (args.len != 2)
return error.InvalidArgs;
if (!args[0].eql(args[1])) {
std.log.err("Expected {}, got {}\n", .{ args[1], args[0] });
return error.AssertionFailed;
}
return .void;
}
}.call));
}
if (options.benchmark == false) {
var vm = try lola.runtime.VM.init(allocator, &env);
defer vm.deinit();
while (true) {
var result = vm.execute(options.limit) catch |err| {
var stderr = std.io.getStdErr().writer();
if (std.builtin.mode == .Debug) {
if (@errorReturnTrace()) |err_trace| {
std.debug.dumpStackTrace(err_trace.*);
} else {
try stderr.print("Panic during execution: {}\n", .{@errorName(err)});
}
} else {
try stderr.print("Panic during execution: {}\n", .{@errorName(err)});
}
try stderr.print("Call stack:\n", .{});
try vm.printStackTrace(stderr);
return 1;
};
pool.clearUsageCounters();
try pool.walkEnvironment(env);
try pool.walkVM(vm);
pool.collectGarbage();
switch (result) {
.completed => return 0,
.exhausted => {
try std.io.getStdErr().writer().print("Execution exhausted after {} instructions!\n", .{
options.limit,
});
return 1;
},
.paused => {
// continue execution here
std.time.sleep(100); // sleep at least 100 ns and return control to scheduler
},
}
}
} else {
var cycle: usize = 0;
var stats = lola.runtime.VM.Statistics{};
var total_time: u64 = 0;
var total_timer = try std.time.Timer.start();
// Run at least one second
while ((cycle < 100) or (total_timer.read() < std.time.ns_per_s)) : (cycle += 1) {
var vm = try lola.runtime.VM.init(allocator, &env);
defer vm.deinit();
var timer = try std.time.Timer.start();
emulation: while (true) {
var result = vm.execute(options.limit) catch |err| {
var stderr = std.io.getStdErr().writer();
try stderr.print("Panic during execution: {}\n", .{@errorName(err)});
try stderr.print("Call stack:\n", .{});
try vm.printStackTrace(stderr);
return 1;
};
pool.clearUsageCounters();
try pool.walkEnvironment(env);
try pool.walkVM(vm);
pool.collectGarbage();
switch (result) {
.completed => break :emulation,
.exhausted => {
try std.io.getStdErr().writer().print("Execution exhausted after {} instructions!\n", .{
options.limit,
});
return 1;
},
.paused => {},
}
}
total_time += timer.lap();
stats.instructions += vm.stats.instructions;
stats.stalls += vm.stats.stalls;
}
try std.io.getStdErr().writer().print(
\\Benchmark result:
\\ Number of runs: {}
\\ Mean time: {d} µs
\\ Mean #instructions: {d}
\\ Mean #stalls: {d}
\\ Mean instruction/s: {d}
\\
, .{
cycle,
(@intToFloat(f64, total_time) / @intToFloat(f64, cycle)) / std.time.ns_per_us,
@intToFloat(f64, stats.instructions) / @intToFloat(f64, cycle),
@intToFloat(f64, stats.stalls) / @intToFloat(f64, cycle),
std.time.ns_per_s * @intToFloat(f64, stats.instructions) / @intToFloat(f64, total_time),
});
}
return 0;
}
fn compileFileToUnit(allocator: *std.mem.Allocator, fileName: []const u8) !lola.CompileUnit {
const maxLength = 1 << 20; // 1 MB
var source = blk: {
var file = try std.fs.cwd().openFile(fileName, .{ .read = true, .write = false });
defer file.close();
break :blk try file.reader().readAllAlloc(gpa, maxLength);
};
defer gpa.free(source);
var diag = lola.compiler.Diagnostics.init(allocator);
defer {
for (diag.messages.items) |msg| {
std.debug.print("{}\n", .{msg});
}
diag.deinit();
}
const seq = try lola.compiler.tokenizer.tokenize(allocator, &diag, fileName, source);
defer allocator.free(seq);
var pgm = try lola.compiler.parser.parse(allocator, &diag, seq);
defer pgm.deinit();
const successful = try lola.compiler.validate(allocator, &diag, pgm);
if (!successful)
return error.CompileError;
var compile_unit = try lola.compiler.generateIR(allocator, pgm, fileName);
errdefer compile_unit;
return compile_unit;
}
fn loadModuleFromFile(allocator: *std.mem.Allocator, fileName: []const u8) !lola.CompileUnit {
var file = try std.fs.cwd().openFile(fileName, .{ .read = true, .write = false });
defer file.close();
return try lola.CompileUnit.loadFromStream(allocator, file.reader());
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/examples/host | repos/Ziguana-Game-System/old-version/libs/lola/examples/host/multi-environment/main.zig | const std = @import("std");
const lola = @import("lola");
////
// Multi-environment communication example:
// In this example, we have three scripts:
// server.lola: Exporting a simple key-value store
// client-a.lola: Writes "Hello, World!" into the store in server
// client-b.lola: Reads the message from the server and prints it
//
// Real world application:
// This shows the inter-environment communication capabilities of LoLa,
// which is useful for games with interactive computer systems that need
// to interact with each other in a user-scriptable way.
//
// Each computer is its own environment, providing a simple script.
// Computers/Environments can communicate via a object interface, exposing
// other computers as a LoLa object and allowing those environments to
// communicate with each other.
//
pub const ObjectPool = lola.runtime.ObjectPool([_]type{
lola.libs.runtime.LoLaDictionary,
lola.libs.runtime.LoLaList,
// Environment is a non-serializable object. If you need to serialize a whole VM state with cross-references,
// provide your own wrapper implementation
lola.runtime.Environment,
});
pub fn main() anyerror!u8 {
var gpa_state = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa_state.deinit();
const allocator = &gpa_state.allocator;
var diagnostics = lola.compiler.Diagnostics.init(allocator);
defer {
for (diagnostics.messages.items) |msg| {
std.debug.print("{}\n", .{msg});
}
diagnostics.deinit();
}
var server_unit = (try lola.compiler.compile(allocator, &diagnostics, "server.lola", @embedFile("server.lola"))) orelse return 1;
defer server_unit.deinit();
var client_a_unit = (try lola.compiler.compile(allocator, &diagnostics, "client-a.lola", @embedFile("client-a.lola"))) orelse return 1;
defer client_a_unit.deinit();
var client_b_unit = (try lola.compiler.compile(allocator, &diagnostics, "client-b.lola", @embedFile("client-b.lola"))) orelse return 1;
defer client_b_unit.deinit();
var pool = ObjectPool.init(allocator);
defer pool.deinit();
var server_env = try lola.runtime.Environment.init(allocator, &server_unit, pool.interface());
defer server_env.deinit();
var client_a_env = try lola.runtime.Environment.init(allocator, &client_a_unit, pool.interface());
defer client_a_env.deinit();
var client_b_env = try lola.runtime.Environment.init(allocator, &client_b_unit, pool.interface());
defer client_b_env.deinit();
for ([_]*lola.runtime.Environment{ &server_env, &client_a_env, &client_b_env }) |env| {
try lola.libs.std.install(env, allocator);
try lola.libs.runtime.install(env, allocator);
}
var server_obj_handle = try pool.createObject(&server_env);
// Important: The environment is stored in the ObjectPool,
// but will be destroyed earlier by us, so we have to remove it
// from the pool before we destroy `server_env`!
defer pool.destroyObject(server_obj_handle);
const getServerFunction = lola.runtime.Function{
.syncUser = .{
.context = lola.runtime.Context.init(lola.runtime.ObjectHandle, &server_obj_handle),
.call = struct {
fn call(
environment: *lola.runtime.Environment,
context: lola.runtime.Context,
args: []const lola.runtime.Value,
) anyerror!lola.runtime.Value {
return lola.runtime.Value.initObject(context.get(lola.runtime.ObjectHandle).*);
}
}.call,
.destructor = null,
},
};
try client_a_env.installFunction("GetServer", getServerFunction);
try client_b_env.installFunction("GetServer", getServerFunction);
// First, initialize the server and let it initialize `storage`.
{
var vm = try lola.runtime.VM.init(allocator, &server_env);
defer vm.deinit();
const result = try vm.execute(null);
if (result != .completed)
return error.CouldNotCompleteCode;
}
// Then, let Client A execute
{
var vm = try lola.runtime.VM.init(allocator, &client_a_env);
defer vm.deinit();
const result = try vm.execute(null);
if (result != .completed)
return error.CouldNotCompleteCode;
}
// Then, let Client B execute
{
var vm = try lola.runtime.VM.init(allocator, &client_b_env);
defer vm.deinit();
const result = try vm.execute(null);
if (result != .completed)
return error.CouldNotCompleteCode;
}
return 0;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/examples/host | repos/Ziguana-Game-System/old-version/libs/lola/examples/host/minimal-host/main.zig | const std = @import("std");
const lola = @import("lola");
////
// Minimal API example:
// This example shows how to get started with the LoLa library.
// Compiles and runs the Hello-World program.
//
const example_source =
\\Print("Hello, World!");
\\
;
// This is required for the runtime library to be able to provide
// object implementations.
pub const ObjectPool = lola.runtime.ObjectPool([_]type{
lola.libs.runtime.LoLaDictionary,
lola.libs.runtime.LoLaList,
});
pub fn main() anyerror!u8 {
var gpa_state = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa_state.deinit();
const allocator = &gpa_state.allocator;
// Step 1: Compile the source code into a compile unit
// This stores the error messages and warnings, we
// just keep it and print all messages on exit (if any).
var diagnostics = lola.compiler.Diagnostics.init(allocator);
defer {
for (diagnostics.messages.items) |msg| {
std.debug.print("{}\n", .{msg});
}
diagnostics.deinit();
}
// This compiles a piece of source code into a compile unit.
// A compile unit is a piece of LoLa IR code with metadata for
// all existing functions, debug symbols and so on. It can be loaded into
// a environment and be executed.
var compile_unit = (try lola.compiler.compile(allocator, &diagnostics, "example_source", example_source)) orelse {
std.debug.print("failed to compile example_source!\n", .{});
return 1;
};
defer compile_unit.deinit();
// A object pool is required for garabge collecting object handles
// stored in several LoLa environments and virtual machines.
var pool = ObjectPool.init(allocator);
defer pool.deinit();
// A environment stores global variables and provides functions
// to the virtual machines. It is also a possible LoLa object that
// can be passed into virtual machines.
var env = try lola.runtime.Environment.init(allocator, &compile_unit, pool.interface());
defer env.deinit();
// Install both standard and runtime library into
// our environment. You can see how to implement custom
// functions if you check out the implementation of both
// libraries!
try lola.libs.std.install(&env, allocator);
try lola.libs.runtime.install(&env, allocator);
// Create a virtual machine that is used to execute LoLa bytecode.
// Using `.init` will always run the top-level code.
var vm = try lola.runtime.VM.init(allocator, &env);
defer vm.deinit();
// The main interpreter loop:
while (true) {
// Run the virtual machine for up to 150 instructions
var result = vm.execute(150) catch |err| {
// When the virtua machine panics, we receive a Zig error
std.debug.print("LoLa panic: {}\n", .{@errorName(err)});
return 1;
};
// Prepare a garbage collection cycle:
pool.clearUsageCounters();
// Mark all objects currently referenced in the environment
try pool.walkEnvironment(env);
// Mark all objects currently referenced in the virtual machine
try pool.walkVM(vm);
// Delete all objects that are not referenced by our system anymore
pool.collectGarbage();
switch (result) {
// This means that our script execution has ended and
// the top-level code has come to an end
.completed => break,
// This means the VM has exhausted its provided instruction quota
// and returned control to the host.
.exhausted => {
std.debug.print("Execution exhausted after 150 instructions!\n", .{});
},
// This means the virtual machine was suspended via a async function call.
.paused => std.time.sleep(100),
}
}
return 0;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/examples/host | repos/Ziguana-Game-System/old-version/libs/lola/examples/host/serialization/main.zig | const std = @import("std");
const lola = @import("lola");
////
// Serialization API example:
// This example shows how to save a whole-program state into a buffer
// and restore that later to continue execution.
//
// NOTE: This example is work-in-progress!
const example_source =
\\for(i in Range(1, 100)) {
\\ Print("Round ", i);
\\}
;
pub const ObjectPool = lola.runtime.ObjectPool([_]type{
lola.libs.runtime.LoLaDictionary,
lola.libs.runtime.LoLaList,
});
// this will store our intermediate data
var serialization_buffer: [4096]u8 = undefined;
pub fn main() anyerror!void {
{
var gpa_state = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa_state.deinit();
try run_serialization(&gpa_state.allocator);
}
{
var gpa_state = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa_state.deinit();
try run_deserialization(&gpa_state.allocator);
}
}
fn run_serialization(allocator: *std.mem.Allocator) !void {
var diagnostics = lola.compiler.Diagnostics.init(allocator);
defer {
for (diagnostics.messages.items) |msg| {
std.debug.print("{}\n", .{msg});
}
diagnostics.deinit();
}
var compile_unit = (try lola.compiler.compile(allocator, &diagnostics, "example_source", example_source)) orelse return error.FailedToCompile;
defer compile_unit.deinit();
var pool = ObjectPool.init(allocator);
defer pool.deinit();
var env = try lola.runtime.Environment.init(allocator, &compile_unit, pool.interface());
defer env.deinit();
try lola.libs.std.install(&env, allocator);
try lola.libs.runtime.install(&env, allocator);
var vm = try lola.runtime.VM.init(allocator, &env);
defer vm.deinit();
var result = try vm.execute(405);
std.debug.assert(result == .exhausted); // we didn't finish running our nice example
var stdout = std.io.getStdOut().writer();
try stdout.writeAll("Suspend at\n");
try vm.printStackTrace(stdout);
{
var stream = std.io.fixedBufferStream(&serialization_buffer);
var writer = stream.writer();
try compile_unit.saveToStream(writer);
// This saves all objects associated with their handles.
// This will only work when all object classes are serializable though.
try pool.serialize(writer);
// this saves all global variables saved in the environment
try env.serialize(writer);
var registry = lola.runtime.EnvironmentMap.init(allocator);
defer registry.deinit();
try registry.add(1234, &env);
// This saves the current virtual machine state
try vm.serialize(®istry, writer);
try stdout.print("saved state to {} bytes!\n", .{
stream.getWritten().len,
});
}
}
fn run_deserialization(allocator: *std.mem.Allocator) !void {
var stream = std.io.fixedBufferStream(&serialization_buffer);
var reader = stream.reader();
// Trivial deserialization:
// Just load the compile unit from disk again
var compile_unit = try lola.CompileUnit.loadFromStream(allocator, reader);
defer compile_unit.deinit();
// This is the reason we need to specialize lola.runtime.ObjectPool() on
// a type list:
// We need a way to do generic deserialization (arbitrary types) and it requires
// a way to get a runtime type-handle and turn it back into a deserialization function.
// this is done by storing the type indices per created object which can then be turned back
// into a real lola.runtime.Object.
var object_pool = try ObjectPool.deserialize(allocator, reader);
defer object_pool.deinit();
// Environments cannot be deserialized directly from a stream:
// Each environment contains function pointers and references its compile unit.
// Both of these things cannot be done by a pure stream serialization.
// Thus, we need to restore the constant part of the environment by hand and
// install all functions as well:
var env = try lola.runtime.Environment.init(allocator, &compile_unit, object_pool.interface());
defer env.deinit();
// Installs the functions back into the environment.
try lola.libs.std.install(&env, allocator);
try lola.libs.runtime.install(&env, allocator);
// This will restore the whole environment state back to how it was at serialization
// time. All globals will be restored here.
try env.deserialize(reader);
// This is needed for deserialization:
// We need means to have a unique Environment <-> ID mapping
// which is persistent over the serialization process.
var registry = lola.runtime.EnvironmentMap.init(allocator);
defer registry.deinit();
// Here we need to add all environments that were previously serialized with
// the same IDs as before.
try registry.add(1234, &env);
// Restore the virtual machine with all function calls.
var vm = try lola.runtime.VM.deserialize(allocator, ®istry, reader);
defer vm.deinit();
var stdout = std.io.getStdOut().writer();
try stdout.print("restored state with {} bytes!\n", .{
stream.getWritten().len,
});
try stdout.writeAll("Resume at\n");
try vm.printStackTrace(stdout);
// let the program finish
_ = try vm.execute(null);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/examples | repos/Ziguana-Game-System/old-version/libs/lola/examples/lola/README.md | # LoLa Examples
- [Hello World](hello-world.lola)
- [Iterative Fibonacci Numbers](fib-iterative.lola)
- [Summing up an array](sum-of-array.lola)
- [Reverse Array](reverse-array.lola)
- [Bubble Sort](bubble-sort.lola)
- [Global Variable Usage](global-setter.lola) |
0 | repos/Ziguana-Game-System/old-version/libs/lola | repos/Ziguana-Game-System/old-version/libs/lola/design/README.md | # LoLa Design
The logo is not licenced under MIT licence!
Do not use this in anywhere without previous agreement with Felix Queißner ([email protected])!
Logo design by [www.artbyluphalia.com](www.artbyluphalia.com). Give her a visit!
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs | repos/Ziguana-Game-System/old-version/libs/lola/libs/interface.zig/interface.zig | const std = @import("std");
const mem = std.mem;
const trait = std.meta.trait;
const assert = std.debug.assert;
const expect = std.testing.expect;
const expectEqual = std.testing.expectEqual;
pub const SelfType = @Type(.Opaque);
fn makeSelfPtr(ptr: anytype) *SelfType {
if (comptime !trait.isSingleItemPtr(@TypeOf(ptr))) {
@compileError("SelfType pointer initialization expects pointer parameter.");
}
const T = std.meta.Child(@TypeOf(ptr));
if (@sizeOf(T) > 0) {
return @ptrCast(*SelfType, ptr);
} else {
return undefined;
}
}
fn selfPtrAs(self: *SelfType, comptime T: type) *T {
if (@sizeOf(T) > 0) {
return @alignCast(@alignOf(T), @ptrCast(*align(1) T, self));
} else {
return undefined;
}
}
fn constSelfPtrAs(self: *const SelfType, comptime T: type) *const T {
if (@sizeOf(T) > 0) {
return @alignCast(@alignOf(T), @ptrCast(*align(1) const T, self));
} else {
return undefined;
}
}
pub const Storage = struct {
pub const Comptime = struct {
erased_ptr: *SelfType,
ImplType: type,
fn makeInit(comptime TInterface: type) type {
return struct {
fn init(obj: anytype) !TInterface {
const ImplType = PtrChildOrSelf(@TypeOf(obj));
comptime var obj_holder = obj;
return TInterface{
.vtable_ptr = &comptime makeVTable(TInterface.VTable, ImplType),
.storage = Comptime{
.erased_ptr = makeSelfPtr(&obj_holder),
.ImplType = @TypeOf(obj),
},
};
}
};
}
pub fn getSelfPtr(comptime self: *Comptime) *SelfType {
return self.erased_ptr;
}
pub fn deinit(comptime self: Comptime) void {}
};
pub const NonOwning = struct {
erased_ptr: *SelfType,
fn makeInit(comptime TInterface: type) type {
return struct {
fn init(ptr: anytype) !TInterface {
return TInterface{
.vtable_ptr = &comptime makeVTable(TInterface.VTable, PtrChildOrSelf(@TypeOf(ptr))),
.storage = NonOwning{
.erased_ptr = makeSelfPtr(ptr),
},
};
}
};
}
pub fn getSelfPtr(self: NonOwning) *SelfType {
return self.erased_ptr;
}
pub fn deinit(self: NonOwning) void {}
};
pub const Owning = struct {
allocator: *mem.Allocator,
mem: []u8,
fn makeInit(comptime TInterface: type) type {
return struct {
fn init(obj: anytype, allocator: *std.mem.Allocator) !TInterface {
const AllocT = @TypeOf(obj);
var ptr = try allocator.create(AllocT);
ptr.* = obj;
return TInterface{
.vtable_ptr = &comptime makeVTable(TInterface.VTable, PtrChildOrSelf(AllocT)),
.storage = Owning{
.allocator = allocator,
.mem = std.mem.asBytes(ptr)[0..],
},
};
}
};
}
pub fn getSelfPtr(self: Owning) *SelfType {
return makeSelfPtr(&self.mem[0]);
}
pub fn deinit(self: Owning) void {
const result = self.allocator.shrinkBytes(self.mem, 0, 0, 0, 0);
assert(result == 0);
}
};
pub fn Inline(comptime size: usize) type {
return struct {
const Self = @This();
mem: [size]u8,
fn makeInit(comptime TInterface: type) type {
return struct {
fn init(value: anytype) !TInterface {
const ImplSize = @sizeOf(@TypeOf(value));
if (ImplSize > size) {
@compileError("Type does not fit in inline storage.");
}
var self = Self{
.mem = undefined,
};
if (ImplSize > 0) {
std.mem.copy(u8, self.mem[0..], @ptrCast([*]const u8, &args[0])[0..ImplSize]);
}
return TInterface{
.vtable_ptr = &comptime makeVTable(TInterface.VTable, PtrChildOrSelf(@TypeOf(value))),
.storage = self,
};
}
};
}
pub fn getSelfPtr(self: *Self) *SelfType {
return makeSelfPtr(&self.mem[0]);
}
pub fn deinit(self: Self) void {}
};
}
pub fn InlineOrOwning(comptime size: usize) type {
return struct {
const Self = @This();
data: union(enum) {
Inline: Inline(size),
Owning: Owning,
},
pub fn init(args: anytype) !Self {
if (args.len != 2) {
@compileError("InlineOrOwning storage expected a 2-tuple in initialization.");
}
const ImplSize = @sizeOf(@TypeOf(args[0]));
if (ImplSize > size) {
return Self{
.data = .{
.Owning = try Owning.init(args),
},
};
} else {
return Self{
.data = .{
.Inline = try Inline(size).init(.{args[0]}),
},
};
}
}
pub fn getSelfPtr(self: *Self) *SelfType {
return switch (self.data) {
.Inline => |*i| i.getSelfPtr(),
.Owning => |*o| o.getSelfPtr(),
};
}
pub fn deinit(self: Self) void {
switch (self.data) {
.Inline => |i| i.deinit(),
.Owning => |o| o.deinit(),
}
}
};
}
};
fn PtrChildOrSelf(comptime T: type) type {
if (comptime trait.isSingleItemPtr(T)) {
return std.meta.Child(T);
}
return T;
}
const GenCallType = enum {
BothAsync,
BothBlocking,
AsyncCallsBlocking,
BlockingCallsAsync,
};
fn makeCall(
comptime name: []const u8,
comptime CurrSelfType: type,
comptime Return: type,
comptime ImplT: type,
comptime call_type: GenCallType,
self_ptr: CurrSelfType,
args: anytype,
) Return {
const is_const = CurrSelfType == *const SelfType;
const self = if (is_const) constSelfPtrAs(self_ptr, ImplT) else selfPtrAs(self_ptr, ImplT);
const fptr = @field(ImplT, name);
const first_arg_ptr = comptime std.meta.trait.is(.Pointer)(@typeInfo(@TypeOf(fptr)).Fn.args[0].arg_type.?);
const self_arg = if (first_arg_ptr) .{self} else .{self.*};
return switch (call_type) {
.BothBlocking => @call(.{ .modifier = .always_inline }, fptr, self_arg ++ args),
.AsyncCallsBlocking, .BothAsync => await @call(.{ .modifier = .async_kw }, fptr, self_arg ++ args),
.BlockingCallsAsync => @compileError("Trying to implement blocking virtual function " ++ name ++ " with async implementation."),
};
}
fn getFunctionFromImpl(comptime name: []const u8, comptime FnT: type, comptime ImplT: type) ?FnT {
const our_cc = @typeInfo(FnT).Fn.calling_convention;
// Find the candidate in the implementation type.
for (std.meta.declarations(ImplT)) |decl| {
if (std.mem.eql(u8, name, decl.name)) {
switch (decl.data) {
.Fn => |fn_decl| {
const args = @typeInfo(fn_decl.fn_type).Fn.args;
if (args.len == 0) {
return @field(ImplT, name);
}
if (args.len > 0) {
const arg0_type = args[0].arg_type.?;
const is_method = arg0_type == ImplT or arg0_type == *ImplT or arg0_type == *const ImplT;
const candidate_cc = @typeInfo(fn_decl.fn_type).Fn.calling_convention;
switch (candidate_cc) {
.Async, .Unspecified => {},
else => return null,
}
const Return = @typeInfo(FnT).Fn.return_type orelse noreturn;
const CurrSelfType = @typeInfo(FnT).Fn.args[0].arg_type.?;
const call_type: GenCallType = switch (our_cc) {
.Async => if (candidate_cc == .Async) .BothAsync else .AsyncCallsBlocking,
.Unspecified => if (candidate_cc == .Unspecified) .BothBlocking else .BlockingCallsAsync,
else => unreachable,
};
if (!is_method) {
return @field(ImplT, name);
}
// TODO: Make this less hacky somehow?
// We need some new feature to do so unfortunately.
return switch (args.len) {
1 => struct {
fn impl(self_ptr: CurrSelfType) callconv(our_cc) Return {
return @call(.{ .modifier = .always_inline }, makeCall, .{ name, CurrSelfType, Return, ImplT, call_type, self_ptr, .{} });
}
}.impl,
2 => struct {
fn impl(self_ptr: CurrSelfType, arg: args[1].arg_type.?) callconv(our_cc) Return {
return @call(.{ .modifier = .always_inline }, makeCall, .{ name, CurrSelfType, Return, ImplT, call_type, self_ptr, .{arg} });
}
}.impl,
3 => struct {
fn impl(self_ptr: CurrSelfType, arg1: args[1].arg_type.?, arg2: args[2].arg_type.?) callconv(our_cc) Return {
return @call(.{ .modifier = .always_inline }, makeCall, .{ name, CurrSelfType, Return, ImplT, call_type, self_ptr, .{ arg1, arg2 } });
}
}.impl,
4 => struct {
fn impl(self_ptr: CurrSelfType, arg1: args[1].arg_type.?, arg2: args[2].arg_type.?, arg3: args[3].arg_type.?) callconv(our_cc) Return {
return @call(.{ .modifier = .always_inline }, makeCall, .{ name, CurrSelfType, Return, ImplT, call_type, self_ptr, .{ arg1, arg2, arg3 } });
}
}.impl,
5 => struct {
fn impl(self_ptr: CurrSelfType, arg1: args[1].arg_type.?, arg2: args[2].arg_type.?, arg3: args[3].arg_type.?, arg4: args[4].arg_type.?) callconv(our_cc) Return {
return @call(.{ .modifier = .always_inline }, makeCall, .{ name, CurrSelfType, Return, ImplT, call_type, self_ptr, .{ arg1, arg2, arg3, arg4 } });
}
}.impl,
6 => struct {
fn impl(self_ptr: CurrSelfType, arg1: args[1].arg_type.?, arg2: args[2].arg_type.?, arg3: args[3].arg_type.?, arg4: args[4].arg_type.?, arg5: args[5].arg_type.?) callconv(our_cc) Return {
return @call(.{ .modifier = .always_inline }, makeCall, .{ name, CurrSelfType, Return, ImplT, call_type, self_ptr, .{ arg1, arg2, arg3, arg4, arg5 } });
}
}.impl,
else => @compileError("Unsupported number of arguments, please provide a manually written vtable."),
};
}
},
else => return null,
}
}
}
return null;
}
fn makeVTable(comptime VTableT: type, comptime ImplT: type) VTableT {
if (comptime !trait.isContainer(ImplT)) {
@compileError("Type '" ++ @typeName(ImplT) ++ "' must be a container to implement interface.");
}
var vtable: VTableT = undefined;
for (std.meta.fields(VTableT)) |field| {
var fn_type = field.field_type;
const is_optional = trait.is(.Optional)(fn_type);
if (is_optional) {
fn_type = std.meta.Child(fn_type);
}
const candidate = comptime getFunctionFromImpl(field.name, fn_type, ImplT);
if (candidate == null and !is_optional) {
@compileError("Type '" ++ @typeName(ImplT) ++ "' does not implement non optional function '" ++ field.name ++ "'.");
} else if (!is_optional) {
@field(vtable, field.name) = candidate.?;
} else {
@field(vtable, field.name) = candidate;
}
}
return vtable;
}
fn checkVtableType(comptime VTableT: type) void {
if (comptime !trait.is(.Struct)(VTableT)) {
@compileError("VTable type " ++ @typeName(VTableT) ++ " must be a struct.");
}
for (std.meta.declarations(VTableT)) |decl| {
switch (decl.data) {
.Fn => @compileError("VTable type defines method '" ++ decl.name ++ "'."),
.Type, .Var => {},
}
}
for (std.meta.fields(VTableT)) |field| {
var field_type = field.field_type;
if (trait.is(.Optional)(field_type)) {
field_type = std.meta.Child(field_type);
}
if (!trait.is(.Fn)(field_type)) {
@compileError("VTable type defines non function field '" ++ field.name ++ "'.");
}
const type_info = @typeInfo(field_type);
if (type_info.Fn.is_generic) {
@compileError("Virtual function '" ++ field.name ++ "' cannot be generic.");
}
switch (type_info.Fn.calling_convention) {
.Unspecified, .Async => {},
else => @compileError("Virtual function's '" ++ field.name ++ "' calling convention is not default or async."),
}
}
}
fn vtableHasMethod(comptime VTableT: type, comptime name: []const u8, is_optional: *bool, is_async: *bool, is_method: *bool) bool {
for (std.meta.fields(VTableT)) |field| {
if (std.mem.eql(u8, name, field.name)) {
is_optional.* = trait.is(.Optional)(field.field_type);
const fn_typeinfo = @typeInfo(if (is_optional.*) std.meta.Child(field.field_type) else field.field_type).Fn;
is_async.* = fn_typeinfo.calling_convention == .Async;
is_method.* = fn_typeinfo.args.len > 0 and blk: {
const first_arg_type = fn_typeinfo.args[0].arg_type.?;
break :blk first_arg_type == *SelfType or first_arg_type == *const SelfType;
};
return true;
}
}
return false;
}
fn VTableReturnType(comptime VTableT: type, comptime name: []const u8) type {
for (std.meta.fields(VTableT)) |field| {
if (std.mem.eql(u8, name, field.name)) {
const is_optional = trait.is(.Optional)(field.field_type);
var fn_ret_type = (if (is_optional)
@typeInfo(std.meta.Child(field.field_type)).Fn.return_type
else
@typeInfo(field.field_type).Fn.return_type) orelse noreturn;
if (is_optional) {
return ?fn_ret_type;
}
return fn_ret_type;
}
}
@compileError("VTable type '" ++ @typeName(VTableT) ++ "' has no virtual function '" ++ name ++ "'.");
}
pub fn Interface(comptime VTableT: type, comptime StorageT: type) type {
comptime checkVtableType(VTableT);
const stack_size: usize = if (@hasDecl(VTableT, "async_call_stack_size"))
VTableT.async_call_stack_size
else
1 * 1024 * 1024;
return struct {
vtable_ptr: *const VTableT,
storage: StorageT,
const Self = @This();
const VTable = VTableT;
const Storage = StorageT;
pub const init = StorageT.makeInit(Self).init;
pub fn initWithVTable(vtable_ptr: *const VTableT, args: anytype) !Self {
return .{
.vtable_ptr = vtable_ptr,
.storage = try init(args),
};
}
pub fn call(self: anytype, comptime name: []const u8, args: anytype) VTableReturnType(VTableT, name) {
comptime var is_optional = true;
comptime var is_async = true;
comptime var is_method = true;
comptime assert(vtableHasMethod(VTableT, name, &is_optional, &is_async, &is_method));
const fn_ptr = if (is_optional) blk: {
const val = @field(self.vtable_ptr, name);
if (val) |v| break :blk v;
return null;
} else @field(self.vtable_ptr, name);
if (is_method) {
const self_ptr = self.storage.getSelfPtr();
const new_args = .{self_ptr};
if (!is_async) {
return @call(.{}, fn_ptr, new_args ++ args);
} else {
var stack_frame: [stack_size]u8 align(std.Target.stack_align) = undefined;
return await @asyncCall(&stack_frame, {}, fn_ptr, new_args ++ args);
}
} else {
if (!is_async) {
return @call(.{}, fn_ptr, args);
} else {
var stack_frame: [stack_size]u8 align(std.Target.stack_align) = undefined;
return await @asyncCall(&stack_frame, {}, fn_ptr, args);
}
}
}
pub fn deinit(self: Self) void {
self.storage.deinit();
}
};
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs | repos/Ziguana-Game-System/old-version/libs/lola/libs/interface.zig/examples.zig | const interface = @import("interface.zig");
const Interface = interface.Interface;
const SelfType = interface.SelfType;
const std = @import("std");
const mem = std.mem;
const expectEqual = std.testing.expectEqual;
const assert = std.debug.assert;
test "Simple NonOwning interface" {
const NonOwningTest = struct {
fn run() !void {
const Fooer = Interface(struct {
foo: fn (*SelfType) usize,
}, interface.Storage.NonOwning);
const TestFooer = struct {
const Self = @This();
state: usize,
pub fn foo(self: *Self) usize {
const tmp = self.state;
self.state += 1;
return tmp;
}
};
var f = TestFooer{ .state = 42 };
var fooer = try Fooer.init(&f);
defer fooer.deinit();
expectEqual(@as(usize, 42), fooer.call("foo", .{}));
expectEqual(@as(usize, 43), fooer.call("foo", .{}));
}
};
try NonOwningTest.run();
comptime try NonOwningTest.run();
}
test "Comptime only interface" {
// return error.SkipZigTest;
const TestIFace = Interface(struct {
foo: fn (*SelfType, u8) u8,
}, interface.Storage.Comptime);
const TestType = struct {
const Self = @This();
state: u8,
pub fn foo(self: Self, a: u8) u8 {
return self.state + a;
}
};
comptime var iface = try TestIFace.init(TestType{ .state = 0 });
expectEqual(@as(u8, 42), iface.call("foo", .{42}));
}
test "Owning interface with optional function and a non-method function" {
const OwningOptionalFuncTest = struct {
fn run() !void {
const TestOwningIface = Interface(struct {
someFn: ?fn (*const SelfType, usize, usize) usize,
otherFn: fn (*SelfType, usize) anyerror!void,
thirdFn: fn(usize) usize,
}, interface.Storage.Owning);
const TestStruct = struct {
const Self = @This();
state: usize,
pub fn someFn(self: Self, a: usize, b: usize) usize {
return self.state * a + b;
}
// Note that our return type need only coerce to the virtual function's
// return type.
pub fn otherFn(self: *Self, new_state: usize) void {
self.state = new_state;
}
pub fn thirdFn(arg: usize) usize {
return arg + 1;
}
};
var iface_instance = try TestOwningIface.init(comptime TestStruct{ .state = 0 }, std.testing.allocator);
defer iface_instance.deinit();
try iface_instance.call("otherFn", .{100});
expectEqual(@as(usize, 42), iface_instance.call("someFn", .{ 0, 42 }).?);
expectEqual(@as(usize, 101), iface_instance.call("thirdFn", .{ 100 }));
}
};
try OwningOptionalFuncTest.run();
}
test "Interface with virtual async function implemented by an async function" {
const AsyncIFace = Interface(struct {
const async_call_stack_size = 1024;
foo: fn (*SelfType) callconv(.Async) void,
}, interface.Storage.NonOwning);
const Impl = struct {
const Self = @This();
state: usize,
frame: anyframe = undefined,
pub fn foo(self: *Self) void {
suspend {
self.frame = @frame();
}
self.state += 1;
suspend;
self.state += 1;
}
};
var i = Impl{ .state = 0 };
var instance = try AsyncIFace.init(&i);
_ = async instance.call("foo", .{});
expectEqual(@as(usize, 0), i.state);
resume i.frame;
expectEqual(@as(usize, 1), i.state);
resume i.frame;
expectEqual(@as(usize, 2), i.state);
}
test "Interface with virtual async function implemented by a blocking function" {
const AsyncIFace = Interface(struct {
readBytes: fn (*SelfType, []u8) callconv(.Async) anyerror!void,
}, interface.Storage.Inline(8));
const Impl = struct {
const Self = @This();
pub fn readBytes(self: Self, outBuf: []u8) void {
for (outBuf) |*c| {
c.* = 3;
}
}
};
var instance = try AsyncIFace.init(Impl{});
var buf: [256]u8 = undefined;
try await async instance.call("readBytes", .{buf[0..]});
expectEqual([_]u8{3} ** 256, buf);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs | repos/Ziguana-Game-System/old-version/libs/lola/libs/interface.zig/README.md | # Zig Interfaces
Easy solution for all your zig dynamic dispatch needs!
## Features
- Fully decoupled interfaces and implementations
- Control over the storage/ownership of interface objects
- Comptime support (including comptime-only interfaces)
- Async function partial support (blocking on [#4621](https://github.com/ziglang/zig/issues/4621))
- Optional function support
- Support for manually written vtables
## Example
```zig
const interface = @import("interface.zig");
const Interface = interface.Interface;
const SelfType = interface.SelfType;
// Let us create a Reader interface.
// We wrap it in our own struct to make function calls more natural.
const Reader = struct {
pub const ReadError = error { CouldNotRead };
const IFace = Interface(struct {
// Our interface requires a single non optional, non-const read function.
read: fn (*SelfType, buf: []u8) ReadError!usize,
}, interface.Storage.NonOwning); // This is a non owning interface, similar to Rust dyn traits.
iface: IFace,
// Wrap the interface's init, since the interface is non owning it requires no allocator argument.
pub fn init(impl_ptr: var) Reader {
return .{ .iface = try IFace.init(.{impl_ptr}) };
}
// Wrap the read function call
pub fn read(self: *Reader, buf: []u8) ReadError!usize {
return self.iface.call("read", .{buf});
}
// Define additional, non-dynamic functions!
pub fn readAll(self: *Self, buf: []u8) ReadError!usize {
var index: usize = 0;
while (index != buf.len) {
const partial_amt = try self.read(buffer[index..]);
if (partial_amt == 0) return index;
index += partial_amt;
}
return index;
}
};
// Let's create an example reader
const ExampleReader = struct {
state: u8,
// Note that this reader cannot return an error, the return type
// of our implementation functions only needs to coerce to the
// interface's function return type.
pub fn read(self: ExampleReader, buf: []u8) usize {
for (buf) |*c| {
c.* = self.state;
}
return buf.len;
}
};
test "Use our reader interface!" {
var example_reader = ExampleReader{ .state=42 };
var reader = Reader.init(&example_reader);
var buf: [100]u8 = undefined;
_ = reader.read(&buf) catch unreachable;
}
```
See examples.zig for more examples.
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs | repos/Ziguana-Game-System/old-version/libs/lola/libs/args/demo.zig | const std = @import("std");
const argsParser = @import("args.zig");
pub fn main() !void {
var argsAllocator = std.heap.page_allocator;
const options = try argsParser.parseForCurrentProcess(struct {
// This declares long options for double hyphen
output: ?[]const u8 = null,
@"with-offset": bool = false,
@"with-hexdump": bool = false,
@"intermix-source": bool = false,
numberOfBytes: ?i32 = null,
mode: enum { default, special, slow, fast } = .default,
// This declares short-hand options for single hyphen
pub const shorthands = .{
.S = "intermix-source",
.b = "with-hexdump",
.O = "with-offset",
.o = "output",
};
}, argsAllocator);
defer options.deinit();
std.debug.print("executable name: {}\n", .{options.executable_name});
std.debug.print("parsed options:\n", .{});
inline for (std.meta.fields(@TypeOf(options.options))) |fld| {
std.debug.print("\t{} = {}\n", .{
fld.name,
@field(options.options, fld.name),
});
}
std.debug.print("parsed positionals:\n", .{});
for (options.positionals) |arg| {
std.debug.print("\t'{}'\n", .{arg});
}
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs | repos/Ziguana-Game-System/old-version/libs/lola/libs/args/README.md | # Zig Argument Parser
Simple-to-use argument parser with struct-based config
## Features
- Automatic option generation from a config struct
- Familiar *look & feel*:
- Everything after the first `--` is assumed to be a positional argument
- A single `-` is interpreted as a positional argument which can be used as the stdin/stdout file placeholder
- Short options with no argument can be combined into a single argument: `-dfe`
- Long options can use either `--option=value` or `--option value` syntax
- Integrated support for primitive types:
- All integer types (signed & unsigned)
- Floating point types
- Booleans (takes optional argument. If no argument given, the bool is set, otherwise, one of `yes`, `true`, `y`, `no`, `false`, `n` is interpreted)
- Strings
- Enumerations
## Example
```zig
const options = try argsParser.parse(struct {
// This declares long options for double hyphen
output: ?[]const u8 = null,
@"with-offset": bool = false,
@"with-hexdump": bool = false,
@"intermix-source": bool = false,
numberOfBytes: ?i32 = null,
// This declares short-hand options for single hyphen
pub const shorthands = .{
.S = "intermix-source",
.b = "with-hexdump",
.O = "with-offset",
.o = "output",
};
}, &args, argsAllocator);
defer options.deinit();
std.debug.warn("parsed result:\n{}\npositionals:\n", .{options.options});
for (options.positionals) |arg| {
std.debug.warn("\t{}\n", .{arg});
}
```
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs | repos/Ziguana-Game-System/old-version/libs/lola/libs/args/args.zig | const std = @import("std");
/// Parses arguments for the given specification and our current process.
/// - `Spec` is the configuration of the arguments.
/// - `allocator` is the allocator that is used to allocate all required memory
pub fn parseForCurrentProcess(comptime Spec: type, allocator: *std.mem.Allocator) !ParseArgsResult(Spec) {
var args = std.process.args();
const executable_name = try (args.next(allocator) orelse {
try std.io.getStdErr().writer().writeAll("Failed to get executable name from the argument list!\n");
return error.NoExecutableName;
});
errdefer allocator.free(executable_name);
var result = try parse(Spec, &args, allocator);
result.executable_name = executable_name;
return result;
}
/// Parses arguments for the given specification.
/// - `Spec` is the configuration of the arguments.
/// - `args` is an ArgIterator that will yield the command line arguments.
/// - `allocator` is the allocator that is used to allocate all required memory
///
/// Note that `.executable_name` in the result will not be set!
pub fn parse(comptime Spec: type, args: *std.process.ArgIterator, allocator: *std.mem.Allocator) !ParseArgsResult(Spec) {
var result = ParseArgsResult(Spec){
.arena = std.heap.ArenaAllocator.init(allocator),
.options = Spec{},
.positionals = undefined,
.executable_name = null,
};
errdefer result.arena.deinit();
var arglist = std.ArrayList([]const u8).init(allocator);
errdefer arglist.deinit();
while (args.next(&result.arena.allocator)) |item_or_error| {
const item = try item_or_error;
if (std.mem.startsWith(u8, item, "--")) {
if (std.mem.eql(u8, item, "--")) {
// double hyphen is considered 'everything from here now is positional'
break;
}
const Pair = struct {
name: []const u8,
value: ?[]const u8,
};
const pair = if (std.mem.indexOf(u8, item, "=")) |index|
Pair{
.name = item[2..index],
.value = item[index + 1 ..],
}
else
Pair{
.name = item[2..],
.value = null,
};
var found = false;
inline for (std.meta.fields(Spec)) |fld| {
if (std.mem.eql(u8, pair.name, fld.name)) {
try parseOption(Spec, &result, args, fld.name, pair.value);
found = true;
}
}
if (!found) {
try std.io.getStdErr().writer().print("Unknown command line option: {}\n", .{pair.name});
return error.EncounteredUnknownArgument;
}
} else if (std.mem.startsWith(u8, item, "-")) {
if (std.mem.eql(u8, item, "-")) {
// single hyphen is considered a positional argument
try arglist.append(item);
} else {
if (@hasDecl(Spec, "shorthands")) {
for (item[1..]) |char, index| {
var found = false;
inline for (std.meta.fields(@TypeOf(Spec.shorthands))) |fld| {
if (fld.name.len != 1)
@compileError("All shorthand fields must be exactly one character long!");
if (fld.name[0] == char) {
const real_fld = std.meta.fieldInfo(Spec, @field(Spec.shorthands, fld.name));
// -2 because we stripped of the "-" at the beginning
if (requiresArg(real_fld.field_type) and index != item.len - 2) {
try std.io.getStdErr().writer().writeAll("An option with argument must be the last option for short command line options.\n");
return error.EncounteredUnexpectedArgument;
}
try parseOption(Spec, &result, args, real_fld.name, null);
found = true;
}
}
if (!found) {
try std.io.getStdErr().writer().print("Unknown command line option: -{c}\n", .{char});
return error.EncounteredUnknownArgument;
}
}
} else {
try std.io.getStdErr().writer().writeAll("Short command line options are not supported.\n");
return error.EncounteredUnsupportedArgument;
}
}
} else {
try arglist.append(item);
}
}
// This will consume the rest of the arguments as positional ones.
// Only executes when the above loop is broken.
while (args.next(&result.arena.allocator)) |item_or_error| {
const item = try item_or_error;
try arglist.append(item);
}
result.positionals = arglist.toOwnedSlice();
return result;
}
/// The return type of the argument parser.
pub fn ParseArgsResult(comptime Spec: type) type {
return struct {
const Self = @This();
arena: std.heap.ArenaAllocator,
/// The options with either default or set values.
options: Spec,
/// The positional arguments that were passed to the process.
positionals: [][]const u8,
/// Name of the executable file (or: zeroth argument)
executable_name: ?[]const u8,
pub fn deinit(self: Self) void {
self.arena.child_allocator.free(self.positionals);
if (self.executable_name) |n|
self.arena.child_allocator.free(n);
self.arena.deinit();
}
};
}
/// Returns true if the given type requires an argument to be parsed.
fn requiresArg(comptime T: type) bool {
const H = struct {
fn doesArgTypeRequireArg(comptime Type: type) bool {
if (Type == []const u8)
return true;
return switch (@as(std.builtin.TypeId, @typeInfo(Type))) {
.Int, .Float, .Enum => true,
.Bool => false,
.Struct, .Union => true,
else => @compileError(@typeName(Type) ++ " is not a supported argument type!"),
};
}
};
const ti = @typeInfo(T);
if (ti == .Optional) {
return H.doesArgTypeRequireArg(ti.Optional.child);
} else {
return H.doesArgTypeRequireArg(T);
}
}
/// Parses a boolean option.
fn parseBoolean(str: []const u8) !bool {
return if (std.mem.eql(u8, str, "yes"))
true
else if (std.mem.eql(u8, str, "true"))
true
else if (std.mem.eql(u8, str, "y"))
true
else if (std.mem.eql(u8, str, "no"))
false
else if (std.mem.eql(u8, str, "false"))
false
else if (std.mem.eql(u8, str, "n"))
false
else
return error.NotABooleanValue;
}
/// Converts an argument value to the target type.
fn convertArgumentValue(comptime T: type, textInput: []const u8) !T {
if (T == []const u8)
return textInput;
switch (@typeInfo(T)) {
.Optional => |opt| return try convertArgumentValue(opt.child, textInput),
.Bool => if (textInput.len > 0)
return try parseBoolean(textInput)
else
return true, // boolean options are always true
.Int => |int| return if (int.is_signed)
try std.fmt.parseInt(T, textInput, 10)
else
try std.fmt.parseUnsigned(T, textInput, 10),
.Float => return try std.fmt.parseFloat(T, textInput),
.Enum => {
if (@hasDecl(T, "parse")) {
return try T.parse(textInput);
} else {
return std.meta.stringToEnum(T, textInput) orelse return error.InvalidEnumeration;
}
},
.Struct, .Union => {
if (@hasDecl(T, "parse")) {
return try T.parse(textInput);
} else {
@compileError(@typeName(T) ++ " has no public visible `fn parse([]const u8) !T`!");
}
},
else => @compileError(@typeName(T) ++ " is not a supported argument type!"),
}
}
/// Parses an option value into the correct type.
fn parseOption(
comptime Spec: type,
result: *ParseArgsResult(Spec),
args: *std.process.ArgIterator,
/// The name of the option that is currently parsed.
comptime name: []const u8,
/// Optional pre-defined value for options that use `--foo=bar`
value: ?[]const u8,
) !void {
const field_type = @TypeOf(@field(result.options, name));
@field(result.options, name) = if (requiresArg(field_type)) blk: {
const argval = if (value) |val|
val
else
try (args.next(&result.arena.allocator) orelse {
try std.io.getStdErr().writer().print(
"Missing argument for {}.\n",
.{name},
);
return error.MissingArgument;
});
break :blk convertArgumentValue(field_type, argval) catch |err| {
try outputParseError(name, err);
return err;
};
} else
convertArgumentValue(field_type, if (value) |val| val else "") catch |err| {
try outputParseError(name, err);
return err;
}; // argument is "empty"
}
/// Helper function that will print an error message when a value could not be parsed, then return the same error again
fn outputParseError(option: []const u8, err: anytype) !void {
try std.io.getStdErr().writer().print("Failed to parse option {}: {}\n", .{
option,
@errorName(err),
});
return err;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/README.md | # koino


Zig port of [Comrak](https://github.com/kivikakk/comrak). Maintains 100% spec-compatibility with [GitHub Flavored Markdown](https://github.github.com/gfm/).
## Getting started
* Clone the repository with submodules, as we have quite a few dependencies.
```console
$ git clone --recurse-submodules https://github.com/kivikakk/koino
```
* [Follow the `libpcre.zig` dependency install instructions](https://github.com/kivikakk/libpcre.zig/blob/main/README.md) for your operating system.
* Build and run the spec suite.
```console
$ zig build test
$ make spec
```
* Have a look at the bottom of [`parser.zig`](https://github.com/kivikakk/koino/blob/main/src/parser.zig) to see some test usage.
## Usage
Command line:
```console
$ koino --help
Usage: koino [-hu] [-e <EXTENSION>...] [--smart]
Options:
-h, --help Display this help and exit
-u, --unsafe Render raw HTML and dangerous URLs
-e, --extension <EXTENSION>... Enable an extension. (table,strikethrough,autolink,tagfilter)
--smart Use smart punctuation.
```
Library:
TODO!
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/build.zig | const std = @import("std");
const linkPcre = @import("vendor/libpcre.zig/build.zig").linkPcre;
pub fn build(b: *std.build.Builder) !void {
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("koino", "src/main.zig");
exe.setTarget(target);
exe.setBuildMode(mode);
try addCommonRequirements(exe);
exe.install();
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
const test_exe = b.addTest("src/main.zig");
try addCommonRequirements(test_exe);
const test_step = b.step("test", "Run all the tests");
test_step.dependOn(&test_exe.step);
}
fn addCommonRequirements(exe: *std.build.LibExeObjStep) !void {
exe.addPackagePath("libpcre", "vendor/libpcre.zig/src/main.zig");
exe.addPackagePath("htmlentities", "vendor/htmlentities.zig/src/main.zig");
exe.addPackagePath("clap", "vendor/zig-clap/clap.zig");
exe.addPackagePath("zunicode", "vendor/zunicode/src/zunicode.zig");
try linkPcre(exe);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/FindAsan.cmake | #
# The MIT License (MIT)
#
# Copyright (c) 2013 Matthew Arsenault
#
# 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.
#
# This module tests if address sanitizer is supported by the compiler,
# and creates a ASan build type (i.e. set CMAKE_BUILD_TYPE=ASan to use
# it). This sets the following variables:
#
# CMAKE_C_FLAGS_ASAN - Flags to use for C with asan
# CMAKE_CXX_FLAGS_ASAN - Flags to use for C++ with asan
# HAVE_ADDRESS_SANITIZER - True or false if the ASan build type is available
include(CheckCCompilerFlag)
# Set -Werror to catch "argument unused during compilation" warnings
set(CMAKE_REQUIRED_FLAGS "-Werror -faddress-sanitizer") # Also needs to be a link flag for test to pass
check_c_compiler_flag("-faddress-sanitizer" HAVE_FLAG_ADDRESS_SANITIZER)
set(CMAKE_REQUIRED_FLAGS "-Werror -fsanitize=address") # Also needs to be a link flag for test to pass
check_c_compiler_flag("-fsanitize=address" HAVE_FLAG_SANITIZE_ADDRESS)
unset(CMAKE_REQUIRED_FLAGS)
if(HAVE_FLAG_SANITIZE_ADDRESS)
# Clang 3.2+ use this version
set(ADDRESS_SANITIZER_FLAG "-fsanitize=address")
elseif(HAVE_FLAG_ADDRESS_SANITIZER)
# Older deprecated flag for ASan
set(ADDRESS_SANITIZER_FLAG "-faddress-sanitizer")
endif()
if(NOT ADDRESS_SANITIZER_FLAG)
return()
else(NOT ADDRESS_SANITIZER_FLAG)
set(HAVE_ADDRESS_SANITIZER FALSE)
endif()
set(HAVE_ADDRESS_SANITIZER TRUE)
set(CMAKE_C_FLAGS_ASAN "-O1 -g ${ADDRESS_SANITIZER_FLAG} -fno-omit-frame-pointer -fno-optimize-sibling-calls"
CACHE STRING "Flags used by the C compiler during ASan builds."
FORCE)
set(CMAKE_CXX_FLAGS_ASAN "-O1 -g ${ADDRESS_SANITIZER_FLAG} -fno-omit-frame-pointer -fno-optimize-sibling-calls"
CACHE STRING "Flags used by the C++ compiler during ASan builds."
FORCE)
set(CMAKE_EXE_LINKER_FLAGS_ASAN "${ADDRESS_SANITIZER_FLAG}"
CACHE STRING "Flags used for linking binaries during ASan builds."
FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_ASAN "${ADDRESS_SANITIZER_FLAG}"
CACHE STRING "Flags used by the shared libraries linker during ASan builds."
FORCE)
mark_as_advanced(CMAKE_C_FLAGS_ASAN
CMAKE_CXX_FLAGS_ASAN
CMAKE_EXE_LINKER_FLAGS_ASAN
CMAKE_SHARED_LINKER_FLAGS_ASAN)
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/why-cmark-and-not-x.md | Why use `cmark` and not X?
==========================
`hoedown`
---------
`hoedown` (which derives from `sundown`) is slightly faster
than `cmark` in our benchmarks (0.21s vs. 0.29s). But both
are much faster than any other available implementations.
`hoedown` boasts of including "protection against all possible
DOS attacks," but there are some chinks in the armor:
% time python -c 'print(("[" * 50000) + "a" + ("]" * 50000))' | cmark
...
user 0m0.073s
% time python -c 'print(("[" * 50000) + "a" + ("]" * 50000))' | hoedown
...
0m17.84s
`hoedown` has many parsing bugs. Here is a selection (as of
v3.0.3):
% hoedown
- one
- two
1. three
^D
<ul>
<li>one
<ul>
<li>two</li>
<li>three</li>
</ul></li>
</ul>
% hoedown
## hi\###
^D
<h2>hi\</h2>
% hoedown
[ΑΓΩ]: /φου
[αγω]
^D
<p>[αγω]</p>
% hoedown
```
[foo]: /url
```
[foo]
^D
<p>```</p>
<p>```</p>
<p><a href="/url">foo</a></p>
% hoedown
[foo](url "ti\*tle")
^D
<p><a href="url" title="ti\*tle">foo</a></p>
% ./hoedown
- one
- two
- three
- four
^D
<ul>
<li>one
<ul>
<li>two</li>
<li>three</li>
<li>four</li>
</ul></li>
</ul>
`discount`
----------
`cmark` is about six times faster.
`kramdown`
----------
`cmark` is about a hundred times faster.
`kramdown` also gets tied in knots by pathological input like
python -c 'print(("[" * 50000) + "a" + ("]" * 50000))'
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/benchmarks.md | # Benchmarks
Here are some benchmarks, run on an ancient Thinkpad running Intel
Core 2 Duo at 2GHz. The input text is a 11MB Markdown file built by
concatenating the Markdown sources of all the localizations of the
first edition of
[*Pro Git*](https://github.com/progit/progit/tree/master/en) by Scott
Chacon.
|Implementation | Time (sec)|
|-------------------|-----------:|
| Markdown.pl | 2921.24 |
| Python markdown | 291.25 |
| PHP markdown | 20.82 |
| kramdown | 17.32 |
| cheapskate | 8.24 |
| peg-markdown | 5.45 |
| parsedown | 5.06 |
| **commonmark.js** | 2.09 |
| marked | 1.99 |
| discount | 1.85 |
| **cmark** | 0.29 |
| hoedown | 0.21 |
To run these benchmarks, use `make bench PROG=/path/to/program`.
`time` is used to measure execution speed. The reported
time is the *difference* between the time to run the program
with the benchmark input and the time to run it with no input.
(This procedure ensures that implementations in dynamic languages are
not penalized by startup time.) A median of ten runs is taken. The
process is reniced to a high priority so that the system doesn't
interrupt runs.
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/nmake.bat | @nmake.exe /nologo /f Makefile.nmake %*
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/changelog.txt | [0.29.0]
* Update spec to 0.29.
* Make rendering safe by default (#239, #273).
Adds `CMARK_OPT_UNSAFE` and make `CMARK_OPT_SAFE` a no-op (for API
compatibility). The new default behavior is to suppress raw HTML and
potentially dangerous links. The `CMARK_OPT_UNSAFE` option has to be set
explicitly to prevent this.
**NOTE:** This change will require modifications in bindings for cmark
and in most libraries and programs that use cmark.
Borrows heavily from @kivikakk's patch in github/cmark-gfm#123.
* Add sourcepos info for inlines (Yuki Izumi).
* Disallow more than 32 nested balanced parens in a link (Yuki Izumi).
* Resolve link references before creating setext header.
A setext header line after a link reference should not
create a header, according to the spec.
* commonmark renderer: improve escaping.
URL-escape special characters when escape mode is URL, and not otherwise.
Entity-escape control characters (< 0x20) in non-literal escape modes.
* render: only emit actual newline when escape mode is LITERAL.
For markdown content, e.g., in other contexts we want some
kind of escaping, not a literal newline.
* Update code span normalization to conform with spec change.
* Allow empty `<>` link destination in reference link.
* Remove leftover includes of `memory.h` (#290).
* A link destination can't start with `<` unless it is
an angle-bracket link that also ends with `>` (#289).
(If your URL really starts with `<`, URL-escape it.)
* Allow internal delimiter runs to match if both have lengths that are
multiples of 3. See commonmark/commonmark#528.
* Include `references.h` in `parser.h` (#287).
* Fix `[link](<foo\>)`.
* Use hand-rolled scanner for thematic break (see #284).
Keep track of the last position where a thematic break
failed to match on a line, to avoid rescanning unnecessarily.
* Rename `ends_with_blank_line` with `S_` prefix.
* Add `CMARK_NODE__LAST_LINE_CHECKED` flag (#284).
Use this to avoid unnecessary recursion in `ends_with_blank_line`.
* In `ends_with_blank_line`, call `S_set_last_line_blank`
to avoid unnecessary repetition (#284). Once we settle whether a list
item ends in a blank line, we don't need to revisit this in considering
parent list items.
* Disallow unescaped `(` in parenthesized link title.
* Copy line/col info straight from opener/closer (Ashe Connor).
We can't rely on anything in `subj` since it's been modified while parsing
the subject and could represent line info from a future line. This is
simple and works.
* `render.c`: reset `last_breakable` after cr. Fixes jgm/pandoc#5033.
* Fix a typo in `houdini_href_e.c` (Felix Yan).
* commonmark writer: use `~~~` fences if info string contains backtick.
This is needed for round-trip tests.
* Update scanners for new info string rules.
* Add XSLT stylesheet to convert cmark XML back to Commonmark
(Nick Wellnhofer, #264). Initial version of an XSLT stylesheet that
converts the XML format produced by `cmark -t xml` back to Commonmark.
* Check for whitespace before reference title (#263).
* Bump CMake to version 3 (Jonathan Müller).
* Build: Remove deprecated call to `add_compiler_export_flags()`
(Jonathan Müller). It is deprecated in CMake 3.0, the replacement is to
set the `CXX_VISIBILITY_PRESET` (or in our case `C_VISIBILITY_PRESET`) and
`VISIBILITY_INLINES_HIDDEN` properties of the target. We're already
setting them by setting the CMake variables anyway, so the call can be
removed.
* Build: only attempt to install MSVC system libraries on Windows
(Saleem Abdulrasool). Newer versions of CMake attempt to query the system
for information about the VS 2017 installation. Unfortunately, this query
fails on non-Windows systems when cross-compiling:
`cmake_host_system_information does not recognize <key> VS_15_DIR`.
CMake will not find these system libraries on non-Windows hosts anyways,
and we were silencing the warnings, so simply omit the installation when
cross-compiling to Windows.
* Simplify code normalization, in line with spec change.
* Implement code span spec changes. These affect both parsing and writing
commonmark.
* Add link parsing corner cases to regressions (Ashe Connor).
* Add `xml:space="preserve"` in XML output when appropriate
(Nguyễn Thái Ngọc Duy).
(For text, code, code_block, html_inline and html_block tags.)
* Removed meta from list of block tags. Added regression test.
See commonmark/CommonMark#527.
* `entity_tests.py` - omit noisy success output.
* `pathological_tests.py`: make tests run faster.
Commented out the (already ignored) "many references" test, which
times out. Reduced the iterations for a couple other tests.
* `pathological_tests.py`: added test for deeply nested lists.
* Optimize `S_find_first_nonspace`. We were needlessly redoing things we'd
already done. Now we skip the work if the first nonspace is greater than
the current offset. This fixes pathological slowdown with deeply nested
lists (#255). For N = 3000, the time goes from over 17s to about 0.7s.
Thanks to Martin Mitas for diagnosing the problem.
* Allow spaces in link destination delimited with pointy brackets.
* Adjust max length of decimal/numeric entities.
See commonmark/CommonMark#487.
* Fix inline raw HTML parsing.
This fixes a recently added failing spec test case. Previously spaces
were being allowed in unquoted attribute values; no we forbid them.
* Don't allow list markers to be indented >= 4 spaces.
See commonmark/CommonMark#497.
* Check for empty buffer when rendering (Phil Turnbull).
For empty documents, `->size` is zero so
`renderer.buffer->ptr[renderer.buffer->size - 1]` will cause an
out-of-bounds read. Empty buffers always point to the global
`cmark_strbuf__initbuf` buffer so we read `cmark_strbuf__initbuf[-1]`.
* Also run API tests with `CMARK_SHARED=OFF` (Nick Wellnhofer).
* Rename roundtrip and entity tests (Nick Wellnhofer).
Rename the tests to reflect that they use the library, not the
executable.
* Generate export header for static-only build (#247, Nick Wellnhofer).
* Fuzz width parameter too (Phil Turnbull). Allow the `width` parameter to
be generated too so we get better fuzz-coverage.
* Don't discard empty fuzz test-cases (Phil Turnbull). We currently discard
fuzz test-cases that are empty but empty inputs are valid markdown. This
improves the fuzzing coverage slightly.
* Fixed exit code for pathological tests.
* Add allowed failures to `pathological_tests.py`.
This allows us to include tests that we don't yet know how to pass.
* Add timeout to `pathological_tests.py`.
Tests must complete in 8 seconds or are errors.
* Add more pathological tests (Martin Mitas).
These tests target the issues #214, #218, #220.
* Use pledge(2) on OpenBSD (Ashe Connor).
* Update the Racket wrapper (Eli Barzilay).
* Makefile: For afl target, don't build tests.
[0.28.3.gfm.20]
* Add tasklist extension implementation (Watson1978, #94).
[0.28.3.gfm.19]
* Prevent out-of-bound memory access in strikethrough matcher (Xavier Décoret, #124).
* Limit recursion in autolink extension (Xavier Décoret, #125).
* Add plaintext rendering for footnotes (Xavier Décoret, #126).
[0.28.3.gfm.18]
* Match strikethrough more strictly (#120).
* Default to safe operation (#123).
[0.28.3.gfm.17]
* Allow extension to provide opaque allocation function (Nicolás Ojeda
Bär, #89).
* Upstream optimisations and fixes.
* Extensions can add custom XML attributes (#116).
* Support for GFM extensions in cmark XML to CommonMark XSLT converter
(Maëlle Salmon, #117).
[0.28.3.gfm.16]
* Do not percent-encode tildes (~) in HTML attribute values (#110).
* Fix footnote references in tables (#112).
[0.28.3.gfm.15]
* Escape non-strikethrough tildes (~) in commonmark output (John MacFarlane, #106).
* Cosmetic fix to table HTML output (John MacFarlane, #105).
* Use two tildes for strikethrough CommonMark output (John MacFarlane, #104).
* Normalised header and define names (#109).
[0.28.3.gfm.14]
* Added a plaintext renderer for strikethrough nodes.
[0.28.3.gfm.13]
* Footnote rendering bugfix (Michael Camilleri, #90).
* Debian packaging (Joachim Nilsson, #97).
* Add CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE for redcarpet compatibility.
* Add CMARK_OPT_TABLE_PREFER_STYLE_ATTRIBUTES (FUJI Goro, #86, #87).
* Fix pathological nested list parsing (Phil Turnbull, #95).
* Expose more of the extension APIs (Minghao Liu, #96).
* Add python example which uses extensions (Greg Stein, #102).
* Add CMARK_OPT_FULL_INFO_STRING (Mike Kavouras, #103).
[0.28.3.gfm.12]
* Various security and bug fixes.
[0.28.3]
* Include GNUInstallDirs in src/CMakeLists.txt (Nick Wellnhofer, #240).
This fixes build problems on some cmake versions (#241).
[0.28.2]
* Fixed regression in install dest for static library (#238).
Due to a mistake, 0.28.1 installed libcmark.a into include/.
[0.28.1]
* `--smart`: open quote can never occur right after `]` or `)` (#227).
* Fix quadratic behavior in `finalize` (Vicent Marti).
* Don't use `CMAKE_INSTALL_LIBDIR` to create `libcmark.pc` (#236).
This wasn't getting set in processing `libcmark.pc.in`, and we
were getting the wrong entry in `libcmark.pc`.
The new approach sets an internal `libdir` variable to
`lib${LIB_SUFFIX}`. This variable is used both to set the
install destination and in the libcmark.pc.in template.
* Update README.md, replace `make astyle` with `make format`
(Nguyễn Thái Ngọc Duy).
[0.28.0.gfm.11]
* Do not output empty `<tbody>` in table extension.
[0.28.0.gfm.10]
* Fix denial of service parsing references.
[0.28.0.gfm.9]
* Fix denial of service parsing nested links (#49).
[0.28.0.gfm.8]
* Fix bug where autolink would cause `:` to be skipped in emphasis
processing.
[0.28.0.gfm.7]
* Strikethrough characters do not disturb regular emphasis processing.
[0.28.0.gfm.6]
* Fix inline sourcepos info when inlines span multiple lines, and in
ATX headings.
[0.28.0.gfm.5]
* Latest spec.
* Fix a typo in the spec (John Gardner).
* Fix quadratic behavior in reference lookups.
* Add `core_extensions_ensure_registered`.
* Add sourcepos information for inlines.
[0.28.0]
* Update spec.
* Use unsigned integer when shifting (Phil Turnbull).
Avoids a UBSAN warning which can be triggered when handling a
long sequence of backticks.
* Avoid memcpy'ing NULL pointers (Phil Turnbull).
Avoids a UBSAN warning when link title is empty string.
The length of the memcpy is zero so the NULL pointer is not
dereferenced but it is still undefined behaviour.
* DeMorgan simplification of some tests in emphasis parser.
This also brings the code into closer alignment with the wording
of the spec (see jgm/CommonMark#467).
* Fixed undefined shift in commonmark writer (#211).
Found by google/oss-fuzz:
<https://oss-fuzz.com/v2/testcase-detail/4686992824598528>.
* latex writer: fix memory overflow (#210).
We got an array overflow in enumerated lists nested more than
10 deep with start number =/= 1.
This commit also ensures that we don't try to set `enum_` counters
that aren't defined by LaTeX (generally up to enumv).
Found by google/oss-fuzz:
<https://oss-fuzz.com/v2/testcase-detail/5546760854306816>.
* Check for NULL pointer in get_link_type (Phil Turnbull).
`echo '[](xx:)' | ./build/src/cmark -t latex` gave a
segfault.
* Move fuzzing dictionary into single file (Phil Turnbull).
This allows AFL and libFuzzer to use the same dictionary
* Reset bytes after UTF8 proc (Yuki Izumi, #206).
* Don't scan past an EOL (Yuki Izumi).
The existing negated character classes (`[^…]`) are careful to
always include` \x00` in the characters excluded, but these `.`
catch-alls can scan right past the terminating NUL placed
at the end of the buffer by `_scan_at`. As such, buffer
overruns can occur. Also, don't scan past a newline in HTML
block end scanners.
* Document cases where `get_` functions return `NULL` (#155).
E.g. `cmark_node_get_url` on a non-link or image.
* Properly handle backslashes in link destinations (#192).
Only ascii punctuation characters are escapable, per the spec.
* Fixed `cmark_node_get_list_start` to return 0 for bullet lists,
as documented (#202).
* Use `CMARK_NO_DELIM` for bullet lists (#201).
* Fixed code for freeing delimiter stack (#189).
* Removed abort outside of conditional (typo).
* Removed coercion in error message when aborting from buffer.
* Print message to stderr when we abort due to memory demands (#188).
* `libcmark.pc`: use `CMAKE_INSTALL_LIBDIR` (#185, Jens Petersen).
Needed for multilib distros like Fedora.
* Fixed buffer overflow error in `S_parser_feed` (#184).
The overflow could occur in the following condition:
the buffer ends with `\r` and the next memory address
contains `\n`.
* Update emphasis parsing for spec change.
Strong now goes inside Emph rather than the reverse,
when both scopes are possible. The code is much simpler.
This also avoids a spec inconsistency that cmark had previously:
`***hi***` became Strong (Emph "hi")) but
`***hi****` became Emph (Strong "hi")) "*"
* Fixes for the LaTeX renderer (#182, Doeme)
+ Don't double-output the link in latex-rendering.
+ Prevent ligatures in dashes sensibly when rendering latex.
`\-` is a hyphenation, so it doesn't get displayed at all.
* Added a test for NULL when freeing `subj->last_delim`.
* Cleaned up setting of lower bounds for openers.
We now use a much smaller array.
* Fix #178, quadratic parsing bug. Add pathological test.
* Slight improvement of clarity of logic in emph matching.
* Fix "multiple of 3" determination in emph/strong parsing.
We need to store the length of the original delimiter run,
instead of using the length of the remaining delimiters
after some have been subtracted. Test case:
`a***b* c*`. Thanks to Raph Levin for reporting.
* Correctly initialize chunk in S_process_line (Nick Wellnhofer, #170).
The `alloc` member wasn't initialized. This also allows to add an
assertion in `chunk_rtrim` which doesn't work for alloced chunks.
* Added 'make newbench'.
* `scanners.c` generated with re2c 0.16 (68K smaller!).
* `scanners.re` - fixed warnings; use `*` for fallback.
* Fixed some warnings in `scanners.re`.
* Update CaseFolding to latest (Kevin Wojniak, #168).
* Allow balanced nested parens in link destinations (Yuki Izumi, #166)
* Allocate enough bytes for backticks array.
* Inlines: Ensure that the delimiter stack is freed in subject.
* Fixed pathological cases with backtick code spans:
- Removed recursion in scan_to_closing_backticks
- Added an array of pointers to potential backtick closers
to subject
- This array is used to avoid traversing the subject again
when we've already seen all the potential backtick closers.
- Added a max bound of 1000 for backtick code span delimiters.
- This helps with pathological cases like:
x
x `
x ``
x ```
x ````
...
- Added pathological test case.
Thanks to Martin Mitáš for identifying the problem and for
discussion of solutions.
* Remove redundant cmake_minimum_required (#163, @kainjow).
* Make shared and static libraries optional (Azamat H. Hackimov).
Now you can enable/disable compilation and installation targets for
shared and static libraries via `-DCMARK_SHARED=ON/OFF` and
`-DCMARK_STATIC=ON/OFF`.
* Added support for built-in `${LIB_SUFFIX}` feature (Azamat H.
Hackimov). Replaced `${LIB_INSTALL_DIR}` option with built-in
`${LIB_SUFFIX}` for installing for 32/64-bit systems. Normally,
CMake will set `${LIB_SUFFIX}` automatically for required enviroment.
If you have any issues with it, you can override this option with
`-DLIB_SUFFIX=64` or `-DLIB_SUFFIX=""` during configuration.
* Add Makefile target and harness to fuzz with libFuzzer (Phil Turnbull).
This can be run locally with `make libFuzzer` but the harness will be
integrated into oss-fuzz for large-scale fuzzing.
* Advertise `--validate-utf8` in usage information
(Nguyễn Thái Ngọc Duy).
* Makefile: use warnings with re2c.
* README: Add link to Python wrapper, prettify languages list
(Pavlo Kapyshin).
* README: Add link to cmark-scala (Tim Nieradzik, #196)
[0.27.1.gfm.4]
* Fix regression with nested parentheses in link targets (#48).
[0.27.1.gfm.3]
* Various undefined behavior issues fixed (#38, #39, #40).
* Tag filter is case-insensitive (#43).
[0.27.1.gfm.2]
* Fix a number of bugs (reading past end of buffer, undefined behavior.
* Add `cmark_syntax_extension_get_private()`. (Jonathan Müller)
[0.27.1.gfm.1]
* Add plaintext renderer.
* Remove normalize option; we now always normalize the AST.
* Add getters for table alignment.
* `make install` also installs the extensions static/shared library.
[0.27.1.gfm.0]
* Add extensions: tagfilter, strikethrough, table, autolink.
* Add arena memory implementation.
* Add CMARK_OPT_GITHUB_PRE_LANG for fenced code blocks.
* Skip UTF-8 BOM on input.
[0.27.1]
* Set policy for CMP0063 to avoid a warning (#162).
Put set_policy under cmake version test.
Otherwise we get errors in older versions of cmake.
* Use VERSION_GREATER to clean up cmake version test.
* Improve afl target. Use afl-clang by default. Set default for path.
[0.27.0]
* Update spec to 0.27.
* Fix warnings building with MSVC on Windows (#165, Hugh Bellamy).
* Fix `CMAKE_C_VISIBILITY_PRESET` for cmake versions greater than 1.8
(e.g. 3.6.2) (#162, Hugh Bellamy). This lets us build swift-cmark
on Windows, using clang-cl.
* Fix for non-matching entities (#161, Yuki Izumi).
* Modified `print_delimiters` (commented out) so it compiles again.
* `make format`: don't change order of includes.
* Changed logic for null/eol checks (#160).
+ only check once for "not at end of line"
+ check for null before we check for newline characters (the
previous patch would fail for NULL + CR)
* Fix by not advancing past both `\0` and `\n` (Yuki Izumi).
* Add test for NUL-LF sequence (Yuki Izumi).
* Fix memory leak in list parsing (Yuki Izumi).
* Use `cmark_mem` to free where used to alloc (Yuki Izumi).
* Allow a shortcut link before a `(` (jgm/CommonMark#427).
* Allow tabs after setext header line (jgm/commonmark.js#109).
* Don't let URI schemes start with spaces.
* Fixed h2..h6 HTML blocks (jgm/CommonMark#430). Added regression test.
* Autolink scheme can contain digits (Gábor Csárdi).
* Fix nullary function declarations in cmark.h (Nick Wellnhofer).
Fixes strict prototypes warnings.
* COPYING: Update file name and remove duplicate section and
(Peter Eisentraut).
* Fix typo (Pavlo Kapyshin).
[0.26.1]
* Removed unnecessary typedef that caused build failure on
some platforms.
* Use `$(MAKE)` in Makefile instead of hardcoded `make` (#146,
Tobias Kortkamp).
[0.26.0]
* Implement spec changes for list items:
- Empty list items cannot interrupt paragraphs.
- Ordered lists cannot interrupt paragraphs unless
they start with 1.
- Removed "two blank lines break out of a list" feature.
* Fix sourcepos for blockquotes (#142).
* Fix sourcepos for atx headers (#141).
* Fix ATX headers and thematic breaks to allow tabs as well as spaces.
* Fix `chunk_set_cstr` with suffix of current string (#139,
Nick Wellnhofer). It's possible that `cmark_chunk_set_cstr` is called
with a substring (suffix) of the current string. Delay freeing of the
chunk content to handle this case correctly.
* Export targets on installation (Jonathan Müller).
This allows using them in other cmake projects.
* Fix cmake warning about CMP0048 (Jonathan Müller).
* commonmark renderer: Ensure we don't have a blank line
before a code block when it's the first thing in a list
item.
* Change parsing of strong/emph in response to spec changes.
`process_emphasis` now gets better results in corner cases.
The change is this: when considering matches between an interior
delimiter run (one that can open and can close) and another delimiter
run, we require that the sum of the lengths of the two delimiter
runs mod 3 is not 0.
* Ported Robin Stocker's changes to link parsing in jgm/commonmark#101.
This uses a separate stack for brackets, instead of putting them on the
delimiter stack. This avoids the need for looking through the delimiter
stack for the next bracket.
* `cmark_reference_lookup`: Return NULL if reference is null string.
* Fix character type detection in `commonmark.c` (Nick Wellnhofer).
Fixes test failures on Windows and undefined behavior.
- Implement `cmark_isalpha`.
- Check for ASCII character before implicit cast to char.
- Use internal ctype functions in `commonmark.c`.
* Better documentation of memory-freeing responsibilities.
in `cmark.h` and its man page (#124).
* Use library functions to insert nodes in emphasis/link processing.
Previously we did this manually, which introduces many
places where errors can creep in.
* Correctly handle list marker followed only by spaces.
Previously when a list marker was followed only by spaces,
cmark expected the following content to be indented by
the same number of spaces. But in this case we should
treat the line just like a blank line and set list padding
accordingly.
* Fixed a number of issues relating to line wrapping.
- Extend `CMARK_OPT_NOBREAKS` to all renderers and add `--nobreaks`.
- Do not autowrap, regardless of width parameter, if
`CMARK_OPT_NOBREAKS` is set.
- Fixed `CMARK_OPT_HARDBREAKS` for LaTeX and man renderers.
- Ensure that no auto-wrapping occurs if
`CMARK_OPT_NOBREAKS` is enabled, or if output is CommonMark and
`CMARK_OPT_HARDBREAKS` is enabled.
* Set stdin to binary mode on Windows (Nick Wellnhofer, #113).
This fixes EOLs when reading from stdin.
* Add library option to render softbreaks as spaces (Pavlo
Kapyshin). Note that the `NOBREAKS` option is HTML-only
* renderer: `no_linebreaks` instead of `no_wrap`.
We generally want this option to prohibit any breaking
in things like headers (not just wraps, but softbreaks).
* Coerce `realurllen` to `int`. This is an alternate solution for pull
request #132, which introduced a new warning on the comparison
(Benedict Cohen).
* Remove unused variable `link_text` (Mathiew Duponchelle).
* Improved safety checks in buffer (Vicent Marti).
* Add new interface allowing specification of custom memory allocator
for nodes (Vicent Marti). Added `cmark_node_new_with_mem`,
`cmark_parser_new_with_mem`, `cmark_mem` to API.
* Reduce storage size for nodes by using bit flags instead of
separate booleans (Vicent Marti).
* config: Add `SSIZE_T` compat for Win32 (Vicent Marti).
* cmake: Global handler for OOM situations (Vicent Marti).
* Add tests for memory exhaustion (Vicent Marti).
* Document in man page and public header that one should use the same
memory allocator for every node in a tree.
* Fix ctypes in Python FFI calls (Nick Wellnhofer). This didn't cause
problems so far because all types are 32-bit on 32-bit systems and
arguments are passed in registers on x86-64. The wrong types could cause
crashes on other platforms, though.
* Remove spurious failures in roundtrip tests. In the commonmark writer we
separate lists, and lists and indented code, using a dummy HTML comment.
So in evaluating the round-trip tests, we now strip out
these comments. We also normalize HTML to avoid issues
having to do with line breaks.
* Add 2016 to copyright (Kevin Burke).
* Added `to_commonmark` in `test/cmark.py` (for round-trip tests).
* `spec_test.py` - parameterize `do_test` with converter.
* `spec_tests.py`: exit code is now sum of failures and errors.
This ensures that a failing exit code will be given when
there are errors, not just with failures.
* Fixed round trip tests. Previously they actually ran
`cmark` instead of the round-trip version, since there was a bug in
setting the ROUNDTRIP variable (#131).
* Added new `roundtrip_tests.py`. This replaces the old use of simple shell
scripts. It is much faster, and more flexible. (We will be able
to do custom normalization and skip certain tests.)
* Fix tests under MinGW (Nick Wellnhofer).
* Fix leak in `api_test` (Mathieu Duponchelle).
* Makefile: have leakcheck stop on first error instead of going through
all the formats and options and probably getting the same output.
* Add regression tests (Nick Wellnhofer).
[0.25.2]
* Open files in binary mode (#113, Nick Wellnhofer). Now that cmark
supports different line endings, files must be openend in binary mode
on Windows.
* Reset `partially_consumed_tab` on every new line (#114, Nick Wellnhofer).
* Handle buffer split across a CRLF line ending (#117). Adds an internal
field to the parser struct to keep track of `last_buffer_ended_with_cr`.
Added test.
[0.25.1]
* Release with no code changes. cmark version was mistakenly set to
0.25.1 in the 0.25.0 release (#112), so this release just
ensures that this will cause no confusion later.
[0.25.0]
* Fixed tabs in indentation (#101). This patch fixes S_advance_offset
so that it doesn't gobble a tab character when advancing less than the
width of a tab.
* Added partially_consumed_tab to parser. This keeps track of when we
have gotten partway through a tab when consuming initial indentation.
* Simplified add_line (only need parser parameter).
* Properly handle partially consumed tab. E.g. in
- foo
<TAB><TAB>bar
we should consume two spaces from the second tab, including two spaces
in the code block.
* Properly handle tabs with blockquotes and fenced blocks.
* Fixed handling of tabs in lists.
* Clarified logic in S_advance_offset.
* Use an assertion to check for in-range html_block_type.
It's a programming error if the type is out of range.
* Refactored S_processLines to make the logic easier to
understand, and added documentation (Mathieu Duponchelle).
* Removed unnecessary check for empty string_content.
* Factored out contains_inlines.
* Moved the cmake minimum version to top line of CMakeLists.txt
(tinysun212).
* Fix ctype(3) usage on NetBSD (Kamil Rytarowski). We need to cast value
passed to isspace(3) to unsigned char to explicitly prevent possibly
undefined behavior.
* Compile in plain C mode with MSVC 12.0 or newer (Nick Wellnhofer).
Under MSVC, we used to compile in C++ mode to get some C99 features
like mixing declarations and code. With newer MSVC versions, it's
possible to build in plain C mode.
* Switched from "inline" to "CMARK_INLINE" (Nick Wellnhofer).
Newer MSVC versions support enough of C99 to be able to compile cmark
in plain C mode. Only the "inline" keyword is still unsupported.
We have to use "__inline" instead.
* Added include guards to config.h
* config.h.in - added compatibility snprintf, vsnprintf for MSVC.
* Replaced sprintf with snprintf (Marco Benelli).
* config.h: include stdio.h for _vscprintf etc.
* Include starg.h when needed in config.h.
* Removed an unnecessary C99-ism in buffer.c. This helps compiling on
systems like luarocks that don't have all the cmake configuration
goodness (thanks to carlmartus).
* Don't use variable length arrays (Nick Wellnhofer).
They're not supported by MSVC.
* Test with multiple MSVC versions under Appveyor (Nick Wellnhofer).
* Fix installation dir of man-pages on NetBSD (Kamil Rytarowski).
* Fixed typo in cmark.h comments (Chris Eidhof).
* Clarify in man page that cmark_node_free frees a node's children too.
* Fixed documentation of --width in man page.
* Require re2c >= 1.14.2 (#102).
* Generated scanners.c with more recent re2c.
[0.24.1]
* Commonmark renderer:
+ Use HTML comment, not two blank lines, to separate a list
item from a following code block or list. This makes the
output more portable, since the "two blank lines" rule is
unique to CommonMark. Also, it allows us to break out of
a sublist without breaking out of all levels of nesting.
+ `is_autolink` - handle case where link has no children,
which previously caused a segfault.
+ Use 4-space indent for bullet lists, for increased portability.
+ Use 2-space + newline for line break for increased portability (#90).
+ Improved punctuation escaping. Previously all `)` and
`.` characters after digits were escaped; now they are
only escaped if they are genuinely in a position where
they'd cause a list item. This is achieved by changes in
`render.c`: (a) `renderer->begin_content` is only set to
false after a string of digits at the beginning of the
line, and (b) we never break a line before a digit.
Also, `begin_content` is properly initialized to true.
* Handle NULL root in `consolidate_text_nodes`.
[0.24.0]
* [API change] Added `cmark_node_replace(oldnode, newnode)`.
* Updated spec.txt to 0.24.
* Fixed edge case with escaped parens in link destination (#97).
This was also checked against the #82 case with asan.
* Removed unnecessary check for `fenced` in `cmark_render_html`.
It's sufficient to check that the info string is empty.
Indeed, those who use the API may well create a code block
with an info string without explicitly setting `fenced`.
* Updated format of `test/smart_punct.txt`.
* Updated `test/spec.txt`, `test/smart_punct.txt`, and
`spec_tests.py` to new format.
* Fixed `get_containing_block` logic in `src/commonmark.c`.
This did not allow for the possibility that a node might have no
containing block, causing the commonmark renderer to segfault if
passed an inline node with no block parent.
* Fixed string representations of `CUSTOM_BLOCK`,
`CUSTOM_INLINE`. The old versions `raw_inline` and
`raw_block` were being used, and this led to incorrect xml output.
* Use default opts in python sample wrapper.
* Allow multiline setext header content, as per spec.
* Don't allow spaces in link destinations, even with pointy brackets.
Conforms to latest change in spec.
* Updated `scheme` scanner according to spec change. We no longer use
a whitelist of valid schemes.
* Allow any kind of nodes as children of `CUSTOM_BLOCK` (#96).
* `cmark.h`: moved typedefs for iterator into iterator section.
This just moves some code around so it makes more sense
to read, and in the man page.
* Fixed `make_man_page.py` so it includes typedefs again.
[0.23.0]
* [API change] Added `CUSTOM_BLOCK` and `CUSTOM_INLINE` node types.
They are never generated by the parser, and do not correspond
to CommonMark elements. They are designed to be inserted by
filters that postprocess the AST. For example, a filter might
convert specially marked code blocks to svg diagrams in HTML
and tikz diagrams in LaTeX, passing these through to the renderer
as a `CUSTOM_BLOCK`. These nodes can have children, but they
also have literal text to be printed by the renderer "on enter"
and "on exit." Added `cmark_node_get_on_enter`,
`cmark_node_set_on_enter`, `cmark_node_get_on_exit`,
`cmark_node_set_on_exit` to API.
* [API change] Rename `NODE_HTML` -> `NODE_HTML_BLOCK`,
`NODE_INLINE_HTML` -> `NODE_HTML_INLINE`. Define aliases
so the old names still work, for backwards compatibility.
* [API change] Rename `CMARK_NODE_HEADER` -> `CMARK_NODE_HEADING`.
Note that for backwards compatibility, we have defined aliases:
`CMARK_NODE_HEADER` = `CMARK_NODE_HEADING`,
`cmark_node_get_header_level` = `cmark_node_get_heading_level`, and
`cmark_node_set_header_level` = `cmark_node_set_heading_level`.
* [API change] Rename `CMARK_NODE_HRULE` -> `CMARK_NODE_THEMATIC_BREAK`.
Defined the former as the latter for backwards compatibility.
* Don't allow space between link text and link label in a reference link
(spec change).
* Separate parsing and rendering opts in `cmark.h` (#88).
This change also changes some of these constants' numerical values,
but nothing should change in the API if you use the constants
themselves. It should now be clear in the man page which
options affect parsing and which affect rendering.
* xml renderer - Added xmlns attribute to document node (jgm/CommonMark#87).
* Commonmark renderer: ensure html blocks surrounded by blanks.
Otherwise we get failures of roundtrip tests.
* Commonmark renderer: ensure that literal characters get escaped
when they're at the beginning of a block, e.g. `> \- foo`.
* LaTeX renderer - better handling of internal links.
Now we render `[foo](#bar)` as `\protect\hyperlink{bar}{foo}`.
* Check for NULL pointer in _scan_at (#81).
* `Makefile.nmake`: be more robust when cmake is missing. Previously,
when cmake was missing, the build dir would be created anyway, and
subsequent attempts (even with cmake) would fail, because cmake would
not be run. Depending on `build/CMakeFiles` is more robust -- this won't
be created unless cmake is run. Partially addresses #85.
* Fixed DOCTYPE in xml output.
* commonmark.c: fix `size_t` to `int`. This fixes an MSVC warning
"conversion from 'size_t' to 'int', possible loss of data" (Kevin Wojniak).
* Correct string length in `cmark_parse_document` example (Lee Jeffery).
* Fix non-ASCII end-of-line character check (andyuhnak).
* Fix "declaration shadows a local variable" (Kevin Wojniak).
* Install static library (jgm/CommonMark#381).
* Fix warnings about dropping const qualifier (Kevin Wojniak).
* Use full (unabbreviated) versions of constants (`CMARK_...`).
* Removed outdated targets from Makefile.
* Removed need for sudo in `make bench`.
* Improved benchmark. Use longer test, since `time` has limited resolution.
* Removed `bench.h` and timing calls in `main.c`.
* Updated API docs; getters return empty strings if not set
rather than NULL, as previously documented.
* Added api_tests for custom nodes.
* Made roundtrip test part of the test suite run by cmake.
* Regenerate `scanners.c` using re2c 0.15.3.
* Adjusted scanner for link url. This fixes a heap buffer overflow (#82).
* Added version number (1.0) to XML namespace. We don't guarantee
stability in this until 1.0 is actually released, however.
* Removed obsolete `TIMER` macro.
* Make `LIB_INSTALL_DIR` configurable (Mathieu Bridon, #79).
* Removed out-of-date luajit wrapper.
* Use `input`, not `parser->curline` to determine last line length.
* Small optimizations in `_scan_at`.
* Replaced hard-coded 4 with `TAB_STOP`.
* Have `make format` reformat api tests as well.
* Added api tests for man, latex, commonmark, and xml renderers (#51).
* render.c: added `begin_content` field. This is like `begin_line` except
that it doesn't trigger production of the prefix. So it can be set
after an initial prefix (say `> `) is printed by the renderer, and
consulted in determining whether to escape content that has a special
meaning at the beginning of a line. Used in the commonmark renderer.
* Python 3.5 compatibility: don't require HTMLParseError (Zhiming Wang).
HTMLParseError was removed in Python 3.5. Since it could never be thrown
in Python 3.5+, we simply define a placeholder when HTMLParseError
cannot be imported.
* Set `convert_charrefs=False` in `normalize.py` (#83). This defeats the
new default as of python 3.5, and allows the script to work with python
3.5.
[0.22.0]
* Removed `pre` from blocktags scanner. `pre` is handled separately
in rule 1 and needn't be handled in rule 6.
* Added `iframe` to list of blocktags, as per spec change.
* Fixed bug with `HRULE` after blank line. This previously caused cmark
to break out of a list, thinking it had two consecutive blanks.
* Check for empty string before trying to look at line ending.
* Make sure every line fed to `S_process_line` ends with `\n` (#72).
So `S_process_line` sees only unix style line endings. Ultimately we
probably want a better solution, allowing the line ending style of
the input file to be preserved. This solution forces output with newlines.
* Improved `cmark_strbuf_normalize_whitespace` (#73). Now all characters
that satisfy `cmark_isspace` are recognized as whitespace. Previously
`\r` and `\t` (and others) weren't included.
* Treat line ending with EOF as ending with newline (#71).
* Fixed `--hardbreaks` with `\r\n` line breaks (#68).
* Disallow list item starting with multiple blank lines (jgm/CommonMark#332).
* Allow tabs before closing `#`s in ATX header
* Removed `cmark_strbuf_printf` and `cmark_strbuf_vprintf`.
These are no longer needed, and cause complications for MSVC.
Also removed `HAVE_VA_COPY` and `HAVE_C99_SNPRINTF` feature tests.
* Added option to disable tests (Kevin Wojniak).
* Added `CMARK_INLINE` macro.
* Removed need to disable MSVC warnings 4267, 4244, 4800
(Kevin Wojniak).
* Fixed MSVC inline errors when cmark is included in sources that
don't have the same set of disabled warnings (Kevin Wojniak).
* Fix `FileNotFoundError` errors on tests when cmark is built from
another project via `add_subdirectory()` (Kevin Wojniak).
* Prefix `utf8proc` functions to avoid conflict with existing library
(Kevin Wojniak).
* Avoid name clash between Windows `.pdb` files (Nick Wellnhofer).
* Improved `smart_punct.txt` (see jgm/commonmark.js#61).
* Set `POSITION_INDEPENDENT_CODE` `ON` for static library (see #39).
* `make bench`: allow overriding `BENCHFILE`. Previously if you did
this, it would clopper `BENCHFILE` with the default bench file.
* `make bench`: Use -10 priority with renice.
* Improved `make_autolink`. Ensures that title is chunk with empty
string rather than NULL, as with other links.
* Added `clang-check` target.
* Travis: split `roundtrip_test` and `leakcheck` (OGINO Masanori).
* Use clang-format, llvm style, for formatting. Reformatted all source files.
Added `format` target to Makefile. Removed `astyle` target.
Updated `.editorconfig`.
[0.21.0]
* Updated to version 0.21 of spec.
* Added latex renderer (#31). New exported function in API:
`cmark_render_latex`. New source file: `src/latex.hs`.
* Updates for new HTML block spec. Removed old `html_block_tag` scanner.
Added new `html_block_start` and `html_block_start_7`, as well
as `html_block_end_n` for n = 1-5. Rewrote block parser for new HTML
block spec.
* We no longer preprocess tabs to spaces before parsing.
Instead, we keep track of both the byte offset and
the (virtual) column as we parse block starts.
This allows us to handle tabs without converting
to spaces first. Tabs are left as tabs in the output, as
per the revised spec.
* Removed utf8 validation by default. We now replace null characters
in the line splitting code.
* Added `CMARK_OPT_VALIDATE_UTF8` option and command-line option
`--validate-utf8`. This option causes cmark to check for valid
UTF-8, replacing invalid sequences with the replacement
character, U+FFFD. Previously this was done by default in
connection with tab expansion, but we no longer do it by
default with the new tab treatment. (Many applications will
know that the input is valid UTF-8, so validation will not
be necessary.)
* Added `CMARK_OPT_SAFE` option and `--safe` command-line flag.
+ Added `CMARK_OPT_SAFE`. This option disables rendering of raw HTML
and potentially dangerous links.
+ Added `--safe` option in command-line program.
+ Updated `cmark.3` man page.
+ Added `scan_dangerous_url` to scanners.
+ In HTML, suppress rendering of raw HTML and potentially dangerous
links if `CMARK_OPT_SAFE`. Dangerous URLs are those that begin
with `javascript:`, `vbscript:`, `file:`, or `data:` (except for
`image/png`, `image/gif`, `image/jpeg`, or `image/webp` mime types).
+ Added `api_test` for `OPT_CMARK_SAFE`.
+ Rewrote `README.md` on security.
* Limit ordered list start to 9 digits, per spec.
* Added width parameter to `render_man` (API change).
* Extracted common renderer code from latex, man, and commonmark
renderers into a separate module, `renderer.[ch]` (#63). To write a
renderer now, you only need to write a character escaping function
and a node rendering function. You pass these to `cmark_render`
and it handles all the plumbing (including line wrapping) for you.
So far this is an internal module, but we might consider adding
it to the API in the future.
* commonmark writer: correctly handle email autolinks.
* commonmark writer: escape `!`.
* Fixed soft breaks in commonmark renderer.
* Fixed scanner for link url. re2c returns the longest match, so we
were getting bad results with `[link](foo\(and\(bar\)\))`
which it would parse as containing a bare `\` followed by
an in-parens chunk ending with the final paren.
* Allow non-initial hyphens in html tag names. This allows for
custom tags, see jgm/CommonMark#239.
* Updated `test/smart_punct.txt`.
* Implemented new treatment of hyphens with `--smart`, converting
sequences of hyphens to sequences of em and en dashes that contain no
hyphens.
* HTML renderer: properly split info on first space char (see
jgm/commonmark.js#54).
* Changed version variables to functions (#60, Andrius Bentkus).
This is easier to access using ffi, since some languages, like C#
like to use only function interfaces for accessing library
functionality.
* `process_emphasis`: Fixed setting lower bound to potential openers.
Renamed `potential_openers` -> `openers_bottom`.
Renamed `start_delim` -> `stack_bottom`.
* Added case for #59 to `pathological_test.py`.
* Fixed emphasis/link parsing bug (#59).
* Fixed off-by-one error in line splitting routine.
This caused certain NULLs not to be replaced.
* Don't rtrim in `subject_from_buffer`. This gives bad results in
parsing reference links, where we might have trailing blanks
(`finalize` removes the bytes parsed as a reference definition;
before this change, some blank bytes might remain on the line).
+ Added `column` and `first_nonspace_column` fields to `parser`.
+ Added utility function to advance the offset, computing
the virtual column too. Note that we don't need to deal with
UTF-8 here at all. Only ASCII occurs in block starts.
+ Significant performance improvement due to the fact that
we're not doing UTF-8 validation.
* Fixed entity lookup table. The old one had many errors.
The new one is derived from the list in the npm entities package.
Since the sequences can now be longer (multi-code-point), we
have bumped the length limit from 4 to 8, which also affects
`houdini_html_u.c`. An example of the kind of error that was fixed:
`≧̸` should be rendered as "≧̸" (U+02267 U+00338), but it was
being rendered as "≧" (which is the same as `≧`).
* Replace gperf-based entity lookup with binary tree lookup.
The primary advantage is a big reduction in the size of
the compiled library and executable (> 100K).
There should be no measurable performance difference in
normal documents. I detected only a slight performance
hit in a file containing 1,000,000 entities.
+ Removed `src/html_unescape.gperf` and `src/html_unescape.h`.
+ Added `src/entities.h` (generated by `tools/make_entities_h.py`).
+ Added binary tree lookup functions to `houdini_html_u.c`, and
use the data in `src/entities.h`.
* Renamed `entities.h` -> `entities.inc`, and
`tools/make_entities_h.py` -> `tools/make_entitis_inc.py`.
* Fixed cases like
```
[ref]: url
"title" ok
```
Here we should parse the first line as a reference.
* `inlines.c`: Added utility functions to skip spaces and line endings.
* Fixed backslashes in link destinations that are not part of escapes
(jgm/commonmark#45).
* `process_line`: Removed "add newline if line doesn't have one."
This isn't actually needed.
* Small logic fixes and a simplification in `process_emphasis`.
* Added more pathological tests:
+ Many link closers with no openers.
+ Many link openers with no closers.
+ Many emph openers with no closers.
+ Many closers with no openers.
+ `"*a_ " * 20000`.
* Fixed `process_emphasis` to handle new pathological cases.
Now we have an array of pointers (`potential_openers`),
keyed to the delim char. When we've failed to match a potential opener
prior to point X in the delimiter stack, we reset `potential_openers`
for that opener type to X, and thus avoid having to look again through
all the openers we've already rejected.
* `process_inlines`: remove closers from delim stack when possible.
When they have no matching openers and cannot be openers themselves,
we can safely remove them. This helps with a performance case:
`"a_ " * 20000` (jgm/commonmark.js#43).
* Roll utf8proc_charlen into utf8proc_valid (Nick Wellnhofer).
Speeds up "make bench" by another percent.
* `spec_tests.py`: allow `→` for tab in HTML examples.
* `normalize.py`: don't collapse whitespace in pre contexts.
* Use utf-8 aware re2c.
* Makefile afl target: removed `-m none`, added `CMARK_OPTS`.
* README: added `make afl` instructions.
* Limit generated generated `cmark.3` to 72 character line width.
* Travis: switched to containerized build system.
* Removed `debug.h`. (It uses GNU extensions, and we don't need it anyway.)
* Removed sundown from benchmarks, because the reading was anomalous.
sundown had an arbitrary 16MB limit on buffers, and the benchmark
input exceeded that. So who knows what we were actually testing?
Added hoedown, sundown's successor, which is a better comparison.
[0.20.0]
* Fixed bug in list item parsing when items indented >= 4 spaces (#52).
* Don't allow link labels with no non-whitespace characters
(jgm/CommonMark#322).
* Fixed multiple issues with numeric entities (#33, Nick Wellnhofer).
* Support CR and CRLF line endings (Ben Trask).
* Added test for different line endings to `api_test`.
* Allow NULL value in string setters (Nick Wellnhofer). (NULL
produces a 0-length string value.) Internally, URL and
title are now stored as `cmark_chunk` rather than `char *`.
* Fixed memory leak in `cmark_consolidate_text_nodes` (#32).
* Fixed `is_autolink` in the CommonMark renderer (#50). Previously *any*
link with an absolute URL was treated as an autolink.
* Cope with broken `snprintf` on Windows (Nick Wellnhofer). On Windows,
`snprintf` returns -1 if the output was truncated. Fall back to
Windows-specific `_scprintf`.
* Switched length parameter on `cmark_markdown_to_html`,
`cmark_parser_feed`, and `cmark_parse_document` from `int`
to `size_t` (#53, Nick Wellnhofer).
* Use a custom type `bufsize_t` for all string sizes and indices.
This allows to switch to 64-bit string buffers by changing a single
typedef and a macro definition (Nick Wellnhofer).
* Hardened the `strbuf` code, checking for integer overflows and
adding range checks (Nick Wellnhofer).
* Removed unused function `cmark_strbuf_attach` (Nick Wellnhofer).
* Fixed all implicit 64-bit to 32-bit conversions that
`-Wshorten-64-to-32` warns about (Nick Wellnhofer).
* Added helper function `cmark_strbuf_safe_strlen` that converts
from `size_t` to `bufsize_t` and throws an error in case of
an overflow (Nick Wellnhofer).
* Abort on `strbuf` out of memory errors (Nick Wellnhofer).
Previously such errors were not being trapped. This involves
some internal changes to the `buffer` library that do not affect
the API.
* Factored out `S_find_first_nonspace` in `S_proces_line`.
Added fields `offset`, `first_nonspace`, `indent`, and `blank`
to `cmark_parser` struct. This just removes some repetition.
* Added Racket Racket (5.3+) wrapper (Eli Barzilay).
* Removed `-pg` from Debug build flags (#47).
* Added Ubsan build target, to check for undefined behavior.
* Improved `make leakcheck`. We now return an error status if anything
in the loop fails. We now check `--smart` and `--normalize` options.
* Removed `wrapper3.py`, made `wrapper.py` work with python 2 and 3.
Also improved the wrapper to work with Windows, and to use smart
punctuation (as an example).
* In `wrapper.rb`, added argument for options.
* Revised luajit wrapper.
* Added build status badges to README.md.
* Added links to go, perl, ruby, R, and Haskell bindings to README.md.
[0.19.0]
* Fixed `_` emphasis parsing to conform to spec (jgm/CommonMark#317).
* Updated `spec.txt`.
* Compile static library with `-DCMARK_STATIC_DEFINE` (Nick Wellnhofer).
* Suppress warnings about Windows runtime library files (Nick Wellnhofer).
Visual Studio Express editions do not include the redistributable files.
Set `CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS` to suppress warnings.
* Added appyeyor: Windows continuous integration (`appveyor.yml`).
* Use `os.path.join` in `test/cmark.py` for proper cross-platform paths.
* Fixed `Makefile.nmake`.
* Improved `make afl`: added `test/afl_dictionary`, increased timeout
for hangs.
* Improved README with a description of the library's strengths.
* Pass-through Unicode non-characters (Nick Wellnhofer).
Despite their name, Unicode non-characters are valid code points. They
should be passed through by a library like libcmark.
* Check return status of `utf8proc_iterate` (#27).
[0.18.3]
* Include patch level in soname (Nick Wellnhofer). Minor version is
tied to spec version, so this allows breaking the ABI between spec
releases.
* Install compiler-provided system runtime libraries (Changjiang Yang).
* Use `strbuf_printf` instead of `snprintf`. `snprintf` is not
available on some platforms (Visual Studio 2013 and earlier).
* Fixed memory access bug: "invalid read of size 1" on input `[link](<>)`.
[0.18.2]
* Added commonmark renderer: `cmark_render_commonmark`. In addition
to options, this takes a `width` parameter. A value of 0 disables
wrapping; a positive value wraps the document to the specified
width. Note that width is automatically set to 0 if the
`CMARK_OPT_HARDBREAKS` option is set.
* The `cmark` executable now allows `-t commonmark` for output as
CommonMark. A `--width` option has been added to specify wrapping
width.
* Added `roundtrip_test` Makefile target. This runs all the spec
through the commonmark renderer, and then through the commonmark
parser, and compares normalized HTML to the test. All tests pass
with the current parser and renderer, giving us some confidence that
the commonmark renderer is sufficiently robust. Eventually this
should be pythonized and put in the cmake test routine.
* Removed an unnecessary check in `blocks.c`. By the time we check
for a list start, we've already checked for a horizontal rule, so
we don't need to repeat that check here. Thanks to Robin Stocker for
pointing out a similar redundancy in commonmark.js.
* Fixed bug in `cmark_strbuf_unescape` (`buffer.c`). The old function
gave incorrect results on input like `\\*`, since the next backslash
would be treated as escaping the `*` instead of being escaped itself.
* `scanners.re`: added `_scan_scheme`, `scan_scheme`, used in the
commonmark renderer.
* Check for `CMAKE_C_COMPILER` (not `CC_COMPILER`) when setting C flags.
* Update code examples in documentation, adding new parser option
argument, and using `CMARK_OPT_DEFAULT` (Nick Wellnhofer).
* Added options parameter to `cmark_markdown_to_html`.
* Removed obsolete reference to `CMARK_NODE_LINK_LABEL`.
* `make leakcheck` now checks all output formats.
* `test/cmark.py`: set default options for `markdown_to_html`.
* Warn about buggy re2c versions (Nick Wellnhofer).
[0.18.1]
* Build static version of library in default build (#11).
* `cmark.h`: Add missing argument to `cmark_parser_new` (#12).
[0.18]
* Switch to 2-clause BSD license, with agreement of contributors.
* Added Profile build type, `make prof` target.
* Fixed autolink scanner to conform to the spec. Backslash escapes
not allowed in autolinks.
* Don't rely on strnlen being available (Nick Wellnhofer).
* Updated scanners for new whitespace definition.
* Added `CMARK_OPT_SMART` and `--smart` option, `smart.c`, `smart.h`.
* Added test for `--smart` option.
* Fixed segfault with --normalize (closes #7).
* Moved normalization step from XML renderer to `cmark_parser_finish`.
* Added options parameter to `cmark_parse_document`, `cmark_parse_file`.
* Fixed man renderer's escaping for unicode characters.
* Don't require python3 to make `cmark.3` man page.
* Use ASCII escapes for punctuation characters for portability.
* Made `options` an int rather than a long, for consistency.
* Packed `cmark_node` struct to fit into 128 bytes.
This gives a small performance boost and lowers memory usage.
* Repacked `delimiter` struct to avoid hole.
* Fixed use-after-free bug, which arose when a paragraph containing
only reference links and blank space was finalized (#9).
Avoid using `parser->current` in the loop that creates new
blocks, since `finalize` in `add_child` may have removed
the current parser (if it contains only reference definitions).
This isn't a great solution; in the long run we need to rewrite
to make the logic clearer and to make it harder to make
mistakes like this one.
* Added 'Asan' build type. `make asan` will link against ASan; the
resulting executable will do checks for memory access issues.
Thanks @JordanMilne for the suggestion.
* Add Makefile target to fuzz with AFL (Nick Wellnhofer)
The variable `$AFL_PATH` must point to the directory containing the AFL
binaries. It can be set as an environment variable or passed to make on
the command line.
[0.17]
* Stripped out all JavaScript related code and documentation, moving
it to a separate repository (<https://github.com/jgm/commonmark.js>).
* Improved Makefile targets, so that `cmake` is run again only when
necessary (Nick Wellnhofer).
* Added `INSTALL_PREFIX` to the Makefile, allowing installation to a
location other than `/usr/local` without invoking `cmake`
manually (Nick Wellnhofer).
* `make test` now guarantees that the project will
be rebuilt before tests are run (Nick Wellnhofer).
* Prohibited overriding of some Makefile variables (Nick Wellnhofer).
* Provide version number and string, both as macros
(`CMARK_VERSION`, `CMARK_VERSION_STRING`) and as symbols
(`cmark_version`, `cmark_version_string`) (Nick Wellnhofer). All of
these come from `cmark_version.h`, which is constructed from a
template `cmark_version.h.in` and data in `CMakeLists.txt`.
* Avoid calling `free` on null pointer.
* Added an accessor for an iterator's root node (`cmark_iter_get_root`).
* Added user data field for nodes (Nick Wellnhofer). This is
intended mainly for use in bindings for dynamic languages, where
it could store a pointer to a target language object (#287). But
it can be used for anything.
* Man renderer: properly escape multiline strings.
* Added assertion to raise error if finalize is called on a closed block.
* Implemented the new spec rule for emphasis and strong emphasis with `_`.
* Moved the check for fence-close with the other checks for end-of-block.
* Fixed a bug with loose list detection with items containings
fenced code blocks (#285).
* Removed recursive algorithm in `ends_with_blank_line` (#286).
* Minor code reformatting: renamed parameters.
[0.16]
* Added xml renderer (XML representation of the CommonMark AST,
which is described in `CommonMark.dtd`).
* Reduced size of gperf entity table (Nick Wellnhofer).
* Reworked iterators to allow deletion of nodes during iteration
(Nick Wellnhofer).
* Optimized `S_is_leaf`.
* Added `cmark_iter_reset` to iterator API.
* Added `cmark_consolidate_text_nodes` to API to combine adjacent
text nodes.
* Added `CMARK_OPT_NORMALIZE` to options (this combines adjacent
text nodes).
* Added `--normalize` option to command-line program.
* Improved regex for HTML comments in inline parsing.
* Python is no longer required for a basic build from the
repository.
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/CMakeLists.txt | cmake_minimum_required(VERSION 3.0)
project(cmark-gfm)
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 29)
set(PROJECT_VERSION_PATCH 0)
set(PROJECT_VERSION_GFM 0)
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM})
include("FindAsan.cmake")
include("CheckFileOffsetBits.cmake")
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "Do not build in-source.\nPlease remove CMakeCache.txt and the CMakeFiles/ directory.\nThen: mkdir build ; cd build ; cmake .. ; make")
endif()
option(CMARK_TESTS "Build cmark-gfm tests and enable testing" ON)
option(CMARK_STATIC "Build static libcmark-gfm library" ON)
option(CMARK_SHARED "Build shared libcmark-gfm library" ON)
option(CMARK_LIB_FUZZER "Build libFuzzer fuzzing harness" OFF)
add_subdirectory(src)
add_subdirectory(extensions)
if(CMARK_TESTS AND (CMARK_SHARED OR CMARK_STATIC))
add_subdirectory(api_test)
endif()
add_subdirectory(man)
if(CMARK_TESTS)
enable_testing()
add_subdirectory(test testdir)
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Profile Release Asan Ubsan." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/CheckFileOffsetBits.cmake | # - Check if _FILE_OFFSET_BITS macro needed for large files
# CHECK_FILE_OFFSET_BITS ()
#
# The following variables may be set before calling this macro to
# modify the way the check is run:
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# Copyright (c) 2009, Michihiro NAKAJIMA
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#INCLUDE(CheckCSourceCompiles)
GET_FILENAME_COMPONENT(_selfdir_CheckFileOffsetBits
"${CMAKE_CURRENT_LIST_FILE}" PATH)
MACRO (CHECK_FILE_OFFSET_BITS)
IF(NOT DEFINED _FILE_OFFSET_BITS)
MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files")
TRY_COMPILE(__WITHOUT_FILE_OFFSET_BITS_64
${CMAKE_CURRENT_BINARY_DIR}
${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
IF(NOT __WITHOUT_FILE_OFFSET_BITS_64)
TRY_COMPILE(__WITH_FILE_OFFSET_BITS_64
${CMAKE_CURRENT_BINARY_DIR}
${_selfdir_CheckFileOffsetBits}/CheckFileOffsetBits.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=64)
ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64)
IF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
SET(_FILE_OFFSET_BITS 64 CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files")
MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - needed")
ELSE(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
SET(_FILE_OFFSET_BITS "" CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files")
MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - not needed")
ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64)
ENDIF(NOT DEFINED _FILE_OFFSET_BITS)
ENDMACRO (CHECK_FILE_OFFSET_BITS)
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/toolchain-mingw32.cmake | # the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)
# which compilers to use for C and C++
SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)
SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres)
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc "${CMAKE_SOURCE_DIR}/windows")
# adjust the default behaviour of the FIND_XYZ() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/README.md | cmark-gfm
=========
[![Build Status]](https://travis-ci.org/github/cmark-gfm)
[![Windows Build Status]](https://ci.appveyor.com/project/github/cmark)
`cmark-gfm` is an extended version of the C reference implementation of
[CommonMark], a rationalized version of Markdown syntax with a spec. This
repository adds GitHub Flavored Markdown extensions to
[the upstream implementation], as defined in [the spec].
The rest of the README is preserved as-is from the upstream source. Note that
the library and binaries produced by this fork are suffixed with `-gfm` in
order to distinguish them from the upstream.
---
It provides a shared library (`libcmark`) with functions for parsing
CommonMark documents to an abstract syntax tree (AST), manipulating
the AST, and rendering the document to HTML, groff man, LaTeX,
CommonMark, or an XML representation of the AST. It also provides a
command-line program (`cmark`) for parsing and rendering CommonMark
documents.
Advantages of this library:
- **Portable.** The library and program are written in standard
C99 and have no external dependencies. They have been tested with
MSVC, gcc, tcc, and clang.
- **Fast.** cmark can render a Markdown version of *War and Peace* in
the blink of an eye (127 milliseconds on a ten year old laptop,
vs. 100-400 milliseconds for an eye blink). In our [benchmarks],
cmark is 10,000 times faster than the original `Markdown.pl`, and
on par with the very fastest available Markdown processors.
- **Accurate.** The library passes all CommonMark conformance tests.
- **Standardized.** The library can be expected to parse CommonMark
the same way as any other conforming parser. So, for example,
you can use `commonmark.js` on the client to preview content that
will be rendered on the server using `cmark`.
- **Robust.** The library has been extensively fuzz-tested using
[american fuzzy lop]. The test suite includes pathological cases
that bring many other Markdown parsers to a crawl (for example,
thousands-deep nested bracketed text or block quotes).
- **Flexible.** CommonMark input is parsed to an AST which can be
manipulated programmatically prior to rendering.
- **Multiple renderers.** Output in HTML, groff man, LaTeX, CommonMark,
and a custom XML format is supported. And it is easy to write new
renderers to support other formats.
- **Free.** BSD2-licensed.
It is easy to use `libcmark` in python, lua, ruby, and other dynamic
languages: see the `wrappers/` subdirectory for some simple examples.
There are also libraries that wrap `libcmark` for
[Go](https://github.com/rhinoman/go-commonmark),
[Haskell](https://hackage.haskell.org/package/cmark),
[Ruby](https://github.com/gjtorikian/commonmarker),
[Lua](https://github.com/jgm/cmark-lua),
[Perl](https://metacpan.org/release/CommonMark),
[Python](https://pypi.python.org/pypi/paka.cmark),
[R](https://cran.r-project.org/package=commonmark),
[Tcl](https://github.com/apnadkarni/tcl-cmark),
[Scala](https://github.com/sparsetech/cmark-scala) and
[Node.js](https://github.com/killa123/node-cmark).
Installing
----------
Building the C program (`cmark`) and shared library (`libcmark`)
requires [cmake]. If you modify `scanners.re`, then you will also
need [re2c] \(>= 0.14.2\), which is used to generate `scanners.c` from
`scanners.re`. We have included a pre-generated `scanners.c` in
the repository to reduce build dependencies.
If you have GNU make, you can simply `make`, `make test`, and `make
install`. This calls [cmake] to create a `Makefile` in the `build`
directory, then uses that `Makefile` to create the executable and
library. The binaries can be found in `build/src`. The default
installation prefix is `/usr/local`. To change the installation
prefix, pass the `INSTALL_PREFIX` variable if you run `make` for the
first time: `make INSTALL_PREFIX=path`.
For a more portable method, you can use [cmake] manually. [cmake] knows
how to create build environments for many build systems. For example,
on FreeBSD:
mkdir build
cd build
cmake .. # optionally: -DCMAKE_INSTALL_PREFIX=path
make # executable will be created as build/src/cmark
make test
make install
Or, to create Xcode project files on OSX:
mkdir build
cd build
cmake -G Xcode ..
open cmark.xcodeproj
The GNU Makefile also provides a few other targets for developers.
To run a benchmark:
make bench
For more detailed benchmarks:
make newbench
To run a test for memory leaks using `valgrind`:
make leakcheck
To reformat source code using `clang-format`:
make format
To run a "fuzz test" against ten long randomly generated inputs:
make fuzztest
To do a more systematic fuzz test with [american fuzzy lop]:
AFL_PATH=/path/to/afl_directory make afl
Fuzzing with [libFuzzer] is also supported but, because libFuzzer is still
under active development, may not work with your system-installed version of
clang. Assuming LLVM has been built in `$HOME/src/llvm/build` the fuzzer can be
run with:
CC="$HOME/src/llvm/build/bin/clang" LIB_FUZZER_PATH="$HOME/src/llvm/lib/Fuzzer/libFuzzer.a" make libFuzzer
To make a release tarball and zip archive:
make archive
Installing (Windows)
--------------------
To compile with MSVC and NMAKE:
nmake
You can cross-compile a Windows binary and dll on linux if you have the
`mingw32` compiler:
make mingw
The binaries will be in `build-mingw/windows/bin`.
Usage
-----
Instructions for the use of the command line program and library can
be found in the man pages in the `man` subdirectory.
Security
--------
By default, the library will scrub raw HTML and potentially
dangerous links (`javascript:`, `vbscript:`, `data:`, `file:`).
To allow these, use the option `CMARK_OPT_UNSAFE` (or
`--unsafe`) with the command line program. If doing so, we
recommend you use a HTML sanitizer specific to your needs to
protect against [XSS
attacks](http://en.wikipedia.org/wiki/Cross-site_scripting).
Contributing
------------
There is a [forum for discussing
CommonMark](http://talk.commonmark.org); you should use it instead of
github issues for questions and possibly open-ended discussions.
Use the [github issue tracker](http://github.com/commonmark/CommonMark/issues)
only for simple, clear, actionable issues.
Authors
-------
John MacFarlane wrote the original library and program.
The block parsing algorithm was worked out together with David
Greenspan. Vicent Marti optimized the C implementation for
performance, increasing its speed tenfold. Kārlis Gaņģis helped
work out a better parsing algorithm for links and emphasis,
eliminating several worst-case performance issues.
Nick Wellnhofer contributed many improvements, including
most of the C library's API and its test harness.
[benchmarks]: benchmarks.md
[the spec]: https://github.github.com/gfm/
[the upstream implementation]: https://github.com/jgm/cmark
[CommonMark]: http://commonmark.org
[cmake]: http://www.cmake.org/download/
[re2c]: http://re2c.org
[commonmark.js]: https://github.com/commonmark/commonmark.js
[Build Status]: https://img.shields.io/travis/github/cmark-gfm/master.svg?style=flat
[Windows Build Status]: https://ci.appveyor.com/api/projects/status/wv7ifhqhv5itm3d5?svg=true
[american fuzzy lop]: http://lcamtuf.coredump.cx/afl/
[libFuzzer]: http://llvm.org/docs/LibFuzzer.html
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/appveyor.yml | environment:
PYTHON: "C:\\Python34-x64"
PYTHON_VERSION: "3.4.3"
PYTHON_ARCH: "64"
matrix:
- MSVC_VERSION: 10
- MSVC_VERSION: 12
# set up for nmake:
install:
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
build_script:
- 'tools\appveyor-build.bat'
artifacts:
- path: build/src/cmark-gfm.exe
name: cmark-gfm.exe
test_script:
- 'nmake test'
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/.travis.yml | # Ensures that sudo is disabled, so that containerized builds are allowed
sudo: false
os:
- linux
- osx
language: c
compiler:
- clang
- gcc
matrix:
include:
- os: linux
compiler: gcc
env: CMAKE_OPTIONS="-DCMARK_SHARED=OFF"
addons:
apt:
# we need a more recent cmake than travis/linux provides (at least 2.8.9):
sources:
- kubuntu-backports
- kalakris-cmake
packages:
- cmake
- python3
- valgrind
before_install:
- |
if [ ${TRAVIS_OS_NAME:-'linux'} = 'osx' ]
then
echo "Building without python3, to make sure that works."
fi
script:
- (mkdir -p build && cd build && cmake $CMAKE_OPTIONS ..)
- make test
- |
if [ ${TRAVIS_OS_NAME:-'linux'} = 'linux' ]
then
make leakcheck
fi
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/CheckFileOffsetBits.c | #include <sys/types.h>
#define KB ((off_t)1024)
#define MB ((off_t)1024 * KB)
#define GB ((off_t)1024 * MB)
#define TB ((off_t)1024 * GB)
int t2[(((64 * GB -1) % 671088649) == 268434537)
&& (((TB - (64 * GB -1) + 255) % 1792151290) == 305159546)? 1: -1];
int main()
{
;
return 0;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/man/make_man_page.py | #!/usr/bin/env python
# Creates a man page from a C file.
# first argument if present is path to cmark dynamic library
# Comments beginning with `/**` are treated as Groff man, except that
# 'this' is converted to \fIthis\f[], and ''this'' to \fBthis\f[].
# Non-blank lines immediately following a man page comment are treated
# as function signatures or examples and parsed into .Ft, .Fo, .Fa, .Fc. The
# immediately preceding man documentation chunk is printed after the example
# as a comment on it.
# That's about it!
import sys, re, os, platform
from datetime import date
from ctypes import CDLL, c_char_p, c_long, c_void_p
sysname = platform.system()
if sysname == 'Darwin':
cmark = CDLL("build/src/libcmark-gfm.dylib")
else:
cmark = CDLL("build/src/libcmark-gfm.so")
parse_document = cmark.cmark_parse_document
parse_document.restype = c_void_p
parse_document.argtypes = [c_char_p, c_long]
render_man = cmark.cmark_render_man
render_man.restype = c_char_p
render_man.argtypes = [c_void_p, c_long, c_long]
def md2man(text):
if sys.version_info >= (3,0):
textbytes = text.encode('utf-8')
textlen = len(textbytes)
return render_man(parse_document(textbytes, textlen), 0, 65).decode('utf-8')
else:
textbytes = text
textlen = len(text)
return render_man(parse_document(textbytes, textlen), 0, 72)
comment_start_re = re.compile('^\/\*\* ?')
comment_delim_re = re.compile('^[/ ]\** ?')
comment_end_re = re.compile('^ \**\/')
function_re = re.compile('^ *(?:CMARK_GFM_EXPORT\s+)?(?P<type>(?:const\s+)?\w+(?:\s*[*])?)\s*(?P<name>\w+)\s*\((?P<args>[^)]*)\)')
blank_re = re.compile('^\s*$')
macro_re = re.compile('CMARK_GFM_EXPORT *')
typedef_start_re = re.compile('typedef.*{$')
typedef_end_re = re.compile('}')
single_quote_re = re.compile("(?<!\w)'([^']+)'(?!\w)")
double_quote_re = re.compile("(?<!\w)''([^']+)''(?!\w)")
def handle_quotes(s):
return re.sub(double_quote_re, '**\g<1>**', re.sub(single_quote_re, '*\g<1>*', s))
typedef = False
mdlines = []
chunk = []
sig = []
if len(sys.argv) > 1:
sourcefile = sys.argv[1]
else:
print("Usage: make_man_page.py sourcefile")
exit(1)
with open(sourcefile, 'r') as cmarkh:
state = 'default'
for line in cmarkh:
# state transition
oldstate = state
if comment_start_re.match(line):
state = 'man'
elif comment_end_re.match(line) and state == 'man':
continue
elif comment_delim_re.match(line) and state == 'man':
state = 'man'
elif not typedef and blank_re.match(line):
state = 'default'
elif typedef and typedef_end_re.match(line):
typedef = False
elif typedef_start_re.match(line):
typedef = True
state = 'signature'
elif state == 'man':
state = 'signature'
# handle line
if state == 'man':
chunk.append(handle_quotes(re.sub(comment_delim_re, '', line)))
elif state == 'signature':
ln = re.sub(macro_re, '', line)
if typedef or not re.match(blank_re, ln):
sig.append(ln)
elif oldstate == 'signature' and state != 'signature':
if len(mdlines) > 0 and mdlines[-1] != '\n':
mdlines.append('\n')
rawsig = ''.join(sig)
m = function_re.match(rawsig)
mdlines.append('.PP\n')
if m:
mdlines.append('\\fI' + m.group('type') + '\\f[]' + ' ')
mdlines.append('\\fB' + m.group('name') + '\\f[]' + '(')
first = True
for argument in re.split(',', m.group('args')):
if not first:
mdlines.append(', ')
first = False
mdlines.append('\\fI' + argument.strip() + '\\f[]')
mdlines.append(')\n')
else:
mdlines.append('.nf\n\\fC\n.RS 0n\n')
mdlines += sig
mdlines.append('.RE\n\\f[]\n.fi\n')
if len(mdlines) > 0 and mdlines[-1] != '\n':
mdlines.append('\n')
mdlines += md2man(''.join(chunk))
mdlines.append('\n')
chunk = []
sig = []
elif oldstate == 'man' and state != 'signature':
if len(mdlines) > 0 and mdlines[-1] != '\n':
mdlines.append('\n')
mdlines += md2man(''.join(chunk)) # add man chunk
chunk = []
mdlines.append('\n')
sys.stdout.write('.TH cmark-gfm 3 "' + date.today().strftime('%B %d, %Y') + '" "LOCAL" "Library Functions Manual"\n')
sys.stdout.write(''.join(mdlines))
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/man/CMakeLists.txt | if (NOT MSVC)
include(GNUInstallDirs)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/man1/cmark-gfm.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/man3/cmark-gfm.3
DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
endif(NOT MSVC)
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/data/CaseFolding.txt | # CaseFolding-9.0.0.txt
# Date: 2016-03-02, 18:54:54 GMT
# © 2016 Unicode®, Inc.
# Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries.
# For terms of use, see http://www.unicode.org/terms_of_use.html
#
# Unicode Character Database
# For documentation, see http://www.unicode.org/reports/tr44/
#
# Case Folding Properties
#
# This file is a supplement to the UnicodeData file.
# It provides a case folding mapping generated from the Unicode Character Database.
# If all characters are mapped according to the full mapping below, then
# case differences (according to UnicodeData.txt and SpecialCasing.txt)
# are eliminated.
#
# The data supports both implementations that require simple case foldings
# (where string lengths don't change), and implementations that allow full case folding
# (where string lengths may grow). Note that where they can be supported, the
# full case foldings are superior: for example, they allow "MASSE" and "Maße" to match.
#
# All code points not listed in this file map to themselves.
#
# NOTE: case folding does not preserve normalization formats!
#
# For information on case folding, including how to have case folding
# preserve normalization formats, see Section 3.13 Default Case Algorithms in
# The Unicode Standard.
#
# ================================================================================
# Format
# ================================================================================
# The entries in this file are in the following machine-readable format:
#
# <code>; <status>; <mapping>; # <name>
#
# The status field is:
# C: common case folding, common mappings shared by both simple and full mappings.
# F: full case folding, mappings that cause strings to grow in length. Multiple characters are separated by spaces.
# S: simple case folding, mappings to single characters where different from F.
# T: special case for uppercase I and dotted uppercase I
# - For non-Turkic languages, this mapping is normally not used.
# - For Turkic languages (tr, az), this mapping can be used instead of the normal mapping for these characters.
# Note that the Turkic mappings do not maintain canonical equivalence without additional processing.
# See the discussions of case mapping in the Unicode Standard for more information.
#
# Usage:
# A. To do a simple case folding, use the mappings with status C + S.
# B. To do a full case folding, use the mappings with status C + F.
#
# The mappings with status T can be used or omitted depending on the desired case-folding
# behavior. (The default option is to exclude them.)
#
# =================================================================
# Property: Case_Folding
# All code points not explicitly listed for Case_Folding
# have the value C for the status field, and the code point itself for the mapping field.
# =================================================================
0041; C; 0061; # LATIN CAPITAL LETTER A
0042; C; 0062; # LATIN CAPITAL LETTER B
0043; C; 0063; # LATIN CAPITAL LETTER C
0044; C; 0064; # LATIN CAPITAL LETTER D
0045; C; 0065; # LATIN CAPITAL LETTER E
0046; C; 0066; # LATIN CAPITAL LETTER F
0047; C; 0067; # LATIN CAPITAL LETTER G
0048; C; 0068; # LATIN CAPITAL LETTER H
0049; C; 0069; # LATIN CAPITAL LETTER I
0049; T; 0131; # LATIN CAPITAL LETTER I
004A; C; 006A; # LATIN CAPITAL LETTER J
004B; C; 006B; # LATIN CAPITAL LETTER K
004C; C; 006C; # LATIN CAPITAL LETTER L
004D; C; 006D; # LATIN CAPITAL LETTER M
004E; C; 006E; # LATIN CAPITAL LETTER N
004F; C; 006F; # LATIN CAPITAL LETTER O
0050; C; 0070; # LATIN CAPITAL LETTER P
0051; C; 0071; # LATIN CAPITAL LETTER Q
0052; C; 0072; # LATIN CAPITAL LETTER R
0053; C; 0073; # LATIN CAPITAL LETTER S
0054; C; 0074; # LATIN CAPITAL LETTER T
0055; C; 0075; # LATIN CAPITAL LETTER U
0056; C; 0076; # LATIN CAPITAL LETTER V
0057; C; 0077; # LATIN CAPITAL LETTER W
0058; C; 0078; # LATIN CAPITAL LETTER X
0059; C; 0079; # LATIN CAPITAL LETTER Y
005A; C; 007A; # LATIN CAPITAL LETTER Z
00B5; C; 03BC; # MICRO SIGN
00C0; C; 00E0; # LATIN CAPITAL LETTER A WITH GRAVE
00C1; C; 00E1; # LATIN CAPITAL LETTER A WITH ACUTE
00C2; C; 00E2; # LATIN CAPITAL LETTER A WITH CIRCUMFLEX
00C3; C; 00E3; # LATIN CAPITAL LETTER A WITH TILDE
00C4; C; 00E4; # LATIN CAPITAL LETTER A WITH DIAERESIS
00C5; C; 00E5; # LATIN CAPITAL LETTER A WITH RING ABOVE
00C6; C; 00E6; # LATIN CAPITAL LETTER AE
00C7; C; 00E7; # LATIN CAPITAL LETTER C WITH CEDILLA
00C8; C; 00E8; # LATIN CAPITAL LETTER E WITH GRAVE
00C9; C; 00E9; # LATIN CAPITAL LETTER E WITH ACUTE
00CA; C; 00EA; # LATIN CAPITAL LETTER E WITH CIRCUMFLEX
00CB; C; 00EB; # LATIN CAPITAL LETTER E WITH DIAERESIS
00CC; C; 00EC; # LATIN CAPITAL LETTER I WITH GRAVE
00CD; C; 00ED; # LATIN CAPITAL LETTER I WITH ACUTE
00CE; C; 00EE; # LATIN CAPITAL LETTER I WITH CIRCUMFLEX
00CF; C; 00EF; # LATIN CAPITAL LETTER I WITH DIAERESIS
00D0; C; 00F0; # LATIN CAPITAL LETTER ETH
00D1; C; 00F1; # LATIN CAPITAL LETTER N WITH TILDE
00D2; C; 00F2; # LATIN CAPITAL LETTER O WITH GRAVE
00D3; C; 00F3; # LATIN CAPITAL LETTER O WITH ACUTE
00D4; C; 00F4; # LATIN CAPITAL LETTER O WITH CIRCUMFLEX
00D5; C; 00F5; # LATIN CAPITAL LETTER O WITH TILDE
00D6; C; 00F6; # LATIN CAPITAL LETTER O WITH DIAERESIS
00D8; C; 00F8; # LATIN CAPITAL LETTER O WITH STROKE
00D9; C; 00F9; # LATIN CAPITAL LETTER U WITH GRAVE
00DA; C; 00FA; # LATIN CAPITAL LETTER U WITH ACUTE
00DB; C; 00FB; # LATIN CAPITAL LETTER U WITH CIRCUMFLEX
00DC; C; 00FC; # LATIN CAPITAL LETTER U WITH DIAERESIS
00DD; C; 00FD; # LATIN CAPITAL LETTER Y WITH ACUTE
00DE; C; 00FE; # LATIN CAPITAL LETTER THORN
00DF; F; 0073 0073; # LATIN SMALL LETTER SHARP S
0100; C; 0101; # LATIN CAPITAL LETTER A WITH MACRON
0102; C; 0103; # LATIN CAPITAL LETTER A WITH BREVE
0104; C; 0105; # LATIN CAPITAL LETTER A WITH OGONEK
0106; C; 0107; # LATIN CAPITAL LETTER C WITH ACUTE
0108; C; 0109; # LATIN CAPITAL LETTER C WITH CIRCUMFLEX
010A; C; 010B; # LATIN CAPITAL LETTER C WITH DOT ABOVE
010C; C; 010D; # LATIN CAPITAL LETTER C WITH CARON
010E; C; 010F; # LATIN CAPITAL LETTER D WITH CARON
0110; C; 0111; # LATIN CAPITAL LETTER D WITH STROKE
0112; C; 0113; # LATIN CAPITAL LETTER E WITH MACRON
0114; C; 0115; # LATIN CAPITAL LETTER E WITH BREVE
0116; C; 0117; # LATIN CAPITAL LETTER E WITH DOT ABOVE
0118; C; 0119; # LATIN CAPITAL LETTER E WITH OGONEK
011A; C; 011B; # LATIN CAPITAL LETTER E WITH CARON
011C; C; 011D; # LATIN CAPITAL LETTER G WITH CIRCUMFLEX
011E; C; 011F; # LATIN CAPITAL LETTER G WITH BREVE
0120; C; 0121; # LATIN CAPITAL LETTER G WITH DOT ABOVE
0122; C; 0123; # LATIN CAPITAL LETTER G WITH CEDILLA
0124; C; 0125; # LATIN CAPITAL LETTER H WITH CIRCUMFLEX
0126; C; 0127; # LATIN CAPITAL LETTER H WITH STROKE
0128; C; 0129; # LATIN CAPITAL LETTER I WITH TILDE
012A; C; 012B; # LATIN CAPITAL LETTER I WITH MACRON
012C; C; 012D; # LATIN CAPITAL LETTER I WITH BREVE
012E; C; 012F; # LATIN CAPITAL LETTER I WITH OGONEK
0130; F; 0069 0307; # LATIN CAPITAL LETTER I WITH DOT ABOVE
0130; T; 0069; # LATIN CAPITAL LETTER I WITH DOT ABOVE
0132; C; 0133; # LATIN CAPITAL LIGATURE IJ
0134; C; 0135; # LATIN CAPITAL LETTER J WITH CIRCUMFLEX
0136; C; 0137; # LATIN CAPITAL LETTER K WITH CEDILLA
0139; C; 013A; # LATIN CAPITAL LETTER L WITH ACUTE
013B; C; 013C; # LATIN CAPITAL LETTER L WITH CEDILLA
013D; C; 013E; # LATIN CAPITAL LETTER L WITH CARON
013F; C; 0140; # LATIN CAPITAL LETTER L WITH MIDDLE DOT
0141; C; 0142; # LATIN CAPITAL LETTER L WITH STROKE
0143; C; 0144; # LATIN CAPITAL LETTER N WITH ACUTE
0145; C; 0146; # LATIN CAPITAL LETTER N WITH CEDILLA
0147; C; 0148; # LATIN CAPITAL LETTER N WITH CARON
0149; F; 02BC 006E; # LATIN SMALL LETTER N PRECEDED BY APOSTROPHE
014A; C; 014B; # LATIN CAPITAL LETTER ENG
014C; C; 014D; # LATIN CAPITAL LETTER O WITH MACRON
014E; C; 014F; # LATIN CAPITAL LETTER O WITH BREVE
0150; C; 0151; # LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
0152; C; 0153; # LATIN CAPITAL LIGATURE OE
0154; C; 0155; # LATIN CAPITAL LETTER R WITH ACUTE
0156; C; 0157; # LATIN CAPITAL LETTER R WITH CEDILLA
0158; C; 0159; # LATIN CAPITAL LETTER R WITH CARON
015A; C; 015B; # LATIN CAPITAL LETTER S WITH ACUTE
015C; C; 015D; # LATIN CAPITAL LETTER S WITH CIRCUMFLEX
015E; C; 015F; # LATIN CAPITAL LETTER S WITH CEDILLA
0160; C; 0161; # LATIN CAPITAL LETTER S WITH CARON
0162; C; 0163; # LATIN CAPITAL LETTER T WITH CEDILLA
0164; C; 0165; # LATIN CAPITAL LETTER T WITH CARON
0166; C; 0167; # LATIN CAPITAL LETTER T WITH STROKE
0168; C; 0169; # LATIN CAPITAL LETTER U WITH TILDE
016A; C; 016B; # LATIN CAPITAL LETTER U WITH MACRON
016C; C; 016D; # LATIN CAPITAL LETTER U WITH BREVE
016E; C; 016F; # LATIN CAPITAL LETTER U WITH RING ABOVE
0170; C; 0171; # LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
0172; C; 0173; # LATIN CAPITAL LETTER U WITH OGONEK
0174; C; 0175; # LATIN CAPITAL LETTER W WITH CIRCUMFLEX
0176; C; 0177; # LATIN CAPITAL LETTER Y WITH CIRCUMFLEX
0178; C; 00FF; # LATIN CAPITAL LETTER Y WITH DIAERESIS
0179; C; 017A; # LATIN CAPITAL LETTER Z WITH ACUTE
017B; C; 017C; # LATIN CAPITAL LETTER Z WITH DOT ABOVE
017D; C; 017E; # LATIN CAPITAL LETTER Z WITH CARON
017F; C; 0073; # LATIN SMALL LETTER LONG S
0181; C; 0253; # LATIN CAPITAL LETTER B WITH HOOK
0182; C; 0183; # LATIN CAPITAL LETTER B WITH TOPBAR
0184; C; 0185; # LATIN CAPITAL LETTER TONE SIX
0186; C; 0254; # LATIN CAPITAL LETTER OPEN O
0187; C; 0188; # LATIN CAPITAL LETTER C WITH HOOK
0189; C; 0256; # LATIN CAPITAL LETTER AFRICAN D
018A; C; 0257; # LATIN CAPITAL LETTER D WITH HOOK
018B; C; 018C; # LATIN CAPITAL LETTER D WITH TOPBAR
018E; C; 01DD; # LATIN CAPITAL LETTER REVERSED E
018F; C; 0259; # LATIN CAPITAL LETTER SCHWA
0190; C; 025B; # LATIN CAPITAL LETTER OPEN E
0191; C; 0192; # LATIN CAPITAL LETTER F WITH HOOK
0193; C; 0260; # LATIN CAPITAL LETTER G WITH HOOK
0194; C; 0263; # LATIN CAPITAL LETTER GAMMA
0196; C; 0269; # LATIN CAPITAL LETTER IOTA
0197; C; 0268; # LATIN CAPITAL LETTER I WITH STROKE
0198; C; 0199; # LATIN CAPITAL LETTER K WITH HOOK
019C; C; 026F; # LATIN CAPITAL LETTER TURNED M
019D; C; 0272; # LATIN CAPITAL LETTER N WITH LEFT HOOK
019F; C; 0275; # LATIN CAPITAL LETTER O WITH MIDDLE TILDE
01A0; C; 01A1; # LATIN CAPITAL LETTER O WITH HORN
01A2; C; 01A3; # LATIN CAPITAL LETTER OI
01A4; C; 01A5; # LATIN CAPITAL LETTER P WITH HOOK
01A6; C; 0280; # LATIN LETTER YR
01A7; C; 01A8; # LATIN CAPITAL LETTER TONE TWO
01A9; C; 0283; # LATIN CAPITAL LETTER ESH
01AC; C; 01AD; # LATIN CAPITAL LETTER T WITH HOOK
01AE; C; 0288; # LATIN CAPITAL LETTER T WITH RETROFLEX HOOK
01AF; C; 01B0; # LATIN CAPITAL LETTER U WITH HORN
01B1; C; 028A; # LATIN CAPITAL LETTER UPSILON
01B2; C; 028B; # LATIN CAPITAL LETTER V WITH HOOK
01B3; C; 01B4; # LATIN CAPITAL LETTER Y WITH HOOK
01B5; C; 01B6; # LATIN CAPITAL LETTER Z WITH STROKE
01B7; C; 0292; # LATIN CAPITAL LETTER EZH
01B8; C; 01B9; # LATIN CAPITAL LETTER EZH REVERSED
01BC; C; 01BD; # LATIN CAPITAL LETTER TONE FIVE
01C4; C; 01C6; # LATIN CAPITAL LETTER DZ WITH CARON
01C5; C; 01C6; # LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON
01C7; C; 01C9; # LATIN CAPITAL LETTER LJ
01C8; C; 01C9; # LATIN CAPITAL LETTER L WITH SMALL LETTER J
01CA; C; 01CC; # LATIN CAPITAL LETTER NJ
01CB; C; 01CC; # LATIN CAPITAL LETTER N WITH SMALL LETTER J
01CD; C; 01CE; # LATIN CAPITAL LETTER A WITH CARON
01CF; C; 01D0; # LATIN CAPITAL LETTER I WITH CARON
01D1; C; 01D2; # LATIN CAPITAL LETTER O WITH CARON
01D3; C; 01D4; # LATIN CAPITAL LETTER U WITH CARON
01D5; C; 01D6; # LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON
01D7; C; 01D8; # LATIN CAPITAL LETTER U WITH DIAERESIS AND ACUTE
01D9; C; 01DA; # LATIN CAPITAL LETTER U WITH DIAERESIS AND CARON
01DB; C; 01DC; # LATIN CAPITAL LETTER U WITH DIAERESIS AND GRAVE
01DE; C; 01DF; # LATIN CAPITAL LETTER A WITH DIAERESIS AND MACRON
01E0; C; 01E1; # LATIN CAPITAL LETTER A WITH DOT ABOVE AND MACRON
01E2; C; 01E3; # LATIN CAPITAL LETTER AE WITH MACRON
01E4; C; 01E5; # LATIN CAPITAL LETTER G WITH STROKE
01E6; C; 01E7; # LATIN CAPITAL LETTER G WITH CARON
01E8; C; 01E9; # LATIN CAPITAL LETTER K WITH CARON
01EA; C; 01EB; # LATIN CAPITAL LETTER O WITH OGONEK
01EC; C; 01ED; # LATIN CAPITAL LETTER O WITH OGONEK AND MACRON
01EE; C; 01EF; # LATIN CAPITAL LETTER EZH WITH CARON
01F0; F; 006A 030C; # LATIN SMALL LETTER J WITH CARON
01F1; C; 01F3; # LATIN CAPITAL LETTER DZ
01F2; C; 01F3; # LATIN CAPITAL LETTER D WITH SMALL LETTER Z
01F4; C; 01F5; # LATIN CAPITAL LETTER G WITH ACUTE
01F6; C; 0195; # LATIN CAPITAL LETTER HWAIR
01F7; C; 01BF; # LATIN CAPITAL LETTER WYNN
01F8; C; 01F9; # LATIN CAPITAL LETTER N WITH GRAVE
01FA; C; 01FB; # LATIN CAPITAL LETTER A WITH RING ABOVE AND ACUTE
01FC; C; 01FD; # LATIN CAPITAL LETTER AE WITH ACUTE
01FE; C; 01FF; # LATIN CAPITAL LETTER O WITH STROKE AND ACUTE
0200; C; 0201; # LATIN CAPITAL LETTER A WITH DOUBLE GRAVE
0202; C; 0203; # LATIN CAPITAL LETTER A WITH INVERTED BREVE
0204; C; 0205; # LATIN CAPITAL LETTER E WITH DOUBLE GRAVE
0206; C; 0207; # LATIN CAPITAL LETTER E WITH INVERTED BREVE
0208; C; 0209; # LATIN CAPITAL LETTER I WITH DOUBLE GRAVE
020A; C; 020B; # LATIN CAPITAL LETTER I WITH INVERTED BREVE
020C; C; 020D; # LATIN CAPITAL LETTER O WITH DOUBLE GRAVE
020E; C; 020F; # LATIN CAPITAL LETTER O WITH INVERTED BREVE
0210; C; 0211; # LATIN CAPITAL LETTER R WITH DOUBLE GRAVE
0212; C; 0213; # LATIN CAPITAL LETTER R WITH INVERTED BREVE
0214; C; 0215; # LATIN CAPITAL LETTER U WITH DOUBLE GRAVE
0216; C; 0217; # LATIN CAPITAL LETTER U WITH INVERTED BREVE
0218; C; 0219; # LATIN CAPITAL LETTER S WITH COMMA BELOW
021A; C; 021B; # LATIN CAPITAL LETTER T WITH COMMA BELOW
021C; C; 021D; # LATIN CAPITAL LETTER YOGH
021E; C; 021F; # LATIN CAPITAL LETTER H WITH CARON
0220; C; 019E; # LATIN CAPITAL LETTER N WITH LONG RIGHT LEG
0222; C; 0223; # LATIN CAPITAL LETTER OU
0224; C; 0225; # LATIN CAPITAL LETTER Z WITH HOOK
0226; C; 0227; # LATIN CAPITAL LETTER A WITH DOT ABOVE
0228; C; 0229; # LATIN CAPITAL LETTER E WITH CEDILLA
022A; C; 022B; # LATIN CAPITAL LETTER O WITH DIAERESIS AND MACRON
022C; C; 022D; # LATIN CAPITAL LETTER O WITH TILDE AND MACRON
022E; C; 022F; # LATIN CAPITAL LETTER O WITH DOT ABOVE
0230; C; 0231; # LATIN CAPITAL LETTER O WITH DOT ABOVE AND MACRON
0232; C; 0233; # LATIN CAPITAL LETTER Y WITH MACRON
023A; C; 2C65; # LATIN CAPITAL LETTER A WITH STROKE
023B; C; 023C; # LATIN CAPITAL LETTER C WITH STROKE
023D; C; 019A; # LATIN CAPITAL LETTER L WITH BAR
023E; C; 2C66; # LATIN CAPITAL LETTER T WITH DIAGONAL STROKE
0241; C; 0242; # LATIN CAPITAL LETTER GLOTTAL STOP
0243; C; 0180; # LATIN CAPITAL LETTER B WITH STROKE
0244; C; 0289; # LATIN CAPITAL LETTER U BAR
0245; C; 028C; # LATIN CAPITAL LETTER TURNED V
0246; C; 0247; # LATIN CAPITAL LETTER E WITH STROKE
0248; C; 0249; # LATIN CAPITAL LETTER J WITH STROKE
024A; C; 024B; # LATIN CAPITAL LETTER SMALL Q WITH HOOK TAIL
024C; C; 024D; # LATIN CAPITAL LETTER R WITH STROKE
024E; C; 024F; # LATIN CAPITAL LETTER Y WITH STROKE
0345; C; 03B9; # COMBINING GREEK YPOGEGRAMMENI
0370; C; 0371; # GREEK CAPITAL LETTER HETA
0372; C; 0373; # GREEK CAPITAL LETTER ARCHAIC SAMPI
0376; C; 0377; # GREEK CAPITAL LETTER PAMPHYLIAN DIGAMMA
037F; C; 03F3; # GREEK CAPITAL LETTER YOT
0386; C; 03AC; # GREEK CAPITAL LETTER ALPHA WITH TONOS
0388; C; 03AD; # GREEK CAPITAL LETTER EPSILON WITH TONOS
0389; C; 03AE; # GREEK CAPITAL LETTER ETA WITH TONOS
038A; C; 03AF; # GREEK CAPITAL LETTER IOTA WITH TONOS
038C; C; 03CC; # GREEK CAPITAL LETTER OMICRON WITH TONOS
038E; C; 03CD; # GREEK CAPITAL LETTER UPSILON WITH TONOS
038F; C; 03CE; # GREEK CAPITAL LETTER OMEGA WITH TONOS
0390; F; 03B9 0308 0301; # GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
0391; C; 03B1; # GREEK CAPITAL LETTER ALPHA
0392; C; 03B2; # GREEK CAPITAL LETTER BETA
0393; C; 03B3; # GREEK CAPITAL LETTER GAMMA
0394; C; 03B4; # GREEK CAPITAL LETTER DELTA
0395; C; 03B5; # GREEK CAPITAL LETTER EPSILON
0396; C; 03B6; # GREEK CAPITAL LETTER ZETA
0397; C; 03B7; # GREEK CAPITAL LETTER ETA
0398; C; 03B8; # GREEK CAPITAL LETTER THETA
0399; C; 03B9; # GREEK CAPITAL LETTER IOTA
039A; C; 03BA; # GREEK CAPITAL LETTER KAPPA
039B; C; 03BB; # GREEK CAPITAL LETTER LAMDA
039C; C; 03BC; # GREEK CAPITAL LETTER MU
039D; C; 03BD; # GREEK CAPITAL LETTER NU
039E; C; 03BE; # GREEK CAPITAL LETTER XI
039F; C; 03BF; # GREEK CAPITAL LETTER OMICRON
03A0; C; 03C0; # GREEK CAPITAL LETTER PI
03A1; C; 03C1; # GREEK CAPITAL LETTER RHO
03A3; C; 03C3; # GREEK CAPITAL LETTER SIGMA
03A4; C; 03C4; # GREEK CAPITAL LETTER TAU
03A5; C; 03C5; # GREEK CAPITAL LETTER UPSILON
03A6; C; 03C6; # GREEK CAPITAL LETTER PHI
03A7; C; 03C7; # GREEK CAPITAL LETTER CHI
03A8; C; 03C8; # GREEK CAPITAL LETTER PSI
03A9; C; 03C9; # GREEK CAPITAL LETTER OMEGA
03AA; C; 03CA; # GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
03AB; C; 03CB; # GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
03B0; F; 03C5 0308 0301; # GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
03C2; C; 03C3; # GREEK SMALL LETTER FINAL SIGMA
03CF; C; 03D7; # GREEK CAPITAL KAI SYMBOL
03D0; C; 03B2; # GREEK BETA SYMBOL
03D1; C; 03B8; # GREEK THETA SYMBOL
03D5; C; 03C6; # GREEK PHI SYMBOL
03D6; C; 03C0; # GREEK PI SYMBOL
03D8; C; 03D9; # GREEK LETTER ARCHAIC KOPPA
03DA; C; 03DB; # GREEK LETTER STIGMA
03DC; C; 03DD; # GREEK LETTER DIGAMMA
03DE; C; 03DF; # GREEK LETTER KOPPA
03E0; C; 03E1; # GREEK LETTER SAMPI
03E2; C; 03E3; # COPTIC CAPITAL LETTER SHEI
03E4; C; 03E5; # COPTIC CAPITAL LETTER FEI
03E6; C; 03E7; # COPTIC CAPITAL LETTER KHEI
03E8; C; 03E9; # COPTIC CAPITAL LETTER HORI
03EA; C; 03EB; # COPTIC CAPITAL LETTER GANGIA
03EC; C; 03ED; # COPTIC CAPITAL LETTER SHIMA
03EE; C; 03EF; # COPTIC CAPITAL LETTER DEI
03F0; C; 03BA; # GREEK KAPPA SYMBOL
03F1; C; 03C1; # GREEK RHO SYMBOL
03F4; C; 03B8; # GREEK CAPITAL THETA SYMBOL
03F5; C; 03B5; # GREEK LUNATE EPSILON SYMBOL
03F7; C; 03F8; # GREEK CAPITAL LETTER SHO
03F9; C; 03F2; # GREEK CAPITAL LUNATE SIGMA SYMBOL
03FA; C; 03FB; # GREEK CAPITAL LETTER SAN
03FD; C; 037B; # GREEK CAPITAL REVERSED LUNATE SIGMA SYMBOL
03FE; C; 037C; # GREEK CAPITAL DOTTED LUNATE SIGMA SYMBOL
03FF; C; 037D; # GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL
0400; C; 0450; # CYRILLIC CAPITAL LETTER IE WITH GRAVE
0401; C; 0451; # CYRILLIC CAPITAL LETTER IO
0402; C; 0452; # CYRILLIC CAPITAL LETTER DJE
0403; C; 0453; # CYRILLIC CAPITAL LETTER GJE
0404; C; 0454; # CYRILLIC CAPITAL LETTER UKRAINIAN IE
0405; C; 0455; # CYRILLIC CAPITAL LETTER DZE
0406; C; 0456; # CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
0407; C; 0457; # CYRILLIC CAPITAL LETTER YI
0408; C; 0458; # CYRILLIC CAPITAL LETTER JE
0409; C; 0459; # CYRILLIC CAPITAL LETTER LJE
040A; C; 045A; # CYRILLIC CAPITAL LETTER NJE
040B; C; 045B; # CYRILLIC CAPITAL LETTER TSHE
040C; C; 045C; # CYRILLIC CAPITAL LETTER KJE
040D; C; 045D; # CYRILLIC CAPITAL LETTER I WITH GRAVE
040E; C; 045E; # CYRILLIC CAPITAL LETTER SHORT U
040F; C; 045F; # CYRILLIC CAPITAL LETTER DZHE
0410; C; 0430; # CYRILLIC CAPITAL LETTER A
0411; C; 0431; # CYRILLIC CAPITAL LETTER BE
0412; C; 0432; # CYRILLIC CAPITAL LETTER VE
0413; C; 0433; # CYRILLIC CAPITAL LETTER GHE
0414; C; 0434; # CYRILLIC CAPITAL LETTER DE
0415; C; 0435; # CYRILLIC CAPITAL LETTER IE
0416; C; 0436; # CYRILLIC CAPITAL LETTER ZHE
0417; C; 0437; # CYRILLIC CAPITAL LETTER ZE
0418; C; 0438; # CYRILLIC CAPITAL LETTER I
0419; C; 0439; # CYRILLIC CAPITAL LETTER SHORT I
041A; C; 043A; # CYRILLIC CAPITAL LETTER KA
041B; C; 043B; # CYRILLIC CAPITAL LETTER EL
041C; C; 043C; # CYRILLIC CAPITAL LETTER EM
041D; C; 043D; # CYRILLIC CAPITAL LETTER EN
041E; C; 043E; # CYRILLIC CAPITAL LETTER O
041F; C; 043F; # CYRILLIC CAPITAL LETTER PE
0420; C; 0440; # CYRILLIC CAPITAL LETTER ER
0421; C; 0441; # CYRILLIC CAPITAL LETTER ES
0422; C; 0442; # CYRILLIC CAPITAL LETTER TE
0423; C; 0443; # CYRILLIC CAPITAL LETTER U
0424; C; 0444; # CYRILLIC CAPITAL LETTER EF
0425; C; 0445; # CYRILLIC CAPITAL LETTER HA
0426; C; 0446; # CYRILLIC CAPITAL LETTER TSE
0427; C; 0447; # CYRILLIC CAPITAL LETTER CHE
0428; C; 0448; # CYRILLIC CAPITAL LETTER SHA
0429; C; 0449; # CYRILLIC CAPITAL LETTER SHCHA
042A; C; 044A; # CYRILLIC CAPITAL LETTER HARD SIGN
042B; C; 044B; # CYRILLIC CAPITAL LETTER YERU
042C; C; 044C; # CYRILLIC CAPITAL LETTER SOFT SIGN
042D; C; 044D; # CYRILLIC CAPITAL LETTER E
042E; C; 044E; # CYRILLIC CAPITAL LETTER YU
042F; C; 044F; # CYRILLIC CAPITAL LETTER YA
0460; C; 0461; # CYRILLIC CAPITAL LETTER OMEGA
0462; C; 0463; # CYRILLIC CAPITAL LETTER YAT
0464; C; 0465; # CYRILLIC CAPITAL LETTER IOTIFIED E
0466; C; 0467; # CYRILLIC CAPITAL LETTER LITTLE YUS
0468; C; 0469; # CYRILLIC CAPITAL LETTER IOTIFIED LITTLE YUS
046A; C; 046B; # CYRILLIC CAPITAL LETTER BIG YUS
046C; C; 046D; # CYRILLIC CAPITAL LETTER IOTIFIED BIG YUS
046E; C; 046F; # CYRILLIC CAPITAL LETTER KSI
0470; C; 0471; # CYRILLIC CAPITAL LETTER PSI
0472; C; 0473; # CYRILLIC CAPITAL LETTER FITA
0474; C; 0475; # CYRILLIC CAPITAL LETTER IZHITSA
0476; C; 0477; # CYRILLIC CAPITAL LETTER IZHITSA WITH DOUBLE GRAVE ACCENT
0478; C; 0479; # CYRILLIC CAPITAL LETTER UK
047A; C; 047B; # CYRILLIC CAPITAL LETTER ROUND OMEGA
047C; C; 047D; # CYRILLIC CAPITAL LETTER OMEGA WITH TITLO
047E; C; 047F; # CYRILLIC CAPITAL LETTER OT
0480; C; 0481; # CYRILLIC CAPITAL LETTER KOPPA
048A; C; 048B; # CYRILLIC CAPITAL LETTER SHORT I WITH TAIL
048C; C; 048D; # CYRILLIC CAPITAL LETTER SEMISOFT SIGN
048E; C; 048F; # CYRILLIC CAPITAL LETTER ER WITH TICK
0490; C; 0491; # CYRILLIC CAPITAL LETTER GHE WITH UPTURN
0492; C; 0493; # CYRILLIC CAPITAL LETTER GHE WITH STROKE
0494; C; 0495; # CYRILLIC CAPITAL LETTER GHE WITH MIDDLE HOOK
0496; C; 0497; # CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER
0498; C; 0499; # CYRILLIC CAPITAL LETTER ZE WITH DESCENDER
049A; C; 049B; # CYRILLIC CAPITAL LETTER KA WITH DESCENDER
049C; C; 049D; # CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE
049E; C; 049F; # CYRILLIC CAPITAL LETTER KA WITH STROKE
04A0; C; 04A1; # CYRILLIC CAPITAL LETTER BASHKIR KA
04A2; C; 04A3; # CYRILLIC CAPITAL LETTER EN WITH DESCENDER
04A4; C; 04A5; # CYRILLIC CAPITAL LIGATURE EN GHE
04A6; C; 04A7; # CYRILLIC CAPITAL LETTER PE WITH MIDDLE HOOK
04A8; C; 04A9; # CYRILLIC CAPITAL LETTER ABKHASIAN HA
04AA; C; 04AB; # CYRILLIC CAPITAL LETTER ES WITH DESCENDER
04AC; C; 04AD; # CYRILLIC CAPITAL LETTER TE WITH DESCENDER
04AE; C; 04AF; # CYRILLIC CAPITAL LETTER STRAIGHT U
04B0; C; 04B1; # CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE
04B2; C; 04B3; # CYRILLIC CAPITAL LETTER HA WITH DESCENDER
04B4; C; 04B5; # CYRILLIC CAPITAL LIGATURE TE TSE
04B6; C; 04B7; # CYRILLIC CAPITAL LETTER CHE WITH DESCENDER
04B8; C; 04B9; # CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE
04BA; C; 04BB; # CYRILLIC CAPITAL LETTER SHHA
04BC; C; 04BD; # CYRILLIC CAPITAL LETTER ABKHASIAN CHE
04BE; C; 04BF; # CYRILLIC CAPITAL LETTER ABKHASIAN CHE WITH DESCENDER
04C0; C; 04CF; # CYRILLIC LETTER PALOCHKA
04C1; C; 04C2; # CYRILLIC CAPITAL LETTER ZHE WITH BREVE
04C3; C; 04C4; # CYRILLIC CAPITAL LETTER KA WITH HOOK
04C5; C; 04C6; # CYRILLIC CAPITAL LETTER EL WITH TAIL
04C7; C; 04C8; # CYRILLIC CAPITAL LETTER EN WITH HOOK
04C9; C; 04CA; # CYRILLIC CAPITAL LETTER EN WITH TAIL
04CB; C; 04CC; # CYRILLIC CAPITAL LETTER KHAKASSIAN CHE
04CD; C; 04CE; # CYRILLIC CAPITAL LETTER EM WITH TAIL
04D0; C; 04D1; # CYRILLIC CAPITAL LETTER A WITH BREVE
04D2; C; 04D3; # CYRILLIC CAPITAL LETTER A WITH DIAERESIS
04D4; C; 04D5; # CYRILLIC CAPITAL LIGATURE A IE
04D6; C; 04D7; # CYRILLIC CAPITAL LETTER IE WITH BREVE
04D8; C; 04D9; # CYRILLIC CAPITAL LETTER SCHWA
04DA; C; 04DB; # CYRILLIC CAPITAL LETTER SCHWA WITH DIAERESIS
04DC; C; 04DD; # CYRILLIC CAPITAL LETTER ZHE WITH DIAERESIS
04DE; C; 04DF; # CYRILLIC CAPITAL LETTER ZE WITH DIAERESIS
04E0; C; 04E1; # CYRILLIC CAPITAL LETTER ABKHASIAN DZE
04E2; C; 04E3; # CYRILLIC CAPITAL LETTER I WITH MACRON
04E4; C; 04E5; # CYRILLIC CAPITAL LETTER I WITH DIAERESIS
04E6; C; 04E7; # CYRILLIC CAPITAL LETTER O WITH DIAERESIS
04E8; C; 04E9; # CYRILLIC CAPITAL LETTER BARRED O
04EA; C; 04EB; # CYRILLIC CAPITAL LETTER BARRED O WITH DIAERESIS
04EC; C; 04ED; # CYRILLIC CAPITAL LETTER E WITH DIAERESIS
04EE; C; 04EF; # CYRILLIC CAPITAL LETTER U WITH MACRON
04F0; C; 04F1; # CYRILLIC CAPITAL LETTER U WITH DIAERESIS
04F2; C; 04F3; # CYRILLIC CAPITAL LETTER U WITH DOUBLE ACUTE
04F4; C; 04F5; # CYRILLIC CAPITAL LETTER CHE WITH DIAERESIS
04F6; C; 04F7; # CYRILLIC CAPITAL LETTER GHE WITH DESCENDER
04F8; C; 04F9; # CYRILLIC CAPITAL LETTER YERU WITH DIAERESIS
04FA; C; 04FB; # CYRILLIC CAPITAL LETTER GHE WITH STROKE AND HOOK
04FC; C; 04FD; # CYRILLIC CAPITAL LETTER HA WITH HOOK
04FE; C; 04FF; # CYRILLIC CAPITAL LETTER HA WITH STROKE
0500; C; 0501; # CYRILLIC CAPITAL LETTER KOMI DE
0502; C; 0503; # CYRILLIC CAPITAL LETTER KOMI DJE
0504; C; 0505; # CYRILLIC CAPITAL LETTER KOMI ZJE
0506; C; 0507; # CYRILLIC CAPITAL LETTER KOMI DZJE
0508; C; 0509; # CYRILLIC CAPITAL LETTER KOMI LJE
050A; C; 050B; # CYRILLIC CAPITAL LETTER KOMI NJE
050C; C; 050D; # CYRILLIC CAPITAL LETTER KOMI SJE
050E; C; 050F; # CYRILLIC CAPITAL LETTER KOMI TJE
0510; C; 0511; # CYRILLIC CAPITAL LETTER REVERSED ZE
0512; C; 0513; # CYRILLIC CAPITAL LETTER EL WITH HOOK
0514; C; 0515; # CYRILLIC CAPITAL LETTER LHA
0516; C; 0517; # CYRILLIC CAPITAL LETTER RHA
0518; C; 0519; # CYRILLIC CAPITAL LETTER YAE
051A; C; 051B; # CYRILLIC CAPITAL LETTER QA
051C; C; 051D; # CYRILLIC CAPITAL LETTER WE
051E; C; 051F; # CYRILLIC CAPITAL LETTER ALEUT KA
0520; C; 0521; # CYRILLIC CAPITAL LETTER EL WITH MIDDLE HOOK
0522; C; 0523; # CYRILLIC CAPITAL LETTER EN WITH MIDDLE HOOK
0524; C; 0525; # CYRILLIC CAPITAL LETTER PE WITH DESCENDER
0526; C; 0527; # CYRILLIC CAPITAL LETTER SHHA WITH DESCENDER
0528; C; 0529; # CYRILLIC CAPITAL LETTER EN WITH LEFT HOOK
052A; C; 052B; # CYRILLIC CAPITAL LETTER DZZHE
052C; C; 052D; # CYRILLIC CAPITAL LETTER DCHE
052E; C; 052F; # CYRILLIC CAPITAL LETTER EL WITH DESCENDER
0531; C; 0561; # ARMENIAN CAPITAL LETTER AYB
0532; C; 0562; # ARMENIAN CAPITAL LETTER BEN
0533; C; 0563; # ARMENIAN CAPITAL LETTER GIM
0534; C; 0564; # ARMENIAN CAPITAL LETTER DA
0535; C; 0565; # ARMENIAN CAPITAL LETTER ECH
0536; C; 0566; # ARMENIAN CAPITAL LETTER ZA
0537; C; 0567; # ARMENIAN CAPITAL LETTER EH
0538; C; 0568; # ARMENIAN CAPITAL LETTER ET
0539; C; 0569; # ARMENIAN CAPITAL LETTER TO
053A; C; 056A; # ARMENIAN CAPITAL LETTER ZHE
053B; C; 056B; # ARMENIAN CAPITAL LETTER INI
053C; C; 056C; # ARMENIAN CAPITAL LETTER LIWN
053D; C; 056D; # ARMENIAN CAPITAL LETTER XEH
053E; C; 056E; # ARMENIAN CAPITAL LETTER CA
053F; C; 056F; # ARMENIAN CAPITAL LETTER KEN
0540; C; 0570; # ARMENIAN CAPITAL LETTER HO
0541; C; 0571; # ARMENIAN CAPITAL LETTER JA
0542; C; 0572; # ARMENIAN CAPITAL LETTER GHAD
0543; C; 0573; # ARMENIAN CAPITAL LETTER CHEH
0544; C; 0574; # ARMENIAN CAPITAL LETTER MEN
0545; C; 0575; # ARMENIAN CAPITAL LETTER YI
0546; C; 0576; # ARMENIAN CAPITAL LETTER NOW
0547; C; 0577; # ARMENIAN CAPITAL LETTER SHA
0548; C; 0578; # ARMENIAN CAPITAL LETTER VO
0549; C; 0579; # ARMENIAN CAPITAL LETTER CHA
054A; C; 057A; # ARMENIAN CAPITAL LETTER PEH
054B; C; 057B; # ARMENIAN CAPITAL LETTER JHEH
054C; C; 057C; # ARMENIAN CAPITAL LETTER RA
054D; C; 057D; # ARMENIAN CAPITAL LETTER SEH
054E; C; 057E; # ARMENIAN CAPITAL LETTER VEW
054F; C; 057F; # ARMENIAN CAPITAL LETTER TIWN
0550; C; 0580; # ARMENIAN CAPITAL LETTER REH
0551; C; 0581; # ARMENIAN CAPITAL LETTER CO
0552; C; 0582; # ARMENIAN CAPITAL LETTER YIWN
0553; C; 0583; # ARMENIAN CAPITAL LETTER PIWR
0554; C; 0584; # ARMENIAN CAPITAL LETTER KEH
0555; C; 0585; # ARMENIAN CAPITAL LETTER OH
0556; C; 0586; # ARMENIAN CAPITAL LETTER FEH
0587; F; 0565 0582; # ARMENIAN SMALL LIGATURE ECH YIWN
10A0; C; 2D00; # GEORGIAN CAPITAL LETTER AN
10A1; C; 2D01; # GEORGIAN CAPITAL LETTER BAN
10A2; C; 2D02; # GEORGIAN CAPITAL LETTER GAN
10A3; C; 2D03; # GEORGIAN CAPITAL LETTER DON
10A4; C; 2D04; # GEORGIAN CAPITAL LETTER EN
10A5; C; 2D05; # GEORGIAN CAPITAL LETTER VIN
10A6; C; 2D06; # GEORGIAN CAPITAL LETTER ZEN
10A7; C; 2D07; # GEORGIAN CAPITAL LETTER TAN
10A8; C; 2D08; # GEORGIAN CAPITAL LETTER IN
10A9; C; 2D09; # GEORGIAN CAPITAL LETTER KAN
10AA; C; 2D0A; # GEORGIAN CAPITAL LETTER LAS
10AB; C; 2D0B; # GEORGIAN CAPITAL LETTER MAN
10AC; C; 2D0C; # GEORGIAN CAPITAL LETTER NAR
10AD; C; 2D0D; # GEORGIAN CAPITAL LETTER ON
10AE; C; 2D0E; # GEORGIAN CAPITAL LETTER PAR
10AF; C; 2D0F; # GEORGIAN CAPITAL LETTER ZHAR
10B0; C; 2D10; # GEORGIAN CAPITAL LETTER RAE
10B1; C; 2D11; # GEORGIAN CAPITAL LETTER SAN
10B2; C; 2D12; # GEORGIAN CAPITAL LETTER TAR
10B3; C; 2D13; # GEORGIAN CAPITAL LETTER UN
10B4; C; 2D14; # GEORGIAN CAPITAL LETTER PHAR
10B5; C; 2D15; # GEORGIAN CAPITAL LETTER KHAR
10B6; C; 2D16; # GEORGIAN CAPITAL LETTER GHAN
10B7; C; 2D17; # GEORGIAN CAPITAL LETTER QAR
10B8; C; 2D18; # GEORGIAN CAPITAL LETTER SHIN
10B9; C; 2D19; # GEORGIAN CAPITAL LETTER CHIN
10BA; C; 2D1A; # GEORGIAN CAPITAL LETTER CAN
10BB; C; 2D1B; # GEORGIAN CAPITAL LETTER JIL
10BC; C; 2D1C; # GEORGIAN CAPITAL LETTER CIL
10BD; C; 2D1D; # GEORGIAN CAPITAL LETTER CHAR
10BE; C; 2D1E; # GEORGIAN CAPITAL LETTER XAN
10BF; C; 2D1F; # GEORGIAN CAPITAL LETTER JHAN
10C0; C; 2D20; # GEORGIAN CAPITAL LETTER HAE
10C1; C; 2D21; # GEORGIAN CAPITAL LETTER HE
10C2; C; 2D22; # GEORGIAN CAPITAL LETTER HIE
10C3; C; 2D23; # GEORGIAN CAPITAL LETTER WE
10C4; C; 2D24; # GEORGIAN CAPITAL LETTER HAR
10C5; C; 2D25; # GEORGIAN CAPITAL LETTER HOE
10C7; C; 2D27; # GEORGIAN CAPITAL LETTER YN
10CD; C; 2D2D; # GEORGIAN CAPITAL LETTER AEN
13F8; C; 13F0; # CHEROKEE SMALL LETTER YE
13F9; C; 13F1; # CHEROKEE SMALL LETTER YI
13FA; C; 13F2; # CHEROKEE SMALL LETTER YO
13FB; C; 13F3; # CHEROKEE SMALL LETTER YU
13FC; C; 13F4; # CHEROKEE SMALL LETTER YV
13FD; C; 13F5; # CHEROKEE SMALL LETTER MV
1C80; C; 0432; # CYRILLIC SMALL LETTER ROUNDED VE
1C81; C; 0434; # CYRILLIC SMALL LETTER LONG-LEGGED DE
1C82; C; 043E; # CYRILLIC SMALL LETTER NARROW O
1C83; C; 0441; # CYRILLIC SMALL LETTER WIDE ES
1C84; C; 0442; # CYRILLIC SMALL LETTER TALL TE
1C85; C; 0442; # CYRILLIC SMALL LETTER THREE-LEGGED TE
1C86; C; 044A; # CYRILLIC SMALL LETTER TALL HARD SIGN
1C87; C; 0463; # CYRILLIC SMALL LETTER TALL YAT
1C88; C; A64B; # CYRILLIC SMALL LETTER UNBLENDED UK
1E00; C; 1E01; # LATIN CAPITAL LETTER A WITH RING BELOW
1E02; C; 1E03; # LATIN CAPITAL LETTER B WITH DOT ABOVE
1E04; C; 1E05; # LATIN CAPITAL LETTER B WITH DOT BELOW
1E06; C; 1E07; # LATIN CAPITAL LETTER B WITH LINE BELOW
1E08; C; 1E09; # LATIN CAPITAL LETTER C WITH CEDILLA AND ACUTE
1E0A; C; 1E0B; # LATIN CAPITAL LETTER D WITH DOT ABOVE
1E0C; C; 1E0D; # LATIN CAPITAL LETTER D WITH DOT BELOW
1E0E; C; 1E0F; # LATIN CAPITAL LETTER D WITH LINE BELOW
1E10; C; 1E11; # LATIN CAPITAL LETTER D WITH CEDILLA
1E12; C; 1E13; # LATIN CAPITAL LETTER D WITH CIRCUMFLEX BELOW
1E14; C; 1E15; # LATIN CAPITAL LETTER E WITH MACRON AND GRAVE
1E16; C; 1E17; # LATIN CAPITAL LETTER E WITH MACRON AND ACUTE
1E18; C; 1E19; # LATIN CAPITAL LETTER E WITH CIRCUMFLEX BELOW
1E1A; C; 1E1B; # LATIN CAPITAL LETTER E WITH TILDE BELOW
1E1C; C; 1E1D; # LATIN CAPITAL LETTER E WITH CEDILLA AND BREVE
1E1E; C; 1E1F; # LATIN CAPITAL LETTER F WITH DOT ABOVE
1E20; C; 1E21; # LATIN CAPITAL LETTER G WITH MACRON
1E22; C; 1E23; # LATIN CAPITAL LETTER H WITH DOT ABOVE
1E24; C; 1E25; # LATIN CAPITAL LETTER H WITH DOT BELOW
1E26; C; 1E27; # LATIN CAPITAL LETTER H WITH DIAERESIS
1E28; C; 1E29; # LATIN CAPITAL LETTER H WITH CEDILLA
1E2A; C; 1E2B; # LATIN CAPITAL LETTER H WITH BREVE BELOW
1E2C; C; 1E2D; # LATIN CAPITAL LETTER I WITH TILDE BELOW
1E2E; C; 1E2F; # LATIN CAPITAL LETTER I WITH DIAERESIS AND ACUTE
1E30; C; 1E31; # LATIN CAPITAL LETTER K WITH ACUTE
1E32; C; 1E33; # LATIN CAPITAL LETTER K WITH DOT BELOW
1E34; C; 1E35; # LATIN CAPITAL LETTER K WITH LINE BELOW
1E36; C; 1E37; # LATIN CAPITAL LETTER L WITH DOT BELOW
1E38; C; 1E39; # LATIN CAPITAL LETTER L WITH DOT BELOW AND MACRON
1E3A; C; 1E3B; # LATIN CAPITAL LETTER L WITH LINE BELOW
1E3C; C; 1E3D; # LATIN CAPITAL LETTER L WITH CIRCUMFLEX BELOW
1E3E; C; 1E3F; # LATIN CAPITAL LETTER M WITH ACUTE
1E40; C; 1E41; # LATIN CAPITAL LETTER M WITH DOT ABOVE
1E42; C; 1E43; # LATIN CAPITAL LETTER M WITH DOT BELOW
1E44; C; 1E45; # LATIN CAPITAL LETTER N WITH DOT ABOVE
1E46; C; 1E47; # LATIN CAPITAL LETTER N WITH DOT BELOW
1E48; C; 1E49; # LATIN CAPITAL LETTER N WITH LINE BELOW
1E4A; C; 1E4B; # LATIN CAPITAL LETTER N WITH CIRCUMFLEX BELOW
1E4C; C; 1E4D; # LATIN CAPITAL LETTER O WITH TILDE AND ACUTE
1E4E; C; 1E4F; # LATIN CAPITAL LETTER O WITH TILDE AND DIAERESIS
1E50; C; 1E51; # LATIN CAPITAL LETTER O WITH MACRON AND GRAVE
1E52; C; 1E53; # LATIN CAPITAL LETTER O WITH MACRON AND ACUTE
1E54; C; 1E55; # LATIN CAPITAL LETTER P WITH ACUTE
1E56; C; 1E57; # LATIN CAPITAL LETTER P WITH DOT ABOVE
1E58; C; 1E59; # LATIN CAPITAL LETTER R WITH DOT ABOVE
1E5A; C; 1E5B; # LATIN CAPITAL LETTER R WITH DOT BELOW
1E5C; C; 1E5D; # LATIN CAPITAL LETTER R WITH DOT BELOW AND MACRON
1E5E; C; 1E5F; # LATIN CAPITAL LETTER R WITH LINE BELOW
1E60; C; 1E61; # LATIN CAPITAL LETTER S WITH DOT ABOVE
1E62; C; 1E63; # LATIN CAPITAL LETTER S WITH DOT BELOW
1E64; C; 1E65; # LATIN CAPITAL LETTER S WITH ACUTE AND DOT ABOVE
1E66; C; 1E67; # LATIN CAPITAL LETTER S WITH CARON AND DOT ABOVE
1E68; C; 1E69; # LATIN CAPITAL LETTER S WITH DOT BELOW AND DOT ABOVE
1E6A; C; 1E6B; # LATIN CAPITAL LETTER T WITH DOT ABOVE
1E6C; C; 1E6D; # LATIN CAPITAL LETTER T WITH DOT BELOW
1E6E; C; 1E6F; # LATIN CAPITAL LETTER T WITH LINE BELOW
1E70; C; 1E71; # LATIN CAPITAL LETTER T WITH CIRCUMFLEX BELOW
1E72; C; 1E73; # LATIN CAPITAL LETTER U WITH DIAERESIS BELOW
1E74; C; 1E75; # LATIN CAPITAL LETTER U WITH TILDE BELOW
1E76; C; 1E77; # LATIN CAPITAL LETTER U WITH CIRCUMFLEX BELOW
1E78; C; 1E79; # LATIN CAPITAL LETTER U WITH TILDE AND ACUTE
1E7A; C; 1E7B; # LATIN CAPITAL LETTER U WITH MACRON AND DIAERESIS
1E7C; C; 1E7D; # LATIN CAPITAL LETTER V WITH TILDE
1E7E; C; 1E7F; # LATIN CAPITAL LETTER V WITH DOT BELOW
1E80; C; 1E81; # LATIN CAPITAL LETTER W WITH GRAVE
1E82; C; 1E83; # LATIN CAPITAL LETTER W WITH ACUTE
1E84; C; 1E85; # LATIN CAPITAL LETTER W WITH DIAERESIS
1E86; C; 1E87; # LATIN CAPITAL LETTER W WITH DOT ABOVE
1E88; C; 1E89; # LATIN CAPITAL LETTER W WITH DOT BELOW
1E8A; C; 1E8B; # LATIN CAPITAL LETTER X WITH DOT ABOVE
1E8C; C; 1E8D; # LATIN CAPITAL LETTER X WITH DIAERESIS
1E8E; C; 1E8F; # LATIN CAPITAL LETTER Y WITH DOT ABOVE
1E90; C; 1E91; # LATIN CAPITAL LETTER Z WITH CIRCUMFLEX
1E92; C; 1E93; # LATIN CAPITAL LETTER Z WITH DOT BELOW
1E94; C; 1E95; # LATIN CAPITAL LETTER Z WITH LINE BELOW
1E96; F; 0068 0331; # LATIN SMALL LETTER H WITH LINE BELOW
1E97; F; 0074 0308; # LATIN SMALL LETTER T WITH DIAERESIS
1E98; F; 0077 030A; # LATIN SMALL LETTER W WITH RING ABOVE
1E99; F; 0079 030A; # LATIN SMALL LETTER Y WITH RING ABOVE
1E9A; F; 0061 02BE; # LATIN SMALL LETTER A WITH RIGHT HALF RING
1E9B; C; 1E61; # LATIN SMALL LETTER LONG S WITH DOT ABOVE
1E9E; F; 0073 0073; # LATIN CAPITAL LETTER SHARP S
1E9E; S; 00DF; # LATIN CAPITAL LETTER SHARP S
1EA0; C; 1EA1; # LATIN CAPITAL LETTER A WITH DOT BELOW
1EA2; C; 1EA3; # LATIN CAPITAL LETTER A WITH HOOK ABOVE
1EA4; C; 1EA5; # LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE
1EA6; C; 1EA7; # LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE
1EA8; C; 1EA9; # LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE
1EAA; C; 1EAB; # LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND TILDE
1EAC; C; 1EAD; # LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND DOT BELOW
1EAE; C; 1EAF; # LATIN CAPITAL LETTER A WITH BREVE AND ACUTE
1EB0; C; 1EB1; # LATIN CAPITAL LETTER A WITH BREVE AND GRAVE
1EB2; C; 1EB3; # LATIN CAPITAL LETTER A WITH BREVE AND HOOK ABOVE
1EB4; C; 1EB5; # LATIN CAPITAL LETTER A WITH BREVE AND TILDE
1EB6; C; 1EB7; # LATIN CAPITAL LETTER A WITH BREVE AND DOT BELOW
1EB8; C; 1EB9; # LATIN CAPITAL LETTER E WITH DOT BELOW
1EBA; C; 1EBB; # LATIN CAPITAL LETTER E WITH HOOK ABOVE
1EBC; C; 1EBD; # LATIN CAPITAL LETTER E WITH TILDE
1EBE; C; 1EBF; # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE
1EC0; C; 1EC1; # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE
1EC2; C; 1EC3; # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE
1EC4; C; 1EC5; # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE
1EC6; C; 1EC7; # LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND DOT BELOW
1EC8; C; 1EC9; # LATIN CAPITAL LETTER I WITH HOOK ABOVE
1ECA; C; 1ECB; # LATIN CAPITAL LETTER I WITH DOT BELOW
1ECC; C; 1ECD; # LATIN CAPITAL LETTER O WITH DOT BELOW
1ECE; C; 1ECF; # LATIN CAPITAL LETTER O WITH HOOK ABOVE
1ED0; C; 1ED1; # LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE
1ED2; C; 1ED3; # LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND GRAVE
1ED4; C; 1ED5; # LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE
1ED6; C; 1ED7; # LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE
1ED8; C; 1ED9; # LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND DOT BELOW
1EDA; C; 1EDB; # LATIN CAPITAL LETTER O WITH HORN AND ACUTE
1EDC; C; 1EDD; # LATIN CAPITAL LETTER O WITH HORN AND GRAVE
1EDE; C; 1EDF; # LATIN CAPITAL LETTER O WITH HORN AND HOOK ABOVE
1EE0; C; 1EE1; # LATIN CAPITAL LETTER O WITH HORN AND TILDE
1EE2; C; 1EE3; # LATIN CAPITAL LETTER O WITH HORN AND DOT BELOW
1EE4; C; 1EE5; # LATIN CAPITAL LETTER U WITH DOT BELOW
1EE6; C; 1EE7; # LATIN CAPITAL LETTER U WITH HOOK ABOVE
1EE8; C; 1EE9; # LATIN CAPITAL LETTER U WITH HORN AND ACUTE
1EEA; C; 1EEB; # LATIN CAPITAL LETTER U WITH HORN AND GRAVE
1EEC; C; 1EED; # LATIN CAPITAL LETTER U WITH HORN AND HOOK ABOVE
1EEE; C; 1EEF; # LATIN CAPITAL LETTER U WITH HORN AND TILDE
1EF0; C; 1EF1; # LATIN CAPITAL LETTER U WITH HORN AND DOT BELOW
1EF2; C; 1EF3; # LATIN CAPITAL LETTER Y WITH GRAVE
1EF4; C; 1EF5; # LATIN CAPITAL LETTER Y WITH DOT BELOW
1EF6; C; 1EF7; # LATIN CAPITAL LETTER Y WITH HOOK ABOVE
1EF8; C; 1EF9; # LATIN CAPITAL LETTER Y WITH TILDE
1EFA; C; 1EFB; # LATIN CAPITAL LETTER MIDDLE-WELSH LL
1EFC; C; 1EFD; # LATIN CAPITAL LETTER MIDDLE-WELSH V
1EFE; C; 1EFF; # LATIN CAPITAL LETTER Y WITH LOOP
1F08; C; 1F00; # GREEK CAPITAL LETTER ALPHA WITH PSILI
1F09; C; 1F01; # GREEK CAPITAL LETTER ALPHA WITH DASIA
1F0A; C; 1F02; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA
1F0B; C; 1F03; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA
1F0C; C; 1F04; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA
1F0D; C; 1F05; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA
1F0E; C; 1F06; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI
1F0F; C; 1F07; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI
1F18; C; 1F10; # GREEK CAPITAL LETTER EPSILON WITH PSILI
1F19; C; 1F11; # GREEK CAPITAL LETTER EPSILON WITH DASIA
1F1A; C; 1F12; # GREEK CAPITAL LETTER EPSILON WITH PSILI AND VARIA
1F1B; C; 1F13; # GREEK CAPITAL LETTER EPSILON WITH DASIA AND VARIA
1F1C; C; 1F14; # GREEK CAPITAL LETTER EPSILON WITH PSILI AND OXIA
1F1D; C; 1F15; # GREEK CAPITAL LETTER EPSILON WITH DASIA AND OXIA
1F28; C; 1F20; # GREEK CAPITAL LETTER ETA WITH PSILI
1F29; C; 1F21; # GREEK CAPITAL LETTER ETA WITH DASIA
1F2A; C; 1F22; # GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA
1F2B; C; 1F23; # GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA
1F2C; C; 1F24; # GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA
1F2D; C; 1F25; # GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA
1F2E; C; 1F26; # GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI
1F2F; C; 1F27; # GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI
1F38; C; 1F30; # GREEK CAPITAL LETTER IOTA WITH PSILI
1F39; C; 1F31; # GREEK CAPITAL LETTER IOTA WITH DASIA
1F3A; C; 1F32; # GREEK CAPITAL LETTER IOTA WITH PSILI AND VARIA
1F3B; C; 1F33; # GREEK CAPITAL LETTER IOTA WITH DASIA AND VARIA
1F3C; C; 1F34; # GREEK CAPITAL LETTER IOTA WITH PSILI AND OXIA
1F3D; C; 1F35; # GREEK CAPITAL LETTER IOTA WITH DASIA AND OXIA
1F3E; C; 1F36; # GREEK CAPITAL LETTER IOTA WITH PSILI AND PERISPOMENI
1F3F; C; 1F37; # GREEK CAPITAL LETTER IOTA WITH DASIA AND PERISPOMENI
1F48; C; 1F40; # GREEK CAPITAL LETTER OMICRON WITH PSILI
1F49; C; 1F41; # GREEK CAPITAL LETTER OMICRON WITH DASIA
1F4A; C; 1F42; # GREEK CAPITAL LETTER OMICRON WITH PSILI AND VARIA
1F4B; C; 1F43; # GREEK CAPITAL LETTER OMICRON WITH DASIA AND VARIA
1F4C; C; 1F44; # GREEK CAPITAL LETTER OMICRON WITH PSILI AND OXIA
1F4D; C; 1F45; # GREEK CAPITAL LETTER OMICRON WITH DASIA AND OXIA
1F50; F; 03C5 0313; # GREEK SMALL LETTER UPSILON WITH PSILI
1F52; F; 03C5 0313 0300; # GREEK SMALL LETTER UPSILON WITH PSILI AND VARIA
1F54; F; 03C5 0313 0301; # GREEK SMALL LETTER UPSILON WITH PSILI AND OXIA
1F56; F; 03C5 0313 0342; # GREEK SMALL LETTER UPSILON WITH PSILI AND PERISPOMENI
1F59; C; 1F51; # GREEK CAPITAL LETTER UPSILON WITH DASIA
1F5B; C; 1F53; # GREEK CAPITAL LETTER UPSILON WITH DASIA AND VARIA
1F5D; C; 1F55; # GREEK CAPITAL LETTER UPSILON WITH DASIA AND OXIA
1F5F; C; 1F57; # GREEK CAPITAL LETTER UPSILON WITH DASIA AND PERISPOMENI
1F68; C; 1F60; # GREEK CAPITAL LETTER OMEGA WITH PSILI
1F69; C; 1F61; # GREEK CAPITAL LETTER OMEGA WITH DASIA
1F6A; C; 1F62; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA
1F6B; C; 1F63; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA
1F6C; C; 1F64; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA
1F6D; C; 1F65; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA
1F6E; C; 1F66; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI
1F6F; C; 1F67; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI
1F80; F; 1F00 03B9; # GREEK SMALL LETTER ALPHA WITH PSILI AND YPOGEGRAMMENI
1F81; F; 1F01 03B9; # GREEK SMALL LETTER ALPHA WITH DASIA AND YPOGEGRAMMENI
1F82; F; 1F02 03B9; # GREEK SMALL LETTER ALPHA WITH PSILI AND VARIA AND YPOGEGRAMMENI
1F83; F; 1F03 03B9; # GREEK SMALL LETTER ALPHA WITH DASIA AND VARIA AND YPOGEGRAMMENI
1F84; F; 1F04 03B9; # GREEK SMALL LETTER ALPHA WITH PSILI AND OXIA AND YPOGEGRAMMENI
1F85; F; 1F05 03B9; # GREEK SMALL LETTER ALPHA WITH DASIA AND OXIA AND YPOGEGRAMMENI
1F86; F; 1F06 03B9; # GREEK SMALL LETTER ALPHA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI
1F87; F; 1F07 03B9; # GREEK SMALL LETTER ALPHA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI
1F88; F; 1F00 03B9; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI
1F88; S; 1F80; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI
1F89; F; 1F01 03B9; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND PROSGEGRAMMENI
1F89; S; 1F81; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND PROSGEGRAMMENI
1F8A; F; 1F02 03B9; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA AND PROSGEGRAMMENI
1F8A; S; 1F82; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA AND PROSGEGRAMMENI
1F8B; F; 1F03 03B9; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA AND PROSGEGRAMMENI
1F8B; S; 1F83; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA AND PROSGEGRAMMENI
1F8C; F; 1F04 03B9; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA AND PROSGEGRAMMENI
1F8C; S; 1F84; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA AND PROSGEGRAMMENI
1F8D; F; 1F05 03B9; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA AND PROSGEGRAMMENI
1F8D; S; 1F85; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA AND PROSGEGRAMMENI
1F8E; F; 1F06 03B9; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI
1F8E; S; 1F86; # GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI
1F8F; F; 1F07 03B9; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI
1F8F; S; 1F87; # GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI
1F90; F; 1F20 03B9; # GREEK SMALL LETTER ETA WITH PSILI AND YPOGEGRAMMENI
1F91; F; 1F21 03B9; # GREEK SMALL LETTER ETA WITH DASIA AND YPOGEGRAMMENI
1F92; F; 1F22 03B9; # GREEK SMALL LETTER ETA WITH PSILI AND VARIA AND YPOGEGRAMMENI
1F93; F; 1F23 03B9; # GREEK SMALL LETTER ETA WITH DASIA AND VARIA AND YPOGEGRAMMENI
1F94; F; 1F24 03B9; # GREEK SMALL LETTER ETA WITH PSILI AND OXIA AND YPOGEGRAMMENI
1F95; F; 1F25 03B9; # GREEK SMALL LETTER ETA WITH DASIA AND OXIA AND YPOGEGRAMMENI
1F96; F; 1F26 03B9; # GREEK SMALL LETTER ETA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI
1F97; F; 1F27 03B9; # GREEK SMALL LETTER ETA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI
1F98; F; 1F20 03B9; # GREEK CAPITAL LETTER ETA WITH PSILI AND PROSGEGRAMMENI
1F98; S; 1F90; # GREEK CAPITAL LETTER ETA WITH PSILI AND PROSGEGRAMMENI
1F99; F; 1F21 03B9; # GREEK CAPITAL LETTER ETA WITH DASIA AND PROSGEGRAMMENI
1F99; S; 1F91; # GREEK CAPITAL LETTER ETA WITH DASIA AND PROSGEGRAMMENI
1F9A; F; 1F22 03B9; # GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA AND PROSGEGRAMMENI
1F9A; S; 1F92; # GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA AND PROSGEGRAMMENI
1F9B; F; 1F23 03B9; # GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA AND PROSGEGRAMMENI
1F9B; S; 1F93; # GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA AND PROSGEGRAMMENI
1F9C; F; 1F24 03B9; # GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA AND PROSGEGRAMMENI
1F9C; S; 1F94; # GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA AND PROSGEGRAMMENI
1F9D; F; 1F25 03B9; # GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA AND PROSGEGRAMMENI
1F9D; S; 1F95; # GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA AND PROSGEGRAMMENI
1F9E; F; 1F26 03B9; # GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI
1F9E; S; 1F96; # GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI
1F9F; F; 1F27 03B9; # GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI
1F9F; S; 1F97; # GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI
1FA0; F; 1F60 03B9; # GREEK SMALL LETTER OMEGA WITH PSILI AND YPOGEGRAMMENI
1FA1; F; 1F61 03B9; # GREEK SMALL LETTER OMEGA WITH DASIA AND YPOGEGRAMMENI
1FA2; F; 1F62 03B9; # GREEK SMALL LETTER OMEGA WITH PSILI AND VARIA AND YPOGEGRAMMENI
1FA3; F; 1F63 03B9; # GREEK SMALL LETTER OMEGA WITH DASIA AND VARIA AND YPOGEGRAMMENI
1FA4; F; 1F64 03B9; # GREEK SMALL LETTER OMEGA WITH PSILI AND OXIA AND YPOGEGRAMMENI
1FA5; F; 1F65 03B9; # GREEK SMALL LETTER OMEGA WITH DASIA AND OXIA AND YPOGEGRAMMENI
1FA6; F; 1F66 03B9; # GREEK SMALL LETTER OMEGA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI
1FA7; F; 1F67 03B9; # GREEK SMALL LETTER OMEGA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI
1FA8; F; 1F60 03B9; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND PROSGEGRAMMENI
1FA8; S; 1FA0; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND PROSGEGRAMMENI
1FA9; F; 1F61 03B9; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND PROSGEGRAMMENI
1FA9; S; 1FA1; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND PROSGEGRAMMENI
1FAA; F; 1F62 03B9; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA AND PROSGEGRAMMENI
1FAA; S; 1FA2; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA AND PROSGEGRAMMENI
1FAB; F; 1F63 03B9; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA AND PROSGEGRAMMENI
1FAB; S; 1FA3; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA AND PROSGEGRAMMENI
1FAC; F; 1F64 03B9; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA AND PROSGEGRAMMENI
1FAC; S; 1FA4; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA AND PROSGEGRAMMENI
1FAD; F; 1F65 03B9; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA AND PROSGEGRAMMENI
1FAD; S; 1FA5; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA AND PROSGEGRAMMENI
1FAE; F; 1F66 03B9; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI
1FAE; S; 1FA6; # GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI
1FAF; F; 1F67 03B9; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI
1FAF; S; 1FA7; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI
1FB2; F; 1F70 03B9; # GREEK SMALL LETTER ALPHA WITH VARIA AND YPOGEGRAMMENI
1FB3; F; 03B1 03B9; # GREEK SMALL LETTER ALPHA WITH YPOGEGRAMMENI
1FB4; F; 03AC 03B9; # GREEK SMALL LETTER ALPHA WITH OXIA AND YPOGEGRAMMENI
1FB6; F; 03B1 0342; # GREEK SMALL LETTER ALPHA WITH PERISPOMENI
1FB7; F; 03B1 0342 03B9; # GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI
1FB8; C; 1FB0; # GREEK CAPITAL LETTER ALPHA WITH VRACHY
1FB9; C; 1FB1; # GREEK CAPITAL LETTER ALPHA WITH MACRON
1FBA; C; 1F70; # GREEK CAPITAL LETTER ALPHA WITH VARIA
1FBB; C; 1F71; # GREEK CAPITAL LETTER ALPHA WITH OXIA
1FBC; F; 03B1 03B9; # GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI
1FBC; S; 1FB3; # GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI
1FBE; C; 03B9; # GREEK PROSGEGRAMMENI
1FC2; F; 1F74 03B9; # GREEK SMALL LETTER ETA WITH VARIA AND YPOGEGRAMMENI
1FC3; F; 03B7 03B9; # GREEK SMALL LETTER ETA WITH YPOGEGRAMMENI
1FC4; F; 03AE 03B9; # GREEK SMALL LETTER ETA WITH OXIA AND YPOGEGRAMMENI
1FC6; F; 03B7 0342; # GREEK SMALL LETTER ETA WITH PERISPOMENI
1FC7; F; 03B7 0342 03B9; # GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI
1FC8; C; 1F72; # GREEK CAPITAL LETTER EPSILON WITH VARIA
1FC9; C; 1F73; # GREEK CAPITAL LETTER EPSILON WITH OXIA
1FCA; C; 1F74; # GREEK CAPITAL LETTER ETA WITH VARIA
1FCB; C; 1F75; # GREEK CAPITAL LETTER ETA WITH OXIA
1FCC; F; 03B7 03B9; # GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI
1FCC; S; 1FC3; # GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI
1FD2; F; 03B9 0308 0300; # GREEK SMALL LETTER IOTA WITH DIALYTIKA AND VARIA
1FD3; F; 03B9 0308 0301; # GREEK SMALL LETTER IOTA WITH DIALYTIKA AND OXIA
1FD6; F; 03B9 0342; # GREEK SMALL LETTER IOTA WITH PERISPOMENI
1FD7; F; 03B9 0308 0342; # GREEK SMALL LETTER IOTA WITH DIALYTIKA AND PERISPOMENI
1FD8; C; 1FD0; # GREEK CAPITAL LETTER IOTA WITH VRACHY
1FD9; C; 1FD1; # GREEK CAPITAL LETTER IOTA WITH MACRON
1FDA; C; 1F76; # GREEK CAPITAL LETTER IOTA WITH VARIA
1FDB; C; 1F77; # GREEK CAPITAL LETTER IOTA WITH OXIA
1FE2; F; 03C5 0308 0300; # GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND VARIA
1FE3; F; 03C5 0308 0301; # GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND OXIA
1FE4; F; 03C1 0313; # GREEK SMALL LETTER RHO WITH PSILI
1FE6; F; 03C5 0342; # GREEK SMALL LETTER UPSILON WITH PERISPOMENI
1FE7; F; 03C5 0308 0342; # GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND PERISPOMENI
1FE8; C; 1FE0; # GREEK CAPITAL LETTER UPSILON WITH VRACHY
1FE9; C; 1FE1; # GREEK CAPITAL LETTER UPSILON WITH MACRON
1FEA; C; 1F7A; # GREEK CAPITAL LETTER UPSILON WITH VARIA
1FEB; C; 1F7B; # GREEK CAPITAL LETTER UPSILON WITH OXIA
1FEC; C; 1FE5; # GREEK CAPITAL LETTER RHO WITH DASIA
1FF2; F; 1F7C 03B9; # GREEK SMALL LETTER OMEGA WITH VARIA AND YPOGEGRAMMENI
1FF3; F; 03C9 03B9; # GREEK SMALL LETTER OMEGA WITH YPOGEGRAMMENI
1FF4; F; 03CE 03B9; # GREEK SMALL LETTER OMEGA WITH OXIA AND YPOGEGRAMMENI
1FF6; F; 03C9 0342; # GREEK SMALL LETTER OMEGA WITH PERISPOMENI
1FF7; F; 03C9 0342 03B9; # GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI
1FF8; C; 1F78; # GREEK CAPITAL LETTER OMICRON WITH VARIA
1FF9; C; 1F79; # GREEK CAPITAL LETTER OMICRON WITH OXIA
1FFA; C; 1F7C; # GREEK CAPITAL LETTER OMEGA WITH VARIA
1FFB; C; 1F7D; # GREEK CAPITAL LETTER OMEGA WITH OXIA
1FFC; F; 03C9 03B9; # GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI
1FFC; S; 1FF3; # GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI
2126; C; 03C9; # OHM SIGN
212A; C; 006B; # KELVIN SIGN
212B; C; 00E5; # ANGSTROM SIGN
2132; C; 214E; # TURNED CAPITAL F
2160; C; 2170; # ROMAN NUMERAL ONE
2161; C; 2171; # ROMAN NUMERAL TWO
2162; C; 2172; # ROMAN NUMERAL THREE
2163; C; 2173; # ROMAN NUMERAL FOUR
2164; C; 2174; # ROMAN NUMERAL FIVE
2165; C; 2175; # ROMAN NUMERAL SIX
2166; C; 2176; # ROMAN NUMERAL SEVEN
2167; C; 2177; # ROMAN NUMERAL EIGHT
2168; C; 2178; # ROMAN NUMERAL NINE
2169; C; 2179; # ROMAN NUMERAL TEN
216A; C; 217A; # ROMAN NUMERAL ELEVEN
216B; C; 217B; # ROMAN NUMERAL TWELVE
216C; C; 217C; # ROMAN NUMERAL FIFTY
216D; C; 217D; # ROMAN NUMERAL ONE HUNDRED
216E; C; 217E; # ROMAN NUMERAL FIVE HUNDRED
216F; C; 217F; # ROMAN NUMERAL ONE THOUSAND
2183; C; 2184; # ROMAN NUMERAL REVERSED ONE HUNDRED
24B6; C; 24D0; # CIRCLED LATIN CAPITAL LETTER A
24B7; C; 24D1; # CIRCLED LATIN CAPITAL LETTER B
24B8; C; 24D2; # CIRCLED LATIN CAPITAL LETTER C
24B9; C; 24D3; # CIRCLED LATIN CAPITAL LETTER D
24BA; C; 24D4; # CIRCLED LATIN CAPITAL LETTER E
24BB; C; 24D5; # CIRCLED LATIN CAPITAL LETTER F
24BC; C; 24D6; # CIRCLED LATIN CAPITAL LETTER G
24BD; C; 24D7; # CIRCLED LATIN CAPITAL LETTER H
24BE; C; 24D8; # CIRCLED LATIN CAPITAL LETTER I
24BF; C; 24D9; # CIRCLED LATIN CAPITAL LETTER J
24C0; C; 24DA; # CIRCLED LATIN CAPITAL LETTER K
24C1; C; 24DB; # CIRCLED LATIN CAPITAL LETTER L
24C2; C; 24DC; # CIRCLED LATIN CAPITAL LETTER M
24C3; C; 24DD; # CIRCLED LATIN CAPITAL LETTER N
24C4; C; 24DE; # CIRCLED LATIN CAPITAL LETTER O
24C5; C; 24DF; # CIRCLED LATIN CAPITAL LETTER P
24C6; C; 24E0; # CIRCLED LATIN CAPITAL LETTER Q
24C7; C; 24E1; # CIRCLED LATIN CAPITAL LETTER R
24C8; C; 24E2; # CIRCLED LATIN CAPITAL LETTER S
24C9; C; 24E3; # CIRCLED LATIN CAPITAL LETTER T
24CA; C; 24E4; # CIRCLED LATIN CAPITAL LETTER U
24CB; C; 24E5; # CIRCLED LATIN CAPITAL LETTER V
24CC; C; 24E6; # CIRCLED LATIN CAPITAL LETTER W
24CD; C; 24E7; # CIRCLED LATIN CAPITAL LETTER X
24CE; C; 24E8; # CIRCLED LATIN CAPITAL LETTER Y
24CF; C; 24E9; # CIRCLED LATIN CAPITAL LETTER Z
2C00; C; 2C30; # GLAGOLITIC CAPITAL LETTER AZU
2C01; C; 2C31; # GLAGOLITIC CAPITAL LETTER BUKY
2C02; C; 2C32; # GLAGOLITIC CAPITAL LETTER VEDE
2C03; C; 2C33; # GLAGOLITIC CAPITAL LETTER GLAGOLI
2C04; C; 2C34; # GLAGOLITIC CAPITAL LETTER DOBRO
2C05; C; 2C35; # GLAGOLITIC CAPITAL LETTER YESTU
2C06; C; 2C36; # GLAGOLITIC CAPITAL LETTER ZHIVETE
2C07; C; 2C37; # GLAGOLITIC CAPITAL LETTER DZELO
2C08; C; 2C38; # GLAGOLITIC CAPITAL LETTER ZEMLJA
2C09; C; 2C39; # GLAGOLITIC CAPITAL LETTER IZHE
2C0A; C; 2C3A; # GLAGOLITIC CAPITAL LETTER INITIAL IZHE
2C0B; C; 2C3B; # GLAGOLITIC CAPITAL LETTER I
2C0C; C; 2C3C; # GLAGOLITIC CAPITAL LETTER DJERVI
2C0D; C; 2C3D; # GLAGOLITIC CAPITAL LETTER KAKO
2C0E; C; 2C3E; # GLAGOLITIC CAPITAL LETTER LJUDIJE
2C0F; C; 2C3F; # GLAGOLITIC CAPITAL LETTER MYSLITE
2C10; C; 2C40; # GLAGOLITIC CAPITAL LETTER NASHI
2C11; C; 2C41; # GLAGOLITIC CAPITAL LETTER ONU
2C12; C; 2C42; # GLAGOLITIC CAPITAL LETTER POKOJI
2C13; C; 2C43; # GLAGOLITIC CAPITAL LETTER RITSI
2C14; C; 2C44; # GLAGOLITIC CAPITAL LETTER SLOVO
2C15; C; 2C45; # GLAGOLITIC CAPITAL LETTER TVRIDO
2C16; C; 2C46; # GLAGOLITIC CAPITAL LETTER UKU
2C17; C; 2C47; # GLAGOLITIC CAPITAL LETTER FRITU
2C18; C; 2C48; # GLAGOLITIC CAPITAL LETTER HERU
2C19; C; 2C49; # GLAGOLITIC CAPITAL LETTER OTU
2C1A; C; 2C4A; # GLAGOLITIC CAPITAL LETTER PE
2C1B; C; 2C4B; # GLAGOLITIC CAPITAL LETTER SHTA
2C1C; C; 2C4C; # GLAGOLITIC CAPITAL LETTER TSI
2C1D; C; 2C4D; # GLAGOLITIC CAPITAL LETTER CHRIVI
2C1E; C; 2C4E; # GLAGOLITIC CAPITAL LETTER SHA
2C1F; C; 2C4F; # GLAGOLITIC CAPITAL LETTER YERU
2C20; C; 2C50; # GLAGOLITIC CAPITAL LETTER YERI
2C21; C; 2C51; # GLAGOLITIC CAPITAL LETTER YATI
2C22; C; 2C52; # GLAGOLITIC CAPITAL LETTER SPIDERY HA
2C23; C; 2C53; # GLAGOLITIC CAPITAL LETTER YU
2C24; C; 2C54; # GLAGOLITIC CAPITAL LETTER SMALL YUS
2C25; C; 2C55; # GLAGOLITIC CAPITAL LETTER SMALL YUS WITH TAIL
2C26; C; 2C56; # GLAGOLITIC CAPITAL LETTER YO
2C27; C; 2C57; # GLAGOLITIC CAPITAL LETTER IOTATED SMALL YUS
2C28; C; 2C58; # GLAGOLITIC CAPITAL LETTER BIG YUS
2C29; C; 2C59; # GLAGOLITIC CAPITAL LETTER IOTATED BIG YUS
2C2A; C; 2C5A; # GLAGOLITIC CAPITAL LETTER FITA
2C2B; C; 2C5B; # GLAGOLITIC CAPITAL LETTER IZHITSA
2C2C; C; 2C5C; # GLAGOLITIC CAPITAL LETTER SHTAPIC
2C2D; C; 2C5D; # GLAGOLITIC CAPITAL LETTER TROKUTASTI A
2C2E; C; 2C5E; # GLAGOLITIC CAPITAL LETTER LATINATE MYSLITE
2C60; C; 2C61; # LATIN CAPITAL LETTER L WITH DOUBLE BAR
2C62; C; 026B; # LATIN CAPITAL LETTER L WITH MIDDLE TILDE
2C63; C; 1D7D; # LATIN CAPITAL LETTER P WITH STROKE
2C64; C; 027D; # LATIN CAPITAL LETTER R WITH TAIL
2C67; C; 2C68; # LATIN CAPITAL LETTER H WITH DESCENDER
2C69; C; 2C6A; # LATIN CAPITAL LETTER K WITH DESCENDER
2C6B; C; 2C6C; # LATIN CAPITAL LETTER Z WITH DESCENDER
2C6D; C; 0251; # LATIN CAPITAL LETTER ALPHA
2C6E; C; 0271; # LATIN CAPITAL LETTER M WITH HOOK
2C6F; C; 0250; # LATIN CAPITAL LETTER TURNED A
2C70; C; 0252; # LATIN CAPITAL LETTER TURNED ALPHA
2C72; C; 2C73; # LATIN CAPITAL LETTER W WITH HOOK
2C75; C; 2C76; # LATIN CAPITAL LETTER HALF H
2C7E; C; 023F; # LATIN CAPITAL LETTER S WITH SWASH TAIL
2C7F; C; 0240; # LATIN CAPITAL LETTER Z WITH SWASH TAIL
2C80; C; 2C81; # COPTIC CAPITAL LETTER ALFA
2C82; C; 2C83; # COPTIC CAPITAL LETTER VIDA
2C84; C; 2C85; # COPTIC CAPITAL LETTER GAMMA
2C86; C; 2C87; # COPTIC CAPITAL LETTER DALDA
2C88; C; 2C89; # COPTIC CAPITAL LETTER EIE
2C8A; C; 2C8B; # COPTIC CAPITAL LETTER SOU
2C8C; C; 2C8D; # COPTIC CAPITAL LETTER ZATA
2C8E; C; 2C8F; # COPTIC CAPITAL LETTER HATE
2C90; C; 2C91; # COPTIC CAPITAL LETTER THETHE
2C92; C; 2C93; # COPTIC CAPITAL LETTER IAUDA
2C94; C; 2C95; # COPTIC CAPITAL LETTER KAPA
2C96; C; 2C97; # COPTIC CAPITAL LETTER LAULA
2C98; C; 2C99; # COPTIC CAPITAL LETTER MI
2C9A; C; 2C9B; # COPTIC CAPITAL LETTER NI
2C9C; C; 2C9D; # COPTIC CAPITAL LETTER KSI
2C9E; C; 2C9F; # COPTIC CAPITAL LETTER O
2CA0; C; 2CA1; # COPTIC CAPITAL LETTER PI
2CA2; C; 2CA3; # COPTIC CAPITAL LETTER RO
2CA4; C; 2CA5; # COPTIC CAPITAL LETTER SIMA
2CA6; C; 2CA7; # COPTIC CAPITAL LETTER TAU
2CA8; C; 2CA9; # COPTIC CAPITAL LETTER UA
2CAA; C; 2CAB; # COPTIC CAPITAL LETTER FI
2CAC; C; 2CAD; # COPTIC CAPITAL LETTER KHI
2CAE; C; 2CAF; # COPTIC CAPITAL LETTER PSI
2CB0; C; 2CB1; # COPTIC CAPITAL LETTER OOU
2CB2; C; 2CB3; # COPTIC CAPITAL LETTER DIALECT-P ALEF
2CB4; C; 2CB5; # COPTIC CAPITAL LETTER OLD COPTIC AIN
2CB6; C; 2CB7; # COPTIC CAPITAL LETTER CRYPTOGRAMMIC EIE
2CB8; C; 2CB9; # COPTIC CAPITAL LETTER DIALECT-P KAPA
2CBA; C; 2CBB; # COPTIC CAPITAL LETTER DIALECT-P NI
2CBC; C; 2CBD; # COPTIC CAPITAL LETTER CRYPTOGRAMMIC NI
2CBE; C; 2CBF; # COPTIC CAPITAL LETTER OLD COPTIC OOU
2CC0; C; 2CC1; # COPTIC CAPITAL LETTER SAMPI
2CC2; C; 2CC3; # COPTIC CAPITAL LETTER CROSSED SHEI
2CC4; C; 2CC5; # COPTIC CAPITAL LETTER OLD COPTIC SHEI
2CC6; C; 2CC7; # COPTIC CAPITAL LETTER OLD COPTIC ESH
2CC8; C; 2CC9; # COPTIC CAPITAL LETTER AKHMIMIC KHEI
2CCA; C; 2CCB; # COPTIC CAPITAL LETTER DIALECT-P HORI
2CCC; C; 2CCD; # COPTIC CAPITAL LETTER OLD COPTIC HORI
2CCE; C; 2CCF; # COPTIC CAPITAL LETTER OLD COPTIC HA
2CD0; C; 2CD1; # COPTIC CAPITAL LETTER L-SHAPED HA
2CD2; C; 2CD3; # COPTIC CAPITAL LETTER OLD COPTIC HEI
2CD4; C; 2CD5; # COPTIC CAPITAL LETTER OLD COPTIC HAT
2CD6; C; 2CD7; # COPTIC CAPITAL LETTER OLD COPTIC GANGIA
2CD8; C; 2CD9; # COPTIC CAPITAL LETTER OLD COPTIC DJA
2CDA; C; 2CDB; # COPTIC CAPITAL LETTER OLD COPTIC SHIMA
2CDC; C; 2CDD; # COPTIC CAPITAL LETTER OLD NUBIAN SHIMA
2CDE; C; 2CDF; # COPTIC CAPITAL LETTER OLD NUBIAN NGI
2CE0; C; 2CE1; # COPTIC CAPITAL LETTER OLD NUBIAN NYI
2CE2; C; 2CE3; # COPTIC CAPITAL LETTER OLD NUBIAN WAU
2CEB; C; 2CEC; # COPTIC CAPITAL LETTER CRYPTOGRAMMIC SHEI
2CED; C; 2CEE; # COPTIC CAPITAL LETTER CRYPTOGRAMMIC GANGIA
2CF2; C; 2CF3; # COPTIC CAPITAL LETTER BOHAIRIC KHEI
A640; C; A641; # CYRILLIC CAPITAL LETTER ZEMLYA
A642; C; A643; # CYRILLIC CAPITAL LETTER DZELO
A644; C; A645; # CYRILLIC CAPITAL LETTER REVERSED DZE
A646; C; A647; # CYRILLIC CAPITAL LETTER IOTA
A648; C; A649; # CYRILLIC CAPITAL LETTER DJERV
A64A; C; A64B; # CYRILLIC CAPITAL LETTER MONOGRAPH UK
A64C; C; A64D; # CYRILLIC CAPITAL LETTER BROAD OMEGA
A64E; C; A64F; # CYRILLIC CAPITAL LETTER NEUTRAL YER
A650; C; A651; # CYRILLIC CAPITAL LETTER YERU WITH BACK YER
A652; C; A653; # CYRILLIC CAPITAL LETTER IOTIFIED YAT
A654; C; A655; # CYRILLIC CAPITAL LETTER REVERSED YU
A656; C; A657; # CYRILLIC CAPITAL LETTER IOTIFIED A
A658; C; A659; # CYRILLIC CAPITAL LETTER CLOSED LITTLE YUS
A65A; C; A65B; # CYRILLIC CAPITAL LETTER BLENDED YUS
A65C; C; A65D; # CYRILLIC CAPITAL LETTER IOTIFIED CLOSED LITTLE YUS
A65E; C; A65F; # CYRILLIC CAPITAL LETTER YN
A660; C; A661; # CYRILLIC CAPITAL LETTER REVERSED TSE
A662; C; A663; # CYRILLIC CAPITAL LETTER SOFT DE
A664; C; A665; # CYRILLIC CAPITAL LETTER SOFT EL
A666; C; A667; # CYRILLIC CAPITAL LETTER SOFT EM
A668; C; A669; # CYRILLIC CAPITAL LETTER MONOCULAR O
A66A; C; A66B; # CYRILLIC CAPITAL LETTER BINOCULAR O
A66C; C; A66D; # CYRILLIC CAPITAL LETTER DOUBLE MONOCULAR O
A680; C; A681; # CYRILLIC CAPITAL LETTER DWE
A682; C; A683; # CYRILLIC CAPITAL LETTER DZWE
A684; C; A685; # CYRILLIC CAPITAL LETTER ZHWE
A686; C; A687; # CYRILLIC CAPITAL LETTER CCHE
A688; C; A689; # CYRILLIC CAPITAL LETTER DZZE
A68A; C; A68B; # CYRILLIC CAPITAL LETTER TE WITH MIDDLE HOOK
A68C; C; A68D; # CYRILLIC CAPITAL LETTER TWE
A68E; C; A68F; # CYRILLIC CAPITAL LETTER TSWE
A690; C; A691; # CYRILLIC CAPITAL LETTER TSSE
A692; C; A693; # CYRILLIC CAPITAL LETTER TCHE
A694; C; A695; # CYRILLIC CAPITAL LETTER HWE
A696; C; A697; # CYRILLIC CAPITAL LETTER SHWE
A698; C; A699; # CYRILLIC CAPITAL LETTER DOUBLE O
A69A; C; A69B; # CYRILLIC CAPITAL LETTER CROSSED O
A722; C; A723; # LATIN CAPITAL LETTER EGYPTOLOGICAL ALEF
A724; C; A725; # LATIN CAPITAL LETTER EGYPTOLOGICAL AIN
A726; C; A727; # LATIN CAPITAL LETTER HENG
A728; C; A729; # LATIN CAPITAL LETTER TZ
A72A; C; A72B; # LATIN CAPITAL LETTER TRESILLO
A72C; C; A72D; # LATIN CAPITAL LETTER CUATRILLO
A72E; C; A72F; # LATIN CAPITAL LETTER CUATRILLO WITH COMMA
A732; C; A733; # LATIN CAPITAL LETTER AA
A734; C; A735; # LATIN CAPITAL LETTER AO
A736; C; A737; # LATIN CAPITAL LETTER AU
A738; C; A739; # LATIN CAPITAL LETTER AV
A73A; C; A73B; # LATIN CAPITAL LETTER AV WITH HORIZONTAL BAR
A73C; C; A73D; # LATIN CAPITAL LETTER AY
A73E; C; A73F; # LATIN CAPITAL LETTER REVERSED C WITH DOT
A740; C; A741; # LATIN CAPITAL LETTER K WITH STROKE
A742; C; A743; # LATIN CAPITAL LETTER K WITH DIAGONAL STROKE
A744; C; A745; # LATIN CAPITAL LETTER K WITH STROKE AND DIAGONAL STROKE
A746; C; A747; # LATIN CAPITAL LETTER BROKEN L
A748; C; A749; # LATIN CAPITAL LETTER L WITH HIGH STROKE
A74A; C; A74B; # LATIN CAPITAL LETTER O WITH LONG STROKE OVERLAY
A74C; C; A74D; # LATIN CAPITAL LETTER O WITH LOOP
A74E; C; A74F; # LATIN CAPITAL LETTER OO
A750; C; A751; # LATIN CAPITAL LETTER P WITH STROKE THROUGH DESCENDER
A752; C; A753; # LATIN CAPITAL LETTER P WITH FLOURISH
A754; C; A755; # LATIN CAPITAL LETTER P WITH SQUIRREL TAIL
A756; C; A757; # LATIN CAPITAL LETTER Q WITH STROKE THROUGH DESCENDER
A758; C; A759; # LATIN CAPITAL LETTER Q WITH DIAGONAL STROKE
A75A; C; A75B; # LATIN CAPITAL LETTER R ROTUNDA
A75C; C; A75D; # LATIN CAPITAL LETTER RUM ROTUNDA
A75E; C; A75F; # LATIN CAPITAL LETTER V WITH DIAGONAL STROKE
A760; C; A761; # LATIN CAPITAL LETTER VY
A762; C; A763; # LATIN CAPITAL LETTER VISIGOTHIC Z
A764; C; A765; # LATIN CAPITAL LETTER THORN WITH STROKE
A766; C; A767; # LATIN CAPITAL LETTER THORN WITH STROKE THROUGH DESCENDER
A768; C; A769; # LATIN CAPITAL LETTER VEND
A76A; C; A76B; # LATIN CAPITAL LETTER ET
A76C; C; A76D; # LATIN CAPITAL LETTER IS
A76E; C; A76F; # LATIN CAPITAL LETTER CON
A779; C; A77A; # LATIN CAPITAL LETTER INSULAR D
A77B; C; A77C; # LATIN CAPITAL LETTER INSULAR F
A77D; C; 1D79; # LATIN CAPITAL LETTER INSULAR G
A77E; C; A77F; # LATIN CAPITAL LETTER TURNED INSULAR G
A780; C; A781; # LATIN CAPITAL LETTER TURNED L
A782; C; A783; # LATIN CAPITAL LETTER INSULAR R
A784; C; A785; # LATIN CAPITAL LETTER INSULAR S
A786; C; A787; # LATIN CAPITAL LETTER INSULAR T
A78B; C; A78C; # LATIN CAPITAL LETTER SALTILLO
A78D; C; 0265; # LATIN CAPITAL LETTER TURNED H
A790; C; A791; # LATIN CAPITAL LETTER N WITH DESCENDER
A792; C; A793; # LATIN CAPITAL LETTER C WITH BAR
A796; C; A797; # LATIN CAPITAL LETTER B WITH FLOURISH
A798; C; A799; # LATIN CAPITAL LETTER F WITH STROKE
A79A; C; A79B; # LATIN CAPITAL LETTER VOLAPUK AE
A79C; C; A79D; # LATIN CAPITAL LETTER VOLAPUK OE
A79E; C; A79F; # LATIN CAPITAL LETTER VOLAPUK UE
A7A0; C; A7A1; # LATIN CAPITAL LETTER G WITH OBLIQUE STROKE
A7A2; C; A7A3; # LATIN CAPITAL LETTER K WITH OBLIQUE STROKE
A7A4; C; A7A5; # LATIN CAPITAL LETTER N WITH OBLIQUE STROKE
A7A6; C; A7A7; # LATIN CAPITAL LETTER R WITH OBLIQUE STROKE
A7A8; C; A7A9; # LATIN CAPITAL LETTER S WITH OBLIQUE STROKE
A7AA; C; 0266; # LATIN CAPITAL LETTER H WITH HOOK
A7AB; C; 025C; # LATIN CAPITAL LETTER REVERSED OPEN E
A7AC; C; 0261; # LATIN CAPITAL LETTER SCRIPT G
A7AD; C; 026C; # LATIN CAPITAL LETTER L WITH BELT
A7AE; C; 026A; # LATIN CAPITAL LETTER SMALL CAPITAL I
A7B0; C; 029E; # LATIN CAPITAL LETTER TURNED K
A7B1; C; 0287; # LATIN CAPITAL LETTER TURNED T
A7B2; C; 029D; # LATIN CAPITAL LETTER J WITH CROSSED-TAIL
A7B3; C; AB53; # LATIN CAPITAL LETTER CHI
A7B4; C; A7B5; # LATIN CAPITAL LETTER BETA
A7B6; C; A7B7; # LATIN CAPITAL LETTER OMEGA
AB70; C; 13A0; # CHEROKEE SMALL LETTER A
AB71; C; 13A1; # CHEROKEE SMALL LETTER E
AB72; C; 13A2; # CHEROKEE SMALL LETTER I
AB73; C; 13A3; # CHEROKEE SMALL LETTER O
AB74; C; 13A4; # CHEROKEE SMALL LETTER U
AB75; C; 13A5; # CHEROKEE SMALL LETTER V
AB76; C; 13A6; # CHEROKEE SMALL LETTER GA
AB77; C; 13A7; # CHEROKEE SMALL LETTER KA
AB78; C; 13A8; # CHEROKEE SMALL LETTER GE
AB79; C; 13A9; # CHEROKEE SMALL LETTER GI
AB7A; C; 13AA; # CHEROKEE SMALL LETTER GO
AB7B; C; 13AB; # CHEROKEE SMALL LETTER GU
AB7C; C; 13AC; # CHEROKEE SMALL LETTER GV
AB7D; C; 13AD; # CHEROKEE SMALL LETTER HA
AB7E; C; 13AE; # CHEROKEE SMALL LETTER HE
AB7F; C; 13AF; # CHEROKEE SMALL LETTER HI
AB80; C; 13B0; # CHEROKEE SMALL LETTER HO
AB81; C; 13B1; # CHEROKEE SMALL LETTER HU
AB82; C; 13B2; # CHEROKEE SMALL LETTER HV
AB83; C; 13B3; # CHEROKEE SMALL LETTER LA
AB84; C; 13B4; # CHEROKEE SMALL LETTER LE
AB85; C; 13B5; # CHEROKEE SMALL LETTER LI
AB86; C; 13B6; # CHEROKEE SMALL LETTER LO
AB87; C; 13B7; # CHEROKEE SMALL LETTER LU
AB88; C; 13B8; # CHEROKEE SMALL LETTER LV
AB89; C; 13B9; # CHEROKEE SMALL LETTER MA
AB8A; C; 13BA; # CHEROKEE SMALL LETTER ME
AB8B; C; 13BB; # CHEROKEE SMALL LETTER MI
AB8C; C; 13BC; # CHEROKEE SMALL LETTER MO
AB8D; C; 13BD; # CHEROKEE SMALL LETTER MU
AB8E; C; 13BE; # CHEROKEE SMALL LETTER NA
AB8F; C; 13BF; # CHEROKEE SMALL LETTER HNA
AB90; C; 13C0; # CHEROKEE SMALL LETTER NAH
AB91; C; 13C1; # CHEROKEE SMALL LETTER NE
AB92; C; 13C2; # CHEROKEE SMALL LETTER NI
AB93; C; 13C3; # CHEROKEE SMALL LETTER NO
AB94; C; 13C4; # CHEROKEE SMALL LETTER NU
AB95; C; 13C5; # CHEROKEE SMALL LETTER NV
AB96; C; 13C6; # CHEROKEE SMALL LETTER QUA
AB97; C; 13C7; # CHEROKEE SMALL LETTER QUE
AB98; C; 13C8; # CHEROKEE SMALL LETTER QUI
AB99; C; 13C9; # CHEROKEE SMALL LETTER QUO
AB9A; C; 13CA; # CHEROKEE SMALL LETTER QUU
AB9B; C; 13CB; # CHEROKEE SMALL LETTER QUV
AB9C; C; 13CC; # CHEROKEE SMALL LETTER SA
AB9D; C; 13CD; # CHEROKEE SMALL LETTER S
AB9E; C; 13CE; # CHEROKEE SMALL LETTER SE
AB9F; C; 13CF; # CHEROKEE SMALL LETTER SI
ABA0; C; 13D0; # CHEROKEE SMALL LETTER SO
ABA1; C; 13D1; # CHEROKEE SMALL LETTER SU
ABA2; C; 13D2; # CHEROKEE SMALL LETTER SV
ABA3; C; 13D3; # CHEROKEE SMALL LETTER DA
ABA4; C; 13D4; # CHEROKEE SMALL LETTER TA
ABA5; C; 13D5; # CHEROKEE SMALL LETTER DE
ABA6; C; 13D6; # CHEROKEE SMALL LETTER TE
ABA7; C; 13D7; # CHEROKEE SMALL LETTER DI
ABA8; C; 13D8; # CHEROKEE SMALL LETTER TI
ABA9; C; 13D9; # CHEROKEE SMALL LETTER DO
ABAA; C; 13DA; # CHEROKEE SMALL LETTER DU
ABAB; C; 13DB; # CHEROKEE SMALL LETTER DV
ABAC; C; 13DC; # CHEROKEE SMALL LETTER DLA
ABAD; C; 13DD; # CHEROKEE SMALL LETTER TLA
ABAE; C; 13DE; # CHEROKEE SMALL LETTER TLE
ABAF; C; 13DF; # CHEROKEE SMALL LETTER TLI
ABB0; C; 13E0; # CHEROKEE SMALL LETTER TLO
ABB1; C; 13E1; # CHEROKEE SMALL LETTER TLU
ABB2; C; 13E2; # CHEROKEE SMALL LETTER TLV
ABB3; C; 13E3; # CHEROKEE SMALL LETTER TSA
ABB4; C; 13E4; # CHEROKEE SMALL LETTER TSE
ABB5; C; 13E5; # CHEROKEE SMALL LETTER TSI
ABB6; C; 13E6; # CHEROKEE SMALL LETTER TSO
ABB7; C; 13E7; # CHEROKEE SMALL LETTER TSU
ABB8; C; 13E8; # CHEROKEE SMALL LETTER TSV
ABB9; C; 13E9; # CHEROKEE SMALL LETTER WA
ABBA; C; 13EA; # CHEROKEE SMALL LETTER WE
ABBB; C; 13EB; # CHEROKEE SMALL LETTER WI
ABBC; C; 13EC; # CHEROKEE SMALL LETTER WO
ABBD; C; 13ED; # CHEROKEE SMALL LETTER WU
ABBE; C; 13EE; # CHEROKEE SMALL LETTER WV
ABBF; C; 13EF; # CHEROKEE SMALL LETTER YA
FB00; F; 0066 0066; # LATIN SMALL LIGATURE FF
FB01; F; 0066 0069; # LATIN SMALL LIGATURE FI
FB02; F; 0066 006C; # LATIN SMALL LIGATURE FL
FB03; F; 0066 0066 0069; # LATIN SMALL LIGATURE FFI
FB04; F; 0066 0066 006C; # LATIN SMALL LIGATURE FFL
FB05; F; 0073 0074; # LATIN SMALL LIGATURE LONG S T
FB06; F; 0073 0074; # LATIN SMALL LIGATURE ST
FB13; F; 0574 0576; # ARMENIAN SMALL LIGATURE MEN NOW
FB14; F; 0574 0565; # ARMENIAN SMALL LIGATURE MEN ECH
FB15; F; 0574 056B; # ARMENIAN SMALL LIGATURE MEN INI
FB16; F; 057E 0576; # ARMENIAN SMALL LIGATURE VEW NOW
FB17; F; 0574 056D; # ARMENIAN SMALL LIGATURE MEN XEH
FF21; C; FF41; # FULLWIDTH LATIN CAPITAL LETTER A
FF22; C; FF42; # FULLWIDTH LATIN CAPITAL LETTER B
FF23; C; FF43; # FULLWIDTH LATIN CAPITAL LETTER C
FF24; C; FF44; # FULLWIDTH LATIN CAPITAL LETTER D
FF25; C; FF45; # FULLWIDTH LATIN CAPITAL LETTER E
FF26; C; FF46; # FULLWIDTH LATIN CAPITAL LETTER F
FF27; C; FF47; # FULLWIDTH LATIN CAPITAL LETTER G
FF28; C; FF48; # FULLWIDTH LATIN CAPITAL LETTER H
FF29; C; FF49; # FULLWIDTH LATIN CAPITAL LETTER I
FF2A; C; FF4A; # FULLWIDTH LATIN CAPITAL LETTER J
FF2B; C; FF4B; # FULLWIDTH LATIN CAPITAL LETTER K
FF2C; C; FF4C; # FULLWIDTH LATIN CAPITAL LETTER L
FF2D; C; FF4D; # FULLWIDTH LATIN CAPITAL LETTER M
FF2E; C; FF4E; # FULLWIDTH LATIN CAPITAL LETTER N
FF2F; C; FF4F; # FULLWIDTH LATIN CAPITAL LETTER O
FF30; C; FF50; # FULLWIDTH LATIN CAPITAL LETTER P
FF31; C; FF51; # FULLWIDTH LATIN CAPITAL LETTER Q
FF32; C; FF52; # FULLWIDTH LATIN CAPITAL LETTER R
FF33; C; FF53; # FULLWIDTH LATIN CAPITAL LETTER S
FF34; C; FF54; # FULLWIDTH LATIN CAPITAL LETTER T
FF35; C; FF55; # FULLWIDTH LATIN CAPITAL LETTER U
FF36; C; FF56; # FULLWIDTH LATIN CAPITAL LETTER V
FF37; C; FF57; # FULLWIDTH LATIN CAPITAL LETTER W
FF38; C; FF58; # FULLWIDTH LATIN CAPITAL LETTER X
FF39; C; FF59; # FULLWIDTH LATIN CAPITAL LETTER Y
FF3A; C; FF5A; # FULLWIDTH LATIN CAPITAL LETTER Z
10400; C; 10428; # DESERET CAPITAL LETTER LONG I
10401; C; 10429; # DESERET CAPITAL LETTER LONG E
10402; C; 1042A; # DESERET CAPITAL LETTER LONG A
10403; C; 1042B; # DESERET CAPITAL LETTER LONG AH
10404; C; 1042C; # DESERET CAPITAL LETTER LONG O
10405; C; 1042D; # DESERET CAPITAL LETTER LONG OO
10406; C; 1042E; # DESERET CAPITAL LETTER SHORT I
10407; C; 1042F; # DESERET CAPITAL LETTER SHORT E
10408; C; 10430; # DESERET CAPITAL LETTER SHORT A
10409; C; 10431; # DESERET CAPITAL LETTER SHORT AH
1040A; C; 10432; # DESERET CAPITAL LETTER SHORT O
1040B; C; 10433; # DESERET CAPITAL LETTER SHORT OO
1040C; C; 10434; # DESERET CAPITAL LETTER AY
1040D; C; 10435; # DESERET CAPITAL LETTER OW
1040E; C; 10436; # DESERET CAPITAL LETTER WU
1040F; C; 10437; # DESERET CAPITAL LETTER YEE
10410; C; 10438; # DESERET CAPITAL LETTER H
10411; C; 10439; # DESERET CAPITAL LETTER PEE
10412; C; 1043A; # DESERET CAPITAL LETTER BEE
10413; C; 1043B; # DESERET CAPITAL LETTER TEE
10414; C; 1043C; # DESERET CAPITAL LETTER DEE
10415; C; 1043D; # DESERET CAPITAL LETTER CHEE
10416; C; 1043E; # DESERET CAPITAL LETTER JEE
10417; C; 1043F; # DESERET CAPITAL LETTER KAY
10418; C; 10440; # DESERET CAPITAL LETTER GAY
10419; C; 10441; # DESERET CAPITAL LETTER EF
1041A; C; 10442; # DESERET CAPITAL LETTER VEE
1041B; C; 10443; # DESERET CAPITAL LETTER ETH
1041C; C; 10444; # DESERET CAPITAL LETTER THEE
1041D; C; 10445; # DESERET CAPITAL LETTER ES
1041E; C; 10446; # DESERET CAPITAL LETTER ZEE
1041F; C; 10447; # DESERET CAPITAL LETTER ESH
10420; C; 10448; # DESERET CAPITAL LETTER ZHEE
10421; C; 10449; # DESERET CAPITAL LETTER ER
10422; C; 1044A; # DESERET CAPITAL LETTER EL
10423; C; 1044B; # DESERET CAPITAL LETTER EM
10424; C; 1044C; # DESERET CAPITAL LETTER EN
10425; C; 1044D; # DESERET CAPITAL LETTER ENG
10426; C; 1044E; # DESERET CAPITAL LETTER OI
10427; C; 1044F; # DESERET CAPITAL LETTER EW
104B0; C; 104D8; # OSAGE CAPITAL LETTER A
104B1; C; 104D9; # OSAGE CAPITAL LETTER AI
104B2; C; 104DA; # OSAGE CAPITAL LETTER AIN
104B3; C; 104DB; # OSAGE CAPITAL LETTER AH
104B4; C; 104DC; # OSAGE CAPITAL LETTER BRA
104B5; C; 104DD; # OSAGE CAPITAL LETTER CHA
104B6; C; 104DE; # OSAGE CAPITAL LETTER EHCHA
104B7; C; 104DF; # OSAGE CAPITAL LETTER E
104B8; C; 104E0; # OSAGE CAPITAL LETTER EIN
104B9; C; 104E1; # OSAGE CAPITAL LETTER HA
104BA; C; 104E2; # OSAGE CAPITAL LETTER HYA
104BB; C; 104E3; # OSAGE CAPITAL LETTER I
104BC; C; 104E4; # OSAGE CAPITAL LETTER KA
104BD; C; 104E5; # OSAGE CAPITAL LETTER EHKA
104BE; C; 104E6; # OSAGE CAPITAL LETTER KYA
104BF; C; 104E7; # OSAGE CAPITAL LETTER LA
104C0; C; 104E8; # OSAGE CAPITAL LETTER MA
104C1; C; 104E9; # OSAGE CAPITAL LETTER NA
104C2; C; 104EA; # OSAGE CAPITAL LETTER O
104C3; C; 104EB; # OSAGE CAPITAL LETTER OIN
104C4; C; 104EC; # OSAGE CAPITAL LETTER PA
104C5; C; 104ED; # OSAGE CAPITAL LETTER EHPA
104C6; C; 104EE; # OSAGE CAPITAL LETTER SA
104C7; C; 104EF; # OSAGE CAPITAL LETTER SHA
104C8; C; 104F0; # OSAGE CAPITAL LETTER TA
104C9; C; 104F1; # OSAGE CAPITAL LETTER EHTA
104CA; C; 104F2; # OSAGE CAPITAL LETTER TSA
104CB; C; 104F3; # OSAGE CAPITAL LETTER EHTSA
104CC; C; 104F4; # OSAGE CAPITAL LETTER TSHA
104CD; C; 104F5; # OSAGE CAPITAL LETTER DHA
104CE; C; 104F6; # OSAGE CAPITAL LETTER U
104CF; C; 104F7; # OSAGE CAPITAL LETTER WA
104D0; C; 104F8; # OSAGE CAPITAL LETTER KHA
104D1; C; 104F9; # OSAGE CAPITAL LETTER GHA
104D2; C; 104FA; # OSAGE CAPITAL LETTER ZA
104D3; C; 104FB; # OSAGE CAPITAL LETTER ZHA
10C80; C; 10CC0; # OLD HUNGARIAN CAPITAL LETTER A
10C81; C; 10CC1; # OLD HUNGARIAN CAPITAL LETTER AA
10C82; C; 10CC2; # OLD HUNGARIAN CAPITAL LETTER EB
10C83; C; 10CC3; # OLD HUNGARIAN CAPITAL LETTER AMB
10C84; C; 10CC4; # OLD HUNGARIAN CAPITAL LETTER EC
10C85; C; 10CC5; # OLD HUNGARIAN CAPITAL LETTER ENC
10C86; C; 10CC6; # OLD HUNGARIAN CAPITAL LETTER ECS
10C87; C; 10CC7; # OLD HUNGARIAN CAPITAL LETTER ED
10C88; C; 10CC8; # OLD HUNGARIAN CAPITAL LETTER AND
10C89; C; 10CC9; # OLD HUNGARIAN CAPITAL LETTER E
10C8A; C; 10CCA; # OLD HUNGARIAN CAPITAL LETTER CLOSE E
10C8B; C; 10CCB; # OLD HUNGARIAN CAPITAL LETTER EE
10C8C; C; 10CCC; # OLD HUNGARIAN CAPITAL LETTER EF
10C8D; C; 10CCD; # OLD HUNGARIAN CAPITAL LETTER EG
10C8E; C; 10CCE; # OLD HUNGARIAN CAPITAL LETTER EGY
10C8F; C; 10CCF; # OLD HUNGARIAN CAPITAL LETTER EH
10C90; C; 10CD0; # OLD HUNGARIAN CAPITAL LETTER I
10C91; C; 10CD1; # OLD HUNGARIAN CAPITAL LETTER II
10C92; C; 10CD2; # OLD HUNGARIAN CAPITAL LETTER EJ
10C93; C; 10CD3; # OLD HUNGARIAN CAPITAL LETTER EK
10C94; C; 10CD4; # OLD HUNGARIAN CAPITAL LETTER AK
10C95; C; 10CD5; # OLD HUNGARIAN CAPITAL LETTER UNK
10C96; C; 10CD6; # OLD HUNGARIAN CAPITAL LETTER EL
10C97; C; 10CD7; # OLD HUNGARIAN CAPITAL LETTER ELY
10C98; C; 10CD8; # OLD HUNGARIAN CAPITAL LETTER EM
10C99; C; 10CD9; # OLD HUNGARIAN CAPITAL LETTER EN
10C9A; C; 10CDA; # OLD HUNGARIAN CAPITAL LETTER ENY
10C9B; C; 10CDB; # OLD HUNGARIAN CAPITAL LETTER O
10C9C; C; 10CDC; # OLD HUNGARIAN CAPITAL LETTER OO
10C9D; C; 10CDD; # OLD HUNGARIAN CAPITAL LETTER NIKOLSBURG OE
10C9E; C; 10CDE; # OLD HUNGARIAN CAPITAL LETTER RUDIMENTA OE
10C9F; C; 10CDF; # OLD HUNGARIAN CAPITAL LETTER OEE
10CA0; C; 10CE0; # OLD HUNGARIAN CAPITAL LETTER EP
10CA1; C; 10CE1; # OLD HUNGARIAN CAPITAL LETTER EMP
10CA2; C; 10CE2; # OLD HUNGARIAN CAPITAL LETTER ER
10CA3; C; 10CE3; # OLD HUNGARIAN CAPITAL LETTER SHORT ER
10CA4; C; 10CE4; # OLD HUNGARIAN CAPITAL LETTER ES
10CA5; C; 10CE5; # OLD HUNGARIAN CAPITAL LETTER ESZ
10CA6; C; 10CE6; # OLD HUNGARIAN CAPITAL LETTER ET
10CA7; C; 10CE7; # OLD HUNGARIAN CAPITAL LETTER ENT
10CA8; C; 10CE8; # OLD HUNGARIAN CAPITAL LETTER ETY
10CA9; C; 10CE9; # OLD HUNGARIAN CAPITAL LETTER ECH
10CAA; C; 10CEA; # OLD HUNGARIAN CAPITAL LETTER U
10CAB; C; 10CEB; # OLD HUNGARIAN CAPITAL LETTER UU
10CAC; C; 10CEC; # OLD HUNGARIAN CAPITAL LETTER NIKOLSBURG UE
10CAD; C; 10CED; # OLD HUNGARIAN CAPITAL LETTER RUDIMENTA UE
10CAE; C; 10CEE; # OLD HUNGARIAN CAPITAL LETTER EV
10CAF; C; 10CEF; # OLD HUNGARIAN CAPITAL LETTER EZ
10CB0; C; 10CF0; # OLD HUNGARIAN CAPITAL LETTER EZS
10CB1; C; 10CF1; # OLD HUNGARIAN CAPITAL LETTER ENT-SHAPED SIGN
10CB2; C; 10CF2; # OLD HUNGARIAN CAPITAL LETTER US
118A0; C; 118C0; # WARANG CITI CAPITAL LETTER NGAA
118A1; C; 118C1; # WARANG CITI CAPITAL LETTER A
118A2; C; 118C2; # WARANG CITI CAPITAL LETTER WI
118A3; C; 118C3; # WARANG CITI CAPITAL LETTER YU
118A4; C; 118C4; # WARANG CITI CAPITAL LETTER YA
118A5; C; 118C5; # WARANG CITI CAPITAL LETTER YO
118A6; C; 118C6; # WARANG CITI CAPITAL LETTER II
118A7; C; 118C7; # WARANG CITI CAPITAL LETTER UU
118A8; C; 118C8; # WARANG CITI CAPITAL LETTER E
118A9; C; 118C9; # WARANG CITI CAPITAL LETTER O
118AA; C; 118CA; # WARANG CITI CAPITAL LETTER ANG
118AB; C; 118CB; # WARANG CITI CAPITAL LETTER GA
118AC; C; 118CC; # WARANG CITI CAPITAL LETTER KO
118AD; C; 118CD; # WARANG CITI CAPITAL LETTER ENY
118AE; C; 118CE; # WARANG CITI CAPITAL LETTER YUJ
118AF; C; 118CF; # WARANG CITI CAPITAL LETTER UC
118B0; C; 118D0; # WARANG CITI CAPITAL LETTER ENN
118B1; C; 118D1; # WARANG CITI CAPITAL LETTER ODD
118B2; C; 118D2; # WARANG CITI CAPITAL LETTER TTE
118B3; C; 118D3; # WARANG CITI CAPITAL LETTER NUNG
118B4; C; 118D4; # WARANG CITI CAPITAL LETTER DA
118B5; C; 118D5; # WARANG CITI CAPITAL LETTER AT
118B6; C; 118D6; # WARANG CITI CAPITAL LETTER AM
118B7; C; 118D7; # WARANG CITI CAPITAL LETTER BU
118B8; C; 118D8; # WARANG CITI CAPITAL LETTER PU
118B9; C; 118D9; # WARANG CITI CAPITAL LETTER HIYO
118BA; C; 118DA; # WARANG CITI CAPITAL LETTER HOLO
118BB; C; 118DB; # WARANG CITI CAPITAL LETTER HORR
118BC; C; 118DC; # WARANG CITI CAPITAL LETTER HAR
118BD; C; 118DD; # WARANG CITI CAPITAL LETTER SSUU
118BE; C; 118DE; # WARANG CITI CAPITAL LETTER SII
118BF; C; 118DF; # WARANG CITI CAPITAL LETTER VIYO
1E900; C; 1E922; # ADLAM CAPITAL LETTER ALIF
1E901; C; 1E923; # ADLAM CAPITAL LETTER DAALI
1E902; C; 1E924; # ADLAM CAPITAL LETTER LAAM
1E903; C; 1E925; # ADLAM CAPITAL LETTER MIIM
1E904; C; 1E926; # ADLAM CAPITAL LETTER BA
1E905; C; 1E927; # ADLAM CAPITAL LETTER SINNYIIYHE
1E906; C; 1E928; # ADLAM CAPITAL LETTER PE
1E907; C; 1E929; # ADLAM CAPITAL LETTER BHE
1E908; C; 1E92A; # ADLAM CAPITAL LETTER RA
1E909; C; 1E92B; # ADLAM CAPITAL LETTER E
1E90A; C; 1E92C; # ADLAM CAPITAL LETTER FA
1E90B; C; 1E92D; # ADLAM CAPITAL LETTER I
1E90C; C; 1E92E; # ADLAM CAPITAL LETTER O
1E90D; C; 1E92F; # ADLAM CAPITAL LETTER DHA
1E90E; C; 1E930; # ADLAM CAPITAL LETTER YHE
1E90F; C; 1E931; # ADLAM CAPITAL LETTER WAW
1E910; C; 1E932; # ADLAM CAPITAL LETTER NUN
1E911; C; 1E933; # ADLAM CAPITAL LETTER KAF
1E912; C; 1E934; # ADLAM CAPITAL LETTER YA
1E913; C; 1E935; # ADLAM CAPITAL LETTER U
1E914; C; 1E936; # ADLAM CAPITAL LETTER JIIM
1E915; C; 1E937; # ADLAM CAPITAL LETTER CHI
1E916; C; 1E938; # ADLAM CAPITAL LETTER HA
1E917; C; 1E939; # ADLAM CAPITAL LETTER QAAF
1E918; C; 1E93A; # ADLAM CAPITAL LETTER GA
1E919; C; 1E93B; # ADLAM CAPITAL LETTER NYA
1E91A; C; 1E93C; # ADLAM CAPITAL LETTER TU
1E91B; C; 1E93D; # ADLAM CAPITAL LETTER NHA
1E91C; C; 1E93E; # ADLAM CAPITAL LETTER VA
1E91D; C; 1E93F; # ADLAM CAPITAL LETTER KHA
1E91E; C; 1E940; # ADLAM CAPITAL LETTER GBE
1E91F; C; 1E941; # ADLAM CAPITAL LETTER ZAL
1E920; C; 1E942; # ADLAM CAPITAL LETTER KPO
1E921; C; 1E943; # ADLAM CAPITAL LETTER SHA
#
# EOF
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/tagfilter.h | #ifndef CMARK_GFM_TAGFILTER_H
#define CMARK_GFM_TAGFILTER_H
#include "cmark-gfm-core-extensions.h"
cmark_syntax_extension *create_tagfilter_extension(void);
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/table.h | #ifndef CMARK_GFM_TABLE_H
#define CMARK_GFM_TABLE_H
#include "cmark-gfm-core-extensions.h"
extern cmark_node_type CMARK_NODE_TABLE, CMARK_NODE_TABLE_ROW,
CMARK_NODE_TABLE_CELL;
cmark_syntax_extension *create_table_extension(void);
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/ext_scanners.h | #include "chunk.h"
#include "cmark-gfm.h"
#ifdef __cplusplus
extern "C" {
#endif
bufsize_t _ext_scan_at(bufsize_t (*scanner)(const unsigned char *),
unsigned char *ptr, int len, bufsize_t offset);
bufsize_t _scan_table_start(const unsigned char *p);
bufsize_t _scan_table_cell(const unsigned char *p);
bufsize_t _scan_table_cell_end(const unsigned char *p);
bufsize_t _scan_table_row_end(const unsigned char *p);
bufsize_t _scan_tasklist(const unsigned char *p);
#define scan_table_start(c, l, n) _ext_scan_at(&_scan_table_start, c, l, n)
#define scan_table_cell(c, l, n) _ext_scan_at(&_scan_table_cell, c, l, n)
#define scan_table_cell_end(c, l, n) _ext_scan_at(&_scan_table_cell_end, c, l, n)
#define scan_table_row_end(c, l, n) _ext_scan_at(&_scan_table_row_end, c, l, n)
#define scan_tasklist(c, l, n) _ext_scan_at(&_scan_tasklist, c, l, n)
#ifdef __cplusplus
}
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/strikethrough.h | #ifndef CMARK_GFM_STRIKETHROUGH_H
#define CMARK_GFM_STRIKETHROUGH_H
#include "cmark-gfm-core-extensions.h"
extern cmark_node_type CMARK_NODE_STRIKETHROUGH;
cmark_syntax_extension *create_strikethrough_extension(void);
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/ext_scanners.c | /* Generated by re2c 1.3 */
#include "ext_scanners.h"
#include <stdlib.h>
bufsize_t _ext_scan_at(bufsize_t (*scanner)(const unsigned char *),
unsigned char *ptr, int len, bufsize_t offset) {
bufsize_t res;
if (ptr == NULL || offset >= len) {
return 0;
} else {
unsigned char lim = ptr[len];
ptr[len] = '\0';
res = scanner(ptr + offset);
ptr[len] = lim;
}
return res;
}
bufsize_t _scan_table_start(const unsigned char *p) {
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych <= ' ') {
if (yych <= '\n') {
if (yych == '\t')
goto yy4;
} else {
if (yych <= '\f')
goto yy4;
if (yych >= ' ')
goto yy4;
}
} else {
if (yych <= '9') {
if (yych == '-')
goto yy5;
} else {
if (yych <= ':')
goto yy6;
if (yych == '|')
goto yy4;
}
}
++p;
yy3 : { return 0; }
yy4:
yych = *(marker = ++p);
if (yybm[0 + yych] & 64) {
goto yy7;
}
if (yych == '-')
goto yy10;
if (yych == ':')
goto yy12;
goto yy3;
yy5:
yych = *(marker = ++p);
if (yybm[0 + yych] & 128) {
goto yy10;
}
if (yych <= ' ') {
if (yych <= 0x08)
goto yy3;
if (yych <= '\r')
goto yy14;
if (yych <= 0x1F)
goto yy3;
goto yy14;
} else {
if (yych <= ':') {
if (yych <= '9')
goto yy3;
goto yy13;
} else {
if (yych == '|')
goto yy14;
goto yy3;
}
}
yy6:
yych = *(marker = ++p);
if (yybm[0 + yych] & 128) {
goto yy10;
}
goto yy3;
yy7:
yych = *++p;
if (yybm[0 + yych] & 64) {
goto yy7;
}
if (yych == '-')
goto yy10;
if (yych == ':')
goto yy12;
yy9:
p = marker;
goto yy3;
yy10:
yych = *++p;
if (yybm[0 + yych] & 128) {
goto yy10;
}
if (yych <= 0x1F) {
if (yych <= '\n') {
if (yych <= 0x08)
goto yy9;
if (yych <= '\t')
goto yy13;
goto yy15;
} else {
if (yych <= '\f')
goto yy13;
if (yych <= '\r')
goto yy17;
goto yy9;
}
} else {
if (yych <= ':') {
if (yych <= ' ')
goto yy13;
if (yych <= '9')
goto yy9;
goto yy13;
} else {
if (yych == '|')
goto yy18;
goto yy9;
}
}
yy12:
yych = *++p;
if (yybm[0 + yych] & 128) {
goto yy10;
}
goto yy9;
yy13:
yych = *++p;
yy14:
if (yych <= '\r') {
if (yych <= '\t') {
if (yych <= 0x08)
goto yy9;
goto yy13;
} else {
if (yych <= '\n')
goto yy15;
if (yych <= '\f')
goto yy13;
goto yy17;
}
} else {
if (yych <= ' ') {
if (yych <= 0x1F)
goto yy9;
goto yy13;
} else {
if (yych == '|')
goto yy18;
goto yy9;
}
}
yy15:
++p;
{ return (bufsize_t)(p - start); }
yy17:
yych = *++p;
if (yych == '\n')
goto yy15;
goto yy9;
yy18:
yych = *++p;
if (yybm[0 + yych] & 128) {
goto yy10;
}
if (yych <= '\r') {
if (yych <= '\t') {
if (yych <= 0x08)
goto yy9;
goto yy18;
} else {
if (yych <= '\n')
goto yy15;
if (yych <= '\f')
goto yy18;
goto yy17;
}
} else {
if (yych <= ' ') {
if (yych <= 0x1F)
goto yy9;
goto yy18;
} else {
if (yych == ':')
goto yy12;
goto yy9;
}
}
}
}
bufsize_t _scan_table_cell(const unsigned char *p) {
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
unsigned int yyaccept = 0;
static const unsigned char yybm[] = {
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 64, 64, 0, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 128, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 64,
64, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
};
yych = *p;
if (yybm[0 + yych] & 64) {
goto yy22;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\r')
goto yy25;
if (yych <= '\\')
goto yy27;
goto yy25;
} else {
if (yych <= 0xDF)
goto yy29;
if (yych <= 0xE0)
goto yy30;
goto yy31;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED)
goto yy32;
if (yych <= 0xEF)
goto yy31;
goto yy33;
} else {
if (yych <= 0xF3)
goto yy34;
if (yych <= 0xF4)
goto yy35;
goto yy25;
}
}
yy22:
yyaccept = 0;
yych = *(marker = ++p);
if (yybm[0 + yych] & 64) {
goto yy22;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\r')
goto yy24;
if (yych <= '\\')
goto yy27;
} else {
if (yych <= 0xDF)
goto yy36;
if (yych <= 0xE0)
goto yy38;
goto yy39;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED)
goto yy40;
if (yych <= 0xEF)
goto yy39;
goto yy41;
} else {
if (yych <= 0xF3)
goto yy42;
if (yych <= 0xF4)
goto yy43;
}
}
yy24 : { return (bufsize_t)(p - start); }
yy25:
++p;
yy26 : { return 0; }
yy27:
yyaccept = 0;
yych = *(marker = ++p);
if (yybm[0 + yych] & 128) {
goto yy27;
}
if (yych <= 0xDF) {
if (yych <= '\f') {
if (yych == '\n')
goto yy24;
goto yy22;
} else {
if (yych <= '\r')
goto yy24;
if (yych <= 0x7F)
goto yy22;
if (yych <= 0xC1)
goto yy24;
goto yy36;
}
} else {
if (yych <= 0xEF) {
if (yych <= 0xE0)
goto yy38;
if (yych == 0xED)
goto yy40;
goto yy39;
} else {
if (yych <= 0xF0)
goto yy41;
if (yych <= 0xF3)
goto yy42;
if (yych <= 0xF4)
goto yy43;
goto yy24;
}
}
yy29:
yych = *++p;
if (yych <= 0x7F)
goto yy26;
if (yych <= 0xBF)
goto yy22;
goto yy26;
yy30:
yyaccept = 1;
yych = *(marker = ++p);
if (yych <= 0x9F)
goto yy26;
if (yych <= 0xBF)
goto yy36;
goto yy26;
yy31:
yyaccept = 1;
yych = *(marker = ++p);
if (yych <= 0x7F)
goto yy26;
if (yych <= 0xBF)
goto yy36;
goto yy26;
yy32:
yyaccept = 1;
yych = *(marker = ++p);
if (yych <= 0x7F)
goto yy26;
if (yych <= 0x9F)
goto yy36;
goto yy26;
yy33:
yyaccept = 1;
yych = *(marker = ++p);
if (yych <= 0x8F)
goto yy26;
if (yych <= 0xBF)
goto yy39;
goto yy26;
yy34:
yyaccept = 1;
yych = *(marker = ++p);
if (yych <= 0x7F)
goto yy26;
if (yych <= 0xBF)
goto yy39;
goto yy26;
yy35:
yyaccept = 1;
yych = *(marker = ++p);
if (yych <= 0x7F)
goto yy26;
if (yych <= 0x8F)
goto yy39;
goto yy26;
yy36:
yych = *++p;
if (yych <= 0x7F)
goto yy37;
if (yych <= 0xBF)
goto yy22;
yy37:
p = marker;
if (yyaccept == 0) {
goto yy24;
} else {
goto yy26;
}
yy38:
yych = *++p;
if (yych <= 0x9F)
goto yy37;
if (yych <= 0xBF)
goto yy36;
goto yy37;
yy39:
yych = *++p;
if (yych <= 0x7F)
goto yy37;
if (yych <= 0xBF)
goto yy36;
goto yy37;
yy40:
yych = *++p;
if (yych <= 0x7F)
goto yy37;
if (yych <= 0x9F)
goto yy36;
goto yy37;
yy41:
yych = *++p;
if (yych <= 0x8F)
goto yy37;
if (yych <= 0xBF)
goto yy39;
goto yy37;
yy42:
yych = *++p;
if (yych <= 0x7F)
goto yy37;
if (yych <= 0xBF)
goto yy39;
goto yy37;
yy43:
yych = *++p;
if (yych <= 0x7F)
goto yy37;
if (yych <= 0x8F)
goto yy39;
goto yy37;
}
}
bufsize_t _scan_table_cell_end(const unsigned char *p) {
const unsigned char *start = p;
{
unsigned char yych;
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 128, 128, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych == '|')
goto yy48;
++p;
{ return 0; }
yy48:
yych = *++p;
if (yybm[0 + yych] & 128) {
goto yy48;
}
{ return (bufsize_t)(p - start); }
}
}
bufsize_t _scan_table_row_end(const unsigned char *p) {
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 128, 128, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych <= '\f') {
if (yych <= 0x08)
goto yy53;
if (yych == '\n')
goto yy56;
goto yy55;
} else {
if (yych <= '\r')
goto yy58;
if (yych == ' ')
goto yy55;
}
yy53:
++p;
yy54 : { return 0; }
yy55:
yych = *(marker = ++p);
if (yych <= 0x08)
goto yy54;
if (yych <= '\r')
goto yy60;
if (yych == ' ')
goto yy60;
goto yy54;
yy56:
++p;
{ return (bufsize_t)(p - start); }
yy58:
yych = *++p;
if (yych == '\n')
goto yy56;
goto yy54;
yy59:
yych = *++p;
yy60:
if (yybm[0 + yych] & 128) {
goto yy59;
}
if (yych <= 0x08)
goto yy61;
if (yych <= '\n')
goto yy56;
if (yych <= '\r')
goto yy62;
yy61:
p = marker;
goto yy54;
yy62:
yych = *++p;
if (yych == '\n')
goto yy56;
goto yy61;
}
}
bufsize_t _scan_tasklist(const unsigned char *p) {
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 64, 64, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych <= ' ') {
if (yych <= '\n') {
if (yych == '\t')
goto yy67;
} else {
if (yych <= '\f')
goto yy67;
if (yych >= ' ')
goto yy67;
}
} else {
if (yych <= ',') {
if (yych <= ')')
goto yy65;
if (yych <= '+')
goto yy68;
} else {
if (yych <= '-')
goto yy68;
if (yych <= '/')
goto yy65;
if (yych <= '9')
goto yy69;
}
}
yy65:
++p;
yy66 : { return 0; }
yy67:
yych = *(marker = ++p);
if (yybm[0 + yych] & 64) {
goto yy70;
}
if (yych <= ',') {
if (yych <= ')')
goto yy66;
if (yych <= '+')
goto yy73;
goto yy66;
} else {
if (yych <= '-')
goto yy73;
if (yych <= '/')
goto yy66;
if (yych <= '9')
goto yy74;
goto yy66;
}
yy68:
yych = *(marker = ++p);
if (yych <= '\n') {
if (yych == '\t')
goto yy75;
goto yy66;
} else {
if (yych <= '\f')
goto yy75;
if (yych == ' ')
goto yy75;
goto yy66;
}
yy69:
yych = *(marker = ++p);
if (yych <= 0x1F) {
if (yych <= '\t') {
if (yych <= 0x08)
goto yy78;
goto yy73;
} else {
if (yych <= '\n')
goto yy66;
if (yych <= '\f')
goto yy73;
goto yy78;
}
} else {
if (yych <= 0x7F) {
if (yych <= ' ')
goto yy73;
goto yy78;
} else {
if (yych <= 0xC1)
goto yy66;
if (yych <= 0xF4)
goto yy78;
goto yy66;
}
}
yy70:
yych = *++p;
if (yybm[0 + yych] & 64) {
goto yy70;
}
if (yych <= ',') {
if (yych <= ')')
goto yy72;
if (yych <= '+')
goto yy73;
} else {
if (yych <= '-')
goto yy73;
if (yych <= '/')
goto yy72;
if (yych <= '9')
goto yy74;
}
yy72:
p = marker;
goto yy66;
yy73:
yych = *++p;
if (yych == '[')
goto yy72;
goto yy76;
yy74:
yych = *++p;
if (yych <= '\n') {
if (yych == '\t')
goto yy73;
goto yy78;
} else {
if (yych <= '\f')
goto yy73;
if (yych == ' ')
goto yy73;
goto yy78;
}
yy75:
yych = *++p;
yy76:
if (yych <= '\f') {
if (yych == '\t')
goto yy75;
if (yych <= '\n')
goto yy72;
goto yy75;
} else {
if (yych <= ' ') {
if (yych <= 0x1F)
goto yy72;
goto yy75;
} else {
if (yych == '[')
goto yy86;
goto yy72;
}
}
yy77:
yych = *++p;
yy78:
if (yybm[0 + yych] & 128) {
goto yy77;
}
if (yych <= 0xC1) {
if (yych <= '\f') {
if (yych <= 0x08)
goto yy73;
if (yych == '\n')
goto yy72;
goto yy75;
} else {
if (yych == ' ')
goto yy75;
if (yych <= 0x7F)
goto yy73;
goto yy72;
}
} else {
if (yych <= 0xED) {
if (yych <= 0xDF)
goto yy79;
if (yych <= 0xE0)
goto yy80;
if (yych <= 0xEC)
goto yy81;
goto yy82;
} else {
if (yych <= 0xF0) {
if (yych <= 0xEF)
goto yy81;
goto yy83;
} else {
if (yych <= 0xF3)
goto yy84;
if (yych <= 0xF4)
goto yy85;
goto yy72;
}
}
}
yy79:
yych = *++p;
if (yych <= 0x7F)
goto yy72;
if (yych <= 0xBF)
goto yy73;
goto yy72;
yy80:
yych = *++p;
if (yych <= 0x9F)
goto yy72;
if (yych <= 0xBF)
goto yy79;
goto yy72;
yy81:
yych = *++p;
if (yych <= 0x7F)
goto yy72;
if (yych <= 0xBF)
goto yy79;
goto yy72;
yy82:
yych = *++p;
if (yych <= 0x7F)
goto yy72;
if (yych <= 0x9F)
goto yy79;
goto yy72;
yy83:
yych = *++p;
if (yych <= 0x8F)
goto yy72;
if (yych <= 0xBF)
goto yy81;
goto yy72;
yy84:
yych = *++p;
if (yych <= 0x7F)
goto yy72;
if (yych <= 0xBF)
goto yy81;
goto yy72;
yy85:
yych = *++p;
if (yych <= 0x7F)
goto yy72;
if (yych <= 0x8F)
goto yy81;
goto yy72;
yy86:
yych = *++p;
if (yych <= 'W') {
if (yych != ' ')
goto yy72;
} else {
if (yych <= 'X')
goto yy87;
if (yych != 'x')
goto yy72;
}
yy87:
yych = *++p;
if (yych != ']')
goto yy72;
yych = *++p;
if (yych <= '\n') {
if (yych != '\t')
goto yy72;
} else {
if (yych <= '\f')
goto yy89;
if (yych != ' ')
goto yy72;
}
yy89:
yych = *++p;
if (yych <= '\n') {
if (yych == '\t')
goto yy89;
} else {
if (yych <= '\f')
goto yy89;
if (yych == ' ')
goto yy89;
}
{ return (bufsize_t)(p - start); }
}
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/strikethrough.c | #include "strikethrough.h"
#include <parser.h>
#include <render.h>
cmark_node_type CMARK_NODE_STRIKETHROUGH;
static cmark_node *match(cmark_syntax_extension *self, cmark_parser *parser,
cmark_node *parent, unsigned char character,
cmark_inline_parser *inline_parser) {
cmark_node *res = NULL;
int left_flanking, right_flanking, punct_before, punct_after, delims;
char buffer[101];
if (character != '~')
return NULL;
delims = cmark_inline_parser_scan_delimiters(
inline_parser, sizeof(buffer) - 1, '~',
&left_flanking,
&right_flanking, &punct_before, &punct_after);
memset(buffer, '~', delims);
buffer[delims] = 0;
res = cmark_node_new_with_mem(CMARK_NODE_TEXT, parser->mem);
cmark_node_set_literal(res, buffer);
res->start_line = res->end_line = cmark_inline_parser_get_line(inline_parser);
res->start_column = cmark_inline_parser_get_column(inline_parser) - delims;
if ((left_flanking || right_flanking) &&
(delims == 2 || (!(parser->options & CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE) && delims == 1))) {
cmark_inline_parser_push_delimiter(inline_parser, character, left_flanking,
right_flanking, res);
}
return res;
}
static delimiter *insert(cmark_syntax_extension *self, cmark_parser *parser,
cmark_inline_parser *inline_parser, delimiter *opener,
delimiter *closer) {
cmark_node *strikethrough;
cmark_node *tmp, *next;
delimiter *delim, *tmp_delim;
delimiter *res = closer->next;
strikethrough = opener->inl_text;
if (opener->inl_text->as.literal.len != closer->inl_text->as.literal.len)
goto done;
if (!cmark_node_set_type(strikethrough, CMARK_NODE_STRIKETHROUGH))
goto done;
cmark_node_set_syntax_extension(strikethrough, self);
tmp = cmark_node_next(opener->inl_text);
while (tmp) {
if (tmp == closer->inl_text)
break;
next = cmark_node_next(tmp);
cmark_node_append_child(strikethrough, tmp);
tmp = next;
}
strikethrough->end_column = closer->inl_text->start_column + closer->inl_text->as.literal.len - 1;
cmark_node_free(closer->inl_text);
delim = closer;
while (delim != NULL && delim != opener) {
tmp_delim = delim->previous;
cmark_inline_parser_remove_delimiter(inline_parser, delim);
delim = tmp_delim;
}
cmark_inline_parser_remove_delimiter(inline_parser, opener);
done:
return res;
}
static const char *get_type_string(cmark_syntax_extension *extension,
cmark_node *node) {
return node->type == CMARK_NODE_STRIKETHROUGH ? "strikethrough" : "<unknown>";
}
static int can_contain(cmark_syntax_extension *extension, cmark_node *node,
cmark_node_type child_type) {
if (node->type != CMARK_NODE_STRIKETHROUGH)
return false;
return CMARK_NODE_TYPE_INLINE_P(child_type);
}
static void commonmark_render(cmark_syntax_extension *extension,
cmark_renderer *renderer, cmark_node *node,
cmark_event_type ev_type, int options) {
renderer->out(renderer, node, "~~", false, LITERAL);
}
static void latex_render(cmark_syntax_extension *extension,
cmark_renderer *renderer, cmark_node *node,
cmark_event_type ev_type, int options) {
// requires \usepackage{ulem}
bool entering = (ev_type == CMARK_EVENT_ENTER);
if (entering) {
renderer->out(renderer, node, "\\sout{", false, LITERAL);
} else {
renderer->out(renderer, node, "}", false, LITERAL);
}
}
static void man_render(cmark_syntax_extension *extension,
cmark_renderer *renderer, cmark_node *node,
cmark_event_type ev_type, int options) {
bool entering = (ev_type == CMARK_EVENT_ENTER);
if (entering) {
renderer->cr(renderer);
renderer->out(renderer, node, ".ST \"", false, LITERAL);
} else {
renderer->out(renderer, node, "\"", false, LITERAL);
renderer->cr(renderer);
}
}
static void html_render(cmark_syntax_extension *extension,
cmark_html_renderer *renderer, cmark_node *node,
cmark_event_type ev_type, int options) {
bool entering = (ev_type == CMARK_EVENT_ENTER);
if (entering) {
cmark_strbuf_puts(renderer->html, "<del>");
} else {
cmark_strbuf_puts(renderer->html, "</del>");
}
}
static void plaintext_render(cmark_syntax_extension *extension,
cmark_renderer *renderer, cmark_node *node,
cmark_event_type ev_type, int options) {
renderer->out(renderer, node, "~", false, LITERAL);
}
cmark_syntax_extension *create_strikethrough_extension(void) {
cmark_syntax_extension *ext = cmark_syntax_extension_new("strikethrough");
cmark_llist *special_chars = NULL;
cmark_syntax_extension_set_get_type_string_func(ext, get_type_string);
cmark_syntax_extension_set_can_contain_func(ext, can_contain);
cmark_syntax_extension_set_commonmark_render_func(ext, commonmark_render);
cmark_syntax_extension_set_latex_render_func(ext, latex_render);
cmark_syntax_extension_set_man_render_func(ext, man_render);
cmark_syntax_extension_set_html_render_func(ext, html_render);
cmark_syntax_extension_set_plaintext_render_func(ext, plaintext_render);
CMARK_NODE_STRIKETHROUGH = cmark_syntax_extension_add_node(1);
cmark_syntax_extension_set_match_inline_func(ext, match);
cmark_syntax_extension_set_inline_from_delim_func(ext, insert);
cmark_mem *mem = cmark_get_default_mem_allocator();
special_chars = cmark_llist_append(mem, special_chars, (void *)'~');
cmark_syntax_extension_set_special_inline_chars(ext, special_chars);
cmark_syntax_extension_set_emphasis(ext, 1);
return ext;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/CMakeLists.txt | cmake_minimum_required(VERSION 2.8)
set(LIBRARY "libcmark-gfm-extensions")
set(STATICLIBRARY "libcmark-gfm-extensions_static")
set(LIBRARY_SOURCES
core-extensions.c
table.c
strikethrough.c
autolink.c
tagfilter.c
ext_scanners.c
ext_scanners.re
ext_scanners.h
tasklist.c
)
include_directories(
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src
)
include (GenerateExportHeader)
include_directories(. ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg")
set(CMAKE_LINKER_PROFILE "${CMAKE_LINKER_FLAGS_RELEASE} -pg")
add_compiler_export_flags()
if (CMARK_SHARED)
add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})
set_target_properties(${LIBRARY} PROPERTIES
OUTPUT_NAME "cmark-gfm-extensions"
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.gfm.${PROJECT_VERSION_GFM}
VERSION ${PROJECT_VERSION})
set_property(TARGET ${LIBRARY}
APPEND PROPERTY MACOSX_RPATH true)
# Avoid name clash between PROGRAM and LIBRARY pdb files.
set_target_properties(${LIBRARY} PROPERTIES PDB_NAME cmark-gfm-extensions_dll)
generate_export_header(${LIBRARY}
BASE_NAME cmark-gfm-extensions)
list(APPEND CMARK_INSTALL ${LIBRARY})
target_link_libraries(${LIBRARY} libcmark-gfm)
endif()
if (CMARK_STATIC)
add_library(${STATICLIBRARY} STATIC ${LIBRARY_SOURCES})
set_target_properties(${STATICLIBRARY} PROPERTIES
COMPILE_FLAGS "-DCMARK_GFM_STATIC_DEFINE -DCMARK_GFM_EXTENSIONS_STATIC_DEFINE"
POSITION_INDEPENDENT_CODE ON)
if (MSVC)
set_target_properties(${STATICLIBRARY} PROPERTIES
OUTPUT_NAME "cmark-gfm-extensions_static"
VERSION ${PROJECT_VERSION})
else()
set_target_properties(${STATICLIBRARY} PROPERTIES
OUTPUT_NAME "cmark-gfm-extensions"
VERSION ${PROJECT_VERSION})
endif(MSVC)
if (NOT CMARK_SHARED)
generate_export_header(${STATICLIBRARY}
BASE_NAME cmark-gfm-extensions)
endif()
list(APPEND CMARK_INSTALL ${STATICLIBRARY})
endif()
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
include (InstallRequiredSystemLibraries)
install(TARGETS ${CMARK_INSTALL}
EXPORT cmark-gfm-extensions
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
)
if (CMARK_SHARED OR CMARK_STATIC)
install(FILES
cmark-gfm-core-extensions.h
${CMAKE_CURRENT_BINARY_DIR}/cmark-gfm-extensions_export.h
DESTINATION include
)
install(EXPORT cmark-gfm-extensions DESTINATION lib${LIB_SUFFIX}/cmake-gfm-extensions)
endif()
# Feature tests
include(CheckIncludeFile)
include(CheckCSourceCompiles)
include(CheckCSourceRuns)
include(CheckSymbolExists)
CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H)
CHECK_C_SOURCE_COMPILES(
"int main() { __builtin_expect(0,0); return 0; }"
HAVE___BUILTIN_EXPECT)
CHECK_C_SOURCE_COMPILES("
int f(void) __attribute__ (());
int main() { return 0; }
" HAVE___ATTRIBUTE__)
# Always compile with warnings
if(MSVC)
# Force to always compile with W4
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX /wd4706 /wd4204 /wd4221 /wd4100 /D_CRT_SECURE_NO_WARNINGS")
elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -std=c99 -pedantic")
endif()
# Compile as C++ under MSVC older than 12.0
if(MSVC AND MSVC_VERSION LESS 1800)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TP")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Ubsan")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
endif()
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/autolink.h | #ifndef CMARK_GFM_AUTOLINK_H
#define CMARK_GFM_AUTOLINK_H
#include "cmark-gfm-core-extensions.h"
cmark_syntax_extension *create_autolink_extension(void);
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/tasklist.h | #ifndef TASKLIST_H
#define TASKLIST_H
#include "cmark-gfm-core-extensions.h"
cmark_syntax_extension *create_tasklist_extension(void);
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/autolink.c | #include "autolink.h"
#include <parser.h>
#include <string.h>
#include <utf8.h>
#if defined(_WIN32)
#define strncasecmp _strnicmp
#else
#include <strings.h>
#endif
static int is_valid_hostchar(const uint8_t *link, size_t link_len) {
int32_t ch;
int r = cmark_utf8proc_iterate(link, (bufsize_t)link_len, &ch);
if (r < 0)
return 0;
return !cmark_utf8proc_is_space(ch) && !cmark_utf8proc_is_punctuation(ch);
}
static int sd_autolink_issafe(const uint8_t *link, size_t link_len) {
static const size_t valid_uris_count = 3;
static const char *valid_uris[] = {"http://", "https://", "ftp://"};
size_t i;
for (i = 0; i < valid_uris_count; ++i) {
size_t len = strlen(valid_uris[i]);
if (link_len > len && strncasecmp((char *)link, valid_uris[i], len) == 0 &&
is_valid_hostchar(link + len, link_len - len))
return 1;
}
return 0;
}
static size_t autolink_delim(uint8_t *data, size_t link_end) {
uint8_t cclose, copen;
size_t i;
for (i = 0; i < link_end; ++i)
if (data[i] == '<') {
link_end = i;
break;
}
while (link_end > 0) {
cclose = data[link_end - 1];
switch (cclose) {
case ')':
copen = '(';
break;
default:
copen = 0;
}
if (strchr("?!.,:*_~'\"", data[link_end - 1]) != NULL)
link_end--;
else if (data[link_end - 1] == ';') {
size_t new_end = link_end - 2;
while (new_end > 0 && cmark_isalpha(data[new_end]))
new_end--;
if (new_end < link_end - 2 && data[new_end] == '&')
link_end = new_end;
else
link_end--;
} else if (copen != 0) {
size_t closing = 0;
size_t opening = 0;
i = 0;
/* Allow any number of matching brackets (as recognised in copen/cclose)
* at the end of the URL. If there is a greater number of closing
* brackets than opening ones, we remove one character from the end of
* the link.
*
* Examples (input text => output linked portion):
*
* http://www.pokemon.com/Pikachu_(Electric)
* => http://www.pokemon.com/Pikachu_(Electric)
*
* http://www.pokemon.com/Pikachu_((Electric)
* => http://www.pokemon.com/Pikachu_((Electric)
*
* http://www.pokemon.com/Pikachu_(Electric))
* => http://www.pokemon.com/Pikachu_(Electric)
*
* http://www.pokemon.com/Pikachu_((Electric))
* => http://www.pokemon.com/Pikachu_((Electric))
*/
while (i < link_end) {
if (data[i] == copen)
opening++;
else if (data[i] == cclose)
closing++;
i++;
}
if (closing <= opening)
break;
link_end--;
} else
break;
}
return link_end;
}
static size_t check_domain(uint8_t *data, size_t size, int allow_short) {
size_t i, np = 0, uscore1 = 0, uscore2 = 0;
for (i = 1; i < size - 1; i++) {
if (data[i] == '_')
uscore2++;
else if (data[i] == '.') {
uscore1 = uscore2;
uscore2 = 0;
np++;
} else if (!is_valid_hostchar(data + i, size - i) && data[i] != '-')
break;
}
if (uscore1 > 0 || uscore2 > 0)
return 0;
if (allow_short) {
/* We don't need a valid domain in the strict sense (with
* least one dot; so just make sure it's composed of valid
* domain characters and return the length of the the valid
* sequence. */
return i;
} else {
/* a valid domain needs to have at least a dot.
* that's as far as we get */
return np ? i : 0;
}
}
static cmark_node *www_match(cmark_parser *parser, cmark_node *parent,
cmark_inline_parser *inline_parser) {
cmark_chunk *chunk = cmark_inline_parser_get_chunk(inline_parser);
size_t max_rewind = cmark_inline_parser_get_offset(inline_parser);
uint8_t *data = chunk->data + max_rewind;
size_t size = chunk->len - max_rewind;
int start = cmark_inline_parser_get_column(inline_parser);
size_t link_end;
if (max_rewind > 0 && strchr("*_~(", data[-1]) == NULL &&
!cmark_isspace(data[-1]))
return 0;
if (size < 4 || memcmp(data, "www.", strlen("www.")) != 0)
return 0;
link_end = check_domain(data, size, 0);
if (link_end == 0)
return NULL;
while (link_end < size && !cmark_isspace(data[link_end]))
link_end++;
link_end = autolink_delim(data, link_end);
if (link_end == 0)
return NULL;
cmark_inline_parser_set_offset(inline_parser, (int)(max_rewind + link_end));
cmark_node *node = cmark_node_new_with_mem(CMARK_NODE_LINK, parser->mem);
cmark_strbuf buf;
cmark_strbuf_init(parser->mem, &buf, 10);
cmark_strbuf_puts(&buf, "http://");
cmark_strbuf_put(&buf, data, (bufsize_t)link_end);
node->as.link.url = cmark_chunk_buf_detach(&buf);
cmark_node *text = cmark_node_new_with_mem(CMARK_NODE_TEXT, parser->mem);
text->as.literal =
cmark_chunk_dup(chunk, (bufsize_t)max_rewind, (bufsize_t)link_end);
cmark_node_append_child(node, text);
node->start_line = text->start_line =
node->end_line = text->end_line =
cmark_inline_parser_get_line(inline_parser);
node->start_column = text->start_column = start - 1;
node->end_column = text->end_column = cmark_inline_parser_get_column(inline_parser) - 1;
return node;
}
static cmark_node *url_match(cmark_parser *parser, cmark_node *parent,
cmark_inline_parser *inline_parser) {
size_t link_end, domain_len;
int rewind = 0;
cmark_chunk *chunk = cmark_inline_parser_get_chunk(inline_parser);
int max_rewind = cmark_inline_parser_get_offset(inline_parser);
uint8_t *data = chunk->data + max_rewind;
size_t size = chunk->len - max_rewind;
if (size < 4 || data[1] != '/' || data[2] != '/')
return 0;
while (rewind < max_rewind && cmark_isalpha(data[-rewind - 1]))
rewind++;
if (!sd_autolink_issafe(data - rewind, size + rewind))
return 0;
link_end = strlen("://");
domain_len = check_domain(data + link_end, size - link_end, 1);
if (domain_len == 0)
return 0;
link_end += domain_len;
while (link_end < size && !cmark_isspace(data[link_end]))
link_end++;
link_end = autolink_delim(data, link_end);
if (link_end == 0)
return NULL;
cmark_inline_parser_set_offset(inline_parser, (int)(max_rewind + link_end));
cmark_node_unput(parent, rewind);
cmark_node *node = cmark_node_new_with_mem(CMARK_NODE_LINK, parser->mem);
cmark_chunk url = cmark_chunk_dup(chunk, max_rewind - rewind,
(bufsize_t)(link_end + rewind));
node->as.link.url = url;
cmark_node *text = cmark_node_new_with_mem(CMARK_NODE_TEXT, parser->mem);
text->as.literal = url;
cmark_node_append_child(node, text);
return node;
}
static cmark_node *match(cmark_syntax_extension *ext, cmark_parser *parser,
cmark_node *parent, unsigned char c,
cmark_inline_parser *inline_parser) {
if (cmark_inline_parser_in_bracket(inline_parser, false) ||
cmark_inline_parser_in_bracket(inline_parser, true))
return NULL;
if (c == ':')
return url_match(parser, parent, inline_parser);
if (c == 'w')
return www_match(parser, parent, inline_parser);
return NULL;
// note that we could end up re-consuming something already a
// part of an inline, because we don't track when the last
// inline was finished in inlines.c.
}
static void postprocess_text(cmark_parser *parser, cmark_node *text, int offset, int depth) {
// postprocess_text can recurse very deeply if there is a very long line of
// '@' only. Stop at a reasonable depth to ensure it cannot crash.
if (depth > 1000) return;
size_t link_end;
uint8_t *data = text->as.literal.data,
*at;
size_t size = text->as.literal.len;
int rewind, max_rewind,
nb = 0, np = 0, ns = 0;
if (offset < 0 || (size_t)offset >= size)
return;
data += offset;
size -= offset;
at = (uint8_t *)memchr(data, '@', size);
if (!at)
return;
max_rewind = (int)(at - data);
data += max_rewind;
size -= max_rewind;
for (rewind = 0; rewind < max_rewind; ++rewind) {
uint8_t c = data[-rewind - 1];
if (cmark_isalnum(c))
continue;
if (strchr(".+-_", c) != NULL)
continue;
if (c == '/')
ns++;
break;
}
if (rewind == 0 || ns > 0) {
postprocess_text(parser, text, max_rewind + 1 + offset, depth + 1);
return;
}
for (link_end = 0; link_end < size; ++link_end) {
uint8_t c = data[link_end];
if (cmark_isalnum(c))
continue;
if (c == '@')
nb++;
else if (c == '.' && link_end < size - 1 && cmark_isalnum(data[link_end + 1]))
np++;
else if (c != '-' && c != '_')
break;
}
if (link_end < 2 || nb != 1 || np == 0 ||
(!cmark_isalpha(data[link_end - 1]) && data[link_end - 1] != '.')) {
postprocess_text(parser, text, max_rewind + 1 + offset, depth + 1);
return;
}
link_end = autolink_delim(data, link_end);
if (link_end == 0) {
postprocess_text(parser, text, max_rewind + 1 + offset, depth + 1);
return;
}
cmark_chunk_to_cstr(parser->mem, &text->as.literal);
cmark_node *link_node = cmark_node_new_with_mem(CMARK_NODE_LINK, parser->mem);
cmark_strbuf buf;
cmark_strbuf_init(parser->mem, &buf, 10);
cmark_strbuf_puts(&buf, "mailto:");
cmark_strbuf_put(&buf, data - rewind, (bufsize_t)(link_end + rewind));
link_node->as.link.url = cmark_chunk_buf_detach(&buf);
cmark_node *link_text = cmark_node_new_with_mem(CMARK_NODE_TEXT, parser->mem);
cmark_chunk email = cmark_chunk_dup(
&text->as.literal,
offset + max_rewind - rewind,
(bufsize_t)(link_end + rewind));
cmark_chunk_to_cstr(parser->mem, &email);
link_text->as.literal = email;
cmark_node_append_child(link_node, link_text);
cmark_node_insert_after(text, link_node);
cmark_node *post = cmark_node_new_with_mem(CMARK_NODE_TEXT, parser->mem);
post->as.literal = cmark_chunk_dup(&text->as.literal,
(bufsize_t)(offset + max_rewind + link_end),
(bufsize_t)(size - link_end));
cmark_chunk_to_cstr(parser->mem, &post->as.literal);
cmark_node_insert_after(link_node, post);
text->as.literal.len = offset + max_rewind - rewind;
text->as.literal.data[text->as.literal.len] = 0;
postprocess_text(parser, post, 0, depth + 1);
}
static cmark_node *postprocess(cmark_syntax_extension *ext, cmark_parser *parser, cmark_node *root) {
cmark_iter *iter;
cmark_event_type ev;
cmark_node *node;
bool in_link = false;
cmark_consolidate_text_nodes(root);
iter = cmark_iter_new(root);
while ((ev = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
node = cmark_iter_get_node(iter);
if (in_link) {
if (ev == CMARK_EVENT_EXIT && node->type == CMARK_NODE_LINK) {
in_link = false;
}
continue;
}
if (ev == CMARK_EVENT_ENTER && node->type == CMARK_NODE_LINK) {
in_link = true;
continue;
}
if (ev == CMARK_EVENT_ENTER && node->type == CMARK_NODE_TEXT) {
postprocess_text(parser, node, 0, /*depth*/0);
}
}
cmark_iter_free(iter);
return root;
}
cmark_syntax_extension *create_autolink_extension(void) {
cmark_syntax_extension *ext = cmark_syntax_extension_new("autolink");
cmark_llist *special_chars = NULL;
cmark_syntax_extension_set_match_inline_func(ext, match);
cmark_syntax_extension_set_postprocess_func(ext, postprocess);
cmark_mem *mem = cmark_get_default_mem_allocator();
special_chars = cmark_llist_append(mem, special_chars, (void *)':');
special_chars = cmark_llist_append(mem, special_chars, (void *)'w');
cmark_syntax_extension_set_special_inline_chars(ext, special_chars);
return ext;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/core-extensions.c | #include "cmark-gfm-core-extensions.h"
#include "autolink.h"
#include "strikethrough.h"
#include "table.h"
#include "tagfilter.h"
#include "tasklist.h"
#include "registry.h"
#include "plugin.h"
static int core_extensions_registration(cmark_plugin *plugin) {
cmark_plugin_register_syntax_extension(plugin, create_table_extension());
cmark_plugin_register_syntax_extension(plugin,
create_strikethrough_extension());
cmark_plugin_register_syntax_extension(plugin, create_autolink_extension());
cmark_plugin_register_syntax_extension(plugin, create_tagfilter_extension());
cmark_plugin_register_syntax_extension(plugin, create_tasklist_extension());
return 1;
}
void cmark_gfm_core_extensions_ensure_registered(void) {
static int registered = 0;
if (!registered) {
cmark_register_plugin(core_extensions_registration);
registered = 1;
}
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/tagfilter.c | #include "tagfilter.h"
#include <parser.h>
#include <ctype.h>
static const char *blacklist[] = {
"title", "textarea", "style", "xmp", "iframe",
"noembed", "noframes", "script", "plaintext", NULL,
};
static int is_tag(const unsigned char *tag_data, size_t tag_size,
const char *tagname) {
size_t i;
if (tag_size < 3 || tag_data[0] != '<')
return 0;
i = 1;
if (tag_data[i] == '/') {
i++;
}
for (; i < tag_size; ++i, ++tagname) {
if (*tagname == 0)
break;
if (tolower(tag_data[i]) != *tagname)
return 0;
}
if (i == tag_size)
return 0;
if (cmark_isspace(tag_data[i]) || tag_data[i] == '>')
return 1;
if (tag_data[i] == '/' && tag_size >= i + 2 && tag_data[i + 1] == '>')
return 1;
return 0;
}
static int filter(cmark_syntax_extension *ext, const unsigned char *tag,
size_t tag_len) {
const char **it;
for (it = blacklist; *it; ++it) {
if (is_tag(tag, tag_len, *it)) {
return 0;
}
}
return 1;
}
cmark_syntax_extension *create_tagfilter_extension(void) {
cmark_syntax_extension *ext = cmark_syntax_extension_new("tagfilter");
cmark_syntax_extension_set_html_filter_func(ext, filter);
return ext;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/table.c | #include <cmark-gfm-extension_api.h>
#include <html.h>
#include <inlines.h>
#include <parser.h>
#include <references.h>
#include <string.h>
#include <render.h>
#include "ext_scanners.h"
#include "strikethrough.h"
#include "table.h"
#include "cmark-gfm-core-extensions.h"
cmark_node_type CMARK_NODE_TABLE, CMARK_NODE_TABLE_ROW,
CMARK_NODE_TABLE_CELL;
typedef struct {
uint16_t n_columns;
int paragraph_offset;
cmark_llist *cells;
} table_row;
typedef struct {
uint16_t n_columns;
uint8_t *alignments;
} node_table;
typedef struct {
bool is_header;
} node_table_row;
typedef struct {
cmark_strbuf *buf;
int start_offset, end_offset, internal_offset;
} node_cell;
static void free_table_cell(cmark_mem *mem, void *data) {
node_cell *cell = (node_cell *)data;
cmark_strbuf_free((cmark_strbuf *)cell->buf);
mem->free(cell->buf);
mem->free(cell);
}
static void free_table_row(cmark_mem *mem, table_row *row) {
if (!row)
return;
cmark_llist_free_full(mem, row->cells, (cmark_free_func)free_table_cell);
mem->free(row);
}
static void free_node_table(cmark_mem *mem, void *ptr) {
node_table *t = (node_table *)ptr;
mem->free(t->alignments);
mem->free(t);
}
static void free_node_table_row(cmark_mem *mem, void *ptr) {
mem->free(ptr);
}
static int get_n_table_columns(cmark_node *node) {
if (!node || node->type != CMARK_NODE_TABLE)
return -1;
return (int)((node_table *)node->as.opaque)->n_columns;
}
static int set_n_table_columns(cmark_node *node, uint16_t n_columns) {
if (!node || node->type != CMARK_NODE_TABLE)
return 0;
((node_table *)node->as.opaque)->n_columns = n_columns;
return 1;
}
static uint8_t *get_table_alignments(cmark_node *node) {
if (!node || node->type != CMARK_NODE_TABLE)
return 0;
return ((node_table *)node->as.opaque)->alignments;
}
static int set_table_alignments(cmark_node *node, uint8_t *alignments) {
if (!node || node->type != CMARK_NODE_TABLE)
return 0;
((node_table *)node->as.opaque)->alignments = alignments;
return 1;
}
static cmark_strbuf *unescape_pipes(cmark_mem *mem, unsigned char *string, bufsize_t len)
{
cmark_strbuf *res = (cmark_strbuf *)mem->calloc(1, sizeof(cmark_strbuf));
bufsize_t r, w;
cmark_strbuf_init(mem, res, len + 1);
cmark_strbuf_put(res, string, len);
cmark_strbuf_putc(res, '\0');
for (r = 0, w = 0; r < len; ++r) {
if (res->ptr[r] == '\\' && res->ptr[r + 1] == '|')
r++;
res->ptr[w++] = res->ptr[r];
}
cmark_strbuf_truncate(res, w);
return res;
}
static table_row *row_from_string(cmark_syntax_extension *self,
cmark_parser *parser, unsigned char *string,
int len) {
// Parses a single table row. It has the following form:
// `delim? table_cell (delim table_cell)* delim? newline`
// Note that cells are allowed to be empty.
//
// From the GitHub-flavored Markdown specification:
//
// > Each row consists of cells containing arbitrary text, in which inlines
// > are parsed, separated by pipes (|). A leading and trailing pipe is also
// > recommended for clarity of reading, and if there’s otherwise parsing
// > ambiguity.
table_row *row = NULL;
bufsize_t cell_matched = 1, pipe_matched = 1, offset;
int expect_more_cells = 1;
int row_end_offset = 0;
row = (table_row *)parser->mem->calloc(1, sizeof(table_row));
row->n_columns = 0;
row->cells = NULL;
// Scan past the (optional) leading pipe.
offset = scan_table_cell_end(string, len, 0);
// Parse the cells of the row. Stop if we reach the end of the input, or if we
// cannot detect any more cells.
while (offset < len && expect_more_cells) {
cell_matched = scan_table_cell(string, len, offset);
pipe_matched = scan_table_cell_end(string, len, offset + cell_matched);
if (cell_matched || pipe_matched) {
// We are guaranteed to have a cell, since (1) either we found some
// content and cell_matched, or (2) we found an empty cell followed by a
// pipe.
cmark_strbuf *cell_buf = unescape_pipes(parser->mem, string + offset,
cell_matched);
cmark_strbuf_trim(cell_buf);
node_cell *cell = (node_cell *)parser->mem->calloc(1, sizeof(*cell));
cell->buf = cell_buf;
cell->start_offset = offset;
cell->end_offset = offset + cell_matched - 1;
while (cell->start_offset > 0 && string[cell->start_offset - 1] != '|') {
--cell->start_offset;
++cell->internal_offset;
}
row->n_columns += 1;
row->cells = cmark_llist_append(parser->mem, row->cells, cell);
}
offset += cell_matched + pipe_matched;
if (pipe_matched) {
expect_more_cells = 1;
} else {
// We've scanned the last cell. Check if we have reached the end of the row
row_end_offset = scan_table_row_end(string, len, offset);
offset += row_end_offset;
// If the end of the row is not the end of the input,
// the row is not a real row but potentially part of the paragraph
// preceding the table.
if (row_end_offset && offset != len) {
row->paragraph_offset = offset;
cmark_llist_free_full(parser->mem, row->cells, (cmark_free_func)free_table_cell);
row->cells = NULL;
row->n_columns = 0;
// Scan past the (optional) leading pipe.
offset += scan_table_cell_end(string, len, offset);
expect_more_cells = 1;
} else {
expect_more_cells = 0;
}
}
}
if (offset != len || row->n_columns == 0) {
free_table_row(parser->mem, row);
row = NULL;
}
return row;
}
static void try_inserting_table_header_paragraph(cmark_parser *parser,
cmark_node *parent_container,
unsigned char *parent_string,
int paragraph_offset) {
cmark_node *paragraph;
cmark_strbuf *paragraph_content;
paragraph = cmark_node_new_with_mem(CMARK_NODE_PARAGRAPH, parser->mem);
paragraph_content = unescape_pipes(parser->mem, parent_string, paragraph_offset);
cmark_strbuf_trim(paragraph_content);
cmark_node_set_string_content(paragraph, (char *) paragraph_content->ptr);
cmark_strbuf_free(paragraph_content);
parser->mem->free(paragraph_content);
if (!cmark_node_insert_before(parent_container, paragraph)) {
parser->mem->free(paragraph);
}
}
static cmark_node *try_opening_table_header(cmark_syntax_extension *self,
cmark_parser *parser,
cmark_node *parent_container,
unsigned char *input, int len) {
cmark_node *table_header;
table_row *header_row = NULL;
table_row *marker_row = NULL;
node_table_row *ntr;
const char *parent_string;
uint16_t i;
if (!scan_table_start(input, len, cmark_parser_get_first_nonspace(parser))) {
return parent_container;
}
// Since scan_table_start was successful, we must have a marker row.
marker_row = row_from_string(self, parser,
input + cmark_parser_get_first_nonspace(parser),
len - cmark_parser_get_first_nonspace(parser));
assert(marker_row);
cmark_arena_push();
// Check for a matching header row. We call `row_from_string` with the entire
// (potentially long) parent container as input, but this should be safe since
// `row_from_string` bails out early if it does not find a row.
parent_string = cmark_node_get_string_content(parent_container);
header_row = row_from_string(self, parser, (unsigned char *)parent_string,
(int)strlen(parent_string));
if (!header_row || header_row->n_columns != marker_row->n_columns) {
free_table_row(parser->mem, marker_row);
free_table_row(parser->mem, header_row);
cmark_arena_pop();
return parent_container;
}
if (cmark_arena_pop()) {
marker_row = row_from_string(
self, parser, input + cmark_parser_get_first_nonspace(parser),
len - cmark_parser_get_first_nonspace(parser));
header_row = row_from_string(self, parser, (unsigned char *)parent_string,
(int)strlen(parent_string));
}
if (!cmark_node_set_type(parent_container, CMARK_NODE_TABLE)) {
free_table_row(parser->mem, header_row);
free_table_row(parser->mem, marker_row);
return parent_container;
}
if (header_row->paragraph_offset) {
try_inserting_table_header_paragraph(parser, parent_container, (unsigned char *)parent_string,
header_row->paragraph_offset);
}
cmark_node_set_syntax_extension(parent_container, self);
parent_container->as.opaque = parser->mem->calloc(1, sizeof(node_table));
set_n_table_columns(parent_container, header_row->n_columns);
uint8_t *alignments =
(uint8_t *)parser->mem->calloc(header_row->n_columns, sizeof(uint8_t));
cmark_llist *it = marker_row->cells;
for (i = 0; it; it = it->next, ++i) {
node_cell *node = (node_cell *)it->data;
bool left = node->buf->ptr[0] == ':', right = node->buf->ptr[node->buf->size - 1] == ':';
if (left && right)
alignments[i] = 'c';
else if (left)
alignments[i] = 'l';
else if (right)
alignments[i] = 'r';
}
set_table_alignments(parent_container, alignments);
table_header =
cmark_parser_add_child(parser, parent_container, CMARK_NODE_TABLE_ROW,
parent_container->start_column);
cmark_node_set_syntax_extension(table_header, self);
table_header->end_column = parent_container->start_column + (int)strlen(parent_string) - 2;
table_header->start_line = table_header->end_line = parent_container->start_line;
table_header->as.opaque = ntr = (node_table_row *)parser->mem->calloc(1, sizeof(node_table_row));
ntr->is_header = true;
{
cmark_llist *tmp;
for (tmp = header_row->cells; tmp; tmp = tmp->next) {
node_cell *cell = (node_cell *) tmp->data;
cmark_node *header_cell = cmark_parser_add_child(parser, table_header,
CMARK_NODE_TABLE_CELL, parent_container->start_column + cell->start_offset);
header_cell->start_line = header_cell->end_line = parent_container->start_line;
header_cell->internal_offset = cell->internal_offset;
header_cell->end_column = parent_container->start_column + cell->end_offset;
cmark_node_set_string_content(header_cell, (char *) cell->buf->ptr);
cmark_node_set_syntax_extension(header_cell, self);
}
}
cmark_parser_advance_offset(
parser, (char *)input,
(int)strlen((char *)input) - 1 - cmark_parser_get_offset(parser), false);
free_table_row(parser->mem, header_row);
free_table_row(parser->mem, marker_row);
return parent_container;
}
static cmark_node *try_opening_table_row(cmark_syntax_extension *self,
cmark_parser *parser,
cmark_node *parent_container,
unsigned char *input, int len) {
cmark_node *table_row_block;
table_row *row;
if (cmark_parser_is_blank(parser))
return NULL;
table_row_block =
cmark_parser_add_child(parser, parent_container, CMARK_NODE_TABLE_ROW,
parent_container->start_column);
cmark_node_set_syntax_extension(table_row_block, self);
table_row_block->end_column = parent_container->end_column;
table_row_block->as.opaque = parser->mem->calloc(1, sizeof(node_table_row));
row = row_from_string(self, parser, input + cmark_parser_get_first_nonspace(parser),
len - cmark_parser_get_first_nonspace(parser));
{
cmark_llist *tmp;
int i, table_columns = get_n_table_columns(parent_container);
for (tmp = row->cells, i = 0; tmp && i < table_columns; tmp = tmp->next, ++i) {
node_cell *cell = (node_cell *) tmp->data;
cmark_node *node = cmark_parser_add_child(parser, table_row_block,
CMARK_NODE_TABLE_CELL, parent_container->start_column + cell->start_offset);
node->internal_offset = cell->internal_offset;
node->end_column = parent_container->start_column + cell->end_offset;
cmark_node_set_string_content(node, (char *) cell->buf->ptr);
cmark_node_set_syntax_extension(node, self);
}
for (; i < table_columns; ++i) {
cmark_node *node = cmark_parser_add_child(
parser, table_row_block, CMARK_NODE_TABLE_CELL, 0);
cmark_node_set_syntax_extension(node, self);
}
}
free_table_row(parser->mem, row);
cmark_parser_advance_offset(parser, (char *)input,
len - 1 - cmark_parser_get_offset(parser), false);
return table_row_block;
}
static cmark_node *try_opening_table_block(cmark_syntax_extension *self,
int indented, cmark_parser *parser,
cmark_node *parent_container,
unsigned char *input, int len) {
cmark_node_type parent_type = cmark_node_get_type(parent_container);
if (!indented && parent_type == CMARK_NODE_PARAGRAPH) {
return try_opening_table_header(self, parser, parent_container, input, len);
} else if (!indented && parent_type == CMARK_NODE_TABLE) {
return try_opening_table_row(self, parser, parent_container, input, len);
}
return NULL;
}
static int matches(cmark_syntax_extension *self, cmark_parser *parser,
unsigned char *input, int len,
cmark_node *parent_container) {
int res = 0;
if (cmark_node_get_type(parent_container) == CMARK_NODE_TABLE) {
cmark_arena_push();
table_row *new_row = row_from_string(
self, parser, input + cmark_parser_get_first_nonspace(parser),
len - cmark_parser_get_first_nonspace(parser));
if (new_row && new_row->n_columns)
res = 1;
free_table_row(parser->mem, new_row);
cmark_arena_pop();
}
return res;
}
static const char *get_type_string(cmark_syntax_extension *self,
cmark_node *node) {
if (node->type == CMARK_NODE_TABLE) {
return "table";
} else if (node->type == CMARK_NODE_TABLE_ROW) {
if (((node_table_row *)node->as.opaque)->is_header)
return "table_header";
else
return "table_row";
} else if (node->type == CMARK_NODE_TABLE_CELL) {
return "table_cell";
}
return "<unknown>";
}
static int can_contain(cmark_syntax_extension *extension, cmark_node *node,
cmark_node_type child_type) {
if (node->type == CMARK_NODE_TABLE) {
return child_type == CMARK_NODE_TABLE_ROW;
} else if (node->type == CMARK_NODE_TABLE_ROW) {
return child_type == CMARK_NODE_TABLE_CELL;
} else if (node->type == CMARK_NODE_TABLE_CELL) {
return child_type == CMARK_NODE_TEXT || child_type == CMARK_NODE_CODE ||
child_type == CMARK_NODE_EMPH || child_type == CMARK_NODE_STRONG ||
child_type == CMARK_NODE_LINK || child_type == CMARK_NODE_IMAGE ||
child_type == CMARK_NODE_STRIKETHROUGH ||
child_type == CMARK_NODE_HTML_INLINE ||
child_type == CMARK_NODE_FOOTNOTE_REFERENCE;
}
return false;
}
static int contains_inlines(cmark_syntax_extension *extension,
cmark_node *node) {
return node->type == CMARK_NODE_TABLE_CELL;
}
static void commonmark_render(cmark_syntax_extension *extension,
cmark_renderer *renderer, cmark_node *node,
cmark_event_type ev_type, int options) {
bool entering = (ev_type == CMARK_EVENT_ENTER);
if (node->type == CMARK_NODE_TABLE) {
renderer->blankline(renderer);
} else if (node->type == CMARK_NODE_TABLE_ROW) {
if (entering) {
renderer->cr(renderer);
renderer->out(renderer, node, "|", false, LITERAL);
}
} else if (node->type == CMARK_NODE_TABLE_CELL) {
if (entering) {
renderer->out(renderer, node, " ", false, LITERAL);
} else {
renderer->out(renderer, node, " |", false, LITERAL);
if (((node_table_row *)node->parent->as.opaque)->is_header &&
!node->next) {
int i;
uint8_t *alignments = get_table_alignments(node->parent->parent);
uint16_t n_cols =
((node_table *)node->parent->parent->as.opaque)->n_columns;
renderer->cr(renderer);
renderer->out(renderer, node, "|", false, LITERAL);
for (i = 0; i < n_cols; i++) {
switch (alignments[i]) {
case 0: renderer->out(renderer, node, " --- |", false, LITERAL); break;
case 'l': renderer->out(renderer, node, " :-- |", false, LITERAL); break;
case 'c': renderer->out(renderer, node, " :-: |", false, LITERAL); break;
case 'r': renderer->out(renderer, node, " --: |", false, LITERAL); break;
}
}
renderer->cr(renderer);
}
}
} else {
assert(false);
}
}
static void latex_render(cmark_syntax_extension *extension,
cmark_renderer *renderer, cmark_node *node,
cmark_event_type ev_type, int options) {
bool entering = (ev_type == CMARK_EVENT_ENTER);
if (node->type == CMARK_NODE_TABLE) {
if (entering) {
int i;
uint16_t n_cols;
uint8_t *alignments = get_table_alignments(node);
renderer->cr(renderer);
renderer->out(renderer, node, "\\begin{table}", false, LITERAL);
renderer->cr(renderer);
renderer->out(renderer, node, "\\begin{tabular}{", false, LITERAL);
n_cols = ((node_table *)node->as.opaque)->n_columns;
for (i = 0; i < n_cols; i++) {
switch(alignments[i]) {
case 0:
case 'l':
renderer->out(renderer, node, "l", false, LITERAL);
break;
case 'c':
renderer->out(renderer, node, "c", false, LITERAL);
break;
case 'r':
renderer->out(renderer, node, "r", false, LITERAL);
break;
}
}
renderer->out(renderer, node, "}", false, LITERAL);
renderer->cr(renderer);
} else {
renderer->out(renderer, node, "\\end{tabular}", false, LITERAL);
renderer->cr(renderer);
renderer->out(renderer, node, "\\end{table}", false, LITERAL);
renderer->cr(renderer);
}
} else if (node->type == CMARK_NODE_TABLE_ROW) {
if (!entering) {
renderer->cr(renderer);
}
} else if (node->type == CMARK_NODE_TABLE_CELL) {
if (!entering) {
if (node->next) {
renderer->out(renderer, node, " & ", false, LITERAL);
} else {
renderer->out(renderer, node, " \\\\", false, LITERAL);
}
}
} else {
assert(false);
}
}
static const char *xml_attr(cmark_syntax_extension *extension,
cmark_node *node) {
if (node->type == CMARK_NODE_TABLE_CELL) {
if (cmark_gfm_extensions_get_table_row_is_header(node->parent)) {
uint8_t *alignments = get_table_alignments(node->parent->parent);
int i = 0;
cmark_node *n;
for (n = node->parent->first_child; n; n = n->next, ++i)
if (n == node)
break;
switch (alignments[i]) {
case 'l': return " align=\"left\"";
case 'c': return " align=\"center\"";
case 'r': return " align=\"right\"";
}
}
}
return NULL;
}
static void man_render(cmark_syntax_extension *extension,
cmark_renderer *renderer, cmark_node *node,
cmark_event_type ev_type, int options) {
bool entering = (ev_type == CMARK_EVENT_ENTER);
if (node->type == CMARK_NODE_TABLE) {
if (entering) {
int i;
uint16_t n_cols;
uint8_t *alignments = get_table_alignments(node);
renderer->cr(renderer);
renderer->out(renderer, node, ".TS", false, LITERAL);
renderer->cr(renderer);
renderer->out(renderer, node, "tab(@);", false, LITERAL);
renderer->cr(renderer);
n_cols = ((node_table *)node->as.opaque)->n_columns;
for (i = 0; i < n_cols; i++) {
switch (alignments[i]) {
case 'l':
renderer->out(renderer, node, "l", false, LITERAL);
break;
case 0:
case 'c':
renderer->out(renderer, node, "c", false, LITERAL);
break;
case 'r':
renderer->out(renderer, node, "r", false, LITERAL);
break;
}
}
if (n_cols) {
renderer->out(renderer, node, ".", false, LITERAL);
renderer->cr(renderer);
}
} else {
renderer->out(renderer, node, ".TE", false, LITERAL);
renderer->cr(renderer);
}
} else if (node->type == CMARK_NODE_TABLE_ROW) {
if (!entering) {
renderer->cr(renderer);
}
} else if (node->type == CMARK_NODE_TABLE_CELL) {
if (!entering && node->next) {
renderer->out(renderer, node, "@", false, LITERAL);
}
} else {
assert(false);
}
}
static void html_table_add_align(cmark_strbuf* html, const char* align, int options) {
if (options & CMARK_OPT_TABLE_PREFER_STYLE_ATTRIBUTES) {
cmark_strbuf_puts(html, " style=\"text-align: ");
cmark_strbuf_puts(html, align);
cmark_strbuf_puts(html, "\"");
} else {
cmark_strbuf_puts(html, " align=\"");
cmark_strbuf_puts(html, align);
cmark_strbuf_puts(html, "\"");
}
}
struct html_table_state {
unsigned need_closing_table_body : 1;
unsigned in_table_header : 1;
};
static void html_render(cmark_syntax_extension *extension,
cmark_html_renderer *renderer, cmark_node *node,
cmark_event_type ev_type, int options) {
bool entering = (ev_type == CMARK_EVENT_ENTER);
cmark_strbuf *html = renderer->html;
cmark_node *n;
// XXX: we just monopolise renderer->opaque.
struct html_table_state *table_state =
(struct html_table_state *)&renderer->opaque;
if (node->type == CMARK_NODE_TABLE) {
if (entering) {
cmark_html_render_cr(html);
cmark_strbuf_puts(html, "<table");
cmark_html_render_sourcepos(node, html, options);
cmark_strbuf_putc(html, '>');
table_state->need_closing_table_body = false;
} else {
if (table_state->need_closing_table_body) {
cmark_html_render_cr(html);
cmark_strbuf_puts(html, "</tbody>");
cmark_html_render_cr(html);
}
table_state->need_closing_table_body = false;
cmark_html_render_cr(html);
cmark_strbuf_puts(html, "</table>");
cmark_html_render_cr(html);
}
} else if (node->type == CMARK_NODE_TABLE_ROW) {
if (entering) {
cmark_html_render_cr(html);
if (((node_table_row *)node->as.opaque)->is_header) {
table_state->in_table_header = 1;
cmark_strbuf_puts(html, "<thead>");
cmark_html_render_cr(html);
} else if (!table_state->need_closing_table_body) {
cmark_strbuf_puts(html, "<tbody>");
cmark_html_render_cr(html);
table_state->need_closing_table_body = 1;
}
cmark_strbuf_puts(html, "<tr");
cmark_html_render_sourcepos(node, html, options);
cmark_strbuf_putc(html, '>');
} else {
cmark_html_render_cr(html);
cmark_strbuf_puts(html, "</tr>");
if (((node_table_row *)node->as.opaque)->is_header) {
cmark_html_render_cr(html);
cmark_strbuf_puts(html, "</thead>");
table_state->in_table_header = false;
}
}
} else if (node->type == CMARK_NODE_TABLE_CELL) {
uint8_t *alignments = get_table_alignments(node->parent->parent);
if (entering) {
cmark_html_render_cr(html);
if (table_state->in_table_header) {
cmark_strbuf_puts(html, "<th");
} else {
cmark_strbuf_puts(html, "<td");
}
int i = 0;
for (n = node->parent->first_child; n; n = n->next, ++i)
if (n == node)
break;
switch (alignments[i]) {
case 'l': html_table_add_align(html, "left", options); break;
case 'c': html_table_add_align(html, "center", options); break;
case 'r': html_table_add_align(html, "right", options); break;
}
cmark_html_render_sourcepos(node, html, options);
cmark_strbuf_putc(html, '>');
} else {
if (table_state->in_table_header) {
cmark_strbuf_puts(html, "</th>");
} else {
cmark_strbuf_puts(html, "</td>");
}
}
} else {
assert(false);
}
}
static void opaque_alloc(cmark_syntax_extension *self, cmark_mem *mem, cmark_node *node) {
if (node->type == CMARK_NODE_TABLE) {
node->as.opaque = mem->calloc(1, sizeof(node_table));
} else if (node->type == CMARK_NODE_TABLE_ROW) {
node->as.opaque = mem->calloc(1, sizeof(node_table_row));
} else if (node->type == CMARK_NODE_TABLE_CELL) {
node->as.opaque = mem->calloc(1, sizeof(node_cell));
}
}
static void opaque_free(cmark_syntax_extension *self, cmark_mem *mem, cmark_node *node) {
if (node->type == CMARK_NODE_TABLE) {
free_node_table(mem, node->as.opaque);
} else if (node->type == CMARK_NODE_TABLE_ROW) {
free_node_table_row(mem, node->as.opaque);
}
}
static int escape(cmark_syntax_extension *self, cmark_node *node, int c) {
return
node->type != CMARK_NODE_TABLE &&
node->type != CMARK_NODE_TABLE_ROW &&
node->type != CMARK_NODE_TABLE_CELL &&
c == '|';
}
cmark_syntax_extension *create_table_extension(void) {
cmark_syntax_extension *self = cmark_syntax_extension_new("table");
cmark_syntax_extension_set_match_block_func(self, matches);
cmark_syntax_extension_set_open_block_func(self, try_opening_table_block);
cmark_syntax_extension_set_get_type_string_func(self, get_type_string);
cmark_syntax_extension_set_can_contain_func(self, can_contain);
cmark_syntax_extension_set_contains_inlines_func(self, contains_inlines);
cmark_syntax_extension_set_commonmark_render_func(self, commonmark_render);
cmark_syntax_extension_set_plaintext_render_func(self, commonmark_render);
cmark_syntax_extension_set_latex_render_func(self, latex_render);
cmark_syntax_extension_set_xml_attr_func(self, xml_attr);
cmark_syntax_extension_set_man_render_func(self, man_render);
cmark_syntax_extension_set_html_render_func(self, html_render);
cmark_syntax_extension_set_opaque_alloc_func(self, opaque_alloc);
cmark_syntax_extension_set_opaque_free_func(self, opaque_free);
cmark_syntax_extension_set_commonmark_escape_func(self, escape);
CMARK_NODE_TABLE = cmark_syntax_extension_add_node(0);
CMARK_NODE_TABLE_ROW = cmark_syntax_extension_add_node(0);
CMARK_NODE_TABLE_CELL = cmark_syntax_extension_add_node(0);
return self;
}
uint16_t cmark_gfm_extensions_get_table_columns(cmark_node *node) {
if (node->type != CMARK_NODE_TABLE)
return 0;
return ((node_table *)node->as.opaque)->n_columns;
}
uint8_t *cmark_gfm_extensions_get_table_alignments(cmark_node *node) {
if (node->type != CMARK_NODE_TABLE)
return 0;
return ((node_table *)node->as.opaque)->alignments;
}
int cmark_gfm_extensions_set_table_columns(cmark_node *node, uint16_t n_columns) {
return set_n_table_columns(node, n_columns);
}
int cmark_gfm_extensions_set_table_alignments(cmark_node *node, uint16_t ncols, uint8_t *alignments) {
uint8_t *a = (uint8_t *)cmark_node_mem(node)->calloc(1, ncols);
memcpy(a, alignments, ncols);
return set_table_alignments(node, a);
}
int cmark_gfm_extensions_get_table_row_is_header(cmark_node *node)
{
if (!node || node->type != CMARK_NODE_TABLE_ROW)
return 0;
return ((node_table_row *)node->as.opaque)->is_header;
}
int cmark_gfm_extensions_set_table_row_is_header(cmark_node *node, int is_header)
{
if (!node || node->type != CMARK_NODE_TABLE_ROW)
return 0;
((node_table_row *)node->as.opaque)->is_header = (is_header != 0);
return 1;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/cmark-gfm-core-extensions.h | #ifndef CMARK_GFM_CORE_EXTENSIONS_H
#define CMARK_GFM_CORE_EXTENSIONS_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cmark-gfm-extension_api.h"
#include "cmark-gfm-extensions_export.h"
#include "config.h" // for bool
#include <stdint.h>
CMARK_GFM_EXTENSIONS_EXPORT
void cmark_gfm_core_extensions_ensure_registered(void);
CMARK_GFM_EXTENSIONS_EXPORT
uint16_t cmark_gfm_extensions_get_table_columns(cmark_node *node);
/** Sets the number of columns for the table, returning 1 on success and 0 on error.
*/
CMARK_GFM_EXTENSIONS_EXPORT
int cmark_gfm_extensions_set_table_columns(cmark_node *node, uint16_t n_columns);
CMARK_GFM_EXTENSIONS_EXPORT
uint8_t *cmark_gfm_extensions_get_table_alignments(cmark_node *node);
/** Sets the alignments for the table, returning 1 on success and 0 on error.
*/
CMARK_GFM_EXTENSIONS_EXPORT
int cmark_gfm_extensions_set_table_alignments(cmark_node *node, uint16_t ncols, uint8_t *alignments);
CMARK_GFM_EXTENSIONS_EXPORT
int cmark_gfm_extensions_get_table_row_is_header(cmark_node *node);
/** Sets whether the node is a table header row, returning 1 on success and 0 on error.
*/
CMARK_GFM_EXTENSIONS_EXPORT
int cmark_gfm_extensions_set_table_row_is_header(cmark_node *node, int is_header);
CMARK_GFM_EXTENSIONS_EXPORT
bool cmark_gfm_extensions_get_tasklist_item_checked(cmark_node *node);
/* For backwards compatibility */
#define cmark_gfm_extensions_tasklist_is_checked cmark_gfm_extensions_get_tasklist_item_checked
/** Sets whether a tasklist item is "checked" (completed), returning 1 on success and 0 on error.
*/
CMARK_GFM_EXTENSIONS_EXPORT
int cmark_gfm_extensions_set_tasklist_item_checked(cmark_node *node, bool is_checked);
#ifdef __cplusplus
}
#endif
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/extensions/tasklist.c | #include "tasklist.h"
#include <parser.h>
#include <render.h>
#include <html.h>
#include "ext_scanners.h"
typedef enum {
CMARK_TASKLIST_NOCHECKED,
CMARK_TASKLIST_CHECKED,
} cmark_tasklist_type;
// Local constants
static const char *TYPE_STRING = "tasklist";
static const char *get_type_string(cmark_syntax_extension *extension, cmark_node *node) {
return TYPE_STRING;
}
// Return 1 if state was set, 0 otherwise
int cmark_gfm_extensions_set_tasklist_item_checked(cmark_node *node, bool is_checked) {
// The node has to exist, and be an extension, and actually be the right type in order to get the value.
if (!node || !node->extension || strcmp(cmark_node_get_type_string(node), TYPE_STRING))
return 0;
node->as.list.checked = is_checked;
return 1;
}
bool cmark_gfm_extensions_get_tasklist_item_checked(cmark_node *node) {
if (!node || !node->extension || strcmp(cmark_node_get_type_string(node), TYPE_STRING))
return false;
if (node->as.list.checked) {
return true;
}
else {
return false;
}
}
static bool parse_node_item_prefix(cmark_parser *parser, const char *input,
cmark_node *container) {
bool res = false;
if (parser->indent >=
container->as.list.marker_offset + container->as.list.padding) {
cmark_parser_advance_offset(parser, input, container->as.list.marker_offset +
container->as.list.padding,
true);
res = true;
} else if (parser->blank && container->first_child != NULL) {
// if container->first_child is NULL, then the opening line
// of the list item was blank after the list marker; in this
// case, we are done with the list item.
cmark_parser_advance_offset(parser, input, parser->first_nonspace - parser->offset,
false);
res = true;
}
return res;
}
static int matches(cmark_syntax_extension *self, cmark_parser *parser,
unsigned char *input, int len,
cmark_node *parent_container) {
return parse_node_item_prefix(parser, (const char*)input, parent_container);
}
static int can_contain(cmark_syntax_extension *extension, cmark_node *node,
cmark_node_type child_type) {
return (node->type == CMARK_NODE_ITEM) ? 1 : 0;
}
static cmark_node *open_tasklist_item(cmark_syntax_extension *self,
int indented, cmark_parser *parser,
cmark_node *parent_container,
unsigned char *input, int len) {
cmark_node_type node_type = cmark_node_get_type(parent_container);
if (node_type != CMARK_NODE_ITEM) {
return NULL;
}
bufsize_t matched = scan_tasklist(input, len, 0);
if (!matched) {
return NULL;
}
cmark_node_set_syntax_extension(parent_container, self);
cmark_parser_advance_offset(parser, (char *)input, 3, false);
// Either an upper or lower case X means the task is completed.
parent_container->as.list.checked = (strstr((char*)input, "[x]") || strstr((char*)input, "[X]"));
return NULL;
}
static void commonmark_render(cmark_syntax_extension *extension,
cmark_renderer *renderer, cmark_node *node,
cmark_event_type ev_type, int options) {
bool entering = (ev_type == CMARK_EVENT_ENTER);
if (entering) {
renderer->cr(renderer);
if (node->as.list.checked) {
renderer->out(renderer, node, "- [x] ", false, LITERAL);
} else {
renderer->out(renderer, node, "- [ ] ", false, LITERAL);
}
cmark_strbuf_puts(renderer->prefix, " ");
} else {
cmark_strbuf_truncate(renderer->prefix, renderer->prefix->size - 2);
renderer->cr(renderer);
}
}
static void html_render(cmark_syntax_extension *extension,
cmark_html_renderer *renderer, cmark_node *node,
cmark_event_type ev_type, int options) {
bool entering = (ev_type == CMARK_EVENT_ENTER);
if (entering) {
cmark_html_render_cr(renderer->html);
cmark_strbuf_puts(renderer->html, "<li");
cmark_html_render_sourcepos(node, renderer->html, options);
cmark_strbuf_putc(renderer->html, '>');
if (node->as.list.checked) {
cmark_strbuf_puts(renderer->html, "<input type=\"checkbox\" checked=\"\" disabled=\"\" /> ");
} else {
cmark_strbuf_puts(renderer->html, "<input type=\"checkbox\" disabled=\"\" /> ");
}
} else {
cmark_strbuf_puts(renderer->html, "</li>\n");
}
}
static const char *xml_attr(cmark_syntax_extension *extension,
cmark_node *node) {
if (node->as.list.checked) {
return " completed=\"true\"";
} else {
return " completed=\"false\"";
}
}
cmark_syntax_extension *create_tasklist_extension(void) {
cmark_syntax_extension *ext = cmark_syntax_extension_new("tasklist");
cmark_syntax_extension_set_match_block_func(ext, matches);
cmark_syntax_extension_set_get_type_string_func(ext, get_type_string);
cmark_syntax_extension_set_open_block_func(ext, open_tasklist_item);
cmark_syntax_extension_set_can_contain_func(ext, can_contain);
cmark_syntax_extension_set_commonmark_render_func(ext, commonmark_render);
cmark_syntax_extension_set_plaintext_render_func(ext, commonmark_render);
cmark_syntax_extension_set_html_render_func(ext, html_render);
cmark_syntax_extension_set_xml_attr_func(ext, xml_attr);
return ext;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/plugin.h | #ifndef CMARK_PLUGIN_H
#define CMARK_PLUGIN_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cmark-gfm.h"
#include "cmark-gfm-extension_api.h"
/**
* cmark_plugin:
*
* A plugin structure, which should be filled by plugin's
* init functions.
*/
struct cmark_plugin {
cmark_llist *syntax_extensions;
};
cmark_llist *
cmark_plugin_steal_syntax_extensions(cmark_plugin *plugin);
cmark_plugin *
cmark_plugin_new(void);
void
cmark_plugin_free(cmark_plugin *plugin);
#ifdef __cplusplus
}
#endif
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/footnotes.c | #include "cmark-gfm.h"
#include "parser.h"
#include "footnotes.h"
#include "inlines.h"
#include "chunk.h"
static void footnote_free(cmark_map *map, cmark_map_entry *_ref) {
cmark_footnote *ref = (cmark_footnote *)_ref;
cmark_mem *mem = map->mem;
if (ref != NULL) {
mem->free(ref->entry.label);
if (ref->node)
cmark_node_free(ref->node);
mem->free(ref);
}
}
void cmark_footnote_create(cmark_map *map, cmark_node *node) {
cmark_footnote *ref;
unsigned char *reflabel = normalize_map_label(map->mem, &node->as.literal);
/* empty footnote name, or composed from only whitespace */
if (reflabel == NULL)
return;
assert(map->sorted == NULL);
ref = (cmark_footnote *)map->mem->calloc(1, sizeof(*ref));
ref->entry.label = reflabel;
ref->node = node;
ref->entry.age = map->size;
ref->entry.next = map->refs;
map->refs = (cmark_map_entry *)ref;
map->size++;
}
cmark_map *cmark_footnote_map_new(cmark_mem *mem) {
return cmark_map_new(mem, footnote_free);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/cmark-gfm-extension_api.h | #ifndef CMARK_GFM_EXTENSION_API_H
#define CMARK_GFM_EXTENSION_API_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cmark-gfm.h"
struct cmark_renderer;
struct cmark_html_renderer;
struct cmark_chunk;
/**
* ## Extension Support
*
* While the "core" of libcmark is strictly compliant with the
* specification, an API is provided for extension writers to
* hook into the parsing process.
*
* It should be noted that the cmark_node API already offers
* room for customization, with methods offered to traverse and
* modify the AST, and even define custom blocks.
* When the desired customization is achievable in an error-proof
* way using that API, it should be the preferred method.
*
* The following API requires a more in-depth understanding
* of libcmark's parsing strategy, which is exposed
* [here](http://spec.commonmark.org/0.24/#appendix-a-parsing-strategy).
*
* It should be used when "a posteriori" modification of the AST
* proves to be too difficult / impossible to implement correctly.
*
* It can also serve as an intermediary step before extending
* the specification, as an extension implemented using this API
* will be trivially integrated in the core if it proves to be
* desirable.
*/
typedef struct cmark_plugin cmark_plugin;
/** A syntax extension that can be attached to a cmark_parser
* with cmark_parser_attach_syntax_extension().
*
* Extension writers should assign functions matching
* the signature of the following 'virtual methods' to
* implement new functionality.
*
* Their calling order and expected behaviour match the procedure outlined
* at <http://spec.commonmark.org/0.24/#phase-1-block-structure>:
*
* During step 1, cmark will call the function provided through
* 'cmark_syntax_extension_set_match_block_func' when it
* iterates over an open block created by this extension,
* to determine whether it could contain the new line.
* If no function was provided, cmark will close the block.
*
* During step 2, if and only if the new line doesn't match any
* of the standard syntax rules, cmark will call the function
* provided through 'cmark_syntax_extension_set_open_block_func'
* to let the extension determine whether that new line matches
* one of its syntax rules.
* It is the responsibility of the parser to create and add the
* new block with cmark_parser_make_block and cmark_parser_add_child.
* If no function was provided is NULL, the extension will have
* no effect at all on the final block structure of the AST.
*
* #### Inline parsing phase hooks
*
* For each character provided by the extension through
* 'cmark_syntax_extension_set_special_inline_chars',
* the function provided by the extension through
* 'cmark_syntax_extension_set_match_inline_func'
* will get called, it is the responsibility of the extension
* to scan the characters located at the current inline parsing offset
* with the cmark_inline_parser API.
*
* Depending on the type of the extension, it can either:
*
* * Scan forward, determine that the syntax matches and return
* a newly-created inline node with the appropriate type.
* This is the technique that would be used if inline code
* (with backticks) was implemented as an extension.
* * Scan only the character(s) that its syntax rules require
* for opening and closing nodes, push a delimiter on the
* delimiter stack, and return a simple text node with its
* contents set to the character(s) consumed.
* This is the technique that would be used if emphasis
* inlines were implemented as an extension.
*
* When an extension has pushed delimiters on the stack,
* the function provided through
* 'cmark_syntax_extension_set_inline_from_delim_func'
* will get called in a latter phase,
* when the inline parser has matched opener and closer delimiters
* created by the extension together.
*
* It is then the responsibility of the extension to modify
* and populate the opener inline text node, and to remove
* the necessary delimiters from the delimiter stack.
*
* Finally, the extension should return NULL if its scan didn't
* match its syntax rules.
*
* The extension can store whatever private data it might need
* with 'cmark_syntax_extension_set_private',
* and optionally define a free function for this data.
*/
typedef struct subject cmark_inline_parser;
/** Exposed raw for now */
typedef struct delimiter {
struct delimiter *previous;
struct delimiter *next;
cmark_node *inl_text;
bufsize_t length;
unsigned char delim_char;
int can_open;
int can_close;
} delimiter;
/**
* ### Plugin API.
*
* Extensions should be distributed as dynamic libraries,
* with a single exported function named after the distributed
* filename.
*
* When discovering extensions (see cmark_init), cmark will
* try to load a symbol named "init_{{filename}}" in all the
* dynamic libraries it encounters.
*
* For example, given a dynamic library named myextension.so
* (or myextension.dll), cmark will try to load the symbol
* named "init_myextension". This means that the filename
* must lend itself to forming a valid C identifier, with
* the notable exception of dashes, which will be translated
* to underscores, which means cmark will look for a function
* named "init_my_extension" if it encounters a dynamic library
* named "my-extension.so".
*
* See the 'cmark_plugin_init_func' typedef for the exact prototype
* this function should follow.
*
* For now the extensibility of cmark is not complete, as
* it only offers API to hook into the block parsing phase
* (<http://spec.commonmark.org/0.24/#phase-1-block-structure>).
*
* See 'cmark_plugin_register_syntax_extension' for more information.
*/
/** The prototype plugins' init function should follow.
*/
typedef int (*cmark_plugin_init_func)(cmark_plugin *plugin);
/** Register a syntax 'extension' with the 'plugin', it will be made
* available as an extension and, if attached to a cmark_parser
* with 'cmark_parser_attach_syntax_extension', it will contribute
* to the block parsing process.
*
* See the documentation for 'cmark_syntax_extension' for information
* on how to implement one.
*
* This function will typically be called from the init function
* of external modules.
*
* This takes ownership of 'extension', one should not call
* 'cmark_syntax_extension_free' on a registered extension.
*/
CMARK_GFM_EXPORT
int cmark_plugin_register_syntax_extension(cmark_plugin *plugin,
cmark_syntax_extension *extension);
/** This will search for the syntax extension named 'name' among the
* registered syntax extensions.
*
* It can then be attached to a cmark_parser
* with the cmark_parser_attach_syntax_extension method.
*/
CMARK_GFM_EXPORT
cmark_syntax_extension *cmark_find_syntax_extension(const char *name);
/** Should create and add a new open block to 'parent_container' if
* 'input' matches a syntax rule for that block type. It is allowed
* to modify the type of 'parent_container'.
*
* Should return the newly created block if there is one, or
* 'parent_container' if its type was modified, or NULL.
*/
typedef cmark_node * (*cmark_open_block_func) (cmark_syntax_extension *extension,
int indented,
cmark_parser *parser,
cmark_node *parent_container,
unsigned char *input,
int len);
typedef cmark_node *(*cmark_match_inline_func)(cmark_syntax_extension *extension,
cmark_parser *parser,
cmark_node *parent,
unsigned char character,
cmark_inline_parser *inline_parser);
typedef delimiter *(*cmark_inline_from_delim_func)(cmark_syntax_extension *extension,
cmark_parser *parser,
cmark_inline_parser *inline_parser,
delimiter *opener,
delimiter *closer);
/** Should return 'true' if 'input' can be contained in 'container',
* 'false' otherwise.
*/
typedef int (*cmark_match_block_func) (cmark_syntax_extension *extension,
cmark_parser *parser,
unsigned char *input,
int len,
cmark_node *container);
typedef const char *(*cmark_get_type_string_func) (cmark_syntax_extension *extension,
cmark_node *node);
typedef int (*cmark_can_contain_func) (cmark_syntax_extension *extension,
cmark_node *node,
cmark_node_type child);
typedef int (*cmark_contains_inlines_func) (cmark_syntax_extension *extension,
cmark_node *node);
typedef void (*cmark_common_render_func) (cmark_syntax_extension *extension,
struct cmark_renderer *renderer,
cmark_node *node,
cmark_event_type ev_type,
int options);
typedef int (*cmark_commonmark_escape_func) (cmark_syntax_extension *extension,
cmark_node *node,
int c);
typedef const char* (*cmark_xml_attr_func) (cmark_syntax_extension *extension,
cmark_node *node);
typedef void (*cmark_html_render_func) (cmark_syntax_extension *extension,
struct cmark_html_renderer *renderer,
cmark_node *node,
cmark_event_type ev_type,
int options);
typedef int (*cmark_html_filter_func) (cmark_syntax_extension *extension,
const unsigned char *tag,
size_t tag_len);
typedef cmark_node *(*cmark_postprocess_func) (cmark_syntax_extension *extension,
cmark_parser *parser,
cmark_node *root);
typedef int (*cmark_ispunct_func) (char c);
typedef void (*cmark_opaque_alloc_func) (cmark_syntax_extension *extension,
cmark_mem *mem,
cmark_node *node);
typedef void (*cmark_opaque_free_func) (cmark_syntax_extension *extension,
cmark_mem *mem,
cmark_node *node);
/** Free a cmark_syntax_extension.
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_free (cmark_mem *mem, cmark_syntax_extension *extension);
/** Return a newly-constructed cmark_syntax_extension, named 'name'.
*/
CMARK_GFM_EXPORT
cmark_syntax_extension *cmark_syntax_extension_new (const char *name);
CMARK_GFM_EXPORT
cmark_node_type cmark_syntax_extension_add_node(int is_inline);
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_emphasis(cmark_syntax_extension *extension, int emphasis);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_open_block_func(cmark_syntax_extension *extension,
cmark_open_block_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_match_block_func(cmark_syntax_extension *extension,
cmark_match_block_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_match_inline_func(cmark_syntax_extension *extension,
cmark_match_inline_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_inline_from_delim_func(cmark_syntax_extension *extension,
cmark_inline_from_delim_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_special_inline_chars(cmark_syntax_extension *extension,
cmark_llist *special_chars);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_get_type_string_func(cmark_syntax_extension *extension,
cmark_get_type_string_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_can_contain_func(cmark_syntax_extension *extension,
cmark_can_contain_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_contains_inlines_func(cmark_syntax_extension *extension,
cmark_contains_inlines_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_commonmark_render_func(cmark_syntax_extension *extension,
cmark_common_render_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_plaintext_render_func(cmark_syntax_extension *extension,
cmark_common_render_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_latex_render_func(cmark_syntax_extension *extension,
cmark_common_render_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_xml_attr_func(cmark_syntax_extension *extension,
cmark_xml_attr_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_man_render_func(cmark_syntax_extension *extension,
cmark_common_render_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_html_render_func(cmark_syntax_extension *extension,
cmark_html_render_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_html_filter_func(cmark_syntax_extension *extension,
cmark_html_filter_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_commonmark_escape_func(cmark_syntax_extension *extension,
cmark_commonmark_escape_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_private(cmark_syntax_extension *extension,
void *priv,
cmark_free_func free_func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void *cmark_syntax_extension_get_private(cmark_syntax_extension *extension);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_postprocess_func(cmark_syntax_extension *extension,
cmark_postprocess_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_opaque_alloc_func(cmark_syntax_extension *extension,
cmark_opaque_alloc_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_syntax_extension_set_opaque_free_func(cmark_syntax_extension *extension,
cmark_opaque_free_func func);
/** See the documentation for 'cmark_syntax_extension'
*/
CMARK_GFM_EXPORT
void cmark_parser_set_backslash_ispunct_func(cmark_parser *parser,
cmark_ispunct_func func);
/** Return the index of the line currently being parsed, starting with 1.
*/
CMARK_GFM_EXPORT
int cmark_parser_get_line_number(cmark_parser *parser);
/** Return the offset in bytes in the line being processed.
*
* Example:
*
* ### foo
*
* Here, offset will first be 0, then 5 (the index of the 'f' character).
*/
CMARK_GFM_EXPORT
int cmark_parser_get_offset(cmark_parser *parser);
/**
* Return the offset in 'columns' in the line being processed.
*
* This value may differ from the value returned by
* cmark_parser_get_offset() in that it accounts for tabs,
* and as such should not be used as an index in the current line's
* buffer.
*
* Example:
*
* cmark_parser_advance_offset() can be called to advance the
* offset by a number of columns, instead of a number of bytes.
*
* In that case, if offset falls "in the middle" of a tab
* character, 'column' and offset will differ.
*
* ```
* foo \t bar
* ^ ^^
* offset (0) 20
* ```
*
* If cmark_parser_advance_offset is called here with 'columns'
* set to 'true' and 'offset' set to 22, cmark_parser_get_offset()
* will return 20, whereas cmark_parser_get_column() will return
* 22.
*
* Additionally, as tabs expand to the next multiple of 4 column,
* cmark_parser_has_partially_consumed_tab() will now return
* 'true'.
*/
CMARK_GFM_EXPORT
int cmark_parser_get_column(cmark_parser *parser);
/** Return the absolute index in bytes of the first nonspace
* character coming after the offset as returned by
* cmark_parser_get_offset() in the line currently being processed.
*
* Example:
*
* ```
* foo bar baz \n
* ^ ^ ^
* 0 offset (16) first_nonspace (28)
* ```
*/
CMARK_GFM_EXPORT
int cmark_parser_get_first_nonspace(cmark_parser *parser);
/** Return the absolute index of the first nonspace column coming after 'offset'
* in the line currently being processed, counting tabs as multiple
* columns as appropriate.
*
* See the documentation for cmark_parser_get_first_nonspace() and
* cmark_parser_get_column() for more information.
*/
CMARK_GFM_EXPORT
int cmark_parser_get_first_nonspace_column(cmark_parser *parser);
/** Return the difference between the values returned by
* cmark_parser_get_first_nonspace_column() and
* cmark_parser_get_column().
*
* This is not a byte offset, as it can count one tab as multiple
* characters.
*/
CMARK_GFM_EXPORT
int cmark_parser_get_indent(cmark_parser *parser);
/** Return 'true' if the line currently being processed has been entirely
* consumed, 'false' otherwise.
*
* Example:
*
* ```
* foo bar baz \n
* ^
* offset
* ```
*
* This function will return 'false' here.
*
* ```
* foo bar baz \n
* ^
* offset
* ```
* This function will still return 'false'.
*
* ```
* foo bar baz \n
* ^
* offset
* ```
*
* At this point, this function will now return 'true'.
*/
CMARK_GFM_EXPORT
int cmark_parser_is_blank(cmark_parser *parser);
/** Return 'true' if the value returned by cmark_parser_get_offset()
* is 'inside' an expanded tab.
*
* See the documentation for cmark_parser_get_column() for more
* information.
*/
CMARK_GFM_EXPORT
int cmark_parser_has_partially_consumed_tab(cmark_parser *parser);
/** Return the length in bytes of the previously processed line, excluding potential
* newline (\n) and carriage return (\r) trailing characters.
*/
CMARK_GFM_EXPORT
int cmark_parser_get_last_line_length(cmark_parser *parser);
/** Add a child to 'parent' during the parsing process.
*
* If 'parent' isn't the kind of node that can accept this child,
* this function will back up till it hits a node that can, closing
* blocks as appropriate.
*/
CMARK_GFM_EXPORT
cmark_node*cmark_parser_add_child(cmark_parser *parser,
cmark_node *parent,
cmark_node_type block_type,
int start_column);
/** Advance the 'offset' of the parser in the current line.
*
* See the documentation of cmark_parser_get_offset() and
* cmark_parser_get_column() for more information.
*/
CMARK_GFM_EXPORT
void cmark_parser_advance_offset(cmark_parser *parser,
const char *input,
int count,
int columns);
CMARK_GFM_EXPORT
void cmark_parser_feed_reentrant(cmark_parser *parser, const char *buffer, size_t len);
/** Attach the syntax 'extension' to the 'parser', to provide extra syntax
* rules.
* See the documentation for cmark_syntax_extension for more information.
*
* Returns 'true' if the 'extension' was successfully attached,
* 'false' otherwise.
*/
CMARK_GFM_EXPORT
int cmark_parser_attach_syntax_extension(cmark_parser *parser, cmark_syntax_extension *extension);
/** Change the type of 'node'.
*
* Return 0 if the type could be changed, 1 otherwise.
*/
CMARK_GFM_EXPORT int cmark_node_set_type(cmark_node *node, cmark_node_type type);
/** Return the string content for all types of 'node'.
* The pointer stays valid as long as 'node' isn't freed.
*/
CMARK_GFM_EXPORT const char *cmark_node_get_string_content(cmark_node *node);
/** Set the string 'content' for all types of 'node'.
* Copies 'content'.
*/
CMARK_GFM_EXPORT int cmark_node_set_string_content(cmark_node *node, const char *content);
/** Get the syntax extension responsible for the creation of 'node'.
* Return NULL if 'node' was created because it matched standard syntax rules.
*/
CMARK_GFM_EXPORT cmark_syntax_extension *cmark_node_get_syntax_extension(cmark_node *node);
/** Set the syntax extension responsible for creating 'node'.
*/
CMARK_GFM_EXPORT int cmark_node_set_syntax_extension(cmark_node *node,
cmark_syntax_extension *extension);
/**
* ## Inline syntax extension helpers
*
* The inline parsing process is described in detail at
* <http://spec.commonmark.org/0.24/#phase-2-inline-structure>
*/
/** Should return 'true' if the predicate matches 'c', 'false' otherwise
*/
typedef int (*cmark_inline_predicate)(int c);
/** Advance the current inline parsing offset */
CMARK_GFM_EXPORT
void cmark_inline_parser_advance_offset(cmark_inline_parser *parser);
/** Get the current inline parsing offset */
CMARK_GFM_EXPORT
int cmark_inline_parser_get_offset(cmark_inline_parser *parser);
/** Set the offset in bytes in the chunk being processed by the given inline parser.
*/
CMARK_GFM_EXPORT
void cmark_inline_parser_set_offset(cmark_inline_parser *parser, int offset);
/** Gets the cmark_chunk being operated on by the given inline parser.
* Use cmark_inline_parser_get_offset to get our current position in the chunk.
*/
CMARK_GFM_EXPORT
struct cmark_chunk *cmark_inline_parser_get_chunk(cmark_inline_parser *parser);
/** Returns 1 if the inline parser is currently in a bracket; pass 1 for 'image'
* if you want to know about an image-type bracket, 0 for link-type. */
CMARK_GFM_EXPORT
int cmark_inline_parser_in_bracket(cmark_inline_parser *parser, int image);
/** Remove the last n characters from the last child of the given node.
* This only works where all n characters are in the single last child, and the last
* child is CMARK_NODE_TEXT.
*/
CMARK_GFM_EXPORT
void cmark_node_unput(cmark_node *node, int n);
/** Get the character located at the current inline parsing offset
*/
CMARK_GFM_EXPORT
unsigned char cmark_inline_parser_peek_char(cmark_inline_parser *parser);
/** Get the character located 'pos' bytes in the current line.
*/
CMARK_GFM_EXPORT
unsigned char cmark_inline_parser_peek_at(cmark_inline_parser *parser, int pos);
/** Whether the inline parser has reached the end of the current line
*/
CMARK_GFM_EXPORT
int cmark_inline_parser_is_eof(cmark_inline_parser *parser);
/** Get the characters located after the current inline parsing offset
* while 'pred' matches. Free after usage.
*/
CMARK_GFM_EXPORT
char *cmark_inline_parser_take_while(cmark_inline_parser *parser, cmark_inline_predicate pred);
/** Push a delimiter on the delimiter stack.
* See <<http://spec.commonmark.org/0.24/#phase-2-inline-structure> for
* more information on the parameters
*/
CMARK_GFM_EXPORT
void cmark_inline_parser_push_delimiter(cmark_inline_parser *parser,
unsigned char c,
int can_open,
int can_close,
cmark_node *inl_text);
/** Remove 'delim' from the delimiter stack
*/
CMARK_GFM_EXPORT
void cmark_inline_parser_remove_delimiter(cmark_inline_parser *parser, delimiter *delim);
CMARK_GFM_EXPORT
delimiter *cmark_inline_parser_get_last_delimiter(cmark_inline_parser *parser);
CMARK_GFM_EXPORT
int cmark_inline_parser_get_line(cmark_inline_parser *parser);
CMARK_GFM_EXPORT
int cmark_inline_parser_get_column(cmark_inline_parser *parser);
/** Convenience function to scan a given delimiter.
*
* 'left_flanking' and 'right_flanking' will be set to true if they
* respectively precede and follow a non-space, non-punctuation
* character.
*
* Additionally, 'punct_before' and 'punct_after' will respectively be set
* if the preceding or following character is a punctuation character.
*
* Note that 'left_flanking' and 'right_flanking' can both be 'true'.
*
* Returns the number of delimiters encountered, in the limit
* of 'max_delims', and advances the inline parsing offset.
*/
CMARK_GFM_EXPORT
int cmark_inline_parser_scan_delimiters(cmark_inline_parser *parser,
int max_delims,
unsigned char c,
int *left_flanking,
int *right_flanking,
int *punct_before,
int *punct_after);
CMARK_GFM_EXPORT
void cmark_manage_extensions_special_characters(cmark_parser *parser, int add);
CMARK_GFM_EXPORT
cmark_llist *cmark_parser_get_syntax_extensions(cmark_parser *parser);
CMARK_GFM_EXPORT
void cmark_arena_push(void);
CMARK_GFM_EXPORT
int cmark_arena_pop(void);
#ifdef __cplusplus
}
#endif
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/references.c | #include "cmark-gfm.h"
#include "parser.h"
#include "references.h"
#include "inlines.h"
#include "chunk.h"
static void reference_free(cmark_map *map, cmark_map_entry *_ref) {
cmark_reference *ref = (cmark_reference *)_ref;
cmark_mem *mem = map->mem;
if (ref != NULL) {
mem->free(ref->entry.label);
cmark_chunk_free(mem, &ref->url);
cmark_chunk_free(mem, &ref->title);
mem->free(ref);
}
}
void cmark_reference_create(cmark_map *map, cmark_chunk *label,
cmark_chunk *url, cmark_chunk *title) {
cmark_reference *ref;
unsigned char *reflabel = normalize_map_label(map->mem, label);
/* empty reference name, or composed from only whitespace */
if (reflabel == NULL)
return;
assert(map->sorted == NULL);
ref = (cmark_reference *)map->mem->calloc(1, sizeof(*ref));
ref->entry.label = reflabel;
ref->url = cmark_clean_url(map->mem, url);
ref->title = cmark_clean_title(map->mem, title);
ref->entry.age = map->size;
ref->entry.next = map->refs;
map->refs = (cmark_map_entry *)ref;
map->size++;
}
cmark_map *cmark_reference_map_new(cmark_mem *mem) {
return cmark_map_new(mem, reference_free);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/scanners.h | #ifndef CMARK_SCANNERS_H
#define CMARK_SCANNERS_H
#include "cmark-gfm.h"
#include "chunk.h"
#ifdef __cplusplus
extern "C" {
#endif
bufsize_t _scan_at(bufsize_t (*scanner)(const unsigned char *), cmark_chunk *c,
bufsize_t offset);
bufsize_t _scan_scheme(const unsigned char *p);
bufsize_t _scan_autolink_uri(const unsigned char *p);
bufsize_t _scan_autolink_email(const unsigned char *p);
bufsize_t _scan_html_tag(const unsigned char *p);
bufsize_t _scan_liberal_html_tag(const unsigned char *p);
bufsize_t _scan_html_block_start(const unsigned char *p);
bufsize_t _scan_html_block_start_7(const unsigned char *p);
bufsize_t _scan_html_block_end_1(const unsigned char *p);
bufsize_t _scan_html_block_end_2(const unsigned char *p);
bufsize_t _scan_html_block_end_3(const unsigned char *p);
bufsize_t _scan_html_block_end_4(const unsigned char *p);
bufsize_t _scan_html_block_end_5(const unsigned char *p);
bufsize_t _scan_link_title(const unsigned char *p);
bufsize_t _scan_spacechars(const unsigned char *p);
bufsize_t _scan_atx_heading_start(const unsigned char *p);
bufsize_t _scan_setext_heading_line(const unsigned char *p);
bufsize_t _scan_open_code_fence(const unsigned char *p);
bufsize_t _scan_close_code_fence(const unsigned char *p);
bufsize_t _scan_entity(const unsigned char *p);
bufsize_t _scan_dangerous_url(const unsigned char *p);
bufsize_t _scan_footnote_definition(const unsigned char *p);
#define scan_scheme(c, n) _scan_at(&_scan_scheme, c, n)
#define scan_autolink_uri(c, n) _scan_at(&_scan_autolink_uri, c, n)
#define scan_autolink_email(c, n) _scan_at(&_scan_autolink_email, c, n)
#define scan_html_tag(c, n) _scan_at(&_scan_html_tag, c, n)
#define scan_liberal_html_tag(c, n) _scan_at(&_scan_liberal_html_tag, c, n)
#define scan_html_block_start(c, n) _scan_at(&_scan_html_block_start, c, n)
#define scan_html_block_start_7(c, n) _scan_at(&_scan_html_block_start_7, c, n)
#define scan_html_block_end_1(c, n) _scan_at(&_scan_html_block_end_1, c, n)
#define scan_html_block_end_2(c, n) _scan_at(&_scan_html_block_end_2, c, n)
#define scan_html_block_end_3(c, n) _scan_at(&_scan_html_block_end_3, c, n)
#define scan_html_block_end_4(c, n) _scan_at(&_scan_html_block_end_4, c, n)
#define scan_html_block_end_5(c, n) _scan_at(&_scan_html_block_end_5, c, n)
#define scan_link_title(c, n) _scan_at(&_scan_link_title, c, n)
#define scan_spacechars(c, n) _scan_at(&_scan_spacechars, c, n)
#define scan_atx_heading_start(c, n) _scan_at(&_scan_atx_heading_start, c, n)
#define scan_setext_heading_line(c, n) \
_scan_at(&_scan_setext_heading_line, c, n)
#define scan_open_code_fence(c, n) _scan_at(&_scan_open_code_fence, c, n)
#define scan_close_code_fence(c, n) _scan_at(&_scan_close_code_fence, c, n)
#define scan_entity(c, n) _scan_at(&_scan_entity, c, n)
#define scan_dangerous_url(c, n) _scan_at(&_scan_dangerous_url, c, n)
#define scan_footnote_definition(c, n) _scan_at(&_scan_footnote_definition, c, n)
#ifdef __cplusplus
}
#endif
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/map.h | #ifndef CMARK_MAP_H
#define CMARK_MAP_H
#include "chunk.h"
#ifdef __cplusplus
extern "C" {
#endif
struct cmark_map_entry {
struct cmark_map_entry *next;
unsigned char *label;
unsigned int age;
};
typedef struct cmark_map_entry cmark_map_entry;
struct cmark_map;
typedef void (*cmark_map_free_f)(struct cmark_map *, cmark_map_entry *);
struct cmark_map {
cmark_mem *mem;
cmark_map_entry *refs;
cmark_map_entry **sorted;
unsigned int size;
cmark_map_free_f free;
};
typedef struct cmark_map cmark_map;
unsigned char *normalize_map_label(cmark_mem *mem, cmark_chunk *ref);
cmark_map *cmark_map_new(cmark_mem *mem, cmark_map_free_f free);
void cmark_map_free(cmark_map *map);
cmark_map_entry *cmark_map_lookup(cmark_map *map, cmark_chunk *label);
#ifdef __cplusplus
}
#endif
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/buffer.c | #include <stdarg.h>
#include <string.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include "config.h"
#include "cmark_ctype.h"
#include "buffer.h"
/* Used as default value for cmark_strbuf->ptr so that people can always
* assume ptr is non-NULL and zero terminated even for new cmark_strbufs.
*/
unsigned char cmark_strbuf__initbuf[1];
#ifndef MIN
#define MIN(x, y) ((x < y) ? x : y)
#endif
void cmark_strbuf_init(cmark_mem *mem, cmark_strbuf *buf,
bufsize_t initial_size) {
buf->mem = mem;
buf->asize = 0;
buf->size = 0;
buf->ptr = cmark_strbuf__initbuf;
if (initial_size > 0)
cmark_strbuf_grow(buf, initial_size);
}
static CMARK_INLINE void S_strbuf_grow_by(cmark_strbuf *buf, bufsize_t add) {
cmark_strbuf_grow(buf, buf->size + add);
}
void cmark_strbuf_grow(cmark_strbuf *buf, bufsize_t target_size) {
assert(target_size > 0);
if (target_size < buf->asize)
return;
if (target_size > (bufsize_t)(INT32_MAX / 2)) {
fprintf(stderr,
"[cmark] cmark_strbuf_grow requests buffer with size > %d, aborting\n",
(INT32_MAX / 2));
abort();
}
/* Oversize the buffer by 50% to guarantee amortized linear time
* complexity on append operations. */
bufsize_t new_size = target_size + target_size / 2;
new_size += 1;
new_size = (new_size + 7) & ~7;
buf->ptr = (unsigned char *)buf->mem->realloc(buf->asize ? buf->ptr : NULL,
new_size);
buf->asize = new_size;
}
bufsize_t cmark_strbuf_len(const cmark_strbuf *buf) { return buf->size; }
void cmark_strbuf_free(cmark_strbuf *buf) {
if (!buf)
return;
if (buf->ptr != cmark_strbuf__initbuf)
buf->mem->free(buf->ptr);
cmark_strbuf_init(buf->mem, buf, 0);
}
void cmark_strbuf_clear(cmark_strbuf *buf) {
buf->size = 0;
if (buf->asize > 0)
buf->ptr[0] = '\0';
}
void cmark_strbuf_set(cmark_strbuf *buf, const unsigned char *data,
bufsize_t len) {
if (len <= 0 || data == NULL) {
cmark_strbuf_clear(buf);
} else {
if (data != buf->ptr) {
if (len >= buf->asize)
cmark_strbuf_grow(buf, len);
memmove(buf->ptr, data, len);
}
buf->size = len;
buf->ptr[buf->size] = '\0';
}
}
void cmark_strbuf_sets(cmark_strbuf *buf, const char *string) {
cmark_strbuf_set(buf, (const unsigned char *)string,
string ? (bufsize_t)strlen(string) : 0);
}
void cmark_strbuf_putc(cmark_strbuf *buf, int c) {
S_strbuf_grow_by(buf, 1);
buf->ptr[buf->size++] = (unsigned char)(c & 0xFF);
buf->ptr[buf->size] = '\0';
}
void cmark_strbuf_put(cmark_strbuf *buf, const unsigned char *data,
bufsize_t len) {
if (len <= 0)
return;
S_strbuf_grow_by(buf, len);
memmove(buf->ptr + buf->size, data, len);
buf->size += len;
buf->ptr[buf->size] = '\0';
}
void cmark_strbuf_puts(cmark_strbuf *buf, const char *string) {
cmark_strbuf_put(buf, (const unsigned char *)string, (bufsize_t)strlen(string));
}
void cmark_strbuf_copy_cstr(char *data, bufsize_t datasize,
const cmark_strbuf *buf) {
bufsize_t copylen;
assert(buf);
if (!data || datasize <= 0)
return;
data[0] = '\0';
if (buf->size == 0 || buf->asize <= 0)
return;
copylen = buf->size;
if (copylen > datasize - 1)
copylen = datasize - 1;
memmove(data, buf->ptr, copylen);
data[copylen] = '\0';
}
void cmark_strbuf_swap(cmark_strbuf *buf_a, cmark_strbuf *buf_b) {
cmark_strbuf t = *buf_a;
*buf_a = *buf_b;
*buf_b = t;
}
unsigned char *cmark_strbuf_detach(cmark_strbuf *buf) {
unsigned char *data = buf->ptr;
if (buf->asize == 0) {
/* return an empty string */
return (unsigned char *)buf->mem->calloc(1, 1);
}
cmark_strbuf_init(buf->mem, buf, 0);
return data;
}
int cmark_strbuf_cmp(const cmark_strbuf *a, const cmark_strbuf *b) {
int result = memcmp(a->ptr, b->ptr, MIN(a->size, b->size));
return (result != 0) ? result
: (a->size < b->size) ? -1 : (a->size > b->size) ? 1 : 0;
}
bufsize_t cmark_strbuf_strchr(const cmark_strbuf *buf, int c, bufsize_t pos) {
if (pos >= buf->size)
return -1;
if (pos < 0)
pos = 0;
const unsigned char *p =
(unsigned char *)memchr(buf->ptr + pos, c, buf->size - pos);
if (!p)
return -1;
return (bufsize_t)(p - (const unsigned char *)buf->ptr);
}
bufsize_t cmark_strbuf_strrchr(const cmark_strbuf *buf, int c, bufsize_t pos) {
if (pos < 0 || buf->size == 0)
return -1;
if (pos >= buf->size)
pos = buf->size - 1;
bufsize_t i;
for (i = pos; i >= 0; i--) {
if (buf->ptr[i] == (unsigned char)c)
return i;
}
return -1;
}
void cmark_strbuf_truncate(cmark_strbuf *buf, bufsize_t len) {
if (len < 0)
len = 0;
if (len < buf->size) {
buf->size = len;
buf->ptr[buf->size] = '\0';
}
}
void cmark_strbuf_drop(cmark_strbuf *buf, bufsize_t n) {
if (n > 0) {
if (n > buf->size)
n = buf->size;
buf->size = buf->size - n;
if (buf->size)
memmove(buf->ptr, buf->ptr + n, buf->size);
buf->ptr[buf->size] = '\0';
}
}
void cmark_strbuf_rtrim(cmark_strbuf *buf) {
if (!buf->size)
return;
while (buf->size > 0) {
if (!cmark_isspace(buf->ptr[buf->size - 1]))
break;
buf->size--;
}
buf->ptr[buf->size] = '\0';
}
void cmark_strbuf_trim(cmark_strbuf *buf) {
bufsize_t i = 0;
if (!buf->size)
return;
while (i < buf->size && cmark_isspace(buf->ptr[i]))
i++;
cmark_strbuf_drop(buf, i);
cmark_strbuf_rtrim(buf);
}
// Destructively modify string, collapsing consecutive
// space and newline characters into a single space.
void cmark_strbuf_normalize_whitespace(cmark_strbuf *s) {
bool last_char_was_space = false;
bufsize_t r, w;
for (r = 0, w = 0; r < s->size; ++r) {
if (cmark_isspace(s->ptr[r])) {
if (!last_char_was_space) {
s->ptr[w++] = ' ';
last_char_was_space = true;
}
} else {
s->ptr[w++] = s->ptr[r];
last_char_was_space = false;
}
}
cmark_strbuf_truncate(s, w);
}
// Destructively unescape a string: remove backslashes before punctuation chars.
extern void cmark_strbuf_unescape(cmark_strbuf *buf) {
bufsize_t r, w;
for (r = 0, w = 0; r < buf->size; ++r) {
if (buf->ptr[r] == '\\' && cmark_ispunct(buf->ptr[r + 1]))
r++;
buf->ptr[w++] = buf->ptr[r];
}
cmark_strbuf_truncate(buf, w);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/syntax_extension.c | #include <stdlib.h>
#include <assert.h>
#include "cmark-gfm.h"
#include "syntax_extension.h"
#include "buffer.h"
extern cmark_mem CMARK_DEFAULT_MEM_ALLOCATOR;
static cmark_mem *_mem = &CMARK_DEFAULT_MEM_ALLOCATOR;
void cmark_syntax_extension_free(cmark_mem *mem, cmark_syntax_extension *extension) {
if (extension->free_function && extension->priv) {
extension->free_function(mem, extension->priv);
}
cmark_llist_free(mem, extension->special_inline_chars);
mem->free(extension->name);
mem->free(extension);
}
cmark_syntax_extension *cmark_syntax_extension_new(const char *name) {
cmark_syntax_extension *res = (cmark_syntax_extension *) _mem->calloc(1, sizeof(cmark_syntax_extension));
res->name = (char *) _mem->calloc(1, sizeof(char) * (strlen(name)) + 1);
strcpy(res->name, name);
return res;
}
cmark_node_type cmark_syntax_extension_add_node(int is_inline) {
cmark_node_type *ref = !is_inline ? &CMARK_NODE_LAST_BLOCK : &CMARK_NODE_LAST_INLINE;
if ((*ref & CMARK_NODE_VALUE_MASK) == CMARK_NODE_VALUE_MASK) {
assert(false);
return (cmark_node_type) 0;
}
return *ref = (cmark_node_type) ((int) *ref + 1);
}
void cmark_syntax_extension_set_emphasis(cmark_syntax_extension *extension,
int emphasis) {
extension->emphasis = emphasis == 1;
}
void cmark_syntax_extension_set_open_block_func(cmark_syntax_extension *extension,
cmark_open_block_func func) {
extension->try_opening_block = func;
}
void cmark_syntax_extension_set_match_block_func(cmark_syntax_extension *extension,
cmark_match_block_func func) {
extension->last_block_matches = func;
}
void cmark_syntax_extension_set_match_inline_func(cmark_syntax_extension *extension,
cmark_match_inline_func func) {
extension->match_inline = func;
}
void cmark_syntax_extension_set_inline_from_delim_func(cmark_syntax_extension *extension,
cmark_inline_from_delim_func func) {
extension->insert_inline_from_delim = func;
}
void cmark_syntax_extension_set_special_inline_chars(cmark_syntax_extension *extension,
cmark_llist *special_chars) {
extension->special_inline_chars = special_chars;
}
void cmark_syntax_extension_set_get_type_string_func(cmark_syntax_extension *extension,
cmark_get_type_string_func func) {
extension->get_type_string_func = func;
}
void cmark_syntax_extension_set_can_contain_func(cmark_syntax_extension *extension,
cmark_can_contain_func func) {
extension->can_contain_func = func;
}
void cmark_syntax_extension_set_contains_inlines_func(cmark_syntax_extension *extension,
cmark_contains_inlines_func func) {
extension->contains_inlines_func = func;
}
void cmark_syntax_extension_set_commonmark_render_func(cmark_syntax_extension *extension,
cmark_common_render_func func) {
extension->commonmark_render_func = func;
}
void cmark_syntax_extension_set_plaintext_render_func(cmark_syntax_extension *extension,
cmark_common_render_func func) {
extension->plaintext_render_func = func;
}
void cmark_syntax_extension_set_latex_render_func(cmark_syntax_extension *extension,
cmark_common_render_func func) {
extension->latex_render_func = func;
}
void cmark_syntax_extension_set_xml_attr_func(cmark_syntax_extension *extension,
cmark_xml_attr_func func) {
extension->xml_attr_func = func;
}
void cmark_syntax_extension_set_man_render_func(cmark_syntax_extension *extension,
cmark_common_render_func func) {
extension->man_render_func = func;
}
void cmark_syntax_extension_set_html_render_func(cmark_syntax_extension *extension,
cmark_html_render_func func) {
extension->html_render_func = func;
}
void cmark_syntax_extension_set_html_filter_func(cmark_syntax_extension *extension,
cmark_html_filter_func func) {
extension->html_filter_func = func;
}
void cmark_syntax_extension_set_postprocess_func(cmark_syntax_extension *extension,
cmark_postprocess_func func) {
extension->postprocess_func = func;
}
void cmark_syntax_extension_set_private(cmark_syntax_extension *extension,
void *priv,
cmark_free_func free_func) {
extension->priv = priv;
extension->free_function = free_func;
}
void *cmark_syntax_extension_get_private(cmark_syntax_extension *extension) {
return extension->priv;
}
void cmark_syntax_extension_set_opaque_alloc_func(cmark_syntax_extension *extension,
cmark_opaque_alloc_func func) {
extension->opaque_alloc_func = func;
}
void cmark_syntax_extension_set_opaque_free_func(cmark_syntax_extension *extension,
cmark_opaque_free_func func) {
extension->opaque_free_func = func;
}
void cmark_syntax_extension_set_commonmark_escape_func(cmark_syntax_extension *extension,
cmark_commonmark_escape_func func) {
extension->commonmark_escape_func = func;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/main.c | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "config.h"
#include "cmark-gfm.h"
#include "node.h"
#include "cmark-gfm-extension_api.h"
#include "syntax_extension.h"
#include "parser.h"
#include "registry.h"
#include "../extensions/cmark-gfm-core-extensions.h"
#if defined(__OpenBSD__)
# include <sys/param.h>
# if OpenBSD >= 201605
# define USE_PLEDGE
# include <unistd.h>
# endif
#endif
#if defined(__OpenBSD__)
# include <sys/param.h>
# if OpenBSD >= 201605
# define USE_PLEDGE
# include <unistd.h>
# endif
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <io.h>
#include <fcntl.h>
#endif
typedef enum {
FORMAT_NONE,
FORMAT_HTML,
FORMAT_XML,
FORMAT_MAN,
FORMAT_COMMONMARK,
FORMAT_PLAINTEXT,
FORMAT_LATEX
} writer_format;
void print_usage() {
printf("Usage: cmark-gfm [FILE*]\n");
printf("Options:\n");
printf(" --to, -t FORMAT Specify output format (html, xml, man, "
"commonmark, plaintext, latex)\n");
printf(" --width WIDTH Specify wrap width (default 0 = nowrap)\n");
printf(" --sourcepos Include source position attribute\n");
printf(" --hardbreaks Treat newlines as hard line breaks\n");
printf(" --nobreaks Render soft line breaks as spaces\n");
printf(" --unsafe Render raw HTML and dangerous URLs\n");
printf(" --smart Use smart punctuation\n");
printf(" --validate-utf8 Replace UTF-8 invalid sequences with U+FFFD\n");
printf(" --github-pre-lang Use GitHub-style <pre lang> for code blocks\n");
printf(" --extension, -e EXTENSION_NAME Specify an extension name to use\n");
printf(" --list-extensions List available extensions and quit\n");
printf(" --strikethrough-double-tilde Only parse strikethrough (if enabled)\n");
printf(" with two tildes\n");
printf(" --table-prefer-style-attributes Use style attributes to align table cells\n"
" instead of align attributes.\n");
printf(" --full-info-string Include remainder of code block info\n"
" string in a separate attribute.\n");
printf(" --help, -h Print usage information\n");
printf(" --version Print version\n");
}
static bool print_document(cmark_node *document, writer_format writer,
int options, int width, cmark_parser *parser) {
char *result;
cmark_mem *mem = cmark_get_default_mem_allocator();
switch (writer) {
case FORMAT_HTML:
result = cmark_render_html_with_mem(document, options, parser->syntax_extensions, mem);
break;
case FORMAT_XML:
result = cmark_render_xml_with_mem(document, options, mem);
break;
case FORMAT_MAN:
result = cmark_render_man_with_mem(document, options, width, mem);
break;
case FORMAT_COMMONMARK:
result = cmark_render_commonmark_with_mem(document, options, width, mem);
break;
case FORMAT_PLAINTEXT:
result = cmark_render_plaintext_with_mem(document, options, width, mem);
break;
case FORMAT_LATEX:
result = cmark_render_latex_with_mem(document, options, width, mem);
break;
default:
fprintf(stderr, "Unknown format %d\n", writer);
return false;
}
printf("%s", result);
mem->free(result);
return true;
}
static void print_extensions(void) {
cmark_llist *syntax_extensions;
cmark_llist *tmp;
printf ("Available extensions:\nfootnotes\n");
cmark_mem *mem = cmark_get_default_mem_allocator();
syntax_extensions = cmark_list_syntax_extensions(mem);
for (tmp = syntax_extensions; tmp; tmp=tmp->next) {
cmark_syntax_extension *ext = (cmark_syntax_extension *) tmp->data;
printf("%s\n", ext->name);
}
cmark_llist_free(mem, syntax_extensions);
}
int main(int argc, char *argv[]) {
int i, numfps = 0;
int *files;
char buffer[4096];
cmark_parser *parser = NULL;
size_t bytes;
cmark_node *document = NULL;
int width = 0;
char *unparsed;
writer_format writer = FORMAT_HTML;
int options = CMARK_OPT_DEFAULT;
int res = 1;
#ifdef USE_PLEDGE
if (pledge("stdio rpath", NULL) != 0) {
perror("pledge");
return 1;
}
#endif
cmark_gfm_core_extensions_ensure_registered();
#ifdef USE_PLEDGE
if (pledge("stdio rpath", NULL) != 0) {
perror("pledge");
return 1;
}
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
_setmode(_fileno(stdin), _O_BINARY);
_setmode(_fileno(stdout), _O_BINARY);
#endif
files = (int *)calloc(argc, sizeof(*files));
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "--version") == 0) {
printf("cmark-gfm %s", CMARK_GFM_VERSION_STRING);
printf(" - CommonMark with GitHub Flavored Markdown converter\n(C) 2014-2016 John MacFarlane\n");
goto success;
} else if (strcmp(argv[i], "--list-extensions") == 0) {
print_extensions();
goto success;
} else if (strcmp(argv[i], "--full-info-string") == 0) {
options |= CMARK_OPT_FULL_INFO_STRING;
} else if (strcmp(argv[i], "--table-prefer-style-attributes") == 0) {
options |= CMARK_OPT_TABLE_PREFER_STYLE_ATTRIBUTES;
} else if (strcmp(argv[i], "--strikethrough-double-tilde") == 0) {
options |= CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE;
} else if (strcmp(argv[i], "--sourcepos") == 0) {
options |= CMARK_OPT_SOURCEPOS;
} else if (strcmp(argv[i], "--hardbreaks") == 0) {
options |= CMARK_OPT_HARDBREAKS;
} else if (strcmp(argv[i], "--nobreaks") == 0) {
options |= CMARK_OPT_NOBREAKS;
} else if (strcmp(argv[i], "--smart") == 0) {
options |= CMARK_OPT_SMART;
} else if (strcmp(argv[i], "--github-pre-lang") == 0) {
options |= CMARK_OPT_GITHUB_PRE_LANG;
} else if (strcmp(argv[i], "--unsafe") == 0) {
options |= CMARK_OPT_UNSAFE;
} else if (strcmp(argv[i], "--validate-utf8") == 0) {
options |= CMARK_OPT_VALIDATE_UTF8;
} else if (strcmp(argv[i], "--liberal-html-tag") == 0) {
options |= CMARK_OPT_LIBERAL_HTML_TAG;
} else if ((strcmp(argv[i], "--help") == 0) ||
(strcmp(argv[i], "-h") == 0)) {
print_usage();
goto success;
} else if (strcmp(argv[i], "--width") == 0) {
i += 1;
if (i < argc) {
width = (int)strtol(argv[i], &unparsed, 10);
if (unparsed && strlen(unparsed) > 0) {
fprintf(stderr, "failed parsing width '%s' at '%s'\n", argv[i],
unparsed);
goto failure;
}
} else {
fprintf(stderr, "--width requires an argument\n");
goto failure;
}
} else if ((strcmp(argv[i], "-t") == 0) || (strcmp(argv[i], "--to") == 0)) {
i += 1;
if (i < argc) {
if (strcmp(argv[i], "man") == 0) {
writer = FORMAT_MAN;
} else if (strcmp(argv[i], "html") == 0) {
writer = FORMAT_HTML;
} else if (strcmp(argv[i], "xml") == 0) {
writer = FORMAT_XML;
} else if (strcmp(argv[i], "commonmark") == 0) {
writer = FORMAT_COMMONMARK;
} else if (strcmp(argv[i], "plaintext") == 0) {
writer = FORMAT_PLAINTEXT;
} else if (strcmp(argv[i], "latex") == 0) {
writer = FORMAT_LATEX;
} else {
fprintf(stderr, "Unknown format %s\n", argv[i]);
goto failure;
}
} else {
fprintf(stderr, "No argument provided for %s\n", argv[i - 1]);
goto failure;
}
} else if ((strcmp(argv[i], "-e") == 0) || (strcmp(argv[i], "--extension") == 0)) {
i += 1; // Simpler to handle extensions in a second pass, as we can directly register
// them with the parser.
if (i < argc && strcmp(argv[i], "footnotes") == 0) {
options |= CMARK_OPT_FOOTNOTES;
}
} else if (*argv[i] == '-') {
print_usage();
goto failure;
} else { // treat as file argument
files[numfps++] = i;
}
}
#if DEBUG
parser = cmark_parser_new(options);
#else
parser = cmark_parser_new_with_mem(options, cmark_get_arena_mem_allocator());
#endif
for (i = 1; i < argc; i++) {
if ((strcmp(argv[i], "-e") == 0) || (strcmp(argv[i], "--extension") == 0)) {
i += 1;
if (i < argc) {
if (strcmp(argv[i], "footnotes") == 0) {
continue;
}
cmark_syntax_extension *syntax_extension = cmark_find_syntax_extension(argv[i]);
if (!syntax_extension) {
fprintf(stderr, "Unknown extension %s\n", argv[i]);
goto failure;
}
cmark_parser_attach_syntax_extension(parser, syntax_extension);
} else {
fprintf(stderr, "No argument provided for %s\n", argv[i - 1]);
goto failure;
}
}
}
for (i = 0; i < numfps; i++) {
FILE *fp = fopen(argv[files[i]], "rb");
if (fp == NULL) {
fprintf(stderr, "Error opening file %s: %s\n", argv[files[i]],
strerror(errno));
goto failure;
}
while ((bytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
cmark_parser_feed(parser, buffer, bytes);
if (bytes < sizeof(buffer)) {
break;
}
}
fclose(fp);
}
if (numfps == 0) {
while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0) {
cmark_parser_feed(parser, buffer, bytes);
if (bytes < sizeof(buffer)) {
break;
}
}
}
#ifdef USE_PLEDGE
if (pledge("stdio", NULL) != 0) {
perror("pledge");
return 1;
}
#endif
document = cmark_parser_finish(parser);
if (!document || !print_document(document, writer, options, width, parser))
goto failure;
success:
res = 0;
failure:
#if DEBUG
if (parser)
cmark_parser_free(parser);
if (document)
cmark_node_free(document);
#else
cmark_arena_reset();
#endif
cmark_release_plugins();
free(files);
return res;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/render.h | #ifndef CMARK_RENDER_H
#define CMARK_RENDER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include "buffer.h"
#include "chunk.h"
typedef enum { LITERAL, NORMAL, TITLE, URL } cmark_escaping;
struct cmark_renderer {
cmark_mem *mem;
cmark_strbuf *buffer;
cmark_strbuf *prefix;
int column;
int width;
int need_cr;
bufsize_t last_breakable;
bool begin_line;
bool begin_content;
bool no_linebreaks;
bool in_tight_list_item;
void (*outc)(struct cmark_renderer *, cmark_node *, cmark_escaping, int32_t, unsigned char);
void (*cr)(struct cmark_renderer *);
void (*blankline)(struct cmark_renderer *);
void (*out)(struct cmark_renderer *, cmark_node *, const char *, bool, cmark_escaping);
unsigned int footnote_ix;
};
typedef struct cmark_renderer cmark_renderer;
struct cmark_html_renderer {
cmark_strbuf *html;
cmark_node *plain;
cmark_llist *filter_extensions;
unsigned int footnote_ix;
unsigned int written_footnote_ix;
void *opaque;
};
typedef struct cmark_html_renderer cmark_html_renderer;
void cmark_render_ascii(cmark_renderer *renderer, const char *s);
void cmark_render_code_point(cmark_renderer *renderer, uint32_t c);
char *cmark_render(cmark_mem *mem, cmark_node *root, int options, int width,
void (*outc)(cmark_renderer *, cmark_node *,
cmark_escaping, int32_t,
unsigned char),
int (*render_node)(cmark_renderer *renderer,
cmark_node *node,
cmark_event_type ev_type, int options));
#ifdef __cplusplus
}
#endif
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/plugin.c | #include <stdlib.h>
#include "plugin.h"
extern cmark_mem CMARK_DEFAULT_MEM_ALLOCATOR;
int cmark_plugin_register_syntax_extension(cmark_plugin * plugin,
cmark_syntax_extension * extension) {
plugin->syntax_extensions = cmark_llist_append(&CMARK_DEFAULT_MEM_ALLOCATOR, plugin->syntax_extensions, extension);
return 1;
}
cmark_plugin *
cmark_plugin_new(void) {
cmark_plugin *res = (cmark_plugin *) CMARK_DEFAULT_MEM_ALLOCATOR.calloc(1, sizeof(cmark_plugin));
res->syntax_extensions = NULL;
return res;
}
void
cmark_plugin_free(cmark_plugin *plugin) {
cmark_llist_free_full(&CMARK_DEFAULT_MEM_ALLOCATOR,
plugin->syntax_extensions,
(cmark_free_func) cmark_syntax_extension_free);
CMARK_DEFAULT_MEM_ALLOCATOR.free(plugin);
}
cmark_llist *
cmark_plugin_steal_syntax_extensions(cmark_plugin *plugin) {
cmark_llist *res = plugin->syntax_extensions;
plugin->syntax_extensions = NULL;
return res;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/houdini.h | #ifndef CMARK_HOUDINI_H
#define CMARK_HOUDINI_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "config.h"
#include "buffer.h"
#ifdef HAVE___BUILTIN_EXPECT
#define likely(x) __builtin_expect((x), 1)
#define unlikely(x) __builtin_expect((x), 0)
#else
#define likely(x) (x)
#define unlikely(x) (x)
#endif
#ifdef HOUDINI_USE_LOCALE
#define _isxdigit(c) isxdigit(c)
#define _isdigit(c) isdigit(c)
#else
/*
* Helper _isdigit methods -- do not trust the current locale
* */
#define _isxdigit(c) (strchr("0123456789ABCDEFabcdef", (c)) != NULL)
#define _isdigit(c) ((c) >= '0' && (c) <= '9')
#endif
#define HOUDINI_ESCAPED_SIZE(x) (((x)*12) / 10)
#define HOUDINI_UNESCAPED_SIZE(x) (x)
CMARK_GFM_EXPORT
bufsize_t houdini_unescape_ent(cmark_strbuf *ob, const uint8_t *src,
bufsize_t size);
CMARK_GFM_EXPORT
int houdini_escape_html(cmark_strbuf *ob, const uint8_t *src,
bufsize_t size);
CMARK_GFM_EXPORT
int houdini_escape_html0(cmark_strbuf *ob, const uint8_t *src,
bufsize_t size, int secure);
CMARK_GFM_EXPORT
int houdini_unescape_html(cmark_strbuf *ob, const uint8_t *src,
bufsize_t size);
CMARK_GFM_EXPORT
void houdini_unescape_html_f(cmark_strbuf *ob, const uint8_t *src,
bufsize_t size);
CMARK_GFM_EXPORT
int houdini_escape_href(cmark_strbuf *ob, const uint8_t *src,
bufsize_t size);
#ifdef __cplusplus
}
#endif
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/plaintext.c | #include "node.h"
#include "syntax_extension.h"
#include "render.h"
#define OUT(s, wrap, escaping) renderer->out(renderer, node, s, wrap, escaping)
#define LIT(s) renderer->out(renderer, node, s, false, LITERAL)
#define CR() renderer->cr(renderer)
#define BLANKLINE() renderer->blankline(renderer)
#define LISTMARKER_SIZE 20
// Functions to convert cmark_nodes to plain text strings.
static CMARK_INLINE void outc(cmark_renderer *renderer, cmark_node *node,
cmark_escaping escape,
int32_t c, unsigned char nextc) {
cmark_render_code_point(renderer, c);
}
// if node is a block node, returns node.
// otherwise returns first block-level node that is an ancestor of node.
// if there is no block-level ancestor, returns NULL.
static cmark_node *get_containing_block(cmark_node *node) {
while (node) {
if (CMARK_NODE_BLOCK_P(node)) {
return node;
} else {
node = node->parent;
}
}
return NULL;
}
static int S_render_node(cmark_renderer *renderer, cmark_node *node,
cmark_event_type ev_type, int options) {
cmark_node *tmp;
int list_number;
cmark_delim_type list_delim;
int i;
bool entering = (ev_type == CMARK_EVENT_ENTER);
char listmarker[LISTMARKER_SIZE];
bool first_in_list_item;
bufsize_t marker_width;
bool allow_wrap = renderer->width > 0 && !(CMARK_OPT_NOBREAKS & options) &&
!(CMARK_OPT_HARDBREAKS & options);
// Don't adjust tight list status til we've started the list.
// Otherwise we loose the blank line between a paragraph and
// a following list.
if (!(node->type == CMARK_NODE_ITEM && node->prev == NULL && entering)) {
tmp = get_containing_block(node);
renderer->in_tight_list_item =
tmp && // tmp might be NULL if there is no containing block
((tmp->type == CMARK_NODE_ITEM &&
cmark_node_get_list_tight(tmp->parent)) ||
(tmp && tmp->parent && tmp->parent->type == CMARK_NODE_ITEM &&
cmark_node_get_list_tight(tmp->parent->parent)));
}
if (node->extension && node->extension->plaintext_render_func) {
node->extension->plaintext_render_func(node->extension, renderer, node, ev_type, options);
return 1;
}
switch (node->type) {
case CMARK_NODE_DOCUMENT:
break;
case CMARK_NODE_BLOCK_QUOTE:
break;
case CMARK_NODE_LIST:
if (!entering && node->next && (node->next->type == CMARK_NODE_CODE_BLOCK ||
node->next->type == CMARK_NODE_LIST)) {
CR();
}
break;
case CMARK_NODE_ITEM:
if (cmark_node_get_list_type(node->parent) == CMARK_BULLET_LIST) {
marker_width = 4;
} else {
list_number = cmark_node_get_list_start(node->parent);
list_delim = cmark_node_get_list_delim(node->parent);
tmp = node;
while (tmp->prev) {
tmp = tmp->prev;
list_number += 1;
}
// we ensure a width of at least 4 so
// we get nice transition from single digits
// to double
snprintf(listmarker, LISTMARKER_SIZE, "%d%s%s", list_number,
list_delim == CMARK_PAREN_DELIM ? ")" : ".",
list_number < 10 ? " " : " ");
marker_width = (bufsize_t)strlen(listmarker);
}
if (entering) {
if (cmark_node_get_list_type(node->parent) == CMARK_BULLET_LIST) {
LIT(" - ");
renderer->begin_content = true;
} else {
LIT(listmarker);
renderer->begin_content = true;
}
for (i = marker_width; i--;) {
cmark_strbuf_putc(renderer->prefix, ' ');
}
} else {
cmark_strbuf_truncate(renderer->prefix,
renderer->prefix->size - marker_width);
CR();
}
break;
case CMARK_NODE_HEADING:
if (entering) {
renderer->begin_content = true;
renderer->no_linebreaks = true;
} else {
renderer->no_linebreaks = false;
BLANKLINE();
}
break;
case CMARK_NODE_CODE_BLOCK:
first_in_list_item = node->prev == NULL && node->parent &&
node->parent->type == CMARK_NODE_ITEM;
if (!first_in_list_item) {
BLANKLINE();
}
OUT(cmark_node_get_literal(node), false, LITERAL);
BLANKLINE();
break;
case CMARK_NODE_HTML_BLOCK:
break;
case CMARK_NODE_CUSTOM_BLOCK:
break;
case CMARK_NODE_THEMATIC_BREAK:
BLANKLINE();
break;
case CMARK_NODE_PARAGRAPH:
if (!entering) {
BLANKLINE();
}
break;
case CMARK_NODE_TEXT:
OUT(cmark_node_get_literal(node), allow_wrap, NORMAL);
break;
case CMARK_NODE_LINEBREAK:
CR();
break;
case CMARK_NODE_SOFTBREAK:
if (CMARK_OPT_HARDBREAKS & options) {
CR();
} else if (!renderer->no_linebreaks && renderer->width == 0 &&
!(CMARK_OPT_HARDBREAKS & options) &&
!(CMARK_OPT_NOBREAKS & options)) {
CR();
} else {
OUT(" ", allow_wrap, LITERAL);
}
break;
case CMARK_NODE_CODE:
OUT(cmark_node_get_literal(node), allow_wrap, LITERAL);
break;
case CMARK_NODE_HTML_INLINE:
break;
case CMARK_NODE_CUSTOM_INLINE:
break;
case CMARK_NODE_STRONG:
break;
case CMARK_NODE_EMPH:
break;
case CMARK_NODE_LINK:
break;
case CMARK_NODE_IMAGE:
break;
case CMARK_NODE_FOOTNOTE_REFERENCE:
if (entering) {
LIT("[^");
OUT(cmark_chunk_to_cstr(renderer->mem, &node->as.literal), false, LITERAL);
LIT("]");
}
break;
case CMARK_NODE_FOOTNOTE_DEFINITION:
if (entering) {
renderer->footnote_ix += 1;
LIT("[^");
char n[32];
snprintf(n, sizeof(n), "%d", renderer->footnote_ix);
OUT(n, false, LITERAL);
LIT("]: ");
cmark_strbuf_puts(renderer->prefix, " ");
} else {
cmark_strbuf_truncate(renderer->prefix, renderer->prefix->size - 4);
}
break;
default:
assert(false);
break;
}
return 1;
}
char *cmark_render_plaintext(cmark_node *root, int options, int width) {
return cmark_render_plaintext_with_mem(root, options, width, cmark_node_mem(root));
}
char *cmark_render_plaintext_with_mem(cmark_node *root, int options, int width, cmark_mem *mem) {
if (options & CMARK_OPT_HARDBREAKS) {
// disable breaking on width, since it has
// a different meaning with OPT_HARDBREAKS
width = 0;
}
return cmark_render(mem, root, options, width, outc, S_render_node);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/cmark-gfm_version.h.in | #ifndef CMARK_GFM_VERSION_H
#define CMARK_GFM_VERSION_H
#define CMARK_GFM_VERSION ((@PROJECT_VERSION_MAJOR@ << 24) | (@PROJECT_VERSION_MINOR@ << 16) | (@PROJECT_VERSION_PATCH@ << 8) | @PROJECT_VERSION_GFM@)
#define CMARK_GFM_VERSION_STRING "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@[email protected].@PROJECT_VERSION_GFM@"
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/blocks.c | /**
* Block parsing implementation.
*
* For a high-level overview of the block parsing process,
* see http://spec.commonmark.org/0.24/#phase-1-block-structure
*/
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include "cmark_ctype.h"
#include "syntax_extension.h"
#include "config.h"
#include "parser.h"
#include "cmark-gfm.h"
#include "node.h"
#include "references.h"
#include "utf8.h"
#include "scanners.h"
#include "inlines.h"
#include "houdini.h"
#include "buffer.h"
#include "footnotes.h"
#define CODE_INDENT 4
#define TAB_STOP 4
#ifndef MIN
#define MIN(x, y) ((x < y) ? x : y)
#endif
#define peek_at(i, n) (i)->data[n]
static bool S_last_line_blank(const cmark_node *node) {
return (node->flags & CMARK_NODE__LAST_LINE_BLANK) != 0;
}
static bool S_last_line_checked(const cmark_node *node) {
return (node->flags & CMARK_NODE__LAST_LINE_CHECKED) != 0;
}
static CMARK_INLINE cmark_node_type S_type(const cmark_node *node) {
return (cmark_node_type)node->type;
}
static void S_set_last_line_blank(cmark_node *node, bool is_blank) {
if (is_blank)
node->flags |= CMARK_NODE__LAST_LINE_BLANK;
else
node->flags &= ~CMARK_NODE__LAST_LINE_BLANK;
}
static void S_set_last_line_checked(cmark_node *node) {
node->flags |= CMARK_NODE__LAST_LINE_CHECKED;
}
static CMARK_INLINE bool S_is_line_end_char(char c) {
return (c == '\n' || c == '\r');
}
static CMARK_INLINE bool S_is_space_or_tab(char c) {
return (c == ' ' || c == '\t');
}
static void S_parser_feed(cmark_parser *parser, const unsigned char *buffer,
size_t len, bool eof);
static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
bufsize_t bytes);
static cmark_node *make_block(cmark_mem *mem, cmark_node_type tag,
int start_line, int start_column) {
cmark_node *e;
e = (cmark_node *)mem->calloc(1, sizeof(*e));
cmark_strbuf_init(mem, &e->content, 32);
e->type = (uint16_t)tag;
e->flags = CMARK_NODE__OPEN;
e->start_line = start_line;
e->start_column = start_column;
e->end_line = start_line;
return e;
}
// Create a root document node.
static cmark_node *make_document(cmark_mem *mem) {
cmark_node *e = make_block(mem, CMARK_NODE_DOCUMENT, 1, 1);
return e;
}
int cmark_parser_attach_syntax_extension(cmark_parser *parser,
cmark_syntax_extension *extension) {
parser->syntax_extensions = cmark_llist_append(parser->mem, parser->syntax_extensions, extension);
if (extension->match_inline || extension->insert_inline_from_delim) {
parser->inline_syntax_extensions = cmark_llist_append(
parser->mem, parser->inline_syntax_extensions, extension);
}
return 1;
}
static void cmark_parser_dispose(cmark_parser *parser) {
if (parser->root)
cmark_node_free(parser->root);
if (parser->refmap)
cmark_map_free(parser->refmap);
}
static void cmark_parser_reset(cmark_parser *parser) {
cmark_llist *saved_exts = parser->syntax_extensions;
cmark_llist *saved_inline_exts = parser->inline_syntax_extensions;
int saved_options = parser->options;
cmark_mem *saved_mem = parser->mem;
cmark_parser_dispose(parser);
memset(parser, 0, sizeof(cmark_parser));
parser->mem = saved_mem;
cmark_strbuf_init(parser->mem, &parser->curline, 256);
cmark_strbuf_init(parser->mem, &parser->linebuf, 0);
cmark_node *document = make_document(parser->mem);
parser->refmap = cmark_reference_map_new(parser->mem);
parser->root = document;
parser->current = document;
parser->syntax_extensions = saved_exts;
parser->inline_syntax_extensions = saved_inline_exts;
parser->options = saved_options;
}
cmark_parser *cmark_parser_new_with_mem(int options, cmark_mem *mem) {
cmark_parser *parser = (cmark_parser *)mem->calloc(1, sizeof(cmark_parser));
parser->mem = mem;
parser->options = options;
cmark_parser_reset(parser);
return parser;
}
cmark_parser *cmark_parser_new(int options) {
extern cmark_mem CMARK_DEFAULT_MEM_ALLOCATOR;
return cmark_parser_new_with_mem(options, &CMARK_DEFAULT_MEM_ALLOCATOR);
}
void cmark_parser_free(cmark_parser *parser) {
cmark_mem *mem = parser->mem;
cmark_parser_dispose(parser);
cmark_strbuf_free(&parser->curline);
cmark_strbuf_free(&parser->linebuf);
cmark_llist_free(parser->mem, parser->syntax_extensions);
cmark_llist_free(parser->mem, parser->inline_syntax_extensions);
mem->free(parser);
}
static cmark_node *finalize(cmark_parser *parser, cmark_node *b);
// Returns true if line has only space characters, else false.
static bool is_blank(cmark_strbuf *s, bufsize_t offset) {
while (offset < s->size) {
switch (s->ptr[offset]) {
case '\r':
case '\n':
return true;
case ' ':
offset++;
break;
case '\t':
offset++;
break;
default:
return false;
}
}
return true;
}
static CMARK_INLINE bool accepts_lines(cmark_node_type block_type) {
return (block_type == CMARK_NODE_PARAGRAPH ||
block_type == CMARK_NODE_HEADING ||
block_type == CMARK_NODE_CODE_BLOCK);
}
static CMARK_INLINE bool contains_inlines(cmark_node *node) {
if (node->extension && node->extension->contains_inlines_func) {
return node->extension->contains_inlines_func(node->extension, node) != 0;
}
return (node->type == CMARK_NODE_PARAGRAPH ||
node->type == CMARK_NODE_HEADING);
}
static void add_line(cmark_node *node, cmark_chunk *ch, cmark_parser *parser) {
int chars_to_tab;
int i;
assert(node->flags & CMARK_NODE__OPEN);
if (parser->partially_consumed_tab) {
parser->offset += 1; // skip over tab
// add space characters:
chars_to_tab = TAB_STOP - (parser->column % TAB_STOP);
for (i = 0; i < chars_to_tab; i++) {
cmark_strbuf_putc(&node->content, ' ');
}
}
cmark_strbuf_put(&node->content, ch->data + parser->offset,
ch->len - parser->offset);
}
static void remove_trailing_blank_lines(cmark_strbuf *ln) {
bufsize_t i;
unsigned char c;
for (i = ln->size - 1; i >= 0; --i) {
c = ln->ptr[i];
if (c != ' ' && c != '\t' && !S_is_line_end_char(c))
break;
}
if (i < 0) {
cmark_strbuf_clear(ln);
return;
}
for (; i < ln->size; ++i) {
c = ln->ptr[i];
if (!S_is_line_end_char(c))
continue;
cmark_strbuf_truncate(ln, i);
break;
}
}
// Check to see if a node ends with a blank line, descending
// if needed into lists and sublists.
static bool S_ends_with_blank_line(cmark_node *node) {
if (S_last_line_checked(node)) {
return(S_last_line_blank(node));
} else if ((S_type(node) == CMARK_NODE_LIST ||
S_type(node) == CMARK_NODE_ITEM) && node->last_child) {
S_set_last_line_checked(node);
return(S_ends_with_blank_line(node->last_child));
} else {
S_set_last_line_checked(node);
return (S_last_line_blank(node));
}
}
// returns true if content remains after link defs are resolved.
static bool resolve_reference_link_definitions(
cmark_parser *parser,
cmark_node *b) {
bufsize_t pos;
cmark_strbuf *node_content = &b->content;
cmark_chunk chunk = {node_content->ptr, node_content->size, 0};
while (chunk.len && chunk.data[0] == '[' &&
(pos = cmark_parse_reference_inline(parser->mem, &chunk,
parser->refmap))) {
chunk.data += pos;
chunk.len -= pos;
}
cmark_strbuf_drop(node_content, (node_content->size - chunk.len));
return !is_blank(&b->content, 0);
}
static cmark_node *finalize(cmark_parser *parser, cmark_node *b) {
bufsize_t pos;
cmark_node *item;
cmark_node *subitem;
cmark_node *parent;
bool has_content;
parent = b->parent;
assert(b->flags &
CMARK_NODE__OPEN); // shouldn't call finalize on closed blocks
b->flags &= ~CMARK_NODE__OPEN;
if (parser->curline.size == 0) {
// end of input - line number has not been incremented
b->end_line = parser->line_number;
b->end_column = parser->last_line_length;
} else if (S_type(b) == CMARK_NODE_DOCUMENT ||
(S_type(b) == CMARK_NODE_CODE_BLOCK && b->as.code.fenced) ||
(S_type(b) == CMARK_NODE_HEADING && b->as.heading.setext)) {
b->end_line = parser->line_number;
b->end_column = parser->curline.size;
if (b->end_column && parser->curline.ptr[b->end_column - 1] == '\n')
b->end_column -= 1;
if (b->end_column && parser->curline.ptr[b->end_column - 1] == '\r')
b->end_column -= 1;
} else {
b->end_line = parser->line_number - 1;
b->end_column = parser->last_line_length;
}
cmark_strbuf *node_content = &b->content;
switch (S_type(b)) {
case CMARK_NODE_PARAGRAPH:
{
has_content = resolve_reference_link_definitions(parser, b);
if (!has_content) {
// remove blank node (former reference def)
cmark_node_free(b);
}
break;
}
case CMARK_NODE_CODE_BLOCK:
if (!b->as.code.fenced) { // indented code
remove_trailing_blank_lines(node_content);
cmark_strbuf_putc(node_content, '\n');
} else {
// first line of contents becomes info
for (pos = 0; pos < node_content->size; ++pos) {
if (S_is_line_end_char(node_content->ptr[pos]))
break;
}
assert(pos < node_content->size);
cmark_strbuf tmp = CMARK_BUF_INIT(parser->mem);
houdini_unescape_html_f(&tmp, node_content->ptr, pos);
cmark_strbuf_trim(&tmp);
cmark_strbuf_unescape(&tmp);
b->as.code.info = cmark_chunk_buf_detach(&tmp);
if (node_content->ptr[pos] == '\r')
pos += 1;
if (node_content->ptr[pos] == '\n')
pos += 1;
cmark_strbuf_drop(node_content, pos);
}
b->as.code.literal = cmark_chunk_buf_detach(node_content);
break;
case CMARK_NODE_HTML_BLOCK:
b->as.literal = cmark_chunk_buf_detach(node_content);
break;
case CMARK_NODE_LIST: // determine tight/loose status
b->as.list.tight = true; // tight by default
item = b->first_child;
while (item) {
// check for non-final non-empty list item ending with blank line:
if (S_last_line_blank(item) && item->next) {
b->as.list.tight = false;
break;
}
// recurse into children of list item, to see if there are
// spaces between them:
subitem = item->first_child;
while (subitem) {
if ((item->next || subitem->next) &&
S_ends_with_blank_line(subitem)) {
b->as.list.tight = false;
break;
}
subitem = subitem->next;
}
if (!(b->as.list.tight)) {
break;
}
item = item->next;
}
break;
default:
break;
}
return parent;
}
// Add a node as child of another. Return pointer to child.
static cmark_node *add_child(cmark_parser *parser, cmark_node *parent,
cmark_node_type block_type, int start_column) {
assert(parent);
// if 'parent' isn't the kind of node that can accept this child,
// then back up til we hit a node that can.
while (!cmark_node_can_contain_type(parent, block_type)) {
parent = finalize(parser, parent);
}
cmark_node *child =
make_block(parser->mem, block_type, parser->line_number, start_column);
child->parent = parent;
if (parent->last_child) {
parent->last_child->next = child;
child->prev = parent->last_child;
} else {
parent->first_child = child;
child->prev = NULL;
}
parent->last_child = child;
return child;
}
void cmark_manage_extensions_special_characters(cmark_parser *parser, int add) {
cmark_llist *tmp_ext;
for (tmp_ext = parser->inline_syntax_extensions; tmp_ext; tmp_ext=tmp_ext->next) {
cmark_syntax_extension *ext = (cmark_syntax_extension *) tmp_ext->data;
cmark_llist *tmp_char;
for (tmp_char = ext->special_inline_chars; tmp_char; tmp_char=tmp_char->next) {
unsigned char c = (unsigned char)(size_t)tmp_char->data;
if (add)
cmark_inlines_add_special_character(c, ext->emphasis);
else
cmark_inlines_remove_special_character(c, ext->emphasis);
}
}
}
// Walk through node and all children, recursively, parsing
// string content into inline content where appropriate.
static void process_inlines(cmark_parser *parser,
cmark_map *refmap, int options) {
cmark_iter *iter = cmark_iter_new(parser->root);
cmark_node *cur;
cmark_event_type ev_type;
cmark_manage_extensions_special_characters(parser, true);
while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
cur = cmark_iter_get_node(iter);
if (ev_type == CMARK_EVENT_ENTER) {
if (contains_inlines(cur)) {
cmark_parse_inlines(parser, cur, refmap, options);
}
}
}
cmark_manage_extensions_special_characters(parser, false);
cmark_iter_free(iter);
}
static int sort_footnote_by_ix(const void *_a, const void *_b) {
cmark_footnote *a = *(cmark_footnote **)_a;
cmark_footnote *b = *(cmark_footnote **)_b;
return (int)a->ix - (int)b->ix;
}
static void process_footnotes(cmark_parser *parser) {
// * Collect definitions in a map.
// * Iterate the references in the document in order, assigning indices to
// definitions in the order they're seen.
// * Write out the footnotes at the bottom of the document in index order.
cmark_map *map = cmark_footnote_map_new(parser->mem);
cmark_iter *iter = cmark_iter_new(parser->root);
cmark_node *cur;
cmark_event_type ev_type;
while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
cur = cmark_iter_get_node(iter);
if (ev_type == CMARK_EVENT_EXIT && cur->type == CMARK_NODE_FOOTNOTE_DEFINITION) {
cmark_node_unlink(cur);
cmark_footnote_create(map, cur);
}
}
cmark_iter_free(iter);
iter = cmark_iter_new(parser->root);
unsigned int ix = 0;
while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
cur = cmark_iter_get_node(iter);
if (ev_type == CMARK_EVENT_EXIT && cur->type == CMARK_NODE_FOOTNOTE_REFERENCE) {
cmark_footnote *footnote = (cmark_footnote *)cmark_map_lookup(map, &cur->as.literal);
if (footnote) {
if (!footnote->ix)
footnote->ix = ++ix;
char n[32];
snprintf(n, sizeof(n), "%d", footnote->ix);
cmark_chunk_free(parser->mem, &cur->as.literal);
cmark_strbuf buf = CMARK_BUF_INIT(parser->mem);
cmark_strbuf_puts(&buf, n);
cur->as.literal = cmark_chunk_buf_detach(&buf);
} else {
cmark_node *text = (cmark_node *)parser->mem->calloc(1, sizeof(*text));
cmark_strbuf_init(parser->mem, &text->content, 0);
text->type = (uint16_t) CMARK_NODE_TEXT;
cmark_strbuf buf = CMARK_BUF_INIT(parser->mem);
cmark_strbuf_puts(&buf, "[^");
cmark_strbuf_put(&buf, cur->as.literal.data, cur->as.literal.len);
cmark_strbuf_putc(&buf, ']');
text->as.literal = cmark_chunk_buf_detach(&buf);
cmark_node_insert_after(cur, text);
cmark_node_free(cur);
}
}
}
cmark_iter_free(iter);
if (map->sorted) {
qsort(map->sorted, map->size, sizeof(cmark_map_entry *), sort_footnote_by_ix);
for (unsigned int i = 0; i < map->size; ++i) {
cmark_footnote *footnote = (cmark_footnote *)map->sorted[i];
if (!footnote->ix)
continue;
cmark_node_append_child(parser->root, footnote->node);
footnote->node = NULL;
}
}
cmark_map_free(map);
}
// Attempts to parse a list item marker (bullet or enumerated).
// On success, returns length of the marker, and populates
// data with the details. On failure, returns 0.
static bufsize_t parse_list_marker(cmark_mem *mem, cmark_chunk *input,
bufsize_t pos, bool interrupts_paragraph,
cmark_list **dataptr) {
unsigned char c;
bufsize_t startpos;
cmark_list *data;
bufsize_t i;
startpos = pos;
c = peek_at(input, pos);
if (c == '*' || c == '-' || c == '+') {
pos++;
if (!cmark_isspace(peek_at(input, pos))) {
return 0;
}
if (interrupts_paragraph) {
i = pos;
// require non-blank content after list marker:
while (S_is_space_or_tab(peek_at(input, i))) {
i++;
}
if (peek_at(input, i) == '\n') {
return 0;
}
}
data = (cmark_list *)mem->calloc(1, sizeof(*data));
data->marker_offset = 0; // will be adjusted later
data->list_type = CMARK_BULLET_LIST;
data->bullet_char = c;
data->start = 0;
data->delimiter = CMARK_NO_DELIM;
data->tight = false;
} else if (cmark_isdigit(c)) {
int start = 0;
int digits = 0;
do {
start = (10 * start) + (peek_at(input, pos) - '0');
pos++;
digits++;
// We limit to 9 digits to avoid overflow,
// assuming max int is 2^31 - 1
// This also seems to be the limit for 'start' in some browsers.
} while (digits < 9 && cmark_isdigit(peek_at(input, pos)));
if (interrupts_paragraph && start != 1) {
return 0;
}
c = peek_at(input, pos);
if (c == '.' || c == ')') {
pos++;
if (!cmark_isspace(peek_at(input, pos))) {
return 0;
}
if (interrupts_paragraph) {
// require non-blank content after list marker:
i = pos;
while (S_is_space_or_tab(peek_at(input, i))) {
i++;
}
if (S_is_line_end_char(peek_at(input, i))) {
return 0;
}
}
data = (cmark_list *)mem->calloc(1, sizeof(*data));
data->marker_offset = 0; // will be adjusted later
data->list_type = CMARK_ORDERED_LIST;
data->bullet_char = 0;
data->start = start;
data->delimiter = (c == '.' ? CMARK_PERIOD_DELIM : CMARK_PAREN_DELIM);
data->tight = false;
} else {
return 0;
}
} else {
return 0;
}
*dataptr = data;
return (pos - startpos);
}
// Return 1 if list item belongs in list, else 0.
static int lists_match(cmark_list *list_data, cmark_list *item_data) {
return (list_data->list_type == item_data->list_type &&
list_data->delimiter == item_data->delimiter &&
// list_data->marker_offset == item_data.marker_offset &&
list_data->bullet_char == item_data->bullet_char);
}
static cmark_node *finalize_document(cmark_parser *parser) {
while (parser->current != parser->root) {
parser->current = finalize(parser, parser->current);
}
finalize(parser, parser->root);
process_inlines(parser, parser->refmap, parser->options);
if (parser->options & CMARK_OPT_FOOTNOTES)
process_footnotes(parser);
return parser->root;
}
cmark_node *cmark_parse_file(FILE *f, int options) {
unsigned char buffer[4096];
cmark_parser *parser = cmark_parser_new(options);
size_t bytes;
cmark_node *document;
while ((bytes = fread(buffer, 1, sizeof(buffer), f)) > 0) {
bool eof = bytes < sizeof(buffer);
S_parser_feed(parser, buffer, bytes, eof);
if (eof) {
break;
}
}
document = cmark_parser_finish(parser);
cmark_parser_free(parser);
return document;
}
cmark_node *cmark_parse_document(const char *buffer, size_t len, int options) {
cmark_parser *parser = cmark_parser_new(options);
cmark_node *document;
S_parser_feed(parser, (const unsigned char *)buffer, len, true);
document = cmark_parser_finish(parser);
cmark_parser_free(parser);
return document;
}
void cmark_parser_feed(cmark_parser *parser, const char *buffer, size_t len) {
S_parser_feed(parser, (const unsigned char *)buffer, len, false);
}
void cmark_parser_feed_reentrant(cmark_parser *parser, const char *buffer, size_t len) {
cmark_strbuf saved_linebuf;
cmark_strbuf_init(parser->mem, &saved_linebuf, 0);
cmark_strbuf_puts(&saved_linebuf, cmark_strbuf_cstr(&parser->linebuf));
cmark_strbuf_clear(&parser->linebuf);
S_parser_feed(parser, (const unsigned char *)buffer, len, true);
cmark_strbuf_sets(&parser->linebuf, cmark_strbuf_cstr(&saved_linebuf));
cmark_strbuf_free(&saved_linebuf);
}
static void S_parser_feed(cmark_parser *parser, const unsigned char *buffer,
size_t len, bool eof) {
const unsigned char *end = buffer + len;
static const uint8_t repl[] = {239, 191, 189};
if (parser->last_buffer_ended_with_cr && *buffer == '\n') {
// skip NL if last buffer ended with CR ; see #117
buffer++;
}
parser->last_buffer_ended_with_cr = false;
while (buffer < end) {
const unsigned char *eol;
bufsize_t chunk_len;
bool process = false;
for (eol = buffer; eol < end; ++eol) {
if (S_is_line_end_char(*eol)) {
process = true;
break;
}
if (*eol == '\0' && eol < end) {
break;
}
}
if (eol >= end && eof) {
process = true;
}
chunk_len = (bufsize_t)(eol - buffer);
if (process) {
if (parser->linebuf.size > 0) {
cmark_strbuf_put(&parser->linebuf, buffer, chunk_len);
S_process_line(parser, parser->linebuf.ptr, parser->linebuf.size);
cmark_strbuf_clear(&parser->linebuf);
} else {
S_process_line(parser, buffer, chunk_len);
}
} else {
if (eol < end && *eol == '\0') {
// omit NULL byte
cmark_strbuf_put(&parser->linebuf, buffer, chunk_len);
// add replacement character
cmark_strbuf_put(&parser->linebuf, repl, 3);
} else {
cmark_strbuf_put(&parser->linebuf, buffer, chunk_len);
}
}
buffer += chunk_len;
if (buffer < end) {
if (*buffer == '\0') {
// skip over NULL
buffer++;
} else {
// skip over line ending characters
if (*buffer == '\r') {
buffer++;
if (buffer == end)
parser->last_buffer_ended_with_cr = true;
}
if (buffer < end && *buffer == '\n')
buffer++;
}
}
}
}
static void chop_trailing_hashtags(cmark_chunk *ch) {
bufsize_t n, orig_n;
cmark_chunk_rtrim(ch);
orig_n = n = ch->len - 1;
// if string ends in space followed by #s, remove these:
while (n >= 0 && peek_at(ch, n) == '#')
n--;
// Check for a space before the final #s:
if (n != orig_n && n >= 0 && S_is_space_or_tab(peek_at(ch, n))) {
ch->len = n;
cmark_chunk_rtrim(ch);
}
}
// Check for thematic break. On failure, return 0 and update
// thematic_break_kill_pos with the index at which the
// parse fails. On success, return length of match.
// "...three or more hyphens, asterisks,
// or underscores on a line by themselves. If you wish, you may use
// spaces between the hyphens or asterisks."
static int S_scan_thematic_break(cmark_parser *parser, cmark_chunk *input,
bufsize_t offset) {
bufsize_t i;
char c;
char nextc = '\0';
int count;
i = offset;
c = peek_at(input, i);
if (!(c == '*' || c == '_' || c == '-')) {
parser->thematic_break_kill_pos = i;
return 0;
}
count = 1;
while ((nextc = peek_at(input, ++i))) {
if (nextc == c) {
count++;
} else if (nextc != ' ' && nextc != '\t') {
break;
}
}
if (count >= 3 && (nextc == '\r' || nextc == '\n')) {
return (i - offset) + 1;
} else {
parser->thematic_break_kill_pos = i;
return 0;
}
}
// Find first nonspace character from current offset, setting
// parser->first_nonspace, parser->first_nonspace_column,
// parser->indent, and parser->blank. Does not advance parser->offset.
static void S_find_first_nonspace(cmark_parser *parser, cmark_chunk *input) {
char c;
int chars_to_tab = TAB_STOP - (parser->column % TAB_STOP);
if (parser->first_nonspace <= parser->offset) {
parser->first_nonspace = parser->offset;
parser->first_nonspace_column = parser->column;
while ((c = peek_at(input, parser->first_nonspace))) {
if (c == ' ') {
parser->first_nonspace += 1;
parser->first_nonspace_column += 1;
chars_to_tab = chars_to_tab - 1;
if (chars_to_tab == 0) {
chars_to_tab = TAB_STOP;
}
} else if (c == '\t') {
parser->first_nonspace += 1;
parser->first_nonspace_column += chars_to_tab;
chars_to_tab = TAB_STOP;
} else {
break;
}
}
}
parser->indent = parser->first_nonspace_column - parser->column;
parser->blank = S_is_line_end_char(peek_at(input, parser->first_nonspace));
}
// Advance parser->offset and parser->column. parser->offset is the
// byte position in input; parser->column is a virtual column number
// that takes into account tabs. (Multibyte characters are not taken
// into account, because the Markdown line prefixes we are interested in
// analyzing are entirely ASCII.) The count parameter indicates
// how far to advance the offset. If columns is true, then count
// indicates a number of columns; otherwise, a number of bytes.
// If advancing a certain number of columns partially consumes
// a tab character, parser->partially_consumed_tab is set to true.
static void S_advance_offset(cmark_parser *parser, cmark_chunk *input,
bufsize_t count, bool columns) {
char c;
int chars_to_tab;
int chars_to_advance;
while (count > 0 && (c = peek_at(input, parser->offset))) {
if (c == '\t') {
chars_to_tab = TAB_STOP - (parser->column % TAB_STOP);
if (columns) {
parser->partially_consumed_tab = chars_to_tab > count;
chars_to_advance = MIN(count, chars_to_tab);
parser->column += chars_to_advance;
parser->offset += (parser->partially_consumed_tab ? 0 : 1);
count -= chars_to_advance;
} else {
parser->partially_consumed_tab = false;
parser->column += chars_to_tab;
parser->offset += 1;
count -= 1;
}
} else {
parser->partially_consumed_tab = false;
parser->offset += 1;
parser->column += 1; // assume ascii; block starts are ascii
count -= 1;
}
}
}
static bool S_last_child_is_open(cmark_node *container) {
return container->last_child &&
(container->last_child->flags & CMARK_NODE__OPEN);
}
static bool parse_block_quote_prefix(cmark_parser *parser, cmark_chunk *input) {
bool res = false;
bufsize_t matched = 0;
matched =
parser->indent <= 3 && peek_at(input, parser->first_nonspace) == '>';
if (matched) {
S_advance_offset(parser, input, parser->indent + 1, true);
if (S_is_space_or_tab(peek_at(input, parser->offset))) {
S_advance_offset(parser, input, 1, true);
}
res = true;
}
return res;
}
static bool parse_footnote_definition_block_prefix(cmark_parser *parser, cmark_chunk *input,
cmark_node *container) {
if (parser->indent >= 4) {
S_advance_offset(parser, input, 4, true);
return true;
} else if (input->len > 0 && (input->data[0] == '\n' || (input->data[0] == '\r' && input->data[1] == '\n'))) {
return true;
}
return false;
}
static bool parse_node_item_prefix(cmark_parser *parser, cmark_chunk *input,
cmark_node *container) {
bool res = false;
if (parser->indent >=
container->as.list.marker_offset + container->as.list.padding) {
S_advance_offset(parser, input, container->as.list.marker_offset +
container->as.list.padding,
true);
res = true;
} else if (parser->blank && container->first_child != NULL) {
// if container->first_child is NULL, then the opening line
// of the list item was blank after the list marker; in this
// case, we are done with the list item.
S_advance_offset(parser, input, parser->first_nonspace - parser->offset,
false);
res = true;
}
return res;
}
static bool parse_code_block_prefix(cmark_parser *parser, cmark_chunk *input,
cmark_node *container,
bool *should_continue) {
bool res = false;
if (!container->as.code.fenced) { // indented
if (parser->indent >= CODE_INDENT) {
S_advance_offset(parser, input, CODE_INDENT, true);
res = true;
} else if (parser->blank) {
S_advance_offset(parser, input, parser->first_nonspace - parser->offset,
false);
res = true;
}
} else { // fenced
bufsize_t matched = 0;
if (parser->indent <= 3 && (peek_at(input, parser->first_nonspace) ==
container->as.code.fence_char)) {
matched = scan_close_code_fence(input, parser->first_nonspace);
}
if (matched >= container->as.code.fence_length) {
// closing fence - and since we're at
// the end of a line, we can stop processing it:
*should_continue = false;
S_advance_offset(parser, input, matched, false);
parser->current = finalize(parser, container);
} else {
// skip opt. spaces of fence parser->offset
int i = container->as.code.fence_offset;
while (i > 0 && S_is_space_or_tab(peek_at(input, parser->offset))) {
S_advance_offset(parser, input, 1, true);
i--;
}
res = true;
}
}
return res;
}
static bool parse_html_block_prefix(cmark_parser *parser,
cmark_node *container) {
bool res = false;
int html_block_type = container->as.html_block_type;
assert(html_block_type >= 1 && html_block_type <= 7);
switch (html_block_type) {
case 1:
case 2:
case 3:
case 4:
case 5:
// these types of blocks can accept blanks
res = true;
break;
case 6:
case 7:
res = !parser->blank;
break;
}
return res;
}
static bool parse_extension_block(cmark_parser *parser,
cmark_node *container,
cmark_chunk *input)
{
bool res = false;
if (container->extension->last_block_matches) {
if (container->extension->last_block_matches(
container->extension, parser, input->data, input->len, container))
res = true;
}
return res;
}
/**
* For each containing node, try to parse the associated line start.
*
* Will not close unmatched blocks, as we may have a lazy continuation
* line -> http://spec.commonmark.org/0.24/#lazy-continuation-line
*
* Returns: The last matching node, or NULL
*/
static cmark_node *check_open_blocks(cmark_parser *parser, cmark_chunk *input,
bool *all_matched) {
bool should_continue = true;
*all_matched = false;
cmark_node *container = parser->root;
cmark_node_type cont_type;
while (S_last_child_is_open(container)) {
container = container->last_child;
cont_type = S_type(container);
S_find_first_nonspace(parser, input);
if (container->extension) {
if (!parse_extension_block(parser, container, input))
goto done;
continue;
}
switch (cont_type) {
case CMARK_NODE_BLOCK_QUOTE:
if (!parse_block_quote_prefix(parser, input))
goto done;
break;
case CMARK_NODE_ITEM:
if (!parse_node_item_prefix(parser, input, container))
goto done;
break;
case CMARK_NODE_CODE_BLOCK:
if (!parse_code_block_prefix(parser, input, container, &should_continue))
goto done;
break;
case CMARK_NODE_HEADING:
// a heading can never contain more than one line
goto done;
case CMARK_NODE_HTML_BLOCK:
if (!parse_html_block_prefix(parser, container))
goto done;
break;
case CMARK_NODE_PARAGRAPH:
if (parser->blank)
goto done;
break;
case CMARK_NODE_FOOTNOTE_DEFINITION:
if (!parse_footnote_definition_block_prefix(parser, input, container))
goto done;
break;
default:
break;
}
}
*all_matched = true;
done:
if (!*all_matched) {
container = container->parent; // back up to last matching node
}
if (!should_continue) {
container = NULL;
}
return container;
}
static void open_new_blocks(cmark_parser *parser, cmark_node **container,
cmark_chunk *input, bool all_matched) {
bool indented;
cmark_list *data = NULL;
bool maybe_lazy = S_type(parser->current) == CMARK_NODE_PARAGRAPH;
cmark_node_type cont_type = S_type(*container);
bufsize_t matched = 0;
int lev = 0;
bool save_partially_consumed_tab;
bool has_content;
int save_offset;
int save_column;
while (cont_type != CMARK_NODE_CODE_BLOCK &&
cont_type != CMARK_NODE_HTML_BLOCK) {
S_find_first_nonspace(parser, input);
indented = parser->indent >= CODE_INDENT;
if (!indented && peek_at(input, parser->first_nonspace) == '>') {
bufsize_t blockquote_startpos = parser->first_nonspace;
S_advance_offset(parser, input,
parser->first_nonspace + 1 - parser->offset, false);
// optional following character
if (S_is_space_or_tab(peek_at(input, parser->offset))) {
S_advance_offset(parser, input, 1, true);
}
*container = add_child(parser, *container, CMARK_NODE_BLOCK_QUOTE,
blockquote_startpos + 1);
} else if (!indented && (matched = scan_atx_heading_start(
input, parser->first_nonspace))) {
bufsize_t hashpos;
int level = 0;
bufsize_t heading_startpos = parser->first_nonspace;
S_advance_offset(parser, input,
parser->first_nonspace + matched - parser->offset,
false);
*container = add_child(parser, *container, CMARK_NODE_HEADING,
heading_startpos + 1);
hashpos = cmark_chunk_strchr(input, '#', parser->first_nonspace);
while (peek_at(input, hashpos) == '#') {
level++;
hashpos++;
}
(*container)->as.heading.level = level;
(*container)->as.heading.setext = false;
(*container)->internal_offset = matched;
} else if (!indented && (matched = scan_open_code_fence(
input, parser->first_nonspace))) {
*container = add_child(parser, *container, CMARK_NODE_CODE_BLOCK,
parser->first_nonspace + 1);
(*container)->as.code.fenced = true;
(*container)->as.code.fence_char = peek_at(input, parser->first_nonspace);
(*container)->as.code.fence_length = (matched > 255) ? 255 : (uint8_t)matched;
(*container)->as.code.fence_offset =
(int8_t)(parser->first_nonspace - parser->offset);
(*container)->as.code.info = cmark_chunk_literal("");
S_advance_offset(parser, input,
parser->first_nonspace + matched - parser->offset,
false);
} else if (!indented && ((matched = scan_html_block_start(
input, parser->first_nonspace)) ||
(cont_type != CMARK_NODE_PARAGRAPH &&
(matched = scan_html_block_start_7(
input, parser->first_nonspace))))) {
*container = add_child(parser, *container, CMARK_NODE_HTML_BLOCK,
parser->first_nonspace + 1);
(*container)->as.html_block_type = matched;
// note, we don't adjust parser->offset because the tag is part of the
// text
} else if (!indented && cont_type == CMARK_NODE_PARAGRAPH &&
(lev =
scan_setext_heading_line(input, parser->first_nonspace))) {
// finalize paragraph, resolving reference links
has_content = resolve_reference_link_definitions(parser, *container);
if (has_content) {
(*container)->type = (uint16_t)CMARK_NODE_HEADING;
(*container)->as.heading.level = lev;
(*container)->as.heading.setext = true;
S_advance_offset(parser, input, input->len - 1 - parser->offset, false);
}
} else if (!indented &&
!(cont_type == CMARK_NODE_PARAGRAPH && !all_matched) &&
(parser->thematic_break_kill_pos <= parser->first_nonspace) &&
(matched = S_scan_thematic_break(parser, input, parser->first_nonspace))) {
// it's only now that we know the line is not part of a setext heading:
*container = add_child(parser, *container, CMARK_NODE_THEMATIC_BREAK,
parser->first_nonspace + 1);
S_advance_offset(parser, input, input->len - 1 - parser->offset, false);
} else if (!indented &&
parser->options & CMARK_OPT_FOOTNOTES &&
(matched = scan_footnote_definition(input, parser->first_nonspace))) {
cmark_chunk c = cmark_chunk_dup(input, parser->first_nonspace + 2, matched - 2);
cmark_chunk_to_cstr(parser->mem, &c);
while (c.data[c.len - 1] != ']')
--c.len;
--c.len;
S_advance_offset(parser, input, parser->first_nonspace + matched - parser->offset, false);
*container = add_child(parser, *container, CMARK_NODE_FOOTNOTE_DEFINITION, parser->first_nonspace + matched + 1);
(*container)->as.literal = c;
(*container)->internal_offset = matched;
} else if ((!indented || cont_type == CMARK_NODE_LIST) &&
parser->indent < 4 &&
(matched = parse_list_marker(
parser->mem, input, parser->first_nonspace,
(*container)->type == CMARK_NODE_PARAGRAPH, &data))) {
// Note that we can have new list items starting with >= 4
// spaces indent, as long as the list container is still open.
int i = 0;
// compute padding:
S_advance_offset(parser, input,
parser->first_nonspace + matched - parser->offset,
false);
save_partially_consumed_tab = parser->partially_consumed_tab;
save_offset = parser->offset;
save_column = parser->column;
while (parser->column - save_column <= 5 &&
S_is_space_or_tab(peek_at(input, parser->offset))) {
S_advance_offset(parser, input, 1, true);
}
i = parser->column - save_column;
if (i >= 5 || i < 1 ||
// only spaces after list marker:
S_is_line_end_char(peek_at(input, parser->offset))) {
data->padding = matched + 1;
parser->offset = save_offset;
parser->column = save_column;
parser->partially_consumed_tab = save_partially_consumed_tab;
if (i > 0) {
S_advance_offset(parser, input, 1, true);
}
} else {
data->padding = matched + i;
}
// check container; if it's a list, see if this list item
// can continue the list; otherwise, create a list container.
data->marker_offset = parser->indent;
if (cont_type != CMARK_NODE_LIST ||
!lists_match(&((*container)->as.list), data)) {
*container = add_child(parser, *container, CMARK_NODE_LIST,
parser->first_nonspace + 1);
memcpy(&((*container)->as.list), data, sizeof(*data));
}
// add the list item
*container = add_child(parser, *container, CMARK_NODE_ITEM,
parser->first_nonspace + 1);
/* TODO: static */
memcpy(&((*container)->as.list), data, sizeof(*data));
parser->mem->free(data);
} else if (indented && !maybe_lazy && !parser->blank) {
S_advance_offset(parser, input, CODE_INDENT, true);
*container = add_child(parser, *container, CMARK_NODE_CODE_BLOCK,
parser->offset + 1);
(*container)->as.code.fenced = false;
(*container)->as.code.fence_char = 0;
(*container)->as.code.fence_length = 0;
(*container)->as.code.fence_offset = 0;
(*container)->as.code.info = cmark_chunk_literal("");
} else {
cmark_llist *tmp;
cmark_node *new_container = NULL;
for (tmp = parser->syntax_extensions; tmp; tmp=tmp->next) {
cmark_syntax_extension *ext = (cmark_syntax_extension *) tmp->data;
if (ext->try_opening_block) {
new_container = ext->try_opening_block(
ext, indented, parser, *container, input->data, input->len);
if (new_container) {
*container = new_container;
break;
}
}
}
if (!new_container) {
break;
}
}
if (accepts_lines(S_type(*container))) {
// if it's a line container, it can't contain other containers
break;
}
cont_type = S_type(*container);
maybe_lazy = false;
}
}
static void add_text_to_container(cmark_parser *parser, cmark_node *container,
cmark_node *last_matched_container,
cmark_chunk *input) {
cmark_node *tmp;
// what remains at parser->offset is a text line. add the text to the
// appropriate container.
S_find_first_nonspace(parser, input);
if (parser->blank && container->last_child)
S_set_last_line_blank(container->last_child, true);
// block quote lines are never blank as they start with >
// and we don't count blanks in fenced code for purposes of tight/loose
// lists or breaking out of lists. we also don't set last_line_blank
// on an empty list item.
const cmark_node_type ctype = S_type(container);
const bool last_line_blank =
(parser->blank && ctype != CMARK_NODE_BLOCK_QUOTE &&
ctype != CMARK_NODE_HEADING && ctype != CMARK_NODE_THEMATIC_BREAK &&
!(ctype == CMARK_NODE_CODE_BLOCK && container->as.code.fenced) &&
!(ctype == CMARK_NODE_ITEM && container->first_child == NULL &&
container->start_line == parser->line_number));
S_set_last_line_blank(container, last_line_blank);
tmp = container;
while (tmp->parent) {
S_set_last_line_blank(tmp->parent, false);
tmp = tmp->parent;
}
// If the last line processed belonged to a paragraph node,
// and we didn't match all of the line prefixes for the open containers,
// and we didn't start any new containers,
// and the line isn't blank,
// then treat this as a "lazy continuation line" and add it to
// the open paragraph.
if (parser->current != last_matched_container &&
container == last_matched_container && !parser->blank &&
S_type(parser->current) == CMARK_NODE_PARAGRAPH) {
add_line(parser->current, input, parser);
} else { // not a lazy continuation
// Finalize any blocks that were not matched and set cur to container:
while (parser->current != last_matched_container) {
parser->current = finalize(parser, parser->current);
assert(parser->current != NULL);
}
if (S_type(container) == CMARK_NODE_CODE_BLOCK) {
add_line(container, input, parser);
} else if (S_type(container) == CMARK_NODE_HTML_BLOCK) {
add_line(container, input, parser);
int matches_end_condition;
switch (container->as.html_block_type) {
case 1:
// </script>, </style>, </pre>
matches_end_condition =
scan_html_block_end_1(input, parser->first_nonspace);
break;
case 2:
// -->
matches_end_condition =
scan_html_block_end_2(input, parser->first_nonspace);
break;
case 3:
// ?>
matches_end_condition =
scan_html_block_end_3(input, parser->first_nonspace);
break;
case 4:
// >
matches_end_condition =
scan_html_block_end_4(input, parser->first_nonspace);
break;
case 5:
// ]]>
matches_end_condition =
scan_html_block_end_5(input, parser->first_nonspace);
break;
default:
matches_end_condition = 0;
break;
}
if (matches_end_condition) {
container = finalize(parser, container);
assert(parser->current != NULL);
}
} else if (parser->blank) {
// ??? do nothing
} else if (accepts_lines(S_type(container))) {
if (S_type(container) == CMARK_NODE_HEADING &&
container->as.heading.setext == false) {
chop_trailing_hashtags(input);
}
S_advance_offset(parser, input, parser->first_nonspace - parser->offset,
false);
add_line(container, input, parser);
} else {
// create paragraph container for line
container = add_child(parser, container, CMARK_NODE_PARAGRAPH,
parser->first_nonspace + 1);
S_advance_offset(parser, input, parser->first_nonspace - parser->offset,
false);
add_line(container, input, parser);
}
parser->current = container;
}
}
/* See http://spec.commonmark.org/0.24/#phase-1-block-structure */
static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
bufsize_t bytes) {
cmark_node *last_matched_container;
bool all_matched = true;
cmark_node *container;
cmark_chunk input;
cmark_node *current;
cmark_strbuf_clear(&parser->curline);
if (parser->options & CMARK_OPT_VALIDATE_UTF8)
cmark_utf8proc_check(&parser->curline, buffer, bytes);
else
cmark_strbuf_put(&parser->curline, buffer, bytes);
bytes = parser->curline.size;
// ensure line ends with a newline:
if (bytes == 0 || !S_is_line_end_char(parser->curline.ptr[bytes - 1]))
cmark_strbuf_putc(&parser->curline, '\n');
parser->offset = 0;
parser->column = 0;
parser->first_nonspace = 0;
parser->first_nonspace_column = 0;
parser->thematic_break_kill_pos = 0;
parser->indent = 0;
parser->blank = false;
parser->partially_consumed_tab = false;
input.data = parser->curline.ptr;
input.len = parser->curline.size;
input.alloc = 0;
// Skip UTF-8 BOM.
if (parser->line_number == 0 &&
input.len >= 3 &&
memcmp(input.data, "\xef\xbb\xbf", 3) == 0)
parser->offset += 3;
parser->line_number++;
last_matched_container = check_open_blocks(parser, &input, &all_matched);
if (!last_matched_container)
goto finished;
container = last_matched_container;
current = parser->current;
open_new_blocks(parser, &container, &input, all_matched);
/* parser->current might have changed if feed_reentrant was called */
if (current == parser->current)
add_text_to_container(parser, container, last_matched_container, &input);
finished:
parser->last_line_length = input.len;
if (parser->last_line_length &&
input.data[parser->last_line_length - 1] == '\n')
parser->last_line_length -= 1;
if (parser->last_line_length &&
input.data[parser->last_line_length - 1] == '\r')
parser->last_line_length -= 1;
cmark_strbuf_clear(&parser->curline);
}
cmark_node *cmark_parser_finish(cmark_parser *parser) {
cmark_node *res;
cmark_llist *extensions;
/* Parser was already finished once */
if (parser->root == NULL)
return NULL;
if (parser->linebuf.size) {
S_process_line(parser, parser->linebuf.ptr, parser->linebuf.size);
cmark_strbuf_clear(&parser->linebuf);
}
finalize_document(parser);
cmark_consolidate_text_nodes(parser->root);
cmark_strbuf_free(&parser->curline);
cmark_strbuf_free(&parser->linebuf);
#if CMARK_DEBUG_NODES
if (cmark_node_check(parser->root, stderr)) {
abort();
}
#endif
for (extensions = parser->syntax_extensions; extensions; extensions = extensions->next) {
cmark_syntax_extension *ext = (cmark_syntax_extension *) extensions->data;
if (ext->postprocess_func) {
cmark_node *processed = ext->postprocess_func(ext, parser, parser->root);
if (processed)
parser->root = processed;
}
}
res = parser->root;
parser->root = NULL;
cmark_parser_reset(parser);
return res;
}
int cmark_parser_get_line_number(cmark_parser *parser) {
return parser->line_number;
}
bufsize_t cmark_parser_get_offset(cmark_parser *parser) {
return parser->offset;
}
bufsize_t cmark_parser_get_column(cmark_parser *parser) {
return parser->column;
}
int cmark_parser_get_first_nonspace(cmark_parser *parser) {
return parser->first_nonspace;
}
int cmark_parser_get_first_nonspace_column(cmark_parser *parser) {
return parser->first_nonspace_column;
}
int cmark_parser_get_indent(cmark_parser *parser) {
return parser->indent;
}
int cmark_parser_is_blank(cmark_parser *parser) {
return parser->blank;
}
int cmark_parser_has_partially_consumed_tab(cmark_parser *parser) {
return parser->partially_consumed_tab;
}
int cmark_parser_get_last_line_length(cmark_parser *parser) {
return parser->last_line_length;
}
cmark_node *cmark_parser_add_child(cmark_parser *parser,
cmark_node *parent,
cmark_node_type block_type,
int start_column) {
return add_child(parser, parent, block_type, start_column);
}
void cmark_parser_advance_offset(cmark_parser *parser,
const char *input,
int count,
int columns) {
cmark_chunk input_chunk = cmark_chunk_literal(input);
S_advance_offset(parser, &input_chunk, count, columns != 0);
}
void cmark_parser_set_backslash_ispunct_func(cmark_parser *parser,
cmark_ispunct_func func) {
parser->backslash_ispunct = func;
}
cmark_llist *cmark_parser_get_syntax_extensions(cmark_parser *parser) {
return parser->syntax_extensions;
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/iterator.h | #ifndef CMARK_ITERATOR_H
#define CMARK_ITERATOR_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cmark-gfm.h"
typedef struct {
cmark_event_type ev_type;
cmark_node *node;
} cmark_iter_state;
struct cmark_iter {
cmark_mem *mem;
cmark_node *root;
cmark_iter_state cur;
cmark_iter_state next;
};
#ifdef __cplusplus
}
#endif
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/chunk.h | #ifndef CMARK_CHUNK_H
#define CMARK_CHUNK_H
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "cmark-gfm.h"
#include "buffer.h"
#include "cmark_ctype.h"
#define CMARK_CHUNK_EMPTY \
{ NULL, 0, 0 }
typedef struct cmark_chunk {
unsigned char *data;
bufsize_t len;
bufsize_t alloc; // also implies a NULL-terminated string
} cmark_chunk;
static CMARK_INLINE void cmark_chunk_free(cmark_mem *mem, cmark_chunk *c) {
if (c->alloc)
mem->free(c->data);
c->data = NULL;
c->alloc = 0;
c->len = 0;
}
static CMARK_INLINE void cmark_chunk_ltrim(cmark_chunk *c) {
assert(!c->alloc);
while (c->len && cmark_isspace(c->data[0])) {
c->data++;
c->len--;
}
}
static CMARK_INLINE void cmark_chunk_rtrim(cmark_chunk *c) {
assert(!c->alloc);
while (c->len > 0) {
if (!cmark_isspace(c->data[c->len - 1]))
break;
c->len--;
}
}
static CMARK_INLINE void cmark_chunk_trim(cmark_chunk *c) {
cmark_chunk_ltrim(c);
cmark_chunk_rtrim(c);
}
static CMARK_INLINE bufsize_t cmark_chunk_strchr(cmark_chunk *ch, int c,
bufsize_t offset) {
const unsigned char *p =
(unsigned char *)memchr(ch->data + offset, c, ch->len - offset);
return p ? (bufsize_t)(p - ch->data) : ch->len;
}
static CMARK_INLINE const char *cmark_chunk_to_cstr(cmark_mem *mem,
cmark_chunk *c) {
unsigned char *str;
if (c->alloc) {
return (char *)c->data;
}
str = (unsigned char *)mem->calloc(c->len + 1, 1);
if (c->len > 0) {
memcpy(str, c->data, c->len);
}
str[c->len] = 0;
c->data = str;
c->alloc = 1;
return (char *)str;
}
static CMARK_INLINE void cmark_chunk_set_cstr(cmark_mem *mem, cmark_chunk *c,
const char *str) {
unsigned char *old = c->alloc ? c->data : NULL;
if (str == NULL) {
c->len = 0;
c->data = NULL;
c->alloc = 0;
} else {
c->len = (bufsize_t)strlen(str);
c->data = (unsigned char *)mem->calloc(c->len + 1, 1);
c->alloc = 1;
memcpy(c->data, str, c->len + 1);
}
if (old != NULL) {
mem->free(old);
}
}
static CMARK_INLINE cmark_chunk cmark_chunk_literal(const char *data) {
bufsize_t len = data ? (bufsize_t)strlen(data) : 0;
cmark_chunk c = {(unsigned char *)data, len, 0};
return c;
}
static CMARK_INLINE cmark_chunk cmark_chunk_dup(const cmark_chunk *ch,
bufsize_t pos, bufsize_t len) {
cmark_chunk c = {ch->data + pos, len, 0};
return c;
}
static CMARK_INLINE cmark_chunk cmark_chunk_buf_detach(cmark_strbuf *buf) {
cmark_chunk c;
c.len = buf->size;
c.data = cmark_strbuf_detach(buf);
c.alloc = 1;
return c;
}
/* trim_new variants are to be used when the source chunk may or may not be
* allocated; forces a newly allocated chunk. */
static CMARK_INLINE cmark_chunk cmark_chunk_ltrim_new(cmark_mem *mem, cmark_chunk *c) {
cmark_chunk r = cmark_chunk_dup(c, 0, c->len);
cmark_chunk_ltrim(&r);
cmark_chunk_to_cstr(mem, &r);
return r;
}
static CMARK_INLINE cmark_chunk cmark_chunk_rtrim_new(cmark_mem *mem, cmark_chunk *c) {
cmark_chunk r = cmark_chunk_dup(c, 0, c->len);
cmark_chunk_rtrim(&r);
cmark_chunk_to_cstr(mem, &r);
return r;
}
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/latex.c | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "config.h"
#include "cmark-gfm.h"
#include "node.h"
#include "buffer.h"
#include "utf8.h"
#include "scanners.h"
#include "render.h"
#include "syntax_extension.h"
#define OUT(s, wrap, escaping) renderer->out(renderer, node, s, wrap, escaping)
#define LIT(s) renderer->out(renderer, node, s, false, LITERAL)
#define CR() renderer->cr(renderer)
#define BLANKLINE() renderer->blankline(renderer)
#define LIST_NUMBER_STRING_SIZE 20
static CMARK_INLINE void outc(cmark_renderer *renderer, cmark_node *node,
cmark_escaping escape,
int32_t c, unsigned char nextc) {
if (escape == LITERAL) {
cmark_render_code_point(renderer, c);
return;
}
switch (c) {
case 123: // '{'
case 125: // '}'
case 35: // '#'
case 37: // '%'
case 38: // '&'
cmark_render_ascii(renderer, "\\");
cmark_render_code_point(renderer, c);
break;
case 36: // '$'
case 95: // '_'
if (escape == NORMAL) {
cmark_render_ascii(renderer, "\\");
}
cmark_render_code_point(renderer, c);
break;
case 45: // '-'
if (nextc == 45) { // prevent ligature
cmark_render_ascii(renderer, "-{}");
} else {
cmark_render_ascii(renderer, "-");
}
break;
case 126: // '~'
if (escape == NORMAL) {
cmark_render_ascii(renderer, "\\textasciitilde{}");
} else {
cmark_render_code_point(renderer, c);
}
break;
case 94: // '^'
cmark_render_ascii(renderer, "\\^{}");
break;
case 92: // '\\'
if (escape == URL) {
// / acts as path sep even on windows:
cmark_render_ascii(renderer, "/");
} else {
cmark_render_ascii(renderer, "\\textbackslash{}");
}
break;
case 124: // '|'
cmark_render_ascii(renderer, "\\textbar{}");
break;
case 60: // '<'
cmark_render_ascii(renderer, "\\textless{}");
break;
case 62: // '>'
cmark_render_ascii(renderer, "\\textgreater{}");
break;
case 91: // '['
case 93: // ']'
cmark_render_ascii(renderer, "{");
cmark_render_code_point(renderer, c);
cmark_render_ascii(renderer, "}");
break;
case 34: // '"'
cmark_render_ascii(renderer, "\\textquotedbl{}");
// requires \usepackage[T1]{fontenc}
break;
case 39: // '\''
cmark_render_ascii(renderer, "\\textquotesingle{}");
// requires \usepackage{textcomp}
break;
case 160: // nbsp
cmark_render_ascii(renderer, "~");
break;
case 8230: // hellip
cmark_render_ascii(renderer, "\\ldots{}");
break;
case 8216: // lsquo
if (escape == NORMAL) {
cmark_render_ascii(renderer, "`");
} else {
cmark_render_code_point(renderer, c);
}
break;
case 8217: // rsquo
if (escape == NORMAL) {
cmark_render_ascii(renderer, "\'");
} else {
cmark_render_code_point(renderer, c);
}
break;
case 8220: // ldquo
if (escape == NORMAL) {
cmark_render_ascii(renderer, "``");
} else {
cmark_render_code_point(renderer, c);
}
break;
case 8221: // rdquo
if (escape == NORMAL) {
cmark_render_ascii(renderer, "''");
} else {
cmark_render_code_point(renderer, c);
}
break;
case 8212: // emdash
if (escape == NORMAL) {
cmark_render_ascii(renderer, "---");
} else {
cmark_render_code_point(renderer, c);
}
break;
case 8211: // endash
if (escape == NORMAL) {
cmark_render_ascii(renderer, "--");
} else {
cmark_render_code_point(renderer, c);
}
break;
default:
cmark_render_code_point(renderer, c);
}
}
typedef enum {
NO_LINK,
URL_AUTOLINK,
EMAIL_AUTOLINK,
NORMAL_LINK,
INTERNAL_LINK
} link_type;
static link_type get_link_type(cmark_node *node) {
size_t title_len, url_len;
cmark_node *link_text;
char *realurl;
int realurllen;
bool isemail = false;
if (node->type != CMARK_NODE_LINK) {
return NO_LINK;
}
const char *url = cmark_node_get_url(node);
cmark_chunk url_chunk = cmark_chunk_literal(url);
if (url && *url == '#') {
return INTERNAL_LINK;
}
url_len = strlen(url);
if (url_len == 0 || scan_scheme(&url_chunk, 0) == 0) {
return NO_LINK;
}
const char *title = cmark_node_get_title(node);
title_len = strlen(title);
// if it has a title, we can't treat it as an autolink:
if (title_len == 0) {
link_text = node->first_child;
cmark_consolidate_text_nodes(link_text);
if (!link_text)
return NO_LINK;
realurl = (char *)url;
realurllen = (int)url_len;
if (strncmp(realurl, "mailto:", 7) == 0) {
realurl += 7;
realurllen -= 7;
isemail = true;
}
if (realurllen == link_text->as.literal.len &&
strncmp(realurl, (char *)link_text->as.literal.data,
link_text->as.literal.len) == 0) {
if (isemail) {
return EMAIL_AUTOLINK;
} else {
return URL_AUTOLINK;
}
}
}
return NORMAL_LINK;
}
static int S_get_enumlevel(cmark_node *node) {
int enumlevel = 0;
cmark_node *tmp = node;
while (tmp) {
if (tmp->type == CMARK_NODE_LIST &&
cmark_node_get_list_type(node) == CMARK_ORDERED_LIST) {
enumlevel++;
}
tmp = tmp->parent;
}
return enumlevel;
}
static int S_render_node(cmark_renderer *renderer, cmark_node *node,
cmark_event_type ev_type, int options) {
int list_number;
int enumlevel;
char list_number_string[LIST_NUMBER_STRING_SIZE];
bool entering = (ev_type == CMARK_EVENT_ENTER);
cmark_list_type list_type;
bool allow_wrap = renderer->width > 0 && !(CMARK_OPT_NOBREAKS & options);
if (node->extension && node->extension->latex_render_func) {
node->extension->latex_render_func(node->extension, renderer, node, ev_type, options);
return 1;
}
switch (node->type) {
case CMARK_NODE_DOCUMENT:
break;
case CMARK_NODE_BLOCK_QUOTE:
if (entering) {
LIT("\\begin{quote}");
CR();
} else {
LIT("\\end{quote}");
BLANKLINE();
}
break;
case CMARK_NODE_LIST:
list_type = cmark_node_get_list_type(node);
if (entering) {
LIT("\\begin{");
LIT(list_type == CMARK_ORDERED_LIST ? "enumerate" : "itemize");
LIT("}");
CR();
list_number = cmark_node_get_list_start(node);
if (list_number > 1) {
enumlevel = S_get_enumlevel(node);
// latex normally supports only five levels
if (enumlevel >= 1 && enumlevel <= 5) {
snprintf(list_number_string, LIST_NUMBER_STRING_SIZE, "%d",
list_number);
LIT("\\setcounter{enum");
switch (enumlevel) {
case 1: LIT("i"); break;
case 2: LIT("ii"); break;
case 3: LIT("iii"); break;
case 4: LIT("iv"); break;
case 5: LIT("v"); break;
default: LIT("i"); break;
}
LIT("}{");
OUT(list_number_string, false, NORMAL);
LIT("}");
}
CR();
}
} else {
LIT("\\end{");
LIT(list_type == CMARK_ORDERED_LIST ? "enumerate" : "itemize");
LIT("}");
BLANKLINE();
}
break;
case CMARK_NODE_ITEM:
if (entering) {
LIT("\\item ");
} else {
CR();
}
break;
case CMARK_NODE_HEADING:
if (entering) {
switch (cmark_node_get_heading_level(node)) {
case 1:
LIT("\\section");
break;
case 2:
LIT("\\subsection");
break;
case 3:
LIT("\\subsubsection");
break;
case 4:
LIT("\\paragraph");
break;
case 5:
LIT("\\subparagraph");
break;
}
LIT("{");
} else {
LIT("}");
BLANKLINE();
}
break;
case CMARK_NODE_CODE_BLOCK:
CR();
LIT("\\begin{verbatim}");
CR();
OUT(cmark_node_get_literal(node), false, LITERAL);
CR();
LIT("\\end{verbatim}");
BLANKLINE();
break;
case CMARK_NODE_HTML_BLOCK:
break;
case CMARK_NODE_CUSTOM_BLOCK:
CR();
OUT(entering ? cmark_node_get_on_enter(node) : cmark_node_get_on_exit(node),
false, LITERAL);
CR();
break;
case CMARK_NODE_THEMATIC_BREAK:
BLANKLINE();
LIT("\\begin{center}\\rule{0.5\\linewidth}{\\linethickness}\\end{center}");
BLANKLINE();
break;
case CMARK_NODE_PARAGRAPH:
if (!entering) {
BLANKLINE();
}
break;
case CMARK_NODE_TEXT:
OUT(cmark_node_get_literal(node), allow_wrap, NORMAL);
break;
case CMARK_NODE_LINEBREAK:
LIT("\\\\");
CR();
break;
case CMARK_NODE_SOFTBREAK:
if (options & CMARK_OPT_HARDBREAKS) {
LIT("\\\\");
CR();
} else if (renderer->width == 0 && !(CMARK_OPT_NOBREAKS & options)) {
CR();
} else {
OUT(" ", allow_wrap, NORMAL);
}
break;
case CMARK_NODE_CODE:
LIT("\\texttt{");
OUT(cmark_node_get_literal(node), false, NORMAL);
LIT("}");
break;
case CMARK_NODE_HTML_INLINE:
break;
case CMARK_NODE_CUSTOM_INLINE:
OUT(entering ? cmark_node_get_on_enter(node) : cmark_node_get_on_exit(node),
false, LITERAL);
break;
case CMARK_NODE_STRONG:
if (entering) {
LIT("\\textbf{");
} else {
LIT("}");
}
break;
case CMARK_NODE_EMPH:
if (entering) {
LIT("\\emph{");
} else {
LIT("}");
}
break;
case CMARK_NODE_LINK:
if (entering) {
const char *url = cmark_node_get_url(node);
// requires \usepackage{hyperref}
switch (get_link_type(node)) {
case URL_AUTOLINK:
LIT("\\url{");
OUT(url, false, URL);
LIT("}");
return 0; // Don't process further nodes to avoid double-rendering artefacts
case EMAIL_AUTOLINK:
LIT("\\href{");
OUT(url, false, URL);
LIT("}\\nolinkurl{");
break;
case NORMAL_LINK:
LIT("\\href{");
OUT(url, false, URL);
LIT("}{");
break;
case INTERNAL_LINK:
LIT("\\protect\\hyperlink{");
OUT(url + 1, false, URL);
LIT("}{");
break;
case NO_LINK:
LIT("{"); // error?
}
} else {
LIT("}");
}
break;
case CMARK_NODE_IMAGE:
if (entering) {
LIT("\\protect\\includegraphics{");
// requires \include{graphicx}
OUT(cmark_node_get_url(node), false, URL);
LIT("}");
return 0;
}
break;
case CMARK_NODE_FOOTNOTE_DEFINITION:
case CMARK_NODE_FOOTNOTE_REFERENCE:
// TODO
break;
default:
assert(false);
break;
}
return 1;
}
char *cmark_render_latex(cmark_node *root, int options, int width) {
return cmark_render_latex_with_mem(root, options, width, cmark_node_mem(root));
}
char *cmark_render_latex_with_mem(cmark_node *root, int options, int width, cmark_mem *mem) {
return cmark_render(mem, root, options, width, outc, S_render_node);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/linked_list.c | #include <stdlib.h>
#include "cmark-gfm.h"
cmark_llist *cmark_llist_append(cmark_mem *mem, cmark_llist *head, void *data) {
cmark_llist *tmp;
cmark_llist *new_node = (cmark_llist *) mem->calloc(1, sizeof(cmark_llist));
new_node->data = data;
new_node->next = NULL;
if (!head)
return new_node;
for (tmp = head; tmp->next; tmp=tmp->next);
tmp->next = new_node;
return head;
}
void cmark_llist_free_full(cmark_mem *mem, cmark_llist *head, cmark_free_func free_func) {
cmark_llist *tmp, *prev;
for (tmp = head; tmp;) {
if (free_func)
free_func(mem, tmp->data);
prev = tmp;
tmp = tmp->next;
mem->free(prev);
}
}
void cmark_llist_free(cmark_mem *mem, cmark_llist *head) {
cmark_llist_free_full(mem, head, NULL);
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/scanners.c | /* Generated by re2c 1.1.1 */
#include <stdlib.h>
#include "chunk.h"
#include "scanners.h"
bufsize_t _scan_at(bufsize_t (*scanner)(const unsigned char *), cmark_chunk *c, bufsize_t offset)
{
bufsize_t res;
unsigned char *ptr = (unsigned char *)c->data;
if (ptr == NULL || offset > c->len) {
return 0;
} else {
unsigned char lim = ptr[c->len];
ptr[c->len] = '\0';
res = scanner(ptr + offset);
ptr[c->len] = lim;
}
return res;
}
// Try to match a scheme including colon.
bufsize_t _scan_scheme(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
yych = *p;
if (yych <= '@') goto yy2;
if (yych <= 'Z') goto yy4;
if (yych <= '`') goto yy2;
if (yych <= 'z') goto yy4;
yy2:
++p;
yy3:
{ return 0; }
yy4:
yych = *(marker = ++p);
if (yych <= '/') {
if (yych <= '+') {
if (yych <= '*') goto yy3;
} else {
if (yych <= ',') goto yy3;
if (yych >= '/') goto yy3;
}
} else {
if (yych <= 'Z') {
if (yych <= '9') goto yy5;
if (yych <= '@') goto yy3;
} else {
if (yych <= '`') goto yy3;
if (yych >= '{') goto yy3;
}
}
yy5:
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych == '+') goto yy7;
} else {
if (yych != '/') goto yy7;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych >= 'A') goto yy7;
} else {
if (yych <= '`') goto yy6;
if (yych <= 'z') goto yy7;
}
}
yy6:
p = marker;
goto yy3;
yy7:
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych == '+') goto yy10;
goto yy6;
} else {
if (yych == '/') goto yy6;
goto yy10;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
goto yy10;
} else {
if (yych <= '`') goto yy6;
if (yych <= 'z') goto yy10;
goto yy6;
}
}
yy8:
++p;
{ return (bufsize_t)(p - start); }
yy10:
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy6;
} else {
if (yych == '/') goto yy6;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy8;
if (yych <= '@') goto yy6;
} else {
if (yych <= '`') goto yy6;
if (yych >= '{') goto yy6;
}
}
yych = *++p;
if (yych == ':') goto yy8;
goto yy6;
}
}
// Try to match URI autolink after first <, returning number of chars matched.
bufsize_t _scan_autolink_uri(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 0, 128, 0, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych <= '@') goto yy41;
if (yych <= 'Z') goto yy43;
if (yych <= '`') goto yy41;
if (yych <= 'z') goto yy43;
yy41:
++p;
yy42:
{ return 0; }
yy43:
yych = *(marker = ++p);
if (yych <= '/') {
if (yych <= '+') {
if (yych <= '*') goto yy42;
} else {
if (yych <= ',') goto yy42;
if (yych >= '/') goto yy42;
}
} else {
if (yych <= 'Z') {
if (yych <= '9') goto yy44;
if (yych <= '@') goto yy42;
} else {
if (yych <= '`') goto yy42;
if (yych >= '{') goto yy42;
}
}
yy44:
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych == '+') goto yy46;
} else {
if (yych != '/') goto yy46;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych >= 'A') goto yy46;
} else {
if (yych <= '`') goto yy45;
if (yych <= 'z') goto yy46;
}
}
yy45:
p = marker;
goto yy42;
yy46:
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych == '+') goto yy49;
goto yy45;
} else {
if (yych == '/') goto yy45;
goto yy49;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
goto yy49;
} else {
if (yych <= '`') goto yy45;
if (yych <= 'z') goto yy49;
goto yy45;
}
}
yy47:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy47;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '<') goto yy45;
if (yych <= '>') goto yy50;
goto yy45;
} else {
if (yych <= 0xDF) goto yy52;
if (yych <= 0xE0) goto yy53;
goto yy54;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy55;
if (yych <= 0xEF) goto yy54;
goto yy56;
} else {
if (yych <= 0xF3) goto yy57;
if (yych <= 0xF4) goto yy58;
goto yy45;
}
}
yy49:
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych == '+') goto yy59;
goto yy45;
} else {
if (yych == '/') goto yy45;
goto yy59;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
goto yy59;
} else {
if (yych <= '`') goto yy45;
if (yych <= 'z') goto yy59;
goto yy45;
}
}
yy50:
++p;
{ return (bufsize_t)(p - start); }
yy52:
yych = *++p;
if (yych <= 0x7F) goto yy45;
if (yych <= 0xBF) goto yy47;
goto yy45;
yy53:
yych = *++p;
if (yych <= 0x9F) goto yy45;
if (yych <= 0xBF) goto yy52;
goto yy45;
yy54:
yych = *++p;
if (yych <= 0x7F) goto yy45;
if (yych <= 0xBF) goto yy52;
goto yy45;
yy55:
yych = *++p;
if (yych <= 0x7F) goto yy45;
if (yych <= 0x9F) goto yy52;
goto yy45;
yy56:
yych = *++p;
if (yych <= 0x8F) goto yy45;
if (yych <= 0xBF) goto yy54;
goto yy45;
yy57:
yych = *++p;
if (yych <= 0x7F) goto yy45;
if (yych <= 0xBF) goto yy54;
goto yy45;
yy58:
yych = *++p;
if (yych <= 0x7F) goto yy45;
if (yych <= 0x8F) goto yy54;
goto yy45;
yy59:
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych <= '9') {
if (yych <= ',') {
if (yych != '+') goto yy45;
} else {
if (yych == '/') goto yy45;
}
} else {
if (yych <= 'Z') {
if (yych <= ':') goto yy47;
if (yych <= '@') goto yy45;
} else {
if (yych <= '`') goto yy45;
if (yych >= '{') goto yy45;
}
}
yych = *++p;
if (yych == ':') goto yy47;
goto yy45;
}
}
// Try to match email autolink after first <, returning num of chars matched.
bufsize_t _scan_autolink_email(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 128, 0, 128, 128, 128, 128, 128,
0, 0, 128, 128, 0, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 0, 0, 0, 128, 0, 128,
0, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 0, 0, 0, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych <= '9') {
if (yych <= '\'') {
if (yych == '!') goto yy91;
if (yych >= '#') goto yy91;
} else {
if (yych <= ')') goto yy89;
if (yych != ',') goto yy91;
}
} else {
if (yych <= '?') {
if (yych == '=') goto yy91;
if (yych >= '?') goto yy91;
} else {
if (yych <= 'Z') {
if (yych >= 'A') goto yy91;
} else {
if (yych <= ']') goto yy89;
if (yych <= '~') goto yy91;
}
}
}
yy89:
++p;
yy90:
{ return 0; }
yy91:
yych = *(marker = ++p);
if (yych <= ',') {
if (yych <= '"') {
if (yych == '!') goto yy93;
goto yy90;
} else {
if (yych <= '\'') goto yy93;
if (yych <= ')') goto yy90;
if (yych <= '+') goto yy93;
goto yy90;
}
} else {
if (yych <= '>') {
if (yych <= '9') goto yy93;
if (yych == '=') goto yy93;
goto yy90;
} else {
if (yych <= 'Z') goto yy93;
if (yych <= ']') goto yy90;
if (yych <= '~') goto yy93;
goto yy90;
}
}
yy92:
yych = *++p;
yy93:
if (yybm[0+yych] & 128) {
goto yy92;
}
if (yych <= '>') goto yy94;
if (yych <= '@') goto yy95;
yy94:
p = marker;
goto yy90;
yy95:
yych = *++p;
if (yych <= '@') {
if (yych <= '/') goto yy94;
if (yych >= ':') goto yy94;
} else {
if (yych <= 'Z') goto yy96;
if (yych <= '`') goto yy94;
if (yych >= '{') goto yy94;
}
yy96:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy98;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy98;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy98;
goto yy94;
}
}
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy101;
if (yych <= '/') goto yy94;
goto yy102;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy102;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy102;
goto yy94;
}
}
yy98:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych <= '-') goto yy101;
goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy102;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy102;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy102;
goto yy94;
}
}
yy99:
++p;
{ return (bufsize_t)(p - start); }
yy101:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy103;
if (yych <= '/') goto yy94;
goto yy104;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy104;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy104;
goto yy94;
}
}
yy102:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy104;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy104;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy104;
goto yy94;
}
}
yy103:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy105;
if (yych <= '/') goto yy94;
goto yy106;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy106;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy106;
goto yy94;
}
}
yy104:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy106;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy106;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy106;
goto yy94;
}
}
yy105:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy107;
if (yych <= '/') goto yy94;
goto yy108;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy108;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy108;
goto yy94;
}
}
yy106:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy108;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy108;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy108;
goto yy94;
}
}
yy107:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy109;
if (yych <= '/') goto yy94;
goto yy110;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy110;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy110;
goto yy94;
}
}
yy108:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy110;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy110;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy110;
goto yy94;
}
}
yy109:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy111;
if (yych <= '/') goto yy94;
goto yy112;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy112;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy112;
goto yy94;
}
}
yy110:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy112;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy112;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy112;
goto yy94;
}
}
yy111:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy113;
if (yych <= '/') goto yy94;
goto yy114;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy114;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy114;
goto yy94;
}
}
yy112:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy114;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy114;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy114;
goto yy94;
}
}
yy113:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy115;
if (yych <= '/') goto yy94;
goto yy116;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy116;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy116;
goto yy94;
}
}
yy114:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy116;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy116;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy116;
goto yy94;
}
}
yy115:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy117;
if (yych <= '/') goto yy94;
goto yy118;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy118;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy118;
goto yy94;
}
}
yy116:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy118;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy118;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy118;
goto yy94;
}
}
yy117:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy119;
if (yych <= '/') goto yy94;
goto yy120;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy120;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy120;
goto yy94;
}
}
yy118:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy120;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy120;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy120;
goto yy94;
}
}
yy119:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy121;
if (yych <= '/') goto yy94;
goto yy122;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy122;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy122;
goto yy94;
}
}
yy120:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy122;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy122;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy122;
goto yy94;
}
}
yy121:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy123;
if (yych <= '/') goto yy94;
goto yy124;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy124;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy124;
goto yy94;
}
}
yy122:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy124;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy124;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy124;
goto yy94;
}
}
yy123:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy125;
if (yych <= '/') goto yy94;
goto yy126;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy126;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy126;
goto yy94;
}
}
yy124:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy126;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy126;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy126;
goto yy94;
}
}
yy125:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy127;
if (yych <= '/') goto yy94;
goto yy128;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy128;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy128;
goto yy94;
}
}
yy126:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy128;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy128;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy128;
goto yy94;
}
}
yy127:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy129;
if (yych <= '/') goto yy94;
goto yy130;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy130;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy130;
goto yy94;
}
}
yy128:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy130;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy130;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy130;
goto yy94;
}
}
yy129:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy131;
if (yych <= '/') goto yy94;
goto yy132;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy132;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy132;
goto yy94;
}
}
yy130:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy132;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy132;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy132;
goto yy94;
}
}
yy131:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy133;
if (yych <= '/') goto yy94;
goto yy134;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy134;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy134;
goto yy94;
}
}
yy132:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy134;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy134;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy134;
goto yy94;
}
}
yy133:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy135;
if (yych <= '/') goto yy94;
goto yy136;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy136;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy136;
goto yy94;
}
}
yy134:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy136;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy136;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy136;
goto yy94;
}
}
yy135:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy137;
if (yych <= '/') goto yy94;
goto yy138;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy138;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy138;
goto yy94;
}
}
yy136:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy138;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy138;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy138;
goto yy94;
}
}
yy137:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy139;
if (yych <= '/') goto yy94;
goto yy140;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy140;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy140;
goto yy94;
}
}
yy138:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy140;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy140;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy140;
goto yy94;
}
}
yy139:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy141;
if (yych <= '/') goto yy94;
goto yy142;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy142;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy142;
goto yy94;
}
}
yy140:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy142;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy142;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy142;
goto yy94;
}
}
yy141:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy143;
if (yych <= '/') goto yy94;
goto yy144;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy144;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy144;
goto yy94;
}
}
yy142:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy144;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy144;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy144;
goto yy94;
}
}
yy143:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy145;
if (yych <= '/') goto yy94;
goto yy146;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy146;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy146;
goto yy94;
}
}
yy144:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy146;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy146;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy146;
goto yy94;
}
}
yy145:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy147;
if (yych <= '/') goto yy94;
goto yy148;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy148;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy148;
goto yy94;
}
}
yy146:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy148;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy148;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy148;
goto yy94;
}
}
yy147:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy149;
if (yych <= '/') goto yy94;
goto yy150;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy150;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy150;
goto yy94;
}
}
yy148:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy150;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy150;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy150;
goto yy94;
}
}
yy149:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy151;
if (yych <= '/') goto yy94;
goto yy152;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy152;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy152;
goto yy94;
}
}
yy150:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy152;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy152;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy152;
goto yy94;
}
}
yy151:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy153;
if (yych <= '/') goto yy94;
goto yy154;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy154;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy154;
goto yy94;
}
}
yy152:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy154;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy154;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy154;
goto yy94;
}
}
yy153:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy155;
if (yych <= '/') goto yy94;
goto yy156;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy156;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy156;
goto yy94;
}
}
yy154:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy156;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy156;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy156;
goto yy94;
}
}
yy155:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy157;
if (yych <= '/') goto yy94;
goto yy158;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy158;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy158;
goto yy94;
}
}
yy156:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy158;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy158;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy158;
goto yy94;
}
}
yy157:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy159;
if (yych <= '/') goto yy94;
goto yy160;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy160;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy160;
goto yy94;
}
}
yy158:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy160;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy160;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy160;
goto yy94;
}
}
yy159:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy161;
if (yych <= '/') goto yy94;
goto yy162;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy162;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy162;
goto yy94;
}
}
yy160:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy162;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy162;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy162;
goto yy94;
}
}
yy161:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy163;
if (yych <= '/') goto yy94;
goto yy164;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy164;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy164;
goto yy94;
}
}
yy162:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy164;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy164;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy164;
goto yy94;
}
}
yy163:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy165;
if (yych <= '/') goto yy94;
goto yy166;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy166;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy166;
goto yy94;
}
}
yy164:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy166;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy166;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy166;
goto yy94;
}
}
yy165:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy167;
if (yych <= '/') goto yy94;
goto yy168;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy168;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy168;
goto yy94;
}
}
yy166:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy168;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy168;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy168;
goto yy94;
}
}
yy167:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy169;
if (yych <= '/') goto yy94;
goto yy170;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy170;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy170;
goto yy94;
}
}
yy168:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy170;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy170;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy170;
goto yy94;
}
}
yy169:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy171;
if (yych <= '/') goto yy94;
goto yy172;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy172;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy172;
goto yy94;
}
}
yy170:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy172;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy172;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy172;
goto yy94;
}
}
yy171:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy173;
if (yych <= '/') goto yy94;
goto yy174;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy174;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy174;
goto yy94;
}
}
yy172:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy174;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy174;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy174;
goto yy94;
}
}
yy173:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy175;
if (yych <= '/') goto yy94;
goto yy176;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy176;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy176;
goto yy94;
}
}
yy174:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy176;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy176;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy176;
goto yy94;
}
}
yy175:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy177;
if (yych <= '/') goto yy94;
goto yy178;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy178;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy178;
goto yy94;
}
}
yy176:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy178;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy178;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy178;
goto yy94;
}
}
yy177:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy179;
if (yych <= '/') goto yy94;
goto yy180;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy180;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy180;
goto yy94;
}
}
yy178:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy180;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy180;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy180;
goto yy94;
}
}
yy179:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy181;
if (yych <= '/') goto yy94;
goto yy182;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy182;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy182;
goto yy94;
}
}
yy180:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy182;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy182;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy182;
goto yy94;
}
}
yy181:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy183;
if (yych <= '/') goto yy94;
goto yy184;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy184;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy184;
goto yy94;
}
}
yy182:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy184;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy184;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy184;
goto yy94;
}
}
yy183:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy185;
if (yych <= '/') goto yy94;
goto yy186;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy186;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy186;
goto yy94;
}
}
yy184:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy186;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy186;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy186;
goto yy94;
}
}
yy185:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy187;
if (yych <= '/') goto yy94;
goto yy188;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy188;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy188;
goto yy94;
}
}
yy186:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy188;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy188;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy188;
goto yy94;
}
}
yy187:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy189;
if (yych <= '/') goto yy94;
goto yy190;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy190;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy190;
goto yy94;
}
}
yy188:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy190;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy190;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy190;
goto yy94;
}
}
yy189:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy191;
if (yych <= '/') goto yy94;
goto yy192;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy192;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy192;
goto yy94;
}
}
yy190:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy192;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy192;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy192;
goto yy94;
}
}
yy191:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy193;
if (yych <= '/') goto yy94;
goto yy194;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy194;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy194;
goto yy94;
}
}
yy192:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy194;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy194;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy194;
goto yy94;
}
}
yy193:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy195;
if (yych <= '/') goto yy94;
goto yy196;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy196;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy196;
goto yy94;
}
}
yy194:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy196;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy196;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy196;
goto yy94;
}
}
yy195:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy197;
if (yych <= '/') goto yy94;
goto yy198;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy198;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy198;
goto yy94;
}
}
yy196:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy198;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy198;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy198;
goto yy94;
}
}
yy197:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy199;
if (yych <= '/') goto yy94;
goto yy200;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy200;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy200;
goto yy94;
}
}
yy198:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy200;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy200;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy200;
goto yy94;
}
}
yy199:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy201;
if (yych <= '/') goto yy94;
goto yy202;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy202;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy202;
goto yy94;
}
}
yy200:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy202;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy202;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy202;
goto yy94;
}
}
yy201:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy203;
if (yych <= '/') goto yy94;
goto yy204;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy204;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy204;
goto yy94;
}
}
yy202:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy204;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy204;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy204;
goto yy94;
}
}
yy203:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy205;
if (yych <= '/') goto yy94;
goto yy206;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy206;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy206;
goto yy94;
}
}
yy204:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy206;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy206;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy206;
goto yy94;
}
}
yy205:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy207;
if (yych <= '/') goto yy94;
goto yy208;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy208;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy208;
goto yy94;
}
}
yy206:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy208;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy208;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy208;
goto yy94;
}
}
yy207:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy209;
if (yych <= '/') goto yy94;
goto yy210;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy210;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy210;
goto yy94;
}
}
yy208:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy210;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy210;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy210;
goto yy94;
}
}
yy209:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy211;
if (yych <= '/') goto yy94;
goto yy212;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy212;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy212;
goto yy94;
}
}
yy210:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy212;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy212;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy212;
goto yy94;
}
}
yy211:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy213;
if (yych <= '/') goto yy94;
goto yy214;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy214;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy214;
goto yy94;
}
}
yy212:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy214;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy214;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy214;
goto yy94;
}
}
yy213:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy215;
if (yych <= '/') goto yy94;
goto yy216;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy216;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy216;
goto yy94;
}
}
yy214:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy216;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy216;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy216;
goto yy94;
}
}
yy215:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy217;
if (yych <= '/') goto yy94;
goto yy218;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy218;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy218;
goto yy94;
}
}
yy216:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy218;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy218;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy218;
goto yy94;
}
}
yy217:
yych = *++p;
if (yych <= '9') {
if (yych == '-') goto yy219;
if (yych <= '/') goto yy94;
goto yy220;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy94;
goto yy220;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy220;
goto yy94;
}
}
yy218:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= ',') goto yy94;
if (yych >= '.') goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy220;
goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
goto yy220;
} else {
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy220;
goto yy94;
}
}
yy219:
yych = *++p;
if (yych <= '@') {
if (yych <= '/') goto yy94;
if (yych <= '9') goto yy221;
goto yy94;
} else {
if (yych <= 'Z') goto yy221;
if (yych <= '`') goto yy94;
if (yych <= 'z') goto yy221;
goto yy94;
}
yy220:
yych = *++p;
if (yych <= '=') {
if (yych <= '.') {
if (yych <= '-') goto yy94;
goto yy95;
} else {
if (yych <= '/') goto yy94;
if (yych >= ':') goto yy94;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy99;
if (yych <= '@') goto yy94;
} else {
if (yych <= '`') goto yy94;
if (yych >= '{') goto yy94;
}
}
yy221:
yych = *++p;
if (yych == '.') goto yy95;
if (yych == '>') goto yy99;
goto yy94;
}
}
// Try to match an HTML tag after first <, returning num of chars matched.
bufsize_t _scan_html_tag(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
static const unsigned char yybm[] = {
/* table 1 .. 8: 0 */
0, 250, 250, 250, 250, 250, 250, 250,
250, 235, 235, 235, 235, 235, 250, 250,
250, 250, 250, 250, 250, 250, 250, 250,
250, 250, 250, 250, 250, 250, 250, 250,
235, 250, 202, 250, 250, 250, 250, 170,
250, 250, 250, 250, 250, 246, 254, 250,
254, 254, 254, 254, 254, 254, 254, 254,
254, 254, 254, 250, 234, 234, 232, 250,
250, 254, 254, 254, 254, 254, 254, 254,
254, 254, 254, 254, 254, 254, 254, 254,
254, 254, 254, 254, 254, 254, 254, 254,
254, 254, 254, 250, 250, 122, 250, 254,
234, 254, 254, 254, 254, 254, 254, 254,
254, 254, 254, 254, 254, 254, 254, 254,
254, 254, 254, 254, 254, 254, 254, 254,
254, 254, 254, 250, 250, 250, 250, 250,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
/* table 9 .. 11: 256 */
0, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 192, 128, 128,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 128, 128, 128, 128, 128, 0,
128, 224, 224, 224, 224, 224, 224, 224,
224, 224, 224, 224, 224, 224, 224, 224,
224, 224, 224, 224, 224, 224, 224, 224,
224, 224, 224, 128, 128, 128, 128, 128,
128, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 128, 128, 128, 128, 128,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych <= '>') {
if (yych <= '!') {
if (yych >= '!') goto yy226;
} else {
if (yych == '/') goto yy227;
}
} else {
if (yych <= 'Z') {
if (yych <= '?') goto yy228;
if (yych >= 'A') goto yy229;
} else {
if (yych <= '`') goto yy224;
if (yych <= 'z') goto yy229;
}
}
yy224:
++p;
yy225:
{ return 0; }
yy226:
yych = *(marker = ++p);
if (yybm[256+yych] & 32) {
goto yy232;
}
if (yych == '-') goto yy230;
if (yych <= '@') goto yy225;
if (yych <= '[') goto yy234;
goto yy225;
yy227:
yych = *(marker = ++p);
if (yych <= '@') goto yy225;
if (yych <= 'Z') goto yy235;
if (yych <= '`') goto yy225;
if (yych <= 'z') goto yy235;
goto yy225;
yy228:
yych = *(marker = ++p);
if (yych <= 0x00) goto yy225;
if (yych <= 0x7F) goto yy238;
if (yych <= 0xC1) goto yy225;
if (yych <= 0xF4) goto yy238;
goto yy225;
yy229:
yych = *(marker = ++p);
if (yych <= '.') {
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy225;
if (yych <= '\r') goto yy250;
goto yy225;
} else {
if (yych <= ' ') goto yy250;
if (yych == '-') goto yy250;
goto yy225;
}
} else {
if (yych <= '@') {
if (yych <= '9') goto yy250;
if (yych == '>') goto yy250;
goto yy225;
} else {
if (yych <= 'Z') goto yy250;
if (yych <= '`') goto yy225;
if (yych <= 'z') goto yy250;
goto yy225;
}
}
yy230:
yych = *++p;
if (yych == '-') goto yy254;
yy231:
p = marker;
goto yy225;
yy232:
yych = *++p;
if (yybm[256+yych] & 32) {
goto yy232;
}
if (yych <= 0x08) goto yy231;
if (yych <= '\r') goto yy255;
if (yych == ' ') goto yy255;
goto yy231;
yy234:
yych = *++p;
if (yych == 'C') goto yy257;
if (yych == 'c') goto yy257;
goto yy231;
yy235:
yych = *++p;
if (yybm[256+yych] & 64) {
goto yy235;
}
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy231;
if (yych <= '\r') goto yy258;
goto yy231;
} else {
if (yych <= ' ') goto yy258;
if (yych == '>') goto yy252;
goto yy231;
}
yy237:
yych = *++p;
yy238:
if (yybm[256+yych] & 128) {
goto yy237;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= 0x00) goto yy231;
if (yych >= '@') goto yy231;
} else {
if (yych <= 0xDF) goto yy240;
if (yych <= 0xE0) goto yy241;
goto yy242;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy243;
if (yych <= 0xEF) goto yy242;
goto yy244;
} else {
if (yych <= 0xF3) goto yy245;
if (yych <= 0xF4) goto yy246;
goto yy231;
}
}
yych = *++p;
if (yych <= 0xE0) {
if (yych <= '>') {
if (yych <= 0x00) goto yy231;
if (yych <= '=') goto yy237;
goto yy252;
} else {
if (yych <= 0x7F) goto yy237;
if (yych <= 0xC1) goto yy231;
if (yych >= 0xE0) goto yy241;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy243;
goto yy242;
} else {
if (yych <= 0xF0) goto yy244;
if (yych <= 0xF3) goto yy245;
if (yych <= 0xF4) goto yy246;
goto yy231;
}
}
yy240:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy237;
goto yy231;
yy241:
yych = *++p;
if (yych <= 0x9F) goto yy231;
if (yych <= 0xBF) goto yy240;
goto yy231;
yy242:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy240;
goto yy231;
yy243:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0x9F) goto yy240;
goto yy231;
yy244:
yych = *++p;
if (yych <= 0x8F) goto yy231;
if (yych <= 0xBF) goto yy242;
goto yy231;
yy245:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy242;
goto yy231;
yy246:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0x8F) goto yy242;
goto yy231;
yy247:
yych = *++p;
if (yybm[0+yych] & 1) {
goto yy247;
}
if (yych <= '>') {
if (yych <= '9') {
if (yych == '/') goto yy251;
goto yy231;
} else {
if (yych <= ':') goto yy260;
if (yych <= '=') goto yy231;
goto yy252;
}
} else {
if (yych <= '^') {
if (yych <= '@') goto yy231;
if (yych <= 'Z') goto yy260;
goto yy231;
} else {
if (yych == '`') goto yy231;
if (yych <= 'z') goto yy260;
goto yy231;
}
}
yy249:
yych = *++p;
yy250:
if (yybm[0+yych] & 1) {
goto yy247;
}
if (yych <= '=') {
if (yych <= '.') {
if (yych == '-') goto yy249;
goto yy231;
} else {
if (yych <= '/') goto yy251;
if (yych <= '9') goto yy249;
goto yy231;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy252;
if (yych <= '@') goto yy231;
goto yy249;
} else {
if (yych <= '`') goto yy231;
if (yych <= 'z') goto yy249;
goto yy231;
}
}
yy251:
yych = *++p;
if (yych != '>') goto yy231;
yy252:
++p;
{ return (bufsize_t)(p - start); }
yy254:
yych = *++p;
if (yych == '-') goto yy264;
if (yych == '>') goto yy231;
goto yy263;
yy255:
yych = *++p;
if (yybm[0+yych] & 2) {
goto yy255;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= 0x00) goto yy231;
if (yych <= '>') goto yy252;
goto yy231;
} else {
if (yych <= 0xDF) goto yy272;
if (yych <= 0xE0) goto yy273;
goto yy274;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy275;
if (yych <= 0xEF) goto yy274;
goto yy276;
} else {
if (yych <= 0xF3) goto yy277;
if (yych <= 0xF4) goto yy278;
goto yy231;
}
}
yy257:
yych = *++p;
if (yych == 'D') goto yy279;
if (yych == 'd') goto yy279;
goto yy231;
yy258:
yych = *++p;
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy231;
if (yych <= '\r') goto yy258;
goto yy231;
} else {
if (yych <= ' ') goto yy258;
if (yych == '>') goto yy252;
goto yy231;
}
yy260:
yych = *++p;
if (yybm[0+yych] & 4) {
goto yy260;
}
if (yych <= ',') {
if (yych <= '\r') {
if (yych <= 0x08) goto yy231;
goto yy280;
} else {
if (yych == ' ') goto yy280;
goto yy231;
}
} else {
if (yych <= '<') {
if (yych <= '/') goto yy251;
goto yy231;
} else {
if (yych <= '=') goto yy282;
if (yych <= '>') goto yy252;
goto yy231;
}
}
yy262:
yych = *++p;
yy263:
if (yybm[0+yych] & 8) {
goto yy262;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= 0x00) goto yy231;
if (yych <= '-') goto yy284;
goto yy231;
} else {
if (yych <= 0xDF) goto yy265;
if (yych <= 0xE0) goto yy266;
goto yy267;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy268;
if (yych <= 0xEF) goto yy267;
goto yy269;
} else {
if (yych <= 0xF3) goto yy270;
if (yych <= 0xF4) goto yy271;
goto yy231;
}
}
yy264:
yych = *++p;
if (yych == '-') goto yy251;
if (yych == '>') goto yy231;
goto yy263;
yy265:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy262;
goto yy231;
yy266:
yych = *++p;
if (yych <= 0x9F) goto yy231;
if (yych <= 0xBF) goto yy265;
goto yy231;
yy267:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy265;
goto yy231;
yy268:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0x9F) goto yy265;
goto yy231;
yy269:
yych = *++p;
if (yych <= 0x8F) goto yy231;
if (yych <= 0xBF) goto yy267;
goto yy231;
yy270:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy267;
goto yy231;
yy271:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0x8F) goto yy267;
goto yy231;
yy272:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy255;
goto yy231;
yy273:
yych = *++p;
if (yych <= 0x9F) goto yy231;
if (yych <= 0xBF) goto yy272;
goto yy231;
yy274:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy272;
goto yy231;
yy275:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0x9F) goto yy272;
goto yy231;
yy276:
yych = *++p;
if (yych <= 0x8F) goto yy231;
if (yych <= 0xBF) goto yy274;
goto yy231;
yy277:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy274;
goto yy231;
yy278:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0x8F) goto yy274;
goto yy231;
yy279:
yych = *++p;
if (yych == 'A') goto yy285;
if (yych == 'a') goto yy285;
goto yy231;
yy280:
yych = *++p;
if (yych <= '<') {
if (yych <= ' ') {
if (yych <= 0x08) goto yy231;
if (yych <= '\r') goto yy280;
if (yych <= 0x1F) goto yy231;
goto yy280;
} else {
if (yych <= '/') {
if (yych <= '.') goto yy231;
goto yy251;
} else {
if (yych == ':') goto yy260;
goto yy231;
}
}
} else {
if (yych <= 'Z') {
if (yych <= '=') goto yy282;
if (yych <= '>') goto yy252;
if (yych <= '@') goto yy231;
goto yy260;
} else {
if (yych <= '_') {
if (yych <= '^') goto yy231;
goto yy260;
} else {
if (yych <= '`') goto yy231;
if (yych <= 'z') goto yy260;
goto yy231;
}
}
}
yy282:
yych = *++p;
if (yybm[0+yych] & 16) {
goto yy286;
}
if (yych <= 0xE0) {
if (yych <= '"') {
if (yych <= 0x00) goto yy231;
if (yych <= ' ') goto yy282;
goto yy288;
} else {
if (yych <= '\'') goto yy290;
if (yych <= 0xC1) goto yy231;
if (yych <= 0xDF) goto yy292;
goto yy293;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy295;
goto yy294;
} else {
if (yych <= 0xF0) goto yy296;
if (yych <= 0xF3) goto yy297;
if (yych <= 0xF4) goto yy298;
goto yy231;
}
}
yy284:
yych = *++p;
if (yybm[0+yych] & 8) {
goto yy262;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= 0x00) goto yy231;
if (yych <= '-') goto yy251;
goto yy231;
} else {
if (yych <= 0xDF) goto yy265;
if (yych <= 0xE0) goto yy266;
goto yy267;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy268;
if (yych <= 0xEF) goto yy267;
goto yy269;
} else {
if (yych <= 0xF3) goto yy270;
if (yych <= 0xF4) goto yy271;
goto yy231;
}
}
yy285:
yych = *++p;
if (yych == 'T') goto yy299;
if (yych == 't') goto yy299;
goto yy231;
yy286:
yych = *++p;
if (yybm[0+yych] & 16) {
goto yy286;
}
if (yych <= 0xE0) {
if (yych <= '=') {
if (yych <= 0x00) goto yy231;
if (yych <= ' ') goto yy247;
goto yy231;
} else {
if (yych <= '>') goto yy252;
if (yych <= 0xC1) goto yy231;
if (yych <= 0xDF) goto yy292;
goto yy293;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy295;
goto yy294;
} else {
if (yych <= 0xF0) goto yy296;
if (yych <= 0xF3) goto yy297;
if (yych <= 0xF4) goto yy298;
goto yy231;
}
}
yy288:
yych = *++p;
if (yybm[0+yych] & 32) {
goto yy288;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= 0x00) goto yy231;
if (yych <= '"') goto yy300;
goto yy231;
} else {
if (yych <= 0xDF) goto yy301;
if (yych <= 0xE0) goto yy302;
goto yy303;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy304;
if (yych <= 0xEF) goto yy303;
goto yy305;
} else {
if (yych <= 0xF3) goto yy306;
if (yych <= 0xF4) goto yy307;
goto yy231;
}
}
yy290:
yych = *++p;
if (yybm[0+yych] & 64) {
goto yy290;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= 0x00) goto yy231;
if (yych <= '\'') goto yy300;
goto yy231;
} else {
if (yych <= 0xDF) goto yy308;
if (yych <= 0xE0) goto yy309;
goto yy310;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy311;
if (yych <= 0xEF) goto yy310;
goto yy312;
} else {
if (yych <= 0xF3) goto yy313;
if (yych <= 0xF4) goto yy314;
goto yy231;
}
}
yy292:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy286;
goto yy231;
yy293:
yych = *++p;
if (yych <= 0x9F) goto yy231;
if (yych <= 0xBF) goto yy292;
goto yy231;
yy294:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy292;
goto yy231;
yy295:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0x9F) goto yy292;
goto yy231;
yy296:
yych = *++p;
if (yych <= 0x8F) goto yy231;
if (yych <= 0xBF) goto yy294;
goto yy231;
yy297:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy294;
goto yy231;
yy298:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0x8F) goto yy294;
goto yy231;
yy299:
yych = *++p;
if (yych == 'A') goto yy315;
if (yych == 'a') goto yy315;
goto yy231;
yy300:
yych = *++p;
if (yybm[0+yych] & 1) {
goto yy247;
}
if (yych == '/') goto yy251;
if (yych == '>') goto yy252;
goto yy231;
yy301:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy288;
goto yy231;
yy302:
yych = *++p;
if (yych <= 0x9F) goto yy231;
if (yych <= 0xBF) goto yy301;
goto yy231;
yy303:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy301;
goto yy231;
yy304:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0x9F) goto yy301;
goto yy231;
yy305:
yych = *++p;
if (yych <= 0x8F) goto yy231;
if (yych <= 0xBF) goto yy303;
goto yy231;
yy306:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy303;
goto yy231;
yy307:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0x8F) goto yy303;
goto yy231;
yy308:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy290;
goto yy231;
yy309:
yych = *++p;
if (yych <= 0x9F) goto yy231;
if (yych <= 0xBF) goto yy308;
goto yy231;
yy310:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy308;
goto yy231;
yy311:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0x9F) goto yy308;
goto yy231;
yy312:
yych = *++p;
if (yych <= 0x8F) goto yy231;
if (yych <= 0xBF) goto yy310;
goto yy231;
yy313:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy310;
goto yy231;
yy314:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0x8F) goto yy310;
goto yy231;
yy315:
yych = *++p;
if (yych != '[') goto yy231;
yy316:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy316;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= 0x00) goto yy231;
if (yych >= '^') goto yy231;
} else {
if (yych <= 0xDF) goto yy319;
if (yych <= 0xE0) goto yy320;
goto yy321;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy322;
if (yych <= 0xEF) goto yy321;
goto yy323;
} else {
if (yych <= 0xF3) goto yy324;
if (yych <= 0xF4) goto yy325;
goto yy231;
}
}
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy316;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= 0x00) goto yy231;
if (yych <= ']') goto yy326;
goto yy231;
} else {
if (yych <= 0xDF) goto yy319;
if (yych <= 0xE0) goto yy320;
goto yy321;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy322;
if (yych <= 0xEF) goto yy321;
goto yy323;
} else {
if (yych <= 0xF3) goto yy324;
if (yych <= 0xF4) goto yy325;
goto yy231;
}
}
yy319:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy316;
goto yy231;
yy320:
yych = *++p;
if (yych <= 0x9F) goto yy231;
if (yych <= 0xBF) goto yy319;
goto yy231;
yy321:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy319;
goto yy231;
yy322:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0x9F) goto yy319;
goto yy231;
yy323:
yych = *++p;
if (yych <= 0x8F) goto yy231;
if (yych <= 0xBF) goto yy321;
goto yy231;
yy324:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0xBF) goto yy321;
goto yy231;
yy325:
yych = *++p;
if (yych <= 0x7F) goto yy231;
if (yych <= 0x8F) goto yy321;
goto yy231;
yy326:
yych = *++p;
if (yych <= 0xE0) {
if (yych <= '>') {
if (yych <= 0x00) goto yy231;
if (yych <= '=') goto yy316;
goto yy252;
} else {
if (yych <= 0x7F) goto yy316;
if (yych <= 0xC1) goto yy231;
if (yych <= 0xDF) goto yy319;
goto yy320;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy322;
goto yy321;
} else {
if (yych <= 0xF0) goto yy323;
if (yych <= 0xF3) goto yy324;
if (yych <= 0xF4) goto yy325;
goto yy231;
}
}
}
}
// Try to (liberally) match an HTML tag after first <, returning num of chars matched.
bufsize_t _scan_liberal_html_tag(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
unsigned int yyaccept = 0;
static const unsigned char yybm[] = {
0, 64, 64, 64, 64, 64, 64, 64,
64, 64, 0, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 128, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych <= 0xE0) {
if (yych <= '\n') {
if (yych <= 0x00) goto yy329;
if (yych <= '\t') goto yy331;
} else {
if (yych <= 0x7F) goto yy331;
if (yych <= 0xC1) goto yy329;
if (yych <= 0xDF) goto yy332;
goto yy333;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy335;
goto yy334;
} else {
if (yych <= 0xF0) goto yy336;
if (yych <= 0xF3) goto yy337;
if (yych <= 0xF4) goto yy338;
}
}
yy329:
++p;
yy330:
{ return 0; }
yy331:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= '\n') {
if (yych <= 0x00) goto yy330;
if (yych <= '\t') goto yy340;
goto yy330;
} else {
if (yych <= 0x7F) goto yy340;
if (yych <= 0xC1) goto yy330;
if (yych <= 0xF4) goto yy340;
goto yy330;
}
yy332:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy330;
if (yych <= 0xBF) goto yy339;
goto yy330;
yy333:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x9F) goto yy330;
if (yych <= 0xBF) goto yy345;
goto yy330;
yy334:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy330;
if (yych <= 0xBF) goto yy345;
goto yy330;
yy335:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy330;
if (yych <= 0x9F) goto yy345;
goto yy330;
yy336:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x8F) goto yy330;
if (yych <= 0xBF) goto yy347;
goto yy330;
yy337:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy330;
if (yych <= 0xBF) goto yy347;
goto yy330;
yy338:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy330;
if (yych <= 0x8F) goto yy347;
goto yy330;
yy339:
yych = *++p;
yy340:
if (yybm[0+yych] & 64) {
goto yy339;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\n') goto yy341;
if (yych <= '>') goto yy342;
} else {
if (yych <= 0xDF) goto yy345;
if (yych <= 0xE0) goto yy346;
goto yy347;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy348;
if (yych <= 0xEF) goto yy347;
goto yy349;
} else {
if (yych <= 0xF3) goto yy350;
if (yych <= 0xF4) goto yy351;
}
}
yy341:
p = marker;
if (yyaccept == 0) {
goto yy330;
} else {
goto yy344;
}
yy342:
yyaccept = 1;
yych = *(marker = ++p);
if (yybm[0+yych] & 64) {
goto yy339;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\n') goto yy344;
if (yych <= '>') goto yy342;
} else {
if (yych <= 0xDF) goto yy345;
if (yych <= 0xE0) goto yy346;
goto yy347;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy348;
if (yych <= 0xEF) goto yy347;
goto yy349;
} else {
if (yych <= 0xF3) goto yy350;
if (yych <= 0xF4) goto yy351;
}
}
yy344:
{ return (bufsize_t)(p - start); }
yy345:
yych = *++p;
if (yych <= 0x7F) goto yy341;
if (yych <= 0xBF) goto yy339;
goto yy341;
yy346:
yych = *++p;
if (yych <= 0x9F) goto yy341;
if (yych <= 0xBF) goto yy345;
goto yy341;
yy347:
yych = *++p;
if (yych <= 0x7F) goto yy341;
if (yych <= 0xBF) goto yy345;
goto yy341;
yy348:
yych = *++p;
if (yych <= 0x7F) goto yy341;
if (yych <= 0x9F) goto yy345;
goto yy341;
yy349:
yych = *++p;
if (yych <= 0x8F) goto yy341;
if (yych <= 0xBF) goto yy347;
goto yy341;
yy350:
yych = *++p;
if (yych <= 0x7F) goto yy341;
if (yych <= 0xBF) goto yy347;
goto yy341;
yy351:
yych = *++p;
if (yych <= 0x7F) goto yy341;
if (yych <= 0x8F) goto yy347;
goto yy341;
}
}
// Try to match an HTML block tag start line, returning
// an integer code for the type of block (1-6, matching the spec).
// #7 is handled by a separate function, below.
bufsize_t _scan_html_block_start(const unsigned char *p)
{
const unsigned char *marker = NULL;
{
unsigned char yych;
yych = *p;
if (yych == '<') goto yy356;
++p;
yy355:
{ return 0; }
yy356:
yych = *(marker = ++p);
switch (yych) {
case '!': goto yy357;
case '/': goto yy359;
case '?': goto yy360;
case 'A':
case 'a': goto yy362;
case 'B':
case 'b': goto yy363;
case 'C':
case 'c': goto yy364;
case 'D':
case 'd': goto yy365;
case 'F':
case 'f': goto yy366;
case 'H':
case 'h': goto yy367;
case 'I':
case 'i': goto yy368;
case 'L':
case 'l': goto yy369;
case 'M':
case 'm': goto yy370;
case 'N':
case 'n': goto yy371;
case 'O':
case 'o': goto yy372;
case 'P':
case 'p': goto yy373;
case 'S':
case 's': goto yy374;
case 'T':
case 't': goto yy375;
case 'U':
case 'u': goto yy376;
default: goto yy355;
}
yy357:
yych = *++p;
if (yych <= '@') {
if (yych == '-') goto yy377;
} else {
if (yych <= 'Z') goto yy378;
if (yych <= '[') goto yy380;
}
yy358:
p = marker;
goto yy355;
yy359:
yych = *++p;
switch (yych) {
case 'A':
case 'a': goto yy362;
case 'B':
case 'b': goto yy363;
case 'C':
case 'c': goto yy364;
case 'D':
case 'd': goto yy365;
case 'F':
case 'f': goto yy366;
case 'H':
case 'h': goto yy367;
case 'I':
case 'i': goto yy368;
case 'L':
case 'l': goto yy369;
case 'M':
case 'm': goto yy370;
case 'N':
case 'n': goto yy371;
case 'O':
case 'o': goto yy372;
case 'P':
case 'p': goto yy381;
case 'S':
case 's': goto yy382;
case 'T':
case 't': goto yy375;
case 'U':
case 'u': goto yy376;
default: goto yy358;
}
yy360:
++p;
{ return 3; }
yy362:
yych = *++p;
if (yych <= 'S') {
if (yych <= 'D') {
if (yych <= 'C') goto yy358;
goto yy383;
} else {
if (yych <= 'Q') goto yy358;
if (yych <= 'R') goto yy384;
goto yy385;
}
} else {
if (yych <= 'q') {
if (yych == 'd') goto yy383;
goto yy358;
} else {
if (yych <= 'r') goto yy384;
if (yych <= 's') goto yy385;
goto yy358;
}
}
yy363:
yych = *++p;
if (yych <= 'O') {
if (yych <= 'K') {
if (yych == 'A') goto yy386;
goto yy358;
} else {
if (yych <= 'L') goto yy387;
if (yych <= 'N') goto yy358;
goto yy388;
}
} else {
if (yych <= 'k') {
if (yych == 'a') goto yy386;
goto yy358;
} else {
if (yych <= 'l') goto yy387;
if (yych == 'o') goto yy388;
goto yy358;
}
}
yy364:
yych = *++p;
if (yych <= 'O') {
if (yych <= 'D') {
if (yych == 'A') goto yy389;
goto yy358;
} else {
if (yych <= 'E') goto yy390;
if (yych <= 'N') goto yy358;
goto yy391;
}
} else {
if (yych <= 'd') {
if (yych == 'a') goto yy389;
goto yy358;
} else {
if (yych <= 'e') goto yy390;
if (yych == 'o') goto yy391;
goto yy358;
}
}
yy365:
yych = *++p;
switch (yych) {
case 'D':
case 'L':
case 'T':
case 'd':
case 'l':
case 't': goto yy392;
case 'E':
case 'e': goto yy393;
case 'I':
case 'i': goto yy394;
default: goto yy358;
}
yy366:
yych = *++p;
if (yych <= 'R') {
if (yych <= 'N') {
if (yych == 'I') goto yy395;
goto yy358;
} else {
if (yych <= 'O') goto yy396;
if (yych <= 'Q') goto yy358;
goto yy397;
}
} else {
if (yych <= 'n') {
if (yych == 'i') goto yy395;
goto yy358;
} else {
if (yych <= 'o') goto yy396;
if (yych == 'r') goto yy397;
goto yy358;
}
}
yy367:
yych = *++p;
if (yych <= 'S') {
if (yych <= 'D') {
if (yych <= '0') goto yy358;
if (yych <= '6') goto yy392;
goto yy358;
} else {
if (yych <= 'E') goto yy398;
if (yych == 'R') goto yy392;
goto yy358;
}
} else {
if (yych <= 'q') {
if (yych <= 'T') goto yy399;
if (yych == 'e') goto yy398;
goto yy358;
} else {
if (yych <= 'r') goto yy392;
if (yych == 't') goto yy399;
goto yy358;
}
}
yy368:
yych = *++p;
if (yych == 'F') goto yy400;
if (yych == 'f') goto yy400;
goto yy358;
yy369:
yych = *++p;
if (yych <= 'I') {
if (yych == 'E') goto yy401;
if (yych <= 'H') goto yy358;
goto yy402;
} else {
if (yych <= 'e') {
if (yych <= 'd') goto yy358;
goto yy401;
} else {
if (yych == 'i') goto yy402;
goto yy358;
}
}
yy370:
yych = *++p;
if (yych <= 'E') {
if (yych == 'A') goto yy403;
if (yych <= 'D') goto yy358;
goto yy404;
} else {
if (yych <= 'a') {
if (yych <= '`') goto yy358;
goto yy403;
} else {
if (yych == 'e') goto yy404;
goto yy358;
}
}
yy371:
yych = *++p;
if (yych <= 'O') {
if (yych == 'A') goto yy405;
if (yych <= 'N') goto yy358;
goto yy406;
} else {
if (yych <= 'a') {
if (yych <= '`') goto yy358;
goto yy405;
} else {
if (yych == 'o') goto yy406;
goto yy358;
}
}
yy372:
yych = *++p;
if (yych <= 'P') {
if (yych == 'L') goto yy392;
if (yych <= 'O') goto yy358;
goto yy407;
} else {
if (yych <= 'l') {
if (yych <= 'k') goto yy358;
goto yy392;
} else {
if (yych == 'p') goto yy407;
goto yy358;
}
}
yy373:
yych = *++p;
if (yych <= '>') {
if (yych <= ' ') {
if (yych <= 0x08) goto yy358;
if (yych <= '\r') goto yy408;
if (yych <= 0x1F) goto yy358;
goto yy408;
} else {
if (yych == '/') goto yy410;
if (yych <= '=') goto yy358;
goto yy408;
}
} else {
if (yych <= 'R') {
if (yych == 'A') goto yy411;
if (yych <= 'Q') goto yy358;
goto yy412;
} else {
if (yych <= 'a') {
if (yych <= '`') goto yy358;
goto yy411;
} else {
if (yych == 'r') goto yy412;
goto yy358;
}
}
}
yy374:
yych = *++p;
switch (yych) {
case 'C':
case 'c': goto yy413;
case 'E':
case 'e': goto yy414;
case 'O':
case 'o': goto yy415;
case 'T':
case 't': goto yy416;
case 'U':
case 'u': goto yy417;
default: goto yy358;
}
yy375:
yych = *++p;
switch (yych) {
case 'A':
case 'a': goto yy418;
case 'B':
case 'b': goto yy419;
case 'D':
case 'd': goto yy392;
case 'F':
case 'f': goto yy420;
case 'H':
case 'h': goto yy421;
case 'I':
case 'i': goto yy422;
case 'R':
case 'r': goto yy423;
default: goto yy358;
}
yy376:
yych = *++p;
if (yych == 'L') goto yy392;
if (yych == 'l') goto yy392;
goto yy358;
yy377:
yych = *++p;
if (yych == '-') goto yy424;
goto yy358;
yy378:
++p;
{ return 4; }
yy380:
yych = *++p;
if (yych == 'C') goto yy426;
if (yych == 'c') goto yy426;
goto yy358;
yy381:
yych = *++p;
if (yych <= '/') {
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy358;
if (yych <= '\r') goto yy408;
goto yy358;
} else {
if (yych <= ' ') goto yy408;
if (yych <= '.') goto yy358;
goto yy410;
}
} else {
if (yych <= '@') {
if (yych == '>') goto yy408;
goto yy358;
} else {
if (yych <= 'A') goto yy411;
if (yych == 'a') goto yy411;
goto yy358;
}
}
yy382:
yych = *++p;
if (yych <= 'U') {
if (yych <= 'N') {
if (yych == 'E') goto yy414;
goto yy358;
} else {
if (yych <= 'O') goto yy415;
if (yych <= 'T') goto yy358;
goto yy417;
}
} else {
if (yych <= 'n') {
if (yych == 'e') goto yy414;
goto yy358;
} else {
if (yych <= 'o') goto yy415;
if (yych == 'u') goto yy417;
goto yy358;
}
}
yy383:
yych = *++p;
if (yych == 'D') goto yy427;
if (yych == 'd') goto yy427;
goto yy358;
yy384:
yych = *++p;
if (yych == 'T') goto yy428;
if (yych == 't') goto yy428;
goto yy358;
yy385:
yych = *++p;
if (yych == 'I') goto yy429;
if (yych == 'i') goto yy429;
goto yy358;
yy386:
yych = *++p;
if (yych == 'S') goto yy430;
if (yych == 's') goto yy430;
goto yy358;
yy387:
yych = *++p;
if (yych == 'O') goto yy431;
if (yych == 'o') goto yy431;
goto yy358;
yy388:
yych = *++p;
if (yych == 'D') goto yy432;
if (yych == 'd') goto yy432;
goto yy358;
yy389:
yych = *++p;
if (yych == 'P') goto yy433;
if (yych == 'p') goto yy433;
goto yy358;
yy390:
yych = *++p;
if (yych == 'N') goto yy434;
if (yych == 'n') goto yy434;
goto yy358;
yy391:
yych = *++p;
if (yych == 'L') goto yy435;
if (yych == 'l') goto yy435;
goto yy358;
yy392:
yych = *++p;
if (yych <= ' ') {
if (yych <= 0x08) goto yy358;
if (yych <= '\r') goto yy408;
if (yych <= 0x1F) goto yy358;
goto yy408;
} else {
if (yych <= '/') {
if (yych <= '.') goto yy358;
goto yy410;
} else {
if (yych == '>') goto yy408;
goto yy358;
}
}
yy393:
yych = *++p;
if (yych == 'T') goto yy436;
if (yych == 't') goto yy436;
goto yy358;
yy394:
yych = *++p;
if (yych <= 'V') {
if (yych <= 'Q') {
if (yych == 'A') goto yy437;
goto yy358;
} else {
if (yych <= 'R') goto yy392;
if (yych <= 'U') goto yy358;
goto yy392;
}
} else {
if (yych <= 'q') {
if (yych == 'a') goto yy437;
goto yy358;
} else {
if (yych <= 'r') goto yy392;
if (yych == 'v') goto yy392;
goto yy358;
}
}
yy395:
yych = *++p;
if (yych <= 'G') {
if (yych == 'E') goto yy438;
if (yych <= 'F') goto yy358;
goto yy439;
} else {
if (yych <= 'e') {
if (yych <= 'd') goto yy358;
goto yy438;
} else {
if (yych == 'g') goto yy439;
goto yy358;
}
}
yy396:
yych = *++p;
if (yych <= 'R') {
if (yych == 'O') goto yy434;
if (yych <= 'Q') goto yy358;
goto yy440;
} else {
if (yych <= 'o') {
if (yych <= 'n') goto yy358;
goto yy434;
} else {
if (yych == 'r') goto yy440;
goto yy358;
}
}
yy397:
yych = *++p;
if (yych == 'A') goto yy441;
if (yych == 'a') goto yy441;
goto yy358;
yy398:
yych = *++p;
if (yych == 'A') goto yy442;
if (yych == 'a') goto yy442;
goto yy358;
yy399:
yych = *++p;
if (yych == 'M') goto yy376;
if (yych == 'm') goto yy376;
goto yy358;
yy400:
yych = *++p;
if (yych == 'R') goto yy443;
if (yych == 'r') goto yy443;
goto yy358;
yy401:
yych = *++p;
if (yych == 'G') goto yy444;
if (yych == 'g') goto yy444;
goto yy358;
yy402:
yych = *++p;
if (yych <= '/') {
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy358;
if (yych <= '\r') goto yy408;
goto yy358;
} else {
if (yych <= ' ') goto yy408;
if (yych <= '.') goto yy358;
goto yy410;
}
} else {
if (yych <= 'M') {
if (yych == '>') goto yy408;
goto yy358;
} else {
if (yych <= 'N') goto yy445;
if (yych == 'n') goto yy445;
goto yy358;
}
}
yy403:
yych = *++p;
if (yych == 'I') goto yy446;
if (yych == 'i') goto yy446;
goto yy358;
yy404:
yych = *++p;
if (yych == 'N') goto yy447;
if (yych == 'n') goto yy447;
goto yy358;
yy405:
yych = *++p;
if (yych == 'V') goto yy392;
if (yych == 'v') goto yy392;
goto yy358;
yy406:
yych = *++p;
if (yych == 'F') goto yy448;
if (yych == 'f') goto yy448;
goto yy358;
yy407:
yych = *++p;
if (yych == 'T') goto yy449;
if (yych == 't') goto yy449;
goto yy358;
yy408:
++p;
{ return 6; }
yy410:
yych = *++p;
if (yych == '>') goto yy408;
goto yy358;
yy411:
yych = *++p;
if (yych == 'R') goto yy450;
if (yych == 'r') goto yy450;
goto yy358;
yy412:
yych = *++p;
if (yych == 'E') goto yy451;
if (yych == 'e') goto yy451;
goto yy358;
yy413:
yych = *++p;
if (yych == 'R') goto yy452;
if (yych == 'r') goto yy452;
goto yy358;
yy414:
yych = *++p;
if (yych == 'C') goto yy433;
if (yych == 'c') goto yy433;
goto yy358;
yy415:
yych = *++p;
if (yych == 'U') goto yy453;
if (yych == 'u') goto yy453;
goto yy358;
yy416:
yych = *++p;
if (yych == 'Y') goto yy454;
if (yych == 'y') goto yy454;
goto yy358;
yy417:
yych = *++p;
if (yych == 'M') goto yy455;
if (yych == 'm') goto yy455;
goto yy358;
yy418:
yych = *++p;
if (yych == 'B') goto yy456;
if (yych == 'b') goto yy456;
goto yy358;
yy419:
yych = *++p;
if (yych == 'O') goto yy388;
if (yych == 'o') goto yy388;
goto yy358;
yy420:
yych = *++p;
if (yych == 'O') goto yy457;
if (yych == 'o') goto yy457;
goto yy358;
yy421:
yych = *++p;
if (yych <= '/') {
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy358;
if (yych <= '\r') goto yy408;
goto yy358;
} else {
if (yych <= ' ') goto yy408;
if (yych <= '.') goto yy358;
goto yy410;
}
} else {
if (yych <= 'D') {
if (yych == '>') goto yy408;
goto yy358;
} else {
if (yych <= 'E') goto yy458;
if (yych == 'e') goto yy458;
goto yy358;
}
}
yy422:
yych = *++p;
if (yych == 'T') goto yy456;
if (yych == 't') goto yy456;
goto yy358;
yy423:
yych = *++p;
if (yych <= '/') {
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy358;
if (yych <= '\r') goto yy408;
goto yy358;
} else {
if (yych <= ' ') goto yy408;
if (yych <= '.') goto yy358;
goto yy410;
}
} else {
if (yych <= '@') {
if (yych == '>') goto yy408;
goto yy358;
} else {
if (yych <= 'A') goto yy459;
if (yych == 'a') goto yy459;
goto yy358;
}
}
yy424:
++p;
{ return 2; }
yy426:
yych = *++p;
if (yych == 'D') goto yy460;
if (yych == 'd') goto yy460;
goto yy358;
yy427:
yych = *++p;
if (yych == 'R') goto yy461;
if (yych == 'r') goto yy461;
goto yy358;
yy428:
yych = *++p;
if (yych == 'I') goto yy462;
if (yych == 'i') goto yy462;
goto yy358;
yy429:
yych = *++p;
if (yych == 'D') goto yy463;
if (yych == 'd') goto yy463;
goto yy358;
yy430:
yych = *++p;
if (yych == 'E') goto yy464;
if (yych == 'e') goto yy464;
goto yy358;
yy431:
yych = *++p;
if (yych == 'C') goto yy465;
if (yych == 'c') goto yy465;
goto yy358;
yy432:
yych = *++p;
if (yych == 'Y') goto yy392;
if (yych == 'y') goto yy392;
goto yy358;
yy433:
yych = *++p;
if (yych == 'T') goto yy466;
if (yych == 't') goto yy466;
goto yy358;
yy434:
yych = *++p;
if (yych == 'T') goto yy467;
if (yych == 't') goto yy467;
goto yy358;
yy435:
yych = *++p;
if (yych <= '/') {
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy358;
if (yych <= '\r') goto yy408;
goto yy358;
} else {
if (yych <= ' ') goto yy408;
if (yych <= '.') goto yy358;
goto yy410;
}
} else {
if (yych <= 'F') {
if (yych == '>') goto yy408;
goto yy358;
} else {
if (yych <= 'G') goto yy468;
if (yych == 'g') goto yy468;
goto yy358;
}
}
yy436:
yych = *++p;
if (yych == 'A') goto yy469;
if (yych == 'a') goto yy469;
goto yy358;
yy437:
yych = *++p;
if (yych == 'L') goto yy470;
if (yych == 'l') goto yy470;
goto yy358;
yy438:
yych = *++p;
if (yych == 'L') goto yy471;
if (yych == 'l') goto yy471;
goto yy358;
yy439:
yych = *++p;
if (yych <= 'U') {
if (yych == 'C') goto yy472;
if (yych <= 'T') goto yy358;
goto yy473;
} else {
if (yych <= 'c') {
if (yych <= 'b') goto yy358;
goto yy472;
} else {
if (yych == 'u') goto yy473;
goto yy358;
}
}
yy440:
yych = *++p;
if (yych == 'M') goto yy392;
if (yych == 'm') goto yy392;
goto yy358;
yy441:
yych = *++p;
if (yych == 'M') goto yy474;
if (yych == 'm') goto yy474;
goto yy358;
yy442:
yych = *++p;
if (yych == 'D') goto yy475;
if (yych == 'd') goto yy475;
goto yy358;
yy443:
yych = *++p;
if (yych == 'A') goto yy476;
if (yych == 'a') goto yy476;
goto yy358;
yy444:
yych = *++p;
if (yych == 'E') goto yy477;
if (yych == 'e') goto yy477;
goto yy358;
yy445:
yych = *++p;
if (yych == 'K') goto yy392;
if (yych == 'k') goto yy392;
goto yy358;
yy446:
yych = *++p;
if (yych == 'N') goto yy392;
if (yych == 'n') goto yy392;
goto yy358;
yy447:
yych = *++p;
if (yych == 'U') goto yy478;
if (yych == 'u') goto yy478;
goto yy358;
yy448:
yych = *++p;
if (yych == 'R') goto yy479;
if (yych == 'r') goto yy479;
goto yy358;
yy449:
yych = *++p;
if (yych <= 'I') {
if (yych == 'G') goto yy468;
if (yych <= 'H') goto yy358;
goto yy480;
} else {
if (yych <= 'g') {
if (yych <= 'f') goto yy358;
goto yy468;
} else {
if (yych == 'i') goto yy480;
goto yy358;
}
}
yy450:
yych = *++p;
if (yych == 'A') goto yy440;
if (yych == 'a') goto yy440;
goto yy358;
yy451:
yych = *++p;
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy358;
if (yych <= '\r') goto yy481;
goto yy358;
} else {
if (yych <= ' ') goto yy481;
if (yych == '>') goto yy481;
goto yy358;
}
yy452:
yych = *++p;
if (yych == 'I') goto yy483;
if (yych == 'i') goto yy483;
goto yy358;
yy453:
yych = *++p;
if (yych == 'R') goto yy484;
if (yych == 'r') goto yy484;
goto yy358;
yy454:
yych = *++p;
if (yych == 'L') goto yy412;
if (yych == 'l') goto yy412;
goto yy358;
yy455:
yych = *++p;
if (yych == 'M') goto yy485;
if (yych == 'm') goto yy485;
goto yy358;
yy456:
yych = *++p;
if (yych == 'L') goto yy463;
if (yych == 'l') goto yy463;
goto yy358;
yy457:
yych = *++p;
if (yych == 'O') goto yy486;
if (yych == 'o') goto yy486;
goto yy358;
yy458:
yych = *++p;
if (yych == 'A') goto yy487;
if (yych == 'a') goto yy487;
goto yy358;
yy459:
yych = *++p;
if (yych == 'C') goto yy445;
if (yych == 'c') goto yy445;
goto yy358;
yy460:
yych = *++p;
if (yych == 'A') goto yy488;
if (yych == 'a') goto yy488;
goto yy358;
yy461:
yych = *++p;
if (yych == 'E') goto yy489;
if (yych == 'e') goto yy489;
goto yy358;
yy462:
yych = *++p;
if (yych == 'C') goto yy456;
if (yych == 'c') goto yy456;
goto yy358;
yy463:
yych = *++p;
if (yych == 'E') goto yy392;
if (yych == 'e') goto yy392;
goto yy358;
yy464:
yych = *++p;
if (yych <= '/') {
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy358;
if (yych <= '\r') goto yy408;
goto yy358;
} else {
if (yych <= ' ') goto yy408;
if (yych <= '.') goto yy358;
goto yy410;
}
} else {
if (yych <= 'E') {
if (yych == '>') goto yy408;
goto yy358;
} else {
if (yych <= 'F') goto yy490;
if (yych == 'f') goto yy490;
goto yy358;
}
}
yy465:
yych = *++p;
if (yych == 'K') goto yy491;
if (yych == 'k') goto yy491;
goto yy358;
yy466:
yych = *++p;
if (yych == 'I') goto yy480;
if (yych == 'i') goto yy480;
goto yy358;
yy467:
yych = *++p;
if (yych == 'E') goto yy492;
if (yych == 'e') goto yy492;
goto yy358;
yy468:
yych = *++p;
if (yych == 'R') goto yy493;
if (yych == 'r') goto yy493;
goto yy358;
yy469:
yych = *++p;
if (yych == 'I') goto yy494;
if (yych == 'i') goto yy494;
goto yy358;
yy470:
yych = *++p;
if (yych == 'O') goto yy495;
if (yych == 'o') goto yy495;
goto yy358;
yy471:
yych = *++p;
if (yych == 'D') goto yy496;
if (yych == 'd') goto yy496;
goto yy358;
yy472:
yych = *++p;
if (yych == 'A') goto yy389;
if (yych == 'a') goto yy389;
goto yy358;
yy473:
yych = *++p;
if (yych == 'R') goto yy463;
if (yych == 'r') goto yy463;
goto yy358;
yy474:
yych = *++p;
if (yych == 'E') goto yy497;
if (yych == 'e') goto yy497;
goto yy358;
yy475:
yych = *++p;
if (yych <= '/') {
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy358;
if (yych <= '\r') goto yy408;
goto yy358;
} else {
if (yych <= ' ') goto yy408;
if (yych <= '.') goto yy358;
goto yy410;
}
} else {
if (yych <= 'D') {
if (yych == '>') goto yy408;
goto yy358;
} else {
if (yych <= 'E') goto yy492;
if (yych == 'e') goto yy492;
goto yy358;
}
}
yy476:
yych = *++p;
if (yych == 'M') goto yy463;
if (yych == 'm') goto yy463;
goto yy358;
yy477:
yych = *++p;
if (yych == 'N') goto yy487;
if (yych == 'n') goto yy487;
goto yy358;
yy478:
yych = *++p;
if (yych <= '/') {
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy358;
if (yych <= '\r') goto yy408;
goto yy358;
} else {
if (yych <= ' ') goto yy408;
if (yych <= '.') goto yy358;
goto yy410;
}
} else {
if (yych <= 'H') {
if (yych == '>') goto yy408;
goto yy358;
} else {
if (yych <= 'I') goto yy498;
if (yych == 'i') goto yy498;
goto yy358;
}
}
yy479:
yych = *++p;
if (yych == 'A') goto yy499;
if (yych == 'a') goto yy499;
goto yy358;
yy480:
yych = *++p;
if (yych == 'O') goto yy446;
if (yych == 'o') goto yy446;
goto yy358;
yy481:
++p;
{ return 1; }
yy483:
yych = *++p;
if (yych == 'P') goto yy500;
if (yych == 'p') goto yy500;
goto yy358;
yy484:
yych = *++p;
if (yych == 'C') goto yy463;
if (yych == 'c') goto yy463;
goto yy358;
yy485:
yych = *++p;
if (yych == 'A') goto yy501;
if (yych == 'a') goto yy501;
goto yy358;
yy486:
yych = *++p;
if (yych == 'T') goto yy392;
if (yych == 't') goto yy392;
goto yy358;
yy487:
yych = *++p;
if (yych == 'D') goto yy392;
if (yych == 'd') goto yy392;
goto yy358;
yy488:
yych = *++p;
if (yych == 'T') goto yy502;
if (yych == 't') goto yy502;
goto yy358;
yy489:
yych = *++p;
if (yych == 'S') goto yy503;
if (yych == 's') goto yy503;
goto yy358;
yy490:
yych = *++p;
if (yych == 'O') goto yy504;
if (yych == 'o') goto yy504;
goto yy358;
yy491:
yych = *++p;
if (yych == 'Q') goto yy505;
if (yych == 'q') goto yy505;
goto yy358;
yy492:
yych = *++p;
if (yych == 'R') goto yy392;
if (yych == 'r') goto yy392;
goto yy358;
yy493:
yych = *++p;
if (yych == 'O') goto yy506;
if (yych == 'o') goto yy506;
goto yy358;
yy494:
yych = *++p;
if (yych == 'L') goto yy503;
if (yych == 'l') goto yy503;
goto yy358;
yy495:
yych = *++p;
if (yych == 'G') goto yy392;
if (yych == 'g') goto yy392;
goto yy358;
yy496:
yych = *++p;
if (yych == 'S') goto yy507;
if (yych == 's') goto yy507;
goto yy358;
yy497:
yych = *++p;
if (yych <= '/') {
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy358;
if (yych <= '\r') goto yy408;
goto yy358;
} else {
if (yych <= ' ') goto yy408;
if (yych <= '.') goto yy358;
goto yy410;
}
} else {
if (yych <= 'R') {
if (yych == '>') goto yy408;
goto yy358;
} else {
if (yych <= 'S') goto yy507;
if (yych == 's') goto yy507;
goto yy358;
}
}
yy498:
yych = *++p;
if (yych == 'T') goto yy508;
if (yych == 't') goto yy508;
goto yy358;
yy499:
yych = *++p;
if (yych == 'M') goto yy509;
if (yych == 'm') goto yy509;
goto yy358;
yy500:
yych = *++p;
if (yych == 'T') goto yy451;
if (yych == 't') goto yy451;
goto yy358;
yy501:
yych = *++p;
if (yych == 'R') goto yy432;
if (yych == 'r') goto yy432;
goto yy358;
yy502:
yych = *++p;
if (yych == 'A') goto yy510;
if (yych == 'a') goto yy510;
goto yy358;
yy503:
yych = *++p;
if (yych == 'S') goto yy392;
if (yych == 's') goto yy392;
goto yy358;
yy504:
yych = *++p;
if (yych == 'N') goto yy486;
if (yych == 'n') goto yy486;
goto yy358;
yy505:
yych = *++p;
if (yych == 'U') goto yy511;
if (yych == 'u') goto yy511;
goto yy358;
yy506:
yych = *++p;
if (yych == 'U') goto yy512;
if (yych == 'u') goto yy512;
goto yy358;
yy507:
yych = *++p;
if (yych == 'E') goto yy486;
if (yych == 'e') goto yy486;
goto yy358;
yy508:
yych = *++p;
if (yych == 'E') goto yy440;
if (yych == 'e') goto yy440;
goto yy358;
yy509:
yych = *++p;
if (yych == 'E') goto yy503;
if (yych == 'e') goto yy503;
goto yy358;
yy510:
yych = *++p;
if (yych == '[') goto yy513;
goto yy358;
yy511:
yych = *++p;
if (yych == 'O') goto yy515;
if (yych == 'o') goto yy515;
goto yy358;
yy512:
yych = *++p;
if (yych == 'P') goto yy392;
if (yych == 'p') goto yy392;
goto yy358;
yy513:
++p;
{ return 5; }
yy515:
yych = *++p;
if (yych == 'T') goto yy463;
if (yych == 't') goto yy463;
goto yy358;
}
}
// Try to match an HTML block tag start line of type 7, returning
// 7 if successful, 0 if not.
bufsize_t _scan_html_block_start_7(const unsigned char *p)
{
const unsigned char *marker = NULL;
{
unsigned char yych;
unsigned int yyaccept = 0;
static const unsigned char yybm[] = {
0, 224, 224, 224, 224, 224, 224, 224,
224, 198, 210, 194, 198, 194, 224, 224,
224, 224, 224, 224, 224, 224, 224, 224,
224, 224, 224, 224, 224, 224, 224, 224,
198, 224, 128, 224, 224, 224, 224, 64,
224, 224, 224, 224, 224, 233, 232, 224,
233, 233, 233, 233, 233, 233, 233, 233,
233, 233, 232, 224, 192, 192, 192, 224,
224, 233, 233, 233, 233, 233, 233, 233,
233, 233, 233, 233, 233, 233, 233, 233,
233, 233, 233, 233, 233, 233, 233, 233,
233, 233, 233, 224, 224, 224, 224, 232,
192, 233, 233, 233, 233, 233, 233, 233,
233, 233, 233, 233, 233, 233, 233, 233,
233, 233, 233, 233, 233, 233, 233, 233,
233, 233, 233, 224, 224, 224, 224, 224,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych == '<') goto yy520;
++p;
yy519:
{ return 0; }
yy520:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= '@') {
if (yych != '/') goto yy519;
} else {
if (yych <= 'Z') goto yy523;
if (yych <= '`') goto yy519;
if (yych <= 'z') goto yy523;
goto yy519;
}
yych = *++p;
if (yych <= '@') goto yy522;
if (yych <= 'Z') goto yy525;
if (yych <= '`') goto yy522;
if (yych <= 'z') goto yy525;
yy522:
p = marker;
if (yyaccept == 0) {
goto yy519;
} else {
goto yy538;
}
yy523:
yych = *++p;
if (yybm[0+yych] & 2) {
goto yy527;
}
if (yych <= '=') {
if (yych <= '.') {
if (yych == '-') goto yy523;
goto yy522;
} else {
if (yych <= '/') goto yy529;
if (yych <= '9') goto yy523;
goto yy522;
}
} else {
if (yych <= 'Z') {
if (yych <= '>') goto yy530;
if (yych <= '@') goto yy522;
goto yy523;
} else {
if (yych <= '`') goto yy522;
if (yych <= 'z') goto yy523;
goto yy522;
}
}
yy525:
yych = *++p;
if (yych <= '/') {
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy522;
if (yych <= '\r') goto yy532;
goto yy522;
} else {
if (yych <= ' ') goto yy532;
if (yych == '-') goto yy525;
goto yy522;
}
} else {
if (yych <= '@') {
if (yych <= '9') goto yy525;
if (yych == '>') goto yy530;
goto yy522;
} else {
if (yych <= 'Z') goto yy525;
if (yych <= '`') goto yy522;
if (yych <= 'z') goto yy525;
goto yy522;
}
}
yy527:
yych = *++p;
if (yybm[0+yych] & 2) {
goto yy527;
}
if (yych <= '>') {
if (yych <= '9') {
if (yych != '/') goto yy522;
} else {
if (yych <= ':') goto yy534;
if (yych <= '=') goto yy522;
goto yy530;
}
} else {
if (yych <= '^') {
if (yych <= '@') goto yy522;
if (yych <= 'Z') goto yy534;
goto yy522;
} else {
if (yych == '`') goto yy522;
if (yych <= 'z') goto yy534;
goto yy522;
}
}
yy529:
yych = *++p;
if (yych != '>') goto yy522;
yy530:
yych = *++p;
if (yybm[0+yych] & 4) {
goto yy530;
}
if (yych <= 0x08) goto yy522;
if (yych <= '\n') goto yy536;
if (yych <= '\v') goto yy522;
if (yych <= '\r') goto yy539;
goto yy522;
yy532:
yych = *++p;
if (yych <= 0x1F) {
if (yych <= 0x08) goto yy522;
if (yych <= '\r') goto yy532;
goto yy522;
} else {
if (yych <= ' ') goto yy532;
if (yych == '>') goto yy530;
goto yy522;
}
yy534:
yych = *++p;
if (yybm[0+yych] & 8) {
goto yy534;
}
if (yych <= ',') {
if (yych <= '\r') {
if (yych <= 0x08) goto yy522;
goto yy540;
} else {
if (yych == ' ') goto yy540;
goto yy522;
}
} else {
if (yych <= '<') {
if (yych <= '/') goto yy529;
goto yy522;
} else {
if (yych <= '=') goto yy542;
if (yych <= '>') goto yy530;
goto yy522;
}
}
yy536:
yyaccept = 1;
yych = *(marker = ++p);
if (yybm[0+yych] & 4) {
goto yy530;
}
if (yych <= 0x08) goto yy538;
if (yych <= '\n') goto yy536;
if (yych <= '\v') goto yy538;
if (yych <= '\r') goto yy539;
yy538:
{ return 7; }
yy539:
++p;
goto yy538;
yy540:
yych = *++p;
if (yych <= '<') {
if (yych <= ' ') {
if (yych <= 0x08) goto yy522;
if (yych <= '\r') goto yy540;
if (yych <= 0x1F) goto yy522;
goto yy540;
} else {
if (yych <= '/') {
if (yych <= '.') goto yy522;
goto yy529;
} else {
if (yych == ':') goto yy534;
goto yy522;
}
}
} else {
if (yych <= 'Z') {
if (yych <= '=') goto yy542;
if (yych <= '>') goto yy530;
if (yych <= '@') goto yy522;
goto yy534;
} else {
if (yych <= '_') {
if (yych <= '^') goto yy522;
goto yy534;
} else {
if (yych <= '`') goto yy522;
if (yych <= 'z') goto yy534;
goto yy522;
}
}
}
yy542:
yych = *++p;
if (yybm[0+yych] & 32) {
goto yy544;
}
if (yych <= 0xE0) {
if (yych <= '"') {
if (yych <= 0x00) goto yy522;
if (yych <= ' ') goto yy542;
goto yy546;
} else {
if (yych <= '\'') goto yy548;
if (yych <= 0xC1) goto yy522;
if (yych <= 0xDF) goto yy550;
goto yy551;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy553;
goto yy552;
} else {
if (yych <= 0xF0) goto yy554;
if (yych <= 0xF3) goto yy555;
if (yych <= 0xF4) goto yy556;
goto yy522;
}
}
yy544:
yych = *++p;
if (yybm[0+yych] & 32) {
goto yy544;
}
if (yych <= 0xE0) {
if (yych <= '=') {
if (yych <= 0x00) goto yy522;
if (yych <= ' ') goto yy527;
goto yy522;
} else {
if (yych <= '>') goto yy530;
if (yych <= 0xC1) goto yy522;
if (yych <= 0xDF) goto yy550;
goto yy551;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy553;
goto yy552;
} else {
if (yych <= 0xF0) goto yy554;
if (yych <= 0xF3) goto yy555;
if (yych <= 0xF4) goto yy556;
goto yy522;
}
}
yy546:
yych = *++p;
if (yybm[0+yych] & 64) {
goto yy546;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= 0x00) goto yy522;
if (yych <= '"') goto yy557;
goto yy522;
} else {
if (yych <= 0xDF) goto yy558;
if (yych <= 0xE0) goto yy559;
goto yy560;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy561;
if (yych <= 0xEF) goto yy560;
goto yy562;
} else {
if (yych <= 0xF3) goto yy563;
if (yych <= 0xF4) goto yy564;
goto yy522;
}
}
yy548:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy548;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= 0x00) goto yy522;
if (yych <= '\'') goto yy557;
goto yy522;
} else {
if (yych <= 0xDF) goto yy565;
if (yych <= 0xE0) goto yy566;
goto yy567;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy568;
if (yych <= 0xEF) goto yy567;
goto yy569;
} else {
if (yych <= 0xF3) goto yy570;
if (yych <= 0xF4) goto yy571;
goto yy522;
}
}
yy550:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0xBF) goto yy544;
goto yy522;
yy551:
yych = *++p;
if (yych <= 0x9F) goto yy522;
if (yych <= 0xBF) goto yy550;
goto yy522;
yy552:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0xBF) goto yy550;
goto yy522;
yy553:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0x9F) goto yy550;
goto yy522;
yy554:
yych = *++p;
if (yych <= 0x8F) goto yy522;
if (yych <= 0xBF) goto yy552;
goto yy522;
yy555:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0xBF) goto yy552;
goto yy522;
yy556:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0x8F) goto yy552;
goto yy522;
yy557:
yych = *++p;
if (yybm[0+yych] & 2) {
goto yy527;
}
if (yych == '/') goto yy529;
if (yych == '>') goto yy530;
goto yy522;
yy558:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0xBF) goto yy546;
goto yy522;
yy559:
yych = *++p;
if (yych <= 0x9F) goto yy522;
if (yych <= 0xBF) goto yy558;
goto yy522;
yy560:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0xBF) goto yy558;
goto yy522;
yy561:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0x9F) goto yy558;
goto yy522;
yy562:
yych = *++p;
if (yych <= 0x8F) goto yy522;
if (yych <= 0xBF) goto yy560;
goto yy522;
yy563:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0xBF) goto yy560;
goto yy522;
yy564:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0x8F) goto yy560;
goto yy522;
yy565:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0xBF) goto yy548;
goto yy522;
yy566:
yych = *++p;
if (yych <= 0x9F) goto yy522;
if (yych <= 0xBF) goto yy565;
goto yy522;
yy567:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0xBF) goto yy565;
goto yy522;
yy568:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0x9F) goto yy565;
goto yy522;
yy569:
yych = *++p;
if (yych <= 0x8F) goto yy522;
if (yych <= 0xBF) goto yy567;
goto yy522;
yy570:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0xBF) goto yy567;
goto yy522;
yy571:
yych = *++p;
if (yych <= 0x7F) goto yy522;
if (yych <= 0x8F) goto yy567;
goto yy522;
}
}
// Try to match an HTML block end line of type 1
bufsize_t _scan_html_block_end_1(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
unsigned int yyaccept = 0;
static const unsigned char yybm[] = {
0, 64, 64, 64, 64, 64, 64, 64,
64, 64, 0, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 128, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych <= 0xDF) {
if (yych <= ';') {
if (yych <= 0x00) goto yy574;
if (yych != '\n') goto yy576;
} else {
if (yych <= '<') goto yy577;
if (yych <= 0x7F) goto yy576;
if (yych >= 0xC2) goto yy578;
}
} else {
if (yych <= 0xEF) {
if (yych <= 0xE0) goto yy579;
if (yych == 0xED) goto yy581;
goto yy580;
} else {
if (yych <= 0xF0) goto yy582;
if (yych <= 0xF3) goto yy583;
if (yych <= 0xF4) goto yy584;
}
}
yy574:
++p;
yy575:
{ return 0; }
yy576:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= '\n') {
if (yych <= 0x00) goto yy575;
if (yych <= '\t') goto yy586;
goto yy575;
} else {
if (yych <= 0x7F) goto yy586;
if (yych <= 0xC1) goto yy575;
if (yych <= 0xF4) goto yy586;
goto yy575;
}
yy577:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= '.') {
if (yych <= 0x00) goto yy575;
if (yych == '\n') goto yy575;
goto yy586;
} else {
if (yych <= 0x7F) {
if (yych <= '/') goto yy597;
goto yy586;
} else {
if (yych <= 0xC1) goto yy575;
if (yych <= 0xF4) goto yy586;
goto yy575;
}
}
yy578:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy575;
if (yych <= 0xBF) goto yy585;
goto yy575;
yy579:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x9F) goto yy575;
if (yych <= 0xBF) goto yy590;
goto yy575;
yy580:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy575;
if (yych <= 0xBF) goto yy590;
goto yy575;
yy581:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy575;
if (yych <= 0x9F) goto yy590;
goto yy575;
yy582:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x8F) goto yy575;
if (yych <= 0xBF) goto yy592;
goto yy575;
yy583:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy575;
if (yych <= 0xBF) goto yy592;
goto yy575;
yy584:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy575;
if (yych <= 0x8F) goto yy592;
goto yy575;
yy585:
yych = *++p;
yy586:
if (yybm[0+yych] & 64) {
goto yy585;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\n') goto yy587;
if (yych <= '<') goto yy588;
} else {
if (yych <= 0xDF) goto yy590;
if (yych <= 0xE0) goto yy591;
goto yy592;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy593;
if (yych <= 0xEF) goto yy592;
goto yy594;
} else {
if (yych <= 0xF3) goto yy595;
if (yych <= 0xF4) goto yy596;
}
}
yy587:
p = marker;
if (yyaccept == 0) {
goto yy575;
} else {
goto yy607;
}
yy588:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy588;
}
if (yych <= 0xDF) {
if (yych <= '.') {
if (yych <= 0x00) goto yy587;
if (yych == '\n') goto yy587;
goto yy585;
} else {
if (yych <= '/') goto yy597;
if (yych <= 0x7F) goto yy585;
if (yych <= 0xC1) goto yy587;
}
} else {
if (yych <= 0xEF) {
if (yych <= 0xE0) goto yy591;
if (yych == 0xED) goto yy593;
goto yy592;
} else {
if (yych <= 0xF0) goto yy594;
if (yych <= 0xF3) goto yy595;
if (yych <= 0xF4) goto yy596;
goto yy587;
}
}
yy590:
yych = *++p;
if (yych <= 0x7F) goto yy587;
if (yych <= 0xBF) goto yy585;
goto yy587;
yy591:
yych = *++p;
if (yych <= 0x9F) goto yy587;
if (yych <= 0xBF) goto yy590;
goto yy587;
yy592:
yych = *++p;
if (yych <= 0x7F) goto yy587;
if (yych <= 0xBF) goto yy590;
goto yy587;
yy593:
yych = *++p;
if (yych <= 0x7F) goto yy587;
if (yych <= 0x9F) goto yy590;
goto yy587;
yy594:
yych = *++p;
if (yych <= 0x8F) goto yy587;
if (yych <= 0xBF) goto yy592;
goto yy587;
yy595:
yych = *++p;
if (yych <= 0x7F) goto yy587;
if (yych <= 0xBF) goto yy592;
goto yy587;
yy596:
yych = *++p;
if (yych <= 0x7F) goto yy587;
if (yych <= 0x8F) goto yy592;
goto yy587;
yy597:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy588;
}
if (yych <= 's') {
if (yych <= 'P') {
if (yych <= '\t') {
if (yych <= 0x00) goto yy587;
goto yy585;
} else {
if (yych <= '\n') goto yy587;
if (yych <= 'O') goto yy585;
}
} else {
if (yych <= 'o') {
if (yych == 'S') goto yy599;
goto yy585;
} else {
if (yych <= 'p') goto yy598;
if (yych <= 'r') goto yy585;
goto yy599;
}
}
} else {
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= 0x7F) goto yy585;
goto yy587;
} else {
if (yych <= 0xDF) goto yy590;
if (yych <= 0xE0) goto yy591;
goto yy592;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy593;
if (yych <= 0xEF) goto yy592;
goto yy594;
} else {
if (yych <= 0xF3) goto yy595;
if (yych <= 0xF4) goto yy596;
goto yy587;
}
}
}
yy598:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy588;
}
if (yych <= 0xC1) {
if (yych <= 'Q') {
if (yych <= 0x00) goto yy587;
if (yych == '\n') goto yy587;
goto yy585;
} else {
if (yych <= 'q') {
if (yych <= 'R') goto yy600;
goto yy585;
} else {
if (yych <= 'r') goto yy600;
if (yych <= 0x7F) goto yy585;
goto yy587;
}
}
} else {
if (yych <= 0xED) {
if (yych <= 0xDF) goto yy590;
if (yych <= 0xE0) goto yy591;
if (yych <= 0xEC) goto yy592;
goto yy593;
} else {
if (yych <= 0xF0) {
if (yych <= 0xEF) goto yy592;
goto yy594;
} else {
if (yych <= 0xF3) goto yy595;
if (yych <= 0xF4) goto yy596;
goto yy587;
}
}
}
yy599:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy588;
}
if (yych <= 't') {
if (yych <= 'C') {
if (yych <= '\t') {
if (yych <= 0x00) goto yy587;
goto yy585;
} else {
if (yych <= '\n') goto yy587;
if (yych <= 'B') goto yy585;
goto yy601;
}
} else {
if (yych <= 'b') {
if (yych == 'T') goto yy602;
goto yy585;
} else {
if (yych <= 'c') goto yy601;
if (yych <= 's') goto yy585;
goto yy602;
}
}
} else {
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= 0x7F) goto yy585;
goto yy587;
} else {
if (yych <= 0xDF) goto yy590;
if (yych <= 0xE0) goto yy591;
goto yy592;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy593;
if (yych <= 0xEF) goto yy592;
goto yy594;
} else {
if (yych <= 0xF3) goto yy595;
if (yych <= 0xF4) goto yy596;
goto yy587;
}
}
}
yy600:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy588;
}
if (yych <= 0xC1) {
if (yych <= 'D') {
if (yych <= 0x00) goto yy587;
if (yych == '\n') goto yy587;
goto yy585;
} else {
if (yych <= 'd') {
if (yych <= 'E') goto yy603;
goto yy585;
} else {
if (yych <= 'e') goto yy603;
if (yych <= 0x7F) goto yy585;
goto yy587;
}
}
} else {
if (yych <= 0xED) {
if (yych <= 0xDF) goto yy590;
if (yych <= 0xE0) goto yy591;
if (yych <= 0xEC) goto yy592;
goto yy593;
} else {
if (yych <= 0xF0) {
if (yych <= 0xEF) goto yy592;
goto yy594;
} else {
if (yych <= 0xF3) goto yy595;
if (yych <= 0xF4) goto yy596;
goto yy587;
}
}
}
yy601:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy588;
}
if (yych <= 0xC1) {
if (yych <= 'Q') {
if (yych <= 0x00) goto yy587;
if (yych == '\n') goto yy587;
goto yy585;
} else {
if (yych <= 'q') {
if (yych <= 'R') goto yy604;
goto yy585;
} else {
if (yych <= 'r') goto yy604;
if (yych <= 0x7F) goto yy585;
goto yy587;
}
}
} else {
if (yych <= 0xED) {
if (yych <= 0xDF) goto yy590;
if (yych <= 0xE0) goto yy591;
if (yych <= 0xEC) goto yy592;
goto yy593;
} else {
if (yych <= 0xF0) {
if (yych <= 0xEF) goto yy592;
goto yy594;
} else {
if (yych <= 0xF3) goto yy595;
if (yych <= 0xF4) goto yy596;
goto yy587;
}
}
}
yy602:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy588;
}
if (yych <= 0xC1) {
if (yych <= 'X') {
if (yych <= 0x00) goto yy587;
if (yych == '\n') goto yy587;
goto yy585;
} else {
if (yych <= 'x') {
if (yych <= 'Y') goto yy605;
goto yy585;
} else {
if (yych <= 'y') goto yy605;
if (yych <= 0x7F) goto yy585;
goto yy587;
}
}
} else {
if (yych <= 0xED) {
if (yych <= 0xDF) goto yy590;
if (yych <= 0xE0) goto yy591;
if (yych <= 0xEC) goto yy592;
goto yy593;
} else {
if (yych <= 0xF0) {
if (yych <= 0xEF) goto yy592;
goto yy594;
} else {
if (yych <= 0xF3) goto yy595;
if (yych <= 0xF4) goto yy596;
goto yy587;
}
}
}
yy603:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy588;
}
if (yych <= 0xDF) {
if (yych <= '=') {
if (yych <= 0x00) goto yy587;
if (yych == '\n') goto yy587;
goto yy585;
} else {
if (yych <= '>') goto yy606;
if (yych <= 0x7F) goto yy585;
if (yych <= 0xC1) goto yy587;
goto yy590;
}
} else {
if (yych <= 0xEF) {
if (yych <= 0xE0) goto yy591;
if (yych == 0xED) goto yy593;
goto yy592;
} else {
if (yych <= 0xF0) goto yy594;
if (yych <= 0xF3) goto yy595;
if (yych <= 0xF4) goto yy596;
goto yy587;
}
}
yy604:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy588;
}
if (yych <= 0xC1) {
if (yych <= 'H') {
if (yych <= 0x00) goto yy587;
if (yych == '\n') goto yy587;
goto yy585;
} else {
if (yych <= 'h') {
if (yych <= 'I') goto yy608;
goto yy585;
} else {
if (yych <= 'i') goto yy608;
if (yych <= 0x7F) goto yy585;
goto yy587;
}
}
} else {
if (yych <= 0xED) {
if (yych <= 0xDF) goto yy590;
if (yych <= 0xE0) goto yy591;
if (yych <= 0xEC) goto yy592;
goto yy593;
} else {
if (yych <= 0xF0) {
if (yych <= 0xEF) goto yy592;
goto yy594;
} else {
if (yych <= 0xF3) goto yy595;
if (yych <= 0xF4) goto yy596;
goto yy587;
}
}
}
yy605:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy588;
}
if (yych <= 0xC1) {
if (yych <= 'K') {
if (yych <= 0x00) goto yy587;
if (yych == '\n') goto yy587;
goto yy585;
} else {
if (yych <= 'k') {
if (yych <= 'L') goto yy600;
goto yy585;
} else {
if (yych <= 'l') goto yy600;
if (yych <= 0x7F) goto yy585;
goto yy587;
}
}
} else {
if (yych <= 0xED) {
if (yych <= 0xDF) goto yy590;
if (yych <= 0xE0) goto yy591;
if (yych <= 0xEC) goto yy592;
goto yy593;
} else {
if (yych <= 0xF0) {
if (yych <= 0xEF) goto yy592;
goto yy594;
} else {
if (yych <= 0xF3) goto yy595;
if (yych <= 0xF4) goto yy596;
goto yy587;
}
}
}
yy606:
yyaccept = 1;
yych = *(marker = ++p);
if (yybm[0+yych] & 64) {
goto yy585;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\n') goto yy607;
if (yych <= '<') goto yy588;
} else {
if (yych <= 0xDF) goto yy590;
if (yych <= 0xE0) goto yy591;
goto yy592;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy593;
if (yych <= 0xEF) goto yy592;
goto yy594;
} else {
if (yych <= 0xF3) goto yy595;
if (yych <= 0xF4) goto yy596;
}
}
yy607:
{ return (bufsize_t)(p - start); }
yy608:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy588;
}
if (yych <= 0xC1) {
if (yych <= 'O') {
if (yych <= 0x00) goto yy587;
if (yych == '\n') goto yy587;
goto yy585;
} else {
if (yych <= 'o') {
if (yych >= 'Q') goto yy585;
} else {
if (yych <= 'p') goto yy609;
if (yych <= 0x7F) goto yy585;
goto yy587;
}
}
} else {
if (yych <= 0xED) {
if (yych <= 0xDF) goto yy590;
if (yych <= 0xE0) goto yy591;
if (yych <= 0xEC) goto yy592;
goto yy593;
} else {
if (yych <= 0xF0) {
if (yych <= 0xEF) goto yy592;
goto yy594;
} else {
if (yych <= 0xF3) goto yy595;
if (yych <= 0xF4) goto yy596;
goto yy587;
}
}
}
yy609:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy588;
}
if (yych <= 0xC1) {
if (yych <= 'S') {
if (yych <= 0x00) goto yy587;
if (yych == '\n') goto yy587;
goto yy585;
} else {
if (yych <= 's') {
if (yych <= 'T') goto yy603;
goto yy585;
} else {
if (yych <= 't') goto yy603;
if (yych <= 0x7F) goto yy585;
goto yy587;
}
}
} else {
if (yych <= 0xED) {
if (yych <= 0xDF) goto yy590;
if (yych <= 0xE0) goto yy591;
if (yych <= 0xEC) goto yy592;
goto yy593;
} else {
if (yych <= 0xF0) {
if (yych <= 0xEF) goto yy592;
goto yy594;
} else {
if (yych <= 0xF3) goto yy595;
if (yych <= 0xF4) goto yy596;
goto yy587;
}
}
}
}
}
// Try to match an HTML block end line of type 2
bufsize_t _scan_html_block_end_2(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
unsigned int yyaccept = 0;
static const unsigned char yybm[] = {
0, 64, 64, 64, 64, 64, 64, 64,
64, 64, 0, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 128, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych <= 0xDF) {
if (yych <= ',') {
if (yych <= 0x00) goto yy612;
if (yych != '\n') goto yy614;
} else {
if (yych <= '-') goto yy615;
if (yych <= 0x7F) goto yy614;
if (yych >= 0xC2) goto yy616;
}
} else {
if (yych <= 0xEF) {
if (yych <= 0xE0) goto yy617;
if (yych == 0xED) goto yy619;
goto yy618;
} else {
if (yych <= 0xF0) goto yy620;
if (yych <= 0xF3) goto yy621;
if (yych <= 0xF4) goto yy622;
}
}
yy612:
++p;
yy613:
{ return 0; }
yy614:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= '\n') {
if (yych <= 0x00) goto yy613;
if (yych <= '\t') goto yy624;
goto yy613;
} else {
if (yych <= 0x7F) goto yy624;
if (yych <= 0xC1) goto yy613;
if (yych <= 0xF4) goto yy624;
goto yy613;
}
yy615:
yyaccept = 0;
yych = *(marker = ++p);
if (yybm[0+yych] & 128) {
goto yy634;
}
if (yych <= '\n') {
if (yych <= 0x00) goto yy613;
if (yych <= '\t') goto yy624;
goto yy613;
} else {
if (yych <= 0x7F) goto yy624;
if (yych <= 0xC1) goto yy613;
if (yych <= 0xF4) goto yy624;
goto yy613;
}
yy616:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy613;
if (yych <= 0xBF) goto yy623;
goto yy613;
yy617:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x9F) goto yy613;
if (yych <= 0xBF) goto yy627;
goto yy613;
yy618:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy613;
if (yych <= 0xBF) goto yy627;
goto yy613;
yy619:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy613;
if (yych <= 0x9F) goto yy627;
goto yy613;
yy620:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x8F) goto yy613;
if (yych <= 0xBF) goto yy629;
goto yy613;
yy621:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy613;
if (yych <= 0xBF) goto yy629;
goto yy613;
yy622:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy613;
if (yych <= 0x8F) goto yy629;
goto yy613;
yy623:
yych = *++p;
yy624:
if (yybm[0+yych] & 64) {
goto yy623;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\n') goto yy625;
if (yych <= '-') goto yy626;
} else {
if (yych <= 0xDF) goto yy627;
if (yych <= 0xE0) goto yy628;
goto yy629;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy630;
if (yych <= 0xEF) goto yy629;
goto yy631;
} else {
if (yych <= 0xF3) goto yy632;
if (yych <= 0xF4) goto yy633;
}
}
yy625:
p = marker;
if (yyaccept == 0) {
goto yy613;
} else {
goto yy637;
}
yy626:
yych = *++p;
if (yybm[0+yych] & 64) {
goto yy623;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\n') goto yy625;
if (yych <= '-') goto yy634;
goto yy625;
} else {
if (yych <= 0xDF) goto yy627;
if (yych <= 0xE0) goto yy628;
goto yy629;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy630;
if (yych <= 0xEF) goto yy629;
goto yy631;
} else {
if (yych <= 0xF3) goto yy632;
if (yych <= 0xF4) goto yy633;
goto yy625;
}
}
yy627:
yych = *++p;
if (yych <= 0x7F) goto yy625;
if (yych <= 0xBF) goto yy623;
goto yy625;
yy628:
yych = *++p;
if (yych <= 0x9F) goto yy625;
if (yych <= 0xBF) goto yy627;
goto yy625;
yy629:
yych = *++p;
if (yych <= 0x7F) goto yy625;
if (yych <= 0xBF) goto yy627;
goto yy625;
yy630:
yych = *++p;
if (yych <= 0x7F) goto yy625;
if (yych <= 0x9F) goto yy627;
goto yy625;
yy631:
yych = *++p;
if (yych <= 0x8F) goto yy625;
if (yych <= 0xBF) goto yy629;
goto yy625;
yy632:
yych = *++p;
if (yych <= 0x7F) goto yy625;
if (yych <= 0xBF) goto yy629;
goto yy625;
yy633:
yych = *++p;
if (yych <= 0x7F) goto yy625;
if (yych <= 0x8F) goto yy629;
goto yy625;
yy634:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy634;
}
if (yych <= 0xDF) {
if (yych <= '=') {
if (yych <= 0x00) goto yy625;
if (yych == '\n') goto yy625;
goto yy623;
} else {
if (yych <= '>') goto yy636;
if (yych <= 0x7F) goto yy623;
if (yych <= 0xC1) goto yy625;
goto yy627;
}
} else {
if (yych <= 0xEF) {
if (yych <= 0xE0) goto yy628;
if (yych == 0xED) goto yy630;
goto yy629;
} else {
if (yych <= 0xF0) goto yy631;
if (yych <= 0xF3) goto yy632;
if (yych <= 0xF4) goto yy633;
goto yy625;
}
}
yy636:
yyaccept = 1;
yych = *(marker = ++p);
if (yybm[0+yych] & 64) {
goto yy623;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\n') goto yy637;
if (yych <= '-') goto yy626;
} else {
if (yych <= 0xDF) goto yy627;
if (yych <= 0xE0) goto yy628;
goto yy629;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy630;
if (yych <= 0xEF) goto yy629;
goto yy631;
} else {
if (yych <= 0xF3) goto yy632;
if (yych <= 0xF4) goto yy633;
}
}
yy637:
{ return (bufsize_t)(p - start); }
}
}
// Try to match an HTML block end line of type 3
bufsize_t _scan_html_block_end_3(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
unsigned int yyaccept = 0;
static const unsigned char yybm[] = {
0, 64, 64, 64, 64, 64, 64, 64,
64, 64, 0, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 128,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych <= 0xDF) {
if (yych <= '>') {
if (yych <= 0x00) goto yy640;
if (yych != '\n') goto yy642;
} else {
if (yych <= '?') goto yy643;
if (yych <= 0x7F) goto yy642;
if (yych >= 0xC2) goto yy644;
}
} else {
if (yych <= 0xEF) {
if (yych <= 0xE0) goto yy645;
if (yych == 0xED) goto yy647;
goto yy646;
} else {
if (yych <= 0xF0) goto yy648;
if (yych <= 0xF3) goto yy649;
if (yych <= 0xF4) goto yy650;
}
}
yy640:
++p;
yy641:
{ return 0; }
yy642:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= '\n') {
if (yych <= 0x00) goto yy641;
if (yych <= '\t') goto yy652;
goto yy641;
} else {
if (yych <= 0x7F) goto yy652;
if (yych <= 0xC1) goto yy641;
if (yych <= 0xF4) goto yy652;
goto yy641;
}
yy643:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= '=') {
if (yych <= 0x00) goto yy641;
if (yych == '\n') goto yy641;
goto yy652;
} else {
if (yych <= 0x7F) {
if (yych <= '>') goto yy663;
goto yy652;
} else {
if (yych <= 0xC1) goto yy641;
if (yych <= 0xF4) goto yy652;
goto yy641;
}
}
yy644:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy641;
if (yych <= 0xBF) goto yy651;
goto yy641;
yy645:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x9F) goto yy641;
if (yych <= 0xBF) goto yy656;
goto yy641;
yy646:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy641;
if (yych <= 0xBF) goto yy656;
goto yy641;
yy647:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy641;
if (yych <= 0x9F) goto yy656;
goto yy641;
yy648:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x8F) goto yy641;
if (yych <= 0xBF) goto yy658;
goto yy641;
yy649:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy641;
if (yych <= 0xBF) goto yy658;
goto yy641;
yy650:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy641;
if (yych <= 0x8F) goto yy658;
goto yy641;
yy651:
yych = *++p;
yy652:
if (yybm[0+yych] & 64) {
goto yy651;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\n') goto yy653;
if (yych <= '?') goto yy654;
} else {
if (yych <= 0xDF) goto yy656;
if (yych <= 0xE0) goto yy657;
goto yy658;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy659;
if (yych <= 0xEF) goto yy658;
goto yy660;
} else {
if (yych <= 0xF3) goto yy661;
if (yych <= 0xF4) goto yy662;
}
}
yy653:
p = marker;
if (yyaccept == 0) {
goto yy641;
} else {
goto yy664;
}
yy654:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy654;
}
if (yych <= 0xDF) {
if (yych <= '=') {
if (yych <= 0x00) goto yy653;
if (yych == '\n') goto yy653;
goto yy651;
} else {
if (yych <= '>') goto yy663;
if (yych <= 0x7F) goto yy651;
if (yych <= 0xC1) goto yy653;
}
} else {
if (yych <= 0xEF) {
if (yych <= 0xE0) goto yy657;
if (yych == 0xED) goto yy659;
goto yy658;
} else {
if (yych <= 0xF0) goto yy660;
if (yych <= 0xF3) goto yy661;
if (yych <= 0xF4) goto yy662;
goto yy653;
}
}
yy656:
yych = *++p;
if (yych <= 0x7F) goto yy653;
if (yych <= 0xBF) goto yy651;
goto yy653;
yy657:
yych = *++p;
if (yych <= 0x9F) goto yy653;
if (yych <= 0xBF) goto yy656;
goto yy653;
yy658:
yych = *++p;
if (yych <= 0x7F) goto yy653;
if (yych <= 0xBF) goto yy656;
goto yy653;
yy659:
yych = *++p;
if (yych <= 0x7F) goto yy653;
if (yych <= 0x9F) goto yy656;
goto yy653;
yy660:
yych = *++p;
if (yych <= 0x8F) goto yy653;
if (yych <= 0xBF) goto yy658;
goto yy653;
yy661:
yych = *++p;
if (yych <= 0x7F) goto yy653;
if (yych <= 0xBF) goto yy658;
goto yy653;
yy662:
yych = *++p;
if (yych <= 0x7F) goto yy653;
if (yych <= 0x8F) goto yy658;
goto yy653;
yy663:
yyaccept = 1;
yych = *(marker = ++p);
if (yybm[0+yych] & 64) {
goto yy651;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\n') goto yy664;
if (yych <= '?') goto yy654;
} else {
if (yych <= 0xDF) goto yy656;
if (yych <= 0xE0) goto yy657;
goto yy658;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy659;
if (yych <= 0xEF) goto yy658;
goto yy660;
} else {
if (yych <= 0xF3) goto yy661;
if (yych <= 0xF4) goto yy662;
}
}
yy664:
{ return (bufsize_t)(p - start); }
}
}
// Try to match an HTML block end line of type 4
bufsize_t _scan_html_block_end_4(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
unsigned int yyaccept = 0;
static const unsigned char yybm[] = {
0, 128, 128, 128, 128, 128, 128, 128,
128, 128, 0, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 64, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yybm[0+yych] & 64) {
goto yy670;
}
if (yych <= 0xE0) {
if (yych <= '\n') {
if (yych <= 0x00) goto yy667;
if (yych <= '\t') goto yy669;
} else {
if (yych <= 0x7F) goto yy669;
if (yych <= 0xC1) goto yy667;
if (yych <= 0xDF) goto yy673;
goto yy674;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy676;
goto yy675;
} else {
if (yych <= 0xF0) goto yy677;
if (yych <= 0xF3) goto yy678;
if (yych <= 0xF4) goto yy679;
}
}
yy667:
++p;
yy668:
{ return 0; }
yy669:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= '\n') {
if (yych <= 0x00) goto yy668;
if (yych <= '\t') goto yy681;
goto yy668;
} else {
if (yych <= 0x7F) goto yy681;
if (yych <= 0xC1) goto yy668;
if (yych <= 0xF4) goto yy681;
goto yy668;
}
yy670:
yyaccept = 1;
yych = *(marker = ++p);
if (yybm[0+yych] & 128) {
goto yy680;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\n') goto yy672;
if (yych <= '>') goto yy670;
} else {
if (yych <= 0xDF) goto yy683;
if (yych <= 0xE0) goto yy684;
goto yy685;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy686;
if (yych <= 0xEF) goto yy685;
goto yy687;
} else {
if (yych <= 0xF3) goto yy688;
if (yych <= 0xF4) goto yy689;
}
}
yy672:
{ return (bufsize_t)(p - start); }
yy673:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy668;
if (yych <= 0xBF) goto yy680;
goto yy668;
yy674:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x9F) goto yy668;
if (yych <= 0xBF) goto yy683;
goto yy668;
yy675:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy668;
if (yych <= 0xBF) goto yy683;
goto yy668;
yy676:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy668;
if (yych <= 0x9F) goto yy683;
goto yy668;
yy677:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x8F) goto yy668;
if (yych <= 0xBF) goto yy685;
goto yy668;
yy678:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy668;
if (yych <= 0xBF) goto yy685;
goto yy668;
yy679:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy668;
if (yych <= 0x8F) goto yy685;
goto yy668;
yy680:
yych = *++p;
yy681:
if (yybm[0+yych] & 128) {
goto yy680;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\n') goto yy682;
if (yych <= '>') goto yy670;
} else {
if (yych <= 0xDF) goto yy683;
if (yych <= 0xE0) goto yy684;
goto yy685;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy686;
if (yych <= 0xEF) goto yy685;
goto yy687;
} else {
if (yych <= 0xF3) goto yy688;
if (yych <= 0xF4) goto yy689;
}
}
yy682:
p = marker;
if (yyaccept == 0) {
goto yy668;
} else {
goto yy672;
}
yy683:
yych = *++p;
if (yych <= 0x7F) goto yy682;
if (yych <= 0xBF) goto yy680;
goto yy682;
yy684:
yych = *++p;
if (yych <= 0x9F) goto yy682;
if (yych <= 0xBF) goto yy683;
goto yy682;
yy685:
yych = *++p;
if (yych <= 0x7F) goto yy682;
if (yych <= 0xBF) goto yy683;
goto yy682;
yy686:
yych = *++p;
if (yych <= 0x7F) goto yy682;
if (yych <= 0x9F) goto yy683;
goto yy682;
yy687:
yych = *++p;
if (yych <= 0x8F) goto yy682;
if (yych <= 0xBF) goto yy685;
goto yy682;
yy688:
yych = *++p;
if (yych <= 0x7F) goto yy682;
if (yych <= 0xBF) goto yy685;
goto yy682;
yy689:
yych = *++p;
if (yych <= 0x7F) goto yy682;
if (yych <= 0x8F) goto yy685;
goto yy682;
}
}
// Try to match an HTML block end line of type 5
bufsize_t _scan_html_block_end_5(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
unsigned int yyaccept = 0;
static const unsigned char yybm[] = {
0, 64, 64, 64, 64, 64, 64, 64,
64, 64, 0, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 128, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych <= 0xDF) {
if (yych <= '\\') {
if (yych <= 0x00) goto yy692;
if (yych != '\n') goto yy694;
} else {
if (yych <= ']') goto yy695;
if (yych <= 0x7F) goto yy694;
if (yych >= 0xC2) goto yy696;
}
} else {
if (yych <= 0xEF) {
if (yych <= 0xE0) goto yy697;
if (yych == 0xED) goto yy699;
goto yy698;
} else {
if (yych <= 0xF0) goto yy700;
if (yych <= 0xF3) goto yy701;
if (yych <= 0xF4) goto yy702;
}
}
yy692:
++p;
yy693:
{ return 0; }
yy694:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= '\n') {
if (yych <= 0x00) goto yy693;
if (yych <= '\t') goto yy704;
goto yy693;
} else {
if (yych <= 0x7F) goto yy704;
if (yych <= 0xC1) goto yy693;
if (yych <= 0xF4) goto yy704;
goto yy693;
}
yy695:
yyaccept = 0;
yych = *(marker = ++p);
if (yybm[0+yych] & 128) {
goto yy714;
}
if (yych <= '\n') {
if (yych <= 0x00) goto yy693;
if (yych <= '\t') goto yy704;
goto yy693;
} else {
if (yych <= 0x7F) goto yy704;
if (yych <= 0xC1) goto yy693;
if (yych <= 0xF4) goto yy704;
goto yy693;
}
yy696:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy693;
if (yych <= 0xBF) goto yy703;
goto yy693;
yy697:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x9F) goto yy693;
if (yych <= 0xBF) goto yy707;
goto yy693;
yy698:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy693;
if (yych <= 0xBF) goto yy707;
goto yy693;
yy699:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy693;
if (yych <= 0x9F) goto yy707;
goto yy693;
yy700:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x8F) goto yy693;
if (yych <= 0xBF) goto yy709;
goto yy693;
yy701:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy693;
if (yych <= 0xBF) goto yy709;
goto yy693;
yy702:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x7F) goto yy693;
if (yych <= 0x8F) goto yy709;
goto yy693;
yy703:
yych = *++p;
yy704:
if (yybm[0+yych] & 64) {
goto yy703;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\n') goto yy705;
if (yych <= ']') goto yy706;
} else {
if (yych <= 0xDF) goto yy707;
if (yych <= 0xE0) goto yy708;
goto yy709;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy710;
if (yych <= 0xEF) goto yy709;
goto yy711;
} else {
if (yych <= 0xF3) goto yy712;
if (yych <= 0xF4) goto yy713;
}
}
yy705:
p = marker;
if (yyaccept == 0) {
goto yy693;
} else {
goto yy717;
}
yy706:
yych = *++p;
if (yybm[0+yych] & 64) {
goto yy703;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\n') goto yy705;
if (yych <= ']') goto yy714;
goto yy705;
} else {
if (yych <= 0xDF) goto yy707;
if (yych <= 0xE0) goto yy708;
goto yy709;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy710;
if (yych <= 0xEF) goto yy709;
goto yy711;
} else {
if (yych <= 0xF3) goto yy712;
if (yych <= 0xF4) goto yy713;
goto yy705;
}
}
yy707:
yych = *++p;
if (yych <= 0x7F) goto yy705;
if (yych <= 0xBF) goto yy703;
goto yy705;
yy708:
yych = *++p;
if (yych <= 0x9F) goto yy705;
if (yych <= 0xBF) goto yy707;
goto yy705;
yy709:
yych = *++p;
if (yych <= 0x7F) goto yy705;
if (yych <= 0xBF) goto yy707;
goto yy705;
yy710:
yych = *++p;
if (yych <= 0x7F) goto yy705;
if (yych <= 0x9F) goto yy707;
goto yy705;
yy711:
yych = *++p;
if (yych <= 0x8F) goto yy705;
if (yych <= 0xBF) goto yy709;
goto yy705;
yy712:
yych = *++p;
if (yych <= 0x7F) goto yy705;
if (yych <= 0xBF) goto yy709;
goto yy705;
yy713:
yych = *++p;
if (yych <= 0x7F) goto yy705;
if (yych <= 0x8F) goto yy709;
goto yy705;
yy714:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy714;
}
if (yych <= 0xDF) {
if (yych <= '=') {
if (yych <= 0x00) goto yy705;
if (yych == '\n') goto yy705;
goto yy703;
} else {
if (yych <= '>') goto yy716;
if (yych <= 0x7F) goto yy703;
if (yych <= 0xC1) goto yy705;
goto yy707;
}
} else {
if (yych <= 0xEF) {
if (yych <= 0xE0) goto yy708;
if (yych == 0xED) goto yy710;
goto yy709;
} else {
if (yych <= 0xF0) goto yy711;
if (yych <= 0xF3) goto yy712;
if (yych <= 0xF4) goto yy713;
goto yy705;
}
}
yy716:
yyaccept = 1;
yych = *(marker = ++p);
if (yybm[0+yych] & 64) {
goto yy703;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= '\n') goto yy717;
if (yych <= ']') goto yy706;
} else {
if (yych <= 0xDF) goto yy707;
if (yych <= 0xE0) goto yy708;
goto yy709;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy710;
if (yych <= 0xEF) goto yy709;
goto yy711;
} else {
if (yych <= 0xF3) goto yy712;
if (yych <= 0xF4) goto yy713;
}
}
yy717:
{ return (bufsize_t)(p - start); }
}
}
// Try to match a link title (in single quotes, in double quotes, or
// in parentheses), returning number of chars matched. Allow one
// level of internal nesting (quotes within quotes).
bufsize_t _scan_link_title(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
unsigned int yyaccept = 0;
static const unsigned char yybm[] = {
0, 208, 208, 208, 208, 208, 208, 208,
208, 208, 208, 208, 208, 208, 208, 208,
208, 208, 208, 208, 208, 208, 208, 208,
208, 208, 208, 208, 208, 208, 208, 208,
208, 208, 192, 208, 208, 208, 208, 144,
80, 80, 208, 208, 208, 208, 208, 208,
208, 208, 208, 208, 208, 208, 208, 208,
208, 208, 208, 208, 208, 208, 208, 208,
208, 208, 208, 208, 208, 208, 208, 208,
208, 208, 208, 208, 208, 208, 208, 208,
208, 208, 208, 208, 208, 208, 208, 208,
208, 208, 208, 208, 32, 208, 208, 208,
208, 208, 208, 208, 208, 208, 208, 208,
208, 208, 208, 208, 208, 208, 208, 208,
208, 208, 208, 208, 208, 208, 208, 208,
208, 208, 208, 208, 208, 208, 208, 208,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych <= '&') {
if (yych == '"') goto yy722;
} else {
if (yych <= '\'') goto yy723;
if (yych <= '(') goto yy724;
}
++p;
yy721:
{ return 0; }
yy722:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x00) goto yy721;
if (yych <= 0x7F) goto yy726;
if (yych <= 0xC1) goto yy721;
if (yych <= 0xF4) goto yy726;
goto yy721;
yy723:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= 0x00) goto yy721;
if (yych <= 0x7F) goto yy740;
if (yych <= 0xC1) goto yy721;
if (yych <= 0xF4) goto yy740;
goto yy721;
yy724:
yyaccept = 0;
yych = *(marker = ++p);
if (yych <= '(') {
if (yych <= 0x00) goto yy721;
if (yych <= '\'') goto yy753;
goto yy721;
} else {
if (yych <= 0x7F) goto yy753;
if (yych <= 0xC1) goto yy721;
if (yych <= 0xF4) goto yy753;
goto yy721;
}
yy725:
yych = *++p;
yy726:
if (yybm[0+yych] & 16) {
goto yy725;
}
if (yych <= 0xE0) {
if (yych <= '\\') {
if (yych <= 0x00) goto yy727;
if (yych <= '"') goto yy728;
goto yy730;
} else {
if (yych <= 0xC1) goto yy727;
if (yych <= 0xDF) goto yy732;
goto yy733;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy735;
goto yy734;
} else {
if (yych <= 0xF0) goto yy736;
if (yych <= 0xF3) goto yy737;
if (yych <= 0xF4) goto yy738;
}
}
yy727:
p = marker;
if (yyaccept <= 1) {
if (yyaccept == 0) {
goto yy721;
} else {
goto yy729;
}
} else {
if (yyaccept == 2) {
goto yy742;
} else {
goto yy755;
}
}
yy728:
++p;
yy729:
{ return (bufsize_t)(p - start); }
yy730:
yych = *++p;
if (yybm[0+yych] & 16) {
goto yy725;
}
if (yych <= 0xE0) {
if (yych <= '\\') {
if (yych <= 0x00) goto yy727;
if (yych <= '"') goto yy765;
goto yy730;
} else {
if (yych <= 0xC1) goto yy727;
if (yych >= 0xE0) goto yy733;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy735;
goto yy734;
} else {
if (yych <= 0xF0) goto yy736;
if (yych <= 0xF3) goto yy737;
if (yych <= 0xF4) goto yy738;
goto yy727;
}
}
yy732:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0xBF) goto yy725;
goto yy727;
yy733:
yych = *++p;
if (yych <= 0x9F) goto yy727;
if (yych <= 0xBF) goto yy732;
goto yy727;
yy734:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0xBF) goto yy732;
goto yy727;
yy735:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0x9F) goto yy732;
goto yy727;
yy736:
yych = *++p;
if (yych <= 0x8F) goto yy727;
if (yych <= 0xBF) goto yy734;
goto yy727;
yy737:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0xBF) goto yy734;
goto yy727;
yy738:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0x8F) goto yy734;
goto yy727;
yy739:
yych = *++p;
yy740:
if (yybm[0+yych] & 64) {
goto yy739;
}
if (yych <= 0xE0) {
if (yych <= '\\') {
if (yych <= 0x00) goto yy727;
if (yych >= '(') goto yy743;
} else {
if (yych <= 0xC1) goto yy727;
if (yych <= 0xDF) goto yy745;
goto yy746;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy748;
goto yy747;
} else {
if (yych <= 0xF0) goto yy749;
if (yych <= 0xF3) goto yy750;
if (yych <= 0xF4) goto yy751;
goto yy727;
}
}
yy741:
++p;
yy742:
{ return (bufsize_t)(p - start); }
yy743:
yych = *++p;
if (yybm[0+yych] & 64) {
goto yy739;
}
if (yych <= 0xE0) {
if (yych <= '\\') {
if (yych <= 0x00) goto yy727;
if (yych <= '\'') goto yy766;
goto yy743;
} else {
if (yych <= 0xC1) goto yy727;
if (yych >= 0xE0) goto yy746;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy748;
goto yy747;
} else {
if (yych <= 0xF0) goto yy749;
if (yych <= 0xF3) goto yy750;
if (yych <= 0xF4) goto yy751;
goto yy727;
}
}
yy745:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0xBF) goto yy739;
goto yy727;
yy746:
yych = *++p;
if (yych <= 0x9F) goto yy727;
if (yych <= 0xBF) goto yy745;
goto yy727;
yy747:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0xBF) goto yy745;
goto yy727;
yy748:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0x9F) goto yy745;
goto yy727;
yy749:
yych = *++p;
if (yych <= 0x8F) goto yy727;
if (yych <= 0xBF) goto yy747;
goto yy727;
yy750:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0xBF) goto yy747;
goto yy727;
yy751:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0x8F) goto yy747;
goto yy727;
yy752:
yych = *++p;
yy753:
if (yybm[0+yych] & 128) {
goto yy752;
}
if (yych <= 0xE0) {
if (yych <= '\\') {
if (yych <= '(') goto yy727;
if (yych >= '*') goto yy756;
} else {
if (yych <= 0xC1) goto yy727;
if (yych <= 0xDF) goto yy758;
goto yy759;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy761;
goto yy760;
} else {
if (yych <= 0xF0) goto yy762;
if (yych <= 0xF3) goto yy763;
if (yych <= 0xF4) goto yy764;
goto yy727;
}
}
yy754:
++p;
yy755:
{ return (bufsize_t)(p - start); }
yy756:
yych = *++p;
if (yych <= 0xDF) {
if (yych <= '[') {
if (yych <= 0x00) goto yy727;
if (yych == ')') goto yy767;
goto yy752;
} else {
if (yych <= '\\') goto yy756;
if (yych <= 0x7F) goto yy752;
if (yych <= 0xC1) goto yy727;
}
} else {
if (yych <= 0xEF) {
if (yych <= 0xE0) goto yy759;
if (yych == 0xED) goto yy761;
goto yy760;
} else {
if (yych <= 0xF0) goto yy762;
if (yych <= 0xF3) goto yy763;
if (yych <= 0xF4) goto yy764;
goto yy727;
}
}
yy758:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0xBF) goto yy752;
goto yy727;
yy759:
yych = *++p;
if (yych <= 0x9F) goto yy727;
if (yych <= 0xBF) goto yy758;
goto yy727;
yy760:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0xBF) goto yy758;
goto yy727;
yy761:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0x9F) goto yy758;
goto yy727;
yy762:
yych = *++p;
if (yych <= 0x8F) goto yy727;
if (yych <= 0xBF) goto yy760;
goto yy727;
yy763:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0xBF) goto yy760;
goto yy727;
yy764:
yych = *++p;
if (yych <= 0x7F) goto yy727;
if (yych <= 0x8F) goto yy760;
goto yy727;
yy765:
yyaccept = 1;
yych = *(marker = ++p);
if (yybm[0+yych] & 16) {
goto yy725;
}
if (yych <= 0xE0) {
if (yych <= '\\') {
if (yych <= 0x00) goto yy729;
if (yych <= '"') goto yy728;
goto yy730;
} else {
if (yych <= 0xC1) goto yy729;
if (yych <= 0xDF) goto yy732;
goto yy733;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy735;
goto yy734;
} else {
if (yych <= 0xF0) goto yy736;
if (yych <= 0xF3) goto yy737;
if (yych <= 0xF4) goto yy738;
goto yy729;
}
}
yy766:
yyaccept = 2;
yych = *(marker = ++p);
if (yybm[0+yych] & 64) {
goto yy739;
}
if (yych <= 0xE0) {
if (yych <= '\\') {
if (yych <= 0x00) goto yy742;
if (yych <= '\'') goto yy741;
goto yy743;
} else {
if (yych <= 0xC1) goto yy742;
if (yych <= 0xDF) goto yy745;
goto yy746;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy748;
goto yy747;
} else {
if (yych <= 0xF0) goto yy749;
if (yych <= 0xF3) goto yy750;
if (yych <= 0xF4) goto yy751;
goto yy742;
}
}
yy767:
yyaccept = 3;
yych = *(marker = ++p);
if (yybm[0+yych] & 128) {
goto yy752;
}
if (yych <= 0xE0) {
if (yych <= '\\') {
if (yych <= '(') goto yy755;
if (yych <= ')') goto yy754;
goto yy756;
} else {
if (yych <= 0xC1) goto yy755;
if (yych <= 0xDF) goto yy758;
goto yy759;
}
} else {
if (yych <= 0xEF) {
if (yych == 0xED) goto yy761;
goto yy760;
} else {
if (yych <= 0xF0) goto yy762;
if (yych <= 0xF3) goto yy763;
if (yych <= 0xF4) goto yy764;
goto yy755;
}
}
}
}
// Match space characters, including newlines.
bufsize_t _scan_spacechars(const unsigned char *p)
{
const unsigned char *start = p; \
{
unsigned char yych;
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 128, 128, 128, 128, 128, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
128, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yybm[0+yych] & 128) {
goto yy772;
}
++p;
{ return 0; }
yy772:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy772;
}
{ return (bufsize_t)(p - start); }
}
}
// Match ATX heading start.
bufsize_t _scan_atx_heading_start(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 128, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
128, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych == '#') goto yy779;
++p;
yy778:
{ return 0; }
yy779:
yych = *(marker = ++p);
if (yybm[0+yych] & 128) {
goto yy780;
}
if (yych <= '\f') {
if (yych <= 0x08) goto yy778;
if (yych <= '\n') goto yy783;
goto yy778;
} else {
if (yych <= '\r') goto yy783;
if (yych == '#') goto yy784;
goto yy778;
}
yy780:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy780;
}
yy782:
{ return (bufsize_t)(p - start); }
yy783:
++p;
goto yy782;
yy784:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy780;
}
if (yych <= '\f') {
if (yych <= 0x08) goto yy785;
if (yych <= '\n') goto yy783;
} else {
if (yych <= '\r') goto yy783;
if (yych == '#') goto yy786;
}
yy785:
p = marker;
goto yy778;
yy786:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy780;
}
if (yych <= '\f') {
if (yych <= 0x08) goto yy785;
if (yych <= '\n') goto yy783;
goto yy785;
} else {
if (yych <= '\r') goto yy783;
if (yych != '#') goto yy785;
}
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy780;
}
if (yych <= '\f') {
if (yych <= 0x08) goto yy785;
if (yych <= '\n') goto yy783;
goto yy785;
} else {
if (yych <= '\r') goto yy783;
if (yych != '#') goto yy785;
}
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy780;
}
if (yych <= '\f') {
if (yych <= 0x08) goto yy785;
if (yych <= '\n') goto yy783;
goto yy785;
} else {
if (yych <= '\r') goto yy783;
if (yych != '#') goto yy785;
}
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy780;
}
if (yych <= 0x08) goto yy785;
if (yych <= '\n') goto yy783;
if (yych == '\r') goto yy783;
goto yy785;
}
}
// Match setext heading line. Return 1 for level-1 heading,
// 2 for level-2, 0 for no match.
bufsize_t _scan_setext_heading_line(const unsigned char *p)
{
const unsigned char *marker = NULL;
{
unsigned char yych;
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 32, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
32, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 64, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 128, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych == '-') goto yy794;
if (yych == '=') goto yy795;
++p;
yy793:
{ return 0; }
yy794:
yych = *(marker = ++p);
if (yybm[0+yych] & 64) {
goto yy801;
}
if (yych <= '\f') {
if (yych <= 0x08) goto yy793;
if (yych <= '\n') goto yy797;
goto yy793;
} else {
if (yych <= '\r') goto yy797;
if (yych == ' ') goto yy797;
goto yy793;
}
yy795:
yych = *(marker = ++p);
if (yybm[0+yych] & 128) {
goto yy807;
}
if (yych <= '\f') {
if (yych <= 0x08) goto yy793;
if (yych <= '\n') goto yy804;
goto yy793;
} else {
if (yych <= '\r') goto yy804;
if (yych == ' ') goto yy804;
goto yy793;
}
yy796:
yych = *++p;
yy797:
if (yybm[0+yych] & 32) {
goto yy796;
}
if (yych <= 0x08) goto yy798;
if (yych <= '\n') goto yy799;
if (yych == '\r') goto yy799;
yy798:
p = marker;
goto yy793;
yy799:
++p;
{ return 2; }
yy801:
yych = *++p;
if (yybm[0+yych] & 32) {
goto yy796;
}
if (yych <= '\f') {
if (yych <= 0x08) goto yy798;
if (yych <= '\n') goto yy799;
goto yy798;
} else {
if (yych <= '\r') goto yy799;
if (yych == '-') goto yy801;
goto yy798;
}
yy803:
yych = *++p;
yy804:
if (yych <= '\f') {
if (yych <= 0x08) goto yy798;
if (yych <= '\t') goto yy803;
if (yych >= '\v') goto yy798;
} else {
if (yych <= '\r') goto yy805;
if (yych == ' ') goto yy803;
goto yy798;
}
yy805:
++p;
{ return 1; }
yy807:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy807;
}
if (yych <= '\f') {
if (yych <= 0x08) goto yy798;
if (yych <= '\t') goto yy803;
if (yych <= '\n') goto yy805;
goto yy798;
} else {
if (yych <= '\r') goto yy805;
if (yych == ' ') goto yy803;
goto yy798;
}
}
}
// Scan an opening code fence.
bufsize_t _scan_open_code_fence(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
static const unsigned char yybm[] = {
0, 192, 192, 192, 192, 192, 192, 192,
192, 192, 0, 192, 192, 0, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192,
144, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 224, 192,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych == '`') goto yy813;
if (yych == '~') goto yy814;
++p;
yy812:
{ return 0; }
yy813:
yych = *(marker = ++p);
if (yych == '`') goto yy815;
goto yy812;
yy814:
yych = *(marker = ++p);
if (yych == '~') goto yy817;
goto yy812;
yy815:
yych = *++p;
if (yybm[0+yych] & 16) {
goto yy818;
}
yy816:
p = marker;
goto yy812;
yy817:
yych = *++p;
if (yybm[0+yych] & 32) {
goto yy820;
}
goto yy816;
yy818:
yych = *++p;
if (yybm[0+yych] & 16) {
goto yy818;
}
if (yych <= 0xDF) {
if (yych <= '\f') {
if (yych <= 0x00) goto yy816;
if (yych == '\n') {
marker = p;
goto yy824;
}
marker = p;
goto yy822;
} else {
if (yych <= '\r') {
marker = p;
goto yy824;
}
if (yych <= 0x7F) {
marker = p;
goto yy822;
}
if (yych <= 0xC1) goto yy816;
marker = p;
goto yy826;
}
} else {
if (yych <= 0xEF) {
if (yych <= 0xE0) {
marker = p;
goto yy827;
}
if (yych == 0xED) {
marker = p;
goto yy829;
}
marker = p;
goto yy828;
} else {
if (yych <= 0xF0) {
marker = p;
goto yy830;
}
if (yych <= 0xF3) {
marker = p;
goto yy831;
}
if (yych <= 0xF4) {
marker = p;
goto yy832;
}
goto yy816;
}
}
yy820:
yych = *++p;
if (yybm[0+yych] & 32) {
goto yy820;
}
if (yych <= 0xDF) {
if (yych <= '\f') {
if (yych <= 0x00) goto yy816;
if (yych == '\n') {
marker = p;
goto yy835;
}
marker = p;
goto yy833;
} else {
if (yych <= '\r') {
marker = p;
goto yy835;
}
if (yych <= 0x7F) {
marker = p;
goto yy833;
}
if (yych <= 0xC1) goto yy816;
marker = p;
goto yy837;
}
} else {
if (yych <= 0xEF) {
if (yych <= 0xE0) {
marker = p;
goto yy838;
}
if (yych == 0xED) {
marker = p;
goto yy840;
}
marker = p;
goto yy839;
} else {
if (yych <= 0xF0) {
marker = p;
goto yy841;
}
if (yych <= 0xF3) {
marker = p;
goto yy842;
}
if (yych <= 0xF4) {
marker = p;
goto yy843;
}
goto yy816;
}
}
yy822:
yych = *++p;
if (yybm[0+yych] & 64) {
goto yy822;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= 0x00) goto yy816;
if (yych >= 0x0E) goto yy816;
} else {
if (yych <= 0xDF) goto yy826;
if (yych <= 0xE0) goto yy827;
goto yy828;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy829;
if (yych <= 0xEF) goto yy828;
goto yy830;
} else {
if (yych <= 0xF3) goto yy831;
if (yych <= 0xF4) goto yy832;
goto yy816;
}
}
yy824:
++p;
p = marker;
{ return (bufsize_t)(p - start); }
yy826:
yych = *++p;
if (yych <= 0x7F) goto yy816;
if (yych <= 0xBF) goto yy822;
goto yy816;
yy827:
yych = *++p;
if (yych <= 0x9F) goto yy816;
if (yych <= 0xBF) goto yy826;
goto yy816;
yy828:
yych = *++p;
if (yych <= 0x7F) goto yy816;
if (yych <= 0xBF) goto yy826;
goto yy816;
yy829:
yych = *++p;
if (yych <= 0x7F) goto yy816;
if (yych <= 0x9F) goto yy826;
goto yy816;
yy830:
yych = *++p;
if (yych <= 0x8F) goto yy816;
if (yych <= 0xBF) goto yy828;
goto yy816;
yy831:
yych = *++p;
if (yych <= 0x7F) goto yy816;
if (yych <= 0xBF) goto yy828;
goto yy816;
yy832:
yych = *++p;
if (yych <= 0x7F) goto yy816;
if (yych <= 0x8F) goto yy828;
goto yy816;
yy833:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy833;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= 0x00) goto yy816;
if (yych >= 0x0E) goto yy816;
} else {
if (yych <= 0xDF) goto yy837;
if (yych <= 0xE0) goto yy838;
goto yy839;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy840;
if (yych <= 0xEF) goto yy839;
goto yy841;
} else {
if (yych <= 0xF3) goto yy842;
if (yych <= 0xF4) goto yy843;
goto yy816;
}
}
yy835:
++p;
p = marker;
{ return (bufsize_t)(p - start); }
yy837:
yych = *++p;
if (yych <= 0x7F) goto yy816;
if (yych <= 0xBF) goto yy833;
goto yy816;
yy838:
yych = *++p;
if (yych <= 0x9F) goto yy816;
if (yych <= 0xBF) goto yy837;
goto yy816;
yy839:
yych = *++p;
if (yych <= 0x7F) goto yy816;
if (yych <= 0xBF) goto yy837;
goto yy816;
yy840:
yych = *++p;
if (yych <= 0x7F) goto yy816;
if (yych <= 0x9F) goto yy837;
goto yy816;
yy841:
yych = *++p;
if (yych <= 0x8F) goto yy816;
if (yych <= 0xBF) goto yy839;
goto yy816;
yy842:
yych = *++p;
if (yych <= 0x7F) goto yy816;
if (yych <= 0xBF) goto yy839;
goto yy816;
yy843:
yych = *++p;
if (yych <= 0x7F) goto yy816;
if (yych <= 0x8F) goto yy839;
goto yy816;
}
}
// Scan a closing code fence with length at least len.
bufsize_t _scan_close_code_fence(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 128, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
128, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
32, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 64, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych == '`') goto yy848;
if (yych == '~') goto yy849;
++p;
yy847:
{ return 0; }
yy848:
yych = *(marker = ++p);
if (yych == '`') goto yy850;
goto yy847;
yy849:
yych = *(marker = ++p);
if (yych == '~') goto yy852;
goto yy847;
yy850:
yych = *++p;
if (yybm[0+yych] & 32) {
goto yy853;
}
yy851:
p = marker;
goto yy847;
yy852:
yych = *++p;
if (yybm[0+yych] & 64) {
goto yy855;
}
goto yy851;
yy853:
yych = *++p;
if (yybm[0+yych] & 32) {
goto yy853;
}
if (yych <= '\f') {
if (yych <= 0x08) goto yy851;
if (yych <= '\t') {
marker = p;
goto yy857;
}
if (yych <= '\n') {
marker = p;
goto yy859;
}
goto yy851;
} else {
if (yych <= '\r') {
marker = p;
goto yy859;
}
if (yych == ' ') {
marker = p;
goto yy857;
}
goto yy851;
}
yy855:
yych = *++p;
if (yybm[0+yych] & 64) {
goto yy855;
}
if (yych <= '\f') {
if (yych <= 0x08) goto yy851;
if (yych <= '\t') {
marker = p;
goto yy861;
}
if (yych <= '\n') {
marker = p;
goto yy863;
}
goto yy851;
} else {
if (yych <= '\r') {
marker = p;
goto yy863;
}
if (yych == ' ') {
marker = p;
goto yy861;
}
goto yy851;
}
yy857:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy857;
}
if (yych <= 0x08) goto yy851;
if (yych <= '\n') goto yy859;
if (yych != '\r') goto yy851;
yy859:
++p;
p = marker;
{ return (bufsize_t)(p - start); }
yy861:
yych = *++p;
if (yych <= '\f') {
if (yych <= 0x08) goto yy851;
if (yych <= '\t') goto yy861;
if (yych >= '\v') goto yy851;
} else {
if (yych <= '\r') goto yy863;
if (yych == ' ') goto yy861;
goto yy851;
}
yy863:
++p;
p = marker;
{ return (bufsize_t)(p - start); }
}
}
// Scans an entity.
// Returns number of chars matched.
bufsize_t _scan_entity(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
yych = *p;
if (yych == '&') goto yy869;
++p;
yy868:
{ return 0; }
yy869:
yych = *(marker = ++p);
if (yych <= '@') {
if (yych != '#') goto yy868;
} else {
if (yych <= 'Z') goto yy872;
if (yych <= '`') goto yy868;
if (yych <= 'z') goto yy872;
goto yy868;
}
yych = *++p;
if (yych <= 'W') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy873;
} else {
if (yych <= 'X') goto yy874;
if (yych == 'x') goto yy874;
}
yy871:
p = marker;
goto yy868;
yy872:
yych = *++p;
if (yych <= '@') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy875;
goto yy871;
} else {
if (yych <= 'Z') goto yy875;
if (yych <= '`') goto yy871;
if (yych <= 'z') goto yy875;
goto yy871;
}
yy873:
yych = *++p;
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy876;
if (yych == ';') goto yy877;
goto yy871;
yy874:
yych = *++p;
if (yych <= '@') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy879;
goto yy871;
} else {
if (yych <= 'F') goto yy879;
if (yych <= '`') goto yy871;
if (yych <= 'f') goto yy879;
goto yy871;
}
yy875:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy880;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
goto yy880;
} else {
if (yych <= '`') goto yy871;
if (yych <= 'z') goto yy880;
goto yy871;
}
}
yy876:
yych = *++p;
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy881;
if (yych != ';') goto yy871;
yy877:
++p;
{ return (bufsize_t)(p - start); }
yy879:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy882;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'F') {
if (yych <= '@') goto yy871;
goto yy882;
} else {
if (yych <= '`') goto yy871;
if (yych <= 'f') goto yy882;
goto yy871;
}
}
yy880:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy883;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
goto yy883;
} else {
if (yych <= '`') goto yy871;
if (yych <= 'z') goto yy883;
goto yy871;
}
}
yy881:
yych = *++p;
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy884;
if (yych == ';') goto yy877;
goto yy871;
yy882:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy885;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'F') {
if (yych <= '@') goto yy871;
goto yy885;
} else {
if (yych <= '`') goto yy871;
if (yych <= 'f') goto yy885;
goto yy871;
}
}
yy883:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy886;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
goto yy886;
} else {
if (yych <= '`') goto yy871;
if (yych <= 'z') goto yy886;
goto yy871;
}
}
yy884:
yych = *++p;
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy887;
if (yych == ';') goto yy877;
goto yy871;
yy885:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy888;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'F') {
if (yych <= '@') goto yy871;
goto yy888;
} else {
if (yych <= '`') goto yy871;
if (yych <= 'f') goto yy888;
goto yy871;
}
}
yy886:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy889;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
goto yy889;
} else {
if (yych <= '`') goto yy871;
if (yych <= 'z') goto yy889;
goto yy871;
}
}
yy887:
yych = *++p;
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy890;
if (yych == ';') goto yy877;
goto yy871;
yy888:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy891;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'F') {
if (yych <= '@') goto yy871;
goto yy891;
} else {
if (yych <= '`') goto yy871;
if (yych <= 'f') goto yy891;
goto yy871;
}
}
yy889:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy892;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
goto yy892;
} else {
if (yych <= '`') goto yy871;
if (yych <= 'z') goto yy892;
goto yy871;
}
}
yy890:
yych = *++p;
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy893;
if (yych == ';') goto yy877;
goto yy871;
yy891:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy893;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'F') {
if (yych <= '@') goto yy871;
goto yy893;
} else {
if (yych <= '`') goto yy871;
if (yych <= 'f') goto yy893;
goto yy871;
}
}
yy892:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy894;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
goto yy894;
} else {
if (yych <= '`') goto yy871;
if (yych <= 'z') goto yy894;
goto yy871;
}
}
yy893:
yych = *++p;
if (yych == ';') goto yy877;
goto yy871;
yy894:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy895;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy895:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy896;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy896:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy897;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy897:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy898;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy898:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy899;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy899:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy900;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy900:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy901;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy901:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy902;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy902:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy903;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy903:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy904;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy904:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy905;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy905:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy906;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy906:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy907;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy907:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy908;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy908:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy909;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy909:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy910;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy910:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy911;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy911:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy912;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy912:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy913;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy913:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy914;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy914:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy915;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy915:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy916;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy916:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy917;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
} else {
if (yych <= '`') goto yy871;
if (yych >= '{') goto yy871;
}
}
yy917:
yych = *++p;
if (yych <= ';') {
if (yych <= '/') goto yy871;
if (yych <= '9') goto yy893;
if (yych <= ':') goto yy871;
goto yy877;
} else {
if (yych <= 'Z') {
if (yych <= '@') goto yy871;
goto yy893;
} else {
if (yych <= '`') goto yy871;
if (yych <= 'z') goto yy893;
goto yy871;
}
}
}
}
// Returns positive value if a URL begins in a way that is potentially
// dangerous, with javascript:, vbscript:, file:, or data:, otherwise 0.
bufsize_t _scan_dangerous_url(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
unsigned int yyaccept = 0;
yych = *p;
if (yych <= 'V') {
if (yych <= 'F') {
if (yych == 'D') goto yy922;
if (yych >= 'F') goto yy923;
} else {
if (yych == 'J') goto yy924;
if (yych >= 'V') goto yy925;
}
} else {
if (yych <= 'f') {
if (yych == 'd') goto yy922;
if (yych >= 'f') goto yy923;
} else {
if (yych <= 'j') {
if (yych >= 'j') goto yy924;
} else {
if (yych == 'v') goto yy925;
}
}
}
++p;
yy921:
{ return 0; }
yy922:
yyaccept = 0;
yych = *(marker = ++p);
if (yych == 'A') goto yy926;
if (yych == 'a') goto yy926;
goto yy921;
yy923:
yyaccept = 0;
yych = *(marker = ++p);
if (yych == 'I') goto yy928;
if (yych == 'i') goto yy928;
goto yy921;
yy924:
yyaccept = 0;
yych = *(marker = ++p);
if (yych == 'A') goto yy929;
if (yych == 'a') goto yy929;
goto yy921;
yy925:
yyaccept = 0;
yych = *(marker = ++p);
if (yych == 'B') goto yy930;
if (yych == 'b') goto yy930;
goto yy921;
yy926:
yych = *++p;
if (yych == 'T') goto yy931;
if (yych == 't') goto yy931;
yy927:
p = marker;
if (yyaccept == 0) {
goto yy921;
} else {
goto yy939;
}
yy928:
yych = *++p;
if (yych == 'L') goto yy932;
if (yych == 'l') goto yy932;
goto yy927;
yy929:
yych = *++p;
if (yych == 'V') goto yy933;
if (yych == 'v') goto yy933;
goto yy927;
yy930:
yych = *++p;
if (yych == 'S') goto yy934;
if (yych == 's') goto yy934;
goto yy927;
yy931:
yych = *++p;
if (yych == 'A') goto yy935;
if (yych == 'a') goto yy935;
goto yy927;
yy932:
yych = *++p;
if (yych == 'E') goto yy936;
if (yych == 'e') goto yy936;
goto yy927;
yy933:
yych = *++p;
if (yych == 'A') goto yy930;
if (yych == 'a') goto yy930;
goto yy927;
yy934:
yych = *++p;
if (yych == 'C') goto yy937;
if (yych == 'c') goto yy937;
goto yy927;
yy935:
yych = *++p;
if (yych == ':') goto yy938;
goto yy927;
yy936:
yych = *++p;
if (yych == ':') goto yy940;
goto yy927;
yy937:
yych = *++p;
if (yych == 'R') goto yy941;
if (yych == 'r') goto yy941;
goto yy927;
yy938:
yyaccept = 1;
yych = *(marker = ++p);
if (yych == 'I') goto yy942;
if (yych == 'i') goto yy942;
yy939:
{ return (bufsize_t)(p - start); }
yy940:
++p;
goto yy939;
yy941:
yych = *++p;
if (yych == 'I') goto yy943;
if (yych == 'i') goto yy943;
goto yy927;
yy942:
yych = *++p;
if (yych == 'M') goto yy944;
if (yych == 'm') goto yy944;
goto yy927;
yy943:
yych = *++p;
if (yych == 'P') goto yy945;
if (yych == 'p') goto yy945;
goto yy927;
yy944:
yych = *++p;
if (yych == 'A') goto yy946;
if (yych == 'a') goto yy946;
goto yy927;
yy945:
yych = *++p;
if (yych == 'T') goto yy936;
if (yych == 't') goto yy936;
goto yy927;
yy946:
yych = *++p;
if (yych == 'G') goto yy947;
if (yych != 'g') goto yy927;
yy947:
yych = *++p;
if (yych == 'E') goto yy948;
if (yych != 'e') goto yy927;
yy948:
yych = *++p;
if (yych != '/') goto yy927;
yych = *++p;
if (yych <= 'W') {
if (yych <= 'J') {
if (yych == 'G') goto yy950;
if (yych <= 'I') goto yy927;
goto yy951;
} else {
if (yych == 'P') goto yy952;
if (yych <= 'V') goto yy927;
goto yy953;
}
} else {
if (yych <= 'j') {
if (yych == 'g') goto yy950;
if (yych <= 'i') goto yy927;
goto yy951;
} else {
if (yych <= 'p') {
if (yych <= 'o') goto yy927;
goto yy952;
} else {
if (yych == 'w') goto yy953;
goto yy927;
}
}
}
yy950:
yych = *++p;
if (yych == 'I') goto yy954;
if (yych == 'i') goto yy954;
goto yy927;
yy951:
yych = *++p;
if (yych == 'P') goto yy955;
if (yych == 'p') goto yy955;
goto yy927;
yy952:
yych = *++p;
if (yych == 'N') goto yy956;
if (yych == 'n') goto yy956;
goto yy927;
yy953:
yych = *++p;
if (yych == 'E') goto yy957;
if (yych == 'e') goto yy957;
goto yy927;
yy954:
yych = *++p;
if (yych == 'F') goto yy958;
if (yych == 'f') goto yy958;
goto yy927;
yy955:
yych = *++p;
if (yych == 'E') goto yy956;
if (yych != 'e') goto yy927;
yy956:
yych = *++p;
if (yych == 'G') goto yy958;
if (yych == 'g') goto yy958;
goto yy927;
yy957:
yych = *++p;
if (yych == 'B') goto yy960;
if (yych == 'b') goto yy960;
goto yy927;
yy958:
++p;
{ return 0; }
yy960:
yych = *++p;
if (yych == 'P') goto yy958;
if (yych == 'p') goto yy958;
goto yy927;
}
}
// Scans a footnote definition opening.
bufsize_t _scan_footnote_definition(const unsigned char *p)
{
const unsigned char *marker = NULL;
const unsigned char *start = p;
{
unsigned char yych;
static const unsigned char yybm[] = {
0, 64, 64, 64, 64, 64, 64, 64,
64, 128, 0, 64, 64, 0, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
128, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 0, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
yych = *p;
if (yych == '[') goto yy965;
++p;
yy964:
{ return 0; }
yy965:
yych = *(marker = ++p);
if (yych != '^') goto yy964;
yych = *++p;
if (yych != ']') goto yy969;
yy967:
p = marker;
goto yy964;
yy968:
yych = *++p;
yy969:
if (yybm[0+yych] & 64) {
goto yy968;
}
if (yych <= 0xEC) {
if (yych <= 0xC1) {
if (yych <= ' ') goto yy967;
if (yych <= ']') goto yy977;
goto yy967;
} else {
if (yych <= 0xDF) goto yy970;
if (yych <= 0xE0) goto yy971;
goto yy972;
}
} else {
if (yych <= 0xF0) {
if (yych <= 0xED) goto yy973;
if (yych <= 0xEF) goto yy972;
goto yy974;
} else {
if (yych <= 0xF3) goto yy975;
if (yych <= 0xF4) goto yy976;
goto yy967;
}
}
yy970:
yych = *++p;
if (yych <= 0x7F) goto yy967;
if (yych <= 0xBF) goto yy968;
goto yy967;
yy971:
yych = *++p;
if (yych <= 0x9F) goto yy967;
if (yych <= 0xBF) goto yy970;
goto yy967;
yy972:
yych = *++p;
if (yych <= 0x7F) goto yy967;
if (yych <= 0xBF) goto yy970;
goto yy967;
yy973:
yych = *++p;
if (yych <= 0x7F) goto yy967;
if (yych <= 0x9F) goto yy970;
goto yy967;
yy974:
yych = *++p;
if (yych <= 0x8F) goto yy967;
if (yych <= 0xBF) goto yy972;
goto yy967;
yy975:
yych = *++p;
if (yych <= 0x7F) goto yy967;
if (yych <= 0xBF) goto yy972;
goto yy967;
yy976:
yych = *++p;
if (yych <= 0x7F) goto yy967;
if (yych <= 0x8F) goto yy972;
goto yy967;
yy977:
yych = *++p;
if (yych != ':') goto yy967;
yy978:
yych = *++p;
if (yybm[0+yych] & 128) {
goto yy978;
}
{ return (bufsize_t)(p - start); }
}
}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/config.h.in | #ifndef CMARK_CONFIG_H
#define CMARK_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
#cmakedefine HAVE_STDBOOL_H
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#elif !defined(__cplusplus)
typedef char bool;
#endif
#cmakedefine HAVE___BUILTIN_EXPECT
#cmakedefine HAVE___ATTRIBUTE__
#ifdef HAVE___ATTRIBUTE__
#define CMARK_ATTRIBUTE(list) __attribute__ (list)
#else
#define CMARK_ATTRIBUTE(list)
#endif
#ifndef CMARK_INLINE
#if defined(_MSC_VER) && !defined(__cplusplus)
#define CMARK_INLINE __inline
#else
#define CMARK_INLINE inline
#endif
#endif
/* snprintf and vsnprintf fallbacks for MSVC before 2015,
due to Valentin Milea http://stackoverflow.com/questions/2915672/
*/
#if defined(_MSC_VER) && _MSC_VER < 1900
#include <stdio.h>
#include <stdarg.h>
#define snprintf c99_snprintf
#define vsnprintf c99_vsnprintf
CMARK_INLINE int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
{
int count = -1;
if (size != 0)
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
if (count == -1)
count = _vscprintf(format, ap);
return count;
}
CMARK_INLINE int c99_snprintf(char *outBuf, size_t size, const char *format, ...)
{
int count;
va_list ap;
va_start(ap, format);
count = c99_vsnprintf(outBuf, size, format, ap);
va_end(ap);
return count;
}
#endif
#ifdef __cplusplus
}
#endif
#endif
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/libcmark-gfm.pc.in | prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=@CMAKE_INSTALL_PREFIX@/@libdir@
includedir=@CMAKE_INSTALL_PREFIX@/include
Name: libcmark-gfm
Description: CommonMark parsing, rendering, and manipulation with GitHub Flavored Markdown extensions
Version: @PROJECT_VERSION@
Libs: -L${libdir} -lcmark-gfm -lcmark-gfm-extensions
Cflags: -I${includedir}
|
0 | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm | repos/Ziguana-Game-System/old-version/libs/lola/libs/koino/vendor/cmark-gfm/src/footnotes.h | #ifndef CMARK_FOOTNOTES_H
#define CMARK_FOOTNOTES_H
#include "map.h"
#ifdef __cplusplus
extern "C" {
#endif
struct cmark_footnote {
cmark_map_entry entry;
cmark_node *node;
unsigned int ix;
};
typedef struct cmark_footnote cmark_footnote;
void cmark_footnote_create(cmark_map *map, cmark_node *node);
cmark_map *cmark_footnote_map_new(cmark_mem *mem);
#ifdef __cplusplus
}
#endif
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.