Skip to content

Instantly share code, notes, and snippets.

View Frityet's full-sized avatar
😁
I LOVE LUA! ❤️

Frityet

😁
I LOVE LUA! ❤️
View GitHub Profile
#include <type_traits>
#define $return using result =
#define $apply using apply =
template<class A, class B>
constexpr auto equals = std::is_same_v<A, B>;
template<typename T>
using call = typename T::result;
#include <cstdio>
#include <string_view>
#include <string>
#include <memory>
#include <unordered_map>
#include <typeindex>
#include <variant>
#include <optional>
#include <functional>
#include <type_traits>
#!/usr/bin/env luajit
local lfs = require("lfs")
local function fail(message)
error(message, 0)
end
local function printf(fmt, ...)
io.write(string.format(fmt, ...))
@Frityet
Frityet / fsm.lua
Last active February 3, 2026 17:41
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local assert = _tl_compat and _tl_compat.assert or assert; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local table = _tl_compat and _tl_compat.table or table
local record Sheep
_naked: boolean
_name: string
__index: Sheep
end
Sheep.__index = Sheep
-- impl Sheep
function Sheep:shear()
print(self._name, "gets a haircut!");
local interface Animal
-- Associated function signature; `Self` refers to the implementor type.
new: function(string): self
-- Method signatures; these will return a string.
name: function(self): string
noise: function(self): string
talk: function(self)
end
@Frityet
Frityet / fsm.tl
Last active September 3, 2025 19:52
-- -*- mode: lua -*-
local macro state_machine!(name: Expression, spec: Expression, ...: Expression): Statement
local err = error
local blockmod = require("teal.block")
local BIDX = blockmod.BLOCK_INDEXES
local function expect_ident(n: any): any
if not n or (n.kind ~= "identifier" and n.kind ~= "variable") then
err("first argument must be an identifier for the machine name")
end
#include <cxxabi.h>
#include <execinfo.h>
#include <format>
#include <functional>
#include <string>
#include <unordered_map>
#include <vector>
#define println(...) puts(std::format(__VA_ARGS__).c_str())
struct HijackEntryBase {

Hand-Written C11 Parser with AST and API

The request is for a comprehensive C11 parser with syntactic parsing, an AST, and traversal API. Other specifics include lexing, parsing from scratch, and a detailed main program for testing.

Searched for handwritten C parser C11 example

#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@interface HTMLNode : NSObject
@property (nonatomic, copy) NSString *tag;
@property (nonatomic, strong) NSMutableDictionary<NSString *, NSString *> *attributes;
@property (nonatomic, strong) NSMutableArray *children;
+ (instancetype)element: (NSString *)tag;