Prompt builder
Describe the program you want. The page adds a compact NanoC syntax card and gives you one prompt to paste into any chat or coding agent. Everything stays in your browser.
Syntax card included in the prompt
NanoC card (alpha). NanoC -> plain C11. Indent 2 spaces, no braces/semicolons. Unrecognized lines are plain C.
FILE +stdio,stdlib (includes, bare name adds .h) | + <x.h> | + "x.h"
FUNC f name | f name(a: int, b: int) int | f get(int x,lo,hi) int ; result type optional (void; main is int); last expression is the result; < v early return; < alone in void
LOCAL n := 0 (literal infers int/double/char/str) | x: Type = expr | int a[] = {1,2} | calls and arithmetic need x: Type = expr
FLOW if c / elif c / else | while c | for i := 0; i < n; i++ | ! break | ^ continue
TYPES s Name a,b: int (struct) | u Name (union) | e Color red,green=5 (enum) ; pointers *T ; arrays/function pointers: exact C
PRE $ N = 1 define | $ F(x) = ((x)*2) | $- N | ?+ N ifdef | ?- N ifndef | ?# expr if | :# expr elif | : else | !! "msg" error | dedent = endif
MACRO @m twice($x) newline-indented body ((($x)*2)) ; use @twice(3) ; captures $a, $b:block, $c:ident, variadic ...
TT @tt then indented program: x := [] ; push(x,v) ; for i range(n) ; str() join() split() replace() len() slice() find() ; emit("C text") ; emit(quote(int a = $n;))
RAW @c { C code } | @c indented | @c "C string"
EXAMPLE
+stdio
s Point
x,y: double
f dist2(p: Point) double
p.x*p.x + p.y*p.y
f main
Point p = {3, 4}
for i := 0; i < 2; i++
printf("%d %g\n", i, dist2(p))
0
RULES comments are // ; no classes, generics, exceptions or GC; use malloc/free; compile with: nanoc run file.nc ; check: nanoc check file.nc --json
Tips for better results
- Ask for one small file first, then iterate; compile with
nanoc check file.nc --jsonand paste the errors back. - Name the headers and libraries you want. Unmarked C passes through, so any C API works.
- For agents,
nanoc help syntaxprints the same card, and llms-full.txt holds the whole guide in a token-saving form.