Advanced Hello World in Zig - Loris Cro (34:50) Oct 13, 2020
stdout, stderr, logging
| <!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"> |
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
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):
- 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.
| 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. |
| ✦ 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 |
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.
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.
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.
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.
To move from a flat stream of tokens to a Syntax Tree, we need to define how tokens relate to each other hierarchically.
In Tree-sitter, the goal is to create a Concrete Syntax Tree (CST). Unlike an Abstract Syntax Tree (AST), which throws away "useless" characters like parentheses or semicolons, a CST keeps everything so that the code can be reconstructed exactly as it was written.
In Zig, we want this to be memory-efficient. Instead of using pointers for every child (which causes cache misses), we can use an index-based approach.
pub const NodeId = u32;Since you're architecting a high-performance parser for large-scale data (like your work with millions of records), Zig's approach to memory is your greatest ally. It avoids the "hidden" costs of garbage collection by making every allocation explicit.
In Zig, if a function needs memory, it must ask for an Allocator.
Zig does not have a global heap. Instead, you pass an Allocator (an interface) to any structure—like your Parser—that needs to grow.
- Explicit Control: You decide if memory lives on the stack, the heap, or a fixed-size buffer.
- The
deferKeyword: To prevent memory leaks, Zig usesdeferto ensure memory is freed as soon as the scope closes. - Safety: Using the
GeneralPurposeAllocator(GPA) during development will catch memory leaks and "double-frees" immediately.