Skip to content

JakeRoggenbuck/planck-reboot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Planck Lang Reboot

Planck Lang compiler, standard library sources, and a reference .plk -> .c compiler.

History

About five years ago, my friend Adam and I wrote a standard library / spec and the start of a compiler for a language called Planck. It was one of many languages and compilers we tried to write. Planck was never finished, but the spec still exists, so I gave it to Codex to see if it could make a grammer definition, a compiler, and a standard library. The grammer was easy, the compiler seems to work for most standard cases, but the standard library does not compile correctly because of limitations in the compiler.

Lessons Learned

It seems like either the standard library has contradictory features that prevented Codex from making a compiler that worked to compile it, or Codex couldn't capture all of those features in its implementation. My guess is a latter based on the code I've read. The specific issues are the use of generic types, incorrectly using self when it's undefined, etc.

image

Generative AI does still seem rather far from being able to build an entire compiler, even with many examples, but it's getting a lot closer every month. I will likely return to this in another five years to see if it can make a completely functional language using our Planck syntax.

The following in 100% AI generated with Codex and GPT 5.2.

Repository Layout

  • src/: existing stdlib .plk files (io, list, math, struct)
  • docs/grammar.md: formal language grammar
  • docs/language-guide.md: language and compiler usage docs
  • compiler/: lexer, tokenizer, parser, and C code generator
  • examples/: runnable sample .plk programs

Quick Start

python3 -m compiler.plkc examples/basic.plk -o /tmp/basic.c
gcc -std=c11 -Wall -Wextra -o /tmp/basic /tmp/basic.c
/tmp/basic

Hello World + Math Example

Planck source (examples/hello_math.plk)

add(a: int, b: int): int {
    return a + b;
}

main(): int {
    nout("Hello, Planck!");
    int result = add(2, 3);
    nout(result);
    return 0;
}

Compile to C

python3 -m compiler.plkc examples/hello_math.plk -o /tmp/hello_math.c
gcc -std=c11 -Wall -Wextra -o /tmp/hello_math /tmp/hello_math.c

Generated C (/tmp/hello_math.c)

#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>

int add(int a, int b);
int main(void);

int add(int a, int b) {
    return (a + b);
}

int main(void) {
    printf("%s\\n", "Hello, Planck!");
    int result = add(2, 3);
    printf("%d\\n", result);
    return 0;
}

Program Output

Hello, Planck!
5

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages