Skip to content

Instantly share code, notes, and snippets.

View Frityet's full-sized avatar
😁
I have like 60 projects that i am not doing

Frityet

😁
I have like 60 projects that i am not doing
View GitHub Profile
@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;
// Helper function to calculate the size of a type based on its encoding
size_t sizeForEncoding(const char *encoding) {
switch (*encoding) {
case 'c': return sizeof(char);
case 's': return sizeof(short);
case 'i': return sizeof(int);
case 'q': return sizeof(long);
case 'Q': return sizeof(size_t);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdint.h>
#include <sys/mman.h>
#include <unistd.h>
#pragma clang assume_nonnull begin
-- Constants for chunk size
local arg = {...}
---@param called string
---@return (string | integer)?
local function get_arg(called)
local tofind = "--"..called
for i, v in ipairs(arg) do
if v == tofind then
local val = arg[i+1]
local socket = require("socket")
local xml_gen = require("x-gen")
local xml = xml_gen.xml
---@param document XML.Node
local function build_response(document)
local str = "<!DOCTYPE html>"..tostring(document)
return ([[
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: %d
#define _XOPEN_SOURCE 700
#include <signal.h>
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <stdbool.h>
@Frityet
Frityet / CArray.h
Last active March 30, 2024 20:23
Objective C Carray
#import <ObjFW/ObjFW.h>
OF_ASSUME_NONNULL_BEGIN
#define $_concat(a, b) a##b
#define $concat(...) $_concat(__VA_ARGS__)
#if !defined($carray_name)
# define $carray_name(T) $concat(T, Array)