When a parsed expression's source has no raw-text marker and no NUL byte, the parser keeps each expression's text and name directly from the source slice through KeepTextSlice, instead of copying, terminating and rescanning it first. Both paths end at keep_text's canonical pointer for the same bytes, so kept pointers and generated C are unchanged.
131 lines
4.5 KiB
C
131 lines
4.5 KiB
C
/* Generated by zi2c from compiler_parse.zi. */
|
|
#ifndef ZIRAN_COMPILER_PARSE_H
|
|
#define ZIRAN_COMPILER_PARSE_H
|
|
|
|
#include <stdbool.h>
|
|
#include "zir_string_types.h"
|
|
#include "zir_slice.h"
|
|
#ifdef ZIRAN_COMPILER_PARSE_H_PRIVATE
|
|
#ifndef ZIRAN_TYPE_FORWARD_TokenText
|
|
#define ZIRAN_TYPE_FORWARD_TokenText
|
|
typedef struct TokenText TokenText;
|
|
#endif
|
|
#endif
|
|
#ifndef ZIRAN_TYPE_FORWARD_ExprStatementCursor
|
|
#define ZIRAN_TYPE_FORWARD_ExprStatementCursor
|
|
typedef struct ExprStatementCursor ExprStatementCursor;
|
|
#endif
|
|
#ifdef ZIRAN_COMPILER_PARSE_H_PRIVATE
|
|
#ifndef ZIRAN_TYPE_FORWARD_ExprText
|
|
#define ZIRAN_TYPE_FORWARD_ExprText
|
|
typedef struct ExprText ExprText;
|
|
#endif
|
|
#endif
|
|
#ifdef ZIRAN_COMPILER_PARSE_H_PRIVATE
|
|
#ifndef ZIRAN_TYPE_FORWARD_PreparedDefault
|
|
#define ZIRAN_TYPE_FORWARD_PreparedDefault
|
|
typedef struct PreparedDefault PreparedDefault;
|
|
#endif
|
|
#endif
|
|
#ifdef ZIRAN_COMPILER_PARSE_H_PRIVATE
|
|
#ifndef ZIRAN_TYPE_FORWARD_Parser
|
|
#define ZIRAN_TYPE_FORWARD_Parser
|
|
typedef struct Parser Parser;
|
|
#endif
|
|
#endif
|
|
#include "compiler_expression.h"
|
|
#include "compiler_ir.h"
|
|
#include "compiler_scan.h"
|
|
#include "compiler_services.h"
|
|
#include "compiler_text.h"
|
|
#include "compiler_type.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
#ifdef ZIRAN_COMPILER_PARSE_H_PRIVATE
|
|
|
|
struct TokenText {
|
|
uint8_t* data;
|
|
size_t count;
|
|
};
|
|
#endif
|
|
|
|
struct ExprStatementCursor {
|
|
void* text;
|
|
size_t length;
|
|
int32_t base_line;
|
|
int32_t line;
|
|
size_t at;
|
|
};
|
|
#ifdef ZIRAN_COMPILER_PARSE_H_PRIVATE
|
|
|
|
struct ExprText {
|
|
uint8_t* data;
|
|
size_t count;
|
|
};
|
|
#endif
|
|
#ifdef ZIRAN_COMPILER_PARSE_H_PRIVATE
|
|
|
|
struct PreparedDefault {
|
|
String text;
|
|
bool valid;
|
|
};
|
|
#endif
|
|
#ifdef ZIRAN_COMPILER_PARSE_H_PRIVATE
|
|
|
|
struct Parser {
|
|
ZirFunction* fn;
|
|
ZirModule* module;
|
|
ZirSourceSpan span;
|
|
String source;
|
|
String expected_type;
|
|
int32_t stmt_index;
|
|
int32_t default_depth;
|
|
bool failed;
|
|
int32_t depth;
|
|
Scan token;
|
|
int64_t span_offset;
|
|
ZirSourceSpan span_cursor;
|
|
int32_t checks;
|
|
bool plain_source;
|
|
};
|
|
#endif
|
|
void CompilerLexerInit(ZirLexer* lexer, void* source, void* path);
|
|
ZirToken LexerNext(ZirLexer* lexer);
|
|
ZirToken LexerNextCode(ZirLexer* lexer);
|
|
uint8_t* CompilerTokenKindName(int32_t kind);
|
|
int32_t CompilerParseExpr(ZirFunction* fn, ZirModule* module, void* text, ZirSourceSpan span);
|
|
int32_t CompilerParseExprNoDefaults(ZirFunction* fn, ZirModule* module, void* text, ZirSourceSpan span);
|
|
int32_t CompilerParseExprTyped(ZirFunction* fn, ZirModule* module, void* text, ZirSourceSpan span, void* expected);
|
|
int32_t CompilerDefineIsAggregate(ZirModule* module, ZirDefine* definition);
|
|
int32_t CompilerCallerLocationLiteral(ZirModule* module, ZirSourceSpan span, void* output, size_t capacity);
|
|
int32_t* ExpressionOwners(ZirFunction* fn);
|
|
int32_t ExpressionLexicalCallTarget(ZirFunction* fn, int32_t index, int32_t statement, uint8_t* output, size_t capacity);
|
|
size_t ExprSavedCursorLength(ExprStatementCursor* cursor, void* text, int32_t line);
|
|
int64_t ExprSavedSourceOffset(ExprStatementCursor* cursor, void* text, ZirSourceSpan base, ZirSourceSpan span);
|
|
void CompilerStructureFunction(ZirFunction* fn, ZirModule* module);
|
|
bool compiler_parse_ExpandCallDefaults(ZirFunction* fn, ZirModule* module, ZirSourceSpan span, int32_t stmt_index, int32_t callee, int32_t* first, int32_t* last, int32_t depth);
|
|
int32_t compiler_parse_ParseExpression(ZirFunction* fn, ZirModule* module, String text, ZirSourceSpan span, String expected_type, int32_t stmt_index, int32_t default_depth);
|
|
int32_t compiler_parse_ParseExpressionFrom(ZirFunction* fn, ZirModule* module, String text, ZirSourceSpan span, String expected_type, int32_t stmt_index, int32_t default_depth, bool plain_source);
|
|
|
|
/* Small procedures other modules inline; compiler_parse.c defines them. */
|
|
#if !defined(__cplusplus) && !defined(ZIRAN_COMPILER_PARSE_H_SOURCE) && !defined(ZIRAN_NO_HEADER_INLINE)
|
|
#include <stdbool.h>
|
|
#include "zir_string_types.h"
|
|
static inline int32_t compiler_parse_ParseExpression_ziran_inline(ZirFunction* fn, ZirModule* module, String text, ZirSourceSpan span, String expected_type, int32_t stmt_index, int32_t default_depth);
|
|
#define compiler_parse_ParseExpression(...) compiler_parse_ParseExpression_ziran_inline(__VA_ARGS__)
|
|
|
|
static inline int32_t
|
|
compiler_parse_ParseExpression_ziran_inline(ZirFunction* fn, ZirModule* module, String text, ZirSourceSpan span, String expected_type, int32_t stmt_index, int32_t default_depth)
|
|
{
|
|
return compiler_parse_ParseExpressionFrom(fn, module, text, span, expected_type, stmt_index, default_depth, false);
|
|
}
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* ZIRAN_COMPILER_PARSE_H */
|