_ ____ _ _ ___ _ ____ ____ _ _ _ _____ _____ _______
/ \ | _ \| \ | |/ _ \| | | _ \ / ___| | \ | | / \|_ _|_ _\ \ / / ____|
/ _ \ | |_) | \| | | | | | | | | | | | \| | / _ \ | | | | \ \ / /| _|
/ ___ \| _ <| |\ | |_| | |___| |_| | |___ | |\ |/ ___ \| | | | \ V / | |___
/_/ \_\_| \_\_| \_|\___/|_____|____/ \____| |_| \_/_/ \_\_| |___| \_/ |_____|
FORK WITH NATIVE CODE GENERATION - "I'LL BE BACK"
This is a fork of ArnoldC that adds native code generation capabilities. Instead of only outputting JVM bytecode, this version can generate:
- Freestanding C code for bare-metal programming
- x86 Assembly for direct hardware control
- Complete kernel packages ready to boot
# Original JVM bytecode (unchanged)
arnoldc hello.arnoldc # → hello.class
# NEW: Generate C code
arnoldc -native hello.arnoldc # → hello.c
# NEW: Generate x86 assembly
arnoldc -asm hello.arnoldc # → hello.asm
# NEW: Generate full kernel package
arnoldc -kernel mykernel.arnoldcWe've added Arnold quotes for systems programming:
| Keyword | C Equivalent | Arnold Quote Origin |
|---|---|---|
I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MEMORY |
malloc() |
Terminator |
YOU'RE LUGGAGE |
free() |
Commando |
WHAT'S WRONG WITH YOUR EYES |
*(ptr) read |
Total Recall |
SEE YOU AT THE PARTY |
*(ptr) = write |
Total Recall |
| Keyword | C Equivalent | Arnold Quote Origin |
|---|---|---|
TALK TO THE PORT |
outb(port, val) |
- |
LISTEN TO THE PORT |
inb(port) |
- |
| Keyword | C Equivalent | Arnold Quote Origin |
|---|---|---|
EVERYBODY CHILL |
cli (disable IRQ) |
Batman & Robin |
LET'S PARTY |
sti (enable IRQ) |
- |
SLEEP NOW |
hlt |
- |
| Keyword | C Equivalent | Arnold Quote Origin |
|---|---|---|
CRUSH THEM |
& (AND) |
- |
JOIN THEM |
| (OR) |
- |
CONFUSE THEM |
^ (XOR) |
- |
PUSH LEFT |
<< |
- |
PUSH RIGHT |
>> |
- |
| Keyword | C Equivalent |
|---|---|
SPEAK TO THE MACHINE |
__asm__("...") |
THE MACHINE SAYS |
End of asm block |
| Keyword | C Equivalent |
|---|---|
THESE ARE MY OPTIONS |
enum name { |
OPTION |
Enum value |
NO MORE OPTIONS |
} |
| Keyword | C Equivalent |
|---|---|
LET ME TELL YOU SOMETHING |
#define |
BRING IN |
#include |
IF YOU KNOW |
#ifdef |
IF YOU DON'T KNOW |
#ifndef |
THAT'S ALL I KNOW |
#endif |
ONLY ONCE |
#pragma once |
| Keyword | C Equivalent |
|---|---|
TALK TO YOURSELF "..." |
/* ... */ |
LET ME THINK ABOUT THIS |
/* multiline |
I'VE THOUGHT ABOUT IT |
*/ end |
| Keyword | C Equivalent |
|---|---|
YOU ARE NOT YOU YOU ARE ME |
== |
YOU ARE NOT ME |
!= |
LET OFF SOME STEAM BENNET |
> |
YOU'RE AT LEAST AS BIG AS |
>= |
YOU'RE NOT BIG ENOUGH |
< |
YOU'RE NOT BIGGER THAN |
<= |
THAT'S A LIE |
! (logical NOT) |
TURN IT AROUND |
~ (bitwise NOT) |
IT'S SHOWTIME
TALK TO THE HAND "ArnoldC Kernel Booting..."
HEY CHRISTMAS TREE vgaBuffer
YOU SET US UP 753664
HEY CHRISTMAS TREE character
YOU SET US UP 65
EVERYBODY CHILL
SEE YOU AT THE PARTY vgaBuffer character
LET'S PARTY
TALK TO THE HAND "Kernel initialized!"
SLEEP NOW
YOU HAVE BEEN TERMINATED
This compiles to actual kernel code that:
- Disables interrupts
- Writes 'A' to VGA memory (0xB8000)
- Enables interrupts
- Halts the CPU
# Ubuntu/Debian
sudo apt install openjdk-11-jdk scala sbt
# Build the compiler
sbt assembly# Run the test suite
sbt testTests cover:
- Parser tests for all syntax features
- Code generator tests for C output
- Type system tests
- Control flow tests
- Bitwise operation tests
# Compile your ArnoldC kernel
java -jar ArnoldC-Native.jar -kernel mykernel.arnoldc
# This generates:
# - mykernel_kernel.c (C code)
# - arnold_runtime.h (Runtime header)
# - Makefile (Build system)
# Build the kernel (requires cross-compiler)
make
# Run in QEMU
make run┌─────────────────────────────────────────────────────────┐
│ ArnoldC Source │
│ IT'S SHOWTIME ... TERMINATED │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ ArnoldParser │
│ (Parboiled PEG) │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ Abstract Syntax Tree │
│ RootNode → MethodNode → StatementNode │
└─────────────────────────────────────────────────────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
┌───────────────────┐ ┌─────────┐ ┌─────────────┐
│ JVM Generator │ │ Native │ │ ASM │
│ (Original ASM) │ │ Gen (C) │ │ Generator │
└───────────────────┘ └─────────┘ └─────────────┘
│ │ │
▼ ▼ ▼
.class .c .asm
(JVM) (GCC/Clang) (NASM)
│ │
└─────┬──────┘
▼
┌─────────────────┐
│ Kernel Binary │
│ (Bootable!) │
└─────────────────┘
- Parsing: Same Parboiled parser as original ArnoldC
- AST: Extended with new node types for kernel ops
- Code Generation: New
NativeGeneratorclass that:- Walks the AST
- Outputs freestanding C code
- Maps Arnold quotes to C constructs
- Compilation: GCC cross-compiler builds native binary
- Linking: Custom linker script places code at 1MB
- Booting: GRUB or direct QEMU multiboot
- Single tool - One compiler, multiple backends
- Proper AST - Work with parsed structure, not text
- Extensible - Easy to add new keywords
- Maintainable - Changes to parser benefit all backends
- Authentic - It's still ArnoldC, just enhanced
- All original ArnoldC programs work unchanged
- New keywords only needed for kernel-specific ops
- JVM output identical to original compiler
-nativeand-kernelare additive features
- The JVM backend (default mode,
-run) only supports original ArnoldC syntax - New native-mode keywords (memory ops, port I/O, inline assembly, etc.) will fail in JVM mode
- To use extended features, you must compile with
-native,-asm, or-kernelflags - Reason: JVM bytecode cannot represent raw memory access or hardware instructions
- The codebase defines ~194 AST node classes, but only ~46 have parser rules
- The remaining ~150 nodes are planned future extensions and currently unparseable
- Categories of planned nodes (not yet implemented in parser):
- Advanced bitwise operations (bit set/clear/toggle, masks, rotation, population count)
- CPU-specific instructions (CPUID, RDTSC, RDMSR, WRMSR, control register access)
- Advanced control flow (else-if chains, infinite loops, panic/assert)
- Function attributes (inline, noreturn, aligned, static, section, ISR handlers)
- Advanced preprocessor directives (elif, conditional compilation, line directives)
- Advanced assembly (page table operations, memory fences, TLB invalidation)
- Type system extensions (typedefs, bitfields, packed structs, anonymous structs)
- Advanced arrays (dynamic arrays, slices, nested initializers, extern declarations)
- Callback registration system
- Documentation comments
- See
src/main/scala/org/arnoldc/ast/AstNode.scalafor the full list - If you need these features, you must add parser rules to
ArnoldParserExtended.scala
- Kernel mode (
-kernelflag) generates a Makefile that requires:i686-elf-gcccross-compiler (not standard GCC)linker.ldfile (must be created manually - not auto-generated)- NASM assembler for any assembly components
- The generated Makefile is a template and may need customization for your kernel
- QEMU testing (
make run) assumes a multiboot-compatible kernel structure
- For the definitive list of working keywords, see the tables in the README
- All keywords in the "New Keywords for Kernel Programming" section work in
-native/-asm/-kernelmodes - Original ArnoldC keywords work in all modes (JVM and native)
- Fork this repo
- Add your Arnold quotes
- Implement the AST node
- Add to NativeGenerator
- Submit PR with "I'LL BE BACK"
Apache 2.0 (same as original ArnoldC)
"Come with me if you want to boot." - ArnoldC Kernel
"I'll be back." - Every kernel after a reboot
"Consider that a divorce." - When unmounting filesystems
"Get to the chopper!" - Memory allocation
"You have been terminated." - Process exit
- Original ArnoldC: Lauri Hartikk
- Native Extension: Claude Code
- Inspiration: The Governator himself