Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

Implements a complete C library for parsing, serializing, and validating TAML documents with JSON/XML/YAML format conversion capabilities.

Core Components

  • Parser (src/parser.c) - Deserializes TAML to C structs with type inference (int, float, bool, string, null)
  • Serializer (src/serializer.c) - Converts C structs back to TAML with proper tab indentation
  • Validator (src/validator.c) - Enforces TAML spec rules (tabs-only indentation, no tabs in content, indentation consistency) with line-specific error reporting
  • Value API (src/value.c) - Create and manipulate TAML objects/arrays programmatically
  • Format Converters (src/converters.c) - Bidirectional JSON↔TAML conversion; XML/YAML stubs

API

// Parse TAML
const char *taml = "server\n\thost\tlocalhost\n\tport\t8080\n";
taml_document_t *doc = taml_parse(taml, NULL);

// Access values
taml_value_t *server = taml_object_get(doc->root, "server");
taml_value_t *port = taml_object_get(server, "port");
printf("Port: %lld\n", port->data.int_val);  // Port: 8080

// Validate
char error[256];
int line;
if (taml_validate(taml, error, sizeof(error), &line) != TAML_OK) {
    printf("Error at line %d: %s\n", line, error);
}

// Convert JSON to TAML
taml_document_t *from_json = taml_from_json("{\"key\": \"value\"}");
char *taml_output = taml_stringify(from_json, NULL);

Implementation Details

  • Pure C99, zero dependencies
  • Static (libtaml.a) and shared (libtaml.so) library builds
  • ~2,500 LOC across 6 source files
  • Comprehensive memory management with taml_free_* functions
  • Test coverage: parsing, serialization, validation, JSON conversion

Known Limitations

  • JSON converter uses fixed 4KB buffer (adequate for typical configs, not suitable for multi-MB JSON)
  • XML/YAML converters are stubs requiring external parser libraries for full implementation
Original prompt

This section details on the original issue you should resolve

<issue_title>We need a C implementation of a parser and validator of TAML</issue_title>
<issue_description>We need a parser in the C programming language that will be able to read TAML content and write TAML content by serializing and deserializing objects appropriately. I'd also like a validator that will let me know if valid TAML content has been submitted.

I'd also like to be able to have some conversion methods with that serializer that will let me convert easily from JSON XML and yaml format to TAML

Write this library into a child folder called "C"</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add C implementation of TAML parser and validator Add C implementation of TAML parser, validator, and format converters Dec 18, 2025
Copilot AI requested a review from csharpfritz December 18, 2025 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

We need a C implementation of a parser and validator of TAML

2 participants