Official C implementation of the UP (Unified Properties) language parser.
📚 API Documentation | 🧪 Test Status | 📖 Specification
Portable & Fast - ANSI C compatible, minimal dependencies
- ✅ Full UP Syntax Support - Scalars, blocks, lists, tables, multiline strings
- ✅ Type Annotations - Parse and preserve type hints (
!int
,!bool
, etc.) - ✅ ANSI C Compatible - Works with C89 and later
- ✅ Portable - Cross-platform (Linux, macOS, Windows, BSD)
- ✅ Well-Tested - Comprehensive test suite
- ✅ Minimal Dependencies - Only standard library
- ✅ CLI Tool - Command-line utility included
- C compiler (GCC, Clang, MSVC)
- make (or cmake)
git clone https://github.com/uplang/c
cd c
make
sudo make install
mkdir build && cd build
cmake ..
make
sudo make install
#include <up.h>
#include <stdio.h>
int main() {
up_parser_t *parser = up_parser_new();
const char *input =
"name Alice\n"
"age!int 30\n";
up_document_t *doc = up_parse_string(parser, input);
if (!doc) {
fprintf(stderr, "Parse error\n");
return 1;
}
// Access values
const char *name = up_doc_get_scalar(doc, "name");
printf("Name: %s\n", name);
// Cleanup
up_document_free(doc);
up_parser_free(parser);
return 0;
}
Compile and run:
gcc example.c -lup -o example
./example
📖 For detailed examples and tutorials, see QUICKSTART.md
- QUICKSTART.md - Getting started guide with examples
- DESIGN.md - Architecture and design decisions
- UP Specification - Complete language specification
up_parser_t
- Opaque parser handleup_document_t
- Parsed document handleup_node_t
- Key-value pair structureup_value_t
- Tagged union for value types
#include <up.h>
// Create parser
up_parser_t *parser = up_parser_new();
// Parse from string
up_document_t *doc = up_parse_string(parser, content);
// Parse from file
FILE *f = fopen("config.up", "r");
up_document_t *doc = up_parse_file(parser, f);
fclose(f);
// Access values
const char *name = up_doc_get_scalar(doc, "name");
// Cleanup
up_document_free(doc);
up_parser_free(parser);
See DESIGN.md for complete API documentation and implementation details.
# Parse and display
up-parse config.up
# Validate syntax
up-validate config.up
# Convert to JSON
up-convert config.up --format json
# Run all tests
make test
# Run with valgrind (memory leak detection)
make test-valgrind
# Run specific test
./tests/test_parser
c/
├── include/
│ └── up.h # Public API header
├── src/
│ ├── parser.c # Parser implementation
│ ├── types.c # Data structures
│ ├── memory.c # Memory management
│ └── cli.c # CLI tool
├── tests/
│ └── test_parser.c # Tests
├── Makefile
├── CMakeLists.txt
├── README.md # This file
├── QUICKSTART.md # Getting started guide
├── DESIGN.md # Architecture documentation
└── LICENSE # GNU GPLv3
Contributions are welcome! Please see the main CONTRIBUTING.md for guidelines.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
- UP Language Specification - Official language spec
- Syntax Reference - Quick syntax guide
- UP Namespaces - Official namespace plugins
- Go - Reference implementation
- Java - Modern Java 21+ with records and sealed types
- JavaScript/TypeScript - Browser and Node.js support
- Python - Pythonic implementation with dataclasses
- Rust - Zero-cost abstractions and memory safety
- Issues: github.com/uplang/c/issues
- Discussions: github.com/uplang/spec/discussions