/*
 * This file is part of Beastie <https://purl.org/nxg/dist/beastie>
 * SPDX-FileCopyrightText: 2025 Norman Gray <https://nxg.me.uk>
 * SPDX-License-Identifier: BSD-2-Clause
 */

#ifndef PARSE_JSON_H
#define PARSE_JSON_H 1

#include <stdio.h>
#include "yycommon.h"

struct json_extra_s {
    void* yyscanbuf;            // cast from YY_BUFFER_STATE
    char* path;                 // source file
    FILE* f;
};
typedef struct json_extra_s* json_extra_t;

yyscan_t parse_json_setup_file(json_extra_t extra, const char* path);
yyscan_t parse_json_setup_string(json_extra_t extra, const char* s);
void parse_json_finish(json_extra_t extra, yyscan_t scanner);
int jsonlex(YYSTYPE* lvalp, YYLTYPE* llocp, yyscan_t scanner);
int jsonget_lineno(yyscan_t);

// defined in parse-json.y
int jsonparse(json_extra_t, s7_pointer* parse_result, yyscan_t scanner);

#endif /* PARSE_JSON_H */
