<commit_before>/*
 * Copyright (C) 2015-2020 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef YDSH_YDSH_H
#define YDSH_YDSH_H

#include <stdio.h>

#ifdef __cplusplus
extern "C" {
#endif

struct DSState;
typedef struct DSState DSState;

/*********************/
/**     DSState     **/
/*********************/

typedef enum {
    DS_EXEC_MODE_NORMAL,
    DS_EXEC_MODE_PARSE_ONLY,
    DS_EXEC_MODE_CHECK_ONLY,
    DS_EXEC_MODE_COMPILE_ONLY,
} DSExecMode;

/**
 * create new DSState with DSExecMode
 * you can call DSState_delete() to release object.
 * @param mode
 * @return
 * if specified invalid mode, return null
 */
DSState *DSState_createWithMode(DSExecMode mode);

#define DSState_create() DSState_createWithMode(DS_EXEC_MODE_NORMAL)

/**
 * delete DSState. after release object, assign null to ctx.
 * @param st
 * may be null
 */
void DSState_delete(DSState **st);

/**
 * get DSExecMode.
 * @param st
 * may be null
 * @return
 * if st is null, return always DS_EXEC_MODE_NORMAL
 */
DSExecMode DSState_mode(const DSState *st);

/**
 * affect DSState_eval() result. (not affect DSState_loadAndEval())
 * @param st
 * @param lineNum
 * if st is null, do nothing
 */
void DSState_setLineNum(DSState *st, unsigned int lineNum);

/**
 * get line number after latest evaluation or setLineNum().<commit_msg>replace function macro from public header<commit_after>/*
 * Copyright (C) 2015-2020 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef YDSH_YDSH_H
#define YDSH_YDSH_H

#include <stdio.h>

#ifdef __cplusplus
extern "C" {
#endif

struct DSState;
typedef struct DSState DSState;

/*********************/
/**     DSState     **/
/*********************/

typedef enum {
    DS_EXEC_MODE_NORMAL,
    DS_EXEC_MODE_PARSE_ONLY,
    DS_EXEC_MODE_CHECK_ONLY,
    DS_EXEC_MODE_COMPILE_ONLY,
} DSExecMode;

/**
 * create new DSState with DSExecMode
 * you can call DSState_delete() to release object.
 * @param mode
 * @return
 * if specified invalid mode, return null
 */
DSState *DSState_createWithMode(DSExecMode mode);

static inline DSState *DSState_create() {
    return DSState_createWithMode(DS_EXEC_MODE_NORMAL);
}

/**
 * delete DSState. after release object, assign null to ctx.
 * @param st
 * may be null
 */
void DSState_delete(DSState **st);

/**
 * get DSExecMode.
 * @param st
 * may be null
 * @return
 * if st is null, return always DS_EXEC_MODE_NORMAL
 */
DSExecMode DSState_mode(const DSState *st);

/**
 * affect DSState_eval() result. (not affect DSState_loadAndEval())
 * @param st
 * @param lineNum
 * if st is null, do nothing
 */
void DSState_setLineNum(DSState *st, unsigned int lineNum);

/**
 * get line number after latest evaluation or setLineNum().
{'fraction_non_alphanumeric': 0.11463087248322147, 'fraction_numerical': 0.006442953020134228, 'mean_word_length': 4.111111111111111, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4582989', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1146, 'n_words': 409}