Skip to content

Instantly share code, notes, and snippets.

View alogic0's full-sized avatar

Oleg Tsybulskyi alogic0

View GitHub Profile
@alogic0
alogic0 / lexer_1.md
Created April 18, 2026 07:00
Lexer 1

To understand Tree-sitter using Zig, we start with the absolute atom of parsing: the Lexer.

In a traditional compiler, the Lexer (or Scanner) turns a string of characters into a stream of Tokens. In an incremental system like Tree-sitter, the lexer must be able to start at any byte offset, but for our first step, we will build a linear Lexer in Zig.


1. The Core Data Structures

First, we define what our "Tokens" look like. Using a Zig enum is perfect for this because we can use tagged unions later for more complex metadata.

@alogic0
alogic0 / tree-sitter-learning-path.md
Last active April 18, 2026 06:32
Parser generator

Tree-sitter is a high-speed, incremental parsing system that has revolutionized how editors like Neovim and VS Code handle syntax highlighting and code navigation. To understand its algorithms, you need to bridge the gap between traditional context-free grammars and modern incremental state management.

Here is your structured learning path to mastering the mechanics behind Tree-sitter.


Phase 1: The Theoretical Foundation

Before diving into Tree-sitter’s source code, you must understand the "Classical" way of parsing. Tree-sitter is based on LR(1) parsing, but with specific enhancements.

@alogic0
alogic0 / analytic
Created April 17, 2026 02:58
gen-z-sitter_opiniot.txt
✦ This repository is a highly disciplined and architecturally mature rewrite of the Tree-sitter generator in Zig. It stands out for its rigorous
engineering standards, incremental milestone-driven approach, and clear focus on real-world compatibility.
Here is a breakdown of my assessment:
1. Exceptional Planning and Organization
The project is one of the most well-documented "work-in-progress" compilers I've seen.
* Milestone Rigor: Every stage of development is tracked via specific MILESTONE_X_IMPLEMENTATION_CHECKLIST.md files. You have successfully
navigated from basic scaffold (M0) all the way through complex parse-table serialization and real-world external scanner integration (M31).
* The Master Plan: MASTER_PLAN.md and MASTER_PLAN_2.md provide a high-level strategic roadmap that balances internal architectural purity with the
@alogic0
alogic0 / fog2_12.txt
Created September 24, 2024 14:02
English exercise
Ex 1
2. She's been writing articles about global warming since last month.
3. They haven't been living in New York for a few years.
4. They've been living in Toronto since 2013.
5. They've been driving a fuel-efficient car since last year.
6. Pete hasn't been working since last year.
7. Pete and Amanda have been thinking of treveling to Africa since last year.
8. Amanda has been reading a lot about Africa for a few months.
9. Pete has been studying zoology back in school since last month.
@alogic0
alogic0 / money.md
Last active September 22, 2024 09:12
English phrases and words related to money, expenses, and taxes

Certainly! Here are some essential English phrases and words related to money, expenses, and taxes that your friend should know when living in Memphis (or anywhere in the United States):

Money and Banking

  • Currency: The official currency is the US Dollar (USD).
  • Bank Account: To open a bank account, you might need an ID and proof of address.
  • Checking Account: An account used for daily transactions.
  • Savings Account: An account used to save money and earn interest.
  • Debit Card: A card linked to your bank account for transactions.
  • Credit Card: A card that allows you to borrow money up to a certain limit.
  • ATM (Automated Teller Machine): A machine to withdraw or deposit money.

https://www.youtube.com/watch?v=Yy5cKX4jBkQ
Britney Spears - Born To Make You Happy

I'm sitting here alone within up in my room
I'm thinking up of about the times that we've been through
Oh, my love

I'm looking on at a picture in my hand
Trying to my best to understand
I really wanna know what we did wrong

@alogic0
alogic0 / zig_learn_video.md
Last active August 19, 2023 16:54
Zig learn video
@alogic0
alogic0 / paskha.html
Created April 16, 2023 17:44
Orthodox Easter Calculator
<!DOCTYPE html>
<html>
<head>
<title>Orthodox Easter Calculator</title>
</head>
<body>
<h1>Orthodox Easter Calculator</h1>
<p>Enter a year and see the year day for Orthodox Easter using Gauss formula.</p>
<label for="year">Year:</label>
<input type="number" id="year" min="0" max="9999">
@alogic0
alogic0 / paskha.zig
Last active April 12, 2023 22:47
calc orthodox Easter day
const std = @import("std");
const expect = std.testing.expect;
const expectEqualDeep = std.testing.expectEqualDeep;
const stdout = std.io.getStdOut().writer();
const stderr = std.io.getStdErr().writer();
const cumdaytab = [_][14]i32{
[_]i32{ 0, -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364 },
[_]i32{ 0, -1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
@alogic0
alogic0 / reverse_codepoint.zig
Last active April 9, 2023 16:54
reverse utf-8 strings, codepoints only
const std = @import("std");
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
fn reverse_string(str: []const u8) ![]u8 {
var len = str.len;
var out = try allocator.alloc(u8, len);
var str_iter = (try std.unicode.Utf8View.init(str)).iterator();