Sha256: 079e0467f623be79f19815ae9b205eec00d0fa03683dfa543fedc3b1bcef94f2

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

#include "cdrafter.h"

#include "snowcrash.h"
#include "sosJSON.h"

#include "SerializeAST.h"
#include "SerializeSourcemap.h"
#include "SerializeResult.h"

#include <string.h>

namespace sc = snowcrash;

static char* ToString(const std::stringstream& stream) 
{
    size_t length = stream.str().length() + 1;
    char* str = (char*)malloc(length);
    memcpy(str, stream.str().c_str(), length);
    return str;
}

SC_API int drafter_c_parse(const char* source, 
                           sc_blueprint_parser_options options, 
                           char** result) 
{

    std::stringstream inputStream;

    inputStream << source;

    sc::ParseResult<sc::Blueprint> blueprint;
    sc::parse(inputStream.str(), options, blueprint);

    sos::SerializeJSON serializer;

    if (result) {
        std::stringstream resultStream;
        serializer.process(drafter::WrapResult(blueprint, options), resultStream);
        resultStream << "\n";
        *result = ToString(resultStream);
    }

    return blueprint.report.error.code;
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
redsnow-0.4.4 ext/drafter/src/cdrafter.cc
redsnow-0.4.3 ext/drafter/src/cdrafter.cc
redsnow-0.4.1 ext/drafter/src/cdrafter.cc
redsnow-0.4.0 ext/drafter/src/cdrafter.cc