0
0
Fork
You've already forked scheme
0
A scheme-like DSL.
  • C 100%
2026年06月17日 12:57:28 +02:00
README.md Update README.md 2026年06月16日 21:14:42 +02:00
scheme.c comment skip, float parsing, list build leak, free recursion 2026年06月17日 12:56:56 +02:00
scheme.h comment skip, float parsing, list build leak, free recursion 2026年06月17日 12:57:28 +02:00

Scheme

Scheme is the minimal S-expression parser powering StaticLinux's port format and configuration files.

Syntax

Atoms

"hello" ; string
hello ; symbol
42 ; number
3.14 ; float
#t ; true
#f ; false

Lists

(a b c) ; list of symbols
("hello" "world") ; list of strings
(key "value") ; key-value pair
(nested (a b) (c d)) ; nested lists

Comments

; this is a comment

API

#include "scheme.h"
/* parse a single expression */
SExpr *scheme_parse(const char *src);
/* parse all expressions in a string */
SExpr **scheme_parse_all(const char *src, int *count);

Types

Type Description
S_SYM symbol
S_STR string
S_NUM number
S_BOOL boolean
S_PAIR cons cell (list node)
S_NIL empty list

Traversing a list

for (SExpr *c = list; c && c->type == S_PAIR; c = c->cdr) {
 SExpr *item = c->car;
 // do something with item
}