GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - StarOne01/my-kaleidoscope: Building the LLVM Kaleidoscope language from scratch in C++, out loud and in public. Lexer first. Dishum comes later.

BranchesTags
Open more actions menu

Latest commit

 

History

13 Commits
13 Commits

Folders and files

NameName
Last commit message
Last commit date
AST.cpp
AST.cpp
 
 
README.md
README.md
 
 
lexer.cpp
lexer.cpp
 
 

Repository files navigation

my-kaleidoscope

Twist a kaleidoscope and one picture shatters into a hundred pieces. A compiler does the reverse: it takes the pieces and makes something that runs.

My from-scratch build of Kaleidoscope, the toy language from the LLVM tutorial, written in C++. Started 30 Sep 2026. Seven commits in, and the lexer already has more comments than logic. That's on purpose.

Status: day one. hhaaa Expect rough edges, bugs I haven't found yet, and commit messages with too many exclamation marks.

The pipeline

Source code goes in one end. Each stage hands something simpler to the next.

Stage What it does Status
Lexer Chops raw characters into tokens done, i guess
Parser Builds an AST from the tokens Planned
Codegen Turns the AST into LLVM IR Planned
Optimizer Runs a few LLVM passes over the IR Planned
JIT Runs the code on the spot Planned

What the lexer sees so far

Token Meaning
tokDef the def keyword
tokExtern the extern keyword
tokIdentifier names like foo, _bar2
tokNum numbers like 3.14, stored in numVal
tokEof end of input
anything else returned as its raw ASCII value (+, (, , ...)

Comments start with # and run to the end of the line.

The language

Kaleidoscope is small enough to hold in your head. It has functions, extern declarations, floating-point numbers and # comments. Later I want to add control flow and user-defined operators. The syntax below is a sketch and will shift as the parser takes shape.

# a function
def add(a b) a + b

# call something from the C library
extern sin(x)

Build

clang++ -std=c++17 *.cpp -o kaleidoscope
./kaleidoscope

Once codegen lands this will also need LLVM (llvm-config --cxxflags --ldflags). I'll update the instructions when that happens.

How I'm working

  • One stage at a time, in order: lexer, parser, codegen, JIT.
  • Commits are prefixed with the stage, like [lexer].
  • The comments in the code are notes to myself, and I'm keeping them.
  • Bugs are part of the process. If you spot one, open an issue. I'd rather find it early.

Roadmap

  • Working lexer
  • Recursive-descent parser and AST
  • LLVM IR codegen
  • Optimization passes
  • JIT
  • Control flow (if, for) and user-defined operators

Credits

Follows the official LLVM Kaleidoscope tutorial. Mistakes are mine.

About

Building the LLVM Kaleidoscope language from scratch in C++, out loud and in public. Lexer first. Dishum comes later.

Resources

Readme
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.